Debian Codegraph @

src/cups/commandtodyesub.c

raw symbols SCIP
1 /*
2 * Dyesub command filter for Gutenprint
3 *
4 *
5 * Contents:
6 *
7 * main() - Main entry and command processing.
8 */
9
10 /*
11 * Include necessary headers...
12 */
13
14 #include <cups/cups.h>
15 #include <ctype.h>
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <strings.h>
19
20
21 /*
22 * Macros...
23 */
24
25 #define pwrite(s,n) fwrite((s), 1, (n), stdout)
26
27
28 /*
29 * 'main()' - Main entry and processing of driver.
30 */
31
32 int /* O - Exit status */
33 main(int argc, /* I - Number of command-line arguments */
34 char *argv[]) /* I - Command-line arguments */
35 {
36 FILE *fp; /* Command file */
37 char line[1024]; /* Line from file */
38
39
40 /*
41 * Check for valid arguments...
42 */
43
44 if (argc < 6 || argc > 7)
45 {
46 /*
47 * We don't have the correct number of arguments; write an error message
48 * and return.
49 */
50
51 fputs("ERROR: commandtocanon job-id user title copies options [file]\n", stderr);
52 return (1);
53 }
54
55 /*
56 * Open the command file as needed...
57 */
58
59 if (argc == 7)
60 {
61 if ((fp = fopen(argv[6], "r")) == NULL)
62 {
63 perror("ERROR: Unable to open command file - ");
64 return (1);
65 }
66 }
67 else
68 fp = stdin;
69
70 /* Just pass everything through as is */
71
72 while (fgets(line, sizeof(line), fp) != NULL)
73 {
74 pwrite(line, strnlen(line, sizeof(line)));
75 }
76
77 /*
78 * Close the command file and return...
79 */
80
81 if (fp != stdin)
82 fclose(fp);
83
84 return (0);
85 }
86
87
88 /*
89 */