# Current protocol for egg
#
# PROTOCOL <samp_rec> <sec_rec> <rec_pkt> <trialsz>
-PROTOCOL 10 10 6 200
+PROTOCOL 10 10 30 200
#BASKET diesse 193.8.230.134
# noosphere -> diesse
-EGG noosphere 28 128.112.35.133 diesse PERM 1
-BASKET diesse 193.8.230.134
+#EGG noosphere 28 128.112.35.133 diesse PERM 1
+#BASKET diesse 193.8.230.134
# throop -> diesse
#EGG throop 1003 193.8.230.132 diesse PERM 1 http://www.fourmilab.ch/
#BASKET tonga 209.157.90.137
#BASKET tonga1 209.157.90.138
-PROTOCOL 10 10 6 200
+#PROTOCOL 10 10 6 200
#REG PEAR 2 9600
-REG PSEUDO 1 9600
+#REG PSEUDO 1 9600
#REG ORION 1 9600
-NETUP pppscript up
-NETDOWN pppscript down
+#NETUP pppscript up
+#NETDOWN pppscript down
+
+#egg.host.name ID# IP_address noosphere PERM 1
+#BASKET noosphere 128.112.35.133
+#PROTOCOL 10 10 30 200
+#REG ORION 0 9600
+#REG PEAR 0 9600
+
+EGG egg.almadaria.es 1066 195.57.79.136 noosphere PERM 1 http://egg.almadaria.es
+BASKET noosphere 128.112.35.133
+PROTOCOL 10 10 30 200
+REG ORION 0 9600
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,
on RISC machines which typically require values to be
aligned at an even multiple of their length. */
-#define packShort(x) { \
- short s = htons((short) (x)); \
- memcpy(pktP, &s, sizeof(short)); \
- pktP += sizeof(short); \
+#define pack16(x) { \
+ uint16 s = htons((uint16) (x)); \
+ memcpy(pktP, &s, sizeof(uint16)); \
+ pktP += sizeof(uint16); \
}
-#define packLong(x) { \
- long l = htonl((long) (x)); \
- memcpy(pktP, &l, sizeof(long)); \
- pktP += sizeof(long); \
+#define pack32(x) { \
+ uint32 i = htonl((uint32) (x)); \
+ memcpy(pktP, &i, sizeof(uint32)); \
+ pktP += sizeof(uint32); \
}
-#define packByte(x) { \
+#define pack8(x) { \
char c = (x); \
memcpy(pktP, &c, sizeof(char)); \
pktP += sizeof(char); \
}
-#define packBytes(x, n) { \
+#define pack8s(x, n) { \
memcpy(pktP, x, n); \
pktP += n; \
}
pktP. Note that the argument of these macros must be
an lvalue. */
-#define unpackShort(x) { \
- short s; \
- memcpy(&s, pktP, sizeof(short)); \
- pktP += sizeof(short); \
+#define unpack16(x) { \
+ uint16 s; \
+ memcpy(&s, pktP, sizeof(uint16)); \
+ pktP += sizeof(uint16); \
x = ntohs(s); \
}
-#define unpackLong(x) { \
- long l; \
- memcpy(&l, pktP, sizeof(long)); \
- pktP += sizeof(long); \
- x = ntohl(l); \
+#define unpack32(x) { \
+ uint32 i; \
+ memcpy(&i, pktP, sizeof(uint32)); \
+ pktP += sizeof(uint32); \
+ x = ntohl(i); \
}
-#define unpackByte(x) { \
+#define unpack8(x) { \
*((char *) &x) = (char) *pktP++; \
}
-#define unpackBytes(x, n) { \
+#define unpack8s(x, n) { \
memcpy(x, pktP, n); \
pktP += n; \
}
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#include <time.h>
#include "global.h"
#include "genlib.h"
char *pgmname; /* Program name from argv[0] */
char *myaddr; /* Interface to bind */
int16 myport; /* Service port to bind */
-int32 lastDataSent = 0; /* Time last packet sent to basket */
+uint32 lastDataSent = 0; /* Time last packet sent to basket */
/* If no priority increment has been specified at compile time, set to
our default of ±10. [+/- 10, for folks without 8bit editors] */
/* Status exported to user interface. */
-int32 time_latency = 0, time_housekeeping = 0;
+uint32 time_latency = 0, time_housekeeping = 0;
#ifdef ALT_UI
static double mean_Packet = 0.0, mean_Grand = 0.0;
}
#ifdef DEBUG
else {
- printf("REG configured: %s = %d, %d, %ld\n", configuredREG ->reg_name,
+ printf("REG configured: %s = %d, %d, %d\n", configuredREG ->reg_name,
devopts.type, devopts.port, devopts.baud);
}
#endif
totalTrials += ptrials;
mean_Grand = totalGrand / totalTrials;
total_Packets++;
- printf("Packets sent: %ld Packet mean: %6.2f Grand mean: %6.2f\n",
+ printf("Packets sent: %d Packet mean: %6.2f Grand mean: %6.2f\n",
total_Packets, mean_Packet, mean_Grand);
#endif
}
/* But let's be sure it really *is* in the interval. */
if (t.tv_sec < savebuffer.records[0].timestamp ||
t.tv_sec >= (savebuffer.records[0].timestamp + savebuffer.hdr.sec_rec * savebuffer.hdr.rec_pkt)) {
- fprintf(stderr, "***Sample, collected at %ld, is not within packet starting at %ld.\n",
+ fprintf(stderr, "***Sample, collected at %ld, is not within packet starting at %u.\n",
t.tv_sec, savebuffer.records[0].timestamp);
exit(-1);
}
uint32 stime;
char *pktP = pktbuf + (2 * sizeof(uint16));
- unpackShort(reggid);
- unpackLong(stime);
+ unpack16(reggid);
+ unpack32(stime);
#ifdef PACKETDUMP
- fprintf(stderr, "Request: eggid = %d, starttm = %ld: %s",
- reggid, stime, asctime(gmtime((time_t *) &stime)));
+ time_t stime_val = stime;
+ fprintf(stderr, "Request: eggid = %d, starttm = %u: %s\n",
+ reggid, stime, asctime(gmtime(&stime_val)));
#endif
res = LoadPacket(stime, reggid, &retrcart);
}
{ char *pktP = pktbuf + (3 * sizeof(uint16)) + sizeof(uint32);
- unpackShort(protocol.samp_rec);
- unpackShort(protocol.sec_rec);
- unpackShort(protocol.rec_pkt);
- unpackByte(protocol.trialsz);
+ unpack16(protocol.samp_rec);
+ unpack16(protocol.sec_rec);
+ unpack16(protocol.rec_pkt);
+ unpack8(protocol.trialsz);
}
#ifdef PACKETDUMP
fprintf(stderr, "Settings: samp_rec = %d, sec_rec = %d, rec_pkt = %d, trialsz = %d\n",
usec = time_latency;
msec = usec / 1000;
usec %= 1000;
- printf("Sampling latency: %ld.%03ld msec", msec, usec);
+ printf("Sampling latency: %d.%03d msec", msec, usec);
usec = time_housekeeping;
msec = usec / 1000;
usec %= 1000;
- printf(" Housekeeping time: %ld.%03ld msec\n", msec, usec);
+ printf(" Housekeeping time: %d.%03d msec\n", msec, usec);
#endif
lt = ct;
sleeptime = ((1000000 - SLACK) - ct.tv_usec);
static void MakeAwake(AwakePacket *pkt) {
char *pktP = (char *) pkt;
- packShort(AWAKE_PACKET);
- packShort((4 * sizeof(uint16)) + sizeof(uint32));
- packShort(eggtable[0].id);
- packLong(getzulutime(NULL));
+ pack16(AWAKE_PACKET);
+ pack16((4 * sizeof(uint16)) + sizeof(uint32));
+ pack16(eggtable[0].id);
+ pack32(getzulutime(NULL));
}
/* MakeDataPkt -- Build a canonical network byte order data packet
/* Assemble header fields into data packet. */
- packShort(src->hdr.type = DATA_PACKET);
- packShort(src->hdr.pktsize = pktsize);
- packShort(src->hdr.eggid);
- packShort(src->hdr.samp_rec);
- packShort(src->hdr.sec_rec);
- packShort(src->hdr.rec_pkt);
- packByte(src->hdr.trialsz);
- packShort(src->hdr.numrec);
+ pack16(src->hdr.type = DATA_PACKET);
+ pack16(src->hdr.pktsize = pktsize);
+ pack16(src->hdr.eggid);
+ pack16(src->hdr.samp_rec);
+ pack16(src->hdr.sec_rec);
+ pack16(src->hdr.rec_pkt);
+ pack8(src->hdr.trialsz);
+ pack16(src->hdr.numrec);
/* Append data records to packet. */
for (rec = 0; rec < src->hdr.numrec; rec++) {
- packLong(src->records[rec].timestamp);
- packBytes(&(src->records[rec].trials), src->hdr.samp_rec);
+ pack32(src->records[rec].timestamp);
+ pack8s(&(src->records[rec].trials), src->hdr.samp_rec);
}
/* No need to calculate CRC -- NetTalk does that for us.
#include "version.h"
#ifndef NO_UI
-static int32 inittm = 0;
+static uint32 inittm = 0;
#endif
-extern int32 lastDataSent;
-extern int32 time_latency, time_housekeeping;
+extern uint32 lastDataSent;
+extern uint32 time_latency, time_housekeeping;
/* Initialize user interface, as needed. */
int32 UIInit(void) {
if (coll->sampct == 1) {
line = 11;
- move(line++, 5); printw("Samples per record: %3d", (int)coll->opts.samp_rec);
- move(line++, 5); printw("Seconds per record: %3d", (int)coll->opts.sec_rec);
- move(line++, 5); printw("Records per packet: %3d", (int)coll->opts.rec_pkt);
- move(line++, 5); printw("Bits per trial: %3d", (int)coll->opts.trialsz);
+ move(line++, 5); printw("Samples per record: %3d", coll->opts.samp_rec);
+ move(line++, 5); printw("Seconds per record: %3d", coll->opts.sec_rec);
+ move(line++, 5); printw("Records per packet: %3d", coll->opts.rec_pkt);
+ move(line++, 5); printw("Bits per trial: %3d", coll->opts.trialsz);
refresh();
}
#include "global.h"
#include "genlib.h"
-int32 getzulutime(struct timeval *ztv) {
+uint32 getzulutime(struct timeval *ztv) {
struct timeval ttv;
if (ztv) {
/* Assemble header fields into data packet. */
- packShort(src->hdr.type = DATA_PACKET);
- packShort(src->hdr.pktsize = pktsize);
- packShort(src->hdr.eggid);
- packShort(src->hdr.samp_rec);
- packShort(src->hdr.sec_rec);
- packShort(src->hdr.rec_pkt);
- packByte(0); /* Pad byte in case we want to expand trialsz */
- packByte(src->hdr.trialsz);
- packShort(src->hdr.numrec);
+ pack16(src->hdr.type = DATA_PACKET);
+ pack16(src->hdr.pktsize = pktsize);
+ pack16(src->hdr.eggid);
+ pack16(src->hdr.samp_rec);
+ pack16(src->hdr.sec_rec);
+ pack16(src->hdr.rec_pkt);
+ pack8(0); /* Pad byte in case we want to expand trialsz */
+ pack8(src->hdr.trialsz);
+ pack16(src->hdr.numrec);
/* Append data records to packet. */
for (rec = 0; rec < src->hdr.numrec; rec++) {
- packLong(src->records[rec].timestamp);
- packBytes(&(src->records[rec].trials), src->hdr.samp_rec);
+ pack32(src->records[rec].timestamp);
+ pack8s(&(src->records[rec].trials), src->hdr.samp_rec);
}
+
/* Get CRC, pack into base(32,32,64) notation, and add tag byte (0xFF) */
lbuf = BlockCRC16((byte *) rbuf, pktP - rbuf);
lbuf = ((lbuf & 0xF800) << 13) |
((lbuf & 0x07C0) << 10) |
((lbuf & 0x003F) << 8) |
(0x00FF);
- packLong(lbuf);
+ pack32(lbuf);
+
if ((pktP - rbuf) != pktsize) {
- fprintf(stderr, "Length mismatch assembling packet. Computed: %d, actually packed: %d.\n",
+ fprintf(stderr, "Length mismatch assembling packet. Computed: %d, actually packed: %ld.\n",
pktsize, pktP - rbuf);
}
return rbuf;
/* Unpack the portable header into a host-order and aligned
EggHeader packet. */
- unpackShort(dst->hdr.type);
- unpackShort(dst->hdr.pktsize);
- unpackShort(dst->hdr.eggid);
- unpackShort(dst->hdr.samp_rec);
- unpackShort(dst->hdr.sec_rec);
- unpackShort(dst->hdr.rec_pkt);
- unpackByte(pad); /* Pad in case we later grow trialsz */
- unpackByte(dst->hdr.trialsz);
- unpackShort(dst->hdr.numrec);
+ unpack16(dst->hdr.type);
+ unpack16(dst->hdr.pktsize);
+ unpack16(dst->hdr.eggid);
+ unpack16(dst->hdr.samp_rec);
+ unpack16(dst->hdr.sec_rec);
+ unpack16(dst->hdr.rec_pkt);
+ unpack8(pad); /* Pad in case we later grow trialsz */
+ unpack8(dst->hdr.trialsz);
+ unpack16(dst->hdr.numrec);
if (dst->hdr.type != DATA_PACKET) {
#ifdef DEBUG
/* Unpack the data records from the file packet. */
for (rec = 0; rec < dst->hdr.numrec; rec++) {
- unpackLong(dst->records[rec].timestamp);
+ unpack32(dst->records[rec].timestamp);
/* Assumes sizeof(trial) = 1 */
- unpackBytes(&(dst->records[rec].trials), dst->hdr.samp_rec);
+ unpack8s(&(dst->records[rec].trials), dst->hdr.samp_rec);
}
/* Compute the CRC, reassemble into record terminator,
((lbuf & 0x003F) << 8) |
(0x00FF);
- unpackLong(filecrc);
+ unpack32(filecrc);
if (lbuf != filecrc) {
#ifdef DEBUG
- fprintf(stderr, "Bad CRC in packet read from file. Read 0x%08lX, computed 0x%08lX.\n", filecrc, lbuf);
+ fprintf(stderr, "Bad CRC in packet read from file. Read 0x%08X, computed 0x%08X.\n", filecrc, lbuf);
#endif
return -2;
}
if (dst->hdr.pktsize != (pktP - src)) {
#ifdef DEBUG
- fprintf(stderr, "Length mismatch decoding packet. Header: %d, length decoded: %d.\n",
+ fprintf(stderr, "Length mismatch decoding packet. Header: %d, length decoded: %ld.\n",
dst->hdr.pktsize, pktP - src);
#endif
return -1;
void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad) {
char *tp, *loser;
- long saddr;
+ uint32 saddr;
short qcount;
loser = mallocpy(dquad);
}
char *sockaddr2dquad(struct sockaddr_in *sinp) {
- long saddr;
+ uint32 saddr;
saddr = ntohl(sinp->sin_addr.s_addr);
return hl2dquad(saddr);
}
-char *hl2dquad(long addr) {
+char *hl2dquad(uint32 addr) {
static char resout[16];
- sprintf(resout, "%ld.%ld.%ld.%ld",
+ sprintf(resout, "%u.%u.%u.%u",
(addr >> 24) & 0xFF, (addr >> 16) & 0xFF,
(addr >> 8) & 0xFF, addr & 0xFF);
/* Get time in GMT reference frame. If ztv is NULL, simply returns
seconds. Otherwise, returns complete timeval in ztv as well. */
-extern int32 getzulutime(struct timeval *ztv);
+extern uint32 getzulutime(struct timeval *ztv);
/* Get difference in msec between two tvs. */
extern int32 deltams(struct timeval *tv1, struct timeval *tv2);
extern char *mallocpy(char *input);
extern void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad);
extern char *sockaddr2dquad(struct sockaddr_in *sinp); /* Static buffer! */
-extern char *hl2dquad(long addr); /* Static buffer! */
+extern char *hl2dquad(uint32 addr); /* Static buffer! */
/* Access to system or emulated usleep(). */
#include "byteorder.h" /* Build byte-order independent version */
/* Good for i386, but be careful... */
+/*
#ifdef linux
#include <sys/types.h>
-typedef __u8 byte;
-typedef __u8 uint8;
-typedef __u16 uint16;
-typedef __u32 uint32;
-typedef __s8 int8;
-typedef __s16 int16;
-typedef __s32 int32;
+ typedef __u8 byte;
+ typedef __u8 uint8;
+ typedef __u16 uint16;
+ typedef __u32 uint32;
+ typedef __s8 int8;
+ typedef __s16 int16;
+ typedef __s32 int32;
#else
-typedef unsigned char byte;
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned long uint32;
-typedef char int8;
-typedef short int16;
-typedef long int32;
-#endif /* linux */
+ typedef unsigned char byte;
+ typedef unsigned char uint8;
+ typedef unsigned ushort uint16;
+ typedef unsigned uint uint32;
+ typedef char int8;
+ typedef short int16;
+ typedef int int32;
+#endif
+*/
+
+#include <stdint.h>
+typedef uint8_t byte;
+typedef uint8_t uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef int8_t int8;
+typedef int16_t int16;
+typedef int32_t int32;
/* Some fixed assumptions:
Trial type is always bitsum.
char *primbasket;
int16 conntype;
int16 connival; /* Connect interval in minutes */
- int32 lastupd; /* Zulutime of last update received */
+ uint32 lastupd; /* Zulutime of last update received */
int16 setup; /* Does setup match config file? */
char *upcmd; /* Command to bring net up (req if conntype == DND) */
char *dncmd; /* Command to bring net down */
}
#ifdef HEXDUMP
- fprintf(stderr, "Received %ld bytes from %s\n", count,
+ fprintf(stderr, "Received %d bytes from %s\n", count,
inet_ntoa(sin->sin_addr));
xd(stderr, buffer, count, FALSE);
#endif
pktsize = ntohs(rpktsize);
if (pktsize != count) {
#ifdef DEBUG
- fprintf(stderr, "** Bad packet length: pktsize = %d, count = %ld.\n",
+ fprintf(stderr, "** Bad packet length: pktsize = %d, count = %d.\n",
pktsize, count);
#endif
return ERR_PKT_BADLEN;
case 115200: baudcon = B115200; break;
#endif
default:
- printf("%s: Baud rate %ld not supported.\n", pgmname, opts->baud);
+ printf("%s: Baud rate %d not supported.\n", pgmname, opts->baud);
return -1;
}
- fprintf(stderr, "Opening %s at %ld\n", ttydev, opts->baud);
+ fprintf(stderr, "Opening %s at %d\n", ttydev, opts->baud);
if ((TTY_fd = open(ttydev, O_RDONLY
#ifdef CPU_BOUND
| O_NDELAY
case 115200: baudcon = B115200; break;
#endif
default:
- printf("%s: Baud rate %ld not supported.\n", pgmname, opts->baud);
+ printf("%s: Baud rate %d not supported.\n", pgmname, opts->baud);
return -1;
}
- fprintf(stderr, "Opening %s at %ld\n", ttydev, opts->baud);
+ fprintf(stderr, "Opening %s at %d\n", ttydev, opts->baud);
if ((TTY_fd = open(ttydev, O_RDONLY
#ifdef CPU_BOUND
| O_NDELAY
an error on the following declaration, disable it for your
platform. */
-extern char *strdup (const char *s1);
+/*extern char *strdup (const char *s1);*/
/* Eventually, these might deal with making a safe copy or mounting
and unmounting a partition. Until such time as we actually do
struct seekopt {
char filename[256];
uint32 last_time;
- long next_packet;
+ int32 next_packet;
};
static struct seekopt seekOpt[SEEK_OPT_MAX];
int32 SavePacket(EggCarton *cart) {
FILE *fp;
char *packet, datatmp[255], datafile[255], *sp;
- int32 pktime, res;
+ uint32 pktime, res;
pktime = cart->records[0].timestamp;
#ifdef STORAGE_DEBUG
- fprintf(stderr, "SavePacket for %lu: %s", pktime, asctime(gmtime((time_t *) &pktime)));
+ time_t pktime_val = pktime;
+ fprintf(stderr, "SavePacket for %u: %s", pktime, asctime(gmtime(&pktime_val)));
#endif
/* Generate the file name corresponding to the date of
int32 res;
#ifdef STORAGE_DEBUG
- fprintf(stderr, "OpenDatabase: Egg = %d, tindex = %ld %s",
- eggid, tindex, asctime(gmtime((time_t *) &tindex)));
+ time_t tindex_val = tindex;
+ fprintf(stderr, "OpenDatabase: Egg = %d, tindex = %u %s",
+ eggid, tindex, asctime(gmtime(&tindex_val)));
#endif
dbp->eggind = 0;
dbp->fp = NULL;
findex = PROJSTART;
}
#ifdef STORAGE_DEBUG
- fprintf(stderr, "LoadNextPacket(%s, %lu, %d)\n", dbp->fn, tindex, eggid);
+ fprintf(stderr, "LoadNextPacket(%s, %u, %d)\n", dbp->fn, tindex, eggid);
#endif
/* See if the start address for this request is present
seekOpt[i].last_time == tindex) {
fseek(dbp->fp, seekOpt[i].next_packet, SEEK_SET);
#ifdef STORAGE_DEBUG
- fprintf(stderr, "LoadNextPacket; Seek optimised [%ld] to %ld for\n file %s at %lu %s",
+ time_t last_time_val = seekOpt[i].last_time;
+ fprintf(stderr, "LoadNextPacket; Seek optimised [%d] to %d for\n file %s at %u %s",
i,
seekOpt[i].next_packet,
seekOpt[i].filename,
seekOpt[i].last_time,
- asctime(gmtime((time_t *) &(seekOpt[i].last_time))));
+ asctime(gmtime(&last_time_val)));
#endif
break;
}
if (i == seekOptIndex) {
#ifdef STORAGE_DEBUG
- fprintf(stderr, "LoadNextPacket; Cannot optimise seek in file %s\n at %lu %s",
- dbp->fn, tindex, asctime(gmtime((time_t *) &(tindex))));
+ time_t tindex_val = tindex;
+ fprintf(stderr, "LoadNextPacket; Cannot optimise seek in file %s\n at %u %s",
+ dbp->fn, tindex, asctime(gmtime(&tindex_val)));
#endif
break; /* Search wrapped table--cannot optimise */
}
#define SECONDS_PER_DAY (24L * 60 * 60)
findex = ((findex / SECONDS_PER_DAY) + 1) * SECONDS_PER_DAY;
#ifdef STORAGE_DEBUG
- fprintf(stderr, "LoadNextPacket; EOF, CloseDatabase, findex = %lu: %s",
- findex, asctime(gmtime((time_t *) &findex)));
+ time_t findex_val = findex;
+ fprintf(stderr, "LoadNextPacket; EOF, CloseDatabase, findex = %u: %s",
+ findex, asctime(gmtime(&findex_val)));
#endif
if (findex > now) {
#ifdef STORAGE_DEBUG
- fprintf(stderr, "LoadNextPacket; EOF findex = %lu > now = %lu %s",
- findex, now, asctime(gmtime((time_t *) &now)));
+ time_t now_val = now;
+ fprintf(stderr, "LoadNextPacket; EOF findex = %u > now = %u %s",
+ findex, now, asctime(gmtime(&now_val)));
#endif
return ERR_EOF;
}
seekOpt[seekOptIndex].last_time = pktbuf.records[pktbuf.hdr.numrec - 1].timestamp;
seekOpt[seekOptIndex].next_packet = ftell(dbp->fp);
#ifdef STORAGE_DEBUG
- fprintf(stderr, "LoadNextPacket; Seek optimisation[%d] for %s\n to address %ld for time %lu %s",
+ time_t last_time_val = seekOpt[seekOptIndex].last_time;
+ fprintf(stderr, "LoadNextPacket; Seek optimisation[%d] for %s\n to address %d for time %u %s",
seekOptIndex,
seekOpt[seekOptIndex].filename,
seekOpt[seekOptIndex].next_packet,
seekOpt[seekOptIndex].last_time,
- asctime(gmtime((time_t *) &(seekOpt[seekOptIndex].last_time))));
+ asctime(gmtime(&last_time_val)));
#endif
seekOptIndex = (seekOptIndex + 1) % SEEK_OPT_MAX;
return ERR_NONE;
char ldf[255];
#ifdef STORAGE_DEBUG
- fprintf(stderr, "next_filename: egg = %d, mustexist = %d, tindex = %lu %s",
- eggid, mustexist, tindex, asctime(gmtime((time_t *) &tindex)));
+ time_t tindex_val = tindex;
+ fprintf(stderr, "next_filename: egg = %d, mustexist = %d, tindex = %u %s",
+ eggid, mustexist, tindex, asctime(gmtime(&tindex_val)));
#endif
if (eggid < 0 && !mustexist) {
#ifdef STORAGE_DEBUG
int16 eggind;
struct tm *tm;
- tm = gmtime((time_t *) &tindex);
+ time_t time_index = tindex;
+ tm = gmtime(&time_index);
strftime(datatmp, 255, datafmt, tm);
#ifdef STORAGE_DEBUG
- fprintf(stderr, "next_poss_fn: egg = %d, tindex = %lu %s",
+ fprintf(stderr, "next_poss_fn: egg = %d, tindex = %u %s",
eggid, tindex, asctime(tm));
#endif
static char dataformat1[80] = "%02X";
static int bytesperline = 16, doublechar = 0,
dflen = 2;
-static unsigned long fileaddr;
+static unsigned int fileaddr;
static unsigned char lineecho[32];
/* OUTLINE -- Edit a line of binary data into the selected output