Ignore:
Timestamp:
2000-08-03T14:49:41+12:00 (24 years ago)
Author:
johnmcp
Message:

Relatively stable z39.50 implementation now, merged with the mgpp source.
(Still needs a decent interface and query language though...)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/z3950-branch/gsdl/src/recpt/librarymain.cpp

    r1168 r1342  
    2222 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    2323 *
    24  * $Id$
    25  *
    2624 *********************************************************************/
    27 
    28 /*
    29    $Log$
    30    Revision 1.25.2.1  2000/05/11 01:56:29  johnmcp
    31 
    32    added proper config file parsing for z39.50 servers, and minor changes
    33    to pageaction (minor bug when display collections from >1 proto) and
    34    cgiwrapper (announces which collections are z39.50 servers).
    35 
    36    Revision 1.25  2000/04/14 02:52:05  sjboddie
    37    tidied up error messaging and set up some debugging info to be output
    38    when running library from command line
    39 
    40    Revision 1.24  2000/02/29 20:59:02  sjboddie
    41    added error message when unable to read from collect directory - should
    42    probably write this out to a web page too
    43 
    44    Revision 1.23  2000/02/21 21:59:37  sjboddie
    45    gsdlhome now comes from gsdlsite.cfg
    46 
    47    Revision 1.22  2000/02/17 02:35:48  sjboddie
    48    tidied up a bit
    49 
    50    Revision 1.21  2000/02/15 22:53:51  kjm18
    51    search history stuff added.
    52 
    53    Revision 1.20  1999/12/13 02:46:56  davidb
    54    Teach buildaction about recptionist
    55 
    56    Revision 1.19  1999/11/01 21:58:49  sjboddie
    57    no longer set receptionist for some actions that used to
    58 
    59    Revision 1.18  1999/10/25 22:29:31  sjboddie
    60    receptionist now checks collect diectory for collections
    61    rather than collections.txt file
    62 
    63    Revision 1.17  1999/10/19 03:23:43  davidb
    64    Collection building support through web pages
    65    and internal and external link handling for collection documents
    66 
    67    Revision 1.16  1999/10/18 20:07:33  sjboddie
    68    added htmlbrowserclass
    69 
    70    Revision 1.15  1999/10/14 23:03:10  sjboddie
    71    another browser
    72 
    73    Revision 1.14  1999/10/10 08:14:09  sjboddie
    74    - metadata now returns mp rather than array
    75    - redesigned browsing support (although it's not finished so
    76    won't currently work ;-)
    77 
    78    Revision 1.13  1999/09/16 21:39:35  sjboddie
    79    added gb converters
    80 
    81    Revision 1.12  1999/09/14 22:42:06  sjboddie
    82    included utf8 converter
    83 
    84    Revision 1.11  1999/09/14 22:03:27  sjboddie
    85    now reads in collections from a file to avoid recompiling
    86 
    87    Revision 1.10  1999/09/08 00:51:11  sjboddie
    88    removed old interface stuff
    89 
    90    Revision 1.9  1999/09/07 04:56:56  sjboddie
    91    added GPL notice
    92 
    93    Revision 1.8  1999/07/15 06:08:55  rjmcnab
    94    Moved the adding of the actions to librarymain so that they can
    95    be overriden easier.
    96 
    97    Revision 1.7  1999/06/15 01:56:12  sjboddie
    98    Got multiple collections working
    99 
    100    Revision 1.6  1999/05/10 03:40:39  sjboddie
    101    lots of changes - slowly getting document action sorted out
    102 
    103    Revision 1.5  1999/04/19 23:56:10  rjmcnab
    104    Finished the gdbm metadata stuff
    105 
    106    Revision 1.4  1999/04/12 03:45:05  rjmcnab
    107    Finished the query filter.
    108 
    109    Revision 1.3  1999/04/06 22:20:35  rjmcnab
    110    Got browsefilter working.
    111 
    112    Revision 1.2  1999/03/05 03:53:54  sjboddie
    113 
    114    fixed some bugs
    115 
    116    Revision 1.1  1999/02/21 22:35:22  rjmcnab
    117 
    118    Initial revision.
    119 
    120  */
    121 
    12225
    12326#include "receptionist.h"
     
    12932#include "filter.h"
    13033#include "browsefilter.h"
    131 #include "queryfilter.h"
     34#include "mgqueryfilter.h"
     35#include "mgppqueryfilter.h"
    13236#include "infodbclass.h"
     37#include "mggdbmsource.h"
    13338#include "mgsearch.h"
    134 #include "mggdbmsource.h"
     39#include "mgppsearch.h"
    13540#include "fileutil.h"
    13641#include <assert.h>
     
    16267  nullproto nproto;
    16368  z3950proto zproto;
     69
    16470  text_tarray collections;
    165 
    16671
    16772  // get gsdlhome
     
    17075  text_t collectdir = filename_cat (gsdlhome, "collect");
    17176  read_dir (collectdir, collections);
    172 
     77 
    17378  text_tarray::const_iterator thiscol = collections.begin();
    17479  text_tarray::const_iterator endcol = collections.end();
     
    17782   
    17883    // ignore the modelcol
    179     if (*thiscol == "modelcol") {thiscol ++; continue;}
    180    
     84
     85    if (*thiscol == "modelcol") {
     86      thiscol ++;
     87      continue;
     88    }
     89   
     90    // read config file to see if built with mg or mgpp
     91    text_t buildtype = "mg"; // mg is default
     92    text_tarray cfgline;
     93    text_t key;
     94    text_t filename = filename_cat(collectdir, *thiscol, "index/build.cfg");
     95    ifstream confin(filename.getcstr());
     96
     97    if (confin) {
     98      while (read_cfg_line(confin, cfgline) >= 0) {
     99    if (cfgline.size() ==2 ) {
     100      key = cfgline[0];
     101      cfgline.erase(cfgline.begin());
     102      if (key =="buildtype") {
     103        buildtype = cfgline[0];
     104        break;
     105      }
     106    }
     107      }
     108    }
     109   
     110    confin.close();
     111
    181112    // this memory is created but never destroyed
    182113    // we're also not doing any error checking to make sure we didn't
     
    184115    collectserver *cserver = new collectserver();
    185116    gdbmclass *gdbmhandler = new gdbmclass();
    186     mgsearchclass *mgsearch = new mgsearchclass();
    187    
     117
    188118    // add a null filter
    189119    filterclass *filter = new filterclass ();
     
    193123    browsefilterclass *browsefilter = new browsefilterclass();
    194124    browsefilter->set_gdbmptr (gdbmhandler);
    195     cserver->add_filter (browsefilter);
    196    
    197     // add a query filter
    198     queryfilterclass *queryfilter = new queryfilterclass();
    199     queryfilter->set_gdbmptr (gdbmhandler);
    200     queryfilter->set_mgsearchptr (mgsearch);
    201     cserver->add_filter (queryfilter);
    202    
    203     // add a mg and gdbm source
    204     mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
    205     mggdbmsource->set_gdbmptr (gdbmhandler);
    206     mggdbmsource->set_mgsearchptr (mgsearch);
    207     cserver->add_source (mggdbmsource);
     125    cserver->add_filter (browsefilter); 
     126 
     127    if (buildtype == "mg") {
     128       mgsearchclass *mgsearch = new mgsearchclass();
     129 
     130       // add a query filter
     131       mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
     132       queryfilter->set_gdbmptr (gdbmhandler);
     133       queryfilter->set_mgsearchptr (mgsearch);
     134       cserver->add_filter (queryfilter);
     135       
     136       // add a mg and gdbm source
     137       mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
     138       mggdbmsource->set_gdbmptr (gdbmhandler);
     139       mggdbmsource->set_mgsearchptr (mgsearch);
     140       cserver->add_source (mggdbmsource);
     141    }
     142    else if (buildtype == "mgpp") {
     143     
     144      mgppsearchclass *mgsearch = new mgppsearchclass();
     145
     146      // add a query filter
     147      mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
     148      queryfilter->set_gdbmptr (gdbmhandler);
     149      queryfilter->set_mgsearchptr (mgsearch);
     150      cserver->add_filter (queryfilter);
     151     
     152      // add a mg and gdbm source
     153      mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
     154      mggdbmsource->set_gdbmptr (gdbmhandler);
     155      mggdbmsource->set_mgsearchptr (mgsearch);
     156      cserver->add_source (mggdbmsource);
     157   
     158    }
    208159   
    209160    // inform collection server and everything it contains about its
     
    247198  recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
    248199
    249   if (!gsdlhome.empty()) {
    250     mapinconvertclass gbinconvert;
    251     gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1);
    252     mapoutconvertclass gboutconvert;
    253     gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5);
    254     recpt.add_converter ("g", &gbinconvert, &gboutconvert);
    255   }
     200  mapinconvertclass gbinconvert;
     201  gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1);
     202  mapoutconvertclass gboutconvert;
     203  gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5);
     204  recpt.add_converter ("g", &gbinconvert, &gboutconvert);
     205
     206  text_t armapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
     207  armapfile = filename_cat (armapfile, "WINDOWS", "1256.TXT");
     208  simplemapinconvertclass arinconvert;
     209  arinconvert.setmapfile (armapfile);
     210  simplemapoutconvertclass aroutconvert;
     211  aroutconvert.setmapfile (armapfile);
     212  recpt.add_converter ("a", &arinconvert, &aroutconvert); 
     213
    256214
    257215  // the list of actions. Note: these actions will become invalid
     
    262220
    263221  pageaction apageaction;
     222  apageaction.set_receptionist (&recpt);
    264223  recpt.add_action (&apageaction);
    265224
     
    268227
    269228  queryaction aqueryaction;
     229  aqueryaction.set_receptionist (&recpt);
    270230  recpt.add_action (&aqueryaction);
    271231
    272232  documentaction adocumentaction;
     233  adocumentaction.set_receptionist (&recpt);
    273234  recpt.add_action (&adocumentaction);
    274235
     
    313274  return 0;
    314275}
    315 
    316 
    317 
    318 
    319 
Note: See TracChangeset for help on using the changeset viewer.