comparison lwar/main.c @ 188:bb2665c7005c

Added --extract and --replace to lwar
author lost
date Sun, 22 Mar 2009 06:51:48 +0000
parents cc41ccee8f64
children bae1e3ecdce1
comparison
equal deleted inserted replaced
187:857cb407229e 188:bb2665c7005c
61 61
62 case 'm': 62 case 'm':
63 mergeflag = 1; 63 mergeflag = 1;
64 break; 64 break;
65 65
66 // case 'r': 66 case 'r':
67 // // remove members 67 // replace members
68 // operation = LWAR_OP_REMOVE; 68 operation = LWAR_OP_REPLACE;
69 // break; 69 break;
70 70
71 case 'l': 71 case 'l':
72 // list members 72 // list members
73 operation = LWAR_OP_LIST; 73 operation = LWAR_OP_LIST;
74 break; 74 break;
75 75
76 case 'x':
77 // extract members
78 operation = LWAR_OP_EXTRACT;
79 break;
80
76 case ARGP_KEY_ARG: 81 case ARGP_KEY_ARG:
77 if (archive_file) 82 if (archive_file)
78 { 83 {
79 // add archive member to list 84 // add archive member to list
80 add_file_name(arg); 85 add_file_name(arg);
89 return 0; 94 return 0;
90 } 95 }
91 96
92 static struct argp_option options[] = 97 static struct argp_option options[] =
93 { 98 {
94 // { "remove", 'r', 0, 0, 99 { "replace", 'r', 0, 0,
95 // "Remove members from the archive" }, 100 "Add or replace archive members" },
101 { "extract", 'x', 0, 0,
102 "Extract members from the archive" },
96 { "add", 'a', 0, 0, 103 { "add", 'a', 0, 0,
97 "Add members to the archive" }, 104 "Add members to the archive" },
98 { "list", 'l', 0, 0, 105 { "list", 'l', 0, 0,
99 "List the contents of the archive" }, 106 "List the contents of the archive" },
100 { "create", 'c', 0, 0, 107 { "create", 'c', 0, 0,
115 }; 122 };
116 123
117 extern void do_list(void); 124 extern void do_list(void);
118 extern void do_add(void); 125 extern void do_add(void);
119 extern void do_remove(void); 126 extern void do_remove(void);
127 extern void do_replace(void);
128 extern void do_extract(void);
120 129
121 // main function; parse command line, set up assembler state, and run the 130 // main function; parse command line, set up assembler state, and run the
122 // assembler on the first file 131 // assembler on the first file
123 int main(int argc, char **argv) 132 int main(int argc, char **argv)
124 { 133 {
133 { 142 {
134 fprintf(stderr, "You must specify an operation.\n"); 143 fprintf(stderr, "You must specify an operation.\n");
135 exit(1); 144 exit(1);
136 } 145 }
137 146
138 if (operation == LWAR_OP_LIST || operation == LWAR_OP_REMOVE) 147 if (operation == LWAR_OP_LIST || operation == LWAR_OP_REMOVE || operation == LWAR_OP_EXTRACT)
139 { 148 {
140 struct stat stbuf; 149 struct stat stbuf;
141 // make sure the archive exists 150 // make sure the archive exists
142 if (stat(archive_file, &stbuf) < 0) 151 if (stat(archive_file, &stbuf) < 0)
143 { 152 {
184 193
185 case LWAR_OP_REMOVE: 194 case LWAR_OP_REMOVE:
186 do_remove(); 195 do_remove();
187 break; 196 break;
188 197
198 case LWAR_OP_REPLACE:
199 do_replace();
200 break;
201
202 case LWAR_OP_EXTRACT:
203 do_extract();
204 break;
189 } 205 }
190 206
191 exit(0); 207 exit(0);
192 } 208 }