Changeset 93 for trunk/gsdl/src/library


Ignore:
Timestamp:
1998-12-31T22:18:58+13:00 (26 years ago)
Author:
rjmcnab
Message:

Wrote an output and input converter for GBK. Added an option to collect.cfg
to specify which converter should be the default for a given collection.

Location:
trunk/gsdl/src/library
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/library/libinterface.cpp

    r92 r93  
    1111
    1212#include <assert.h>
     13
     14
     15
    1316
    1417///////////////////////
     
    147150libinterface::libinterface() {
    148151  browse = NULL;
     152  gbinconvert = NULL;
     153  gboutconvert = NULL;
    149154}
    150155
     
    158163  thecollectdir = filename_cat (thecollectdir, get_collection_name());
    159164  filename = filename_cat (thecollectdir, "etc");
    160   filename = filename_cat (filename, "config.cfg");
     165  filename = filename_cat (filename, "collect.cfg");
     166
    161167  if (!file_exists(filename)) thecollectdir = gsdlhome;
    162168
     
    207213    else if (key == "numbytes")     cfg_info.numbytes = (double)cfgline[0].getint();
    208214    else if (key == "numdocs")      cfg_info.numdocs = (double)cfgline[0].getint();
     215    else if (key == "defaultencoding")
     216      cfg_info.defaultencoding = cfgline[0];
    209217      }
    210218    }
     
    233241#endif
    234242  gdbm.opendatabase (filename);
     243
     244
     245  // set default values for the configuration file
     246  cfg_info.defaultencoding = "w";
    235247
    236248  // read in the configuration files etc/collect.cfg and index/build.cfg
     
    265277  srand(time(NULL));
    266278
     279  gbinconvert = new gbinconvertclass (gsdlhome);
     280
     281  utf8outconvert.set_rzws(1);
     282  gboutconvert = new gboutconvertclass (gsdlhome);
     283  if (gboutconvert != NULL) gboutconvert->set_rzws(1);
     284
    267285  return collection_init(collection);
    268286}
     
    295313  outconvertclass *outconvert = NULL;
    296314  if (arg_n == "8") {
    297     outconvert = new utf8outconvertclass();
    298     ((utf8outconvertclass *)outconvert)->set_rzws(1); // remove zer-width spaces
    299   }
    300   else outconvert = new outconvertclass; // default
     315    outconvert = &utf8outconvert;
     316  } else if (arg_n == "g" && gboutconvert != NULL) {
     317    outconvert = gboutconvert;
     318  }
     319  else outconvert = &asciioutconvert; // default
    301320
    302321  if (outconvert == NULL) return err;
     
    327346  argconfigstr =
    328347    "+a[p]"    // action: q=query, b=browse, t=targetdoc, p=page, a1=auxiliary
    329     "n[w]"     // encoding: w=western, 8=utf8, 7=utf7, g=GB2312, k=GBK
     348    "n[]"     // encoding: w=western, 8=utf8, 7=utf7, g=GB2312, k=GBK
    330349    "t[1]"     // query type: 0=boolean, 1=ranked
    331350    "i[c]"     // index: c=chapter, p=paragraph, t=title, b=book
     
    459478void libinterface::check_args (cgiargsclass &args)
    460479{
    461   text_t collection = get_collection_name();
    462   args.setarg("c", collection);
     480  args.setarg("c", get_collection_name());
     481  if (args["n"].empty()) args.setarg("n", cfg_info.defaultencoding);
    463482}
    464483
  • trunk/gsdl/src/library/libinterface.h

    r92 r93  
    77#include "display.h"
    88#include "gdbmclass.h"
     9#include "gsdlunicode.h"
    910
    1011#ifdef __GNUG__
     
    4243  double      numbytes;
    4344  double      numdocs;
     45  text_t      defaultencoding;
    4446};
    4547
     
    105107  outconvertclass logconvert;
    106108  displayclass disp;
     109
     110  inconvertclass asciiinconvert;
     111  utf8inconvertclass utf8inconvert;
     112  gbinconvertclass *gbinconvert;
     113  outconvertclass asciioutconvert;
     114  utf8outconvertclass utf8outconvert;
     115  gboutconvertclass *gboutconvert;
    107116
    108117
Note: See TracChangeset for help on using the changeset viewer.