capture all my changes since upstream 5.1 in quilt format
[debian/gcpegg] / debian / patches / all_my_changes.diff
1 Description: <short summary of the patch>
2  TODO: Put a short summary on the line above and replace this paragraph
3  with a longer explanation of this change. Complete the meta-information
4  with other relevant fields (see below for details). To make it easier, the
5  information below has been extracted from the changelog. Adjust it or drop
6  it.
7  .
8  gcpegg (5.1-15) unstable; urgency=medium
9  .
10    * stop trying to force which VT eggsh is launched on
11 Author: Bdale Garbee <bdale@gag.com>
12
13 ---
14 The information above should follow the Patch Tagging Guidelines, please
15 checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
16 are templates for supplementary fields that you might want to add:
17
18 Origin: <vendor|upstream|other>, <url of original patch>
19 Bug: <url in upstream bugtracker>
20 Bug-Debian: https://bugs.debian.org/<bugnumber>
21 Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
22 Forwarded: <no|not-needed|url proving that it has been forwarded>
23 Reviewed-By: <name and email of someone who approved the patch>
24 Last-Update: 2019-10-26
25
26 --- gcpegg-5.1.orig/basket.c
27 +++ gcpegg-5.1/basket.c
28 @@ -42,6 +42,7 @@
29  #include <sys/socket.h>
30  #include <netdb.h>
31  #include <netinet/in.h>
32 +#include <time.h>
33  #include "global.h"
34  #include "genlib.h"
35  #include "storage.h"
36 @@ -90,6 +91,7 @@ static void updateHTML(void)
37         int i;
38         static uint32 lastHtml = 0;
39         uint32 now = getzulutime(NULL);
40 +       time_t now_val;
41         char udate[256], ustime[256];
42          static char timeFormat[] = "%Y-%m-%d %T";
43  
44 @@ -113,9 +115,11 @@ static void updateHTML(void)
45                 htmlFile[0] = 0;      /* Suppress further updates */
46                 return;
47             }
48 -
49 -           strftime(udate, sizeof udate, timeFormat, gmtime((time_t *) &now));
50 -           strftime(ustime, sizeof ustime, timeFormat, gmtime((time_t *) &upsince));
51 +      
52 +      now_val = now;
53 +      strftime(udate, sizeof udate, timeFormat, gmtime(&now_val));
54 +      time_t upsince_val = upsince;
55 +      strftime(ustime, sizeof ustime, timeFormat, gmtime(&upsince_val));
56  
57              fprintf(hf, "\
58  <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n\
59 @@ -146,8 +150,10 @@ static void updateHTML(void)
60                    strcpy(udate, "<td colspan=2 align=center><em>Never contacted</em>");
61                    strcpy(ustime, "");
62               } else {
63 -                  strftime(udate, sizeof udate, "<td align=center>%Y-%m-%d %T", gmtime((time_t *) &eggtable[i].lastupd));
64 -                  strftime(ustime, sizeof ustime, "<td align=center>%Y-%m-%d %T", gmtime((time_t *) &eggStatistics[i].firstPacket));
65 +                  time_t lastupd_val = eggtable[i].lastupd;
66 +                  strftime(udate, sizeof udate, "<td align=center>%Y-%m-%d %T", gmtime(&lastupd_val));
67 +                  time_t firstPacket_val = eggStatistics[i].firstPacket;
68 +                  strftime(ustime, sizeof ustime, "<td align=center>%Y-%m-%d %T", gmtime(&firstPacket_val));
69               }
70               if (eggtable[i].url == NULL) {
71                   url1[0] = url2[0] = 0;
72 @@ -181,7 +187,7 @@ static void updateHTML(void)
73                       coverage = 100;
74                   }
75  
76 -                  fprintf(hf, "<td align=center>%ld<td align=center>%ld<td align=center>%ld%%<td align=center>%.3f\n",
77 +                  fprintf(hf, "<td align=center>%d<td align=center>%d<td align=center>%d%%<td align=center>%.3f\n",
78                           eggStatistics[i].trials,
79                           eggStatistics[i].missing,
80                           coverage,
81 @@ -213,8 +219,9 @@ static void updateHTML(void)
82  </html>\n");
83             fclose(hf);
84  #ifdef DEBUG
85 +            now_val = now;
86              fprintf(stderr, "Updating HTML file %s at %s",
87 -               htmlFile, asctime(gmtime((time_t *) &now)));
88 +               htmlFile, asctime(gmtime(&now_val)));
89  #endif
90         }
91      }
92 @@ -436,9 +443,10 @@ int main(int argc, char *argv[]) {
93  
94         memcpy(&egg_now_time, pktbuf + 6, sizeof egg_now_time);
95         egg_now_time = ntohl(egg_now_time);
96 -       fprintf(stderr, "Awake egg %d (%s) at its %lu: %s",
97 +       time_t egg_now_time_val = egg_now_time;
98 +       fprintf(stderr, "Awake egg %d (%s) at its %u: %s",
99                 pkt_eggid, eggtable[thisegg].name, egg_now_time,
100 -               asctime(gmtime((time_t *) &egg_now_time)));
101 +               asctime(gmtime(&egg_now_time_val)));
102        }
103  #endif
104  
105 @@ -617,14 +625,14 @@ static int32 BasketReceiveDataPacket(cha
106       EggHeader packet. */
107    
108    dpktp = &dpk;
109 -  unpackShort(dpk.type);
110 -  unpackShort(dpk.pktsize);
111 -  unpackShort(dpk.eggid);
112 -  unpackShort(dpk.samp_rec);
113 -  unpackShort(dpk.sec_rec);
114 -  unpackShort(dpk.rec_pkt);
115 -  unpackByte(dpk.trialsz);
116 -  unpackShort(dpk.numrec);
117 +  unpack16(dpk.type);
118 +  unpack16(dpk.pktsize);
119 +  unpack16(dpk.eggid);
120 +  unpack16(dpk.samp_rec);
121 +  unpack16(dpk.sec_rec);
122 +  unpack16(dpk.rec_pkt);
123 +  unpack8(dpk.trialsz);
124 +  unpack16(dpk.numrec);
125  
126    /* This spoofing test is probably completely redundant now. */
127  #ifndef EGG_DYNAMIC      
128 @@ -647,7 +655,7 @@ static int32 BasketReceiveDataPacket(cha
129      char *spktp = pktP;
130  
131      if (result.hdr.numrec > 0) {
132 -      unpackLong(stamp);
133 +      unpack32(stamp);
134      }
135      pktP = spktp;
136      fprintf(stderr, "Received packet: %d records from egg %d (%s).\n",
137 @@ -659,19 +667,20 @@ static int32 BasketReceiveDataPacket(cha
138       transcribe to the result EggCarton.  */
139    
140    for (latest = 0, rec = 0; rec < result.hdr.numrec; rec++) {
141 -    unpackLong(result.records[rec].timestamp);  /* Record timestamp */
142 +    unpack32(result.records[rec].timestamp);    /* Record timestamp */
143      if (result.records[rec].timestamp > latest)
144        latest = result.records[rec].timestamp;
145  #ifdef DEBUG
146 -    fprintf(stderr, "  %10lu  ", result.records[rec].timestamp);
147 +    fprintf(stderr, "  %10u  ", result.records[rec].timestamp);
148  #endif
149      /* Assumes sizeof(trial) = 1 */
150 -    unpackBytes(&(result.records[rec].trials), result.hdr.samp_rec);
151 +    unpack8s(&(result.records[rec].trials), result.hdr.samp_rec);
152  #ifdef DEBUG
153      for (i = 0; i < result.hdr.samp_rec; i++) {
154        fprintf(stderr, "%3d ", result.records[rec].trials[i]);
155      }
156 -    fprintf(stderr, "%s", asctime(gmtime((time_t *) &result.records[rec].timestamp)));
157 +    time_t timestamp_val = result.records[rec].timestamp;
158 +    fprintf(stderr, "%s", asctime(gmtime(&timestamp_val)));
159  #endif
160    }
161  
162 @@ -748,10 +757,10 @@ static int32 BasketReceiveDataPacket(cha
163  static void MakeRequest(ReqPacket *pkt, uint16 eggid, uint32 whence) {
164    char *pktP = (char *) pkt;
165  
166 -  packShort(REQ_PACKET);
167 -  packShort((4 * sizeof(uint16)) + sizeof(uint32));
168 -  packShort(eggid);
169 -  packLong(whence);
170 +  pack16(REQ_PACKET);
171 +  pack16((4 * sizeof(uint16)) + sizeof(uint32));
172 +  pack16(eggid);
173 +  pack32(whence);
174  }
175  
176  /*  MakeSettings  --  Create a settings packet.  This packet,
177 @@ -761,14 +770,14 @@ static void MakeRequest(ReqPacket *pkt,
178  static void MakeSettings(SettingsPacket *pkt, uint16 eggid) {
179    char *pktP = (char *) pkt;
180  
181 -  packShort(SETTINGS_PACKET);
182 -  packShort((7 * sizeof(uint16)) + sizeof(uint32) + sizeof(trial));
183 -  packShort(eggid);
184 -  packLong(getzulutime(NULL));
185 -  packShort(protocol.samp_rec);
186 -  packShort(protocol.sec_rec);
187 -  packShort(protocol.rec_pkt);
188 -  packByte(protocol.trialsz);
189 +  pack16(SETTINGS_PACKET);
190 +  pack16((7 * sizeof(uint16)) + sizeof(uint32) + sizeof(trial));
191 +  pack16(eggid);
192 +  pack32(getzulutime(NULL));
193 +  pack16(protocol.samp_rec);
194 +  pack16(protocol.sec_rec);
195 +  pack16(protocol.rec_pkt);
196 +  pack8(protocol.trialsz);
197  }
198  
199  /*  LoadEggStats  --  Initialise in-memory egg status table
200 @@ -827,7 +836,7 @@ static void SaveEggStats(void) {
201    fprintf(fp, "# Status lines of form:\n");
202    fprintf(fp, "#   STAT <eggname> <eggid> <lastupdzulu> <setupvalid>\n");
203    for (i = 0; i < numeggs; i++) {
204 -    fprintf(fp, "STAT %s %d %ld %d\n",
205 +    fprintf(fp, "STAT %s %d %u %d\n",
206             eggtable[i].name,
207             eggtable[i].id,
208             eggtable[i].lastupd,
209 --- gcpegg-5.1.orig/byteorder.h
210 +++ gcpegg-5.1/byteorder.h
211 @@ -12,25 +12,25 @@
212      on RISC machines which typically require values to be
213      aligned at an even multiple of their length.  */
214  
215 -#define packShort(x) { \
216 -                       short s = htons((short) (x)); \
217 -                       memcpy(pktP, &s, sizeof(short)); \
218 -                       pktP += sizeof(short); \
219 +#define pack16(x) { \
220 +                       uint16 s = htons((uint16) (x)); \
221 +                       memcpy(pktP, &s, sizeof(uint16)); \
222 +                       pktP += sizeof(uint16); \
223                      }
224  
225 -#define packLong(x) { \
226 -                       long l = htonl((long) (x)); \
227 -                       memcpy(pktP, &l, sizeof(long)); \
228 -                       pktP += sizeof(long); \
229 +#define pack32(x) { \
230 +                       uint32 i = htonl((uint32) (x)); \
231 +                       memcpy(pktP, &i, sizeof(uint32)); \
232 +                       pktP += sizeof(uint32); \
233                     }
234  
235 -#define packByte(x) { \
236 +#define pack8(x) { \
237                         char c = (x); \
238                         memcpy(pktP, &c, sizeof(char)); \
239                         pktP += sizeof(char); \
240                     }
241  
242 -#define packBytes(x, n) { \
243 +#define pack8s(x, n) { \
244                             memcpy(pktP, x, n); \
245                             pktP += n; \
246                         }
247 @@ -40,25 +40,25 @@
248      pktP.  Note that the argument of these macros must be
249      an lvalue. */
250  
251 -#define unpackShort(x) { \
252 -                           short s; \
253 -                           memcpy(&s, pktP, sizeof(short)); \
254 -                           pktP += sizeof(short); \
255 +#define unpack16(x) { \
256 +                           uint16 s; \
257 +                           memcpy(&s, pktP, sizeof(uint16)); \
258 +                           pktP += sizeof(uint16); \
259                             x = ntohs(s); \
260                        }
261  
262 -#define unpackLong(x) { \
263 -                          long l; \
264 -                          memcpy(&l, pktP, sizeof(long)); \
265 -                          pktP += sizeof(long); \
266 -                          x = ntohl(l); \
267 +#define unpack32(x) { \
268 +                          uint32 i; \
269 +                          memcpy(&i, pktP, sizeof(uint32)); \
270 +                          pktP += sizeof(uint32); \
271 +                          x = ntohl(i); \
272                       }
273  
274 -#define unpackByte(x) { \
275 +#define unpack8(x) { \
276                         *((char *) &x) = (char) *pktP++; \
277                       }
278  
279 -#define unpackBytes(x, n) { \
280 +#define unpack8s(x, n) { \
281                             memcpy(x, pktP, n); \
282                             pktP += n; \
283                           }
284 --- gcpegg-5.1.orig/egg.c
285 +++ gcpegg-5.1/egg.c
286 @@ -49,6 +49,7 @@
287  #include <sys/socket.h>
288  #include <netdb.h>
289  #include <netinet/in.h>
290 +#include <time.h>
291  
292  #include "global.h"
293  #include "genlib.h"
294 @@ -94,7 +95,7 @@ static EggCarton savebuffer;
295  char   *pgmname;                     /* Program name from argv[0] */
296  char   *myaddr;                      /* Interface to bind */
297  int16  myport;                       /* Service port to bind */
298 -int32 lastDataSent = 0;              /* Time last packet sent to basket */
299 +uint32 lastDataSent = 0;             /* Time last packet sent to basket */
300  
301  /* If no priority increment has been specified at compile time, set to
302     our default of Â±10. [+/- 10, for folks without 8bit editors] */
303 @@ -106,7 +107,7 @@ static int niceness = NICE;       /* Pri
304  
305  /* Status exported to user interface. */
306  
307 -int32 time_latency = 0, time_housekeeping = 0;
308 +uint32 time_latency = 0, time_housekeeping = 0;
309  
310  #ifdef ALT_UI
311  static double mean_Packet = 0.0, mean_Grand = 0.0;
312 @@ -292,7 +293,7 @@ int main(int argc, char *argv[]) {
313    }
314  #ifdef DEBUG
315      else {
316 -    printf("REG configured: %s = %d, %d, %ld\n", configuredREG ->reg_name,
317 +    printf("REG configured: %s = %d, %d, %d\n", configuredREG ->reg_name,
318         devopts.type, devopts.port, devopts.baud);
319    }
320  #endif
321 @@ -463,7 +464,7 @@ int main(int argc, char *argv[]) {
322         totalTrials += ptrials;
323         mean_Grand = totalGrand / totalTrials;
324         total_Packets++;
325 -       printf("Packets sent: %ld  Packet mean: %6.2f  Grand mean: %6.2f\n",
326 +       printf("Packets sent: %d  Packet mean: %6.2f  Grand mean: %6.2f\n",
327                 total_Packets, mean_Packet, mean_Grand);
328  #endif
329        }
330 @@ -489,7 +490,7 @@ int main(int argc, char *argv[]) {
331      /* But let's be sure it really *is* in the interval. */
332      if (t.tv_sec < savebuffer.records[0].timestamp ||
333         t.tv_sec >= (savebuffer.records[0].timestamp + savebuffer.hdr.sec_rec * savebuffer.hdr.rec_pkt)) {
334 -      fprintf(stderr, "***Sample, collected at %ld, is not within packet starting at %ld.\n",
335 +      fprintf(stderr, "***Sample, collected at %ld, is not within packet starting at %u.\n",
336               t.tv_sec, savebuffer.records[0].timestamp);
337        exit(-1);
338      }
339 @@ -605,11 +606,12 @@ int main(int argc, char *argv[]) {
340               uint32 stime;
341               char *pktP = pktbuf + (2 * sizeof(uint16));
342               
343 -             unpackShort(reggid);
344 -             unpackLong(stime);
345 +             unpack16(reggid);
346 +             unpack32(stime);
347  #ifdef PACKETDUMP
348 -             fprintf(stderr, "Request: eggid = %d, starttm = %ld: %s",
349 -                     reggid, stime, asctime(gmtime((time_t *) &stime)));
350 +        time_t stime_val = stime;
351 +             fprintf(stderr, "Request: eggid = %d, starttm = %u: %s\n",
352 +                     reggid, stime, asctime(gmtime(&stime_val)));
353  #endif
354               res = LoadPacket(stime, reggid, &retrcart);
355             }
356 @@ -639,10 +641,10 @@ int main(int argc, char *argv[]) {
357             
358             { char *pktP = pktbuf + (3 * sizeof(uint16)) + sizeof(uint32);
359             
360 -           unpackShort(protocol.samp_rec);
361 -           unpackShort(protocol.sec_rec);
362 -           unpackShort(protocol.rec_pkt);
363 -           unpackByte(protocol.trialsz);
364 +           unpack16(protocol.samp_rec);
365 +           unpack16(protocol.sec_rec);
366 +           unpack16(protocol.rec_pkt);
367 +           unpack8(protocol.trialsz);
368             }
369  #ifdef PACKETDUMP
370             fprintf(stderr, "Settings: samp_rec = %d, sec_rec = %d, rec_pkt = %d, trialsz = %d\n",
371 @@ -672,12 +674,12 @@ int main(int argc, char *argv[]) {
372      usec = time_latency;
373      msec = usec / 1000;
374      usec %= 1000;
375 -    printf("Sampling latency: %ld.%03ld msec", msec, usec);
376 +    printf("Sampling latency: %d.%03d msec", msec, usec);
377  
378      usec = time_housekeeping;
379      msec = usec / 1000;
380      usec %= 1000;
381 -    printf("  Housekeeping time: %ld.%03ld msec\n", msec, usec);
382 +    printf("  Housekeeping time: %d.%03d msec\n", msec, usec);
383  #endif
384      lt = ct;
385      sleeptime = ((1000000 - SLACK) - ct.tv_usec);
386 @@ -845,10 +847,10 @@ static void LoadRCFile(char *filename) {
387  static void MakeAwake(AwakePacket *pkt) {
388    char *pktP = (char *) pkt;
389  
390 -  packShort(AWAKE_PACKET);
391 -  packShort((4 * sizeof(uint16)) + sizeof(uint32));
392 -  packShort(eggtable[0].id);
393 -  packLong(getzulutime(NULL));
394 +  pack16(AWAKE_PACKET);
395 +  pack16((4 * sizeof(uint16)) + sizeof(uint32));
396 +  pack16(eggtable[0].id);
397 +  pack32(getzulutime(NULL));
398  }
399  
400  /*  MakeDataPkt  --  Build a canonical network byte order data packet
401 @@ -866,20 +868,20 @@ static void MakeDataPkt(char **pkt, EggC
402  
403    /* Assemble header fields into data packet. */
404  
405 -  packShort(src->hdr.type = DATA_PACKET);
406 -  packShort(src->hdr.pktsize = pktsize);
407 -  packShort(src->hdr.eggid);
408 -  packShort(src->hdr.samp_rec);
409 -  packShort(src->hdr.sec_rec);
410 -  packShort(src->hdr.rec_pkt);
411 -  packByte(src->hdr.trialsz);
412 -  packShort(src->hdr.numrec);
413 +  pack16(src->hdr.type = DATA_PACKET);
414 +  pack16(src->hdr.pktsize = pktsize);
415 +  pack16(src->hdr.eggid);
416 +  pack16(src->hdr.samp_rec);
417 +  pack16(src->hdr.sec_rec);
418 +  pack16(src->hdr.rec_pkt);
419 +  pack8(src->hdr.trialsz);
420 +  pack16(src->hdr.numrec);
421  
422    /* Append data records to packet. */
423  
424    for (rec = 0; rec < src->hdr.numrec; rec++) {
425 -    packLong(src->records[rec].timestamp);
426 -    packBytes(&(src->records[rec].trials), src->hdr.samp_rec);
427 +    pack32(src->records[rec].timestamp);
428 +    pack8s(&(src->records[rec].trials), src->hdr.samp_rec);
429    }
430  
431    /* No need to calculate CRC -- NetTalk does that for us.
432 --- gcpegg-5.1.orig/eggrc.sample
433 +++ gcpegg-5.1/eggrc.sample
434 @@ -58,8 +58,8 @@
435  #BASKET diesse 193.8.230.134
436  
437  #   noosphere -> diesse
438 -EGG noosphere 28 128.112.35.133 diesse PERM 1
439 -BASKET diesse 193.8.230.134
440 +#EGG noosphere 28 128.112.35.133 diesse PERM 1
441 +#BASKET diesse 193.8.230.134
442  
443  #   throop -> diesse
444  #EGG throop 1003 193.8.230.132 diesse PERM 1 http://www.fourmilab.ch/
445 @@ -78,9 +78,16 @@ BASKET diesse 193.8.230.134
446  
447  #BASKET tonga 209.157.90.137
448  #BASKET tonga1 209.157.90.138
449 -PROTOCOL 10 10 6 200
450 +#PROTOCOL 10 10 6 200
451  #REG PEAR 2 9600
452 -REG PSEUDO 1 9600
453 +#REG PSEUDO 1 9600
454  #REG ORION 1 9600
455 -NETUP pppscript up
456 -NETDOWN pppscript down
457 +#NETUP pppscript up
458 +#NETDOWN pppscript down
459 +
460 +egg.host.name ID# IP_address noosphere PERM 1 
461 +BASKET noosphere 128.112.35.133 
462 +PROTOCOL 10 10 30 200
463 +REG ORION 0 9600
464 +#REG PEAR 0 9600
465 +
466 --- gcpegg-5.1.orig/eggui.c
467 +++ gcpegg-5.1/eggui.c
468 @@ -37,6 +37,8 @@
469  #include <stdio.h>
470  #include <stdlib.h>
471  #include <curses.h>
472 +#include <time.h>
473 +#include <string.h>
474  
475  /*  Curses takes it upon itself to define TRUE and FALSE,
476      incompatibly, as it happens, with the definitions in
477 @@ -55,11 +57,11 @@
478  #include "version.h"
479  
480  #ifndef NO_UI
481 -static int32 inittm = 0;
482 +static uint32 inittm = 0;
483  #endif
484  
485 -extern int32 lastDataSent;
486 -extern int32 time_latency, time_housekeeping;
487 +extern uint32 lastDataSent;
488 +extern uint32 time_latency, time_housekeeping;
489  
490  /* Initialize user interface, as needed. */
491  int32 UIInit(void) {
492 @@ -110,10 +112,10 @@ int32 UIUpdate(int32 cres, CollectRecord
493  
494    if (coll->sampct == 1) {
495      line = 11;
496 -    move(line++, 5); printw("Samples per record: %3d", (int)coll->opts.samp_rec);
497 -    move(line++, 5); printw("Seconds per record: %3d", (int)coll->opts.sec_rec);
498 -    move(line++, 5); printw("Records per packet: %3d", (int)coll->opts.rec_pkt);
499 -    move(line++, 5); printw("Bits per trial:     %3d", (int)coll->opts.trialsz);
500 +    move(line++, 5); printw("Samples per record: %3d", coll->opts.samp_rec);
501 +    move(line++, 5); printw("Seconds per record: %3d", coll->opts.sec_rec);
502 +    move(line++, 5); printw("Records per packet: %3d", coll->opts.rec_pkt);
503 +    move(line++, 5); printw("Bits per trial:     %3d", coll->opts.trialsz);
504      refresh();
505    }
506  
507 @@ -124,17 +126,20 @@ int32 UIUpdate(int32 cres, CollectRecord
508    printw("EGG %s ID %d REG %s %s", eggtable[0].name, eggtable[0].id,
509          configuredREG->reg_name, Version);
510  
511 -  tmstr = ctime(&inittm); tmstr[strlen(tmstr)-1] = 0;
512 +  time_t inittm_val = inittm;
513 +  tmstr = ctime(&inittm_val); tmstr[strlen(tmstr)-1] = 0;
514    move(line++, 5);
515    printw("Up since       %25s", tmstr);
516  
517    move(line++, 5);
518    now = getzulutime(NULL);
519 -  tmstr = ctime(&now); tmstr[strlen(tmstr)-1] = 0;
520 +  time_t now_val = now;
521 +  tmstr = ctime(&now_val); tmstr[strlen(tmstr)-1] = 0;
522    printw("Last sample at %25s", tmstr);
523  
524    move(line++, 5);
525 -  tmstr = ctime(&lastDataSent);
526 +  time_t lastDataSent_val = lastDataSent;
527 +  tmstr = ctime(&lastDataSent_val);
528    tmstr[strlen(tmstr)-1] = 0;
529    printw("Last packet at %25s", lastDataSent == 0 ? "Never" : tmstr);
530  
531 --- gcpegg-5.1.orig/genlib.c
532 +++ gcpegg-5.1/genlib.c
533 @@ -38,7 +38,7 @@
534  #include "global.h"
535  #include "genlib.h"
536  
537 -int32 getzulutime(struct timeval *ztv) {
538 +uint32 getzulutime(struct timeval *ztv) {
539    struct timeval ttv;
540  
541    if (ztv) {
542 @@ -86,31 +86,33 @@ char *Packetize(EggCarton *src) {
543  
544    /* Assemble header fields into data packet. */
545  
546 -  packShort(src->hdr.type = DATA_PACKET);
547 -  packShort(src->hdr.pktsize = pktsize);
548 -  packShort(src->hdr.eggid);
549 -  packShort(src->hdr.samp_rec);
550 -  packShort(src->hdr.sec_rec);
551 -  packShort(src->hdr.rec_pkt);
552 -  packByte(0);                       /* Pad byte in case we want to expand trialsz */
553 -  packByte(src->hdr.trialsz);
554 -  packShort(src->hdr.numrec);
555 +  pack16(src->hdr.type = DATA_PACKET);
556 +  pack16(src->hdr.pktsize = pktsize);
557 +  pack16(src->hdr.eggid);
558 +  pack16(src->hdr.samp_rec);
559 +  pack16(src->hdr.sec_rec);
560 +  pack16(src->hdr.rec_pkt);
561 +  pack8(0);                          /* Pad byte in case we want to expand trialsz */
562 +  pack8(src->hdr.trialsz);
563 +  pack16(src->hdr.numrec);
564  
565    /* Append data records to packet. */
566  
567    for (rec = 0; rec < src->hdr.numrec; rec++) {
568 -    packLong(src->records[rec].timestamp);
569 -    packBytes(&(src->records[rec].trials), src->hdr.samp_rec);
570 +    pack32(src->records[rec].timestamp);
571 +    pack8s(&(src->records[rec].trials), src->hdr.samp_rec);
572    }
573 +
574    /* Get CRC, pack into base(32,32,64) notation, and add tag byte (0xFF) */
575    lbuf = BlockCRC16((byte *) rbuf, pktP - rbuf);
576    lbuf = ((lbuf & 0xF800) << 13) |
577          ((lbuf & 0x07C0) << 10) |
578          ((lbuf & 0x003F) << 8) |
579          (0x00FF);
580 -  packLong(lbuf);
581 +  pack32(lbuf);
582 +
583    if ((pktP - rbuf) != pktsize) {
584 -    fprintf(stderr, "Length mismatch assembling packet.  Computed: %d, actually packed: %d.\n",
585 +    fprintf(stderr, "Length mismatch assembling packet.  Computed: %d, actually packed: %ld.\n",
586         pktsize, pktP - rbuf);
587    }
588    return rbuf;
589 @@ -125,15 +127,15 @@ int32 Unpacketize(EggCarton *dst, char *
590    /* Unpack the portable header into a host-order and aligned
591       EggHeader packet. */
592  
593 -  unpackShort(dst->hdr.type);
594 -  unpackShort(dst->hdr.pktsize);
595 -  unpackShort(dst->hdr.eggid);
596 -  unpackShort(dst->hdr.samp_rec);
597 -  unpackShort(dst->hdr.sec_rec);
598 -  unpackShort(dst->hdr.rec_pkt);
599 -  unpackByte(pad);                   /* Pad in case we later grow trialsz */
600 -  unpackByte(dst->hdr.trialsz);
601 -  unpackShort(dst->hdr.numrec);
602 +  unpack16(dst->hdr.type);
603 +  unpack16(dst->hdr.pktsize);
604 +  unpack16(dst->hdr.eggid);
605 +  unpack16(dst->hdr.samp_rec);
606 +  unpack16(dst->hdr.sec_rec);
607 +  unpack16(dst->hdr.rec_pkt);
608 +  unpack8(pad);                      /* Pad in case we later grow trialsz */
609 +  unpack8(dst->hdr.trialsz);
610 +  unpack16(dst->hdr.numrec);
611  
612    if (dst->hdr.type != DATA_PACKET) {
613  #ifdef DEBUG
614 @@ -145,9 +147,9 @@ int32 Unpacketize(EggCarton *dst, char *
615    /* Unpack the data records from the file packet. */
616  
617    for (rec = 0; rec < dst->hdr.numrec; rec++) {
618 -    unpackLong(dst->records[rec].timestamp);
619 +    unpack32(dst->records[rec].timestamp);
620      /* Assumes sizeof(trial) = 1 */
621 -    unpackBytes(&(dst->records[rec].trials), dst->hdr.samp_rec);
622 +    unpack8s(&(dst->records[rec].trials), dst->hdr.samp_rec);
623    }
624  
625    /* Compute the CRC, reassemble into record terminator,
626 @@ -159,18 +161,18 @@ int32 Unpacketize(EggCarton *dst, char *
627          ((lbuf & 0x003F) << 8) |
628          (0x00FF);
629  
630 -  unpackLong(filecrc);
631 +  unpack32(filecrc);
632  
633    if (lbuf != filecrc) {
634  #ifdef DEBUG
635 -    fprintf(stderr, "Bad CRC in packet read from file.  Read 0x%08lX, computed 0x%08lX.\n", filecrc, lbuf);
636 +    fprintf(stderr, "Bad CRC in packet read from file.  Read 0x%08X, computed 0x%08X.\n", filecrc, lbuf);
637  #endif
638      return -2;
639    }
640  
641    if (dst->hdr.pktsize != (pktP - src)) {
642  #ifdef DEBUG
643 -    fprintf(stderr, "Length mismatch decoding packet.  Header: %d, length decoded: %d.\n",
644 +    fprintf(stderr, "Length mismatch decoding packet.  Header: %d, length decoded: %ld.\n",
645        dst->hdr.pktsize, pktP - src);
646  #endif
647      return -1;
648 @@ -210,7 +212,7 @@ char *mallocpy(char *input) {
649  
650  void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad) {
651    char *tp, *loser;
652 -  long saddr;
653 +  uint32 saddr;
654    short qcount;
655  
656    loser = mallocpy(dquad);
657 @@ -237,16 +239,16 @@ void dquad2sockaddr(struct sockaddr_in *
658  }
659  
660  char *sockaddr2dquad(struct sockaddr_in *sinp) {
661 -  long saddr;
662 +  uint32 saddr;
663    
664    saddr = ntohl(sinp->sin_addr.s_addr);
665    return hl2dquad(saddr);
666  }
667  
668 -char *hl2dquad(long addr) {
669 +char *hl2dquad(uint32 addr) {
670    static char resout[16];
671  
672 -  sprintf(resout, "%ld.%ld.%ld.%ld",
673 +  sprintf(resout, "%u.%u.%u.%u",
674           (addr >> 24) & 0xFF, (addr >> 16) & 0xFF,
675           (addr >> 8) & 0xFF, addr & 0xFF);
676    
677 --- gcpegg-5.1.orig/genlib.h
678 +++ gcpegg-5.1/genlib.h
679 @@ -37,7 +37,7 @@
680  
681  /* Get time in GMT reference frame.  If ztv is NULL, simply returns
682     seconds.  Otherwise, returns complete timeval in ztv as well. */
683 -extern int32 getzulutime(struct timeval *ztv);
684 +extern uint32 getzulutime(struct timeval *ztv);
685  
686  /* Get difference in msec between two tvs. */
687  extern int32 deltams(struct timeval *tv1, struct timeval *tv2);
688 @@ -59,7 +59,7 @@ extern void Parse(char *input, int *argc
689  extern char *mallocpy(char *input);
690  extern void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad);
691  extern char *sockaddr2dquad(struct sockaddr_in *sinp); /* Static buffer! */
692 -extern char *hl2dquad(long addr);      /* Static buffer! */
693 +extern char *hl2dquad(uint32 addr);    /* Static buffer! */
694  
695  
696  /* Access to system or emulated usleep(). */
697 --- gcpegg-5.1.orig/global.h
698 +++ gcpegg-5.1/global.h
699 @@ -32,13 +32,35 @@
700  #include "byteorder.h"         /* Build byte-order independent version */
701  
702  /* Good for i386, but be careful... */
703 -typedef unsigned char byte;
704 -typedef unsigned char uint8;
705 -typedef unsigned short uint16;
706 -typedef unsigned long uint32;
707 -typedef char int8;
708 -typedef short int16;
709 -typedef long int32;
710 +/*
711 +#ifdef linux
712 +#include <sys/types.h>
713 + typedef __u8  byte;
714 + typedef __u8  uint8;
715 + typedef __u16 uint16;
716 + typedef __u32 uint32;
717 + typedef __s8  int8;
718 + typedef __s16 int16;
719 + typedef __s32 int32;
720 +#else
721 + typedef unsigned char byte;
722 + typedef unsigned char uint8;
723 + typedef unsigned ushort uint16;
724 + typedef unsigned uint uint32;
725 + typedef char int8;
726 + typedef short int16;
727 + typedef int int32;
728 +#endif
729 +*/
730 +
731 +#include <stdint.h>
732 +typedef uint8_t byte;
733 +typedef uint8_t        uint8;
734 +typedef uint16_t uint16;
735 +typedef uint32_t uint32;
736 +typedef int8_t int8;
737 +typedef int16_t int16;
738 +typedef int32_t int32;
739  
740  /* Some fixed assumptions:
741     Trial type is always bitsum.
742 @@ -157,7 +179,7 @@ typedef struct eggentry {
743    char *primbasket;
744    int16 conntype;
745    int16 connival;      /* Connect interval in minutes */
746 -  int32 lastupd;       /* Zulutime of last update received */
747 +  uint32 lastupd;      /* Zulutime of last update received */
748    int16 setup;         /* Does setup match config file? */
749    char *upcmd;         /* Command to bring net up (req if conntype == DND) */
750    char *dncmd;         /* Command to bring net down */
751 --- gcpegg-5.1.orig/hw_pear.c
752 +++ gcpegg-5.1/hw_pear.c
753 @@ -87,7 +87,7 @@ int32 OpenDev(DevOpts *opts) {
754       designating /dev/term/a. */
755    sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1));
756  #else
757 -  sprintf(ttydev, "/dev/ttyS%d", opts->port);
758 +  sprintf(ttydev, "/dev/REG", opts->port);
759  #endif
760  
761    switch(opts->baud) {
762 --- gcpegg-5.1.orig/network.c
763 +++ gcpegg-5.1/network.c
764 @@ -237,7 +237,7 @@ int NetListen(int sd, char **pktbuf,
765  
766    size = sizeof(*sin);
767    count = recvfrom(sd, buffer, MAXBUFSIZE, 0,
768 -                  (struct sockaddr *)sin, (int *)&size);
769 +                  (struct sockaddr *)sin, (socklen_t *)&size);
770    if (count < 0) {
771      /* Don't wait for it. */
772      if (errno == EWOULDBLOCK) return ERR_COMM_TMOUT;
773 @@ -246,7 +246,7 @@ int NetListen(int sd, char **pktbuf,
774    }
775  
776  #ifdef HEXDUMP
777 -  fprintf(stderr, "Received %ld bytes from %s\n", count,
778 +  fprintf(stderr, "Received %d bytes from %s\n", count,
779      inet_ntoa(sin->sin_addr));
780    xd(stderr, buffer, count, FALSE);
781  #endif
782 @@ -274,7 +274,7 @@ int NetListen(int sd, char **pktbuf,
783      pktsize = ntohs(rpktsize);
784      if (pktsize != count) {
785  #ifdef DEBUG
786 -        fprintf(stderr, "** Bad packet length: pktsize = %d, count = %ld.\n",
787 +        fprintf(stderr, "** Bad packet length: pktsize = %d, count = %d.\n",
788             pktsize, count);
789  #endif
790         return ERR_PKT_BADLEN;
791 --- gcpegg-5.1.orig/reg_orion.c
792 +++ gcpegg-5.1/reg_orion.c
793 @@ -97,7 +97,7 @@ static int32 OpenDev(DevOpts *opts) {
794    sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1));
795  #endif
796  #else
797 -  sprintf(ttydev, "/dev/ttyS%d", opts->port);
798 +  sprintf(ttydev, "/dev/REG", opts->port);
799  #endif
800  
801    switch(opts->baud) {
802 @@ -111,11 +111,11 @@ static int32 OpenDev(DevOpts *opts) {
803    case 115200: baudcon = B115200; break;
804  #endif
805    default:
806 -    printf("%s: Baud rate %ld not supported.\n", pgmname, opts->baud);
807 +    printf("%s: Baud rate %d not supported.\n", pgmname, opts->baud);
808      return -1;
809    }
810  
811 -  fprintf(stderr, "Opening %s at %ld\n", ttydev, opts->baud);
812 +  fprintf(stderr, "Opening %s at %d\n", ttydev, opts->baud);
813    if ((TTY_fd = open(ttydev, O_RDONLY
814  #ifdef CPU_BOUND
815                                     | O_NDELAY
816 @@ -147,8 +147,10 @@ fprintf(stderr, "Error in open(%s)\n", t
817  #else
818    res = cfsetospeed(&tt, baudcon); 
819    cfmakeraw(&tt);
820 +#if !defined(__FreeBSD_kernel__)
821    tt.c_oflag &= (~(TABDLY | ONLCR));
822  #endif
823 +#endif
824    res = tcsetattr(TTY_fd, TCSANOW, &tt);
825  
826    oldbits[TTY_fd] = bitsleft[TTY_fd] = 0;
827 --- gcpegg-5.1.orig/reg_pear.c
828 +++ gcpegg-5.1/reg_pear.c
829 @@ -77,7 +77,7 @@ static int32 OpenDev(DevOpts *opts) {
830    sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1));
831  #endif
832  #else
833 -  sprintf(ttydev, "/dev/ttyS%d", opts->port);
834 +  sprintf(ttydev, "/dev/REG", opts->port);
835  #endif
836  
837    switch(opts->baud) {
838 @@ -91,11 +91,11 @@ static int32 OpenDev(DevOpts *opts) {
839    case 115200: baudcon = B115200; break;
840  #endif
841    default:
842 -    printf("%s: Baud rate %ld not supported.\n", pgmname, opts->baud);
843 +    printf("%s: Baud rate %d not supported.\n", pgmname, opts->baud);
844      return -1;
845    }
846  
847 -  fprintf(stderr, "Opening %s at %ld\n", ttydev, opts->baud);
848 +  fprintf(stderr, "Opening %s at %d\n", ttydev, opts->baud);
849    if ((TTY_fd = open(ttydev, O_RDONLY
850  #ifdef CPU_BOUND
851                                     | O_NDELAY
852 @@ -122,8 +122,10 @@ static int32 OpenDev(DevOpts *opts) {
853  #else
854    res = cfsetospeed(&tt, baudcon); 
855    cfmakeraw(&tt);
856 +#if !defined(__FreeBSD_kernel__)
857    tt.c_oflag &= (~(TABDLY | ONLCR));
858  #endif
859 +#endif
860    res = tcsetattr(TTY_fd, TCSANOW, &tt);
861  
862    oldbits[TTY_fd] = bitsleft[TTY_fd] = 0;
863 --- gcpegg-5.1.orig/reg_pseudo.c
864 +++ gcpegg-5.1/reg_pseudo.c
865 @@ -27,6 +27,7 @@
866  
867  #include <stdio.h>
868  #include <unistd.h>
869 +#include <time.h>
870  
871  #include "global.h"
872  #include "genlib.h"
873 --- gcpegg-5.1.orig/regtest.c
874 +++ gcpegg-5.1/regtest.c
875 @@ -10,6 +10,10 @@
876  #define __USE_BSD
877  #include <errno.h>
878  #undef __USE_BSD
879 +#if defined(__FreeBSD_kernel__)
880 +/* Not patching the code directly, used once, in a "|" context */
881 +#define O_NDELAY 0
882 +#endif
883  
884  #include <sys/types.h>
885  #include <sys/stat.h>
886 @@ -49,14 +53,16 @@ int main(int argc, char *argv[]) {
887    }
888  
889    if ((TTY_fd = open(argv[1], O_RDWR | O_NDELAY)) < 0) {
890 -    fprintf(stderr, "%s: %s\n", argv[1], sys_errlist[errno]);
891 +    fprintf(stderr, "%s: %s\n", argv[1], strerror(errno));
892      exit(1);
893    }
894  
895    res = tcgetattr(TTY_fd, &tt);
896    res = cfsetospeed(&tt, baud); 
897    cfmakeraw(&tt);
898 +#if !defined(__FreeBSD_kernel__)
899    tt.c_oflag &= (~(TABDLY | ONLCR));
900 +#endif
901    res = tcsetattr(TTY_fd, TCSANOW, &tt);
902  
903    mean = 0;
904 --- gcpegg-5.1.orig/sample.eggrc
905 +++ gcpegg-5.1/sample.eggrc
906 @@ -38,6 +38,9 @@
907  # this time.  Port is serial port number (e.g. 1 for /dev/ttyS1);
908  # <baud> is baud rate.
909  #
910 +#      NOTE: in Debian, the device opened is always /dev/REG!
911 +#            Symlink that to whatever your actual serial device is.
912 +#
913  #   NETUP <script> <args> ...
914  #   NETDOWN <script> <args> ...
915  #
916 @@ -58,8 +61,8 @@
917  #BASKET diesse 193.8.230.134
918  
919  #   noosphere -> diesse
920 -EGG noosphere 28 128.112.35.133 diesse PERM 1
921 -BASKET diesse 193.8.230.134
922 +#EGG noosphere 28 128.112.35.133 diesse PERM 1
923 +#BASKET diesse 193.8.230.134
924  
925  #   throop -> diesse
926  #EGG throop 1003 193.8.230.132 diesse PERM 1 http://www.fourmilab.ch/
927 @@ -78,9 +81,16 @@ BASKET diesse 193.8.230.134
928  
929  #BASKET tonga 209.157.90.137
930  #BASKET tonga1 209.157.90.138
931 -PROTOCOL 10 10 6 200
932 +#PROTOCOL 10 10 6 200
933  #REG PEAR 2 9600
934 -REG PSEUDO 1 9600
935 +#REG PSEUDO 1 9600
936  #REG ORION 1 9600
937 -NETUP pppscript up
938 -NETDOWN pppscript down
939 +#NETUP pppscript up
940 +#NETDOWN pppscript down
941 +
942 +egg.host.name ID# IP_address noosphere PERM 1 
943 +BASKET noosphere 128.112.35.133 
944 +PROTOCOL 10 10 30 200
945 +REG ORION 0 9600
946 +#REG PEAR 0 9600
947 +
948 --- gcpegg-5.1.orig/storage.c
949 +++ gcpegg-5.1/storage.c
950 @@ -43,7 +43,7 @@
951     an error on the following declaration, disable it for your
952     platform. */
953  
954 -extern char *strdup (const char *s1);
955 +/*extern char *strdup (const char *s1);*/
956  
957  /* Eventually, these might deal with making a safe copy or mounting
958     and unmounting a partition. Until such time as we actually do
959 @@ -77,7 +77,7 @@ static int32 next_poss_fn(char *fn, uint
960  struct seekopt {
961      char filename[256];
962      uint32 last_time;
963 -    long next_packet;
964 +    int32 next_packet;
965  };
966  
967  static struct seekopt seekOpt[SEEK_OPT_MAX];
968 @@ -217,11 +217,12 @@ int32 InitStorage(char *path) {
969  int32 SavePacket(EggCarton *cart) {
970    FILE         *fp;
971    char         *packet, datatmp[255], datafile[255], *sp;
972 -  int32        pktime, res;
973 +  uint32       pktime, res;
974  
975    pktime = cart->records[0].timestamp;
976  #ifdef STORAGE_DEBUG
977 -  fprintf(stderr, "SavePacket for %lu: %s", pktime, asctime(gmtime((time_t *) &pktime)));
978 +  time_t pktime_val = pktime;
979 +  fprintf(stderr, "SavePacket for %u: %s", pktime, asctime(gmtime(&pktime_val)));
980  #endif
981  
982    /* Generate the file name corresponding to the date of
983 @@ -285,8 +286,9 @@ int32 OpenDatabase(DBRec *dbp, uint32 ti
984    int32        res;
985  
986  #ifdef STORAGE_DEBUG
987 -  fprintf(stderr, "OpenDatabase: Egg = %d, tindex = %ld %s",
988 -    eggid, tindex, asctime(gmtime((time_t *) &tindex)));
989 +  time_t tindex_val = tindex;
990 +  fprintf(stderr, "OpenDatabase: Egg = %d, tindex = %u %s",
991 +    eggid, tindex, asctime(gmtime(&tindex_val)));
992  #endif
993    dbp->eggind = 0;
994    dbp->fp = NULL;
995 @@ -344,7 +346,7 @@ static int32 LoadNextPacket(DBRec *dbp,
996      findex = PROJSTART;
997    }
998  #ifdef STORAGE_DEBUG
999 -  fprintf(stderr, "LoadNextPacket(%s, %lu, %d)\n", dbp->fn, tindex, eggid);
1000 +  fprintf(stderr, "LoadNextPacket(%s, %u, %d)\n", dbp->fn, tindex, eggid);
1001  #endif
1002  
1003    /* See if the start address for this request is present
1004 @@ -364,20 +366,22 @@ static int32 LoadNextPacket(DBRec *dbp,
1005           seekOpt[i].last_time == tindex) {
1006           fseek(dbp->fp, seekOpt[i].next_packet, SEEK_SET);
1007  #ifdef STORAGE_DEBUG
1008 -          fprintf(stderr, "LoadNextPacket; Seek optimised [%ld] to %ld for\n    file %s at %lu %s",
1009 +        time_t last_time_val = seekOpt[i].last_time;
1010 +        fprintf(stderr, "LoadNextPacket; Seek optimised [%d] to %d for\n    file %s at %u %s",
1011               i,
1012               seekOpt[i].next_packet, 
1013               seekOpt[i].filename,
1014               seekOpt[i].last_time,
1015 -             asctime(gmtime((time_t *) &(seekOpt[i].last_time))));
1016 +             asctime(gmtime(&last_time_val)));
1017  
1018  #endif
1019           break;
1020        }
1021        if (i == seekOptIndex) {
1022  #ifdef STORAGE_DEBUG
1023 -          fprintf(stderr, "LoadNextPacket; Cannot optimise seek in file %s\n    at %lu %s",
1024 -             dbp->fn, tindex, asctime(gmtime((time_t *) &(tindex))));
1025 +        time_t tindex_val = tindex;
1026 +          fprintf(stderr, "LoadNextPacket; Cannot optimise seek in file %s\n    at %u %s",
1027 +             dbp->fn, tindex, asctime(gmtime(&tindex_val)));
1028  #endif
1029           break;                      /* Search wrapped table--cannot optimise */
1030        }
1031 @@ -396,13 +400,15 @@ static int32 LoadNextPacket(DBRec *dbp,
1032  #define SECONDS_PER_DAY (24L * 60 * 60)
1033        findex = ((findex / SECONDS_PER_DAY) + 1) * SECONDS_PER_DAY;
1034  #ifdef STORAGE_DEBUG
1035 -      fprintf(stderr, "LoadNextPacket; EOF, CloseDatabase, findex = %lu: %s",
1036 -         findex, asctime(gmtime((time_t *) &findex)));
1037 +     time_t findex_val = findex;
1038 +      fprintf(stderr, "LoadNextPacket; EOF, CloseDatabase, findex = %u: %s",
1039 +         findex, asctime(gmtime(&findex_val)));
1040  #endif
1041        if (findex > now) {
1042  #ifdef STORAGE_DEBUG
1043 -          fprintf(stderr, "LoadNextPacket; EOF findex = %lu > now = %lu %s",
1044 -         findex, now, asctime(gmtime((time_t *) &now)));
1045 +     time_t now_val = now;
1046 +          fprintf(stderr, "LoadNextPacket; EOF findex = %u > now = %u %s",
1047 +         findex, now, asctime(gmtime(&now_val)));
1048  #endif
1049         return ERR_EOF;
1050        }
1051 @@ -427,12 +433,13 @@ fprintf(stderr, "Eggid = %d Packet.eggid
1052         seekOpt[seekOptIndex].last_time = pktbuf.records[pktbuf.hdr.numrec - 1].timestamp;
1053         seekOpt[seekOptIndex].next_packet = ftell(dbp->fp);
1054  #ifdef STORAGE_DEBUG
1055 -        fprintf(stderr, "LoadNextPacket; Seek optimisation[%d] for %s\n    to address %ld for time %lu %s",
1056 +     time_t last_time_val = seekOpt[seekOptIndex].last_time;
1057 +        fprintf(stderr, "LoadNextPacket; Seek optimisation[%d] for %s\n    to address %d for time %u %s",
1058             seekOptIndex,
1059             seekOpt[seekOptIndex].filename,
1060             seekOpt[seekOptIndex].next_packet, 
1061             seekOpt[seekOptIndex].last_time,
1062 -           asctime(gmtime((time_t *) &(seekOpt[seekOptIndex].last_time))));
1063 +           asctime(gmtime(&last_time_val)));
1064  #endif
1065         seekOptIndex = (seekOptIndex + 1) % SEEK_OPT_MAX;
1066         return ERR_NONE;
1067 @@ -495,8 +502,9 @@ static int32 next_filename(char *fn, uin
1068    char         ldf[255];
1069  
1070  #ifdef STORAGE_DEBUG
1071 -  fprintf(stderr, "next_filename: egg = %d, mustexist = %d, tindex = %lu %s",
1072 -    eggid, mustexist, tindex, asctime(gmtime((time_t *) &tindex)));
1073 +  time_t tindex_val = tindex;
1074 +  fprintf(stderr, "next_filename: egg = %d, mustexist = %d, tindex = %u %s",
1075 +    eggid, mustexist, tindex, asctime(gmtime(&tindex_val)));
1076  #endif
1077    if (eggid < 0 && !mustexist) {
1078  #ifdef STORAGE_DEBUG
1079 @@ -557,10 +565,11 @@ static int32 next_poss_fn(char *fn, uint
1080    int16        eggind;
1081    struct tm    *tm;
1082  
1083 -  tm = gmtime((time_t *) &tindex);
1084 +  time_t time_index = tindex;
1085 +  tm = gmtime(&time_index);
1086    strftime(datatmp, 255, datafmt, tm);
1087  #ifdef STORAGE_DEBUG
1088 -  fprintf(stderr, "next_poss_fn: egg = %d, tindex = %lu %s",
1089 +  fprintf(stderr, "next_poss_fn: egg = %d, tindex = %u %s",
1090      eggid, tindex, asctime(tm));
1091  #endif
1092  
1093 --- gcpegg-5.1.orig/xdsub.c
1094 +++ gcpegg-5.1/xdsub.c
1095 @@ -20,7 +20,7 @@ static char addrformat[80] = "%6X";
1096  static char dataformat1[80] = "%02X";
1097  static int bytesperline = 16, doublechar = 0,
1098            dflen = 2;
1099 -static unsigned long fileaddr;
1100 +static unsigned int fileaddr;
1101  static unsigned char lineecho[32];
1102  
1103  /*  OUTLINE  --  Edit a line of binary data into the selected output