Describe options
[debian-nspark.git] / sqshmain.c
blob48a502aa97cd617e873766ec9e131cc342380654
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "spark.h"
5 #include "arcfs.h"
6 #include "unarc.h"
7 #include "error.h"
9 char *ourname;
10 unsigned char apptype = 0;
11 unsigned char force = 0;
12 unsigned char inffiles = 0;
13 unsigned char listing = 0;
14 unsigned char testing = 0;
15 unsigned char quiet = 1;
16 unsigned char retry = 0;
17 unsigned char singlecase = 0;
18 unsigned char stamp = 1;
19 unsigned char to_stdout = 0;
20 unsigned char verbose = 0;
21 char *archive = NULL;
22 char **files = NULL;
23 char *logfile = NULL;
25 void
26 usage()
28 fprintf(stderr, "sqsh: un-squashes RISC OS squashed files\n");
29 fprintf(stderr, "Usage: sqsh [options] <filename>\n");
30 fprintf(stderr, " where options are:\n");
31 fprintf(stderr, " -c output to stdout\n");
32 fprintf(stderr, " -f force file overwrite\n");
33 fprintf(stderr, " -s do not set timestamp of decompressed file\n");
34 exit(1);
37 int
38 main(int argc, char *argv[])
40 int r;
41 int i;
43 if (argc < 2)
45 usage();
48 ourname = argv[0];
49 for (i = 1; i < argc; i++)
51 if (argv[i][0] == '-')
53 switch (argv[i][1])
55 case 'c':
56 to_stdout = 1;
57 break;
58 case 'f':
59 force = 1;
60 break;
61 case 's':
62 stamp = 0;
63 break;
66 else
68 break;
72 if (i == argc)
74 usage();
76 archive = argv[i];
78 r = do_unsquash();
79 if (r != 0 || writesize > 0)
81 error("Error unsquashing file");
84 return r;