Changeset 1355


Ignore:
Timestamp:
2000-08-04T12:32:20+12:00 (24 years ago)
Author:
jrm21
Message:

Fixed up parsing of z39.50 config file, so that errors go to file instead
of stderr, which screws up the cgi headers and page...
Errors goes to etc/recpt/z3950err.txt

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

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/Makefile.in

    r1351 r1355  
    159159    @YACC@ -b zparse -d zparse.y
    160160
     161zparse.tab.h: zparse.tab.c
     162
    161163parse.yy.c: parse.fl
    162164    flex -oparse.yy.c parse.fl
  • trunk/gsdl/src/recpt/librarymain.cpp

    r1347 r1355  
    187187  z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
    188188  if (file_exists(z3950cfg)) {
    189     zproto.read_config_file(z3950cfg);
     189    text_t z3950err = filename_cat (gsdlhome, "etc");
     190    z3950err = filename_cat (z3950err, "recpt");
     191    z3950err = filename_cat (z3950err, "z3950log.txt");
     192    zproto.read_config_file(z3950cfg,z3950err);
    190193    // only add this protocol if we have any servers configured.
    191194    if (zproto.getServerCount()>0)
  • trunk/gsdl/src/recpt/z3950cfg.h

    r1347 r1355  
    2424  struct z3950cfg *next;
    2525};
    26 struct z3950cfg *zserver_list;
    27 #else
    2826extern struct z3950cfg *zserver_list;
    2927#endif
  • trunk/gsdl/src/recpt/z3950proto.cpp

    r1352 r1355  
    5656}
    5757
    58 void z3950proto::read_config_file(const text_t &filename) {
     58void z3950proto::read_config_file(const text_t &filename, const text_t &errf) {
    5959  struct z3950cfg *here;
    6060  struct z3950cfg *oldhere;
    6161  z3950_server *zserver;
    6262  ShortColInfo_t *tempinfo;
     63  FILE *stderr_tmp, *err;
     64
     65  err=fopen(errf.getcstr(), "a");
     66  stderr_tmp=stderr;
     67  if (err==NULL) {
     68    // what do we do if we can't open the error file?
     69    // this means that errors will go to stderr, which may stuff up
     70    // any cgi headers and the page.
     71  } else {
     72    stderr=err;
     73  }
    6374
    6475  // zconfigparse() is defined in zparse.tab.c,
     
    6879  if (yyin==NULL) {
    6980    cerr << "Could not open "<<filename.getcstr()<<" for reading.\n";
     81    return();
    7082  }
    7183  zconfigparse();
     84  if (err!=NULL) {
     85    fclose(err);
     86    stderr=stderr_tmp;
     87  }
     88
    7289  // we now have the config files in the ptr zserver_list
    7390  if (zserver_list==NULL)
     
    135152}
    136153
    137 void z3950proto::configure (const text_t &key,
    138                 const text_tarray &cfgline) {
    139 
     154void z3950proto::configure (const text_t &/*key*/,
     155                const text_tarray &/*cfgline*/) {
    140156  // this is called for each line in the gsdlsite.cfg file
    141 
    142   if (0)
    143     cerr << "z3950proto::configure called:"
    144      << "key is " << key.getcstr()
    145      << "\n1st line is " << cfgline[0].getcstr() << endl;
    146  
    147157}
    148158
     
    169179                      comerror_t &/*err*/,
    170180                      ostream &/*logout*/) {
    171   // logout here DOESN'T go to initout.txt
    172   // logout << "zdebug: get_collection_list called:\n";
    173 
    174   /** *** for now, we are assuming that each SERVER is a GSDL collection,
    175       as opposed to each DATABASE on the servers.
    176   */
     181
    177182  z3950_server_array::iterator here = zservers.begin();
    178183  z3950_server_array::iterator end = zservers.end();
    179184  while (here != end) {
    180185    collist.push_back((*here)->getName());
    181     //const ShortColInfo_t *info=here->getInfo();
    182     //collist.push_back(info->name);
    183186    here++;
    184187  }
     
    465468    while (fields_here!=fields_end) {
    466469      it=info.collectionmeta.find(*fields_here);
    467       ////////// cerr << "filter: getting " << (*fields_here).getcstr();
    468470      if (it!=info.collectionmeta.end())
    469471        docs_here->metadata[*fields_here].values.push_back((*it).second);
     
    484486        /////// cerr << " (not found)";
    485487      }
    486       ////////cerr << "\n";
    487488      fields_here++;
    488489    } // end of inner while loop
     
    498499    response.docInfo[0].metadata[(*colmeta_here).first].
    499500      values.push_back((*colmeta_here).second);
    500     /////cerr << "\t" << (*colmeta_here).first.getcstr() << "\n";
    501501    colmeta_here++;
    502502      }
  • trunk/gsdl/src/recpt/z3950proto.h

    r1347 r1355  
    4646  void add_server(z3950_server& zserver);
    4747
    48   void read_config_file(const text_t &filename);
     48  void read_config_file(const text_t &filename, const text_t &errfile);
    4949
    5050  void configure (const text_t &key, const text_tarray &cfgline);
  • trunk/gsdl/src/recpt/zparse.tab.c

    r1347 r1355  
    7070
    7171/* defined in z3950proto.cpp */
    72 extern struct z3950cfg *zservers_cfg_file;
     72struct z3950cfg *zserver_list=NULL;
    7373
    7474int yylex(void);
     
    157157#if YYDEBUG != 0
    158158static const short yyrline[] = { 0,
    159     82,    85,    86,    88,    89,    91,   108,   111,   112,   117,
    160    118,   121,   122,   125,   126,   127,   132,   134,   135,   137,
    161    139,   142,   153,   175,   183,   191,   193,   194,   196,   197
     159    82,    85,    86,    88,    89,    91,   111,   115,   116,   121,
     160   122,   125,   126,   129,   130,   131,   136,   138,   139,   141,
     161   143,   146,   157,   179,   187,   195,   197,   198,   200,   201
    162162};
    163163#endif
     
    787787case 3:
    788788#line 86 "zparse.y"
    789 {fprintf(stderr,"No version - not GSDL config file?\n");exit(1);;
     789{fprintf(stderr,"No version - not GSDL config file?\n");return(1);;
    790790    break;}
    791791case 4:
     
    800800             else {
    801801               if((yyval.cfg=malloc(sizeof(struct z3950cfg)))==NULL)
    802              fprintf(stderr,"malloc failed\n");
     802             {
     803               fprintf(stderr,"malloc failed\n");
     804               return(1);
     805             }
    803806               yyval.cfg->shortname=yyvsp[-7].string;
    804807               yyval.cfg->hostname=yyvsp[-6].string;
     
    813816    break;}
    814817case 7:
    815 #line 108 "zparse.y"
    816 {yyval.cfg=NULL;printf("discarding zserver\n");;
     818#line 111 "zparse.y"
     819{yyval.cfg=NULL;
     820          fprintf(stderr,"discarding zserver (line %d)\n",lineno);;
    817821    break;}
    818822case 8:
    819 #line 111 "zparse.y"
     823#line 115 "zparse.y"
    820824{;;
    821825    break;}
    822826case 9:
    823 #line 112 "zparse.y"
     827#line 116 "zparse.y"
    824828{errormsg("Database name needs to be followed by a short "
    825829              "descriptive name (enclosed in \" marks)");
     
    828832    break;}
    829833case 10:
    830 #line 117 "zparse.y"
     834#line 121 "zparse.y"
    831835{yyval.number=atoi(yyvsp[0].string);;
    832836    break;}
    833837case 11:
    834 #line 118 "zparse.y"
     838#line 122 "zparse.y"
    835839{yyval.number=210;;
    836840    break;}
    837841case 12:
    838 #line 121 "zparse.y"
     842#line 125 "zparse.y"
    839843{yyval.string=yyvsp[0].string;;
    840844    break;}
    841845case 13:
    842 #line 122 "zparse.y"
     846#line 126 "zparse.y"
    843847{yyval.string=yyvsp[0].string;
    844848                  errormsg("Icon must be enclosed in quotes");
     
    846850    break;}
    847851case 14:
    848 #line 125 "zparse.y"
     852#line 129 "zparse.y"
    849853{yyval.string=NULL;;
    850854    break;}
    851855case 15:
    852 #line 126 "zparse.y"
     856#line 130 "zparse.y"
    853857{yyval.string=yyvsp[0].string;;
    854858    break;}
    855859case 16:
    856 #line 127 "zparse.y"
     860#line 131 "zparse.y"
    857861{yyval.string=yyvsp[0].string;
    858862          /* this is because of the ':' */
     
    862866    break;}
    863867case 17:
    864 #line 132 "zparse.y"
     868#line 136 "zparse.y"
    865869{yyval.string=NULL;;
    866870    break;}
    867871case 18:
    868 #line 134 "zparse.y"
     872#line 138 "zparse.y"
    869873{defLanguage=0;;
    870874    break;}
    871875case 19:
    872 #line 135 "zparse.y"
     876#line 139 "zparse.y"
    873877{yyval.about=NULL;;
    874878    break;}
    875879case 20:
    876 #line 137 "zparse.y"
     880#line 141 "zparse.y"
    877881{;;
    878882    break;}
    879883case 21:
    880 #line 139 "zparse.y"
     884#line 143 "zparse.y"
    881885{yyval.about=yyvsp[0].about;yyvsp[0].about->next=yyvsp[-1].about;;
    882886    break;}
    883887case 22:
    884 #line 143 "zparse.y"
     888#line 147 "zparse.y"
    885889{
    886890                   if((yyval.about=malloc(sizeof(struct z3950aboutlist)))
    887891                  ==NULL) {
    888892                 fprintf(stderr,"Malloc failed\n");
    889                  exit(1);
     893                 return(1);
    890894                   }
    891895                   yyval.about->lang=yyvsp[-1].string;
     
    895899    break;}
    896900case 23:
    897 #line 154 "zparse.y"
     901#line 158 "zparse.y"
    898902{
    899903                   if (defLanguage)
     
    906910                  ==NULL) {
    907911                 fprintf(stderr,"Malloc failed\n");
    908                  exit(1);
     912                 return(1);
    909913                   }
    910914                   yyval.about->lang=NULL; /* default lang... */
     
    914918    break;}
    915919case 24:
    916 #line 176 "zparse.y"
     920#line 180 "zparse.y"
    917921{
    918922                   yyval.string=malloc(strlen(yyvsp[-2].string)+strlen(yyvsp[0].string)+1);
     
    924928    break;}
    925929case 25:
    926 #line 183 "zparse.y"
     930#line 187 "zparse.y"
    927931{;;
    928932    break;}
    929933case 26:
    930 #line 191 "zparse.y"
     934#line 195 "zparse.y"
    931935{errormsg("missing language");;
    932936    break;}
    933937case 27:
    934 #line 193 "zparse.y"
     938#line 197 "zparse.y"
    935939{;;
    936940    break;}
    937941case 28:
    938 #line 194 "zparse.y"
     942#line 198 "zparse.y"
    939943{;;
    940944    break;}
    941945case 29:
    942 #line 196 "zparse.y"
     946#line 200 "zparse.y"
    943947{;;
    944948    break;}
    945949case 30:
    946 #line 197 "zparse.y"
     950#line 201 "zparse.y"
    947951{;;
    948952    break;}
     
    11701174  return 1;
    11711175}
    1172 #line 200 "zparse.y"
     1176#line 204 "zparse.y"
    11731177
    11741178/*int strncasecmp (const char *, const char *,size_t);*/
  • trunk/gsdl/src/recpt/zparse.y

    r1347 r1355  
    2424
    2525/* defined in z3950proto.cpp */
    26 extern struct z3950cfg *zservers_cfg_file;
     26struct z3950cfg *zserver_list=NULL;
    2727
    2828int yylex(void);
     
    8484
    8585version       : GSDLVERSION {;}
    86               | {fprintf(stderr,"No version - not GSDL config file?\n");exit(1);}
     86              | {fprintf(stderr,"No version - not GSDL config file?\n");return(1);}
    8787
    8888zserverlist   : zserverlist zserver {if ($2!=NULL) {$2->next=$1;$$=$2;}}
     
    9595             else {
    9696               if(($$=malloc(sizeof(struct z3950cfg)))==NULL)
    97              fprintf(stderr,"malloc failed\n");
     97             {
     98               fprintf(stderr,"malloc failed\n");
     99               return(1);
     100             }
    98101               $$->shortname=$1;
    99102               $$->hostname=$2;
     
    106109             }
    107110           }
    108               | error {$$=NULL;printf("discarding zserver\n");}
     111              | error {$$=NULL;
     112          fprintf(stderr,"discarding zserver (line %d)\n",lineno);}
    109113              ;
    110114
     
    145149                  ==NULL) {
    146150                 fprintf(stderr,"Malloc failed\n");
    147                  exit(1);
     151                 return(1);
    148152                   }
    149153                   $$->lang=$2;
     
    162166                  ==NULL) {
    163167                 fprintf(stderr,"Malloc failed\n");
    164                  exit(1);
     168                 return(1);
    165169                   }
    166170                   $$->lang=NULL; /* default lang... */
Note: See TracChangeset for help on using the changeset viewer.