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

Comparing ray/src/px/pflip.c (file contents):
Revision 2.7 by schorsch, Thu Jul 3 22:41:44 2003 UTC vs.
Revision 2.13 by greg, Fri Jun 6 19:11:21 2025 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * flip picture file horizontally and/or vertically
6   */
7  
8 < #include <stdio.h>
9 < #include  <time.h>
10 < #include  <string.h>
11 <
8 > #include "rtio.h"
9 > #include "paths.h"
10   #include "platform.h"
11   #include "color.h"
12   #include "resolu.h"
# Line 24 | Line 22 | int    correctorder = 0;               /* correcting orientation? */
22  
23   FILE    *fin;                           /* input file */
24  
27 char    *progname;
25  
26 + static void memerr(void);
27 + static void scanfile(void);
28 + static void flip(void);
29  
30 < int
31 < neworder()                      /* figure out new order from old */
30 >
31 > static int
32 > neworder(void)                  /* figure out new order from old */
33   {
34          register int  no;
35  
# Line 44 | Line 45 | neworder()                     /* figure out new order from old */
45          return(no);
46   }
47  
48 <
49 < main(argc, argv)
50 < int     argc;
51 < char    *argv[];
48 > int
49 > main(
50 >        int     argc,
51 >        char    *argv[]
52 > )
53   {
54 <        static char     picfmt[LPICFMT+1] = PICFMT;
54 >        static char     picfmt[MAXFMTLEN] = PICFMT;
55          int     i, rval;
56 +        
57          SET_DEFAULT_BINARY();
58          SET_FILE_BINARY(stdout);
59 <        progname = argv[0];
59 >        fixargv0(argv[0]);
60  
61          for (i = 1; i < argc; i++)
62                  if (!strcmp(argv[i], "-h"))
# Line 64 | Line 67 | char   *argv[];
67                          correctorder++;
68                  else
69                          break;
70 +        if (i < argc-2)
71 +                goto userr;
72 +        if (!fhoriz && !fvert)
73 +                fprintf(stderr, "%s: warning - no operation\n", argv[0]);
74          if (i >= argc || argv[i][0] == '-') {
75 <                fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n",
76 <                                progname);
75 >                if (fvert)
76 >                        goto userr;
77 >                SET_FILE_BINARY(stdin);
78 >                fin = stdin;
79 >        } else if ((fin = fopen(argv[i], "r")) == NULL) {
80 >                fprintf(stderr, "%s: cannot open\n", argv[i]);
81                  exit(1);
82          }
72        if ((fin = fopen(argv[i], "r")) == NULL) {
73                fprintf(stderr, "%s: cannot open\n", argv[1]);
74                exit(1);
75        }
83          if (i < argc-1 && freopen(argv[i+1], "w", stdout) == NULL) {
84                  fprintf(stderr, "%s: cannot open\n", argv[i+1]);
85                  exit(1);
# Line 100 | Line 107 | char   *argv[];
107                  scanfile();
108          flip();                         /* flip the image */
109          exit(0);
110 + userr:
111 +        fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n",
112 +                        progname);
113 +        exit(1);
114   }
115  
116  
117 < memerr()
117 > static void
118 > memerr(void)
119   {
120          fprintf(stderr, "%s: out of memory\n", progname);
121          exit(1);
122   }
123  
124  
125 < scanfile()                              /* scan to the end of file */
125 > static void
126 > scanfile(void)                          /* scan to the end of file */
127   {
128          extern long     ftell();
129          COLR    *scanin;
# Line 132 | Line 145 | scanfile()                             /* scan to the end of file */
145   }
146  
147  
148 < flip()                                  /* flip the picture */
148 > static void
149 > flip(void)                                      /* flip the picture */
150   {
151          COLR    *scanin, *scanout;
152          int     y;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines