ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/rtio.h
Revision: 3.34
Committed: Sat Jun 7 05:09:45 2025 UTC (10 hours, 54 minutes ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 3.33: +1 -10 lines
Log Message:
refactor: Put some declarations into "paths.h" and included in "platform.h"

File Contents

# Content
1 /* RCSid $Id: rtio.h,v 3.33 2025/03/01 00:51:26 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 int formatval(char fmt[MAXFMTLEN], const char *s);
56 extern void fputformat(const char *s, FILE *fp);
57 extern int nativebigendian(void);
58 extern int isbigendian(const char *s);
59 extern void fputendian(FILE *fp);
60 typedef int gethfunc(char *s, void *p); /* callback to process header lines */
61 extern int getheader(FILE *fp, gethfunc *f, void *p);
62 extern int globmatch(const char *pat, const char *str);
63 extern int checkheader(FILE *fin, char fmt[MAXFMTLEN], FILE *fout);
64 /* defined in fltdepth.c */
65 extern int open_float_depth(const char *fname, long expected_length);
66 /* defined in badarg.c */
67 extern int badarg(int ac, char **av, const char *fl);
68 /* defined in expandarg.c */
69 extern int envexpchr, filexpchr;
70 extern int expandarg(int *acp, char ***avp, int n);
71 /* defined in fdate.c */
72 extern time_t fdate(const char *fname);
73 extern time_t fddate(int fd);
74 extern int setfdate(const 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 extern int fgetval(FILE *fp, int ty, void *vp);
79 /* 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 byteswap.c */
84 extern void swap16(char *wp, size_t n);
85 extern void swap32(char *wp, size_t n);
86 extern void swap64(char *wp, size_t n);
87 /* defined in portio.c */
88 extern int putstr(char *s, FILE *fp);
89 extern int putint(long i, int siz, FILE *fp);
90 extern int putflt(double f, FILE *fp);
91 extern size_t putbinary(const void *s, size_t elsiz, size_t nel, FILE *fp);
92 extern char *getstr(char *s, FILE *fp);
93 extern long getint(int siz, FILE *fp);
94 extern double getflt(FILE *fp);
95 extern size_t getbinary(void *s, size_t elsiz, size_t nel, FILE *fp);
96 /* defined in rexpr.c */
97 extern int ecompile(char *sp, int iflg, int wflag);
98 extern char *expsave(void);
99 extern void expset(char *ep);
100 extern char *eindex(char *sp);
101 /* defined in savestr.c */
102 extern char *savestr(const char *str);
103 extern void freestr(char *s);
104 extern int shash(const char *s);
105 /* defined in savqstr.c */
106 extern char *savqstr(const char *s);
107 extern void freeqstr(char *s);
108 /* defined in wordfile.c */
109 extern int wordfile(char **words, int nargs, char *fname);
110 extern int wordstring(char **avl, int nargs, char *str);
111 /* defined in words.c */
112 extern char *atos(char *rs, int nb, char *s);
113 extern char *nextword(char *cp, int nb, char *s);
114 extern char *sskip(char *s);
115 extern char *sskip2(char *s, int n);
116 extern char *iskip(char *s);
117 extern char *fskip(char *s);
118 extern int isint(char *s);
119 extern int isintd(char *s, char *ds);
120 extern int isflt(char *s);
121 extern int isfltd(char *s, char *ds);
122 /* defined in lamp.c */
123 extern float * matchlamp(char *s);
124 extern int loadlamps(char *file);
125 extern void freelamps(void);
126
127 #ifndef strlcpy /* defined in option strlcpy.c */
128 extern size_t strlcpy(char *dst, const char *src, size_t siz);
129 extern size_t strlcat(char *dst, const char *src, size_t siz);
130 #endif
131 #ifndef strncasecmp /* defined in option strncasecmp.c */
132 extern int strncasecmp(const char *s1, const char *s2, size_t n);
133 #endif
134 #ifndef strnstr /* defined in option strnstr.c */
135 extern char * strnstr(const char *haystack,
136 const char *needle, size_t len);
137 #endif
138
139 #ifdef __cplusplus
140 }
141 #endif
142 #endif /* _RAD_RTIO_H_ */
143