89 printf (
"%s :%s :%d :%d :%d\n\n", filename, modname, longnames, exportfile, format);
92 std::ifstream infile(filename);
93 if (!infile.is_open()) {
95 std::cerr << std::endl << std::endl <<
"Could not open file \"" << filename <<
"\"" << std::endl;
98 std::ofstream outfile;
100 strcat (modname,
".imp");
101 outfile.open(modname);
115 unsigned long entrysize = 0;
116 unsigned long keysize = 0;
133 while ((c = infile.get()) != EOF) {
137 while ((c = infile.get()) !=
'>')
142 if (keybuffer.length()) {
143 if (((format ==
F_OSIS) && ((!strncmp(keybuffer.c_str(),
"/div>", 5)) || (!strncmp(keybuffer.c_str(),
"/verse>", 7)) || (!strncmp(keybuffer.c_str(),
"/chapter>", 9)))) ||
144 ((format ==
F_THML) && ((!strncmp(keybuffer.c_str(),
"/div", 4)) && (keybuffer[4] >
'0' && keybuffer[4] <
'7')))) {
148 for (i = 0; i < level; i++) {
151 keybuffer2 += divs[i];
152 keysize += divs[i].length();
153 std::cout << keybuffer2 << std::endl;
157 std::cout << keybuffer2 << std::endl;
159 outfile <<
"$$$" << keybuffer2 << std::endl << entbuffer << std::endl;
162 book->
setKey(keybuffer2.c_str());
163 book->
setEntry(entbuffer.c_str(), entrysize);
173 else if (((format ==
F_OSIS) && !((!strncmp(keybuffer.c_str(),
"div>", 4) || !strncmp(keybuffer.c_str(),
"div ", 4)) || (!strncmp(keybuffer.c_str(),
"verse>", 6) || !strncmp(keybuffer.c_str(),
"verse ", 6)) || (!strncmp(keybuffer.c_str(),
"chapter>", 8) || !strncmp(keybuffer.c_str(),
"chapter ", 8)))) ||
174 ((format ==
F_THML) && !((!strncmp(keybuffer.c_str(),
"div", 3)) && (keybuffer[3] >
'0' && keybuffer[3] <
'7')))) {
177 entrysize += keybuffer.length();
178 entbuffer += keybuffer;
185 for (i = 0; i < level; i++) {
188 keybuffer2 += divs[i];
189 keysize += divs[i].length();
190 std::cout << keybuffer2 << std::endl;
194 std::cout << keybuffer2 << std::endl;
196 outfile <<
"$$$" << keybuffer2 << std::endl << entbuffer << std::endl;
199 book->
setKey(keybuffer2.c_str());
200 book->
setEntry(entbuffer.c_str(), entrysize);
209 keysize = keybuffer.length()-1;
215 if (format ==
F_OSIS && longnames ==
false) {
216 strtmp = (
char*)strstr(keybuffer.c_str(),
"osisID=\"");
219 for (;*strtmp !=
'\"'; strtmp++) {
223 else if (*strtmp ==
'.') {
226 else if (*strtmp != 13) {
234 strtmp = (
char*)strstr(keybuffer.c_str(),
"type=\"");
237 for (;*strtmp !=
'\"'; strtmp++) {
241 else if (*strtmp != 13) {
247 strtmp = (
char*)strstr(keybuffer.c_str(),
"n=\"");
250 for (;*strtmp !=
'\"'; strtmp++) {
254 else if (*strtmp != 13) {
261 strtmp = (
char*)strstr(keybuffer.c_str(),
"title=\"");
264 for (;*strtmp !=
'\"'; strtmp++) {
268 else if (*strtmp != 13) {
274 else if (format ==
F_THML) {
275 strtmp = (
char*)strstr(keybuffer.c_str(),
"title=\"");
278 for (;*strtmp !=
'\"'; strtmp++) {
282 else if (*strtmp != 13) {
290 if (keybuffer.length() && n.length())
294 if (longnames && keybuffer.length())
296 if (longnames || !keybuffer.length())
299 divs[level-1] = keybuffer;
static char createModule(const char *ipath)
virtual char setKey(const SWKey *ikey)
static signed char create(const char *path)
virtual void setEntry(const char *inbuf, long len=-1)