--- ray/src/common/rtio.h 2018/04/10 23:38:40 3.16 +++ ray/src/common/rtio.h 2019/07/19 17:37:56 3.20 @@ -1,4 +1,4 @@ -/* RCSid $Id: rtio.h,v 3.16 2018/04/10 23:38:40 greg Exp $ */ +/* RCSid $Id: rtio.h,v 3.20 2019/07/19 17:37:56 greg Exp $ */ /* * Radiance i/o and string routines */ @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ #undef getc @@ -29,6 +30,33 @@ #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); +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 */ @@ -96,6 +124,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 }