SNMP Subagent Programmer's Guide
Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-79
System Time Manager
static int
TEST_systemTimeString(void *ctxt, void **indices, void *attr_ref) <-- 12
{
OCTETSTRING *attr;
short dnt[8]; /* COMPUTETIMESTAMP date-n-time array */
short err; /* COMPUTETIMESTAMP error mask */
attr = (OCTETSTRING *) attr_ref;
/* convert string in *attr to broken-down time */
if (attr->len != 19) /* probably not correct format */ <-- 13
{ return(SNMP_ERR_BAD_VALUE); }
if (sscanf(attr->val, "%4hu/%2hu/%2hu %2hu:%2hu:%2hu", <-- 14
/* YYYY/MM/DD HH:MM:SS */
&dnt[0],&dnt[1],&dnt[2],&dnt[3],&dnt[4],&dnt[5])
/* YYYY MM DD HH MM SS */
!= 6 /* items in scan string */ )
{ return(SNMP_ERR_BAD_VALUE); }
dnt[6] = dnt[7] = 0; /* clear milliseconds and microseconds fields */
/* convert to guardian-style 64-bit julian time stamp */
juliantime = COMPUTETIMESTAMP(dnt,&err); <-- 15
if (err) { return(SNMP_ERR_BAD_VALUE); }
/* convert local civil time to GMT */
juliantime = CONVERTTIMESTAMP(juliantime, 2 /*LCT->GMT*/, /*node*/, &err); <-- 16
if (err) { return(SNMP_ERR_BAD_VALUE); }
return(SNMP_ERR_NO_ERROR);
}
Example 2-16. System Time Manager Access Functions (page 2 of 2)