merge 64-bit fixes from Fernando Lucas Rodriguez <fernando_lr@terra.es>
[debian/gcpegg] / genlib.h
1 /* PROGRAM:     eggsh
2  * FILE:        $Header: /home/egg/src/RCS/genlib.h,v 1.3 1999/02/28 20:05:35 ghn Exp $
3  * PURPOSE:     Define general library interface
4  * AUTHOR:      Greg Nelson
5  * DATE:        98-05-09
6  *
7  * REVISED:
8  * $Log: genlib.h,v $
9  * Revision 1.3  1999/02/28 20:05:35  ghn
10  * Version 5.1: Changed dquad2sockaddr interface to support ip/mm mask,
11  * created hl2dquad to translate host-long to dotted quad, and modified
12  * sockaddr2dquad to use this.
13  *
14  * Revision 1.2  1998/12/31 22:11:05  ghn
15  *  Rev 5 code: includes multi-reg support, HTML, etc.
16  *
17  * Revision 1.1  1998/07/21 11:38:04  ghn
18  * Initial revision
19  *
20  * Copyright 1998 - Greg Nelson
21  */
22
23 #ifndef _GENLIB_H
24
25 #include <unistd.h>
26 #include <sys/time.h>
27 #include <netinet/in.h>
28 #include "global.h"
29
30 #define MAX_PARSE       20
31
32 #ifdef OBSOLETE
33 /* This is actually 366 * 24 * 60 * 60, as opposed the actual length
34    of the mean solar year which is about 365.2524 days.  */
35 #define SEC_PER_YEAR    31622400L
36 #endif
37
38 /* Get time in GMT reference frame.  If ztv is NULL, simply returns
39    seconds.  Otherwise, returns complete timeval in ztv as well. */
40 extern uint32 getzulutime(struct timeval *ztv);
41
42 /* Get difference in msec between two tvs. */
43 extern int32 deltams(struct timeval *tv1, struct timeval *tv2);
44
45 /* Look up an EGG id. */
46 extern uint16 GetID(void);
47
48 /* Create a proper checksummed and packetized byte stream from the raw
49    data in memory.  Return result is malloc'ed, so should be freed by
50    caller. */
51 extern char *Packetize(EggCarton *src);
52
53 extern int32 Unpacketize(EggCarton *dst, char *src);
54
55 /* Compute CRC16 checksum given block and length (from crc16.c) */
56 extern uint16 BlockCRC16(byte *block, uint32 len);
57
58 extern void Parse(char *input, int *argc, char *argv[]);
59 extern char *mallocpy(char *input);
60 extern void dquad2sockaddr(struct sockaddr_in *sinp, int16 *mask, char *dquad);
61 extern char *sockaddr2dquad(struct sockaddr_in *sinp); /* Static buffer! */
62 extern char *hl2dquad(uint32 addr);     /* Static buffer! */
63
64
65 /* Access to system or emulated usleep(). */
66
67 #ifdef USLEEP
68 extern void sf_usleep(unsigned t);
69 #define Usleep sf_usleep
70 #else
71 #define Usleep usleep
72 #endif
73
74 #define _GENLIB_H
75 #endif /* _GENLIB_H */