1 /* This file is part of the Zebra server.
2 Copyright (C) Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <sys/locking.h>
39 #include <yaz/yaz-util.h>
40 #include <yaz/yaz-version.h>
41 #include <yaz/diagbib1.h>
42 #include <yaz/querytowrbuf.h>
43 #include <yaz/pquery.h>
44 #include <sys/types.h>
46 #include <yaz/backend.h>
47 #include <yaz/charneg.h>
48 #include <idzebra/api.h>
50 static int bend_sort(void *handle, bend_sort_rr *rr);
51 static int bend_delete(void *handle, bend_delete_rr *rr);
52 static int bend_esrequest(void *handle, bend_esrequest_rr *rr);
53 static int bend_segment(void *handle, bend_segment_rr *rr);
54 static int bend_search(void *handle, bend_search_rr *r);
55 static int bend_fetch(void *handle, bend_fetch_rr *r);
56 static int bend_scan(void *handle, bend_scan_rr *r);
58 bend_initresult *bend_init(bend_initrequest *q)
60 bend_initresult *r = (bend_initresult *)
61 odr_malloc(q->stream, sizeof(*r));
63 struct statserv_options_block *sob;
70 q->bend_sort = bend_sort;
71 q->bend_delete = bend_delete;
72 q->bend_esrequest = bend_esrequest;
73 q->bend_segment = bend_segment;
74 q->bend_search = bend_search;
75 q->bend_fetch = bend_fetch;
76 q->bend_scan = bend_scan;
78 zebra_get_version(version_str, 0);
80 q->implementation_name = "Zebra Information Server";
81 q->implementation_version = odr_strdup(q->stream, version_str);
83 yaz_log(YLOG_DEBUG, "bend_init");
85 sob = statserv_getcontrol();
86 if (!(zh = zebra_open(sob->handle, 0)))
88 yaz_log(YLOG_WARN, "Failed to read config `%s'", sob->configname);
89 r->errcode = YAZ_BIB1_PERMANENT_SYSTEM_ERROR;
94 q->query_charset = odr_strdup(q->stream, zebra_get_encoding(zh));
97 if (q->auth->which == Z_IdAuthentication_open)
99 char *openpass = xstrdup(q->auth->u.open);
100 char *cp = strchr(openpass, '/');
104 user = nmem_strdup(odr_getmem(q->stream), openpass);
105 passwd = nmem_strdup(odr_getmem(q->stream), cp+1);
109 else if (q->auth->which == Z_IdAuthentication_idPass)
111 Z_IdPass *idPass = q->auth->u.idPass;
113 user = idPass->userId;
114 passwd = idPass->password;
117 if (zebra_auth(zh, user, passwd) != ZEBRA_OK)
119 r->errcode = YAZ_BIB1_INIT_AC_BAD_USERID_AND_OR_PASSWORD;
123 if (q->charneg_request) /* characater set and language negotiation? */
131 NMEM nmem = nmem_create();
133 yaz_get_proposal_charneg(nmem, q->charneg_request,
134 &charsets, &num_charsets,
135 &langs, &num_langs, &selected);
137 for (i = 0; i < num_charsets; i++)
139 const char *right_name = "";
141 * FIXME! It is like rudiment :-))
142 * We have to support this short names of character sets,
143 * because a lot servers in Russia to use own in during
144 * character set and language negotiation still.
147 if (!yaz_matchstr(charsets[i], "win")) {
148 right_name = "WINDOWS-1251";
149 } else if (!yaz_matchstr(charsets[i], "koi")) {
150 right_name = "KOI8-R";
151 } else if (!yaz_matchstr(charsets[i], "iso")) {
152 right_name = "ISO-8859-5";
153 } else if (!yaz_matchstr(charsets[i], "dos")) {
154 right_name = "CP866";
155 } else if (!yaz_matchstr(charsets[i], "uni")) {
156 right_name = "UTF-8";
158 right_name = charsets[i];
160 if (odr_set_charset(q->decode, "UTF-8", right_name) == 0)
162 yaz_log(YLOG_LOG, "charset %d %s (proper name %s): OK", i,
163 charsets[i], right_name);
164 odr_set_charset(q->stream, right_name, "UTF-8");
166 zebra_record_encoding(zh, right_name);
167 zebra_octet_term_encoding(zh, right_name);
168 q->charneg_response =
169 yaz_set_response_charneg(q->stream, charsets[i],
173 yaz_log(YLOG_LOG, "charset %d %s (proper name %s): unsupported", i,
174 charsets[i], right_name);
182 static void search_terms(ZebraHandle zh, bend_search_rr *r)
186 int type = Z_Term_general;
187 struct Z_External *ext;
188 Z_SearchInfoReport *sr;
190 zebra_result_set_term_no(zh, r->setname, &no_terms);
194 r->search_info = odr_malloc(r->stream, sizeof(*r->search_info));
196 r->search_info->num_elements = 1;
197 r->search_info->list =
198 odr_malloc(r->stream, sizeof(*r->search_info->list));
199 r->search_info->list[0] =
200 odr_malloc(r->stream, sizeof(**r->search_info->list));
201 r->search_info->list[0]->category = 0;
202 r->search_info->list[0]->which = Z_OtherInfo_externallyDefinedInfo;
203 ext = odr_malloc(r->stream, sizeof(*ext));
204 r->search_info->list[0]->information.externallyDefinedInfo = ext;
205 ext->direct_reference = odr_oiddup(r->stream,
206 yaz_oid_userinfo_searchresult_1);
207 ext->indirect_reference = 0;
209 ext->which = Z_External_searchResult1;
210 sr = odr_malloc(r->stream, sizeof(Z_SearchInfoReport));
211 ext->u.searchResult1 = sr;
213 sr->elements = odr_malloc(r->stream, sr->num *
214 sizeof(*sr->elements));
215 for (i = 0; i < no_terms; i++)
217 Z_SearchInfoReport_s *se;
222 size_t len = sizeof(outbuf);
223 const char *term_ref_id = 0;
225 zebra_result_set_term_info(zh, r->setname, i,
226 &count, &approx, outbuf, &len,
228 se = sr->elements[i] = odr_malloc(r->stream, sizeof(**sr->elements));
229 se->subqueryId = term_ref_id ?
230 odr_strdup(r->stream, term_ref_id) : 0;
232 se->fullQuery = odr_booldup(r->stream, 0);
233 se->subqueryExpression =
234 odr_malloc(r->stream, sizeof(Z_QueryExpression));
235 se->subqueryExpression->which =
236 Z_QueryExpression_term;
237 se->subqueryExpression->u.term =
238 odr_malloc(r->stream, sizeof(Z_QueryExpressionTerm));
239 term = odr_malloc(r->stream, sizeof(Z_Term));
240 se->subqueryExpression->u.term->queryTerm = term;
243 case Z_Term_characterString:
244 term->which = Z_Term_characterString;
245 term->u.characterString = odr_strdup(r->stream, outbuf);
248 term->which = Z_Term_general;
249 term->u.general = odr_create_Odr_oct(r->stream,
250 #if YAZ_VERSIONL < 0x50000
256 term->which = Z_Term_general;
257 term->u.null = odr_nullval();
259 se->subqueryExpression->u.term->termComment = 0;
260 se->subqueryInterpretation = 0;
261 se->subqueryRecommendation = 0;
262 se->subqueryCount = odr_intdup(r->stream, count);
263 se->subqueryWeight = 0;
268 static int break_handler(void *client_data)
270 bend_association assoc =(bend_association) client_data;
271 if (!bend_assoc_is_alive(assoc))
276 static Z_RPNQuery *query_add_sortkeys(ODR o, Z_RPNQuery *query,
277 const char *sortKeys)
279 #if YAZ_VERSIONL >= 0x40200
280 /* sortkey layour: path,schema,ascending,caseSensitive,missingValue */
281 /* see cql_sortby_to_sortkeys of YAZ. */
283 int num_sortspec = 0;
287 nmem_strsplit_blank(odr_getmem(o), sortKeys, &sortspec, &num_sortspec);
288 if (num_sortspec > 0)
291 WRBUF w = wrbuf_alloc();
293 /* left operand 'd' will be replaced by original query */
294 wrbuf_puts(w, "@or d");
295 for (i = 0; i < num_sortspec; i++)
300 nmem_strsplitx(odr_getmem(o), ",", sortspec[i], &arg, &num_arg, 0);
302 if (num_arg > 5 || num_arg < 1)
304 yaz_log(YLOG_WARN, "Invalid sort spec '%s' num_arg=%d",
305 sortspec[i], num_arg);
308 if (num_arg > 2 && arg[2][0])
309 ascending = atoi(arg[2]);
311 if (i < num_sortspec-1)
312 wrbuf_puts(w, " @or");
313 wrbuf_puts(w, " @attr 1=");
314 yaz_encode_pqf_term(w, arg[0], strlen(arg[0]));
315 wrbuf_printf(w, "@attr 7=%d %d", ascending ? 1 : 2, i);
317 nquery = p_query_rpn(o, wrbuf_cstr(w));
320 yaz_log(YLOG_WARN, "query_add_sortkeys: bad RPN: '%s'",
325 Z_RPNStructure *s = nquery->RPNStructure;
327 if (s->which != Z_RPNStructure_complex)
329 yaz_log(YLOG_WARN, "query_add_sortkeys: not complex operand");
333 /* left operand 'd' is replaced by origial query */
334 s->u.complex->s1 = query->RPNStructure;
335 /* and original query points to our new or+sort things */
336 query->RPNStructure = s;
344 yaz_log(YLOG_WARN, "sortkeys ignored because YAZ version < 4.2.0");
350 int bend_search(void *handle, bend_search_rr *r)
352 ZebraHandle zh = (ZebraHandle) handle;
357 res = zebra_select_databases(zh, r->num_bases,
358 (const char **) r->basenames);
361 zebra_result(zh, &r->errcode, &r->errstring);
364 zebra_set_break_handler(zh, break_handler, r->association);
365 yaz_log(YLOG_DEBUG, "ResultSet '%s'", r->setname);
366 switch (r->query->which)
368 case Z_Query_type_1: case Z_Query_type_101:
369 q2 = query_add_sortkeys(r->stream, r->query->u.type_1, r->srw_sortKeys);
370 res = zebra_search_RPN_x(zh, r->stream, q2,
372 &r->estimated_hit_count,
373 &r->partial_resultset);
375 zebra_result(zh, &r->errcode, &r->errstring);
383 r->errcode = YAZ_BIB1_QUERY_TYPE_UNSUPP;
384 r->errstring = "type-2";
387 r->errcode = YAZ_BIB1_QUERY_TYPE_UNSUPP;
389 zebra_set_break_handler(zh, 0, 0);
394 int bend_fetch(void *handle, bend_fetch_rr *r)
396 ZebraHandle zh = (ZebraHandle) handle;
397 ZebraRetrievalRecord retrievalRecord;
400 retrievalRecord.position = r->number;
403 res = zebra_records_retrieve(zh, r->stream, r->setname, r->comp,
404 r->request_format, 1, &retrievalRecord);
407 /* non-surrogate diagnostic */
408 zebra_result(zh, &r->errcode, &r->errstring);
410 else if (retrievalRecord.errCode)
412 /* surrogate diagnostic (diagnostic per record) */
413 r->surrogate_flag = 1;
414 r->errcode = retrievalRecord.errCode;
415 r->errstring = retrievalRecord.errString;
416 r->basename = retrievalRecord.base;
420 r->basename = retrievalRecord.base;
421 r->record = retrievalRecord.buf;
422 r->len = retrievalRecord.len;
423 r->output_format = odr_oiddup(r->stream, retrievalRecord.format);
428 static int bend_scan(void *handle, bend_scan_rr *r)
430 ZebraScanEntry *entries;
431 ZebraHandle zh = (ZebraHandle) handle;
435 res = zebra_select_databases(zh, r->num_bases,
436 (const char **) r->basenames);
439 zebra_result(zh, &r->errcode, &r->errstring);
442 if (r->step_size != 0 && *r->step_size != 0) {
443 r->errcode = YAZ_BIB1_ONLY_ZERO_STEP_SIZE_SUPPORTED_FOR_SCAN;
447 res = zebra_scan(zh, r->stream, r->term,
450 &r->num_entries, &entries, &is_partial,
455 r->status = BEND_SCAN_PARTIAL;
457 r->status = BEND_SCAN_SUCCESS;
458 for (i = 0; i < r->num_entries; i++)
460 r->entries[i].term = entries[i].term;
461 r->entries[i].display_term = entries[i].display_term;
462 r->entries[i].occurrences = entries[i].occurrences;
467 r->status = BEND_SCAN_PARTIAL;
468 zebra_result(zh, &r->errcode, &r->errstring);
473 void bend_close(void *handle)
475 zebra_close((ZebraHandle) handle);
476 xmalloc_trav("bend_close");
479 int bend_sort(void *handle, bend_sort_rr *rr)
481 ZebraHandle zh = (ZebraHandle) handle;
483 if (zebra_sort(zh, rr->stream,
484 rr->num_input_setnames, (const char **) rr->input_setnames,
485 rr->output_setname, rr->sort_sequence, &rr->sort_status)
487 zebra_result(zh, &rr->errcode, &rr->errstring);
491 int bend_delete(void *handle, bend_delete_rr *rr)
493 ZebraHandle zh = (ZebraHandle) handle;
495 rr->delete_status = zebra_deleteResultSet(zh, rr->function,
496 rr->num_setnames, rr->setnames,
501 static void es_admin_request(bend_esrequest_rr *rr, ZebraHandle zh, Z_AdminEsRequest *r)
503 ZEBRA_RES res = ZEBRA_OK;
504 if (r->toKeep->databaseName)
506 yaz_log(YLOG_LOG, "adm request database %s", r->toKeep->databaseName);
508 switch (r->toKeep->which)
510 case Z_ESAdminOriginPartToKeep_reIndex:
511 yaz_log(YLOG_LOG, "adm-reindex");
512 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
513 rr->errstring = "adm-reindex not implemented yet";
515 case Z_ESAdminOriginPartToKeep_truncate:
516 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
517 rr->errstring = "adm-reindex not implemented yet";
518 yaz_log(YLOG_LOG, "adm-truncate");
520 case Z_ESAdminOriginPartToKeep_drop:
521 yaz_log(YLOG_LOG, "adm-drop");
522 res = zebra_drop_database(zh, r->toKeep->databaseName);
524 case Z_ESAdminOriginPartToKeep_create:
525 yaz_log(YLOG_LOG, "adm-create %s", r->toKeep->databaseName);
526 res = zebra_create_database(zh, r->toKeep->databaseName);
528 case Z_ESAdminOriginPartToKeep_import:
529 yaz_log(YLOG_LOG, "adm-import");
530 res = zebra_admin_import_begin(zh, r->toKeep->databaseName,
531 r->toKeep->u.import->recordType);
533 case Z_ESAdminOriginPartToKeep_refresh:
534 yaz_log(YLOG_LOG, "adm-refresh");
536 case Z_ESAdminOriginPartToKeep_commit:
537 yaz_log(YLOG_LOG, "adm-commit");
538 if (r->toKeep->databaseName)
540 if (zebra_select_database(zh, r->toKeep->databaseName) !=
542 yaz_log(YLOG_WARN, "zebra_select_database failed in "
547 case Z_ESAdminOriginPartToKeep_shutdown:
548 yaz_log(YLOG_LOG, "shutdown");
549 res = zebra_admin_shutdown(zh);
551 case Z_ESAdminOriginPartToKeep_start:
552 yaz_log(YLOG_LOG, "start");
553 zebra_admin_start(zh);
556 yaz_log(YLOG_LOG, "unknown admin");
557 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
558 rr->errstring = "adm-reindex not implemented yet";
561 zebra_result(zh, &rr->errcode, &rr->errstring);
564 static void es_admin(bend_esrequest_rr *rr, ZebraHandle zh, Z_Admin *r)
568 case Z_Admin_esRequest:
569 es_admin_request(rr, zh, r->u.esRequest);
574 yaz_log(YLOG_WARN, "adm taskpackage (unhandled)");
575 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
576 rr->errstring = "adm-task package (unhandled)";
579 int bend_segment(void *handle, bend_segment_rr *rr)
581 ZebraHandle zh = (ZebraHandle) handle;
582 Z_Segment *segment = rr->segment;
584 if (segment->num_segmentRecords)
585 zebra_admin_import_segment(zh, rr->segment);
587 zebra_admin_import_end(zh);
591 int bend_esrequest(void *handle, bend_esrequest_rr *rr)
593 ZebraHandle zh = (ZebraHandle) handle;
595 yaz_log(YLOG_LOG, "function: " ODR_INT_PRINTF, *rr->esr->function);
596 if (rr->esr->packageName)
597 yaz_log(YLOG_LOG, "packagename: %s", rr->esr->packageName);
598 yaz_log(YLOG_LOG, "Waitaction: " ODR_INT_PRINTF, *rr->esr->waitAction);
600 if (!rr->esr->taskSpecificParameters)
602 yaz_log(YLOG_WARN, "No task specific parameters");
604 else if (rr->esr->taskSpecificParameters->which == Z_External_ESAdmin)
606 es_admin(rr, zh, rr->esr->taskSpecificParameters->u.adminService);
608 else if (rr->esr->taskSpecificParameters->which == Z_External_update)
610 Z_IUUpdate *up = rr->esr->taskSpecificParameters->u.update;
611 yaz_log(YLOG_LOG, "Received DB Update");
612 if (up->which == Z_IUUpdate_esRequest)
614 Z_IUUpdateEsRequest *esRequest = up->u.esRequest;
615 Z_IUOriginPartToKeep *toKeep = esRequest->toKeep;
616 Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep;
618 yaz_log(YLOG_LOG, "action");
621 switch (*toKeep->action)
623 case Z_IUOriginPartToKeep_recordInsert:
624 yaz_log(YLOG_LOG, "recordInsert");
626 case Z_IUOriginPartToKeep_recordReplace:
627 yaz_log(YLOG_LOG, "recordUpdate");
629 case Z_IUOriginPartToKeep_recordDelete:
630 yaz_log(YLOG_LOG, "recordDelete");
632 case Z_IUOriginPartToKeep_elementUpdate:
633 yaz_log(YLOG_LOG, "elementUpdate");
635 case Z_IUOriginPartToKeep_specialUpdate:
636 yaz_log(YLOG_LOG, "specialUpdate");
638 case Z_ESAdminOriginPartToKeep_shutdown:
639 yaz_log(YLOG_LOG, "shutDown");
641 case Z_ESAdminOriginPartToKeep_start:
642 yaz_log(YLOG_LOG, "start");
645 yaz_log(YLOG_LOG, " unknown (" ODR_INT_PRINTF ")",
649 if (toKeep->databaseName)
651 yaz_log(YLOG_LOG, "database: %s", toKeep->databaseName);
653 if (zebra_select_database(zh, toKeep->databaseName))
658 yaz_log(YLOG_WARN, "no database supplied for ES Update");
660 YAZ_BIB1_ES_MISSING_MANDATORY_PARAMETER_FOR_SPECIFIED_FUNCTION_;
661 rr->errstring = "database";
664 if (zebra_begin_trans(zh, 1) != ZEBRA_OK)
666 zebra_result(zh, &rr->errcode, &rr->errstring);
671 for (i = 0; notToKeep && i < notToKeep->num; i++)
673 Z_External *rec = notToKeep->elements[i]->record;
674 Odr_oct *opaque_recid = 0;
678 if (notToKeep->elements[i]->u.opaque)
680 switch(notToKeep->elements[i]->which)
682 case Z_IUSuppliedRecords_elem_opaque:
683 opaque_recid = notToKeep->elements[i]->u.opaque;
684 break; /* OK, recid already set */
685 case Z_IUSuppliedRecords_elem_number:
686 sysno_tmp = *notToKeep->elements[i]->u.number;
691 if (rec->direct_reference)
693 char oid_name_str[OID_STR_MAX];
694 const char *oid_name =
695 yaz_oid_to_string_buf(
696 rec->direct_reference,
699 yaz_log(YLOG_LOG, "record %d type %s", i,
704 case Z_External_sutrs:
705 if (rec->u.octet_aligned->len > 170)
706 yaz_log(YLOG_LOG, "%d bytes:\n%.168s ...",
710 yaz_log(YLOG_LOG, "%d bytes:\n%s",
714 case Z_External_octet:
715 if (rec->u.octet_aligned->len > 170)
716 yaz_log(YLOG_LOG, "%d bytes:\n%.168s ...",
717 rec->u.octet_aligned->len,
718 rec->u.octet_aligned->buf);
720 yaz_log(YLOG_LOG, "%d bytes\n%s",
721 rec->u.octet_aligned->len,
722 rec->u.octet_aligned->buf);
724 if (rec->which == Z_External_octet)
726 enum zebra_recctrl_action_t action = action_update;
728 const char *match_criteria = 0;
731 if (*toKeep->action ==
732 Z_IUOriginPartToKeep_recordInsert)
733 action = action_insert;
734 else if (*toKeep->action ==
735 Z_IUOriginPartToKeep_recordReplace)
736 action = action_replace;
737 else if (*toKeep->action ==
738 Z_IUOriginPartToKeep_recordDelete)
739 action = action_delete;
740 else if (*toKeep->action ==
741 Z_IUOriginPartToKeep_specialUpdate)
742 action = action_update;
746 YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
747 rr->errstring = "unsupported ES Update action";
753 size_t l = opaque_recid->len;
754 if (l >= sizeof(recid_str))
756 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
757 rr->errstring = "opaque record ID too large";
760 memcpy(recid_str, opaque_recid->buf, l);
762 match_criteria = recid_str;
764 res = zebra_update_record(
767 sysno, match_criteria, 0, /* fname */
768 (const char *) rec->u.octet_aligned->buf,
769 rec->u.octet_aligned->len);
770 if (res == ZEBRA_FAIL)
773 YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
774 rr->errstring = "update_record failed";
778 if (zebra_end_trans(zh) != ZEBRA_OK)
780 yaz_log(YLOG_WARN, "zebra_end_trans failed for"
781 " extended service operation");
788 yaz_log(YLOG_WARN, "Unknown Extended Service(%d)",
789 rr->esr->taskSpecificParameters->which);
790 rr->errcode = YAZ_BIB1_ES_EXTENDED_SERVICE_TYPE_UNSUPP;
796 static void bend_start(struct statserv_options_block *sob)
798 Res default_res = res_open(0, 0);
801 zebra_stop((ZebraService) sob->handle);
802 res_set(default_res, "profilePath", DEFAULT_PROFILE_PATH);
803 res_set(default_res, "modulePath", DEFAULT_MODULE_PATH);
804 sob->handle = zebra_start_res(sob->configname, default_res, 0);
805 res_close(default_res);
808 yaz_log(YLOG_FATAL, "Failed to read config `%s'", sob->configname);
814 if (!sob->inetd && !sob->background)
820 zebra_pidfname(sob->handle, pidfname);
822 fd = open(pidfname, O_EXCL|O_WRONLY|O_CREAT, 0666);
827 yaz_log(YLOG_FATAL|YLOG_ERRNO, "lock file %s", pidfname);
830 fd = open(pidfname, O_RDWR, 0666);
833 yaz_log(YLOG_FATAL|YLOG_ERRNO, "lock file %s", pidfname);
837 area.l_type = F_WRLCK;
838 area.l_whence = SEEK_SET;
839 area.l_len = area.l_start = 0L;
840 if (fcntl(fd, F_SETLK, &area) == -1)
842 yaz_log(YLOG_ERRNO|YLOG_FATAL, "Zebra server already running");
849 sprintf(pidstr, "%ld", (long) getpid());
850 if (write(fd, pidstr, strlen(pidstr)) != strlen(pidstr))
852 yaz_log(YLOG_ERRNO|YLOG_FATAL, "write fail %s", pidfname);
860 static void bend_stop(struct statserv_options_block *sob)
865 if (!sob->inetd && !sob->background && sob->handle)
868 zebra_pidfname(sob->handle, pidfname);
874 ZebraService service = sob->handle;
879 int main(int argc, char **argv)
881 struct statserv_options_block *sob;
883 sob = statserv_getcontrol();
884 strcpy(sob->configname, "zebra.cfg");
885 sob->bend_start = bend_start;
886 sob->bend_stop = bend_stop;
888 strcpy(sob->service_name, "zebrasrv");
889 strcpy(sob->service_display_name, "Zebra Server");
891 statserv_setcontrol(sob);
893 return statserv_main(argc, argv, bend_init, bend_close);
898 * c-file-style: "Stroustrup"
899 * indent-tabs-mode: nil
901 * vim: shiftwidth=4 tabstop=8 expandtab