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.24 by greg, Thu Mar 12 18:37:24 2009 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>
86 #include  <time.h>
29   #include  <ctype.h>
30  
31 < #define  MAXLINE        512
31 > #include  "rtio.h"
32 > #include  "resolu.h"
33  
34 < #ifndef BSD
92 < #define  index  strchr
93 < #endif
34 > #define  MAXLINE        2048
35  
95 extern char  *index();
96
36   char  HDRSTR[] = "#?";          /* information header magic number */
37  
38   char  FMTSTR[] = "FORMAT=";     /* format identifier */
39  
40   char  TMSTR[] = "CAPDATE=";     /* capture date identifier */
41  
42 < static int mycheck();
42 > static gethfunc mycheck;
43  
44  
45 < void
46 < newheader(s, fp)                /* identifying line of information header */
47 < char  *s;
48 < register FILE  *fp;
45 > extern void
46 > newheader(              /* identifying line of information header */
47 >        char  *s,
48 >        register FILE  *fp
49 > )
50   {
51          fputs(HDRSTR, fp);
52          fputs(s, fp);
# Line 114 | Line 54 | register FILE  *fp;
54   }
55  
56  
57 < int
58 < headidval(r,s)                  /* get header id (return true if is id) */
59 < register char  *r, *s;
57 > extern int
58 > headidval(                      /* get header id (return true if is id) */
59 >        register char  *r,
60 >        register char   *s
61 > )
62   {
63          register char  *cp = HDRSTR;
64  
# Line 128 | Line 70 | register char  *r, *s;
70   }
71  
72  
73 < int
74 < isheadid(s)                     /* check to see if line is header id */
75 < char  *s;
73 > extern int
74 > isheadid(                       /* check to see if line is header id */
75 >        char  *s
76 > )
77   {
78          return(headidval(NULL, s));
79   }
80  
81  
82 < int
83 < dateval(tloc, s)                /* get capture date value */
84 < time_t  *tloc;
85 < char    *s;
82 > extern int
83 > dateval(                /* get capture date value */
84 >        time_t  *tloc,
85 >        char    *s
86 > )
87   {
88          struct tm       tms;
89          register char  *cp = TMSTR;
# Line 161 | Line 105 | char   *s;
105   }
106  
107  
108 < int
109 < isdate(s)                       /* is the given line a capture date? */
110 < char *s;
108 > extern int
109 > isdate(                 /* is the given line a capture date? */
110 >        char *s
111 > )
112   {
113          return(dateval(NULL, s));
114   }
115  
116  
117 < void
118 < fputdate(tv, fp)                /* write out the given time value */
119 < time_t  tv;
120 < FILE    *fp;
117 > extern void
118 > fputdate(               /* write out the given time value */
119 >        time_t  tv,
120 >        FILE    *fp
121 > )
122   {
123          struct tm       *tm = localtime(&tv);
124          if (tm == NULL)
# Line 183 | Line 129 | FILE   *fp;
129   }
130  
131  
132 < void
133 < fputnow(fp)                     /* write out the current time */
134 < FILE    *fp;
132 > extern void
133 > fputnow(                        /* write out the current time */
134 >        FILE    *fp
135 > )
136   {
137          time_t  tv;
138          time(&tv);
# Line 193 | Line 140 | FILE   *fp;
140   }
141  
142  
143 < void
144 < printargs(ac, av, fp)           /* print arguments to a file */
145 < int  ac;
146 < char  **av;
147 < FILE  *fp;
143 > extern void
144 > printargs(              /* print arguments to a file */
145 >        int  ac,
146 >        char  **av,
147 >        FILE  *fp
148 > )
149   {
202        int  quote;
203
150          while (ac-- > 0) {
151                  fputword(*av++, fp);
152                  fputc(ac ? ' ' : '\n', fp);
# Line 208 | Line 154 | FILE  *fp;
154   }
155  
156  
157 < int
158 < formatval(r, s)                 /* get format value (return true if format) */
159 < register char  *r;
160 < register char  *s;
157 > extern int
158 > formatval(                      /* get format value (return true if format) */
159 >        register char  *r,
160 >        register char  *s
161 > )
162   {
163          register char  *cp = FMTSTR;
164  
# Line 227 | Line 174 | register char  *s;
174   }
175  
176  
177 < int
178 < isformat(s)                     /* is line a format line? */
179 < char  *s;
177 > extern int
178 > isformat(                       /* is line a format line? */
179 >        char  *s
180 > )
181   {
182          return(formatval(NULL, s));
183   }
184  
185  
186 < void
187 < fputformat(s, fp)               /* put out a format value */
188 < char  *s;
189 < FILE  *fp;
186 > extern void
187 > fputformat(             /* put out a format value */
188 >        char  *s,
189 >        FILE  *fp
190 > )
191   {
192          fputs(FMTSTR, fp);
193          fputs(s, fp);
# Line 246 | Line 195 | FILE  *fp;
195   }
196  
197  
198 < int
199 < getheader(fp, f, p)             /* get header from file */
200 < FILE  *fp;
201 < int  (*f)();
202 < char  *p;
198 > extern int
199 > getheader(              /* get header from file */
200 >        FILE  *fp,
201 >        gethfunc *f,
202 >        void  *p
203 > )
204   {
205          char  buf[MAXLINE];
206  
# Line 281 | Line 231 | struct check {
231  
232  
233   static int
234 < mycheck(s, cp)                  /* check a header line for format info. */
235 < char  *s;
236 < register struct check  *cp;
234 > mycheck(                        /* check a header line for format info. */
235 >        char  *s,
236 >        void  *cp
237 > )
238   {
239 <        if (!formatval(cp->fs, s) && cp->fp != NULL)
240 <                fputs(s, cp->fp);
239 >        if (!formatval(((struct check*)cp)->fs, s)
240 >                        && ((struct check*)cp)->fp != NULL) {
241 >                fputs(s, ((struct check*)cp)->fp);
242 >        }
243          return(0);
244   }
245  
246  
247 < int
248 < globmatch(p, s)                 /* check for match of s against pattern p */
249 < register char   *p, *s;
247 > extern int
248 > globmatch(                      /* check for match of s against pattern p */
249 >        register char   *p,
250 >        register char   *s
251 > )
252   {
253          int     setmatch;
254  
# Line 357 | Line 312 | register char  *p, *s;
312   * if fout is not NULL.
313   */
314  
315 < int
316 < checkheader(fin, fmt, fout)
317 < FILE  *fin;
318 < char  *fmt;
319 < FILE  *fout;
315 > extern int
316 > checkheader(
317 >        FILE  *fin,
318 >        char  *fmt,
319 >        FILE  *fout
320 > )
321   {
322          struct check    cdat;
323          register char   *cp;
# Line 373 | Line 329 | FILE  *fout;
329          if (!cdat.fs[0])
330                  return(0);
331          for (cp = fmt; *cp; cp++)               /* check for globbing */
332 <                if (*cp == '?' | *cp == '*')
332 >                if ((*cp == '?') | (*cp == '*')) {
333                          if (globmatch(fmt, cdat.fs)) {
334                                  strcpy(fmt, cdat.fs);
335                                  return(1);
336                          } else
337                                  return(-1);
338 +                }
339          return(strcmp(fmt, cdat.fs) ? -1 : 1);  /* literal match */
340   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines