| 1 | greg | 3.23 | /* RCSid $Id: rtio.h,v 3.22 2019/08/14 18:20:02 greg Exp $ */ | 
| 2 | greg | 3.1 | /* | 
| 3 |  |  | *      Radiance i/o and string routines | 
| 4 |  |  | */ | 
| 5 |  |  |  | 
| 6 |  |  | #ifndef _RAD_RTIO_H_ | 
| 7 |  |  | #define _RAD_RTIO_H_ | 
| 8 |  |  |  | 
| 9 |  |  | #include  <stdio.h> | 
| 10 |  |  | #include  <sys/types.h> | 
| 11 |  |  | #include  <fcntl.h> | 
| 12 |  |  | #include  <string.h> | 
| 13 | greg | 3.20 | #include  <time.h> | 
| 14 | schorsch | 3.3 |  | 
| 15 | greg | 3.11 | #ifdef getc_unlocked            /* avoid horrendous overhead of flockfile */ | 
| 16 |  |  | #undef getc | 
| 17 | greg | 3.15 | #undef getchar | 
| 18 | greg | 3.11 | #undef putc | 
| 19 | greg | 3.15 | #undef putchar | 
| 20 | greg | 3.16 | #undef feof | 
| 21 |  |  | #undef ferror | 
| 22 | greg | 3.11 | #define getc    getc_unlocked | 
| 23 | greg | 3.15 | #define getchar getchar_unlocked | 
| 24 | greg | 3.11 | #define putc    putc_unlocked | 
| 25 | greg | 3.15 | #define putchar putchar_unlocked | 
| 26 | greg | 3.21 | #ifndef __cplusplus | 
| 27 | greg | 3.16 | #define feof    feof_unlocked | 
| 28 |  |  | #define ferror  ferror_unlocked | 
| 29 | greg | 3.11 | #endif | 
| 30 | greg | 3.21 | #endif | 
| 31 | greg | 3.11 |  | 
| 32 | schorsch | 3.3 | #ifdef __cplusplus | 
| 33 |  |  | extern "C" { | 
| 34 |  |  | #endif | 
| 35 | greg | 3.20 | /* 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 | greg | 3.22 | extern int      nativebigendian(void); | 
| 59 |  |  | extern int      isbigendian(const char *s); | 
| 60 |  |  | extern void     fputendian(FILE *fp); | 
| 61 | greg | 3.20 | 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 | greg | 3.23 | /* defined in fltdepth.c */ | 
| 66 |  |  | extern int      open_float_depth(const char *fname, long expected_length); | 
| 67 | greg | 3.1 | /* defined in badarg.c */ | 
| 68 |  |  | extern int      badarg(int ac, char **av, char *fl); | 
| 69 |  |  | /* defined in expandarg.c */ | 
| 70 | greg | 3.14 | extern int      envexpchr, filexpchr; | 
| 71 | greg | 3.1 | 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); | 
| 75 |  |  | /* defined in fgetline.c */ | 
| 76 |  |  | extern char     *fgetline(char *s, int n, FILE *fp); | 
| 77 |  |  | /* defined in fgetval.c */ | 
| 78 | schorsch | 3.8 | extern int      fgetval(FILE *fp, int ty, void *vp); | 
| 79 | greg | 3.1 | /* defined in fgetword.c */ | 
| 80 |  |  | extern char     *fgetword(char *s, int n, FILE *fp); | 
| 81 |  |  | /* defined in fputword.c */ | 
| 82 |  |  | extern void     fputword(char *s, FILE *fp); | 
| 83 |  |  | /* defined in fropen.c */ | 
| 84 |  |  | extern FILE     *frlibopen(char *fname); | 
| 85 |  |  | /* defined in getlibpath.c */ | 
| 86 |  |  | extern char     *getrlibpath(void); | 
| 87 | schorsch | 3.5 | /* defined in gethomedir.c */ | 
| 88 | greg | 3.10 | extern char     *gethomedir(char *uname, char *path, int plen); | 
| 89 | greg | 3.1 | /* defined in getpath.c */ | 
| 90 |  |  | extern char     *getpath(char *fname, char *searchpath, int mode); | 
| 91 | greg | 3.9 | /* defined in byteswap.c */ | 
| 92 |  |  | extern void     swap16(char *wp, int n); | 
| 93 |  |  | extern void     swap32(char *wp, int n); | 
| 94 |  |  | extern void     swap64(char *wp, int n); | 
| 95 | greg | 3.1 | /* defined in portio.c */ | 
| 96 |  |  | extern void     putstr(char *s, FILE *fp); | 
| 97 |  |  | extern void     putint(long i, int siz, FILE *fp); | 
| 98 |  |  | extern void     putflt(double f, FILE *fp); | 
| 99 | greg | 3.13 | extern int      putbinary(const void *s, int elsiz, int nel, FILE *fp); | 
| 100 | greg | 3.1 | extern char     *getstr(char *s, FILE *fp); | 
| 101 |  |  | extern long     getint(int siz, FILE *fp); | 
| 102 |  |  | extern double   getflt(FILE *fp); | 
| 103 | greg | 3.13 | extern int      getbinary(void *s, int elsiz, int nel, FILE *fp); | 
| 104 | greg | 3.1 | /* defined in rexpr.c */ | 
| 105 |  |  | extern int      ecompile(char *sp, int iflg, int wflag); | 
| 106 |  |  | extern char     *expsave(void); | 
| 107 |  |  | extern void     expset(char *ep); | 
| 108 |  |  | extern char     *eindex(char *sp); | 
| 109 |  |  | /* defined in savestr.c */ | 
| 110 |  |  | extern char     *savestr(char *str); | 
| 111 |  |  | extern void     freestr(char *s); | 
| 112 |  |  | extern int      shash(char *s); | 
| 113 |  |  | /* defined in savqstr.c */ | 
| 114 |  |  | extern char     *savqstr(char *s); | 
| 115 |  |  | extern void     freeqstr(char *s); | 
| 116 |  |  | /* defined in wordfile.c */ | 
| 117 | greg | 3.12 | extern int      wordfile(char **words, int nargs, char *fname); | 
| 118 |  |  | extern int      wordstring(char **avl, int nargs, char *str); | 
| 119 | greg | 3.1 | /* defined in words.c */ | 
| 120 |  |  | extern char     *atos(char *rs, int nb, char *s); | 
| 121 |  |  | extern char     *nextword(char *cp, int nb, char *s); | 
| 122 |  |  | extern char     *sskip(char *s); | 
| 123 |  |  | extern char     *sskip2(char *s, int n); | 
| 124 |  |  | extern char     *iskip(char *s); | 
| 125 |  |  | extern char     *fskip(char *s); | 
| 126 |  |  | extern int      isint(char *s); | 
| 127 |  |  | extern int      isintd(char *s, char *ds); | 
| 128 |  |  | extern int      isflt(char *s); | 
| 129 |  |  | extern int      isfltd(char *s, char *ds); | 
| 130 |  |  | /* defined in lamp.c */ | 
| 131 |  |  | extern float *  matchlamp(char *s); | 
| 132 |  |  | extern int      loadlamps(char *file); | 
| 133 |  |  | extern void     freelamps(void); | 
| 134 | greg | 3.18 |  | 
| 135 | greg | 3.19 | #ifndef strlcpy                         /* defined in option strlcpy.c */ | 
| 136 | greg | 3.17 | extern size_t   strlcpy(char *dst, const char *src, size_t siz); | 
| 137 |  |  | extern size_t   strlcat(char *dst, const char *src, size_t siz); | 
| 138 | greg | 3.18 | #endif | 
| 139 | greg | 3.1 |  | 
| 140 |  |  | #ifdef __cplusplus | 
| 141 |  |  | } | 
| 142 |  |  | #endif | 
| 143 |  |  | #endif /* _RAD_RTIO_H_ */ | 
| 144 |  |  |  |