Changeset 91 for trunk/gsdl/src/library
- Timestamp:
- 1998-12-30T16:50:37+13:00 (26 years ago)
- Location:
- trunk/gsdl/src/library
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/library/Makefile
r90 r91 25 25 AR = ar 26 26 CC = gcc 27 CCFLAGS = -O2 27 CCFLAGS = -O2 -g 28 28 DEFS = -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM -DUSE_FASTCGI 29 29 RANLIB = ranlib -
trunk/gsdl/src/library/browse.cpp
r61 r91 44 44 else section = *thissection; 45 45 46 gdbm.getinfo(section, collection, info); 47 get_first_section(info.c, child); 48 49 // return_text += "<br>" + doclink + *thissection + "." + child + "\">" + info.t + "</a>\n"; 50 return_text += "<br>" + doclink + *thissection + "." + child + ".1\">" + info.t + "</a>\n"; 46 gdbm.getinfo(section, info); 47 get_first_section(info.contents, child); 48 49 // return_text += "<br>" + doclink + *thissection + "." + child + "\">" + info.title + "</a>\n"; 50 return_text += "<br>" + doclink + *thissection + "." + child + 51 ".1\">" + info.title + "</a>\n"; 51 52 thissection ++; 52 53 } … … 76 77 77 78 // get previous arrow 78 if (gdbm.exists(previous , args["c"])) {79 if (gdbm.exists(previous)) { 79 80 return_text += "<td><a href=\"_httptext_&d=" + classification + "." + previous; 80 81 return_text += "\">_iconless_</a></td>\n"; … … 83 84 // get page ? of ? text 84 85 return_text += "<td align=\"center\">\n"; 85 gdbm.getinfo(booksection, args["c"],info);86 if (is_number(info.t )) {86 gdbm.getinfo(booksection, info); 87 if (is_number(info.title)) { 87 88 splitstring(class_string, contents); 88 gdbm.getinfo(contents.back(), args["c"],topinfo);89 if (is_number(topinfo.t ))90 return_text += " page " + info.t + " of " + topinfo.t+ " ";89 gdbm.getinfo(contents.back(), topinfo); 90 if (is_number(topinfo.title)) 91 return_text += " page " + info.title + " of " + topinfo.title + " "; 91 92 else 92 return_text += " " + info.t + " ";93 return_text += " " + info.title + " "; 93 94 } else { 94 return_text += " " + info.t + " ";95 return_text += " " + info.title + " "; 95 96 } 96 97 return_text += "</td>\n"; 97 98 98 99 // get next arrow 99 if (gdbm.exists(next , args["c"])) {100 if (gdbm.exists(next)) { 100 101 return_text += "<td><a href=\"_httptext_&d=" + classification + "." + next; 101 102 return_text += "\">_iconmore_</a></td>\n"; … … 182 183 while (section != end) { 183 184 tab.clear(); 184 gdbm.getinfo(*section, args["c"],info);185 gdbm.getinfo(*section, info); 185 186 text_t icontabs; 186 187 … … 188 189 icon = "_iconsmalltext_"; 189 190 if (is_top_level(*section)) icon = "_iconopenbook_"; 190 else if (!info.c .empty()) icon = "_iconopenfolder_";191 else if (!info.contents.empty()) icon = "_iconopenfolder_"; 191 192 192 193 // set up pointer … … 217 218 if (args["g"][1] == '0' || is_top_level(*section) || 218 219 !are_same_chapter(booksection, *section) || 219 !info.c .empty()) {220 !info.contents.empty()) { 220 221 return_text += doclink + "d=" + classification; 221 222 return_text += "." + *section + "&a=" + pagetype; … … 228 229 return_text += "\">" + icon + "</a></td>"; 229 230 return_text += "<td colspan=" + text_t(tabsleft); 230 return_text += "><_font_>" + info.t + "</font>";231 return_text += "><_font_>" + info.title + "</font>"; 231 232 return_text += "</td></tr>\n"; 232 233 … … 256 257 if (is_book(*thisparent)) get_book(*thisparent, section); 257 258 else section = *thisparent; 258 gdbm.getinfo(section, args["c"],info);259 gdbm.getinfo(section, info); 259 260 260 261 // set up icon for this parent … … 289 290 return_text += "<td"; 290 291 if (colnum > 1) return_text += " colspan=" + text_t(colnum); 291 return_text += "><_font_>" + info.t ;292 if (!info.a .empty()) return_text += " by " + info.a;292 return_text += "><_font_>" + info.title; 293 if (!info.author.empty()) return_text += " by " + info.author; 293 294 return_text += "</font>"; 294 295 return_text += "</td></tr>\n"; … … 320 321 if (is_book(*thissibling)) get_book(*thissibling, section); 321 322 else section = *thissibling; 322 gdbm.getinfo(section, args["c"],info);323 gdbm.getinfo(section, info); 323 324 324 325 // set up icon for this sibling … … 342 343 tab += ">" + thesetabs + pointer + "</td>"; 343 344 344 if (info.c .empty()) {345 if (info.contents.empty()) { 345 346 // sibling is text document 346 347 icon = "_iconsmalltext_"; … … 362 363 return_text += "\">" + icon + "</a></td><td"; 363 364 if (colnum > 1) return_text += " colspan=" + text_t(colnum); 364 return_text += "><_font_>" + info.t ;365 if (!info.a .empty()) return_text += " by " + info.a;365 return_text += "><_font_>" + info.title; 366 if (!info.author.empty()) return_text += " by " + info.author; 366 367 return_text += "</font></td></tr>\n"; 367 368 } else { 368 369 // sibling is closed book or folder so clicking 369 370 // it should open contents 370 get_first_section(info.c , child);371 get_first_section(info.contents, child); 371 372 372 373 // get classification of child if it's a book … … 393 394 return_text += "\">" + icon + "</a></td><td"; 394 395 if (colnum > 1) return_text += " colspan=" + text_t(colnum); 395 return_text += "><_font_>" + info.t ;396 if (!info.a .empty()) return_text += " by " + info.a;396 return_text += "><_font_>" + info.title; 397 if (!info.author.empty()) return_text += " by " + info.author; 397 398 return_text += "</font></td></tr>\n"; 398 399 } … … 421 422 422 423 // get list of contents for this classification 423 gdbm.getinfo(classt, collection,info);424 if (!info.c .empty()) {425 splitstring(info.c , classcontents);424 gdbm.getinfo(classt, info); 425 if (!info.contents.empty()) { 426 splitstring(info.contents, classcontents); 426 427 vector<text_t>::const_iterator here = classcontents.begin(); 427 428 vector<text_t>::const_iterator end = classcontents.end(); 428 429 429 430 while (here != end) { 430 gdbm.getinfo(*here, collection,info);431 gdbm.getinfo(*here, info); 431 432 432 433 if (*here == classification) { 433 return_text += "<b>" + info.t + "</b> ";434 return_text += "<b>" + info.title + "</b> "; 434 435 } else { 435 if (!info.c .empty()) {436 get_first_section(info.c , firstcontent);436 if (!info.contents.empty()) { 437 get_first_section(info.contents, firstcontent); 437 438 return_text += link + *here + "." + firstcontent + "\">"; 438 return_text += info.t + "</a> ";439 return_text += info.title + "</a> "; 439 440 } 440 441 } … … 462 463 463 464 // get html for previous link if it exists 464 gdbm.getinfo(previous, collection,info);465 if (!info.c .empty()) {466 get_first_section(info.c , firstcontent);465 gdbm.getinfo(previous, info); 466 if (!info.contents.empty()) { 467 get_first_section(info.contents, firstcontent); 467 468 arrows += "<a href=\"_httpbrowse_&d="; 468 469 arrows += previous + "." + firstcontent + "\">"; … … 475 476 476 477 // get html for next link if it exists 477 gdbm.getinfo(next, collection,info);478 if (!info.c .empty()) {479 get_first_section(info.c , firstcontent);478 gdbm.getinfo(next, info); 479 if (!info.contents.empty()) { 480 get_first_section(info.contents, firstcontent); 480 481 arrows += "<a href=\"_httpbrowse_&d="; 481 482 arrows += next + "." + firstcontent + "\">"; … … 539 540 if (cols > totalcols) totalcols = cols; 540 541 541 gdbm.getinfo(section, collection,info);542 if (!info.c .empty()) {542 gdbm.getinfo(section, info); 543 if (!info.contents.empty()) { 543 544 vector<text_t> temp; 544 splitstring(info.c , temp);545 splitstring(info.contents, temp); 545 546 while (!temp.empty()) { 546 547 sections.push_back(temp.back()); … … 601 602 // don't want 'next' arrow pointing to next sibling if current section 602 603 // has children 603 gdbm.getinfo(booksection, args["c"],info);604 if (!info.c .empty()) nextsibling = current_classification;604 gdbm.getinfo(booksection, info); 605 if (!info.contents.empty()) nextsibling = current_classification; 605 606 606 607 // set up the 'previous' arrow … … 615 616 while (previoussibling.empty()) { 616 617 vector<text_t> parentsiblings; 617 gdbm.getinfo(sec, args["c"],info); // info on this section618 text_t last, parent = info.p ;619 gdbm.getinfo(parent, args["c"],info); // info on parent620 gdbm.getinfo(info.p , args["c"], info); // info on grandparent621 splitstring(info.c , parentsiblings); // now have parents siblings618 gdbm.getinfo(sec, info); // info on this section 619 text_t last, parent = info.parent; 620 gdbm.getinfo(parent, info); // info on parent 621 gdbm.getinfo(info.parent, info); // info on grandparent 622 splitstring(info.contents, parentsiblings); // now have parents siblings 622 623 623 624 vector<text_t>::const_iterator thisuncle = parentsiblings.begin(); … … 639 640 text_t prev; // use this in case previoussibling contains classification 640 641 get_book(previoussibling, prev); 641 gdbm.getinfo(prev, args["c"],info);642 while (!info.c .empty()) {642 gdbm.getinfo(prev, info); 643 while (!info.contents.empty()) { 643 644 vector<text_t> contents; 644 splitstring(info.c , contents);645 splitstring(info.contents, contents); 645 646 previoussibling = contents.back(); 646 gdbm.getinfo(previoussibling, args["c"],info);647 gdbm.getinfo(previoussibling, info); 647 648 } 648 649 … … 655 656 // if no younger siblings get parents younger siblings 656 657 while (nextsibling.empty()) { 657 gdbm.getinfo(sec, args["c"],info);658 text_t parent = info.p ;659 gdbm.getinfo(parent, args["c"],info); // parent info660 if (!info.p .empty()) {658 gdbm.getinfo(sec, info); 659 text_t parent = info.parent; 660 gdbm.getinfo(parent, info); // parent info 661 if (!info.parent.empty()) { 661 662 vector<text_t> parentsiblings; 662 gdbm.getinfo(info.p , args["c"], info); // grandparent info663 splitstring(info.c , parentsiblings); // got parents siblings663 gdbm.getinfo(info.parent, info); // grandparent info 664 splitstring(info.contents, parentsiblings); // got parents siblings 664 665 665 666 vector<text_t>::iterator thissibling = parentsiblings.begin(); … … 689 690 text_t next; 690 691 get_book(nextsibling, next); 691 gdbm.getinfo(next, args["c"],info);692 while (!info.c .empty()) {693 get_first_section(info.c , nextsibling);694 gdbm.getinfo(nextsibling, args["c"],info);692 gdbm.getinfo(next, info); 693 while (!info.contents.empty()) { 694 get_first_section(info.contents, nextsibling); 695 gdbm.getinfo(nextsibling, info); 695 696 } 696 697 if (nextsibling[0] == 'B') nextsibling = classification + "." + nextsibling; … … 755 756 else key = *here; 756 757 757 gdbm.getinfo(key, collection,info);758 gdbm.getinfo(key, info); 758 759 if (classification[0] == 'T') { 759 760 760 alphabetize_string_english(info.t );761 info.t += ":#:" + *here;762 tmparray = string_add(tmparray, &len, info.t .getcstr());761 alphabetize_string_english(info.title); 762 info.title += ":#:" + *here; 763 tmparray = string_add(tmparray, &len, info.title.getcstr()); 763 764 764 765 } else if (classification[0] == 'A') { 765 alphabetize_string_name(info.a );766 info.a += ":#:" + *here;767 tmparray = string_add(tmparray, &len, info.a .getcstr());766 alphabetize_string_name(info.author); 767 info.author += ":#:" + *here; 768 tmparray = string_add(tmparray, &len, info.author.getcstr()); 768 769 769 770 } else { 770 info. i+= ":#:" + *here;771 tmparray = string_add(tmparray, &len, info. i.getcstr());771 info.date += ":#:" + *here; 772 tmparray = string_add(tmparray, &len, info.date.getcstr()); 772 773 } 773 774 here ++; -
trunk/gsdl/src/library/cgiwrap.cpp
r90 r91 90 90 if (cfgline.size () >= 2) { 91 91 if (cfgline[0] == "gsdlhome") lib->setgsdlhome(cfgline[1]); 92 else if (cfgline[0] == "macroshome") lib->setmacroshome(cfgline[1]); 93 else if (cfgline[0] == "gdbmhome") lib->setgdbmhome(cfgline[1]); 94 else if (cfgline[0] == "indexhome") lib->setindexhome(cfgline[1]); 92 else if (cfgline[0] == "gdbmdir") lib->setgdbmdir(cfgline[1]); 93 else if (cfgline[0] == "collectdir") lib->setcollectdir(cfgline[1]); 95 94 else if (cfgline[0] == "httpprefix") lib->sethttpprefix(cfgline[1]); 96 95 else if (cfgline[0] == "gwcgi") lib->setgwcgi(cfgline[1]); … … 123 122 124 123 // read in the site configuration file 125 // try in the collection directory, then GSDLHOME/etc, 126 // then in GSDLHOME. 124 // try in the collection/etc directory, and then GSDLHOME/etc. 127 125 text_t filename = filename_cat (GSDLHOME, "collect"); 128 126 filename = filename_cat (filename, lib->get_collection_name()); 127 filename = filename_cat (filename, "etc"); 129 128 filename = filename_cat (filename, "site.cfg"); 130 129 if (!site_cfg_read (lib, filename, maxrequests)) { 131 filename = filename_cat (GSDLHOME, "etc/site.cfg"); 132 if (!site_cfg_read (lib, filename, maxrequests)) { 133 filename = filename_cat (GSDLHOME, "site.cfg"); 134 site_cfg_read (lib, filename, maxrequests); 135 } 130 filename = filename_cat (GSDLHOME, "etc"); 131 filename = filename_cat (GSDLHOME, "site.cfg"); 132 site_cfg_read (lib, filename, maxrequests); 136 133 } 137 134 138 135 // initialise the library software 139 lib->init(); 136 ofstream initout (GSDLHOME "/etc/initout.txt"); 137 lib->init(initout); 138 initout.close(); 140 139 141 140 // find out whether this is being run as a cgi-script -
trunk/gsdl/src/library/gdbmclass.cpp
r66 r91 1 1 #include "text_t.h" 2 2 #include "gdbmclass.h" 3 #include "unitool.h" 4 #include "gsdlunicode.h" 5 #include "fileutil.h" 3 6 #include <ctype.h> 4 7 #include <string.h> … … 36 39 37 40 void gdbm_info::clear () { 38 d = 0; // docnum 39 t.clear(); // title 40 p.clear(); // parent 41 x.clear(); // classification 42 c.clear(); // contents 43 j.clear(); // jobnumber 44 o.clear(); // OID 45 a.clear(); // author 46 s.clear(); // source 47 i.clear(); // date 48 } 49 50 // checks if key is present in infodb. 51 // returns 1 on success 0 on failure 52 int gdbmclass::exists (text_t key, text_t collection) { 53 54 datum key_data; 55 datum return_data; 56 57 // try to open the database if it's not already open 58 if (!open_database(collection)) { 59 if (logout != NULL) (*logout) << "gdbmclass: can't open database\n"; 60 return 0; 61 } 62 63 // sanity check 64 if (gdbm_file == NULL) { 65 if (logout != NULL) (*logout) << "gdbmclass: failed sanity check\n"; 66 return 0; 67 } 68 69 char *db_key = key.getcstr(); 70 71 if (db_key == NULL) { 72 if (logout != NULL) (*logout) << "gdbmclass: failed sanity check\n"; 73 return 0; 74 } 75 76 key_data.dptr = db_key; 77 key_data.dsize = strlen (db_key); 78 return_data = gdbm_fetch (gdbm_file, key_data); 79 delete db_key; 80 db_key = NULL; 81 82 if (return_data.dptr == NULL) { 83 if (logout != NULL) { 84 (*logout) << "gdbmclass: null data pointer\n"; 85 outconvertclass text_t2ascii; 86 (*logout) << text_t2ascii << "gdbmclass: key was \"" << key << "\"\n"; 87 } 88 return 0; 89 } 90 free (return_data.dptr); 91 return 1; 41 docnum = 0; // 'd' 42 title.clear(); // 't' 43 parent.clear(); // 'p' 44 classification.clear(); // 'x' 45 contents.clear(); // 'c' 46 jobnum.clear(); // 'j' 47 OID.clear(); // 'o' 48 author.clear(); // 'a' 49 source.clear(); // 's' 50 date.clear(); // 'i' 51 } 52 53 54 55 56 57 // returns 0 if failed, 1 if opened 58 int gdbmclass::opendatabase (const text_t &filename) { 59 text_t data_location; 60 int block_size = 0; 61 62 if (gdbmfile != NULL) { 63 if (openfile == filename) return 1; 64 else closedatabase (); 65 } 66 67 openfile = filename; 68 69 char *namebuffer = filename.getcstr(); 70 gdbmfile = gdbm_open (namebuffer, block_size, GDBM_READER, 00664, NULL); 71 delete namebuffer; 72 73 if (gdbmfile == NULL && logout != NULL) { 74 outconvertclass text_t2ascii; 75 (*logout) << text_t2ascii << "database open failed on: " << filename << "\n"; 76 } 77 78 return (gdbmfile != NULL); 79 } 80 81 82 void gdbmclass::closedatabase () { 83 if (gdbmfile == NULL) return; 84 85 gdbm_close (gdbmfile); 86 gdbmfile = NULL; 87 openfile.clear(); 92 88 } 93 89 … … 96 92 // key and collection aren't references as they might be aliases to 97 93 // something in info 98 int gdbmclass::getinfo (text_t key, text_t collection, gdbm_info &info) { 99 94 int gdbmclass::getinfo (text_t key, gdbm_info &info) { 95 text_t data; 96 97 if (!getkeydata (key, data)) return -1; 98 text_t::iterator here = data.begin (); 99 text_t::iterator end = data.end (); 100 101 text_t ikey, ivalue; 100 102 info.clear (); // reset info 101 103 104 while (getinfoline(here, end, ikey, ivalue)) { 105 if (ikey == "d") { info.docnum = ivalue.getint(); } 106 else if (ikey == "t") { info.title = ivalue; } 107 else if (ikey == "p") { info.parent = ivalue; } 108 else if (ikey == "x") { info.classification = ivalue; } 109 else if (ikey == "c") { info.contents = ivalue; } 110 else if (ikey == "j") { info.jobnum = ivalue; } 111 else if (ikey == "o") { info.OID = ivalue; } 112 else if (ikey == "a") { info.author = ivalue; } 113 else if (ikey == "s") { info.source = ivalue; } 114 else if (ikey == "i") { info.date = ivalue; } 115 } 116 117 return 0; 118 } 119 120 121 // returns 1 if the key exists 122 int gdbmclass::exists (text_t key) { 123 text_t data; 124 return getkeydata (key, data); 125 } 126 127 128 // returns 1 if successful 129 int gdbmclass::getkeydata (text_t key, text_t &data) { 102 130 datum key_data; 103 131 datum return_data; 104 char ikey[256]; 105 char ivalue[16384]; 106 int pos = 0; 107 108 // try to open the database if it's not already open 109 if (!open_database(collection)) { 110 if (logout != NULL) (*logout) << "gdbmclass: can't open database\n"; 111 return -1; 112 } 113 114 // sanity check 115 if (gdbm_file == NULL) { 116 if (logout != NULL) (*logout) << "gdbmclass: failed sanity check\n"; 117 return -1; 118 } 119 120 char *db_key = key.getcstr(); 121 122 if (db_key == NULL) { 123 if (logout != NULL) (*logout) << "gdbmclass: failed sanity check\n"; 124 return -1; 125 } 126 127 key_data.dptr = db_key; 128 key_data.dsize = strlen (db_key); 129 return_data = gdbm_fetch (gdbm_file, key_data); 130 delete db_key; 131 db_key = NULL; 132 133 if (return_data.dptr == NULL) { 134 if (logout != NULL) { 135 (*logout) << "gdbmclass: null data pointer\n"; 136 outconvertclass text_t2ascii; 137 (*logout) << text_t2ascii << "gdbmclass: key was \"" << key << "\"\n"; 138 } 139 return -1; 140 } 141 142 while ((pos = get_infoline(return_data.dptr, return_data.dsize, 143 pos, ikey, ivalue)) >= 0) { 144 145 if (strcmp (ikey, "d") == 0) { 146 info.d = atoi(ivalue); 147 148 } else if (strcmp (ikey, "p") == 0) { 149 info.p = ivalue; 150 151 } else if (strcmp (ikey, "t") == 0) { 152 info.t = ivalue; 153 154 } else if (strcmp (ikey, "x") == 0) { 155 info.x = ivalue; 156 157 } else if (strcmp (ikey, "c") == 0) { 158 info.c = ivalue; 159 160 } else if (strcmp (ikey, "j") == 0) { 161 info.j = ivalue; 162 163 } else if (strcmp (ikey, "o") == 0) { 164 info.o = ivalue; 165 166 } else if (strcmp (ikey, "a") == 0) { 167 info.a = ivalue; 168 169 } else if (strcmp (ikey, "s") == 0) { 170 info.s = ivalue; 171 172 } else if (strcmp (ikey, "i") == 0) { 173 info.i = ivalue; 174 } 175 } 176 132 133 if (gdbmfile == NULL) return 0; 134 135 // get a utf-8 encoded c string of the unicode key 136 key_data.dptr = (to_utf8(key)).getcstr(); 137 if (key_data.dptr == NULL) { 138 if (logout != NULL) (*logout) << "gdbmclass: out of memory\n"; 139 return 0; 140 } 141 key_data.dsize = strlen (key_data.dptr); 142 143 // fetch the result 144 return_data = gdbm_fetch (gdbmfile, key_data); 145 delete key_data.dptr; 146 147 if (return_data.dptr == NULL) return 0; 148 149 data.setcarr (return_data.dptr, return_data.dsize); 177 150 free (return_data.dptr); 178 179 return 0; 180 } 181 182 void gdbmclass::setgdbmhome (const text_t &thegdbmhome) 183 { 184 gdbmhome = thegdbmhome; 185 } 151 data = to_uni(data); // convert to unicode 152 153 return 1; 154 } 155 186 156 187 157 // parses a line of the form <key>value\n 188 // returns next position, -1 if there was nothing left to process 189 // in the string, -2 if there was an error 190 int gdbmclass::get_infoline (char *str, int len, int pos, char *key, char *value) { 191 int keylen = 0; 192 int valuelen = 0; 193 194 key[0] = '\0'; 195 value[0] = '\0'; 196 158 // returns 1 if successful 159 int gdbmclass::getinfoline (text_t::iterator &here, text_t::iterator end, 160 text_t &key, text_t &value) { 161 key.clear(); 162 value.clear(); 163 197 164 // ignore white space 198 while ( pos < len && isspace(str[pos])) pos++;199 165 while (here != end && is_unicode_space (*here)) here++; 166 200 167 // get the '<' 201 if (pos >= len) return -1; 202 if (str[pos] != '<') return -2; 203 pos++; 168 if (here == end || *here != '<') return 0; 169 here++; 204 170 205 171 // get the key 206 while ( pos < len && str[pos] != '>')207 key [keylen++] = str[pos++];208 209 key[keylen] = '\0';172 while (here != end && *here != '>') { 173 key.push_back(*here); 174 here++; 175 } 210 176 211 177 // get the '>' 212 if ( pos >= len || str[pos] != '>') return -2;213 pos++;178 if (here == end || *here != '>') return 0; 179 here++; 214 180 215 181 // get the value 216 while (pos < len && str[pos] != '\n') 217 value[valuelen++] = str[pos++]; 218 219 value[valuelen] = '\0'; 220 221 return pos; 222 } 223 224 225 // returns 0 if failed, 1 if opened 226 int gdbmclass::open_database (const text_t &collection) { 227 text_t data_location, text_dir; 228 int block_size = 0; 229 230 if (gdbm_file != NULL) { 231 if (collection != gdbm_open_name) { 232 close_database(); 233 } 234 } 235 if (gdbm_file == NULL) { 236 gdbm_open_name = collection; 237 gettextsuffix (collection, text_dir); 238 239 #ifdef __WIN32__ 240 data_location = gdbmhome + text_dir; 241 #else 242 data_location = gdbmhome + text_dir; 243 #endif 244 245 #ifdef _LITTLE_ENDIAN 246 data_location += ".ldb"; // little endian version of the gdbm database 247 #else 248 data_location += ".bdb"; // big endian version on the gdbm database 249 #endif 250 char *namebuffer = data_location.getcstr(); 251 // cerr << "database name: " << namebuffer << "\n"; 252 253 gdbm_file = gdbm_open (namebuffer, block_size, GDBM_READER, 00664, NULL); 254 delete namebuffer; 255 } 256 return (gdbm_file != NULL); 257 } 258 259 260 void gdbmclass::close_database () { 261 262 if (gdbm_file == NULL) return; 263 264 gdbm_close (gdbm_file); 265 gdbm_file = NULL; 266 } 182 while (here != end && *here != '\n') { 183 value.push_back(*here); 184 here++; 185 } 186 187 return 1; 188 } 189 190 267 191 268 192 … … 420 344 vector<text_t> classarray; 421 345 get_book_top (targetdoc, book_top); 422 gdbm.getinfo(book_top, collection,info);423 splitstring (info. x, classarray);346 gdbm.getinfo(book_top, info); 347 splitstring (info.classification, classarray); 424 348 if (!classarray.empty()) classification = classarray[0]; 425 349 else classification = "C.1"; … … 513 437 } else if (booksection.empty()) { 514 438 // get classification siblings 515 gdbm.getinfo(classification, collection,info);516 gdbm.getinfo(info.p , collection, info); // info is now parent info517 splitstring(info.c , siblings);439 gdbm.getinfo(classification, info); 440 gdbm.getinfo(info.parent, info); // info is now parent info 441 splitstring(info.contents, siblings); 518 442 return; 519 443 … … 522 446 if (is_top_level(booksection)) { 523 447 // top level of book so siblings are children of classification 524 gdbm.getinfo(classification, collection,info);525 splitstring(info.c , siblings);448 gdbm.getinfo(classification, info); 449 splitstring(info.contents, siblings); 526 450 527 451 // add classifications to book sections … … 532 456 } else { 533 457 // siblings come from immediate parent 534 gdbm.getinfo(booksection, collection,info);535 gdbm.getinfo(info.p , collection, info); // info is now parent info536 splitstring(info.c , siblings);458 gdbm.getinfo(booksection, info); 459 gdbm.getinfo(info.parent, info); // info is now parent info 460 splitstring(info.contents, siblings); 537 461 538 462 // add classifications to book sections -
trunk/gsdl/src/library/gdbmclass.h
r43 r91 12 12 #endif 13 13 14 #include "locateinfo.h"15 14 16 17 class gdbm_info 18 { 15 class gdbm_info { 19 16 public: 20 int docnum; 21 int d; 22 text_t t; 23 text_t p; 24 text_t x; 25 text_t c; 26 text_t j; 27 text_t o; 28 text_t a; 29 text_t s; 30 text_t i; 17 int docnum; // 'd' 18 text_t title; // 't' 19 text_t parent; // 'p' 20 text_t classification; // 'x' 21 text_t contents; // 'c' 22 text_t jobnum; // 'j' 23 text_t OID; // 'o' 24 text_t author; // 'a' 25 text_t source; // 's' 26 text_t date; // 'i' 31 27 32 28 void clear (); … … 34 30 35 31 36 class gdbmclass 37 { 32 class gdbmclass { 38 33 public: 39 gdbmclass() {gdbm _file = NULL; logout = &cerr;};34 gdbmclass() {gdbmfile = NULL; logout = &cerr;}; 40 35 ~gdbmclass() {}; 41 36 37 // returns 0 if failed, 1 if opened 38 int opendatabase (const text_t &filename); 39 void closedatabase (); 40 42 41 // returns 0 on success, -1 on failure 43 int getinfo (text_t key, text_t collection, gdbm_info &info); 44 void setgdbmhome (const text_t &thegdbmhome); 42 int getinfo (text_t key, gdbm_info &info); 45 43 void setlogout (ostream *thelogout) {logout = thelogout;} 46 int exists (text_t key , text_t collection);44 int exists (text_t key); 47 45 48 46 protected: 49 text_t gdbmhome; // top level directory for gdbm files 50 GDBM_FILE gdbm_file; 51 text_t gdbm_open_name; 47 text_t openfile; 48 GDBM_FILE gdbmfile; 52 49 ostream *logout; 53 50 54 int open_database (const text_t &collection); 55 void close_database (); 56 57 int get_infoline (char *str, int len, int pos, char *key, char *value); 51 int getkeydata (text_t key, text_t &data); 52 int getinfoline (text_t::iterator &here, text_t::iterator end, 53 text_t &key, text_t &value); 58 54 }; 59 55 -
trunk/gsdl/src/library/libinterface.cpp
r67 r91 6 6 #include "libinterface.h" 7 7 #include "cgiargs.h" 8 #include "fileutil.h" 9 #include "cfgread.h" 8 10 9 11 #include <assert.h> … … 142 144 // constructor 143 145 144 libinterface::libinterface() 145 { 146 libinterface::libinterface() { 146 147 browse = NULL; 147 148 } 148 149 149 void libinterface::setgsdlhome (const text_t &thegsdlhome) 150 { 150 void libinterface::setgsdlhome (const text_t &thegsdlhome) { 151 text_t thecollectdir, thegdbmdir, filename; 152 151 153 gsdlhome = thegsdlhome; 152 setmacroshome (thegsdlhome); 153 setgdbmhome (thegsdlhome); 154 setindexhome (thegsdlhome); 155 } 156 157 void libinterface::setmacroshome (const text_t &themacroshome) 158 { 159 macroshome = themacroshome; 160 } 161 162 void libinterface::setgdbmhome (const text_t &thegdbmhome) 163 { 164 gdbmhome = thegdbmhome; 165 gdbm.setgdbmhome(gdbmhome); 166 } 167 168 void libinterface::setindexhome (const text_t &theindexhome) 169 { 170 indexhome = theindexhome; 171 search.setindexhome(theindexhome); 172 } 173 174 void libinterface::sethttpprefix (const text_t &thehttpprefix) 175 { 154 155 // search for etc/collect.cfg 156 thecollectdir = filename_cat (gsdlhome, "collect"); 157 thecollectdir = filename_cat (thecollectdir, get_collection_name()); 158 filename = filename_cat (thecollectdir, "etc"); 159 filename = filename_cat (filename, "config.cfg"); 160 if (!file_exists(filename)) thecollectdir = gsdlhome; 161 162 thegdbmdir = filename_cat (thecollectdir, "index"); 163 thegdbmdir = filename_cat (thegdbmdir, "text"); 164 165 setcollectdir (thecollectdir); 166 setgdbmdir (thegdbmdir); 167 } 168 169 void libinterface::setcollectdir (const text_t &thecollectdir) { 170 collectdir = thecollectdir; 171 172 search.setcollectdir (collectdir); 173 } 174 175 void libinterface::setgdbmdir (const text_t &thegdbmdir) { 176 gdbmdir = thegdbmdir; 177 } 178 179 void libinterface::sethttpprefix (const text_t &thehttpprefix) { 176 180 httpprefix = thehttpprefix; 177 181 } 178 182 179 void libinterface::setgwcgi (const text_t &thegwcgi) 180 { 183 void libinterface::setgwcgi (const text_t &thegwcgi) { 181 184 gwcgi = thegwcgi; 182 185 } 186 187 188 int libinterface::cfg_read (const text_t &filename) { 189 text_t key; 190 text_tarray cfgline; 191 char *cstr = filename.getcstr(); 192 ifstream confin (cstr); 193 delete cstr; 194 195 if (confin) { 196 while (read_cfg_line(confin, cfgline) >= 0) { 197 if (cfgline.size () >= 2) { 198 key = cfgline[0]; 199 cfgline.erase(cfgline.begin()); 200 if (key == "maintainer") cfg_info.maintainer = cfgline[0]; 201 else if (key == "indexes") cfg_info.indexes = cfgline; 202 else if (key == "defaultindex") cfg_info.defaultindex = cfgline[0]; 203 else if (key == "macrofiles") cfg_info.macrofiles = cfgline; 204 else if (key == "builddate") cfg_info.builddate = cfgline[0]; 205 else if (key == "indexmap") cfg_info.indexmap = cfgline; 206 else if (key == "numbytes") cfg_info.numbytes = (double)cfgline[0].getint(); 207 else if (key == "numdocs") cfg_info.numdocs = (double)cfgline[0].getint(); 208 } 209 } 210 confin.close (); 211 return 1; 212 } 213 return 0; 214 } 215 183 216 184 217 // init should be called after the various homes are set, 185 218 // it returns 'false' on failure and 'true' on success 186 bool libinterface::init () 187 { 219 bool libinterface::init (ostream &logout) { 220 text_t collection = get_collection_name(); 221 222 // redirect the error output to logout 223 disp.setlogout (&logout); 224 gdbm.setlogout (&logout); 225 226 // open the gdbm file 227 text_t filename = filename_cat (gdbmdir, get_collection_name ()); 228 #ifdef _LITTLE_ENDIAN 229 filename += ".ldb"; // little endian version of the gdbm database 230 #else 231 filename += ".bdb"; // big endian version on the gdbm database 232 #endif 233 gdbm.opendatabase (filename); 234 235 // read in the configuration files etc/collect.cfg and index/build.cfg 236 // entries in build.cfg should override those in collect.cfg 237 filename = filename_cat (collectdir, "etc"); 238 filename = filename_cat (filename, "collect.cfg"); 239 cfg_read(filename); 240 filename = filename_cat (collectdir, "index"); 241 filename = filename_cat (filename, "build.cfg"); 242 cfg_read(filename); 243 244 // logout << text_t2ascii << "defaultindex: " << cfg_info.defaultindex << "\n"; 245 188 246 set_default_index(); 189 text_t collection = get_collection_name(); 190 191 // load up default macro files -- these shouldn't have absolute file names 192 #ifdef __WIN32__ 193 disp.loaddefaultmacros(macroshome + "\\macros\\base.dm"); 194 disp.loaddefaultmacros(macroshome + "\\macros\\browse.dm"); 195 disp.loaddefaultmacros(macroshome + "\\macros\\text.dm"); 196 disp.loaddefaultmacros(macroshome + "\\macros\\query.dm"); 197 disp.loaddefaultmacros(macroshome + "\\macros\\help.dm"); 198 disp.loaddefaultmacros(macroshome + "\\macros\\gsdl.dm"); 199 disp.loaddefaultmacros(macroshome + "\\macros\\pref.dm"); 200 #else 201 disp.loaddefaultmacros(macroshome + "/macros/base.dm"); 202 disp.loaddefaultmacros(macroshome + "/macros/browse.dm"); 203 disp.loaddefaultmacros(macroshome + "/macros/text.dm"); 204 disp.loaddefaultmacros(macroshome + "/macros/query.dm"); 205 disp.loaddefaultmacros(macroshome + "/macros/help.dm"); 206 disp.loaddefaultmacros(macroshome + "/macros/gsdl.dm"); 207 disp.loaddefaultmacros(macroshome + "/macros/pref.dm"); 208 #endif 247 248 249 // load up the default macro files, the collection directory 250 // is searched first for the file and then the main directory 251 text_t colmacrodir = filename_cat (collectdir, "macros"); 252 text_t gsdlmacrodir = filename_cat (gsdlhome, "macros"); 253 text_tarray::iterator arrhere = cfg_info.macrofiles.begin(); 254 text_tarray::iterator arrend = cfg_info.macrofiles.end(); 255 while (arrhere != arrend) { 256 filename = filename_cat (colmacrodir, *arrhere); 257 if (!file_exists (filename)) { 258 filename = filename_cat (gsdlmacrodir, *arrhere); 259 } 260 disp.loaddefaultmacros(filename); 261 arrhere++; 262 } 209 263 210 264 srand(time(NULL)); … … 222 276 int err = LI_NOERROR; 223 277 224 gdbm.setlogout (&logout); // make the output go where they want! 278 // make the output go where they want! 279 gdbm.setlogout (&logout); 280 disp.setlogout (&logout); 225 281 226 282 cgiargsclass args; … … 725 781 if (args["d"][0] != 'B') get_book(args["d"], docref); 726 782 else docref = args["d"]; 727 if (gdbm.getinfo(docref, queryparams.collection,info) != 0) {783 if (gdbm.getinfo(docref, info) != 0) { 728 784 logout << text_t2ascii << "info_db wasn't opened - " << docref << "\n"; 729 785 return; … … 731 787 732 788 // get document text if there is any 733 if (info.c .empty()) {789 if (info.contents.empty()) { 734 790 search.docTargetDocument(default_index, queryparams.collection, 735 info.d , content);736 if (info.t != "<i>(introductory text)</i>")737 content = "<h3>" + info.t + "</h3>\n" + content;791 info.docnum, content); 792 if (info.title != "<i>(introductory text)</i>") 793 content = "<h3>" + info.title + "</h3>\n" + content; 738 794 } 739 795 } … … 761 817 762 818 // get docnum from gdbm 763 if (gdbm.getinfo(*thiscontent, queryparams.collection,info) != 0) {819 if (gdbm.getinfo(*thiscontent, info) != 0) { 764 820 logout << text_t2ascii << "info_db wasn't opened - " << args["d"] << "\n"; 765 821 return; … … 767 823 768 824 // if section has text get it, otherwise output section title 769 if (info.c .empty()) {825 if (info.contents.empty()) { 770 826 771 827 // output <a name= > tags for all text sections currently displayed in toc (all text sections … … 779 835 780 836 search.docTargetDocument(default_index, queryparams.collection, 781 info.d , text);782 if (info.t != "<i>(introductory text)</i>")783 content += "<h3>" + info.t + "</h3>\n";837 info.docnum, text); 838 if (info.title != "<i>(introductory text)</i>") 839 content += "<h3>" + info.title + "</h3>\n"; 784 840 // content += text + "<hr><br>\n"; 785 841 content += text + "<p>\n"; // no longer want <hr> between sections 786 842 } else { 787 content += "<h3>" + info.t + "</h3>\n";843 content += "<h3>" + info.title + "</h3>\n"; 788 844 } 789 845 … … 820 876 if (args["d"][0] != 'B') get_book(args["d"], docref); 821 877 else docref = args["d"]; 822 if (gdbm.getinfo(docref, queryparams.collection,info) != 0) {878 if (gdbm.getinfo(docref, info) != 0) { 823 879 logout << text_t2ascii << "info_db wasn't opened - " << docref << "\n"; 824 880 return; … … 826 882 827 883 // get document text if there is any 828 if (info.c .empty()) {884 if (info.contents.empty()) { 829 885 search.docTargetDocument(default_index, queryparams.collection, 830 info.d , content);831 if (info.t != "<i>(introductory text)</i>")832 content = "<h3>" + info.t + "</h3>\n" + content;886 info.docnum, content); 887 if (info.title != "<i>(introductory text)</i>") 888 content = "<h3>" + info.title + "</h3>\n" + content; 833 889 } 834 890 } -
trunk/gsdl/src/library/libinterface.h
r89 r91 30 30 31 31 32 class cfg_info_t { 33 public: 34 cfg_info_t () {numbytes=0.0; numdocs=0.0;}; 32 35 33 class libinterface 34 { 36 text_t maintainer; 37 text_tarray indexes; 38 text_t defaultindex; 39 text_tarray macrofiles; 40 text_t builddate; 41 text_tarray indexmap; 42 double numbytes; 43 double numdocs; 44 }; 45 46 47 class libinterface { 35 48 public: 36 49 libinterface (); 37 50 virtual ~libinterface() {} 38 51 39 // setgsdlhome will set the macros, gdbm, index, and text homes 52 // setgsdlhome will search for etc/collect.cfg and 53 // set collectdir and gdbmdir 40 54 void setgsdlhome (const text_t &thegsdlhome); 41 55 42 void setmacroshome (const text_t &themacroshome); 43 void setgdbmhome (const text_t &thegdbmhome); 44 void setindexhome (const text_t &theindexhome); 56 // collectdir contains etc/collect.cfg, archives, 57 // index, and maybe a macros directory 58 void setcollectdir (const text_t &thecollectdir); 59 void setgdbmdir (const text_t &thegdbmdir); 45 60 46 61 void sethttpprefix (const text_t &thehttpprefix); … … 49 64 // init should be called after the various homes are set, 50 65 // it returns 'false' on failure and 'true' on success 51 bool init ( );66 bool init (ostream &logout); 52 67 53 68 // examine the cgi arguments and create the appropriate page, … … 65 80 66 81 protected: 82 cfg_info_t cfg_info; 83 67 84 text_t gsdlhome; 68 text_t macroshome; 69 text_t gdbmhome; 70 text_t indexhome; 85 text_t gdbmdir; 86 text_t collectdir; 71 87 72 88 text_t books; … … 94 110 mgsearchclass search; 95 111 112 int cfg_read (const text_t &filename); 113 96 114 virtual void get_arg_config (text_t &argconfigstr); 97 115 text_t::iterator get_next_config_arg (text_t::iterator first, text_t::iterator last, … … 129 147 virtual void highlighttext(vector<text_t> &termvars, ostream &textout, 130 148 ostream &logout, text_t &text); 131 void libinterface::format_querystring (text_t &querystring);149 void format_querystring (text_t &querystring); 132 150 133 151 … … 139 157 virtual void displaydocsummary (cgiargsclass &args, ostream &textout, 140 158 ostream &logout, queryresultsclass &queryresults, 141 159 int resultnum) {} 142 160 143 161 -
trunk/gsdl/src/library/locateinfo.cpp
r32 r91 1 1 #include "locateinfo.h" 2 #include "fileutil.h" 2 3 3 void getindexsuffix (const text_t &index, 4 const text_t &collection, 5 text_t &ttidxsuffix) 6 { 7 8 // new directory structure 9 // ttidxsuffix = "collect"; 10 11 //#ifdef __WIN32__ 12 //ttidxsuffix += "\\"; 13 //#else 14 //ttidxsuffix += "/"; 15 //#endif 16 17 //ttidxsuffix += collection; 18 19 20 #ifdef __WIN32__ 21 ttidxsuffix += "\\index\\"; 22 #else 23 ttidxsuffix += "/index/"; 24 #endif 25 26 // ttidxsuffix += collection; //this changed with new build software 27 ttidxsuffix += index; 28 #ifdef __WIN32__ 29 ttidxsuffix += "\\"; 30 #else 31 ttidxsuffix += "/"; 32 #endif 33 ttidxsuffix += collection; 4 text_t getindexsuffix (const text_t &collection, 5 const text_t &index) { 6 text_t indexsuffix = "index"; 7 indexsuffix = filename_cat (indexsuffix, index); 8 indexsuffix = filename_cat (indexsuffix, collection); 9 return indexsuffix; 34 10 } 35 11 36 void gettextsuffix (const text_t &collection, 37 text_t &tttxtsuffix) 38 { 39 // new directory structure 40 // tttxtsuffix = "collect"; 41 42 //#ifdef __WIN32__ 43 //tttxtsuffix += "\\"; 44 //#else 45 //tttxtsuffix += "/"; 46 //#endif 47 48 //tttxtsuffix += collection; 49 50 #ifdef __WIN32__ 51 tttxtsuffix += "\\index\\"; 52 #else 53 tttxtsuffix += "/index/"; 54 #endif 55 56 // tttxtsuffix += collection; // path changed with new building software - Stefan. 57 tttxtsuffix += "text"; 58 #ifdef __WIN32__ 59 tttxtsuffix += "\\"; 60 #else 61 tttxtsuffix += "/"; 62 #endif 63 tttxtsuffix += collection; 12 text_t gettextsuffix (const text_t &collection) { 13 text_t textsuffix = "index"; 14 textsuffix = filename_cat (textsuffix, "text"); 15 textsuffix = filename_cat (textsuffix, collection); 16 return textsuffix; 64 17 } -
trunk/gsdl/src/library/locateinfo.h
r4 r91 4 4 #include "text_t.h" 5 5 6 void getindexsuffix (const text_t &index, 7 const text_t &collection, 8 text_t &ttidxsuffix); 6 text_t getindexsuffix (const text_t &collection, 7 const text_t &index); 9 8 10 void gettextsuffix (const text_t &collection, 11 text_t &tttxtsuffix); 9 text_t gettextsuffix (const text_t &collection); 12 10 13 11 #endif -
trunk/gsdl/src/library/mgsearch.cpp
r32 r91 27 27 #include "mgsearch.h" 28 28 #include "locateinfo.h" 29 #include "gsdlunicode.h" 30 #include "unitool.h" 31 29 32 30 33 ///////////// … … 82 85 float Weight, void *info) { 83 86 87 // convert term from utf8 to unicode 88 text_t term; 89 utf8inconvertclass inconvert; 90 convertclass::status_t status; 91 inconvert.reset (); 92 inconvert.setinput (Word, ULen); 93 inconvert.convert (term, status); 94 84 95 queryresultsclass *queryresults = (queryresultsclass *)info; 85 queryresults->termvariants.push_back( Word);96 queryresults->termvariants.push_back(term); 86 97 87 98 return 0; … … 93 104 text_t *output = (text_t *)info; 94 105 if (output == NULL) return 0; 95 96 output->setcarr(Word, ULen); 106 output->clear(); 107 108 utf8inconvertclass inconvert; 109 convertclass::status_t status; 110 inconvert.reset (); 111 inconvert.setinput (Word, ULen); 112 inconvert.convert (*output, status); 97 113 98 114 // replace all control-Cs with spaces 99 115 text_t::iterator here = output->begin(); 100 116 text_t::iterator end = output->end(); 101 while (here != end) 102 { 103 if (*here == '\x3') *here = ' '; 104 here++; 105 } 117 while (here != end) { 118 if (*here == '\x3') *here = ' '; 119 here++; 120 } 106 121 107 122 return 0; … … 129 144 130 145 131 void mgsearchclass::set indexhome (const text_t &theindexhome)132 { 133 indexhome = theindexhome;146 void mgsearchclass::setcollectdir (const text_t &thecollectdir) 147 { 148 collectdir = thecollectdir; 134 149 } 135 150 136 151 137 152 bool mgsearchclass::search(const queryparamclass &queryparams, 138 153 queryresultsclass &queryresults) 139 154 { 140 155 bool databaseloaded = true; … … 146 161 // first check the cache 147 162 if (cache->find(queryparams, queryresults)) 148 { 149 return true; 150 } 163 return true; 151 164 152 165 // make sure there is a query to be processed … … 154 167 text_t::const_iterator queryend = queryparams.querystring.end(); 155 168 while (queryhere != queryend) { 156 if (((*queryhere >= 65) && (*queryhere <= 90)) || 157 ((*queryhere >= 97) && (*queryhere <= 122)) || 158 ((*queryhere >= 192) && (*queryhere <= 214)) || 159 ((*queryhere >= 216) && (*queryhere <= 246)) || 160 ((*queryhere >= 248) && (*queryhere <= 255)) || 161 ((*queryhere >= '0') && (*queryhere <= '9'))) break; 169 if (is_unicode_letdig (*queryhere)) break; 162 170 queryhere++; 163 171 } … … 169 177 170 178 171 172 179 // get the names of the index and text suffixes 173 text_t ttidxsuffix, tttxtsuffix; 174 getindexsuffix (queryparams.search_index, 175 queryparams.collection, ttidxsuffix); 176 gettextsuffix (queryparams.collection, tttxtsuffix); 177 char *idxsuffix = ttidxsuffix.getcstr(); assert (idxsuffix != NULL); 178 char *txtsuffix = tttxtsuffix.getcstr(); assert (txtsuffix != NULL); 180 char *idxsuffix = (getindexsuffix (queryparams.collection, 181 queryparams.search_index)).getcstr(); 182 assert (idxsuffix != NULL); 183 char *txtsuffix = (gettextsuffix (queryparams.collection)).getcstr(); 184 assert (txtsuffix != NULL); 179 185 180 186 #ifdef __WIN32__ 181 char *c indexhome = (indexhome+"\\").getcstr(); assert (cindexhome!= NULL);187 char *ccollectdir = (collectdir+"\\").getcstr(); assert (ccollectdir != NULL); 182 188 #else 183 char *c indexhome = indexhome.getcstr(); assert (cindexhome!= NULL);189 char *ccollectdir = collectdir.getcstr(); assert (ccollectdir != NULL); 184 190 #endif 185 191 186 if (load_database(c indexhome, idxsuffix, txtsuffix))192 if (load_database(ccollectdir, idxsuffix, txtsuffix)) 187 193 { 188 194 setsearchmode (queryparams); … … 195 201 delete idxsuffix; 196 202 delete txtsuffix; 197 delete c indexhome;203 delete ccollectdir; 198 204 199 205 return databaseloaded; … … 348 354 // defaultindex is needed to load one 349 355 bool mgsearchclass::docTargetDocument(const text_t &defaultindex, 350 const text_t &collection,351 int docnum,352 text_t &output)356 const text_t &collection, 357 int docnum, 358 text_t &output) 353 359 { 354 360 bool databaseloaded = true; … … 423 429 { 424 430 // get the names of the index and text suffixes 425 text_t ttidxsuffix, tttxtsuffix;426 getindexsuffix (defaultindex, collection, ttidxsuffix);427 gettextsuffix (collection, tttxtsuffix);428 char *idxsuffix = ttidxsuffix.getcstr(); assert (idxsuffix != NULL);429 char *txtsuffix = tttxtsuffix.getcstr();assert (txtsuffix != NULL);431 char *idxsuffix = (getindexsuffix (collection, 432 defaultindex)).getcstr(); 433 assert (idxsuffix != NULL); 434 char *txtsuffix = (gettextsuffix (collection)).getcstr(); 435 assert (txtsuffix != NULL); 430 436 431 437 #ifdef __WIN32__ 432 char *c indexhome = (indexhome+"\\").getcstr(); assert (cindexhome!= NULL);438 char *ccollectdir = (collectdir+"\\").getcstr(); assert (ccollectdir != NULL); 433 439 #else 434 char *c indexhome = indexhome.getcstr(); assert (cindexhome!= NULL);440 char *ccollectdir = collectdir.getcstr(); assert (ccollectdir != NULL); 435 441 #endif 436 442 437 438 if (load_database(cindexhome, idxsuffix, txtsuffix)) 439 { 440 databaseloaded = true; 441 } 443 if (load_database(ccollectdir, idxsuffix, txtsuffix)) 444 databaseloaded = true; 442 445 else 443 { 444 databaseloaded = false; 445 } 446 446 databaseloaded = false; 447 447 448 // free up the c strings 448 449 delete idxsuffix; 449 450 delete txtsuffix; 450 delete c indexhome;451 delete ccollectdir; 451 452 } 452 453 -
trunk/gsdl/src/library/mgsearch.h
r4 r91 18 18 // the index directory must be set before any searching 19 19 // is done 20 void set indexhome (const text_t &theindexhome);20 void setcollectdir (const text_t &thecollectdir); 21 21 22 22 // the search results are returned in queryresults … … 38 38 protected: 39 39 querycache *cache; 40 text_t indexhome; // top level directory for indexes40 text_t collectdir; // the collection directory 41 41 42 42 void setsearchmode (const queryparamclass &queryparams);
Note:
See TracChangeset
for help on using the changeset viewer.