- Timestamp:
- 2000-05-11T13:56:34+12:00 (24 years ago)
- Location:
- branches/z3950-branch/gsdl/src/recpt
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/z3950-branch/gsdl/src/recpt/Makefile.in
r1004 r1168 77 77 RECEPTHEADERS = 78 78 79 LIBRARYHEADERS = nullproto.h 79 LIBRARYHEADERS = nullproto.h z3950proto.h 80 80 81 81 HEADERS = $(COMMONHEADERS) $(RECPTHEADERS) $(LIBRARYHEADERS) … … 95 95 RECPTSOURCES = recptmain.cpp 96 96 97 LIBRARYSOURCES = nullproto.cpp librarymain.cpp97 LIBRARYSOURCES = nullproto.cpp z3950proto.cpp librarymain.cpp 98 98 99 99 SOURCES = $(COMMONSOURCES) $(RECPTSOURCES) $(LIBRARYSOURCES) … … 109 109 hlistbrowserclass.o datelistbrowserclass.o invbrowserclass.o \ 110 110 pagedbrowserclass.o htmlbrowserclass.o delhistoryaction.o \ 111 historydb.o 111 historydb.o parse.yy.o 112 112 113 113 RECPTOBJECTS = recptmain.o 114 114 115 LIBRARYOBJECTS = nullproto.o librarymain.o115 LIBRARYOBJECTS = nullproto.o z3950proto.o librarymain.o zparse.tab.o 116 116 117 117 OBJECTS = $(COMMONOBJECTS) $(RECPTOBJECTS) $(LIBRARYOBJECTS) … … 133 133 ../colservr/phrasequeryfilter.o 134 134 135 135 # bison and flex temp files 136 zparse.tab.c: zparse.y 137 bison -d zparse.y 138 parse.yy.c: parse.fl 139 flex -oparse.yy.c parse.fl 140 PARSE_TMPFILES= zparse.tab.o zparse.tab.c zparse.tab.h parse.yy.o parse.yy.c 136 141 EXEC = recpt library 137 142 … … 139 144 140 145 distclean: 141 rm -f $(OBJECTS) $(EXEC) Makefile146 rm -f $(OBJECTS) $(EXEC) $(PARSE_TMPFILES) Makefile 142 147 143 148 clean: 144 rm -f $(OBJECTS) $(EXEC) 149 rm -f $(OBJECTS) $(EXEC) $(PARSE_TMPFILES) 145 150 146 151 install: -
branches/z3950-branch/gsdl/src/recpt/cgiwrapper.cpp
r1097 r1168 28 28 /* 29 29 $Log$ 30 Revision 1.25.2.1 2000/05/11 01:56:27 johnmcp 31 32 added proper config file parsing for z39.50 servers, and minor changes 33 to pageaction (minor bug when display collections from >1 proto) and 34 cgiwrapper (announces which collections are z39.50 servers). 35 30 36 Revision 1.25 2000/04/14 04:45:19 sjboddie 31 37 Modified the English of the debug output slightly … … 483 489 recptprotolistclass::iterator rprotolist_here = protos->begin(); 484 490 recptprotolistclass::iterator rprotolist_end = protos->end(); 491 492 bool is_z3950 = false; 485 493 while (rprotolist_here != rprotolist_end) { 486 if ((*rprotolist_here).p != NULL) { 487 488 text_tarray collist; 489 comerror_t err; 490 (*rprotolist_here).p->get_collection_list (collist, err, cerr); 491 if (err == noError) { 492 text_tarray::iterator collist_here = collist.begin(); 493 text_tarray::iterator collist_end = collist.end(); 494 495 while (collist_here != collist_end) { 494 if ((*rprotolist_here).p == NULL) continue; 495 else if (is_z3950==false && 496 (*rprotolist_here).p->get_protocol_name() == "z3950proto") { 497 cout << "\nZ39.50 Servers: (always public)\n" 498 << "---------------\n"; 499 is_z3950=true; 500 } 501 502 text_tarray collist; 503 comerror_t err; 504 (*rprotolist_here).p->get_collection_list (collist, err, cerr); 505 if (err == noError) { 506 text_tarray::iterator collist_here = collist.begin(); 507 text_tarray::iterator collist_end = collist.end(); 508 509 while (collist_here != collist_end) { 510 511 cout << text_t2ascii << *collist_here; 512 513 int spaces = (22 - (*collist_here).size()); 514 if (spaces < 2) spaces = 2; 515 text_t outspaces; 516 for (int i = 0; i < spaces; i++) outspaces.push_back (' '); 517 cout << text_t2ascii << outspaces; 518 519 ColInfoResponse_t cinfo; 520 (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, cerr); 521 if (err == noError && is_z3950 == false) { 522 if (cinfo.isPublic) cout << "public "; 523 else cout << "private"; 496 524 497 cout << text_t2ascii << *collist_here; 498 499 int spaces = (22 - (*collist_here).size()); 500 if (spaces < 2) spaces = 2; 501 text_t outspaces; 502 for (int i = 0; i < spaces; i++) outspaces.push_back (' '); 503 cout << text_t2ascii << outspaces; 504 505 ColInfoResponse_t cinfo; 506 (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, cerr); 507 if (err == noError) { 508 if (cinfo.isPublic) cout << "public "; 509 else cout << "private"; 510 511 if (cinfo.buildDate > 0) cout << " running "; 512 else cout << " not running"; 513 } 514 515 cout << "\n"; 516 517 collist_here ++; 525 if (cinfo.buildDate > 0) cout << " running "; 526 else cout << " not running"; 518 527 } 528 529 cout << "\n"; 530 531 collist_here ++; 519 532 } 520 533 } 534 is_z3950=false; 521 535 rprotolist_here ++; 522 } 536 } // end of while loop 523 537 524 538 cout << "------------------------------------------------------------\n"; -
branches/z3950-branch/gsdl/src/recpt/librarymain.cpp
r1089 r1168 28 28 /* 29 29 $Log$ 30 Revision 1.25.2.1 2000/05/11 01:56:29 johnmcp 31 32 added proper config file parsing for z39.50 servers, and minor changes 33 to pageaction (minor bug when display collections from >1 proto) and 34 cgiwrapper (announces which collections are z39.50 servers). 35 30 36 Revision 1.25 2000/04/14 02:52:05 sjboddie 31 37 tidied up error messaging and set up some debugging info to be output … … 118 124 #include "cgiwrapper.h" 119 125 #include "nullproto.h" 126 // z39.50 stuff - johnmcp 127 #include "z3950proto.h" 120 128 #include "collectserver.h" 121 129 #include "filter.h" … … 153 161 receptionist recpt; 154 162 nullproto nproto; 163 z3950proto zproto; 155 164 text_tarray collections; 165 156 166 157 167 // get gsdlhome … … 207 217 colinfo.push_back (gsdlhome); 208 218 recpt.configure ("collectinfo", colinfo); 209 219 210 220 nproto.add_collectserver (cserver); 211 221 thiscol ++; … … 215 225 recpt.add_protocol (&nproto); 216 226 227 228 229 // z39.50 stuff - johnmcp 230 231 // add the z39.50 server information. Read in the file 232 // etc/recpt/z3950.cfg for list of servers and their databases. 233 text_t z3950cfg = filename_cat (gsdlhome, "etc"); 234 z3950cfg = filename_cat (z3950cfg, "recpt"); 235 z3950cfg = filename_cat (z3950cfg, "z3950.cfg"); 236 if (file_exists(z3950cfg)) { 237 zproto.read_config_file(z3950cfg); 238 // only add this protocol if we have any servers configured. 239 if (zproto.getServerCount()>0) 240 recpt.add_protocol (&zproto); 241 } 242 243 217 244 // add other converters 218 245 utf8inconvertclass utf8inconvert; -
branches/z3950-branch/gsdl/src/recpt/pageaction.cpp
r1033 r1168 28 28 /* 29 29 $Log$ 30 Revision 1.29.6.1 2000/05/11 01:56:30 johnmcp 31 32 added proper config file parsing for z39.50 servers, and minor changes 33 to pageaction (minor bug when display collections from >1 proto) and 34 cgiwrapper (announces which collections are z39.50 servers). 35 30 36 Revision 1.29 2000/03/19 21:16:46 nzdl 31 37 added german language interface … … 266 272 collist_here ++; 267 273 } 268 homeextra += "</tr></table></center>\n";269 disp.setmacro ("homeextra", "home", homeextra); 270 271 }274 // disp.setmacro ("homeextra", "home", homeextra); 275 } 276 } 277 homeextra += "</td></tr>\n<tr>\n"; 272 278 rprotolist_here ++; 273 279 } 280 homeextra += "</tr></table></center>\n"; 281 disp.setmacro ("homeextra", "home", homeextra); 274 282 } 275 283 -
branches/z3950-branch/gsdl/src/recpt/z3950proto.cpp
r1164 r1168 6 6 #include "comtypes.h" 7 7 #include <stdio.h> 8 9 // config file parsing stuff 10 #include "z3950cfg.h" // for reading in config files - 11 // defines "struct z3950cfg *zserver_list" as the head of the list. 12 extern FILE *yyin; 13 // for some reason, adding the following line screws up the linking... 14 //extern int zconfigparse(); 8 15 9 16 /*** … … 17 24 info=NULL; 18 25 meta["iconcollection"]="/~johnmcp/gsdl/images/zserver.png"; 26 // meta["collectionextra"]="Extra collection information"; 27 // meta["collectionname"]="overwritten"; 28 } 29 void z3950_server::setMeta(const text_t &key, const text_t &value) { 30 meta[key]=value; 31 } 32 void z3950_server::setName(const text_t &newname) { 33 title=newname; 34 meta["collectionname"]=newname; 35 // cout << "Have set server name\n"; 19 36 } 20 37 … … 34 51 } 35 52 36 void z3950proto::configure (const text_t &/*key*/, 37 const text_tarray &/*cfgline*/) { 53 void z3950proto::read_config_file(const text_t &filename) { 54 struct z3950cfg *here; 55 z3950_server *zserver; 56 ShortColInfo_t *tempinfo; 57 58 cerr << "attempting to read config file: " << filename.getcstr() << "\n"; 59 // zconfigparse() is defined in zparse.tab.c, 60 // which is the bison output of zparse.y 61 62 yyin=fopen(filename.getcstr(),"r"); 63 if (yyin==NULL) { 64 cerr << "Could not open "<<filename.getcstr()<<" for reading.\n"; 65 } 66 zconfigparse(); 67 // we now have the config files in the ptr zserver_list 68 if (zserver_list==NULL) 69 return; // no valid servers found in the config file - note that 70 // the parser will have already spat out any errors. 71 72 // now create z3950servers for each structure in server_list 73 here=zserver_list; 74 while (here!=NULL) { 75 zserver=new z3950_server; 76 tempinfo=new ShortColInfo_t; 77 78 tempinfo->host.setcstr(here->hostname); 79 tempinfo->port=here->port; 80 tempinfo->name.setcstr(here->dbname); 81 zserver->setInfo(tempinfo); 82 zserver->setName(here->shortname); 83 // now collection metadata. 84 zserver->setMeta("collectionname",here->longname); 85 if (here->icon!=NULL) 86 zserver->setMeta("iconcollection",here->icon); 87 if (here->smallicon!=NULL) 88 zserver->setMeta("iconcollectionsmall",here->smallicon); 89 if (0) { 90 cerr << "creating metadata:\n\tcolname is " << here->longname 91 << "\n\ticoncollection is " << here->icon 92 << "\n and\ticoncollectionsmall is " << here->smallicon 93 << "\n"; 94 } 95 96 // and about list .... later. 97 98 add_server(*zserver); 99 here=here->next; 100 } 101 102 // finally, delete all unneeded allocated memory in server_list 103 104 } 105 106 void z3950proto::configure (const text_t &key, 107 const text_tarray &cfgline) { 38 108 39 109 // this is called for each line in the gsdlsite.cfg file 40 /* cerr << "z3950proto::configure called:" 41 << "key is " << key.getcstr() 42 << "\n1st line is " << cfgline[0].getcstr() << endl; 43 */ 110 111 if (0) 112 cerr << "z3950proto::configure called:" 113 << "key is " << key.getcstr() 114 << "\n1st line is " << cfgline[0].getcstr() << endl; 115 44 116 } 45 117 … … 155 227 */ 156 228 157 collectinfo.receptionist="z3950"; /* for now... this is a url, 158 relative to .../cgi-bin */ 229 ////collectinfo.receptionist="z3950"; 230 /* for now... this is a url, relative to .../cgi-bin. 231 NOTE: if this is empty, it defaults to _gwcgi_?a=p&p=about&c=<colname> 232 */ 159 233 } 160 234 … … 169 243 FilterResponse_t &response, 170 244 comerror_t &err, ostream &logout) { 171 // assume this function is only called when creating the title page, 172 // and looking for the metadata regarding icons. 245 246 // this function is called when: 247 // * creating the title page,(looking for iconcoll* & collectname metadata) 248 // * creating the about page (looking for "Title" metadata) 249 // For the title page, we should not create a connection to the target 250 // (target means the actual z39.50 server, origin means us), but 251 // for the about page and query pages, we need to get information from the 252 // origin. (eg for the about page, we will print out some info such as ID, 253 // name and version. 254 255 // cerr now goes to errout.txt in etc directory 256 173 257 response.numDocs=0; 174 258 response.isApprox=Approximate; // Exact | Approximate | MoreThan … … 181 265 request.docSet (includes OID); 182 266 */ 183 // fill in the metadata for each of the OIDs (if it is requested) 267 268 // response.termInfo.push_back(""); ??????? (should be empty if not req.) 269 270 184 271 if (request.filterResultOptions & FRmetadata) { 185 // request.fields // type text_tset 186 // docInfo is type ResultDocInfo_tarray 272 187 273 ColInfoResponse_t *info = new ColInfoResponse_t; 188 274 get_collectinfo (collection, *info, err, logout); 189 275 // should check err returned here.... 190 276 277 ////////// cerr << "Filter.\n"; 278 191 279 ResultDocInfo_t *docInfo=new ResultDocInfo_t; 192 193 text_tmap::iterator it=info->collectionmeta.find("collectionname"); 194 // cerr now goes to errout.txt in etc directory 195 // "(*it).first" is key, "(*it).second" is value(s). 196 if (it!=info->collectionmeta.end()) 197 docInfo->metadata["collectionname"].values.push_back((*it).second); 198 else // needs to exist, but be empty 199 docInfo->metadata["collectionname"].values.push_back(""); 200 201 it=info->collectionmeta.find("iconcollection"); 202 if (it!=info->collectionmeta.end()) 203 docInfo->metadata["iconcollection"].values.push_back((*it).second); 204 else // needs to exist, but be empty 205 docInfo->metadata["iconcollection"].values.push_back(""); 206 207 it=info->collectionmeta.find("iconcollectionsmall"); 208 if (it!=info->collectionmeta.end()) 209 docInfo->metadata["iconcollectionsmall"].values.push_back((*it).second); 210 else // needs to exist, but be empty 211 docInfo->metadata["iconcollectionsmall"].values.push_back(""); 212 280 281 /* In the absence of any other information, (eg commented code), 282 assuming that if the request.fields is empty, then we should return 283 all metadata, otherwise return only the requested fields */ 284 285 if (!request.fields.empty()) { 286 // loop on all the metadata fields in request.fields (type text_tset) 287 text_tset::iterator fields_here=request.fields.begin(); 288 text_tset::iterator fields_end=request.fields.end(); 289 text_tmap::iterator it; 290 while (fields_here!=fields_end) { 291 it=info->collectionmeta.find(*fields_here); 292 ////////// cerr << "filter: getting " << (*fields_here).getcstr(); 293 if (it!=info->collectionmeta.end()) 294 docInfo->metadata[*fields_here].values.push_back((*it).second); 295 else { 296 docInfo->metadata[*fields_here].values.push_back(""); 297 /////// cerr << " (not found)"; 298 } 299 ////////cerr << "\n"; 300 fields_here++; 301 } // end of while loop 302 } // end of if (!request.fields.empty()) 303 else { 304 // return all metadata for about page or query 305 text_tmap::iterator colmeta_here=info->collectionmeta.begin(); 306 text_tmap::iterator colmeta_end=info->collectionmeta.end(); 307 while (colmeta_here!=colmeta_end) { 308 docInfo->metadata[(*colmeta_here).first]. 309 values.push_back((*colmeta_here).second); 310 /////cerr << "\t" << (*colmeta_here).first.getcstr() << "\n"; 311 colmeta_here++; 312 } 313 // get data from target. 314 z3950_server_array::iterator zserver = zservers.begin(); 315 z3950_server_array::iterator zend = zservers.end(); 316 while (zserver != zend) { 317 if(zserver->getName()==collection) { 318 break; 319 } 320 zserver++; 321 } 322 // now have collection in zserver. 323 // check if "collectionextra" metadata is set. If it isn't, we should 324 // create connection to target to get it. 325 if (info->collectionmeta.find("collectionextra")==colmeta_end) { 326 // it doesn't exist. 327 zserver->setMeta("collectionextra","This is some extra info."); 328 docInfo->metadata["collectionextra"].values.push_back("This is extra"); 329 } 330 331 } // end of else 213 332 214 333 response.docInfo.push_back(*docInfo); 215 } 216 334 } //end of if (... & FRmetadata) ... 217 335 err=noError; 218 336 } -
branches/z3950-branch/gsdl/src/recpt/z3950proto.h
r1164 r1168 5 5 #include "recptproto.h" 6 6 7 // each server can have one or more databases 8 /* 9 class z3950_DB { 10 protected: 11 text_t name; // Descriptive name 12 text_t database; // name for server 13 14 public: 15 z3950_DB(); // constructor 16 ~z3950_DB(); // deconstructor 17 const text_t getName() {return name;} // this gets name 18 void setName(text_t newName) {name=newName;} // this sets name 19 // need to get next (for linked list) 20 }; 21 22 23 typedef vector<z3950_DB> z3950_DB_array; 24 */ 25 26 /*class z3950_DB_Array { 27 protected: 28 int count; 29 // some arraytype... 30 public: 31 z3950_DB first(); 32 z3950_DB last(); 33 void add(z3950_DB *db); 34 void remove(z3950_DB *db); 35 }; 36 */ 37 38 7 // each "server" (ie collection) consists of a {z39.50 server + database} pair. 39 8 class z3950_server { 40 9 protected: … … 49 18 public: 50 19 z3950_server(); 51 // z3950_DB_array getDBs();52 20 const text_t getName() {return title;} 53 void set Name(const text_t &newname) {title=newname;}54 // void setHostname(const text_t &newname) {hostname=newname;}21 void setMeta(const text_t &key, const text_t &value); 22 void setName(const text_t &newname); 55 23 void setInfo(ShortColInfo_t *newinfo) {info=newinfo;} 56 24 const ShortColInfo_t *getInfo() {return info;} … … 71 39 virtual ~z3950proto() {} 72 40 41 int getServerCount() { return zserver_count;} 73 42 /* 74 43 void add_collectserver (collectserver *thecserver) 75 44 {cservers.addcollectserver(thecserver);} 76 45 */ 46 47 void add_server(const z3950_server& zserver); 77 48 78 void add_server(const z3950_server& zserver);49 void read_config_file(const text_t &filename); 79 50 80 51 void configure (const text_t &key, const text_tarray &cfgline);
Note:
See TracChangeset
for help on using the changeset viewer.