12 |
|
* gmtval(t,s) get GMT as UTC |
13 |
|
* fputdate(t,fp) put out the given UTC |
14 |
|
* fputnow(fp) put out the current date and time |
15 |
– |
* printargs(ac,av,fp) print an argument list to fp, followed by '\n' |
15 |
|
* formatval(r,s) copy the format value in s to r |
16 |
|
* fputformat(s,fp) write "FORMAT=%s" to fp |
17 |
|
* nativebigendian() are we native on big-endian machine? |
30 |
|
|
31 |
|
#include "tiff.h" /* for int32 */ |
32 |
|
#include "rtio.h" |
33 |
+ |
#include "color.h" |
34 |
|
#include "resolu.h" |
35 |
|
|
36 |
|
#define MAXLINE 2048 |
57 |
|
{ |
58 |
|
fputs(HDRSTR, fp); |
59 |
|
fputs(s, fp); |
60 |
< |
putc('\n', fp); |
60 |
> |
fputc('\n', fp); |
61 |
|
} |
62 |
|
|
63 |
|
|
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
– |
void |
164 |
– |
printargs( /* print arguments to a file */ |
165 |
– |
int ac, |
166 |
– |
char **av, |
167 |
– |
FILE *fp |
168 |
– |
) |
169 |
– |
{ |
170 |
– |
#if defined(_WIN32) || defined(_WIN64) |
171 |
– |
extern char *fixargv0(char *arg0); |
172 |
– |
char myav0[128]; |
173 |
– |
/* clean up Windows executable path */ |
174 |
– |
if (ac <= 0) return; |
175 |
– |
fputs(fixargv0(strcpy(myav0, *av++)), fp); |
176 |
– |
fputc(--ac ? ' ' : '\n'); |
177 |
– |
#endif |
178 |
– |
while (ac-- > 0) { |
179 |
– |
fputword(*av++, fp); |
180 |
– |
fputc(ac ? ' ' : '\n', fp); |
181 |
– |
} |
182 |
– |
} |
183 |
– |
|
184 |
– |
|
163 |
|
int |
164 |
|
formatval( /* get format value (return true if format) */ |
165 |
|
char fmt[MAXFMTLEN], |
168 |
|
{ |
169 |
|
const char *cp = FMTSTR; |
170 |
|
char *r = fmt; |
171 |
< |
|
171 |
> |
/* check against format string */ |
172 |
|
while (*cp) if (*cp++ != *s++) return(0); |
173 |
|
while (isspace(*s)) s++; |
174 |
|
if (!*s) return(0); |
175 |
< |
if (r == NULL) return(1); |
176 |
< |
do |
175 |
> |
if (r == NULL) /* just checking if format? */ |
176 |
> |
return(1); |
177 |
> |
do /* copy format ID */ |
178 |
|
*r++ = *s++; |
179 |
< |
while (*s && !isspace(*s) && r-fmt < MAXFMTLEN-1); |
180 |
< |
*r = '\0'; |
179 |
> |
while (*s && r-fmt < MAXFMTLEN-1); |
180 |
> |
|
181 |
> |
do /* remove trailing white space */ |
182 |
> |
*r-- = '\0'; |
183 |
> |
while (r > fmt && isspace(*r)); |
184 |
> |
|
185 |
|
return(1); |
186 |
|
} |
187 |
|
|
192 |
|
FILE *fp |
193 |
|
) |
194 |
|
{ |
195 |
+ |
int align = 0; |
196 |
+ |
|
197 |
|
fputs(FMTSTR, fp); |
198 |
|
fputs(s, fp); |
199 |
< |
putc('\n', fp); |
199 |
> |
/* pad to align binary type for mmap() */ |
200 |
> |
if (globmatch(PICFMT, s)) |
201 |
> |
align = 0; /* not needed for picture data */ |
202 |
> |
else if (!strncmp("float", s, 5)) |
203 |
> |
align = sizeof(float); |
204 |
> |
else if (!strncmp("double", s, 6)) |
205 |
> |
align = sizeof(double); |
206 |
> |
else if (!strncmp("16-bit", s, 6)) |
207 |
> |
align = 2; |
208 |
> |
else if (!strncmp("32-bit", s, 6)) |
209 |
> |
align = 4; |
210 |
> |
else if (!strncmp("64-bit", s, 6)) |
211 |
> |
align = 8; |
212 |
> |
if (align) { |
213 |
> |
long pos = ftell(fp); |
214 |
> |
if (pos >= 0) { |
215 |
> |
pos = (pos + 2) % align; |
216 |
> |
if (pos) align -= pos; |
217 |
> |
else align = 0; |
218 |
> |
} else |
219 |
> |
align = 0; |
220 |
> |
} |
221 |
> |
while (align-- > 0) |
222 |
> |
putc(' ', fp); |
223 |
> |
fputc('\n', fp); |
224 |
|
} |
225 |
|
|
226 |
|
|
345 |
|
while (*s++); |
346 |
|
return(0); |
347 |
|
case '[': /* character set */ |
348 |
< |
setmatch = *s == *++p; |
348 |
> |
setmatch = (*s == *++p); |
349 |
|
if (!*p) |
350 |
|
return(0); |
351 |
|
while (*++p != ']') { |
352 |
|
if (!*p) |
353 |
|
return(0); |
354 |
|
if (*p == '-') { |
355 |
< |
setmatch += (p[-1] <= *s && *s <= p[1]); |
355 |
> |
setmatch += (p[-1] <= *s) & (*s <= p[1]); |
356 |
|
if (!*++p) |
357 |
|
break; |
358 |
|
} else |
363 |
|
s++; |
364 |
|
break; |
365 |
|
case '\\': /* literal next */ |
366 |
< |
p++; |
366 |
> |
if (!*++p) |
367 |
> |
return(0); |
368 |
|
/* fall through */ |
369 |
|
default: /* normal character */ |
370 |
|
if (*p != *s) |