Changeset 9210


Ignore:
Timestamp:
2005-02-28T14:52:29+13:00 (19 years ago)
Author:
kjdon
Message:

made some mods to get querying workign on windows. couldn't open a pipe to lucene_query, so output to a file, then read in thefile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/lucenesearch.cpp

    r9115 r9210  
    3434
    3535#include <stdio.h>
     36#include <time.h>
    3637
    3738#include "gsdlconf.h"
     
    118119
    119120  text_t cmd = "lucene_query.pl ";
    120   cmd += indexname + (text_t)" \"" + to_utf8(queryparams.querystring) + (text_t)"\"";
    121 
    122 #ifdef __WIN32__
    123   FILE *PIN = _popen(cmd.getcstr(), "r");
     121  cmd += indexname + (text_t)" \"" + to_utf8(queryparams.querystring) + (text_t)"\"";
     122 
     123  text_t xml_text = "";
     124
     125#ifdef __WIN32__
     126  //FILE *PIN = _popen(cmd.getcstr(), "r"); // didn't seem to work
     127
     128  cmd = (text_t)"bin\\windows\\perl\\bin\\perl.exe -S "+cmd;
     129  clock_t this_time = clock();
     130  text_t filename = "luc";
     131  filename.append(this_time);
     132  filename.append(".txt");
     133  //cerr << "filename = "<<filename<<endl;
     134  text_t out_file = filename_cat(collectdir, filename);
     135  cmd += (text_t)" > "+ out_file;
     136  //cerr << "cmd ="<<cmd<<endl;
     137  system(cmd.getcstr());
     138 
     139  read_file(out_file, xml_text);
     140  remove(out_file.getcstr()); // now delete it
     141 
     142
    124143#else
    125144  FILE *PIN = popen(cmd.getcstr(), "r");
    126 #endif
     145
    127146  if (PIN==NULL) {
     147    perror("PIPE");
    128148    cerr << "Error: unable to open pipe to " << cmd << endl;
     149   
    129150    return false;
    130151  }
    131152
    132   text_t xml_text = "";
    133153
    134154  while (!feof(PIN)) {
     
    138158  }
    139159
     160#endif
    140161  expat_resultset(xml_text,queryresult);
    141162
    142163#ifdef __WIN32__
    143   _pclose(PIN);
     164  //  _pclose(PIN);
    144165#else
    145166  pclose(PIN);
Note: See TracChangeset for help on using the changeset viewer.