1 |
– |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* prot.c - program to rotate picture file 90 degrees clockwise. |
6 |
|
* |
11 |
|
|
12 |
|
#include "color.h" |
13 |
|
|
14 |
+ |
#include <time.h> |
15 |
+ |
|
16 |
|
#include "resolu.h" |
17 |
|
|
18 |
|
int order; /* input scanline order */ |
21 |
|
int correctorder = 0; /* order correction? */ |
22 |
|
int ccw = 0; /* rotate CCW? */ |
23 |
|
|
24 |
< |
#ifdef BIGMEM |
26 |
< |
char buf[1<<22]; /* output buffer */ |
27 |
< |
#else |
24 |
> |
#ifdef SMLMEM |
25 |
|
char buf[1<<20]; /* output buffer */ |
26 |
+ |
#else |
27 |
+ |
char buf[1<<22]; /* output buffer */ |
28 |
|
#endif |
29 |
|
|
30 |
|
int nrows; /* number of rows output at once */ |
34 |
|
char *progname; |
35 |
|
|
36 |
|
short ordertab[4][2] = { |
37 |
< |
{0,XDECR}, {XDECR,XDECR|YDECR}, {XDECR|YDECR,YDECR}, {YDECR,0} |
37 |
> |
{0,0}, {XDECR,XDECR|YDECR}, {XDECR|YDECR,YDECR}, {YDECR,XDECR} |
38 |
|
}; |
39 |
|
|
40 |
|
|
41 |
< |
int |
42 |
< |
neworder() /* return corrected order */ |
41 |
> |
static int neworder(void); |
42 |
> |
static void rotatecw(FILE *fp); |
43 |
> |
static void rotateccw(FILE *fp); |
44 |
> |
|
45 |
> |
|
46 |
> |
|
47 |
> |
static int |
48 |
> |
neworder(void) /* return corrected order */ |
49 |
|
{ |
50 |
+ |
static short ordercw[8]; |
51 |
|
register int i; |
52 |
|
|
53 |
|
if (correctorder) |
54 |
|
return(order); |
55 |
< |
for (i = 4; i--; ) |
56 |
< |
if ((order&~YMAJOR) == ordertab[i][ccw]) |
57 |
< |
return(ordertab[i][1-ccw] | ((order&YMAJOR)^YMAJOR)); |
55 |
> |
if (!ordercw[0]) { |
56 |
> |
ordercw[YMAJOR|YDECR] = 0; |
57 |
> |
ordercw[0] = YMAJOR|XDECR; |
58 |
> |
ordercw[YMAJOR|XDECR] = XDECR|YDECR; |
59 |
> |
ordercw[XDECR|YDECR] = YMAJOR|YDECR; |
60 |
> |
ordercw[YMAJOR|XDECR|YDECR] = XDECR; |
61 |
> |
ordercw[XDECR] = YMAJOR; |
62 |
> |
ordercw[YMAJOR] = YDECR; |
63 |
> |
ordercw[YDECR] = YMAJOR|XDECR|YDECR; |
64 |
> |
} |
65 |
> |
if (!ccw) |
66 |
> |
return(ordercw[order]); |
67 |
> |
for (i = 8; i--; ) |
68 |
> |
if (ordercw[i] == order) |
69 |
> |
return(i); |
70 |
|
fputs("Order botch!\n", stderr); |
71 |
|
exit(2); |
72 |
|
} |
73 |
|
|
74 |
< |
|
75 |
< |
main(argc, argv) |
76 |
< |
int argc; |
77 |
< |
char *argv[]; |
74 |
> |
int |
75 |
> |
main( |
76 |
> |
int argc, |
77 |
> |
char *argv[] |
78 |
> |
) |
79 |
|
{ |
80 |
|
static char picfmt[LPICFMT+1] = PICFMT; |
81 |
|
int rval; |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
< |
rotatecw(fp) /* rotate picture clockwise */ |
142 |
< |
FILE *fp; |
141 |
> |
static void |
142 |
> |
rotatecw( /* rotate picture clockwise */ |
143 |
> |
FILE *fp |
144 |
> |
) |
145 |
|
{ |
146 |
|
register COLR *inln; |
147 |
|
register int xoff, inx, iny; |
172 |
|
exit(1); |
173 |
|
} |
174 |
|
} |
175 |
< |
free((char *)inln); |
175 |
> |
free((void *)inln); |
176 |
|
} |
177 |
|
|
178 |
|
|
179 |
< |
rotateccw(fp) /* rotate picture counter-clockwise */ |
180 |
< |
FILE *fp; |
179 |
> |
static void |
180 |
> |
rotateccw( /* rotate picture counter-clockwise */ |
181 |
> |
FILE *fp |
182 |
> |
) |
183 |
|
{ |
184 |
|
register COLR *inln; |
185 |
|
register int xoff, inx, iny; |
210 |
|
exit(1); |
211 |
|
} |
212 |
|
} |
213 |
< |
free((char *)inln); |
213 |
> |
free((void *)inln); |
214 |
|
} |