#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#include <time.h>
#include "global.h"
#include "genlib.h"
#include "storage.h"
int i;
static uint32 lastHtml = 0;
uint32 now = getzulutime(NULL);
+ time_t now_val;
char udate[256], ustime[256];
static char timeFormat[] = "%Y-%m-%d %T";
htmlFile[0] = 0; /* Suppress further updates */
return;
}
-
- strftime(udate, sizeof udate, timeFormat, gmtime((time_t *) &now));
- strftime(ustime, sizeof ustime, timeFormat, gmtime((time_t *) &upsince));
+
+ now_val = now;
+ strftime(udate, sizeof udate, timeFormat, gmtime(&now_val));
+ time_t upsince_val = upsince;
+ strftime(ustime, sizeof ustime, timeFormat, gmtime(&upsince_val));
fprintf(hf, "\
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n\
strcpy(udate, "<td colspan=2 align=center><em>Never contacted</em>");
strcpy(ustime, "");
} else {
- strftime(udate, sizeof udate, "<td align=center>%Y-%m-%d %T", gmtime((time_t *) &eggtable[i].lastupd));
- strftime(ustime, sizeof ustime, "<td align=center>%Y-%m-%d %T", gmtime((time_t *) &eggStatistics[i].firstPacket));
+ time_t lastupd_val = eggtable[i].lastupd;
+ strftime(udate, sizeof udate, "<td align=center>%Y-%m-%d %T", gmtime(&lastupd_val));
+ time_t firstPacket_val = eggStatistics[i].firstPacket;
+ strftime(ustime, sizeof ustime, "<td align=center>%Y-%m-%d %T", gmtime(&firstPacket_val));
}
if (eggtable[i].url == NULL) {
url1[0] = url2[0] = 0;
coverage = 100;
}
- fprintf(hf, "<td align=center>%ld<td align=center>%ld<td align=center>%ld%%<td align=center>%.3f\n",
+ fprintf(hf, "<td align=center>%d<td align=center>%d<td align=center>%d%%<td align=center>%.3f\n",
eggStatistics[i].trials,
eggStatistics[i].missing,
coverage,
</html>\n");
fclose(hf);
#ifdef DEBUG
+ now_val = now;
fprintf(stderr, "Updating HTML file %s at %s",
- htmlFile, asctime(gmtime((time_t *) &now)));
+ htmlFile, asctime(gmtime(&now_val)));
#endif
}
}
memcpy(&egg_now_time, pktbuf + 6, sizeof egg_now_time);
egg_now_time = ntohl(egg_now_time);
- fprintf(stderr, "Awake egg %d (%s) at its %lu: %s",
+ time_t egg_now_time_val = egg_now_time;
+ fprintf(stderr, "Awake egg %d (%s) at its %u: %s",
pkt_eggid, eggtable[thisegg].name, egg_now_time,
- asctime(gmtime((time_t *) &egg_now_time)));
+ asctime(gmtime(&egg_now_time_val)));
}
#endif
EggHeader packet. */
dpktp = &dpk;
- unpackShort(dpk.type);
- unpackShort(dpk.pktsize);
- unpackShort(dpk.eggid);
- unpackShort(dpk.samp_rec);
- unpackShort(dpk.sec_rec);
- unpackShort(dpk.rec_pkt);
- unpackByte(dpk.trialsz);
- unpackShort(dpk.numrec);
+ unpack16(dpk.type);
+ unpack16(dpk.pktsize);
+ unpack16(dpk.eggid);
+ unpack16(dpk.samp_rec);
+ unpack16(dpk.sec_rec);
+ unpack16(dpk.rec_pkt);
+ unpack8(dpk.trialsz);
+ unpack16(dpk.numrec);
/* This spoofing test is probably completely redundant now. */
#ifndef EGG_DYNAMIC
char *spktp = pktP;
if (result.hdr.numrec > 0) {
- unpackLong(stamp);
+ unpack32(stamp);
}
pktP = spktp;
fprintf(stderr, "Received packet: %d records from egg %d (%s).\n",
transcribe to the result EggCarton. */
for (latest = 0, rec = 0; rec < result.hdr.numrec; rec++) {
- unpackLong(result.records[rec].timestamp); /* Record timestamp */
+ unpack32(result.records[rec].timestamp); /* Record timestamp */
if (result.records[rec].timestamp > latest)
latest = result.records[rec].timestamp;
#ifdef DEBUG
- fprintf(stderr, " %10lu ", result.records[rec].timestamp);
+ fprintf(stderr, " %10u ", result.records[rec].timestamp);
#endif
/* Assumes sizeof(trial) = 1 */
- unpackBytes(&(result.records[rec].trials), result.hdr.samp_rec);
+ unpack8s(&(result.records[rec].trials), result.hdr.samp_rec);
#ifdef DEBUG
for (i = 0; i < result.hdr.samp_rec; i++) {
fprintf(stderr, "%3d ", result.records[rec].trials[i]);
}
- fprintf(stderr, "%s", asctime(gmtime((time_t *) &result.records[rec].timestamp)));
+ time_t timestamp_val = result.records[rec].timestamp;
+ fprintf(stderr, "%s", asctime(gmtime(×tamp_val)));
#endif
}
static void MakeRequest(ReqPacket *pkt, uint16 eggid, uint32 whence) {
char *pktP = (char *) pkt;
- packShort(REQ_PACKET);
- packShort((4 * sizeof(uint16)) + sizeof(uint32));
- packShort(eggid);
- packLong(whence);
+ pack16(REQ_PACKET);
+ pack16((4 * sizeof(uint16)) + sizeof(uint32));
+ pack16(eggid);
+ pack32(whence);
}
/* MakeSettings -- Create a settings packet. This packet,
static void MakeSettings(SettingsPacket *pkt, uint16 eggid) {
char *pktP = (char *) pkt;
- packShort(SETTINGS_PACKET);
- packShort((7 * sizeof(uint16)) + sizeof(uint32) + sizeof(trial));
- packShort(eggid);
- packLong(getzulutime(NULL));
- packShort(protocol.samp_rec);
- packShort(protocol.sec_rec);
- packShort(protocol.rec_pkt);
- packByte(protocol.trialsz);
+ pack16(SETTINGS_PACKET);
+ pack16((7 * sizeof(uint16)) + sizeof(uint32) + sizeof(trial));
+ pack16(eggid);
+ pack32(getzulutime(NULL));
+ pack16(protocol.samp_rec);
+ pack16(protocol.sec_rec);
+ pack16(protocol.rec_pkt);
+ pack8(protocol.trialsz);
}
/* LoadEggStats -- Initialise in-memory egg status table
fprintf(fp, "# Status lines of form:\n");
fprintf(fp, "# STAT <eggname> <eggid> <lastupdzulu> <setupvalid>\n");
for (i = 0; i < numeggs; i++) {
- fprintf(fp, "STAT %s %d %ld %d\n",
+ fprintf(fp, "STAT %s %d %u %d\n",
eggtable[i].name,
eggtable[i].id,
eggtable[i].lastupd,