Guardian Programmer's Guide

Table Of Contents
Managing Time
Guardian Programmer’s Guide 421922-014
18 - 28
Setting the System Clock
unsigned long t;
long long JulianGMT;
char *p;
int result;
puts("SSCK: SETSYSTEMCLOCK utility\n"
"(c) Copyright 2012 Hewlett-Packard Development "
"Company, L.P.\n");
if (argc < 2 || argc > 4) {
puts("Provide one to three parameters:\n"
" 1st is mode (short, required)\n"
" 2nd is 'julianGMT' (long long, depends on mode, "
"sometimes opt)\n"
" 3rd is TUID (short, optional)");
return (argc > 4);
}
t = strtoul(argv[1], &p, 10);
if (*p || t == 0 && errno || t > 999)
return printf("Invalid mode: %s\n", argv[1]), 1;
mode = (short)t;
if (argc > 2) {
JulianGMT = strtoll(argv[2], &p, 10);
if (*p || JulianGMT == 0 & errno)
return printf("Invalid JulianGMT: %s\n", argv[2]), 1;
if (argc > 3) {
t = strtoul(argv[3], &p, 10);
if (*p || t == 0 && errno || t > 65535)
return printf("Invalid TUID: %s\n", argv[3]), 1;
tuid = (short)t;
}
}
printf("SETSYSTEMCLOCK(");
if (argc > 2) printf("%lld", JulianGMT);
printf(", %d", mode);
if (argc > 3) printf(", %d", tuid);
result = SETSYSTEMCLOCK(_optional(argc > 2, JulianGMT),
mode,
_optional(argc > 3, tuid));
printf(") => %d\n", result);
}
This example can be copied to a file named ssckc and compiled with TNS/E native C
as follows:
ccomp /in ssckc/ssck;suppress,extensions,symbols,runnable
Using the SETTIME Command
You rarely need to use the SETTIME command. For most systems, you need to use
SETTIME only when the system is first cold loaded. Only on older hardware is it
necessary to reset the system time following each cold load or power failure.