Changeset 1738


Ignore:
Timestamp:
2000-12-04T17:08:12+13:00 (23 years ago)
Author:
jrm21
Message:

all calls to text_t.getcstr() now delete the returned ptr. Also, we
remove any " chars from the string as this may ruin the query. We don't
yet do any post-processing to filter for phrases...

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

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/z3950proto.cpp

    r1642 r1738  
    6969  //  FILE *errfile declared in z3950cfg.h, defined in zparse.y
    7070
    71   if ((errfile=fopen(errf.getcstr(),"a"))==NULL) {
     71  char *errf_str=errf.getcstr();
     72  if ((errfile=fopen(errf_str,"a"))==NULL) {
    7273    // what do we do if we can't open the error file?
    7374    // this means that errors will go to stderr, which may stuff up
     
    7576    errfile=stderr;
    7677  }
     78  delete errf_str;
    7779  yyout=errfile;
    7880
     
    8082  // which is the bison output of zparse.y
    8183 
    82   yyin=fopen(filename.getcstr(),"r");
     84  char *filename_str=filename.getcstr();
     85  yyin=fopen(filename_str,"r");
    8386  if (yyin==NULL) {
    84     cerr << "Could not open "<<filename.getcstr()<<" for reading.\n";
     87    cerr << "Could not open "<<filename_str<<" for reading.\n";
     88    delete filename_str;
    8589    return;
    8690  }
     91  delete filename_str;
    8792  zconfigparse();
    8893
     
    230235  if (here==end) {
    231236    err=protocolError;
     237    char *coll_str=collection.getcstr();
    232238    logout << "z39.50: couldn't find collection"
    233        << collection.getcstr()
     239       << coll_str
    234240       << endl;
     241    delete coll_str;
    235242    return;
    236243  }
     
    350357    OptionValue_tarray::iterator ov_end=request.filterOptions.end();
    351358    while (ov_here != ov_end) {
    352       //      cout << "OV pair: `" << ov_here->name.getcstr() << "'=`"
    353       //   << ov_here->value.getcstr() << "'\n";
     359      // cerr << "OV pair: `" << ov_here->name.getcstr() << "'=`"
     360      //      << ov_here->value.getcstr() << "'\n";
    354361      if (ov_here->name=="Term")
    355362    {
  • trunk/gsdl/src/recpt/z3950server.cpp

    r1617 r1738  
    8585
    8686  z_initialize();
    87 
    88   if (z_cmd_open(server_and_port.getcstr(),info->name.getcstr())==1)
     87  char* serv_str=server_and_port.getcstr();
     88  char* name_str=info->name.getcstr();
     89  int retval=z_cmd_open(serv_str,name_str);
     90  delete serv_str;
     91  delete name_str;
     92  if (retval==1)
    8993    // we got a connection error
    9094    return false;
     
    110114  // This will require us to actually come up with a query syntax and
    111115  // a parser. For now, we'll just do an "AND" query for all terms
     116  // But look at Common Command Language (CCL) query syntax (ISO 8777).
     117
     118  // need to remove " chars from the query. We should really tell the server
     119  // to do a phrase search on the terms that are between the "s, but we
     120  // can't (easily) tell if the server can do that or not,
     121  // so we'll currently just do a query and then post-process. (not yet
     122  // implemented........)
    112123
    113124  // we need to count number of terms separated by a space
     
    116127  bool inword=false;
    117128  int num_terms=0;
     129
    118130  for (int i=0;i<strlength;i++) {
     131    if (*(ptr+i)=='"') { // convert " to SPACE...
     132      *(ptr+i)=' ';
     133    }
    119134    if (*(ptr+i)!=' ') {
    120135      if (inword==false) {
     
    128143  }
    129144 
    130   // set the field(s) to search on - main ones (that I've found) include:
     145  // set the field(s) to search on - main ones include:
    131146  //  1016  => Any
    132147  //  1     => (Personal) Name
     
    150165    parsed_query+="@and ";
    151166  // append the actual query
    152   parsed_query+=query;
    153 
     167  parsed_query+=ptr;
     168
     169  delete ptr;
    154170}
    155171
     
    196212  parseQuery(query,fields,expanded_query);
    197213
     214  char* query_str=expanded_query.getcstr();
    198215  // following functions defined in yaz_zclient.c
    199   *nummatches=z_cmd_dosearch(expanded_query.getcstr()); // returns # found, -1 on err.
     216  *nummatches=z_cmd_dosearch(query_str); // returns # found, -1 on err.
     217  delete query_str;
    200218  if (*nummatches<=0) {
    201219    if (*nummatches==0) {
     
    263281    parseQuery(query,fields,expanded_query);
    264282
    265     int returned=z_cmd_dosearch(expanded_query.getcstr());
     283    char* query_str=expanded_query.getcstr();
     284    int returned=z_cmd_dosearch(query_str);
     285    delete query_str;
    266286    if (returned<=0) {
    267287      // 0 => none.
     
    308328  if (connect()==false) {
    309329    z_initstr.setcstr("<H2>Server offline</H2>Error - could not connect to server <B>");
    310     z_initstr += info->host.getcstr();
     330    z_initstr += info->host;
    311331    z_initstr += "</B> on port ";
    312332    z_initstr += info->port;
Note: See TracChangeset for help on using the changeset viewer.