From: Sebastian Hammer Date: Sat, 18 Nov 2006 05:00:38 +0000 (+0000) Subject: Added record retrieval, etc. X-Git-Tag: before.append.child~130 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=284686d53e59c7991165de467a83bc6ad755247b;p=pazpar2-moved-to-github.git Added record retrieval, etc. --- diff --git a/.gdb_history b/.gdb_history index 4377013..7ca6424 100644 --- a/.gdb_history +++ b/.gdb_history @@ -1,102 +1,3 @@ -break main -run -c 2000 -quit -break main -run -c 2000 -next -ste -step -next -print hostbuf -next -un -run -nexrt -next -step -next -step -next -print p -print *p -next -cont -run -quit -break main -run -c 2000 -next -step -next -print hostbuf -next -list -bt -frame 1 -list -break event_loop -delete 1 -run -next -print *p -next -quit -break command_accept -run -c 2000 -next -print s -next -print channel_list -print *channel_list -print *channel_list->next -next -print max -next -next -quit -breack command_command -break command_command -run -c 2000 -run -next -print *s -print *s->channel -run -run -run -quit -run -c 2000 -break command_command -cont -next -break command_accept -cont -run -finish -cont -next -cont -next -print res -next -cont -con -cont -quit -run -c 2000 -break command_io -cont -cont -next -print buf -quit -run -c 2000 -break command_command -cont -next -print argv -cont -next list break 54 cont @@ -206,3 +107,150 @@ print *r print *r->presentStatus print *r->numberOfRecordsReturned quit +break process_record +run -c 2001 +next +step +bt +finish +quit +run -c 2000 +run -c 2001 +run -c 2002 +print put - out +print pout - out +print out +print p +run -c 2000 +run -c 2001 +quit +run -c 2001 +bt +frame 1 +print *channel_list +print *channel_list->data +print *((struct target*)channel_list->data) +print *((struct target*)channel_list->data)->session +print *((struct target*)channel_list->data)->session->rechear[0] +print *((struct target*)channel_list->data)->session->recheap[0] +print *((struct target*)channel_list->data)->session->recheap[1] +print *((struct target*)channel_list->data)->session->recheap[2] +print *((struct target*)channel_list->data)->session->recheap[3] +print *((struct target*)channel_list->data)->session->recheap[4] +print *((struct target*)channel_list->data)->session->recheap[5] +cont +list +bt +frame 3 +print *s +run -c 2000 +bt +frame 1 +print *channel_list +print *((struct target*)channel_list->data) +print *((struct target*)channel_list->data)->target +print *((struct target*)channel_list->data)->session +print *((struct target*)channel_list->data)->session->recheap[0] +quit +run -c 2000 +run -c 2002 +bt +frame 2 +list +print *num +print *recs[0] +print *recs[1] +print *recs[2] +print *recs[3] +print *recs[4] +bt +frame rewind_recheap +frame 1 +list +print *S +print *s +bt +frame 2 +break +run +run -c 2000 +bt +list breakpoints +delete +frame 2 +break 865 +list +run -c 2001 +print *s +step +next +step +next +print *s +next +step +print parent +step +print *s +print p +print *s->recheap[0] +run -c 2000 +print *s +print *s->recheap[99] +step +print *s +print *s->recheap[93] +run -c 2001 +delete +cont +quit +list show +function show +help +list +quit +quit +list show +list cmd_show +break 99 +run -c 2000 +print *r +next +print r +print *rt +print *r +cont +print *r +print r +print *r->next +print *r->next_cluster +print *r->next_cluster->next_cluster +quit +quit +run -c 2000 +run -c 2001 +bt +frame 1 +print *r +quit +run -c 2000 +quit +run -c 2001 +run -c 2000 +list handler +break 622 +run -c 2000 +run -c 2001 +cont +cont +next +print len +cont +next +print len +cont +run +run -c 2000 +delete +cont +quit diff --git a/200.pz b/200.pz new file mode 100644 index 0000000..3eb55fb --- /dev/null +++ b/200.pz @@ -0,0 +1,201 @@ +target 128.218.15.173:210/INNOPAC +target 130.212.18.200:210/Innopac +target 131.165.97.2:210/S +target 137.187.166.250:210/INNOPAC +target 144.37.1.4:210/Innopac +target 147.29.116.113:2100/KGB01 +target 161.210.213.100:210/INNOPAC +target 192.197.190.4:210/Advance +target 193.52.199.5:21210/ADVANCE +target 195.249.206.204:210/default +target 195.50.60.15:2103/PB +target 199.184.19.10:210/innopac +target 207.194.254.193:210/advance +target Exlibris.daimi.au.dk:2104/MAT01 +target aleph.mcgill.ca:210/MUSE +target bagel.indexdata.dk:210/gils +target bib.gladsaxe.dk:2100/S +target biblio.hec.ca:210/hec +target corpsrv.lib.vsu.ru:210/elib +target corpsrv.lib.vsu.ru:210/v_vgasa +target corpsrv.lib.vsu.ru:210/v_vgpu +target corpsrv.lib.vsu.ru:210/vsu_books +target eusa.library.net:5666/eusa +target info.library.mun.ca:2200/UNICORN +target jasper.acadiau.ca:2200/UNICORN +target lib.udsu.ru:210/main +target lib.yar.ru:210/iubnt +target lib.yar.ru:210/ksu +target lib.yar.ru:210/t2 +target lib.yar.ru:210/yarcsti +target lib.yar.ru:210/yarrbl +target lib.yar.ru:210/yarrsml +target lib.yar.ru:210/yarsma +target lib.yar.ru:210/yarstu +target lrpapp.cc.umanitoba.ca:2200/unicorn +target malad2.mala.bc.ca:2200/unicorn +target ncsulib.lib.ncsu.edu:210/MARION +target ns1.gbs.spb.ru:212/graphic +target ns1.gbs.spb.ru:212/nmagpl +target ns1.gbs.spb.ru:212/nrdf +target ns1.gbs.spb.ru:212/plain +target ns1.gbs.spb.ru:212/rdftest +target opac.sbn.it:3950/nopac +target proxy2.lib.tpu.ru:2100/prd +target publib.cbx.ru:210/serial +target rs6000.nshpl.library.ns.ca:210/AVR +target rs6000.nshpl.library.ns.ca:210/CBR +target rs6000.nshpl.library.ns.ca:210/CEH +target rs6000.nshpl.library.ns.ca:210/CUR +target rs6000.nshpl.library.ns.ca:210/NSP +target rs6000.nshpl.library.ns.ca:210/PAR +target rs6000.nshpl.library.ns.ca:210/SSR +target rs6000.nshpl.library.ns.ca:210/WCR +target ruslan.ksu.ru:210/er_in +target ruslan.ksu.ru:210/ilaw +target ruslan.ksu.ru:210/kgpu +target ruslan.ksu.ru:210/law_ksu +target ruslan.ksu.ru:210/rmbic +target www.benran.ru:210/serns +target www.cnshb.ru:210/9095 +target www.cnshb.ru:210/tbd1 +target www.grimes.lib.ia.us:210/main +target www.sbn.it:2100/nopac +target z39.gbs.spb.ru:210/graphic +target z39.gbs.spb.ru:210/nmagpl +target z39.gbs.spb.ru:210/nrdf +target z39.gbs.spb.ru:210/plain +target z39.gbs.spb.ru:210/rdftest +target z39.gbs.spb.ru:210/talk_mag +target z39.library.tver.ru:210/RZHEV.KRAY +target z39.library.tver.ru:210/TBS.MAIN +target z39.library.tver.ru:210/TOUNB.KRAY +target z39.library.tver.ru:210/TSTU.MAIN +target z39.library.tver.ru:210/TVERSU.PODP +target z39.library.tver.ru:210/VVOL.MAIN +target z3950.ahds.ac.uk:210/DC +target z3950.fcla.edu:210/FI +target z3950.fcla.edu:210/SR +target z3950.kb.dk:2100/BHS01 +target z3950.kb.dk:2100/DRA01 +target z3950.kb.dk:2100/KBB01 +target z3950.kb.dk:2100/KGL01 +target z3950.ovid.com:2213/pmed +target z3950.usu.ru:210/lest +target z3950.usu.ru:210/publ +target z3950.usu.ru:210/uapa +target z3950.usu.ru:210/urgu +target 12.4.242.230:210/Unicorn +target 129.65.20.27:210/Innopac +target 130.206.134.239:210/INNOPAC +target 131.165.177.76:2100/S +target 134.115.152.130:210/Innopac +target 137.45.212.100:210/INNOPAC +target 141.215.16.4:210/INNOPAC +target 147.175.67.227:2222/DEFAULT +target 147.29.116.113:2100/DAB01 +target 147.29.116.113:2100/PVS +target 147.29.116.113:2100/vej01 +target 149.175.20.20:210/INNOPAC +target 169.139.225.46:210/horizon +target 192.188.131.54:2200/UNICORN +target 192.65.218.23:210/DREWDB +target 193.162.157.130:2100/S +target 193.43.102.194:21210/ADVANCE +target 193.59.172.100:210/INNOPAC +target 194.182.134.04:210/S +target 194.239.156.133:2100/S +target 195.215.203.98:2100/S +target 195.41.8.218:2100/S +target 195.50.60.15:2102/MB +target 196.6.221.16:210/INNOPAC +target 198.62.73.72:210/INNOPAC +target Exlibris.daimi.au.dk:2104/FYS01 +target Exlibris.daimi.au.dk:2104/GEO01 +target Exlibris.daimi.au.dk:2104/KEM01 +target Exlibris.daimi.au.dk:2104/VID01 +target Z3950cat.bl.uk:9909/BLAC +target advance.biblio.polymtl.ca:210/ADVANCE +target alpha.svkol.cz:9909/SVK02 +target atrium.bib.umontreal.ca:210/ADVANCE +target bagel.indexdata.dk:210/marc +target bib.gladsaxe.dk:2101/H +target bib.gladsaxe.dk:2101/S +target biblioteca.uc3m.es:2200/unicorn +target bobcat.nyu.edu:210/ADVANCE +target books.luther.edu:210/innopac +target brocar.unavarra.es:9999/revistas +target catalog.bedfordlibrary.org:210/Innopac +target catalog.mpl.org.eg:2200/Unicorn +target clavis.ucalgary.ca:2200/UNICORN +target corpsrv.lib.vsu.ru:210/educ +target corpsrv.lib.vsu.ru:210/gender +target corpsrv.lib.vsu.ru:210/nlr +target corpsrv.lib.vsu.ru:210/test +target corpsrv.lib.vsu.ru:210/v_vgai +target corpsrv.lib.vsu.ru:210/v_vgau +target corpsrv.lib.vsu.ru:210/v_vglta +target corpsrv.lib.vsu.ru:210/v_vgma +target corpsrv.lib.vsu.ru:210/v_vgta +target corpsrv.lib.vsu.ru:210/v_vstu +target corpsrv.lib.vsu.ru:210/vsu_works +target csulib.ctstateu.edu:210/INNOPAC +target gb.glostrupbib.dk:2100/S +target hcb.bibnet.dk:2100/S +target hermes.lib.cbs.dk:2100/S +target ikast.ikast.bibnet.dk:2100/S +target kat.vkol.cz:9909/SVK02 +target kraka.birkerod.bibnet.dk:2100/S +target lib.ivanovo.ac.ru:210/books +target lib.soas.ac.uk:210/innopac +target lib.yar.ru:210/elib +target lib.yar.ru:210/irsl +target lib.yar.ru:210/ivsu +target lib.yar.ru:210/yarcls +target lib.yar.ru:210/yarmp +target lib.yar.ru:210/yarrsl +target lib.yar.ru:210/yarsaca +target lib.yar.ru:210/yarspu +target lib.yar.ru:210/yarsu +target library.brunel.ac.uk:2200/UNICORN +target library.chsu.ru:210/chsu +target library.hud.ac.uk:210/HORIZON +target library.ucc.ie:210/INNOPAC +target libsys.lib.hull.ac.uk:210/INNOPAC +target libuni01.ccc.govt.nz:2220/cinch +target libuni01.ccc.govt.nz:2220/papers +target malad2.mala.bc.ca:2200/UNICORN +target newlib.ci.lubbock.tx.us:2200/unicorn +target nobis.njl.dk:210/S +target ns1.gbs.spb.ru:212/magaz +target ns1.gbs.spb.ru:212/nplain +target ns1.gbs.spb.ru:212/ntalk +target ns1.gbs.spb.ru:212/rdf +target ns1.gbs.spb.ru:212/talk +target ns1.gbs.spb.ru:212/talk_mag +target ntb.misis.ru:5001/liber +target oda.fynbib.dk:2100/S +target odin2.bib.sdu.dk:210/Horizon +target odin2.bib.sdu.dk:210/otb +target opac.nebis.ch:9909/NEBIS +target opac.sbn.it:2100/nopac +target opac.shu.ac.uk:210/INNOPAC +target opac.unifi.it:210/OPAC +target opac.utmem.edu:210/INNOPAC +target proxy2.lib.tpu.ru:2100/book +target proxy2.lib.tpu.ru:2100/demo +target proxy2.lib.tpu.ru:2100/tpu +target rebiun.crue.org:210/absysREBIUN +target rs6000.nshpl.library.ns.ca:210/ECR +target ruslan.ksu.ru:210/eres +target ruslan.ksu.ru:210/esic +target ruslan.ksu.ru:210/kgmu +target ruslan.ksu.ru:210/kgsa +target ruslan.ksu.ru:210/knc_per +target ruslan.ksu.ru:210/law_e +target ruslan.ksu.ru:210/nb_rt +target ruslan.ksu.ru:210/nir +target ruslan.ksu.ru:210/rub_rt +target serapis.leedsmet.ac.uk:2200/unicorn +target serapis.lmu.ac.uk:2200/unicorn +target sflwww.er.usgs.gov:251/sflwwwmeta diff --git a/command.c b/command.c index 4ea72e1..ca51d55 100644 --- a/command.c +++ b/command.c @@ -1,4 +1,4 @@ -/* $Id: command.c,v 1.1 2006-11-14 20:44:37 quinn Exp $ */ +/* $Id: command.c,v 1.2 2006-11-18 05:00:38 quinn Exp $ */ #include #include @@ -82,6 +82,37 @@ static int cmd_hitsbytarget(struct command_session *s, char **argv, int argc) return 1; } +static int cmd_show(struct command_session *s, char **argv, int argc) +{ + struct record **recs; + int num = 10; + int i; + + if (argc == 2) + num = atoi(argv[1]); + + recs = show(s->psession, 0, &num); + + for (i = 0; i < num; i++) + { + int rc; + struct record *cnode; + struct record *r = recs[i]; + + command_puts(s, r->merge_key); + for (rc = 1, cnode = r->next_cluster; cnode; cnode = cnode->next_cluster, rc++) + ; + if (rc > 1) + { + char buf[256]; + sprintf(buf, " (%d records)", rc); + command_puts(s, buf); + } + command_puts(s, "\n"); + } + return 1; +} + static int cmd_stat(struct command_session *s, char **argv, int argc) { char buf[1024]; @@ -139,9 +170,10 @@ static struct { } cmd_array[] = { {"quit", cmd_quit}, {"load", cmd_load}, - {"search", cmd_search}, + {"find", cmd_search}, {"ht", cmd_hitsbytarget}, {"stat", cmd_stat}, + {"show", cmd_show}, {0,0} }; diff --git a/eventl.h b/eventl.h index b275852..967d5dc 100644 --- a/eventl.h +++ b/eventl.h @@ -4,8 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: eventl.h,v $ - * Revision 1.1 2006-11-14 20:44:38 quinn - * Initial revision + * Revision 1.2 2006-11-18 05:00:38 quinn + * Added record retrieval, etc. + * + * Revision 1.1.1.1 2006/11/14 20:44:38 quinn + * PazPar2 * * Revision 1.1.1.1 2000/02/23 14:40:18 heikki * Original import to cvs @@ -65,7 +68,7 @@ typedef struct iochan #define EVENT_EXCEPT 0x04 #define EVENT_TIMEOUT 0x08 #define EVENT_WORK 0x10 -int force_event; + int force_event; IOC_CALLBACK fun; void *data; int destroyed; @@ -93,4 +96,5 @@ int force_event; IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags); int event_loop(IOCHAN *iochans); + #endif diff --git a/many.pz b/many.pz new file mode 100644 index 0000000..aad47e1 --- /dev/null +++ b/many.pz @@ -0,0 +1,436 @@ +target 12.4.242.230:210/Unicorn +target 128.119.168.1:210/INNOPAC +target 128.119.168.2:210/INNOPAC +target 128.197.130.200:210/INNOPAC +target 128.218.15.173:210/INNOPAC +target 128.83.82.249:210/INNOPAC +target 129.234.4.6:210/INNOPAC +target 129.65.20.27:210/Innopac +target 129.78.72.7:210/INNOPAC +target 130.102.42.45:210/Innopac +target 130.111.64.52:210/INNOPAC +target 130.206.134.239:210/INNOPAC +target 130.212.18.200:210/Innopac +target 130.91.144.191:210/INNOPAC +target 131.165.177.76:2100/S +target 131.165.97.2:210/S +target 131.232.13.6:210/INNOPAC +target 134.115.152.130:210/Innopac +target 134.154.30.10:210/Innopac +target 137.187.166.250:210/INNOPAC +target 137.45.212.100:210/INNOPAC +target 141.215.16.4:210/INNOPAC +target 144.37.1.4:210/Innopac +target 147.143.2.5:210/INNOPAC +target 147.175.67.227:1111/DEFAULT +target 147.175.67.227:2222/DEFAULT +target 147.29.116.113:2100/DAB01 +target 147.29.116.113:2100/KGB01 +target 147.29.116.113:2100/PVS +target 147.29.116.113:2100/vej01 +target 149.130.90.2:210/INNOPAC +target 149.175.20.20:210/INNOPAC +target 161.210.213.100:210/INNOPAC +target 169.139.225.46:210/horizon +target 192.188.131.54:2200/UNICORN +target 192.197.190.4:210/Advance +target 192.65.218.23:210/DREWDB +target 193.162.157.130:2100/S +target 193.43.102.194:21210/ADVANCE +target 193.52.199.5:21210/ADVANCE +target 193.59.172.100:210/INNOPAC +target 194.182.134.04:210/S +target 194.239.156.133:2100/S +target 195.215.203.98:2100/S +target 195.249.206.204:210/Default +target 195.249.206.204:210/default +target 195.41.8.218:2100/S +target 195.50.60.15:2100/CB +target 195.50.60.15:2101/FB +target 195.50.60.15:2102/MB +target 195.50.60.15:2103/PB +target 196.6.221.16:210/INNOPAC +target 198.62.73.72:210/INNOPAC +target 199.184.19.10:210/innopac +target 199.88.71.7:210/INNOPAC +target 202.14.152.4:210/INNOPAC +target 202.40.151.2:210/INNOPAC +target 202.40.216.17:210/INNOPAC +target 206.48.3.167:7090/Voyager +target 207.194.254.193:210/advance +target Exlibris.albertslundbib.dk:2100/S +target Exlibris.daimi.au.dk:2104/FYS01 +target Exlibris.daimi.au.dk:2104/GEO01 +target Exlibris.daimi.au.dk:2104/KEM01 +target Exlibris.daimi.au.dk:2104/MAT01 +target Exlibris.daimi.au.dk:2104/VID01 +target Z3950.maribo.integrabib.dk:210/Default +target Z3950cat.bl.uk:9909/BLAC +target acorn.library.vanderbilt.edu:2200/ACORN +target advance.biblio.polymtl.ca:210/ADVANCE +target advance.lib.rmit.edu.au:21210/Advance +target albert.rit.edu:210/INNOPAC +target aleph.mcgill.ca:210/MUSE +target aleph.rsl.ru:9909/rsl01 +target aleph.unibas.ch:9909/DSV01 +target alpha.svkol.cz:9909/SVK01 +target alpha.svkol.cz:9909/SVK02 +target atrium.bib.umontreal.ca:210/ADVANCE +target bagel.indexdata.dk:210/gils +target bagel.indexdata.dk:210/marc +target bcr1.larioja.org:210/AbsysE +target bib.gladsaxe.dk:2100/S +target bib.gladsaxe.dk:2101/H +target bib.gladsaxe.dk:2101/S +target biblio.crusca.fi.it:9909/ADC01 +target biblio.hec.ca:210/hec +target biblios.dic.uchile.cl:210/BELLO +target biblioteca.uc3m.es:2200/unicorn +target bobcat.nyu.edu:210/ADVANCE +target books.luther.edu:210/innopac +target brocar.unavarra.es:9999/libros +target brocar.unavarra.es:9999/revistas +target camelot.spsl.nsc.ru:2100/cat +target cat.cisti.nrc.ca:210/INNOPAC +target cat.lib.grin.edu:210/innopac +target catalog.bedfordlibrary.org:210/Innopac +target catalog.crl.edu:210/INNOPAC +target catalog.lib.jhu.edu:210/horizon +target catalog.mpl.org.eg:2200/Unicorn +target cisne.sim.ucm.es:210/INNOPAC +target clavis.ucalgary.ca:2200/UNICORN +target cornelia.whoi.edu:7090/VOYAGER +target corpsgeo1.usace.army.mil:2210/geo1 +target corpsrv.lib.vsu.ru:210/books +target corpsrv.lib.vsu.ru:210/educ +target corpsrv.lib.vsu.ru:210/elib +target corpsrv.lib.vsu.ru:210/gender +target corpsrv.lib.vsu.ru:210/nlr +target corpsrv.lib.vsu.ru:210/test +target corpsrv.lib.vsu.ru:210/v_vgai +target corpsrv.lib.vsu.ru:210/v_vgasa +target corpsrv.lib.vsu.ru:210/v_vgau +target corpsrv.lib.vsu.ru:210/v_vglta +target corpsrv.lib.vsu.ru:210/v_vgma +target corpsrv.lib.vsu.ru:210/v_vgpu +target corpsrv.lib.vsu.ru:210/v_vgta +target corpsrv.lib.vsu.ru:210/v_vstu +target corpsrv.lib.vsu.ru:210/vsu_books +target corpsrv.lib.vsu.ru:210/vsu_works +target csulib.ctstateu.edu:210/INNOPAC +target echea.ru.ac.za:210/INNOPAC +target edcsns17.cr.usgs.gov:6675/AVHRR +target edcsns17.cr.usgs.gov:6675/DOQ +target edcsns17.cr.usgs.gov:6675/HAZARDS +target edcsns17.cr.usgs.gov:6675/LANDSAT_MSS +target edcsns17.cr.usgs.gov:6675/LANDSAT_TM +target edcsns17.cr.usgs.gov:6675/NAPP +target edcsns17.cr.usgs.gov:6675/NHAP +target eleanor.lib.gla.ac.uk:210/INNOPAC +target eusa.library.net:5666/eusa +target explore.up.ac.za:210/INNOPAC +target gaudi.ua.es:2200/unicorn +target gb.glostrupbib.dk:2100/S +target geolibr.uiggm.nsc.ru:210/geocat +target hcb.bibnet.dk:2100/S +target helios.nlib.ee:210/INNOPAC +target hermes.lib.cbs.dk:2100/S +target hkbulib.hkbu.edu.hk:210/INNOPAC +target ikast.ikast.bibnet.dk:2100/S +target indexgeo.com.au:6668/dataset +target indexgeo.net:5511/act +target info.library.mun.ca:2200/UNICORN +target innopac.lib.kth.se:210/innopac +target innopac.wits.ac.za:210/INNOPAC +target itec.mty.itesm.mx:210/innopac +target jasper.acadiau.ca:2200/UNICORN +target jenda.lib.nccu.edu.tw:210/INNOPAC +target kat.vkol.cz:9909/SVK01 +target kat.vkol.cz:9909/SVK02 +target kraka.birkerod.bibnet.dk:2100/S +target ksclib.keene.edu:210/INNOPAC +target l1.uwaterloo.ca:7090/VOYAGER +target lance.missouri.edu:210/INNOPAC +target lib.ivanovo.ac.ru:210/books +target lib.leeds.ac.uk:210/INNOPAC +target lib.soas.ac.uk:210/innopac +target lib.udsu.ru:210/articles +target lib.udsu.ru:210/main +target lib.yar.ru:210/elib +target lib.yar.ru:210/irsl +target lib.yar.ru:210/iubnt +target lib.yar.ru:210/ivsu +target lib.yar.ru:210/ksu +target lib.yar.ru:210/t2 +target lib.yar.ru:210/yarcls +target lib.yar.ru:210/yarcsti +target lib.yar.ru:210/yarmp +target lib.yar.ru:210/yarrbl +target lib.yar.ru:210/yarrsl +target lib.yar.ru:210/yarrsml +target lib.yar.ru:210/yarsaca +target lib.yar.ru:210/yarsma +target lib.yar.ru:210/yarspu +target lib.yar.ru:210/yarstu +target lib.yar.ru:210/yarsu +target libadfa.adfa.edu.au:7090/VOYAGER +target libcat.qut.edu.au:210/INNOPAC +target liber.acadlib.lv:211/codex.previous +target liber.acadlib.lv:211/liber1 +target liber.acadlib.lv:212/liber1 +target library.anu.edu.au:210/INNOPAC +target library.ballarat.edu.au:210/INNOPAC +target library.bangor.ac.uk:210/INNOPAC +target library.bilgi.edu.tr:210/INNOPAC +target library.brad.ac.uk:210/xxDefault +target library.brunel.ac.uk:2200/UNICORN +target library.chsu.ru:210/chsu +target library.daemen.edu:210/innopac +target library.deakin.edu.au:210/INNOPAC +target library.gu.edu.au:21210/ADVANCE +target library.hud.ac.uk:210/HORIZON +target library.hull.ac.uk:210/INNOPAC +target library.krasn.ru:210/ccbook +target library.latrobe.edu.au:210/INNOPAC +target library.lbc.edu:7090/voyager +target library.mdx.ac.uk:210/mdx +target library.newcastle.edu.au:210/INNOPAC +target library.ox.ac.uk:210/ADVANCE +target library.tcd.ie:210/advance +target library.ucc.ie:210/INNOPAC +target library.uh.edu:210/INNOPAC +target library.ustu.ru:2100/bookr +target library.vu.edu.au:210/INNOPAC +target library2.open.ac.uk:7090/voyager +target libsys.lib.hull.ac.uk:210/INNOPAC +target libuni01.ccc.govt.nz:2200/unicorn +target libuni01.ccc.govt.nz:2220/cinch +target libuni01.ccc.govt.nz:2220/papers +target libunix.ku.edu.tr:210/INNOPAC +target linc.nus.edu.sg:210/innopac +target lion.swem.wm.edu:2200/unicorn +target loke.dcbib.dk:2100/S +target lrpapp.cc.umanitoba.ca:2200/unicorn +target malad2.mala.bc.ca:2200/UNICORN +target malad2.mala.bc.ca:2200/unicorn +target marte.biblioteca.upm.es:2200/unicorn +target medupe.ub.bw:210/INNOPAC +target melvyl.cdlib.org:210/CDL90 +target mercury.concordia.ca:210/Innopac +target merihobu.utlib.ee:210/INNOPAC +target merlinweb.ville.montreal.qc.ca:2100/Z3950S +target nbinet.ncl.edu.tw:210/INNOPAC +target ncsulib.lib.ncsu.edu:210/MARION +target newlib.ci.lubbock.tx.us:2200/unicorn +target nobis.njl.dk:210/S +target nrhcat.library.nrhtx.com:210/INNOPAC +target ns1.gbs.spb.ru:212/cdrom +target ns1.gbs.spb.ru:212/graphic +target ns1.gbs.spb.ru:212/magaz +target ns1.gbs.spb.ru:212/nmagpl +target ns1.gbs.spb.ru:212/nplain +target ns1.gbs.spb.ru:212/nrdf +target ns1.gbs.spb.ru:212/ntalk +target ns1.gbs.spb.ru:212/plain +target ns1.gbs.spb.ru:212/rdf +target ns1.gbs.spb.ru:212/rdftest +target ns1.gbs.spb.ru:212/talk +target ns1.gbs.spb.ru:212/talk_mag +target ntb.misis.ru:5001/liber +target oda.fynbib.dk:2100/S +target odin2.bib.sdu.dk:210/Horizon +target odin2.bib.sdu.dk:210/otb +target opac.nebis.ch:9909/NEBIS +target opac.sbn.it:2100/nopac +target opac.sbn.it:3950/nopac +target opac.shu.ac.uk:210/INNOPAC +target opac.unifi.it:210/OPAC +target opac.utmem.edu:210/INNOPAC +target orac.lib.uts.edu.au:210/INNOPAC +target pollux.dslak.co.nz:210/MARNSL +target prodorbis.library.yale.edu:7090/voyager +target proxy2.lib.tpu.ru:2100/book +target proxy2.lib.tpu.ru:2100/demo +target proxy2.lib.tpu.ru:2100/prd +target proxy2.lib.tpu.ru:2100/tpu +target publib.cbx.ru:210/serial +target quest.unb.ca:2200/unicorn +target rebiun.crue.org:210/absysREBIUN +target roble.unizar.es:210/INNOPAC +target rs6000.nshpl.library.ns.ca:210/AVR +target rs6000.nshpl.library.ns.ca:210/CBR +target rs6000.nshpl.library.ns.ca:210/CEH +target rs6000.nshpl.library.ns.ca:210/CUR +target rs6000.nshpl.library.ns.ca:210/ECR +target rs6000.nshpl.library.ns.ca:210/NSP +target rs6000.nshpl.library.ns.ca:210/PAR +target rs6000.nshpl.library.ns.ca:210/SSR +target rs6000.nshpl.library.ns.ca:210/WCR +target ruslan.ksu.ru:210/er_corp +target ruslan.ksu.ru:210/er_in +target ruslan.ksu.ru:210/eres +target ruslan.ksu.ru:210/esic +target ruslan.ksu.ru:210/ilaw +target ruslan.ksu.ru:210/kfei +target ruslan.ksu.ru:210/kgmu +target ruslan.ksu.ru:210/kgpu +target ruslan.ksu.ru:210/kgsa +target ruslan.ksu.ru:210/knc_per +target ruslan.ksu.ru:210/knc_ran +target ruslan.ksu.ru:210/law_e +target ruslan.ksu.ru:210/law_ksu +target ruslan.ksu.ru:210/nb_rt +target ruslan.ksu.ru:210/nir +target ruslan.ksu.ru:210/rmbic +target ruslan.ksu.ru:210/rub_rt +target sabio.library.arizona.edu:210/innopac +target salty.slcpl.lib.ut.us:210/INNOPAC +target scotty.mhsl.uab.edu:7090/VOYAGER +target serapis.leedsmet.ac.uk:2200/unicorn +target serapis.lmu.ac.uk:2200/unicorn +target sflwww.er.usgs.gov:251/sflwwwmeta +target silkbib.bib.dk:2100/S +target sirsi.library.utoronto.ca:2200/UNICORN +target star.tsl.state.tx.us:2200/unicorn +target strife.library.uwa.edu.au:210/INNOPAC +target strife.library.uwa.edu.au:210/innopac +target sundog.usask.ca:210/INNOPAC +target tegument.nlm.nih.gov:7090/VOYAGER +target titus.folger.edu:7090/VOYAGER +target tora.htk.dk:2100/S +target troy.lib.sfu.ca:210/INNOPAC +target unicorn.lib.ic.ac.uk:2200/IC +target unicorn.qmced.ac.uk:2200/unicorn +target unicornio.umb.edu.co:2200/Unicorn +target ustlib.ust.hk:210/INNOPAC +target vax.lib.state.ca.us:210/marion +target vlsirsi.rdg.ac.uk:2200/UNICORN +target voyager.its.csiro.au:7090/VOYAGER +target voyager.tcs.tulane.edu:7090/VOYAGER +target voyager.wrlc.org:7090/VOYAGER +target www.agralin.nl:210/clcz3950 +target www.benran.ru:210/CATALOG_LNS +target www.benran.ru:210/SCIENCE_LNS +target www.benran.ru:210/serns +target www.bibliotek.taarnby.dk:210/S +target www.bsmu.anrb.ru:210/books +target www.bsmu.anrb.ru:210/er +target www.bsmu.anrb.ru:210/serial +target www.cnshb.ru:210/8589 +target www.cnshb.ru:210/9095 +target www.cnshb.ru:210/jour +target www.cnshb.ru:210/tbd1 +target www.congreso.es:2100/ABSYSBCD +target www.csc.noaa.gov:2210/CSC_Products +target www.eevl.ac.uk:2100/eevlacuk +target www.grimes.lib.ia.us:210/main +target www.knihovna.cz:8888/un_cat +target www.lib.susu.ac.ru:2101/susu_books +target www.lib.susu.ac.ru:2101/susu_period +target www.library.mephi.ru:210/book +target www.library.nps.gov:7090/VOYAGER +target www.sbn.it:2100/nopac +target www.scran.ac.uk:3950/default +target www.znb.rsu.ru:210/amark +target yulib001.mc.yu.edu:1111/DEFAULT +target z39.gbs.spb.ru:210/cdrom +target z39.gbs.spb.ru:210/graphic +target z39.gbs.spb.ru:210/magaz +target z39.gbs.spb.ru:210/nmagpl +target z39.gbs.spb.ru:210/nplain +target z39.gbs.spb.ru:210/nrdf +target z39.gbs.spb.ru:210/ntalk +target z39.gbs.spb.ru:210/plain +target z39.gbs.spb.ru:210/rdf +target z39.gbs.spb.ru:210/rdftest +target z39.gbs.spb.ru:210/talk +target z39.gbs.spb.ru:210/talk_mag +target z39.libis.lt:210/KNYGOS +target z39.library.tver.ru:210/RZHEV.KRAY +target z39.library.tver.ru:210/RZHEV.MAIN +target z39.library.tver.ru:210/RZHEV.PODP +target z39.library.tver.ru:210/TBS.MAIN +target z39.library.tver.ru:210/TORZH.KRAY +target z39.library.tver.ru:210/TORZH.MAIN +target z39.library.tver.ru:210/TORZH.PODP +target z39.library.tver.ru:210/TOUNB.KRAY +target z39.library.tver.ru:210/TOUNB.MAIN +target z39.library.tver.ru:210/TOUNB.PODP +target z39.library.tver.ru:210/TSTU.MAIN +target z39.library.tver.ru:210/TSTU.PODP +target z39.library.tver.ru:210/TVERSU.MAIN +target z39.library.tver.ru:210/TVERSU.PODP +target z39.library.tver.ru:210/VVOL.KRAY +target z39.library.tver.ru:210/VVOL.MAIN +target z39.library.tver.ru:210/VVOL.PODP +target z3950.ahds.ac.uk:210/CMF +target z3950.ahds.ac.uk:210/DC +target z3950.bcl.jcyl.es:210/AbsysBCL +target z3950.bcl.jcyl.es:210/AbsysCCFL +target z3950.bergen.folkebibl.no:210/data +target z3950.biblos.pk.edu.pl:4210/books +target z3950.bibsys.no:2100/BIBSYS +target z3950.bibsys.no:2100/PERI +target z3950.copac.ac.uk:210/copac +target z3950.copac.ac.uk:2100/COPAC +target z3950.deich.folkebibl.no:210/data +target z3950.dragsholm.integrabib.dk:210/default +target z3950.fcla.edu:210/CF +target z3950.fcla.edu:210/FA +target z3950.fcla.edu:210/FI +target z3950.fcla.edu:210/FO +target z3950.fcla.edu:210/QB +target z3950.fcla.edu:210/RF +target z3950.fcla.edu:210/SR +target z3950.fcla.edu:210/ST +target z3950.gbv.de:20010/GVK +target z3950.gbv.de:20011/GVK +target z3950.gbv.de:20011/GVK +target z3950.gbv.de:210/GVK +target z3950.gbv.de:210/GVK +target z3950.haderslev.integrabib.dk:210/default +target z3950.haslev.integrabib.dk:210/Default +target z3950.hoerning.integrabib.dk:210/default +target z3950.kb.dk:2100/BGF01 +target z3950.kb.dk:2100/BHS01 +target z3950.kb.dk:2100/DRA01 +target z3950.kb.dk:2100/KBB01 +target z3950.kb.dk:2100/KBH01 +target z3950.kb.dk:2100/KGL01 +target z3950.lib.tpu.ru:9999/BOOK +target z3950.libh.uoc.gr:210/default +target z3950.libr.uoc.gr:210/logios +target z3950.libr.uoc.gr:210/ptolemeos_ii +target z3950.library.wisc.edu:210/madison +target z3950.libris.kb.se:210/libr +target z3950.lillehammer.folkebibl.no:210/data +target z3950.loc.gov:7090/voyager +target z3950.nakskov.integrabib.dk:210/default +target z3950.nb.no:2100/Norbok +target z3950.nb.no:2100/Norper +target z3950.nb.no:2100/Sambok +target z3950.nls.uk:7290/voyager +target z3950.nsu.ru:210/alice +target z3950.nsu.ru:210/gash +target z3950.ovid.com:2213/eric +target z3950.ovid.com:2213/pmed +target z3950.rdn.ac.uk:210/xxdefault +target z3950.ringsted.integrabib.dk:210/Default +target z3950.rstlib.nsc.ru:210/liber +target z3950.ruslan.ru:210/NEWS +target z3950.skagen.integrabib.dk:210/default +target z3950.sydfalster.integrabib.dk:210/default +target z3950.trondheim.folkebibl.no:210/data +target z3950.usu.ru:210/gorn +target z3950.usu.ru:210/lest +target z3950.usu.ru:210/papers +target z3950.usu.ru:210/publ +target z3950.usu.ru:210/sonb +target z3950.usu.ru:210/uapa +target z3950.usu.ru:210/ugtu +target z3950.usu.ru:210/uran +target z3950.usu.ru:210/ureu +target z3950.usu.ru:210/urgu +target z3950.usu.ru:210/usaa +target z3950.vallensbaek.integrabib.dk:210/default +target z3950.vejen.integrabib.dk:210/default diff --git a/pazpar2.c b/pazpar2.c index b003664..bcedea6 100644 --- a/pazpar2.c +++ b/pazpar2.c @@ -1,8 +1,4 @@ -/* $Id: pazpar2.c,v 1.1 2006-11-14 20:44:38 quinn Exp $ */ - - -#define PAZPAR2_VERSION "0.1" -#define MAX_DATABASES 512 +/* $Id: pazpar2.c,v 1.2 2006-11-18 05:00:38 quinn Exp $ */ #include #include @@ -11,6 +7,8 @@ #include #include #include +#include +#include #include #include @@ -23,8 +21,9 @@ #include "eventl.h" #include "command.h" -char *myname; -static long int runId=-1; +#define PAZPAR2_VERSION "0.1" +#define MAX_DATABASES 512 +#define MAX_CHUNK 10 struct target { @@ -88,7 +87,7 @@ static struct parameters { PAZPAR2_VERSION, {0,0}, 100, - 10 + MAX_CHUNK }; @@ -191,6 +190,7 @@ static void send_present(IOCHAN i) struct target *t = iochan_getdata(i); Z_APDU *a = zget_APDU(t->odr_out, Z_APDU_presentRequest); int toget; + int start = t->records + 1; toget = global_parameters.chunk; if (toget > t->hits - t->records) @@ -198,6 +198,7 @@ static void send_present(IOCHAN i) yaz_log(YLOG_DEBUG, "Trying to present %d records\n", toget); + a->u.presentRequest->resultSetStartPoint = &start; a->u.presentRequest->numberOfRecordsRequested = &toget; a->u.presentRequest->resultSetId = "Default"; @@ -235,12 +236,6 @@ static void do_initResponse(IOCHAN i, Z_APDU *a) } } -#if 0 -static char *search_geterror(Z_SearchRequest *r) -{ -#endif - - static void do_searchResponse(IOCHAN i, Z_APDU *a) { struct target *t = iochan_getdata(i); @@ -269,7 +264,284 @@ static void do_searchResponse(IOCHAN i, Z_APDU *a) } } -// FIXME Catch present errors!!!!!!! +const char *find_field(const char *rec, const char *field) +{ + const char *line = rec; + + while (*line) + { + if (!strncmp(line, field, 3) && line[3] == ' ') + return line; + while (*(line++) != '\n') + ; + } + return 0; +} + +const char *find_subfield(const char *field, char subfield) +{ + const char *p = field; + + while (*p && *p != '\n') + { + while (*p != '\n' && *p != '\t') + p++; + if (*p == '\t' && *(++p) == subfield) { + if (*(++p) == ' ') + return ++p; + } + } + return 0; +} + +// Extract 245 $a $b 100 $a +char *extract_mergekey(struct session *s, const char *rec) +{ + const char *field, *subfield; + char *e, *ef; + char *out, *p, *pout; + + wrbuf_rewind(s->wrbuf); + + if (!(field = find_field(rec, "245"))) + return 0; + if (!(subfield = find_subfield(field, 'a'))) + return 0; + ef = index(subfield, '\n'); + if ((e = index(subfield, '\t')) && e < ef) + ef = e; + if (ef) + { + wrbuf_write(s->wrbuf, subfield, ef - subfield); + if ((subfield = find_subfield(field, 'b'))) + { + ef = index(subfield, '\n'); + if ((e = index(subfield, '\t')) && e < ef) + ef = e; + if (ef) + { + wrbuf_puts(s->wrbuf, " field "); + wrbuf_write(s->wrbuf, subfield, ef - subfield); + } + } + } + if ((field = find_field(rec, "100"))) + { + if ((subfield = find_subfield(field, 'a'))) + { + ef = index(subfield, '\n'); + if ((e = index(subfield, '\t')) && e < ef) + ef = e; + if (ef) + { + wrbuf_puts(s->wrbuf, " field "); + wrbuf_write(s->wrbuf, subfield, ef - subfield); + } + } + } + wrbuf_putc(s->wrbuf, '\0'); + p = wrbuf_buf(s->wrbuf); + out = pout = nmem_malloc(s->nmem, strlen(p) + 1); + + while (*p) + { + while (isalnum(*p)) + *(pout++) = tolower(*(p++)); + while (*p && !isalnum(*p)) + p++; + *(pout++) = ' '; + } + if (out != pout) + *(--pout) = '\0'; + + return out; +} + +static void push_record(struct session *s, struct record *r) +{ + int p; + assert(s->recheap_max + 1 < s->recheap_size); + + s->recheap[p = ++s->recheap_max] = r; + while (p > 0) + { + int parent = (p - 1) >> 1; + if (strcmp(s->recheap[p]->merge_key, s->recheap[parent]->merge_key) < 0) + { + struct record *tmp; + tmp = s->recheap[parent]; + s->recheap[parent] = s->recheap[p]; + s->recheap[p] = tmp; + p = parent; + } + else + break; + } +} + +static struct record *top_record(struct session *s) +{ + return s-> recheap_max >= 0 ? s->recheap[0] : 0; +} + +static struct record *pop_record(struct session *s) +{ + struct record *res = s->recheap[0]; + int p = 0; + int lastnonleaf = (s->recheap_max - 1) >> 1; + + if (s->recheap_max < 0) + return 0; + + s->recheap[p] = s->recheap[s->recheap_max--]; + + while (p <= lastnonleaf) + { + int right = (p + 1) << 1; + int left = right - 1; + int min = left; + + if (right < s->recheap_max && + strcmp(s->recheap[right]->merge_key, s->recheap[left]->merge_key) < 0) + min = right; + if (strcmp(s->recheap[min]->merge_key, s->recheap[p]->merge_key) < 0) + { + struct record *tmp = s->recheap[min]; + s->recheap[min] = s->recheap[p]; + s->recheap[p] = tmp; + p = min; + } + else + break; + } + return res; +} + +// Like pop_record but collapses identical (merge_key) records +// The heap will contain multiple independent matching records and possibly +// one cluster, created the last time the list was scanned +static struct record *pop_mrecord(struct session *s) +{ + struct record *this; + struct record *next; + + if (!(this = pop_record(s))) + return 0; + + // Collapse identical records + while ((next = top_record(s))) + { + struct record *p, *tmpnext; + if (strcmp(this->merge_key, next->merge_key)) + break; + // Absorb record (and clustersiblings) into a supercluster + for (p = next; p; p = tmpnext) { + tmpnext = p->next_cluster; + p->next_cluster = this->next_cluster; + this->next_cluster = p; + } + + pop_record(s); + } + return this; +} + +// Reads records in sort order. Store records in top of heapspace until rewind is called. +static struct record *read_recheap(struct session *s) +{ + struct record *r = pop_mrecord(s); + + if (r) + { + if (s->recheap_scratch < 0) + s->recheap_scratch = s->recheap_size; + s->recheap[--s->recheap_scratch] = r; + } + + return r; +} + +// Return records to heap after read +static void rewind_recheap(struct session *s) +{ + while (s->recheap_scratch >= 0) { + push_record(s, s->recheap[s->recheap_scratch++]); + if (s->recheap_scratch >= s->recheap_size) + s->recheap_scratch = -1; + } +} + +struct record *ingest_record(struct target *t, char *buf, int len) +{ + struct session *s = t->session; + struct record *res; + const char *recbuf; + + wrbuf_rewind(s->wrbuf); + yaz_marc_xml(s->yaz_marc, YAZ_MARC_LINE); + if (yaz_marc_decode_wrbuf(s->yaz_marc, buf, len, s->wrbuf) < 0) + { + yaz_log(YLOG_WARN, "Failed to decode MARC record"); + return 0; + } + wrbuf_putc(s->wrbuf, '\0'); + recbuf = wrbuf_buf(s->wrbuf); + + res = nmem_malloc(s->nmem, sizeof(struct record)); + + res->merge_key = extract_mergekey(s, recbuf); + if (!res->merge_key) + return 0; + res->buf = nmem_strdupn(s->nmem, recbuf, wrbuf_len(s->wrbuf)); + res->target = t; + res->next_cluster = 0; + res->target_offset = -1; + + yaz_log(YLOG_DEBUG, "Key: %s", res->merge_key); + + push_record(s, res); + + return res; +} + +void ingest_records(struct target *t, Z_Records *r) +{ + //struct session *s = t->session; + struct record *rec; + Z_NamePlusRecordList *rlist; + int i; + + if (r->which != Z_Records_DBOSD) + return; + rlist = r->u.databaseOrSurDiagnostics; + for (i = 0; i < rlist->num_records; i++) + { + Z_NamePlusRecord *npr = rlist->records[i]; + Z_External *e; + char *buf; + int len; + + if (npr->which != Z_NamePlusRecord_databaseRecord) + { + yaz_log(YLOG_WARN, "Unexpected record type, probably diagnostic"); + continue; + } + e = npr->u.databaseRecord; + if (e->which != Z_External_octet) + { + yaz_log(YLOG_WARN, "Unexpected external branch, probably BER"); + continue; + } + buf = (char*) e->u.octet_aligned->buf; + len = e->u.octet_aligned->len; + + rec = ingest_record(t, buf, len); + if (!rec) + continue; + yaz_log(YLOG_DEBUG, "Ingested a fooking record"); + } +} + static void do_presentResponse(IOCHAN i, Z_APDU *a) { struct target *t = iochan_getdata(i); @@ -293,6 +565,7 @@ static void do_presentResponse(IOCHAN i, Z_APDU *a) { yaz_log(YLOG_DEBUG, "Good Present response"); t->records += *r->numberOfRecordsReturned; + ingest_records(t, r->records); t->state = Idle; } else if (*r->presentStatus) @@ -379,6 +652,7 @@ static void handler(IOCHAN i, int event) t->state = Failed; return; } + yaz_log(YLOG_DEBUG, "Successfully decoded %d oct PDU", len); switch (a->which) { case Z_APDU_initResponse: @@ -503,6 +777,7 @@ int load_targets(struct session *s, const char *fn) void search(struct session *s, char *query) { IOCHAN c; + int live_channels = 0; yaz_log(YLOG_DEBUG, "Search"); @@ -530,8 +805,26 @@ void search(struct session *s, char *query) if (t->state == Idle) iochan_setflag(c, EVENT_OUTPUT); + + live_channels++; + } + } + if (live_channels) + { + int maxrecs = live_channels * global_parameters.toget; + if (!s->recheap_size) + { + s->recheap = xmalloc(maxrecs * sizeof(struct record *)); + s->recheap_size = maxrecs; + } + else if (s->recheap_size < maxrecs) + { + s->recheap = xrealloc(s->recheap, maxrecs * sizeof(struct record*)); + s->recheap_size = maxrecs; } } + s->recheap_max = -1; + s->recheap_scratch = -1; } struct session *new_session() @@ -545,6 +838,11 @@ struct session *new_session() session->pqf_parser = yaz_pqf_create(); session->query[0] = '\0'; session->nmem = nmem_create(); + session->yaz_marc = yaz_marc_create(); + yaz_marc_subfield_str(session->yaz_marc, "\t"); + session->wrbuf = wrbuf_alloc(); + session->recheap = 0; + session->recheap_size = 0; return session; } @@ -573,6 +871,25 @@ struct hitsbytarget *hitsbytarget(struct session *s, int *count) return res; } +struct record **show(struct session *s, int start, int *num) +{ + struct record **recs = nmem_malloc(s->nmem, *num * sizeof(struct record *)); + int i; + + // FIXME -- skip initial records + + for (i = 0; i < *num; i++) + { + recs[i] = read_recheap(s); + if (!recs[i]) + { + *num = i; + break; + } + } + rewind_recheap(s); + return recs; +} void statistics(struct session *s, struct statistics *stat) { @@ -611,7 +928,6 @@ int main(int argc, char **argv) if (signal(SIGPIPE, SIG_IGN) < 0) yaz_log(YLOG_WARN|YLOG_ERRNO, "signal"); - myname = argv[0]; yaz_log_init(YLOG_DEFAULT_LEVEL|YLOG_DEBUG, "pazpar2", 0); while ((ret = options("c:", argv, argc, &arg)) != -2) diff --git a/pazpar2.h b/pazpar2.h index 1e22b78..667dab0 100644 --- a/pazpar2.h +++ b/pazpar2.h @@ -3,21 +3,26 @@ #include -struct session { - struct target *targets; - YAZ_PQF_Parser pqf_parser; - int requestid; - char query[1024]; - NMEM nmem; -}; - struct record { struct target *target; int target_offset; char *buf; char *merge_key; struct record *next_cluster; - struct record *head_cluster; +}; + +struct session { + struct target *targets; + YAZ_PQF_Parser pqf_parser; + int requestid; + char query[1024]; + NMEM nmem; + WRBUF wrbuf; + struct record **recheap; + int recheap_size; + int recheap_max; + int recheap_scratch; + yaz_marc_t yaz_marc; }; struct statistics { @@ -45,6 +50,7 @@ struct session *new_session(); int load_targets(struct session *s, const char *fn); void statistics(struct session *s, struct statistics *stat); void search(struct session *s, char *query); +struct record **show(struct session *s, int start, int *num); #endif diff --git a/util.c b/util.c index a92d340..fc67cfa 100644 --- a/util.c +++ b/util.c @@ -1,13 +1,11 @@ -/* $Id: util.c,v 1.1 2006-11-14 20:44:38 quinn Exp $ */ +/* $Id: util.c,v 1.2 2006-11-18 05:00:38 quinn Exp $ */ -#include #include - -extern char *myname; +#include void die(char *string, char *add) { - fprintf(stderr, "%s: %s (%s)\n", myname, string, add ? add : ""); + yaz_log(YLOG_FATAL, "Fatal error: %s (%s)", string, add ? add : ""); abort(); }