FreeCalypso > hg > freecalypso-tools
comparison ffstools/tiffs-mkfs/main.c @ 705:12ae93940467
tiffs-mkfs program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 20 May 2020 06:55:58 +0000 |
parents | |
children | 178ed445021d |
comparison
equal
deleted
inserted
replaced
704:dacd9fdc392a | 705:12ae93940467 |
---|---|
1 #include <sys/types.h> | |
2 #include <sys/param.h> | |
3 #include <stdio.h> | |
4 #include <stdint.h> | |
5 #include <stdlib.h> | |
6 #include <string.h> | |
7 #include <strings.h> | |
8 #include "struct.h" | |
9 #include "globals.h" | |
10 | |
11 void | |
12 process_cmdline(argc, argv) | |
13 char **argv; | |
14 { | |
15 extern int optind; | |
16 extern char *optarg; | |
17 int c; | |
18 | |
19 while ((c = getopt(argc, argv, "c:f:m:")) != EOF) | |
20 switch (c) { | |
21 case 'c': | |
22 chunk_size_max = strtoul(optarg, 0, 0); | |
23 continue; | |
24 case 'f': | |
25 if (*optarg != '/') { | |
26 fprintf(stderr, | |
27 "error: format name must begin with \'/\'\n"); | |
28 exit(1); | |
29 } | |
30 format_name = optarg; | |
31 continue; | |
32 case 'm': | |
33 block_files_max = strtoul(optarg, 0, 0); | |
34 continue; | |
35 default: | |
36 usage: fprintf(stderr, | |
37 "usage: %s [options] <org> <srcdir> <outfile>\n", | |
38 argv[0]); | |
39 exit(1); | |
40 } | |
41 if (argc - optind != 3) | |
42 goto usage; | |
43 parse_org_arg(argv[optind]); | |
44 input_host_dir = argv[optind+1]; | |
45 output_filename = argv[optind+2]; | |
46 } | |
47 | |
48 main(argc, argv) | |
49 char **argv; | |
50 { | |
51 process_cmdline(argc, argv); | |
52 if (!format_name) | |
53 format_name = "/"; | |
54 preen_chunk_size_max(); | |
55 preen_block_files_max(); | |
56 /* input phase */ | |
57 read_dir_level(&root, input_host_dir, 0); | |
58 sort_dir_level(&root); | |
59 /* output phase */ | |
60 prepare_output_buffers(); | |
61 open_output_file(); | |
62 create_root_dir(); | |
63 process_dir_level(&root); | |
64 finish_output(); | |
65 close(output_fd); | |
66 exit(0); | |
67 } |