1 /* $Id: pazpar2.c,v 1.7 2006-11-27 19:44:26 quinn Exp $ */;
8 #include <sys/socket.h>
13 #include <yaz/comstack.h>
14 #include <yaz/tcpip.h>
15 #include <yaz/proto.h>
16 #include <yaz/readconf.h>
17 #include <yaz/pquery.h>
18 #include <yaz/yaz-util.h>
20 #include <yaz/yaz-ccl.h>
26 #include "termlists.h"
28 #include "relevance.h"
30 #define PAZPAR2_VERSION "0.1"
31 #define MAX_DATABASES 512
34 static void target_destroy(IOCHAN i);
38 struct session *session;
43 char databases[MAX_DATABASES][128];
51 int requestid; // ID of current outstanding request
69 static char *state_strings[] = {
82 IOCHAN channel_list = 0;
84 static struct parameters {
85 int timeout; /* operations timeout, in seconds */
86 char implementationId[128];
87 char implementationName[128];
88 char implementationVersion[128];
89 struct timeval base_time;
92 CCL_bibset ccl_filter;
97 "Index Data PazPar2 (MasterKey)",
106 static int send_apdu(struct target *t, Z_APDU *a)
111 if (!z_APDU(t->odr_out, &a, 0, 0))
113 odr_perror(t->odr_out, "Encoding APDU");
116 buf = odr_getbuf(t->odr_out, &len, 0);
117 r = cs_put(t->link, buf, len);
120 yaz_log(YLOG_WARN, "cs_put: %s", cs_errmsg(cs_errno(t->link)));
125 fprintf(stderr, "cs_put incomplete (ParaZ does not handle that)\n");
127 odr_reset(t->odr_out); /* release the APDU structure */
132 static void send_init(IOCHAN i)
134 struct target *t = iochan_getdata(i);
135 Z_APDU *a = zget_APDU(t->odr_out, Z_APDU_initRequest);
137 a->u.initRequest->implementationId = global_parameters.implementationId;
138 a->u.initRequest->implementationName = global_parameters.implementationName;
139 a->u.initRequest->implementationVersion =
140 global_parameters.implementationVersion;
141 ODR_MASK_SET(a->u.initRequest->options, Z_Options_search);
142 ODR_MASK_SET(a->u.initRequest->options, Z_Options_present);
143 ODR_MASK_SET(a->u.initRequest->options, Z_Options_namedResultSets);
145 ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_1);
146 ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_2);
147 ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_3);
148 if (send_apdu(t, a) >= 0)
150 iochan_setflags(i, EVENT_INPUT);
151 t->state = Initializing;
157 static void send_search(IOCHAN i)
159 struct target *t = iochan_getdata(i);
160 struct session *s = t->session;
161 Z_APDU *a = zget_APDU(t->odr_out, Z_APDU_searchRequest);
162 int ndb, cerror, cpos;
165 struct ccl_rpn_node *cn;
167 yaz_log(YLOG_DEBUG, "Sending search");
169 cn = ccl_find_str(global_parameters.ccl_filter, s->query, &cerror, &cpos);
172 a->u.searchRequest->query = zquery = odr_malloc(t->odr_out, sizeof(Z_Query));
173 zquery->which = Z_Query_type_1;
174 zquery->u.type_1 = ccl_rpn_query(t->odr_out, cn);
177 for (ndb = 0; *t->databases[ndb]; ndb++)
179 databaselist = odr_malloc(t->odr_out, sizeof(char*) * ndb);
180 for (ndb = 0; *t->databases[ndb]; ndb++)
181 databaselist[ndb] = t->databases[ndb];
183 a->u.searchRequest->resultSetName = "Default";
184 a->u.searchRequest->databaseNames = databaselist;
185 a->u.searchRequest->num_databaseNames = ndb;
187 if (send_apdu(t, a) >= 0)
189 iochan_setflags(i, EVENT_INPUT);
190 t->state = Searching;
191 t->requestid = s->requestid;
198 odr_reset(t->odr_out);
201 static void send_present(IOCHAN i)
203 struct target *t = iochan_getdata(i);
204 Z_APDU *a = zget_APDU(t->odr_out, Z_APDU_presentRequest);
206 int start = t->records + 1;
208 toget = global_parameters.chunk;
209 if (toget > t->hits - t->records)
210 toget = t->hits - t->records;
212 yaz_log(YLOG_DEBUG, "Trying to present %d records\n", toget);
214 a->u.presentRequest->resultSetStartPoint = &start;
215 a->u.presentRequest->numberOfRecordsRequested = &toget;
217 a->u.presentRequest->resultSetId = "Default";
219 a->u.presentRequest->preferredRecordSyntax = yaz_oidval_to_z3950oid(t->odr_out,
220 CLASS_RECSYN, VAL_USMARC);
222 if (send_apdu(t, a) >= 0)
224 iochan_setflags(i, EVENT_INPUT);
225 t->state = Presenting;
232 odr_reset(t->odr_out);
235 static void do_initResponse(IOCHAN i, Z_APDU *a)
237 struct target *t = iochan_getdata(i);
238 Z_InitResponse *r = a->u.initResponse;
240 yaz_log(YLOG_DEBUG, "Received init response");
250 static void do_searchResponse(IOCHAN i, Z_APDU *a)
252 struct target *t = iochan_getdata(i);
253 Z_SearchResponse *r = a->u.searchResponse;
255 yaz_log(YLOG_DEBUG, "Searchresponse (status=%d)", *r->searchStatus);
257 if (*r->searchStatus)
259 t->hits = *r->resultCount;
261 t->session->total_hits += t->hits;
268 Z_Records *recs = r->records;
269 if (recs->which == Z_Records_NSD)
271 yaz_log(YLOG_WARN, "Non-surrogate diagnostic");
272 t->diagnostic = *recs->u.nonSurrogateDiagnostic->condition;
279 const char *find_field(const char *rec, const char *field)
281 const char *line = rec;
287 if (!strncmp(line, field, 3) && line[3] == ' ')
289 while (*line && *line != '\n')
291 if (!(eol = strchr(line, '\n')))
298 const char *find_subfield(const char *field, char subfield)
300 const char *p = field;
302 while (*p && *p != '\n')
304 while (*p != '\n' && *p != '\t')
306 if (*p == '\t' && *(++p) == subfield) {
318 // Extract 245 $a $b 100 $a
319 char *extract_title(struct session *s, const char *rec)
321 const char *field, *subfield;
323 unsigned char *obuf, *p;
325 wrbuf_rewind(s->wrbuf);
327 if (!(field = find_field(rec, "245")))
329 if (!(subfield = find_subfield(field, 'a')))
331 ef = index(subfield, '\n');
332 if ((e = index(subfield, '\t')) && e < ef)
336 wrbuf_write(s->wrbuf, subfield, ef - subfield);
337 if ((subfield = find_subfield(field, 'b')))
339 ef = index(subfield, '\n');
340 if ((e = index(subfield, '\t')) && e < ef)
344 wrbuf_putc(s->wrbuf, ' ');
345 wrbuf_write(s->wrbuf, subfield, ef - subfield);
349 if ((field = find_field(rec, "100")))
351 if ((subfield = find_subfield(field, 'a')))
353 ef = index(subfield, '\n');
354 if ((e = index(subfield, '\t')) && e < ef)
358 wrbuf_puts(s->wrbuf, ", by ");
359 wrbuf_write(s->wrbuf, subfield, ef - subfield);
363 wrbuf_putc(s->wrbuf, '\0');
364 obuf = nmem_strdup(s->nmem, wrbuf_buf(s->wrbuf));
365 for (p = obuf; *p; p++)
366 if (*p == '&' || *p == '<' || *p > 122 || *p < ' ')
371 // Extract 245 $a $b 100 $a
372 char *extract_mergekey(struct session *s, const char *rec)
374 const char *field, *subfield;
376 char *out, *p, *pout;
378 wrbuf_rewind(s->wrbuf);
380 if (!(field = find_field(rec, "245")))
382 if (!(subfield = find_subfield(field, 'a')))
384 ef = index(subfield, '\n');
385 if ((e = index(subfield, '\t')) && e < ef)
389 wrbuf_write(s->wrbuf, subfield, ef - subfield);
390 if ((subfield = find_subfield(field, 'b')))
392 ef = index(subfield, '\n');
393 if ((e = index(subfield, '\t')) && e < ef)
397 wrbuf_puts(s->wrbuf, " field ");
398 wrbuf_write(s->wrbuf, subfield, ef - subfield);
402 if ((field = find_field(rec, "100")))
404 if ((subfield = find_subfield(field, 'a')))
406 ef = index(subfield, '\n');
407 if ((e = index(subfield, '\t')) && e < ef)
411 wrbuf_puts(s->wrbuf, " field ");
412 wrbuf_write(s->wrbuf, subfield, ef - subfield);
416 wrbuf_putc(s->wrbuf, '\0');
417 p = wrbuf_buf(s->wrbuf);
418 out = pout = nmem_malloc(s->nmem, strlen(p) + 1);
423 *(pout++) = tolower(*(p++));
424 while (*p && !isalnum(*p))
435 static void push_record(struct session *s, struct record *r)
438 assert(s->recheap_max + 1 < s->recheap_size);
440 s->recheap[p = ++s->recheap_max] = r;
443 int parent = (p - 1) >> 1;
444 if (strcmp(s->recheap[p]->merge_key, s->recheap[parent]->merge_key) < 0)
447 tmp = s->recheap[parent];
448 s->recheap[parent] = s->recheap[p];
457 static struct record *top_record(struct session *s)
459 return s-> recheap_max >= 0 ? s->recheap[0] : 0;
462 static struct record *pop_record(struct session *s)
466 int lastnonleaf = (s->recheap_max - 1) >> 1;
468 if (s->recheap_max < 0)
473 s->recheap[p] = s->recheap[s->recheap_max--];
475 while (p <= lastnonleaf)
477 int right = (p + 1) << 1;
478 int left = right - 1;
481 if (right < s->recheap_max &&
482 strcmp(s->recheap[right]->merge_key, s->recheap[left]->merge_key) < 0)
484 if (strcmp(s->recheap[min]->merge_key, s->recheap[p]->merge_key) < 0)
486 struct record *tmp = s->recheap[min];
487 s->recheap[min] = s->recheap[p];
497 // Like pop_record but collapses identical (merge_key) records
498 // The heap will contain multiple independent matching records and possibly
499 // one cluster, created the last time the list was scanned
500 static struct record *pop_mrecord(struct session *s)
505 if (!(this = pop_record(s)))
508 // Collapse identical records
509 while ((next = top_record(s)))
511 struct record *p, *tmpnext;
512 if (strcmp(this->merge_key, next->merge_key))
514 // Absorb record (and clustersiblings) into a supercluster
515 for (p = next; p; p = tmpnext) {
516 tmpnext = p->next_cluster;
517 p->next_cluster = this->next_cluster;
518 this->next_cluster = p;
526 // Reads records in sort order. Store records in top of heapspace until rewind is called.
527 static struct record *read_recheap(struct session *s)
529 struct record *r = pop_mrecord(s);
533 if (s->recheap_scratch < 0)
534 s->recheap_scratch = s->recheap_size;
535 s->recheap[--s->recheap_scratch] = r;
541 // Return records to heap after read
542 static void rewind_recheap(struct session *s)
544 while (s->recheap_scratch >= 0) {
545 push_record(s, s->recheap[s->recheap_scratch++]);
546 if (s->recheap_scratch >= s->recheap_size)
547 s->recheap_scratch = -1;
553 // FIXME needs to be generalized. Should flexibly generate X lists per search
554 static void extract_subject(struct session *s, const char *rec)
556 const char *field, *subfield;
558 while ((field = find_field(rec, "650")))
560 rec = field + 1; // Crude way to cause a loop through repeating fields
561 if ((subfield = find_subfield(field, 'a')))
567 ef = index(subfield, '\n');
570 if ((e = index(subfield, '\t')) && e < ef)
572 while (ef > subfield && !isalpha(*(ef - 1)) && *(ef - 1) != ')')
576 memcpy(buf, subfield, len);
579 termlist_insert(s->termlist, buf);
584 static void pull_relevance_field(struct session *s, struct record *head, const char *rec,
585 char *field, int mult)
588 while ((fb = find_field(rec, field)))
590 char *ffield = strchr(fb, '\t');
593 char *eol = strchr(ffield, '\n');
596 relevance_countwords(s->relevance, head, ffield, eol - ffield, mult);
597 rec = field + 1; // Crude way to cause a loop through repeating fields
601 static void pull_relevance_keys(struct session *s, struct record *head, struct record *rec)
603 relevance_newrec(s->relevance, head);
604 pull_relevance_field(s, head, rec->buf, "100", 2);
605 pull_relevance_field(s, head, rec->buf, "245", 4);
606 //pull_relevance_field(s, head, rec->buf, "530", 1);
607 pull_relevance_field(s, head, rec->buf, "630", 1);
608 pull_relevance_field(s, head, rec->buf, "650", 1);
609 pull_relevance_field(s, head, rec->buf, "700", 1);
610 relevance_donerecord(s->relevance, head);
613 struct record *ingest_record(struct target *t, char *buf, int len)
615 struct session *s = t->session;
620 wrbuf_rewind(s->wrbuf);
621 yaz_marc_xml(s->yaz_marc, YAZ_MARC_LINE);
622 if (yaz_marc_decode_wrbuf(s->yaz_marc, buf, len, s->wrbuf) < 0)
624 yaz_log(YLOG_WARN, "Failed to decode MARC record");
627 wrbuf_putc(s->wrbuf, '\0');
628 recbuf = wrbuf_buf(s->wrbuf);
630 res = nmem_malloc(s->nmem, sizeof(struct record));
631 res->buf = nmem_strdup(s->nmem, recbuf);
633 extract_subject(s, res->buf);
635 res->title = extract_title(s, res->buf);
636 res->merge_key = extract_mergekey(s, res->buf);
640 res->next_cluster = 0;
641 res->target_offset = -1;
642 res->term_frequency_vec = 0;
644 head = reclist_insert(s->reclist, res);
646 pull_relevance_keys(s, head, res);
653 void ingest_records(struct target *t, Z_Records *r)
655 //struct session *s = t->session;
657 Z_NamePlusRecordList *rlist;
660 if (r->which != Z_Records_DBOSD)
662 rlist = r->u.databaseOrSurDiagnostics;
663 for (i = 0; i < rlist->num_records; i++)
665 Z_NamePlusRecord *npr = rlist->records[i];
670 if (npr->which != Z_NamePlusRecord_databaseRecord)
672 yaz_log(YLOG_WARN, "Unexpected record type, probably diagnostic");
675 e = npr->u.databaseRecord;
676 if (e->which != Z_External_octet)
678 yaz_log(YLOG_WARN, "Unexpected external branch, probably BER");
681 buf = (char*) e->u.octet_aligned->buf;
682 len = e->u.octet_aligned->len;
684 rec = ingest_record(t, buf, len);
690 static void do_presentResponse(IOCHAN i, Z_APDU *a)
692 struct target *t = iochan_getdata(i);
693 Z_PresentResponse *r = a->u.presentResponse;
696 Z_Records *recs = r->records;
697 if (recs->which == Z_Records_NSD)
699 yaz_log(YLOG_WARN, "Non-surrogate diagnostic");
700 t->diagnostic = *recs->u.nonSurrogateDiagnostic->condition;
705 if (!*r->presentStatus && t->state != Error)
707 yaz_log(YLOG_DEBUG, "Good Present response");
708 t->records += *r->numberOfRecordsReturned;
709 ingest_records(t, r->records);
712 else if (*r->presentStatus)
714 yaz_log(YLOG_WARN, "Bad Present response");
719 static void handler(IOCHAN i, int event)
721 struct target *t = iochan_getdata(i);
722 struct session *s = t->session;
723 //static int waiting = 0;
725 if (t->state == No_connection) /* Start connection */
727 int res = cs_connect(t->link, t->addr);
729 t->state = Connecting;
730 if (!res) /* we are go */
731 iochan_setevent(i, EVENT_OUTPUT);
733 iochan_setflags(i, EVENT_OUTPUT);
736 yaz_log(YLOG_WARN|YLOG_ERRNO, "ERROR %s connect\n", t->hostport);
742 else if (t->state == Connecting && event & EVENT_OUTPUT)
745 socklen_t errlen = sizeof(errcode);
747 if (getsockopt(cs_fileno(t->link), SOL_SOCKET, SO_ERROR, &errcode,
748 &errlen) < 0 || errcode != 0)
755 yaz_log(YLOG_DEBUG, "Connect OK");
756 t->state = Connected;
760 else if (event & EVENT_INPUT)
762 int len = cs_get(t->link, &t->ibuf, &t->ibufsize);
776 if (t->requestid == s->requestid || t->state == Initializing)
780 odr_reset(t->odr_in);
781 odr_setbuf(t->odr_in, t->ibuf, len, 0);
782 if (!z_APDU(t->odr_in, &a, 0, 0))
789 case Z_APDU_initResponse:
790 do_initResponse(i, a);
792 case Z_APDU_searchResponse:
793 do_searchResponse(i, a);
795 case Z_APDU_presentResponse:
796 do_presentResponse(i, a);
799 yaz_log(YLOG_WARN, "Unexpected result from server");
803 // if (cs_more(t->link))
804 // iochan_setevent(i, EVENT_INPUT);
806 else // we throw away response and go to idle mode
808 yaz_log(YLOG_DEBUG, "Ignoring result to previous operation");
812 /* if len==1 we do nothing but wait for more input */
815 else if (t->state == Connected) {
819 if (t->state == Idle)
821 if (t->requestid != s->requestid && *s->query) {
824 else if (t->hits > 0 && t->records < global_parameters.toget &&
825 t->records < t->hits) {
831 static void target_destroy(IOCHAN i)
833 struct target *t = iochan_getdata(i);
834 struct session *s = t->session;
836 assert(iochan_getfun(i) == handler);
838 yaz_log(YLOG_DEBUG, "Destroying target");
844 odr_destroy(t->odr_in);
846 odr_destroy(t->odr_out);
847 for (p = &s->targets; *p; p = &(*p)->next)
857 int load_targets(struct session *s, const char *fn)
859 FILE *f = fopen(fn, "r");
861 struct target **target_p;
865 yaz_log(YLOG_WARN|YLOG_ERRNO, "open %s", fn);
870 target_destroy(s->targets->iochan);
873 target_p = &s->targets;
874 while (fgets(line, 255, f))
877 struct target *target;
880 if (strncmp(line, "target ", 7))
883 url[strlen(url) - 1] = '\0';
884 yaz_log(LOG_DEBUG, "Target: %s", url);
886 *target_p = target = xmalloc(sizeof(**target_p));
888 target_p = &target->next;
889 target->state = No_connection;
891 target->ibufsize = 0;
892 target->odr_in = odr_createmem(ODR_DECODE);
893 target->odr_out = odr_createmem(ODR_ENCODE);
897 target->requestid = -1;
899 target->diagnostic = 0;
900 strcpy(target->fullname, url);
901 if ((p = strchr(url, '/')))
904 strcpy(target->hostport, url);
907 strcpy(target->databases[0], p);
908 target->databases[1][0] = '\0';
912 strcpy(target->hostport, url);
913 strcpy(target->databases[0], "Default");
914 target->databases[1][0] = '\0';
917 if (!(target->link = cs_create(tcpip_type, 0, PROTO_Z3950)))
919 yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create comstack");
922 if (!(target->addr = cs_straddr(target->link, target->hostport)))
924 printf("ERROR %s bad-address", target->hostport);
925 target->state = Failed;
928 target->iochan = new = iochan_create(cs_fileno(target->link), handler, 0);
930 iochan_setdata(new, target);
931 iochan_setevent(new, EVENT_EXCEPT);
932 new->next = channel_list;
940 static void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num)
948 pull_terms(nmem, n->u.p[0], termlist, num);
949 pull_terms(nmem, n->u.p[1], termlist, num);
952 termlist[(*num)++] = nmem_strdup(nmem, n->u.t.term);
959 // Extract terms from query into null-terminated termlist
960 static int extract_terms(NMEM nmem, char *query, char **termlist)
963 struct ccl_rpn_node *n;
966 n = ccl_find_str(global_parameters.ccl_filter, query, &error, &pos);
969 pull_terms(nmem, n, termlist, &num);
975 char *search(struct session *s, char *query)
978 int live_channels = 0;
980 yaz_log(YLOG_DEBUG, "Search");
982 // Determine what iochans belong to this session
983 // It might have been better to have a list of them
985 strcpy(s->query, query);
988 for (c = channel_list; c; c = c->next)
992 if (iochan_getfun(c) != handler) // Not a Z target
994 t = iochan_getdata(c);
1001 if (t->state == Error)
1004 if (t->state == Idle)
1005 iochan_setflag(c, EVENT_OUTPUT);
1013 int maxrecs = live_channels * global_parameters.toget;
1014 s->termlist = termlist_create(s->nmem, maxrecs, 15);
1015 s->reclist = reclist_create(s->nmem, maxrecs);
1016 extract_terms(s->nmem, query, p);
1017 s->relevance = relevance_create(s->nmem, (const char **) p, maxrecs);
1018 s->total_records = s->total_hits = 0;
1026 struct session *new_session()
1028 struct session *session = xmalloc(sizeof(*session));
1030 yaz_log(YLOG_DEBUG, "New pazpar2 session");
1032 session->total_hits = 0;
1033 session->total_records = 0;
1034 session->termlist = 0;
1035 session->reclist = 0;
1036 session->requestid = -1;
1037 session->targets = 0;
1038 session->pqf_parser = yaz_pqf_create();
1039 session->query[0] = '\0';
1040 session->nmem = nmem_create();
1041 session->yaz_marc = yaz_marc_create();
1042 yaz_marc_subfield_str(session->yaz_marc, "\t");
1043 session->wrbuf = wrbuf_alloc();
1048 void session_destroy(struct session *s)
1050 // FIXME do some shit here!!!!
1053 struct hitsbytarget *hitsbytarget(struct session *s, int *count)
1055 static struct hitsbytarget res[1000]; // FIXME MM
1059 for (c = channel_list; c; c = c->next)
1060 if (iochan_getfun(c) == handler)
1062 struct target *t = iochan_getdata(c);
1063 if (t->session == s)
1065 strcpy(res[*count].id, t->hostport);
1066 res[*count].hits = t->hits;
1067 res[*count].records = t->records;
1068 res[*count].diagnostic = t->diagnostic;
1069 res[*count].state = state_strings[(int) t->state];
1077 struct termlist_score **termlist(struct session *s, int *num)
1079 return termlist_highscore(s->termlist, num);
1082 struct record **show(struct session *s, int start, int *num, int *total, int *sumhits)
1084 struct record **recs = nmem_malloc(s->nmem, *num * sizeof(struct record *));
1087 relevance_prepare_read(s->relevance, s->reclist);
1089 *total = s->reclist->num_records;
1090 *sumhits = s->total_hits;
1092 for (i = 0; i < start; i++)
1093 if (!reclist_read_record(s->reclist))
1099 for (i = 0; i < *num; i++)
1101 struct record *r = reclist_read_record(s->reclist);
1112 void statistics(struct session *s, struct statistics *stat)
1117 bzero(stat, sizeof(*stat));
1118 for (i = 0, c = channel_list; c; i++, c = c->next)
1121 if (iochan_getfun(c) != handler)
1123 t = iochan_getdata(c);
1126 case No_connection: stat->num_no_connection++; break;
1127 case Connecting: stat->num_connecting++; break;
1128 case Initializing: stat->num_initializing++; break;
1129 case Searching: stat->num_searching++; break;
1130 case Presenting: stat->num_presenting++; break;
1131 case Idle: stat->num_idle++; break;
1132 case Failed: stat->num_failed++; break;
1133 case Error: stat->num_error++; break;
1137 stat->num_hits = s->total_hits;
1138 stat->num_records = s->total_records;
1140 stat->num_connections = i;
1143 static CCL_bibset load_cclfile(const char *fn)
1145 CCL_bibset res = ccl_qual_mk();
1146 if (ccl_qual_fname(res, fn) < 0)
1148 yaz_log(YLOG_FATAL|YLOG_ERRNO, "%s", fn);
1154 int main(int argc, char **argv)
1159 if (signal(SIGPIPE, SIG_IGN) < 0)
1160 yaz_log(YLOG_WARN|YLOG_ERRNO, "signal");
1162 yaz_log_init(YLOG_DEFAULT_LEVEL|YLOG_DEBUG, "pazpar2", 0);
1164 while ((ret = options("c:h:p:C:", argv, argc, &arg)) != -2)
1170 command_init(atoi(arg));
1173 global_parameters.ccl_filter = load_cclfile(arg);
1176 http_init(atoi(arg));
1179 http_set_proxyaddr(arg);
1182 fprintf(stderr, "Usage: pazpar2 -d comport");
1188 if (!global_parameters.ccl_filter)
1189 global_parameters.ccl_filter = load_cclfile("default.bib");
1191 event_loop(&channel_list);
1199 * indent-tabs-mode: nil
1201 * vim: shiftwidth=4 tabstop=8 expandtab