本文整理汇总了C++中radMsgLog函数的典型用法代码示例。如果您正苦于以下问题:C++ radMsgLog函数的具体用法?C++ radMsgLog怎么用?C++ radMsgLog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了radMsgLog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sprintf
char *sensorGetHighDate (WV_SENSOR *sensor, char *store, char *dateFormat)
{
struct tm locTime;
if (sensor->time_high == (time_t)0)
{
sprintf (store, "----------");
}
else
{
if (sensor->debug)
{
radMsgLog(PRI_MEDIUM, "SENSOR HIGHDATE DBG: "
"low: %.2f, time_low: %u, high: %.2f, time_high: %u,"
"samples: %d",
sensor->low,
(unsigned int)sensor->time_low,
sensor->high,
(unsigned int)sensor->time_high,
sensor->samples);
}
localtime_r(&sensor->time_high, &locTime);
strftime(store, WV_MAX_DATE_LENGTH-1, dateFormat, &locTime);
if (sensor->debug)
{
radMsgLog(PRI_MEDIUM, "SENSOR HIGHDATE RESULT DBG: %s", store);
}
}
return store;
}
示例2: writeDataRefresh
// Expects the medium to already be open:
static int writeDataRefresh (WVIEWD_WORK *work)
{
uint8_t rqstBuffer[8], readBuffer[8];
int retVal;
rqstBuffer[0] = 0xA2; // One byte write command
rqstBuffer[1] = 0;
rqstBuffer[2] = 0x1A;
rqstBuffer[3] = 0x20;
rqstBuffer[4] = 0xA2;
rqstBuffer[5] = 0xAA;
rqstBuffer[6] = 0;
rqstBuffer[7] = 0x20;
retVal = (*(work->medium.usbhidWrite))(&work->medium, rqstBuffer, 8);
if (retVal != 8)
{
radMsgLog (PRI_HIGH, "WH1080: write data ACK failed!");
return ERROR;
}
// Read 8-byte ACK:
retVal = (*(work->medium.usbhidRead))(&work->medium, readBuffer, 8, 1000);
if (retVal != 8)
{
radMsgLog (PRI_HIGH, "WH1080: read data ACK failed!");
return ERROR;
}
return OK;
}
示例3: procmonSysInit
// system initialization
static int procmonSysInit (WVIEW_PMON_WORK *work)
{
char devPath[256], temp[64];
struct stat fileData;
// check for our daemon's pid file, don't run if it isn't there
sprintf (devPath, "%s/%s", WVIEW_RUN_DIR, WVD_LOCK_FILE_NAME);
if (stat (devPath, &fileData) != 0)
{
radMsgLogInit (PROC_NAME_PMON, TRUE, TRUE);
radMsgLog (PRI_CATASTROPHIC,
"wviewd process not running - aborting!");
radMsgLogExit ();
return ERROR;
}
sprintf (work->pidFile, "%s/%s", WVIEW_RUN_DIR, PMON_LOCK_FILE_NAME);
sprintf (work->fifoFile, "%s/dev/%s", WVIEW_RUN_DIR, PROC_NAME_PMON);
sprintf (work->statusFile, "%s/%s", WVIEW_STATUS_DIRECTORY, PMON_STATUS_FILE_NAME);
sprintf (work->daemonQname, "%s/dev/%s", WVIEW_RUN_DIR, PROC_NAME_DAEMON);
sprintf (work->wviewdir, "%s", WVIEW_RUN_DIR);
// check for our pid file, don't run if it IS there
if (stat (work->pidFile, &fileData) == 0)
{
radMsgLogInit (PROC_NAME_PMON, TRUE, TRUE);
radMsgLog (PRI_CATASTROPHIC,
"lock file %s exists, older copy may be running - aborting!",
work->pidFile);
radMsgLogExit ();
return ERROR;
}
return OK;
}
示例4: stationGetPosition
// station-supplied function to retrieve positional info (lat, long, elev) -
// should populate 'work' fields: latitude, longitude, elevation
// -- Synchronous --
//
// - If station does not store these parameters, they can be retrieved from the
// wview.conf file (see daemon.c for example conf file use) - user must choose
// station type "Generic" when running the wviewconfig script
//
// Returns: OK or ERROR
//
int stationGetPosition (WVIEWD_WORK *work)
{
// just set the values from our internal store - we retrieved them in
// stationInit
work->elevation = (short)ws2300WorkData.elevation;
if (ws2300WorkData.latitude >= 0)
work->latitude = (short)((ws2300WorkData.latitude*10)+0.5);
else
work->latitude = (short)((ws2300WorkData.latitude*10)-0.5);
if (ws2300WorkData.longitude >= 0)
work->longitude = (short)((ws2300WorkData.longitude*10)+0.5);
else
work->longitude = (short)((ws2300WorkData.longitude*10)-0.5);
radMsgLog (PRI_STATUS, "station location: elevation: %d feet",
work->elevation);
radMsgLog (PRI_STATUS, "station location: latitude: %3.1f %c longitude: %3.1f %c",
(float)abs(work->latitude)/10.0,
((work->latitude < 0) ? 'S' : 'N'),
(float)abs(work->longitude)/10.0,
((work->longitude < 0) ? 'W' : 'E'));
return OK;
}
示例5: readFixedBlock
// Expects the medium to already be open:
static int readFixedBlock(WVIEWD_WORK *work, uint8_t* block)
{
// Read fixed block:
if (readBlock(work, 0, block) == ERROR)
{
radMsgLog (PRI_HIGH, "WH1080: readFixedBlock readBlock failed");
return ERROR;
}
// Check for valid magic numbers:
// This is hardly an exhaustive list and I can find no definitive
// documentation that lists all possible values; further, I suspect it is
// more of a header than a magic number...
if ((block[0] == 0x55) ||
(block[0] == 0xFF) ||
(block[0] == 0x01) ||
((block[0] == 0x00) && (block[1] == 0x1E)) ||
((block[0] == 0x00) && (block[1] == 0x01)))
{
return OK;
}
else
{
radMsgLog (PRI_HIGH, "WH1080: readFixedBlock bad magic number %2.2X %2.2X",
(int)block[0], (int)block[1]);
radMsgLog(PRI_HIGH,
"WH1080: You may want to clear the memory on the station "
"console to remove any invalid records or data...");
return ERROR_ABORT;
}
}
示例6: pushLoopToClients
static void pushLoopToClients(LOOP_PKT* loopData)
{
WVIEW_ALARM_CLIENT *client, *oldClient;
LOOP_PKT networkLoop;
datafeedConvertLOOP_HTON(&networkLoop, loopData);
// Push to each socket client:
for (client = (WVIEW_ALARM_CLIENT *) radListGetFirst (&alarmsWork.clientList);
client != NULL;
client = (WVIEW_ALARM_CLIENT *) radListGetNext (&alarmsWork.clientList,
(NODE_PTR)client))
{
// write the frame start so clients may sync to the beginning of each
// data update
if (radSocketWriteExact (client->client,
(void *)DF_LOOP_START_FRAME,
DF_START_FRAME_LENGTH)
!= DF_START_FRAME_LENGTH)
{
// write error, bail on this guy
radMsgLog (PRI_HIGH, "LOOP: write error to client %s:%d - closing socket...",
radSocketGetHost (client->client),
radSocketGetPort (client->client));
statusDecrementStat(ALARM_STATS_CLIENTS);
radProcessIODeRegisterDescriptorByFd(radSocketGetDescriptor(client->client));
radSocketDestroy (client->client);
oldClient = client;
client = (WVIEW_ALARM_CLIENT *)
radListGetPrevious (&alarmsWork.clientList, (NODE_PTR)client);
radListRemove (&alarmsWork.clientList, (NODE_PTR)oldClient);
free (oldClient);
continue;
}
// write out the loop data in network byte order:
if (radSocketWriteExact(client->client, &networkLoop, sizeof(networkLoop))
!= sizeof(networkLoop))
{
// write error, bail on this guy
radMsgLog (PRI_HIGH, "LOOP: write error to client %s:%d - closing socket...",
radSocketGetHost (client->client),
radSocketGetPort (client->client));
statusDecrementStat(ALARM_STATS_CLIENTS);
radProcessIODeRegisterDescriptorByFd(radSocketGetDescriptor(client->client));
radSocketDestroy (client->client);
oldClient = client;
client = (WVIEW_ALARM_CLIENT *)
radListGetPrevious (&alarmsWork.clientList, (NODE_PTR)client);
radListRemove (&alarmsWork.clientList, (NODE_PTR)oldClient);
free (oldClient);
continue;
}
statusIncrementStat(ALARM_STATS_PKTS_SENT);
}
return;
}
示例7: queryParmValue
// Query for a parameter value - it is converted to the proper format later:
static int queryParmValue (const char* configItem, char* valueStore)
{
char query[DB_SQLITE_QUERY_LENGTH_MAX];
SQLITE_RESULT_SET_ID result;
SQLITE_ROW_ID rowDescr;
SQLITE_FIELD_ID field;
if (sqliteID == NULL)
{
radMsgLog (PRI_HIGH, "queryParmValue: sqliteID is NULL!");
return ERROR;
}
sprintf (query, "SELECT value FROM config WHERE name = '%s'", configItem);
if (radsqliteQuery(sqliteID, query, TRUE) == ERROR)
{
radMsgLog (PRI_MEDIUM,
"queryParmValue: radsqliteQuery %s failed!", configItem);
return ERROR;
}
result = radsqliteGetResults (sqliteID);
if (result == NULL)
{
radMsgLog (PRI_MEDIUM,
"queryParmValue: radsqliteGetResults failed!");
return ERROR;
}
// We have a result, return it to the caller:
rowDescr = radsqliteResultsGetFirst (result);
if (rowDescr == NULL)
{
radMsgLog (PRI_MEDIUM,
"queryParmValue: radsqliteResultsGetFirst failed!");
radsqliteReleaseResults (sqliteID, result);
return ERROR;
}
field = radsqliteFieldGet (rowDescr, configCOLUMN_VALUE);
if (field == NULL)
{
radMsgLog (PRI_MEDIUM,
"queryParmValue: radsqliteFieldGet failed!");
radsqliteReleaseResults (sqliteID, result);
return ERROR;
}
memcpy (valueStore,
radsqliteFieldGetCharValue(field),
radsqliteFieldGetCharLength(field));
valueStore[radsqliteFieldGetCharLength(field)] = 0;
// Clean up:
radsqliteReleaseResults (sqliteID, result);
return OK;
}
示例8: defaultSigHandler
static void defaultSigHandler (int signum)
{
int retVal;
switch (signum)
{
case SIGHUP:
// user wants us to change the verbosity setting
retVal = wvutilsToggleVerbosity ();
radMsgLog (PRI_STATUS, "wvcwopd: SIGHUP - toggling log verbosity %s",
((retVal == 0) ? "OFF" : "ON"));
radProcessSignalCatch(signum, defaultSigHandler);
return;
case SIGPIPE:
// we have a far end socket disconnection, we'll handle it in the
// "read/write" code
radProcessSignalCatch(signum, defaultSigHandler);
break;
case SIGILL:
case SIGBUS:
case SIGFPE:
case SIGSEGV:
case SIGXFSZ:
case SIGSYS:
// unrecoverable radProcessSignalCatch- we must exit right now!
radMsgLog (PRI_CATASTROPHIC,
"wvcwopd: recv unrecoverable signal %d: aborting!",
signum);
abort ();
case SIGCHLD:
wvutilsWaitForChildren();
radProcessSignalCatch(signum, defaultSigHandler);
return;
default:
if (cwopWork.exiting)
{
radProcessSignalCatch(signum, defaultSigHandler);
return;
}
// Exit here in case the socket transaction is hung
statusUpdateMessage("exiting normally");
statusUpdate(STATUS_SHUTDOWN);
radMsgLog (PRI_HIGH, "wvcwopd: recv sig %d: exiting now!", signum);
radMsgRouterExit ();
cwopSysExit (&cwopWork);
radProcessExit ();
radSystemExit (WVIEW_SYSTEM_ID);
exit (0);
}
return;
}
示例9: SSHDefaultSigHandler
void SSHDefaultSigHandler (int signum)
{
int retVal;
switch (signum)
{
case SIGHUP:
// user wants us to change the verbosity setting
retVal = wvutilsToggleVerbosity ();
radMsgLog (PRI_STATUS, "wviewsshd: SIGHUP - toggling log verbosity %s",
((retVal == 0) ? "OFF" : "ON"));
radProcessSignalCatch(signum, SSHDefaultSigHandler);
return;
case SIGBUS:
case SIGFPE:
case SIGSEGV:
case SIGXFSZ:
case SIGSYS:
// unrecoverable radProcessSignalCatch- we must exit right now!
radMsgLog (PRI_CATASTROPHIC,
"wviewsshd: recv unrecoverable signal %d: aborting!",
signum);
if (!sshWork.exiting)
{
radTimerDelete (sshWork.timer);
sshSysExit (&sshWork);
radProcessExit ();
radSystemExit (WVIEW_SYSTEM_ID);
}
abort ();
case SIGCHLD:
// it is normal behavior to have children finishing up
wvutilsWaitForChildren();
radProcessSignalCatch(signum, SSHDefaultSigHandler);
break;
default:
// we can allow the process to exit normally...
if (sshWork.exiting)
{
radProcessSignalCatch(signum, SSHDefaultSigHandler);
return;
}
radMsgLog (PRI_HIGH, "wviewsshd: recv signal %d: exiting!", signum);
sshWork.exiting = TRUE;
radProcessSetExitFlag ();
radProcessSignalCatch(signum, SSHDefaultSigHandler);
break;
}
return;
}
示例10: daemonSysInit
/* ... system initialization
*/
static int daemonSysInit (WVIEWD_WORK *work)
{
char temp[256];
char *installPath;
struct stat fileData;
FILE *pidfile;
/* ... create our run directory if it is not there
*/
sprintf (temp, "%s", WVIEW_RUN_DIR);
if (stat (temp, &fileData) != 0)
{
if (mkdir (temp, 0755) != 0)
{
radMsgLogInit (PROC_NAME_DAEMON, TRUE, TRUE);
radMsgLog (PRI_CATASTROPHIC,
"Cannot create run directory: %s - aborting!",
temp);
radMsgLogExit ();
return -1;
}
}
/* ... create our device directory if it is not there
*/
sprintf (temp, "%s/dev", WVIEW_RUN_DIR);
if (stat (temp, &fileData) != 0)
{
if (mkdir (temp, 0755) != 0)
{
radMsgLogInit (PROC_NAME_DAEMON, TRUE, TRUE);
radMsgLog (PRI_CATASTROPHIC,
"Cannot create device directory: %s - aborting!",
temp);
radMsgLogExit ();
return -1;
}
}
sprintf (work->pidFile, "%s/%s", WVIEW_RUN_DIR, WVD_LOCK_FILE_NAME);
sprintf (work->fifoFile, "%s/dev/%s", WVIEW_RUN_DIR, PROC_NAME_DAEMON);
sprintf (work->statusFile, "%s/%s", WVIEW_STATUS_DIRECTORY, WVIEW_STATUS_FILE_NAME);
/* ... check for our pid file, don't run if it is there
*/
if (stat (work->pidFile, &fileData) == 0)
{
radMsgLogInit (PROC_NAME_DAEMON, TRUE, TRUE);
radMsgLog (PRI_CATASTROPHIC,
"lock file %s exists, older copy may be running - aborting!",
work->pidFile);
radMsgLogExit ();
return -1;
}
return 0;
}
示例11: defaultSigHandler
static void defaultSigHandler (int signum)
{
int retVal;
switch (signum)
{
case SIGHUP:
// user wants us to change the verbosity setting
retVal = wvutilsToggleVerbosity ();
radMsgLog (PRI_STATUS, "wviewd: SIGHUP - toggling log verbosity %s",
((retVal == 0) ? "OFF" : "ON"));
radProcessSignalCatch(signum, defaultSigHandler);
return;
case SIGPIPE:
// we have a far end socket disconnection, we'll handle it in the
// "read/write" code
radProcessSignalCatch(signum, defaultSigHandler);
break;
case SIGBUS:
case SIGFPE:
case SIGSEGV:
case SIGXFSZ:
case SIGSYS:
// unrecoverable radProcessSignalCatch- we must exit right now!
radMsgLog (PRI_CATASTROPHIC, "wviewd: recv sig %d: shutting down!", signum);
abort ();
case SIGCHLD:
wvutilsWaitForChildren();
radProcessSignalCatch(signum, defaultSigHandler);
return;
default:
// we can allow the process to exit normally...
if (wviewdWork.exiting)
{
radProcessSignalCatch(signum, defaultSigHandler);
return;
}
radMsgLog (PRI_HIGH, "wviewd: recv sig %d: exiting!", signum);
wviewdWork.exiting = TRUE;
radProcessSetExitFlag ();
radProcessSignalCatch(signum, defaultSigHandler);
break;
}
return;
}
示例12: ClientDataRX
static void ClientDataRX (int fd, void *userData)
{
RADSOCK_ID client = (RADSOCK_ID)userData;
int retVal;
ULONG dateTime;
retVal = datafeedSyncStartOfFrame(client);
switch (retVal)
{
case ERROR:
/* problems! - bail out */
statusUpdateMessage("ClientDataRX: socket error during sync - disconnecting");
radMsgLog (PRI_HIGH, "ClientDataRX: socket error during sync - disconnecting");
RemoveClient(client);
break;
case ERROR_ABORT:
// This guy has bailed out:
statusUpdateMessage("ClientDataRX: socket far-end closed");
radMsgLog (PRI_MEDIUM, "ClientDataRX: socket far-end closed");
RemoveClient(client);
break;
case FALSE:
radMsgLog (PRI_STATUS, "ClientDataRX: RX sync failure - ignoring");
break;
case DF_RQST_ARCHIVE_PKT_TYPE:
// OK, read the unix time sent to retrieve the record:
if (radSocketReadExact(client, (void *)&dateTime, sizeof(dateTime))
!= sizeof (dateTime))
{
statusUpdateMessage("ClientDataRX: socket read error - disconnecting");
radMsgLog (PRI_HIGH, "ClientDataRX: socket read error - disconnecting");
RemoveClient(client);
break;
}
// Convert from network byte order:
dateTime = ntohl(dateTime);
// Now we have the date and time, get busy:
SendNextArchiveRecord(client, dateTime);
break;
}
return;
}
示例13: dataFeedAccept
static void dataFeedAccept (int fd, void *userData)
{
RADSOCK_ID newConnection;
WVIEW_ALARM_CLIENT *client;
newConnection = radSocketServerAcceptConnection(alarmsWork.dataFeedServer);
if (newConnection == NULL)
{
statusUpdateMessage("dataFeed: accept connection failed!");
radMsgLog (PRI_MEDIUM, "dataFeed: accept connection failed!");
return;
}
// stick him on the data feed client list
client = (WVIEW_ALARM_CLIENT *) malloc(sizeof(*client));
if (client == NULL)
{
radMsgLog (PRI_MEDIUM, "dataFeedAccept: malloc failed!");
radSocketDestroy(newConnection);
return;
}
memset(client, 0, sizeof (*client));
client->client = newConnection;
radSocketSetBlocking(client->client, TRUE);
// add it to our descriptors of interest:
if (radProcessIORegisterDescriptor(radSocketGetDescriptor(client->client),
ClientDataRX,
(void*)client->client)
== ERROR)
{
statusUpdateMessage("dataFeedAccept: register descriptor failed!");
radMsgLog (PRI_MEDIUM, "dataFeedAccept: register descriptor failed!");
radSocketDestroy(client->client);
return;
}
radListAddToEnd(&alarmsWork.clientList, (NODE_PTR)client);
statusIncrementStat(ALARM_STATS_CLIENTS);
radMsgLog (PRI_STATUS, "dataFeed: client %s:%d accepted...",
radSocketGetHost (client->client),
radSocketGetPort (client->client));
return;
}
示例14: malloc
/* ... sets both value AND length
*/
int raddatabaseFieldSetCharValue
(
FIELD_ID id,
const char *value,
int valueLength
)
{
char *temp;
if (id->cvalLength < valueLength)
{
temp = (char *) malloc (valueLength+1);
if (temp == NULL)
{
radMsgLog(PRI_MEDIUM, "raddatabaseFieldSetCharValue: malloc failed!");
return ERROR;
}
free (id->cvalue);
id->cvalue = temp;
}
strncpy (id->cvalue, value, valueLength+1);
id->cvalLength = valueLength;
id->type &= ~FIELD_VALUE_IS_NULL;
raddatabaseFieldSetTypeChar (id);
return OK;
}
示例15: htmlIdleState
int htmlIdleState (int state, void *stimulus, void *data)
{
STIM *stim = (STIM *)stimulus;
HTML_WORK *work = (HTML_WORK *)data;
uint16_t year, month, day, hour, minute, second;
WVIEW_MSG_REQUEST msg;
switch (stim->type)
{
case STIM_DUMMY:
// this one starts this state machine - send the archive request
msg.requestType = WVIEW_RQST_TYPE_STATION_INFO;
if (radMsgRouterMessageSend (WVIEW_MSG_TYPE_REQUEST, &msg, sizeof(msg)) == ERROR)
{
radMsgLog (PRI_HIGH, "htmlIdleState: radMsgRouterMessageSend failed!");
statusUpdateMessage("radMsgRouterMessageSend failed!");
statusUpdate(STATUS_ERROR);
return HTML_STATE_ERROR;
}
// initialize the DST state change detector here
wvutilsDetectDSTInit ();
statusUpdate(STATUS_WAITING_FOR_WVIEW);
return HTML_STATE_STATION_INFO;
}
return state;
}