fix for mantis 297

This commit is contained in:
Jeff Hill
2007-08-23 17:46:28 +00:00
parent a8d4a7a879
commit de1b8a94ff
15 changed files with 56 additions and 50 deletions

View File

@@ -50,7 +50,7 @@ void CASG::destructor (
this->magic = 0;
}
else {
this->printf ( "cac: attempt to destroy invalid sync group ignored\n" );
this->printFormated ( "cac: attempt to destroy invalid sync group ignored\n" );
}
this->~CASG ();
}
@@ -257,14 +257,14 @@ void CASG::recycleSyncGroupReadNotify (
this->freeListReadOP.release ( & io );
}
int CASG::printf ( const char *pformat, ... )
int CASG :: printFormated ( const char *pformat, ... )
{
va_list theArgs;
int status;
va_start ( theArgs, pformat );
status = this->client.vPrintf ( pformat, theArgs );
status = this->client.varArgsPrintFormated ( pformat, theArgs );
va_end ( theArgs );

View File

@@ -97,7 +97,7 @@ ca_client_context::ca_client_context ( bool enablePreemptiveCallback ) :
if ( this->sock == INVALID_SOCKET ) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
this->printf (
this->printFormated (
"ca_client_context: unable to create "
"datagram socket because = \"%s\"\n",
sockErrBuf );
@@ -112,7 +112,7 @@ ca_client_context::ca_client_context ( bool enablePreemptiveCallback ) :
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
epicsSocketDestroy ( this->sock );
this->printf (
this->printFormated (
"%s: non blocking IO set fail because \"%s\"\n",
__FILE__, sockErrBuf );
throwWithLocation ( noSocket () );
@@ -132,7 +132,7 @@ ca_client_context::ca_client_context ( bool enablePreemptiveCallback ) :
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
epicsSocketDestroy (this->sock);
this->printf (
this->printFormated (
"CAC: unable to bind to an unconstrained "
"address because = \"%s\"\n",
sockErrBuf );
@@ -148,12 +148,12 @@ ca_client_context::ca_client_context ( bool enablePreemptiveCallback ) :
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
epicsSocketDestroy ( this->sock );
this->printf ( "CAC: getsockname () error was \"%s\"\n", sockErrBuf );
this->printFormated ( "CAC: getsockname () error was \"%s\"\n", sockErrBuf );
throwWithLocation ( noSocket () );
}
if ( tmpAddr.sa.sa_family != AF_INET) {
epicsSocketDestroy ( this->sock );
this->printf ( "CAC: UDP socket was not inet addr family\n" );
this->printFormated ( "CAC: UDP socket was not inet addr family\n" );
throwWithLocation ( noSocket () );
}
this->localPort = htons ( tmpAddr.ia.sin_port );
@@ -256,7 +256,7 @@ void ca_client_context::registerForFileDescriptorCallBack (
// should block here until releated callback in progress completes
}
int ca_client_context::printf (
int ca_client_context :: printFormated (
const char *pformat, ... ) const
{
va_list theArgs;
@@ -264,14 +264,14 @@ int ca_client_context::printf (
va_start ( theArgs, pformat );
status = this->ca_client_context::vPrintf ( pformat, theArgs );
status = this->ca_client_context :: varArgsPrintFormated ( pformat, theArgs );
va_end ( theArgs );
return status;
}
int ca_client_context::vPrintf (
int ca_client_context :: varArgsPrintFormated (
const char *pformat, va_list args ) const // X aCC 361
{
caPrintfFunc * pFunc;
@@ -283,7 +283,7 @@ int ca_client_context::vPrintf (
return ( *pFunc ) ( pformat, args );
}
else {
return ::vfprintf ( stderr, pformat, args );
return :: vfprintf ( stderr, pformat, args );
}
}
@@ -359,8 +359,9 @@ void ca_client_context::signal ( int ca_status, const char * pfilenm,
va_end ( theArgs );
}
void ca_client_context::vSignal ( int ca_status, const char *pfilenm,
int lineno, const char *pFormat, va_list args )
void ca_client_context :: vSignal (
int ca_status, const char *pfilenm,
int lineno, const char *pFormat, va_list args )
{
static const char *severity[] =
{
@@ -374,27 +375,27 @@ void ca_client_context::vSignal ( int ca_status, const char *pfilenm,
"Fatal"
};
this->printf ( "CA.Client.Exception...............................................\n" );
this->printFormated ( "CA.Client.Exception...............................................\n" );
this->printf ( " %s: \"%s\"\n",
this->printFormated ( " %s: \"%s\"\n",
severity[ CA_EXTRACT_SEVERITY ( ca_status ) ],
ca_message ( ca_status ) );
if ( pFormat ) {
this->printf ( " Context: \"" );
this->vPrintf ( pFormat, args );
this->printf ( "\"\n" );
this->printFormated ( " Context: \"" );
this->varArgsPrintFormated ( pFormat, args );
this->printFormated ( "\"\n" );
}
if ( pfilenm ) {
this->printf ( " Source File: %s line %d\n",
this->printFormated ( " Source File: %s line %d\n",
pfilenm, lineno );
}
epicsTime current = epicsTime::getCurrent ();
char date[64];
current.strftime ( date, sizeof ( date ), "%a %b %d %Y %H:%M:%S.%f");
this->printf ( " Current Time: %s\n", date );
this->printFormated ( " Current Time: %s\n", date );
/*
* Terminate execution if unsuccessful
@@ -405,7 +406,7 @@ void ca_client_context::vSignal ( int ca_status, const char *pfilenm,
abort ();
}
this->printf ( "..................................................................\n" );
this->printFormated ( "..................................................................\n" );
}
void ca_client_context::show ( unsigned level ) const

View File

@@ -602,12 +602,13 @@ void cac::disconnectAllIO (
}
}
int cac::printf ( epicsGuard < epicsMutex > & callbackControl,
const char *pformat, ... ) const
int cac :: printFormated (
epicsGuard < epicsMutex > & callbackControl,
const char * pformat, ... ) const
{
va_list theArgs;
va_start ( theArgs, pformat );
int status = this->vPrintf ( callbackControl, pformat, theArgs );
int status = this->varArgsPrintFormated ( callbackControl, pformat, theArgs );
va_end ( theArgs );
return status;
}

View File

@@ -182,9 +182,11 @@ public:
// diagnostics
unsigned circuitCount ( epicsGuard < epicsMutex > & ) const;
void show ( epicsGuard < epicsMutex > &, unsigned level ) const;
int printf ( epicsGuard < epicsMutex > & callbackControl,
int printFormated (
epicsGuard < epicsMutex > & callbackControl,
const char *pformat, ... ) const;
int vPrintf ( epicsGuard < epicsMutex > & callbackControl,
int varArgsPrintFormated (
epicsGuard < epicsMutex > & callbackControl,
const char *pformat, va_list args ) const;
// buffer management
@@ -356,12 +358,12 @@ inline epicsMutex & cac::mutexRef ()
return this->mutex;
}
inline int cac::vPrintf (
inline int cac :: varArgsPrintFormated (
epicsGuard < epicsMutex > & callbackControl,
const char *pformat, va_list args ) const
{
callbackControl.assertIdenticalMutex ( this->cbMutex );
return this->notify.vPrintf ( pformat, args );
return this->notify.varArgsPrintFormated ( pformat, args );
}
inline void cac::attachToClientCtx ()

View File

@@ -287,7 +287,7 @@ public:
epicsGuard < epicsMutex > &, int status, const char * pContext,
const char * pFileName, unsigned lineNo ) = 0;
// perhaps this should be phased out in deference to the exception mechanism
virtual int vPrintf ( const char * pformat, va_list args ) const = 0;
virtual int varArgsPrintFormated ( const char * pformat, va_list args ) const = 0;
// backwards compatibility (from here down)
virtual void attachToClientCtx () = 0;
virtual void callbackProcessingInitiateNotify () = 0;

View File

@@ -328,8 +328,8 @@ public:
void uninstallCASG ( epicsGuard < epicsMutex > &, CASG & );
void selfTest () const;
// perhaps these should be eliminated in deference to the exception mechanism
int printf ( const char * pformat, ... ) const;
int vPrintf ( const char * pformat, va_list args ) const;
int printFormated ( const char * pformat, ... ) const;
int varArgsPrintFormated ( const char * pformat, va_list args ) const;
void signal ( int ca_status, const char * pfilenm,
int lineno, const char * pFormat, ... );
void vSignal ( int ca_status, const char * pfilenm,

View File

@@ -69,12 +69,12 @@ epicsTimerNotify::expireStatus repeaterSubscribeTimer::
static const unsigned nTriesToMsg = 50;
if ( this->attempts > nTriesToMsg && ! this->once ) {
callbackManager mgr ( this->ctxNotify, this->cbMutex );
this->iiu.printf ( mgr.cbGuard,
this->iiu.printFormated ( mgr.cbGuard,
"CA client library is unable to contact CA repeater after %u tries.\n",
nTriesToMsg );
this->iiu.printf ( mgr.cbGuard,
this->iiu.printFormated ( mgr.cbGuard,
"Silence this message by starting a CA repeater daemon\n") ;
this->iiu.printf ( mgr.cbGuard,
this->iiu.printFormated ( mgr.cbGuard,
"or by calling ca_pend_event() and or ca_poll() more often.\n" );
this->once = true;
}

View File

@@ -36,7 +36,7 @@ public:
virtual ~repeaterTimerNotify () = 0;
virtual void repeaterRegistrationMessage (
unsigned attemptNumber ) = 0;
virtual int printf (
virtual int printFormated (
epicsGuard < epicsMutex > & callbackControl,
const char * pformat, ... ) = 0;
};

View File

@@ -182,7 +182,7 @@ public:
unsigned type, arrayElementCount count, const void * pValue );
void completionNotify (
epicsGuard < epicsMutex > &, syncGroupNotify & );
int printf ( const char * pFormat, ... );
int printFormated ( const char * pFormat, ... );
void exception (
epicsGuard < epicsMutex > &, int status, const char * pContext,
const char * pFileName, unsigned lineNo );

View File

@@ -79,7 +79,7 @@ void syncGroupReadNotify::completion (
arrayElementCount count, const void * pData )
{
if ( this->magic != CASG_MAGIC ) {
this->sg.printf (
this->sg.printFormated (
"cac: sync group io_complete(): bad sync grp op magic number?\n" );
return;
}
@@ -98,7 +98,7 @@ void syncGroupReadNotify::exception (
unsigned type, arrayElementCount count )
{
if ( this->magic != CASG_MAGIC ) {
this->sg.printf (
this->sg.printFormated (
"cac: sync group io_complete(): bad sync grp op magic number?\n" );
return;
}

View File

@@ -76,7 +76,7 @@ void syncGroupWriteNotify::completion (
epicsGuard < epicsMutex > & guard )
{
if ( this->magic != CASG_MAGIC ) {
this->sg.printf ( "cac: sync group io_complete(): bad sync grp op magic number?\n" );
this->sg.printFormated ( "cac: sync group io_complete(): bad sync grp op magic number?\n" );
return;
}
this->sg.completionNotify ( guard, *this );
@@ -89,7 +89,7 @@ void syncGroupWriteNotify::exception (
int status, const char *pContext, unsigned type, arrayElementCount count )
{
if ( this->magic != CASG_MAGIC ) {
this->sg.printf ( "cac: sync group io_complete(): bad sync grp op magic number?\n" );
this->sg.printFormated ( "cac: sync group io_complete(): bad sync grp op magic number?\n" );
return;
}
this->sg.exception ( guard, status, pContext,

View File

@@ -1184,7 +1184,7 @@ bool tcpiiu::processIncoming (
// check for 8 byte aligned protocol
if ( this->curMsg.m_postsize & 0x7 ) {
this->printf ( mgr.cbGuard,
this->printFormated ( mgr.cbGuard,
"CAC: server sent missaligned payload 0x%x\n",
this->curMsg.m_postsize );
return false;
@@ -1203,7 +1203,7 @@ bool tcpiiu::processIncoming (
this->curDataMax = this->cacRef.largeBufferSizeTCP ();
}
else {
this->printf ( mgr.cbGuard,
this->printFormated ( mgr.cbGuard,
"CAC: not enough memory for message body cache (ignoring response message)\n");
}
}
@@ -1229,7 +1229,7 @@ bool tcpiiu::processIncoming (
else {
static bool once = false;
if ( ! once ) {
this->printf ( mgr.cbGuard,
this->printFormated ( mgr.cbGuard,
"CAC: response with payload size=%u > EPICS_CA_MAX_ARRAY_BYTES ignored\n",
this->curMsg.m_postsize );
once = true;
@@ -1945,7 +1945,7 @@ void tcpiiu::uninstallChan (
}
}
int tcpiiu::printf (
int tcpiiu :: printFormated (
epicsGuard < epicsMutex > & cbGuard,
const char *pformat, ... )
{
@@ -1956,7 +1956,7 @@ int tcpiiu::printf (
va_start ( theArgs, pformat );
status = this->cacRef.vPrintf ( cbGuard, pformat, theArgs );
status = this->cacRef.varArgsPrintFormated ( cbGuard, pformat, theArgs );
va_end ( theArgs );

View File

@@ -1102,7 +1102,8 @@ void udpiiu::govExpireNotify (
this->ppSearchTmr[0]->installChannel ( guard, chan );
}
int udpiiu::printf ( epicsGuard < epicsMutex > & cbGuard,
int udpiiu :: printFormated (
epicsGuard < epicsMutex > & cbGuard,
const char * pformat, ... )
{
va_list theArgs;
@@ -1110,7 +1111,7 @@ int udpiiu::printf ( epicsGuard < epicsMutex > & cbGuard,
va_start ( theArgs, pformat );
status = this->cacRef.vPrintf ( cbGuard, pformat, theArgs );
status = this->cacRef.varArgsPrintFormated ( cbGuard, pformat, theArgs );
va_end ( theArgs );

View File

@@ -255,7 +255,8 @@ private:
// repeaterTimerNotify
void repeaterRegistrationMessage (
unsigned attemptNumber );
int printf (
int printFormated (
epicsGuard < epicsMutex > & callbackControl,
const char * pformat, ... );

View File

@@ -158,7 +158,7 @@ public:
epicsGuard < epicsMutex > & );
osiSockAddr getNetworkAddress (
epicsGuard < epicsMutex > & ) const;
int printf (
int printFormated (
epicsGuard < epicsMutex > & cbGuard,
const char *pformat, ... );
unsigned channelCount (