--- ray/src/common/rtio.h 2016/03/03 22:09:59 3.11 +++ ray/src/common/rtio.h 2019/08/14 18:20:02 3.22 @@ -1,4 +1,4 @@ -/* RCSid $Id: rtio.h,v 3.11 2016/03/03 22:09:59 greg Exp $ */ +/* RCSid $Id: rtio.h,v 3.22 2019/08/14 18:20:02 greg Exp $ */ /* * Radiance i/o and string routines */ @@ -10,20 +10,62 @@ #include #include #include +#include #ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ #undef getc +#undef getchar #undef putc +#undef putchar +#undef feof +#undef ferror #define getc getc_unlocked +#define getchar getchar_unlocked #define putc putc_unlocked +#define putchar putchar_unlocked +#ifndef __cplusplus +#define feof feof_unlocked +#define ferror ferror_unlocked #endif +#endif #ifdef __cplusplus extern "C" { #endif + /* identify header lines */ +#define MAXFMTLEN 64 +#define isheadid(s) headidval(NULL,s) +#define isformat(s) formatval(NULL,s) +#define isdate(s) dateval(NULL,s) +#define isgmt(s) gmtval(NULL,s) + +#define LATLONSTR "LATLONG=" +#define LLATLONSTR 8 +#define islatlon(hl) (!strncmp(hl,LATLONSTR,LLATLONSTR)) +#define latlonval(ll,hl) sscanf((hl)+LLATLONSTR, "%f %f", \ + &(ll)[0],&(ll)[1]) +#define fputlatlon(lat,lon,fp) fprintf(fp,"%s %.6f %.6f\n",LATLONSTR,lat,lon) + /* defined in header.c */ +extern void newheader(const char *t, FILE *fp); +extern int headidval(char *r, const char *s); +extern int dateval(time_t *t, const char *s); +extern int gmtval(time_t *t, const char *s); +extern void fputdate(time_t t, FILE *fp); +extern void fputnow(FILE *fp); +extern void printargs(int ac, char **av, FILE *fp); +extern int formatval(char fmt[MAXFMTLEN], const char *s); +extern void fputformat(const char *s, FILE *fp); +extern int nativebigendian(void); +extern int isbigendian(const char *s); +extern void fputendian(FILE *fp); +typedef int gethfunc(char *s, void *p); /* callback to process header lines */ +extern int getheader(FILE *fp, gethfunc *f, void *p); +extern int globmatch(const char *pat, const char *str); +extern int checkheader(FILE *fin, char fmt[MAXFMTLEN], FILE *fout); /* defined in badarg.c */ extern int badarg(int ac, char **av, char *fl); /* defined in expandarg.c */ +extern int envexpchr, filexpchr; extern int expandarg(int *acp, char ***avp, int n); /* defined in fdate.c */ extern time_t fdate(char *fname); @@ -52,11 +94,11 @@ extern void swap64(char *wp, int n); extern void putstr(char *s, FILE *fp); extern void putint(long i, int siz, FILE *fp); extern void putflt(double f, FILE *fp); -extern int putbinary(char *s, int elsiz, int nel, FILE *fp); +extern int putbinary(const void *s, int elsiz, int nel, FILE *fp); extern char *getstr(char *s, FILE *fp); extern long getint(int siz, FILE *fp); extern double getflt(FILE *fp); -extern int getbinary(char *s, int elsiz, int nel, FILE *fp); +extern int getbinary(void *s, int elsiz, int nel, FILE *fp); /* defined in rexpr.c */ extern int ecompile(char *sp, int iflg, int wflag); extern char *expsave(void); @@ -70,8 +112,8 @@ extern int shash(char *s); extern char *savqstr(char *s); extern void freeqstr(char *s); /* defined in wordfile.c */ -extern int wordfile(char **words, char *fname); -extern int wordstring(char **avl, char *str); +extern int wordfile(char **words, int nargs, char *fname); +extern int wordstring(char **avl, int nargs, char *str); /* defined in words.c */ extern char *atos(char *rs, int nb, char *s); extern char *nextword(char *cp, int nb, char *s); @@ -87,6 +129,11 @@ extern int isfltd(char *s, char *ds); extern float * matchlamp(char *s); extern int loadlamps(char *file); extern void freelamps(void); + +#ifndef strlcpy /* defined in option strlcpy.c */ +extern size_t strlcpy(char *dst, const char *src, size_t siz); +extern size_t strlcat(char *dst, const char *src, size_t siz); +#endif #ifdef __cplusplus }