1
// Diatheke 4.2 by Chris Little <chrislit@crosswire.org>
2
// Copyright 1999-2002 by CrossWire Bible Society
3
// http://www.crosswire.org/sword/diatheke
4
// Licensed under GNU General Public License (GPL)
5
// see accompanying LICENSE file for license details
8
#include "corediatheke.h"
9
#include "diathekemgr.h"
10
#include "diafiltmgr.h"
19
//if we got this far without exiting, something went wrong, so print syntax
20
fprintf (stderr, "Diatheke command-line SWORD frontend Version 4.2\n");
21
fprintf (stderr, "Copyright 1999-2002 by the CrossWire Bible Society\n");
22
fprintf (stderr, "http://www.crosswire.org/sword/diatheke/\n");
23
fprintf (stderr, "usage: \n ");
24
fprintf (stderr, "diatheke <-b book> [-s search_type] [-r search_range] [-o option_filters]\n");
25
fprintf (stderr, "[-m maximum_verses] [-f output_format] [-l locale]\n");
26
fprintf (stderr, "[-e output_encoding] [-t script] [-v variant#(-1=all|0|1)]\n");
27
fprintf (stderr, "<-k query_key>\n");
28
fprintf (stderr, "\n");
29
fprintf (stderr, "If <book> is \"system\" you may use these system keys: \"modulelist\",\n");
30
fprintf (stderr, "\"modulelistnames\", and \"localelist\".");
31
fprintf (stderr, "\n");
32
fprintf (stderr, "Valid search_type values are: regex, multiword, and phrase(def).\n");
33
fprintf (stderr, "Valid option_filters values are: n (Strong's numbers),\n");
34
fprintf (stderr, " f (Footnotes), m (Morphology), h (Section Headings),\n");
35
fprintf (stderr, " c (Cantillation), v (Hebrew Vowels), a (Greek Accents),\n");
36
fprintf (stderr, " l (Lemmas), s (Scripture Crossrefs), r (Arabic Shaping,\n");
37
fprintf (stderr, " b (Bi-Directional Reordering), x (Red Words of Christ)\n");
39
fprintf (stderr, "Maximum verses may be any integer value\n");
40
fprintf (stderr, "Valid output_format values are: GBF, ThML, RTF, HTML, OSIS, CGI, and plain (def)\n");
41
fprintf (stderr, "Valid output_encoding values are: Latin1, UTF8 (def), UTF16, HTML, and RTF\n");
42
fprintf (stderr, "Valid locale values depend on installed locales. en is default.\n");
43
fprintf (stderr, "The query_key must be the last argument because all following\n");
44
fprintf (stderr, " arguments are added to the key.\n");
47
int main(int argc, char **argv)
50
unsigned char outputformat = FMT_PLAIN, searchtype = ST_NONE, outputencoding = ENC_UTF8;
51
unsigned long optionfilters = OP_NONE;
52
char *text = 0, *locale = 0, *ref = 0, *script = 0, *range = 0;
53
signed short variants = 0;
55
char runquery = 0; // used to check that we have enough arguments to perform a legal query
56
// (a querytype & text = 1 and a ref = 2)
58
for (int i = 1; i < argc; i++) {
59
if (!stricmp("-b", argv[i])) {
66
else if (!stricmp("-s", argv[i])) {
68
if (!stricmp("phrase", argv[i+1])) {
69
searchtype = ST_PHRASE;
72
else if (!stricmp("regex", argv[i+1])) {
73
searchtype = ST_REGEX;
76
else if (!stricmp("multiword", argv[i+1])) {
77
searchtype = ST_MULTIWORD;
83
else if (!stricmp("-r", argv[i])) {
89
else if (!stricmp("-l", argv[i])) {
95
else if (!stricmp("-m", argv[i])) {
97
maxverses = atoi(argv[i+1]);
101
else if (!stricmp("-o", argv[i])) {
103
if (strchr(argv[i+1], 'f'))
104
optionfilters |= OP_FOOTNOTES;
105
if (strchr(argv[i+1], 'n'))
106
optionfilters |= OP_STRONGS;
107
if (strchr(argv[i+1], 'h'))
108
optionfilters |= OP_HEADINGS;
109
if (strchr(argv[i+1], 'm'))
110
optionfilters |= OP_MORPH;
111
if (strchr(argv[i+1], 'c'))
112
optionfilters |= OP_CANTILLATION;
113
if (strchr(argv[i+1], 'v'))
114
optionfilters |= OP_HEBREWPOINTS;
115
if (strchr(argv[i+1], 'a'))
116
optionfilters |= OP_GREEKACCENTS;
117
if (strchr(argv[i+1], 'l'))
118
optionfilters |= OP_LEMMAS;
119
if (strchr(argv[i+1], 's'))
120
optionfilters |= OP_SCRIPREF;
121
if (strchr(argv[i+1], 'r'))
122
optionfilters |= OP_ARSHAPE;
123
if (strchr(argv[i+1], 'b'))
124
optionfilters |= OP_BIDI;
125
if (strchr(argv[i+1], 'x'))
126
optionfilters |= OP_RED;
130
else if (!stricmp("-f", argv[i])) {
132
if (!stricmp("thml", argv[i+1])) {
133
outputformat = FMT_THML;
136
else if (!stricmp("cgi", argv[i+1])) {
137
outputformat = FMT_CGI;
140
else if (!stricmp("gbf", argv[i+1])) {
141
outputformat = FMT_GBF;
144
else if (!stricmp("html", argv[i+1])) {
145
outputformat = FMT_HTML;
148
else if (!stricmp("rtf", argv[i+1])) {
149
outputformat = FMT_RTF;
152
else if (!stricmp("osis", argv[i+1])) {
153
outputformat = FMT_OSIS;
159
else if (!stricmp("-e", argv[i])) {
161
if (!stricmp("utf8", argv[i+1])) {
162
outputencoding = ENC_UTF8;
165
else if (!stricmp("rtf", argv[i+1])) {
166
outputencoding = ENC_RTF;
169
else if (!stricmp("html", argv[i+1])) {
170
outputencoding = ENC_HTML;
173
else if (!stricmp("latin1", argv[i+1])) {
174
outputencoding = ENC_LATIN1;
177
else if (!stricmp("utf16", argv[i+1])) {
178
outputencoding = ENC_UTF16;
184
else if (!stricmp("-k", argv[i])) {
189
for (; i < argc; i++)
190
key = key + " " + argv[i];
191
ref = new char[key.length() + 1];
192
strcpy (ref, key.c_str());
197
else if (!stricmp("-v", argv[i])) {
199
variants = atoi(argv[i+1]);
200
optionfilters |= OP_VARIANTS;
205
else if (!stricmp("-t", argv[i])) {
208
optionfilters |= OP_TRANSLITERATOR;
216
if (runquery == (RQ_BOOK | RQ_REF)) {
217
doquery(maxverses, outputformat, outputencoding, optionfilters, searchtype, range, text, locale, ref, &cout, script, variants);