ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/header.c
(Generate patch)

Comparing ray/src/common/header.c (file contents):
Revision 2.11 by greg, Sat Feb 22 02:07:22 2003 UTC vs.
Revision 2.22 by schorsch, Fri Jan 2 11:35:17 2004 UTC

# Line 24 | Line 24 | static const char      RCSid[] = "$Id$";
24   *  To copy header from input to output, use getheader(fin, fputs, fout)
25   */
26  
27 < /* ====================================================================
28 < * The Radiance Software License, Version 1.0
29 < *
30 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
31 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
32 < *
33 < * Redistribution and use in source and binary forms, with or without
34 < * modification, are permitted provided that the following conditions
35 < * are met:
36 < *
37 < * 1. Redistributions of source code must retain the above copyright
38 < *         notice, this list of conditions and the following disclaimer.
39 < *
40 < * 2. Redistributions in binary form must reproduce the above copyright
41 < *       notice, this list of conditions and the following disclaimer in
42 < *       the documentation and/or other materials provided with the
43 < *       distribution.
44 < *
45 < * 3. The end-user documentation included with the redistribution,
46 < *           if any, must include the following acknowledgment:
47 < *             "This product includes Radiance software
48 < *                 (http://radsite.lbl.gov/)
49 < *                 developed by the Lawrence Berkeley National Laboratory
50 < *               (http://www.lbl.gov/)."
51 < *       Alternately, this acknowledgment may appear in the software itself,
52 < *       if and wherever such third-party acknowledgments normally appear.
53 < *
54 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
55 < *       and "The Regents of the University of California" must
56 < *       not be used to endorse or promote products derived from this
57 < *       software without prior written permission. For written
58 < *       permission, please contact [email protected].
59 < *
60 < * 5. Products derived from this software may not be called "Radiance",
61 < *       nor may "Radiance" appear in their name, without prior written
62 < *       permission of Lawrence Berkeley National Laboratory.
63 < *
64 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
65 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
66 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
67 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
68 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
69 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
70 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
71 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
72 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
73 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
74 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
75 < * SUCH DAMAGE.
76 < * ====================================================================
77 < *
78 < * This software consists of voluntary contributions made by many
79 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
80 < * information on Lawrence Berkeley National Laboratory, please see
81 < * <http://www.lbl.gov/>.
82 < */
27 > #include "copyright.h"
28  
84 #include  <stdio.h>
85 #include  <string.h>
29   #include  <time.h>
30   #include  <ctype.h>
31  
32 + #include  "rtio.h"
33 + #include  "resolu.h"
34 +
35   #define  MAXLINE        512
36  
91 #ifndef BSD
92 #define  index  strchr
93 #endif
94
95 extern char  *index();
96
37   char  HDRSTR[] = "#?";          /* information header magic number */
38  
39   char  FMTSTR[] = "FORMAT=";     /* format identifier */
40  
41   char  TMSTR[] = "CAPDATE=";     /* capture date identifier */
42  
43 < static int mycheck();
43 > static gethfunc mycheck;
44  
45  
46 < void
47 < newheader(s, fp)                /* identifying line of information header */
48 < char  *s;
49 < register FILE  *fp;
46 > extern void
47 > newheader(              /* identifying line of information header */
48 >        char  *s,
49 >        register FILE  *fp
50 > )
51   {
52          fputs(HDRSTR, fp);
53          fputs(s, fp);
# Line 114 | Line 55 | register FILE  *fp;
55   }
56  
57  
58 < int
59 < headidval(r,s)                  /* get header id (return true if is id) */
60 < register char  *r, *s;
58 > extern int
59 > headidval(                      /* get header id (return true if is id) */
60 >        register char  *r,
61 >        register char   *s
62 > )
63   {
64          register char  *cp = HDRSTR;
65  
# Line 128 | Line 71 | register char  *r, *s;
71   }
72  
73  
74 < int
75 < isheadid(s)                     /* check to see if line is header id */
76 < char  *s;
74 > extern int
75 > isheadid(                       /* check to see if line is header id */
76 >        char  *s
77 > )
78   {
79          return(headidval(NULL, s));
80   }
81  
82  
83 < int
84 < dateval(tloc, s)                /* get capture date value */
85 < time_t  *tloc;
86 < char    *s;
83 > extern int
84 > dateval(                /* get capture date value */
85 >        time_t  *tloc,
86 >        char    *s
87 > )
88   {
89          struct tm       tms;
90          register char  *cp = TMSTR;
# Line 161 | Line 106 | char   *s;
106   }
107  
108  
109 < int
110 < isdate(s)                       /* is the given line a capture date? */
111 < char *s;
109 > extern int
110 > isdate(                 /* is the given line a capture date? */
111 >        char *s
112 > )
113   {
114          return(dateval(NULL, s));
115   }
116  
117  
118 < void
119 < fputdate(tv, fp)                /* write out the given time value */
120 < time_t  tv;
121 < FILE    *fp;
118 > extern void
119 > fputdate(               /* write out the given time value */
120 >        time_t  tv,
121 >        FILE    *fp
122 > )
123   {
124          struct tm       *tm = localtime(&tv);
125          if (tm == NULL)
# Line 183 | Line 130 | FILE   *fp;
130   }
131  
132  
133 < void
134 < fputnow(fp)                     /* write out the current time */
135 < FILE    *fp;
133 > extern void
134 > fputnow(                        /* write out the current time */
135 >        FILE    *fp
136 > )
137   {
138          time_t  tv;
139          time(&tv);
# Line 193 | Line 141 | FILE   *fp;
141   }
142  
143  
144 < void
145 < printargs(ac, av, fp)           /* print arguments to a file */
146 < int  ac;
147 < char  **av;
148 < FILE  *fp;
144 > extern void
145 > printargs(              /* print arguments to a file */
146 >        int  ac,
147 >        char  **av,
148 >        FILE  *fp
149 > )
150   {
202        int  quote;
203
151          while (ac-- > 0) {
152                  fputword(*av++, fp);
153                  fputc(ac ? ' ' : '\n', fp);
# Line 208 | Line 155 | FILE  *fp;
155   }
156  
157  
158 < int
159 < formatval(r, s)                 /* get format value (return true if format) */
160 < register char  *r;
161 < register char  *s;
158 > extern int
159 > formatval(                      /* get format value (return true if format) */
160 >        register char  *r,
161 >        register char  *s
162 > )
163   {
164          register char  *cp = FMTSTR;
165  
# Line 227 | Line 175 | register char  *s;
175   }
176  
177  
178 < int
179 < isformat(s)                     /* is line a format line? */
180 < char  *s;
178 > extern int
179 > isformat(                       /* is line a format line? */
180 >        char  *s
181 > )
182   {
183          return(formatval(NULL, s));
184   }
185  
186  
187 < void
188 < fputformat(s, fp)               /* put out a format value */
189 < char  *s;
190 < FILE  *fp;
187 > extern void
188 > fputformat(             /* put out a format value */
189 >        char  *s,
190 >        FILE  *fp
191 > )
192   {
193          fputs(FMTSTR, fp);
194          fputs(s, fp);
# Line 246 | Line 196 | FILE  *fp;
196   }
197  
198  
199 < int
200 < getheader(fp, f, p)             /* get header from file */
201 < FILE  *fp;
202 < int  (*f)();
203 < char  *p;
199 > extern int
200 > getheader(              /* get header from file */
201 >        FILE  *fp,
202 >        gethfunc *f,
203 >        void  *p
204 > )
205   {
206          char  buf[MAXLINE];
207  
# Line 281 | Line 232 | struct check {
232  
233  
234   static int
235 < mycheck(s, cp)                  /* check a header line for format info. */
236 < char  *s;
237 < register struct check  *cp;
235 > mycheck(                        /* check a header line for format info. */
236 >        char  *s,
237 >        void  *cp
238 > )
239   {
240 <        if (!formatval(cp->fs, s) && cp->fp != NULL)
241 <                fputs(s, cp->fp);
240 >        if (!formatval(((struct check*)cp)->fs, s)
241 >                        && ((struct check*)cp)->fp != NULL) {
242 >                fputs(s, ((struct check*)cp)->fp);
243 >        }
244          return(0);
245   }
246  
247  
248 < int
249 < globmatch(p, s)                 /* check for match of s against pattern p */
250 < register char   *p, *s;
248 > extern int
249 > globmatch(                      /* check for match of s against pattern p */
250 >        register char   *p,
251 >        register char   *s
252 > )
253   {
254          int     setmatch;
255  
# Line 357 | Line 313 | register char  *p, *s;
313   * if fout is not NULL.
314   */
315  
316 < int
317 < checkheader(fin, fmt, fout)
318 < FILE  *fin;
319 < char  *fmt;
320 < FILE  *fout;
316 > extern int
317 > checkheader(
318 >        FILE  *fin,
319 >        char  *fmt,
320 >        FILE  *fout
321 > )
322   {
323          struct check    cdat;
324          register char   *cp;
# Line 373 | Line 330 | FILE  *fout;
330          if (!cdat.fs[0])
331                  return(0);
332          for (cp = fmt; *cp; cp++)               /* check for globbing */
333 <                if (*cp == '?' | *cp == '*')
333 >                if ((*cp == '?') | (*cp == '*')) {
334                          if (globmatch(fmt, cdat.fs)) {
335                                  strcpy(fmt, cdat.fs);
336                                  return(1);
337                          } else
338                                  return(-1);
339 +                }
340          return(strcmp(fmt, cdat.fs) ? -1 : 1);  /* literal match */
341   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines