61 const char * helptext =
"addld 1.0 Lexicon & Dictionary module creation tool for the SWORD Project\nUse -a to add a new LD entry from standard input or a file, -d to delete an\nentry, -l to link two LD entries, -c to create a new module.\n usage:\n %s -a <filename> <key> [</path/to/file/with/entry>]\n %s -d <filename> <key>\n %s -l <filename> <first key (already assigned)> <second key>\n %s -c <filename>\nTo use 4-byte LD instead of 2-byte, insert a 4 immediately after the '-'.\nTo use zLD instead of 2-byte, insert a z immediately after the '-'.\n";
64 bool fourbyte =
false;
69 fprintf(stderr, helptext, argv[0], argv[0], argv[0], argv[0]);
73 if (argv[1][1] ==
'4') {
77 else if (argv[1][1] ==
'z') {
85 if ((mode ==
'a') && (argc == 4 || argc == 5)) {
91 SWKey* key = mod.createKey();
100 if (argc == 5) infile = fopen(argv[4],
"r");
104 entrysize = fread(buffer,
sizeof(
char),
sizeof(buffer), infile);
105 mod.setEntry(buffer, entrysize);
109 char buffer[1048576];
111 SWKey* key = mod.createKey();
120 if (argc == 5) infile = fopen(argv[4],
"r");
124 entrysize = fread(buffer,
sizeof(
char),
sizeof(buffer), infile);
125 mod.setEntry(buffer, entrysize);
127 fprintf(stderr,
"error: %s: SWORD library not built with ZIP compression support.\n", argv[0]);
134 SWKey* key = mod.createKey();
143 if (argc == 5) infile = fopen(argv[4],
"r");
147 entrysize = fread(buffer,
sizeof(
char),
sizeof(buffer), infile);
148 mod.setEntry(buffer, entrysize);
153 else if ((mode ==
'l') && argc == 5) {
157 SWKey* key = mod.createKey();
162 SWKey tmpkey = argv[4];
167 SWKey* key = mod.createKey();
173 SWKey tmpkey = argv[4];
178 SWKey* key = mod.createKey();
184 SWKey tmpkey = argv[4];
188 else if ((mode ==
'd') && argc == 4) {
207 else if ((mode ==
'c') && argc == 3) {
212 fprintf(stderr,
"error: %s: couldn't create module at path: %s \n", argv[0], argv[2]);
218 fprintf(stderr,
"error: %s: couldn't create module at path: %s \n", argv[0], argv[2]);
224 fprintf(stderr,
"error: %s: couldn't create module at path: %s \n", argv[0], argv[2]);
232 fprintf(stderr, helptext, argv[0], argv[0], argv[0], argv[0]);
static char createModule(const char *path)
void setPersist(bool ipersist)
static char createModule(const char *path)
static char createModule(const char *path)