| 1 |
/* RCSid $Id: rtio.h,v 3.32 2024/12/03 01:11:43 greg Exp $ */
|
| 2 |
/*
|
| 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 |
#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
|
| 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]) == 2)
|
| 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, 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(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 */
|
| 79 |
extern int fgetval(FILE *fp, int ty, void *vp);
|
| 80 |
/* defined in fgetword.c */
|
| 81 |
extern char *fgetword(char *s, int n, FILE *fp);
|
| 82 |
/* defined in fputword.c */
|
| 83 |
extern void fputword(char *s, FILE *fp);
|
| 84 |
/* defined in fropen.c */
|
| 85 |
extern FILE *frlibopen(char *fname);
|
| 86 |
/* defined in getlibpath.c */
|
| 87 |
extern char *getrlibpath(void);
|
| 88 |
/* defined in gethomedir.c */
|
| 89 |
extern char *gethomedir(char *uname, char *path, int plen);
|
| 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, 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 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 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(const char *str);
|
| 112 |
extern void freestr(char *s);
|
| 113 |
extern int shash(const char *s);
|
| 114 |
/* defined in savqstr.c */
|
| 115 |
extern char *savqstr(const char *s);
|
| 116 |
extern void freeqstr(char *s);
|
| 117 |
/* defined in wordfile.c */
|
| 118 |
extern int wordfile(char **words, int nargs, char *fname);
|
| 119 |
extern int wordstring(char **avl, int nargs, char *str);
|
| 120 |
/* defined in words.c */
|
| 121 |
extern char *atos(char *rs, int nb, char *s);
|
| 122 |
extern char *nextword(char *cp, int nb, char *s);
|
| 123 |
extern char *sskip(char *s);
|
| 124 |
extern char *sskip2(char *s, int n);
|
| 125 |
extern char *iskip(char *s);
|
| 126 |
extern char *fskip(char *s);
|
| 127 |
extern int isint(char *s);
|
| 128 |
extern int isintd(char *s, char *ds);
|
| 129 |
extern int isflt(char *s);
|
| 130 |
extern int isfltd(char *s, char *ds);
|
| 131 |
/* defined in lamp.c */
|
| 132 |
extern float * matchlamp(char *s);
|
| 133 |
extern int loadlamps(char *file);
|
| 134 |
extern void freelamps(void);
|
| 135 |
|
| 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
|
| 140 |
#ifndef strncasecmp /* defined in option strncasecmp.c */
|
| 141 |
extern int strncasecmp(const char *s1, const char *s2, size_t n);
|
| 142 |
#endif
|
| 143 |
#ifndef strnstr /* defined in option strnstr.c */
|
| 144 |
extern char * strnstr(const char *haystack,
|
| 145 |
const char *needle, size_t len);
|
| 146 |
#endif
|
| 147 |
|
| 148 |
#ifdef __cplusplus
|
| 149 |
}
|
| 150 |
#endif
|
| 151 |
#endif /* _RAD_RTIO_H_ */
|
| 152 |
|