10 |
|
#include <sys/types.h> |
11 |
|
#include <fcntl.h> |
12 |
|
#include <string.h> |
13 |
+ |
#include <time.h> |
14 |
|
|
15 |
|
#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ |
16 |
|
#undef getc |
17 |
|
#undef getchar |
18 |
|
#undef putc |
19 |
|
#undef putchar |
19 |
– |
#undef feof |
20 |
– |
#undef ferror |
20 |
|
#define getc getc_unlocked |
21 |
|
#define getchar getchar_unlocked |
22 |
|
#define putc putc_unlocked |
23 |
|
#define putchar putchar_unlocked |
24 |
+ |
#ifndef __cplusplus |
25 |
+ |
#undef feof |
26 |
+ |
#undef ferror |
27 |
|
#define feof feof_unlocked |
28 |
|
#define ferror ferror_unlocked |
29 |
|
#endif |
30 |
+ |
#endif |
31 |
|
|
32 |
|
#ifdef __cplusplus |
33 |
|
extern "C" { |
34 |
|
#endif |
35 |
+ |
/* identify header lines */ |
36 |
+ |
#define MAXFMTLEN 64 |
37 |
+ |
#define isheadid(s) headidval(NULL,s) |
38 |
+ |
#define isformat(s) formatval(NULL,s) |
39 |
+ |
#define isdate(s) dateval(NULL,s) |
40 |
+ |
#define isgmt(s) gmtval(NULL,s) |
41 |
+ |
|
42 |
+ |
#define LATLONSTR "LATLONG=" |
43 |
+ |
#define LLATLONSTR 8 |
44 |
+ |
#define islatlon(hl) (!strncmp(hl,LATLONSTR,LLATLONSTR)) |
45 |
+ |
#define latlonval(ll,hl) sscanf((hl)+LLATLONSTR, "%f %f", \ |
46 |
+ |
&(ll)[0],&(ll)[1]) |
47 |
+ |
#define fputlatlon(lat,lon,fp) fprintf(fp,"%s %.6f %.6f\n",LATLONSTR,lat,lon) |
48 |
+ |
/* defined in header.c */ |
49 |
+ |
extern void newheader(const char *t, FILE *fp); |
50 |
+ |
extern int headidval(char *r, const char *s); |
51 |
+ |
extern int dateval(time_t *t, const char *s); |
52 |
+ |
extern int gmtval(time_t *t, const char *s); |
53 |
+ |
extern void fputdate(time_t t, FILE *fp); |
54 |
+ |
extern void fputnow(FILE *fp); |
55 |
+ |
extern void printargs(int ac, char **av, FILE *fp); |
56 |
+ |
extern int formatval(char fmt[MAXFMTLEN], const char *s); |
57 |
+ |
extern void fputformat(const char *s, FILE *fp); |
58 |
+ |
extern int nativebigendian(void); |
59 |
+ |
extern int isbigendian(const char *s); |
60 |
+ |
extern void fputendian(FILE *fp); |
61 |
+ |
typedef int gethfunc(char *s, void *p); /* callback to process header lines */ |
62 |
+ |
extern int getheader(FILE *fp, gethfunc *f, void *p); |
63 |
+ |
extern int globmatch(const char *pat, const char *str); |
64 |
+ |
extern int checkheader(FILE *fin, char fmt[MAXFMTLEN], FILE *fout); |
65 |
+ |
/* defined in fltdepth.c */ |
66 |
+ |
extern int open_float_depth(const char *fname, long expected_length); |
67 |
|
/* defined in badarg.c */ |
68 |
< |
extern int badarg(int ac, char **av, char *fl); |
68 |
> |
extern int badarg(int ac, char **av, const char *fl); |
69 |
|
/* defined in expandarg.c */ |
70 |
|
extern int envexpchr, filexpchr; |
71 |
|
extern int expandarg(int *acp, char ***avp, int n); |
72 |
|
/* defined in fdate.c */ |
73 |
< |
extern time_t fdate(char *fname); |
74 |
< |
extern int setfdate(char *fname, long ftim); |
73 |
> |
extern time_t fdate(const char *fname); |
74 |
> |
extern time_t fddate(int fd); |
75 |
> |
extern int setfdate(const char *fname, long ftim); |
76 |
|
/* defined in fgetline.c */ |
77 |
|
extern char *fgetline(char *s, int n, FILE *fp); |
78 |
|
/* defined in fgetval.c */ |
90 |
|
/* defined in getpath.c */ |
91 |
|
extern char *getpath(char *fname, char *searchpath, int mode); |
92 |
|
/* defined in byteswap.c */ |
93 |
< |
extern void swap16(char *wp, int n); |
94 |
< |
extern void swap32(char *wp, int n); |
95 |
< |
extern void swap64(char *wp, int n); |
93 |
> |
extern void swap16(char *wp, size_t n); |
94 |
> |
extern void swap32(char *wp, size_t n); |
95 |
> |
extern void swap64(char *wp, size_t n); |
96 |
|
/* defined in portio.c */ |
97 |
< |
extern void putstr(char *s, FILE *fp); |
98 |
< |
extern void putint(long i, int siz, FILE *fp); |
99 |
< |
extern void putflt(double f, FILE *fp); |
100 |
< |
extern int putbinary(const void *s, int elsiz, int nel, FILE *fp); |
97 |
> |
extern int putstr(char *s, FILE *fp); |
98 |
> |
extern int putint(long i, int siz, FILE *fp); |
99 |
> |
extern int putflt(double f, FILE *fp); |
100 |
> |
extern size_t putbinary(const void *s, size_t elsiz, size_t nel, FILE *fp); |
101 |
|
extern char *getstr(char *s, FILE *fp); |
102 |
|
extern long getint(int siz, FILE *fp); |
103 |
|
extern double getflt(FILE *fp); |
104 |
< |
extern int getbinary(void *s, int elsiz, int nel, FILE *fp); |
104 |
> |
extern size_t getbinary(void *s, size_t elsiz, size_t nel, FILE *fp); |
105 |
|
/* defined in rexpr.c */ |
106 |
|
extern int ecompile(char *sp, int iflg, int wflag); |
107 |
|
extern char *expsave(void); |
108 |
|
extern void expset(char *ep); |
109 |
|
extern char *eindex(char *sp); |
110 |
|
/* defined in savestr.c */ |
111 |
< |
extern char *savestr(char *str); |
111 |
> |
extern char *savestr(const char *str); |
112 |
|
extern void freestr(char *s); |
113 |
< |
extern int shash(char *s); |
113 |
> |
extern int shash(const char *s); |
114 |
|
/* defined in savqstr.c */ |
115 |
|
extern char *savqstr(char *s); |
116 |
|
extern void freeqstr(char *s); |
133 |
|
extern int loadlamps(char *file); |
134 |
|
extern void freelamps(void); |
135 |
|
|
136 |
< |
#ifdef __GNUC__ /* defined in option strlcpy.c */ |
136 |
> |
#ifndef strlcpy /* defined in option strlcpy.c */ |
137 |
|
extern size_t strlcpy(char *dst, const char *src, size_t siz); |
138 |
|
extern size_t strlcat(char *dst, const char *src, size_t siz); |
139 |
|
#endif |