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.8 by schorsch, Sun Mar 28 20:33:14 2004 UTC vs.
Revision 2.14 by greg, Sat Jun 7 05:09:46 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 "platform.h"
10   #include "color.h"
11   #include "resolu.h"
# Line 24 | Line 21 | int    correctorder = 0;               /* correcting orientation? */
21  
22   FILE    *fin;                           /* input file */
23  
27 char    *progname;
24  
29
25   static void memerr(void);
26   static void scanfile(void);
27   static void flip(void);
# Line 55 | Line 50 | main(
50          char    *argv[]
51   )
52   {
53 <        static char     picfmt[LPICFMT+1] = PICFMT;
53 >        static char     picfmt[MAXFMTLEN] = PICFMT;
54          int     i, rval;
55 +        
56          SET_DEFAULT_BINARY();
57          SET_FILE_BINARY(stdout);
58 <        progname = argv[0];
58 >        fixargv0(argv[0]);
59  
60          for (i = 1; i < argc; i++)
61                  if (!strcmp(argv[i], "-h"))
# Line 70 | Line 66 | main(
66                          correctorder++;
67                  else
68                          break;
69 +        if (i < argc-2)
70 +                goto userr;
71 +        if (!fhoriz && !fvert)
72 +                fprintf(stderr, "%s: warning - no operation\n", argv[0]);
73          if (i >= argc || argv[i][0] == '-') {
74 <                fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n",
75 <                                progname);
74 >                if (fvert)
75 >                        goto userr;
76 >                SET_FILE_BINARY(stdin);
77 >                fin = stdin;
78 >        } else if ((fin = fopen(argv[i], "r")) == NULL) {
79 >                fprintf(stderr, "%s: cannot open\n", argv[i]);
80                  exit(1);
81          }
78        if ((fin = fopen(argv[i], "r")) == NULL) {
79                fprintf(stderr, "%s: cannot open\n", argv[1]);
80                exit(1);
81        }
82          if (i < argc-1 && freopen(argv[i+1], "w", stdout) == NULL) {
83                  fprintf(stderr, "%s: cannot open\n", argv[i+1]);
84                  exit(1);
# Line 106 | Line 106 | main(
106                  scanfile();
107          flip();                         /* flip the image */
108          exit(0);
109 + userr:
110 +        fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n",
111 +                        progname);
112 +        exit(1);
113   }
114  
115  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines