Ignore:
Timestamp:
2001-06-01T14:51:29+12:00 (23 years ago)
Author:
sjboddie
Message:

Changes to get phind working under windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/phind/host/phindcgi.cpp

    r2062 r2487  
    3737 */
    3838
    39 
    40 #include <iostream.h>
    41 #include <fstream.h>
     39#if defined(GSDL_USE_IOS_H)
     40#  include <fstream.h>
     41#  include <iostream.h>
     42#else
     43#  include <fstream>
     44#  include <iostream>
     45#endif
     46
    4247#include <stdlib.h>
    4348#include <stdio.h>
    4449#include <assert.h>
    4550
    46 #include <vector.h>
    47 #include <algo.h>
     51#if defined(GSDL_USE_STL_H)
     52#  if defined(GSDL_USE_ALGO_H)
     53#    include <algo.h>
     54#  else
     55#    include <algorithm.h>
     56#  endif
     57#  include <vector.h>
     58#else
     59#  include <algorithm>
     60#  include <vector>
     61#endif
    4862
    4963// Include MGPP functionality.
     
    5569
    5670// Include GSDL's text_t object, which makes parsing cgi arguments easier.
    57 #include <text_t.h>
     71#include "text_t.h"
     72#include "fileutil.h"
    5873// Note that GSDL stores strings as text_t objects (vectors of 16-bit short int),
    5974// while MGPP stores strings as UCArray objects (vectors of 8-bit unsigned char).
     
    156171  }
    157172 
    158   char basepath[FILENAME_MAX] = "";
    159   strcat(basepath, gsdlhome);
    160   strcat(basepath, "/collect/");
    161   strcat(basepath, collection);
    162   strcat(basepath, "/index/phind");
    163   strcat(basepath, classifier);
     173  text_t basepathstr = filename_cat(gsdlhome, "collect", collection,
     174                    "index", text_t("phind") + classifier);
     175
     176  char *basepath = basepathstr.getcstr();
    164177
    165178  // If we don't know the phrase number, look itup
     
    183196  // Create a TextData object to read the phrase data (pdata)
    184197  TextData textdata;
    185   char filename[FILENAME_MAX] = "pdata";
    186   if (!textdata.LoadData (basepath, filename)) {
    187     FatalError (1, "Couldn't load text information for \"%s\"", filename);
    188   }
     198
     199  text_t fullpath = filename_cat(basepath, "pdata");
     200  char *fullpathc = fullpath.getcstr();
     201#if defined __WIN32__
     202  char *base = "";
     203#else
     204  char *base = "/";
     205#endif
     206
     207  if (!textdata.LoadData (base, fullpathc)) {
     208    FatalError (1, "Couldn't load text information for \"%s\"", fullpathc);
     209  }
     210
     211  delete fullpathc;
     212
    189213  get_phrase_all_data(textdata, phrase, word, tf, ef, lf, df, el,
    190214              linkdest, linktype, docNums, docfreq);
     
    404428
    405429  textdata.UnloadData ();
     430
     431  delete basepath;
     432
    406433  return 0;
    407434}
     
    494521             unsigned long first, unsigned long last) {
    495522 
     523  //  _chdir(basepath);
     524
    496525  // Create a TextData object to read the document data
    497526  TextData docdata;
    498   char filename[FILENAME_MAX] = "docs";
    499   if (!docdata.LoadData (basepath, filename)) {
    500     FatalError (1, "Couldn't load text information for \"%s\"", filename);
    501   }
     527
     528  text_t fullpath = filename_cat(basepath, "docs");
     529  char *fullpathc = fullpath.getcstr();
     530#if defined __WIN32__
     531  char *base = "";
     532#else
     533  char *base = "/";
     534#endif
     535
     536  if (!docdata.LoadData (base, fullpathc)) {
     537    FatalError (1, "Couldn't load text information for \"%s\"", fullpathc);
     538  }
     539
     540  delete fullpathc;
    502541
    503542  UCArray title, hash;
     
    795834      }
    796835      // store the gsdlhome string
    797       gsdlhome = new (char)[len-i];
     836      gsdlhome = new char[len-i];
    798837      strncpy(gsdlhome, &(buffer[i]), len-i);
    799838    }
     
    916955  // if no classifier number is supplied, default to 1.
    917956  if (classifier == NULL) {
    918     classifier = new (char)[2];
     957    classifier = new char[2];
    919958    strcpy(classifier, "1");
    920959  }
     
    9711010  // Open the index file for searching
    9721011  IndexData indexData;
    973   char indexfilename[FILENAME_MAX] = "pword";
    974   if (!indexData.LoadData (basepath, indexfilename)) {
    975     FatalError (1, "Couldn't load index information for \"%s\"", indexfilename);
    976   }
     1012
     1013  text_t fullpath = filename_cat(basepath, "pword");
     1014  char *fullpathc = fullpath.getcstr();
     1015#if defined __WIN32__
     1016  char *base = "";
     1017#else
     1018  char *base = "/";
     1019#endif
     1020
     1021  if (!indexData.LoadData (base, fullpathc)) {
     1022    FatalError (1, "Couldn't load index information for \"%s\"", fullpathc);
     1023  }
     1024
     1025  delete fullpathc;
    9771026
    9781027  // set up the query object
Note: See TracChangeset for help on using the changeset viewer.