--- ray/src/common/rtio.h 2018/04/10 23:38:40 3.16 +++ ray/src/common/rtio.h 2021/01/15 18:31:38 3.24 @@ -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.24 2021/01/15 18:31:38 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 @@ -22,13 +23,47 @@ #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 fltdepth.c */ +extern int open_float_depth(const char *fname, long expected_length); /* defined in badarg.c */ extern int badarg(int ac, char **av, char *fl); /* defined in expandarg.c */ @@ -54,18 +89,18 @@ extern char *gethomedir(char *uname, char *path, int p /* defined in getpath.c */ extern char *getpath(char *fname, char *searchpath, int mode); /* defined in byteswap.c */ -extern void swap16(char *wp, int n); -extern void swap32(char *wp, int n); -extern void swap64(char *wp, int n); +extern void swap16(char *wp, size_t n); +extern void swap32(char *wp, size_t n); +extern void swap64(char *wp, size_t n); /* defined in portio.c */ 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(const void *s, int elsiz, int nel, FILE *fp); +extern size_t putbinary(const void *s, size_t elsiz, size_t 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(void *s, int elsiz, int nel, FILE *fp); +extern size_t getbinary(void *s, size_t elsiz, size_t nel, FILE *fp); /* defined in rexpr.c */ extern int ecompile(char *sp, int iflg, int wflag); extern char *expsave(void); @@ -96,6 +131,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 }