1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2011 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/diagbib1.h>
41 #include <yaz/querytowrbuf.h>
42 #include <yaz/pquery.h>
43 #include <sys/types.h>
45 #include <yaz/backend.h>
46 #include <yaz/charneg.h>
47 #include <idzebra/api.h>
49 static int bend_sort(void *handle, bend_sort_rr *rr);
50 static int bend_delete(void *handle, bend_delete_rr *rr);
51 static int bend_esrequest(void *handle, bend_esrequest_rr *rr);
52 static int bend_segment(void *handle, bend_segment_rr *rr);
53 static int bend_search(void *handle, bend_search_rr *r);
54 static int bend_fetch(void *handle, bend_fetch_rr *r);
55 static int bend_scan(void *handle, bend_scan_rr *r);
57 bend_initresult *bend_init(bend_initrequest *q)
59 bend_initresult *r = (bend_initresult *)
60 odr_malloc(q->stream, sizeof(*r));
62 struct statserv_options_block *sob;
69 q->bend_sort = bend_sort;
70 q->bend_delete = bend_delete;
71 q->bend_esrequest = bend_esrequest;
72 q->bend_segment = bend_segment;
73 q->bend_search = bend_search;
74 q->bend_fetch = bend_fetch;
75 q->bend_scan = bend_scan;
77 zebra_get_version(version_str, 0);
79 q->implementation_name = "Zebra Information Server";
80 q->implementation_version = odr_strdup(q->stream, version_str);
82 yaz_log(YLOG_DEBUG, "bend_init");
84 sob = statserv_getcontrol();
85 if (!(zh = zebra_open(sob->handle, 0)))
87 yaz_log(YLOG_WARN, "Failed to read config `%s'", sob->configname);
88 r->errcode = YAZ_BIB1_PERMANENT_SYSTEM_ERROR;
93 q->query_charset = odr_strdup(q->stream, zebra_get_encoding(zh));
96 if (q->auth->which == Z_IdAuthentication_open)
98 char *openpass = xstrdup(q->auth->u.open);
99 char *cp = strchr(openpass, '/');
103 user = nmem_strdup(odr_getmem(q->stream), openpass);
104 passwd = nmem_strdup(odr_getmem(q->stream), cp+1);
108 else if (q->auth->which == Z_IdAuthentication_idPass)
110 Z_IdPass *idPass = q->auth->u.idPass;
112 user = idPass->userId;
113 passwd = idPass->password;
116 if (zebra_auth(zh, user, passwd) != ZEBRA_OK)
118 r->errcode = YAZ_BIB1_INIT_AC_BAD_USERID_AND_OR_PASSWORD;
122 if (q->charneg_request) /* characater set and language negotiation? */
130 NMEM nmem = nmem_create();
132 yaz_get_proposal_charneg(nmem, q->charneg_request,
133 &charsets, &num_charsets,
134 &langs, &num_langs, &selected);
136 for (i = 0; i < num_charsets; i++)
138 const char *right_name = "";
140 * FIXME! It is like rudiment :-))
141 * We have to support this short names of character sets,
142 * because a lot servers in Russia to use own in during
143 * character set and language negotiation still.
146 if (!yaz_matchstr(charsets[i], "win")) {
147 right_name = "WINDOWS-1251";
148 } else if (!yaz_matchstr(charsets[i], "koi")) {
149 right_name = "KOI8-R";
150 } else if (!yaz_matchstr(charsets[i], "iso")) {
151 right_name = "ISO-8859-5";
152 } else if (!yaz_matchstr(charsets[i], "dos")) {
153 right_name = "CP866";
154 } else if (!yaz_matchstr(charsets[i], "uni")) {
155 right_name = "UTF-8";
157 right_name = charsets[i];
159 if (odr_set_charset(q->decode, "UTF-8", right_name) == 0)
161 yaz_log(YLOG_LOG, "charset %d %s (proper name %s): OK", i,
162 charsets[i], right_name);
163 odr_set_charset(q->stream, right_name, "UTF-8");
165 zebra_record_encoding(zh, right_name);
166 zebra_octet_term_encoding(zh, right_name);
167 q->charneg_response =
168 yaz_set_response_charneg(q->stream, charsets[i],
172 yaz_log(YLOG_LOG, "charset %d %s (proper name %s): unsupported", i,
173 charsets[i], right_name);
181 static void search_terms(ZebraHandle zh, bend_search_rr *r)
185 int type = Z_Term_general;
186 struct Z_External *ext;
187 Z_SearchInfoReport *sr;
189 zebra_result_set_term_no(zh, r->setname, &no_terms);
193 r->search_info = odr_malloc(r->stream, sizeof(*r->search_info));
195 r->search_info->num_elements = 1;
196 r->search_info->list =
197 odr_malloc(r->stream, sizeof(*r->search_info->list));
198 r->search_info->list[0] =
199 odr_malloc(r->stream, sizeof(**r->search_info->list));
200 r->search_info->list[0]->category = 0;
201 r->search_info->list[0]->which = Z_OtherInfo_externallyDefinedInfo;
202 ext = odr_malloc(r->stream, sizeof(*ext));
203 r->search_info->list[0]->information.externallyDefinedInfo = ext;
204 ext->direct_reference = odr_oiddup(r->stream,
205 yaz_oid_userinfo_searchresult_1);
206 ext->indirect_reference = 0;
208 ext->which = Z_External_searchResult1;
209 sr = odr_malloc(r->stream, sizeof(Z_SearchInfoReport));
210 ext->u.searchResult1 = sr;
212 sr->elements = odr_malloc(r->stream, sr->num *
213 sizeof(*sr->elements));
214 for (i = 0; i<no_terms; i++)
216 Z_SearchInfoReport_s *se;
221 size_t len = sizeof(outbuf);
222 const char *term_ref_id = 0;
224 zebra_result_set_term_info(zh, r->setname, i,
225 &count, &approx, outbuf, &len,
227 se = sr->elements[i] = odr_malloc(r->stream, sizeof(**sr->elements));
228 se->subqueryId = term_ref_id ?
229 odr_strdup(r->stream, term_ref_id) : 0;
231 se->fullQuery = odr_booldup(r->stream, 0);
232 se->subqueryExpression =
233 odr_malloc(r->stream, sizeof(Z_QueryExpression));
234 se->subqueryExpression->which =
235 Z_QueryExpression_term;
236 se->subqueryExpression->u.term =
237 odr_malloc(r->stream, sizeof(Z_QueryExpressionTerm));
238 term = odr_malloc(r->stream, sizeof(Z_Term));
239 se->subqueryExpression->u.term->queryTerm = term;
242 case Z_Term_characterString:
243 term->which = Z_Term_characterString;
244 term->u.characterString = odr_strdup(r->stream, outbuf);
247 term->which = Z_Term_general;
248 term->u.general = odr_malloc(r->stream, sizeof(*term->u.general));
249 term->u.general->size = term->u.general->len = len;
250 term->u.general->buf = odr_malloc(r->stream, len);
251 memcpy(term->u.general->buf, outbuf, len);
254 term->which = Z_Term_general;
255 term->u.null = odr_nullval();
257 se->subqueryExpression->u.term->termComment = 0;
258 se->subqueryInterpretation = 0;
259 se->subqueryRecommendation = 0;
260 se->subqueryCount = odr_intdup(r->stream, count);
261 se->subqueryWeight = 0;
266 static int break_handler(void *client_data)
268 bend_association assoc =(bend_association) client_data;
269 if (!bend_assoc_is_alive(assoc))
274 static Z_RPNQuery *query_add_sortkeys(ODR o, Z_RPNQuery *query,
275 const char *sortKeys)
277 /* sortkey layour: path,schema,ascending,caseSensitive,missingValue */
278 /* see cql_sortby_to_sortkeys of YAZ. */
280 int num_sortspec = 0;
284 nmem_strsplit_blank(odr_getmem(o), sortKeys, &sortspec, &num_sortspec);
285 if (num_sortspec > 0)
288 WRBUF w = wrbuf_alloc();
290 /* left operand 'd' will be replaced by original query */
291 wrbuf_puts(w, "@or d");
292 for (i = 0; i < num_sortspec; i++)
297 nmem_strsplitx(odr_getmem(o), ",", sortspec[i], &arg, &num_arg, 0);
301 yaz_log(YLOG_WARN, "Invalid sort spec '%s' num_arg=%d",
302 sortspec[i], num_arg);
306 ascending = atoi(arg[2]);
308 if (i < num_sortspec-1)
309 wrbuf_puts(w, " @or");
310 wrbuf_puts(w, " @attr 1=");
311 yaz_encode_pqf_term(w, arg[0], strlen(arg[0]));
312 wrbuf_printf(w, "@attr 7=%d %d", ascending ? 1 : 2, i);
314 nquery = p_query_rpn(o, wrbuf_cstr(w));
317 yaz_log(YLOG_WARN, "query_add_sortkeys: bad RPN: '%s'",
322 Z_RPNStructure *s = nquery->RPNStructure;
324 if (s->which != Z_RPNStructure_complex)
326 yaz_log(YLOG_WARN, "query_add_sortkeys: not complex operand");
330 /* left operand 'd' is replaced by origial query */
331 s->u.complex->s1 = query->RPNStructure;
332 /* and original query points to our new or+sort things */
333 query->RPNStructure = s;
341 int bend_search(void *handle, bend_search_rr *r)
343 ZebraHandle zh = (ZebraHandle) handle;
348 res = zebra_select_databases(zh, r->num_bases,
349 (const char **) r->basenames);
352 zebra_result(zh, &r->errcode, &r->errstring);
355 zebra_set_break_handler(zh, break_handler, r->association);
356 yaz_log(YLOG_DEBUG, "ResultSet '%s'", r->setname);
357 switch (r->query->which)
359 case Z_Query_type_1: case Z_Query_type_101:
360 q2 = query_add_sortkeys(r->stream, r->query->u.type_1, r->srw_sortKeys);
361 res = zebra_search_RPN_x(zh, r->stream, q2,
363 &r->estimated_hit_count,
364 &r->partial_resultset);
366 zebra_result(zh, &r->errcode, &r->errstring);
374 r->errcode = YAZ_BIB1_QUERY_TYPE_UNSUPP;
375 r->errstring = "type-2";
378 r->errcode = YAZ_BIB1_QUERY_TYPE_UNSUPP;
380 zebra_set_break_handler(zh, 0, 0);
385 int bend_fetch(void *handle, bend_fetch_rr *r)
387 ZebraHandle zh = (ZebraHandle) handle;
388 ZebraRetrievalRecord retrievalRecord;
391 retrievalRecord.position = r->number;
394 res = zebra_records_retrieve(zh, r->stream, r->setname, r->comp,
395 r->request_format, 1, &retrievalRecord);
398 /* non-surrogate diagnostic */
399 zebra_result(zh, &r->errcode, &r->errstring);
401 else if (retrievalRecord.errCode)
403 /* surrogate diagnostic (diagnostic per record) */
404 r->surrogate_flag = 1;
405 r->errcode = retrievalRecord.errCode;
406 r->errstring = retrievalRecord.errString;
407 r->basename = retrievalRecord.base;
411 r->basename = retrievalRecord.base;
412 r->record = retrievalRecord.buf;
413 r->len = retrievalRecord.len;
414 r->output_format = odr_oiddup(r->stream, retrievalRecord.format);
419 static int bend_scan(void *handle, bend_scan_rr *r)
421 ZebraScanEntry *entries;
422 ZebraHandle zh = (ZebraHandle) handle;
426 res = zebra_select_databases(zh, r->num_bases,
427 (const char **) r->basenames);
430 zebra_result(zh, &r->errcode, &r->errstring);
433 if (r->step_size != 0 && *r->step_size != 0) {
434 r->errcode = YAZ_BIB1_ONLY_ZERO_STEP_SIZE_SUPPORTED_FOR_SCAN;
438 res = zebra_scan(zh, r->stream, r->term,
441 &r->num_entries, &entries, &is_partial,
446 r->status = BEND_SCAN_PARTIAL;
448 r->status = BEND_SCAN_SUCCESS;
449 for (i = 0; i < r->num_entries; i++)
451 r->entries[i].term = entries[i].term;
452 r->entries[i].display_term = entries[i].display_term;
453 r->entries[i].occurrences = entries[i].occurrences;
458 r->status = BEND_SCAN_PARTIAL;
459 zebra_result(zh, &r->errcode, &r->errstring);
464 void bend_close(void *handle)
466 zebra_close((ZebraHandle) handle);
467 xmalloc_trav("bend_close");
470 int bend_sort(void *handle, bend_sort_rr *rr)
472 ZebraHandle zh = (ZebraHandle) handle;
474 if (zebra_sort(zh, rr->stream,
475 rr->num_input_setnames, (const char **) rr->input_setnames,
476 rr->output_setname, rr->sort_sequence, &rr->sort_status)
478 zebra_result(zh, &rr->errcode, &rr->errstring);
482 int bend_delete(void *handle, bend_delete_rr *rr)
484 ZebraHandle zh = (ZebraHandle) handle;
486 rr->delete_status = zebra_deleteResultSet(zh, rr->function,
487 rr->num_setnames, rr->setnames,
492 static void es_admin_request(bend_esrequest_rr *rr, ZebraHandle zh, Z_AdminEsRequest *r)
494 ZEBRA_RES res = ZEBRA_OK;
495 if (r->toKeep->databaseName)
497 yaz_log(YLOG_LOG, "adm request database %s", r->toKeep->databaseName);
499 switch (r->toKeep->which)
501 case Z_ESAdminOriginPartToKeep_reIndex:
502 yaz_log(YLOG_LOG, "adm-reindex");
503 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
504 rr->errstring = "adm-reindex not implemented yet";
506 case Z_ESAdminOriginPartToKeep_truncate:
507 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
508 rr->errstring = "adm-reindex not implemented yet";
509 yaz_log(YLOG_LOG, "adm-truncate");
511 case Z_ESAdminOriginPartToKeep_drop:
512 yaz_log(YLOG_LOG, "adm-drop");
513 res = zebra_drop_database(zh, r->toKeep->databaseName);
515 case Z_ESAdminOriginPartToKeep_create:
516 yaz_log(YLOG_LOG, "adm-create %s", r->toKeep->databaseName);
517 res = zebra_create_database(zh, r->toKeep->databaseName);
519 case Z_ESAdminOriginPartToKeep_import:
520 yaz_log(YLOG_LOG, "adm-import");
521 res = zebra_admin_import_begin(zh, r->toKeep->databaseName,
522 r->toKeep->u.import->recordType);
524 case Z_ESAdminOriginPartToKeep_refresh:
525 yaz_log(YLOG_LOG, "adm-refresh");
527 case Z_ESAdminOriginPartToKeep_commit:
528 yaz_log(YLOG_LOG, "adm-commit");
529 if (r->toKeep->databaseName)
531 if (zebra_select_database(zh, r->toKeep->databaseName) !=
533 yaz_log(YLOG_WARN, "zebra_select_database failed in "
538 case Z_ESAdminOriginPartToKeep_shutdown:
539 yaz_log(YLOG_LOG, "shutdown");
540 res = zebra_admin_shutdown(zh);
542 case Z_ESAdminOriginPartToKeep_start:
543 yaz_log(YLOG_LOG, "start");
544 zebra_admin_start(zh);
547 yaz_log(YLOG_LOG, "unknown admin");
548 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
549 rr->errstring = "adm-reindex not implemented yet";
552 zebra_result(zh, &rr->errcode, &rr->errstring);
555 static void es_admin(bend_esrequest_rr *rr, ZebraHandle zh, Z_Admin *r)
559 case Z_Admin_esRequest:
560 es_admin_request(rr, zh, r->u.esRequest);
565 yaz_log(YLOG_WARN, "adm taskpackage (unhandled)");
566 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
567 rr->errstring = "adm-task package (unhandled)";
570 int bend_segment(void *handle, bend_segment_rr *rr)
572 ZebraHandle zh = (ZebraHandle) handle;
573 Z_Segment *segment = rr->segment;
575 if (segment->num_segmentRecords)
576 zebra_admin_import_segment(zh, rr->segment);
578 zebra_admin_import_end(zh);
582 int bend_esrequest(void *handle, bend_esrequest_rr *rr)
584 ZebraHandle zh = (ZebraHandle) handle;
586 yaz_log(YLOG_LOG, "function: " ODR_INT_PRINTF, *rr->esr->function);
587 if (rr->esr->packageName)
588 yaz_log(YLOG_LOG, "packagename: %s", rr->esr->packageName);
589 yaz_log(YLOG_LOG, "Waitaction: " ODR_INT_PRINTF, *rr->esr->waitAction);
591 if (!rr->esr->taskSpecificParameters)
593 yaz_log(YLOG_WARN, "No task specific parameters");
595 else if (rr->esr->taskSpecificParameters->which == Z_External_ESAdmin)
597 es_admin(rr, zh, rr->esr->taskSpecificParameters->u.adminService);
599 else if (rr->esr->taskSpecificParameters->which == Z_External_update)
601 Z_IUUpdate *up = rr->esr->taskSpecificParameters->u.update;
602 yaz_log(YLOG_LOG, "Received DB Update");
603 if (up->which == Z_IUUpdate_esRequest)
605 Z_IUUpdateEsRequest *esRequest = up->u.esRequest;
606 Z_IUOriginPartToKeep *toKeep = esRequest->toKeep;
607 Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep;
609 yaz_log(YLOG_LOG, "action");
612 switch (*toKeep->action)
614 case Z_IUOriginPartToKeep_recordInsert:
615 yaz_log(YLOG_LOG, "recordInsert");
617 case Z_IUOriginPartToKeep_recordReplace:
618 yaz_log(YLOG_LOG, "recordUpdate");
620 case Z_IUOriginPartToKeep_recordDelete:
621 yaz_log(YLOG_LOG, "recordDelete");
623 case Z_IUOriginPartToKeep_elementUpdate:
624 yaz_log(YLOG_LOG, "elementUpdate");
626 case Z_IUOriginPartToKeep_specialUpdate:
627 yaz_log(YLOG_LOG, "specialUpdate");
629 case Z_ESAdminOriginPartToKeep_shutdown:
630 yaz_log(YLOG_LOG, "shutDown");
632 case Z_ESAdminOriginPartToKeep_start:
633 yaz_log(YLOG_LOG, "start");
636 yaz_log(YLOG_LOG, " unknown (" ODR_INT_PRINTF ")",
640 if (toKeep->databaseName)
642 yaz_log(YLOG_LOG, "database: %s", toKeep->databaseName);
644 if (zebra_select_database(zh, toKeep->databaseName))
649 yaz_log(YLOG_WARN, "no database supplied for ES Update");
651 YAZ_BIB1_ES_MISSING_MANDATORY_PARAMETER_FOR_SPECIFIED_FUNCTION_;
652 rr->errstring = "database";
655 if (zebra_begin_trans(zh, 1) != ZEBRA_OK)
657 zebra_result(zh, &rr->errcode, &rr->errstring);
662 for (i = 0; notToKeep && i < notToKeep->num; i++)
664 Z_External *rec = notToKeep->elements[i]->record;
665 Odr_oct *opaque_recid = 0;
669 if (notToKeep->elements[i]->u.opaque)
671 switch(notToKeep->elements[i]->which)
673 case Z_IUSuppliedRecords_elem_opaque:
674 opaque_recid = notToKeep->elements[i]->u.opaque;
675 break; /* OK, recid already set */
676 case Z_IUSuppliedRecords_elem_number:
677 sysno_tmp = *notToKeep->elements[i]->u.number;
682 if (rec->direct_reference)
684 char oid_name_str[OID_STR_MAX];
685 const char *oid_name =
686 yaz_oid_to_string_buf(
687 rec->direct_reference,
690 yaz_log(YLOG_LOG, "record %d type %s", i,
695 case Z_External_sutrs:
696 if (rec->u.octet_aligned->len > 170)
697 yaz_log(YLOG_LOG, "%d bytes:\n%.168s ...",
701 yaz_log(YLOG_LOG, "%d bytes:\n%s",
705 case Z_External_octet:
706 if (rec->u.octet_aligned->len > 170)
707 yaz_log(YLOG_LOG, "%d bytes:\n%.168s ...",
708 rec->u.octet_aligned->len,
709 rec->u.octet_aligned->buf);
711 yaz_log(YLOG_LOG, "%d bytes\n%s",
712 rec->u.octet_aligned->len,
713 rec->u.octet_aligned->buf);
715 if (rec->which == Z_External_octet)
717 enum zebra_recctrl_action_t action = action_update;
719 const char *match_criteria = 0;
722 if (*toKeep->action ==
723 Z_IUOriginPartToKeep_recordInsert)
724 action = action_insert;
725 else if (*toKeep->action ==
726 Z_IUOriginPartToKeep_recordReplace)
727 action = action_replace;
728 else if (*toKeep->action ==
729 Z_IUOriginPartToKeep_recordDelete)
730 action = action_delete;
731 else if (*toKeep->action ==
732 Z_IUOriginPartToKeep_specialUpdate)
733 action = action_update;
737 YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
738 rr->errstring = "unsupported ES Update action";
744 size_t l = opaque_recid->len;
745 if (l >= sizeof(recid_str))
747 rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
748 rr->errstring = "opaque record ID too large";
751 memcpy(recid_str, opaque_recid->buf, l);
753 match_criteria = recid_str;
755 res = zebra_update_record(
758 sysno, match_criteria, 0, /* fname */
759 (const char *) rec->u.octet_aligned->buf,
760 rec->u.octet_aligned->len);
761 if (res == ZEBRA_FAIL)
764 YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
765 rr->errstring = "update_record failed";
769 if (zebra_end_trans(zh) != ZEBRA_OK)
771 yaz_log(YLOG_WARN, "zebra_end_trans failed for"
772 " extended service operation");
779 yaz_log(YLOG_WARN, "Unknown Extended Service(%d)",
780 rr->esr->taskSpecificParameters->which);
781 rr->errcode = YAZ_BIB1_ES_EXTENDED_SERVICE_TYPE_UNSUPP;
787 static void bend_start(struct statserv_options_block *sob)
789 Res default_res = res_open(0, 0);
792 zebra_stop((ZebraService) sob->handle);
793 res_set(default_res, "profilePath", DEFAULT_PROFILE_PATH);
794 res_set(default_res, "modulePath", DEFAULT_MODULE_PATH);
795 sob->handle = zebra_start_res(sob->configname, default_res, 0);
796 res_close(default_res);
799 yaz_log(YLOG_FATAL, "Failed to read config `%s'", sob->configname);
805 if (!sob->inetd && !sob->background)
811 zebra_pidfname(sob->handle, pidfname);
813 fd = open(pidfname, O_EXCL|O_WRONLY|O_CREAT, 0666);
818 yaz_log(YLOG_FATAL|YLOG_ERRNO, "lock file %s", pidfname);
821 fd = open(pidfname, O_RDWR, 0666);
824 yaz_log(YLOG_FATAL|YLOG_ERRNO, "lock file %s", pidfname);
828 area.l_type = F_WRLCK;
829 area.l_whence = SEEK_SET;
830 area.l_len = area.l_start = 0L;
831 if (fcntl(fd, F_SETLK, &area) == -1)
833 yaz_log(YLOG_ERRNO|YLOG_FATAL, "Zebra server already running");
840 sprintf(pidstr, "%ld", (long) getpid());
841 if (write(fd, pidstr, strlen(pidstr)) != strlen(pidstr))
843 yaz_log(YLOG_ERRNO|YLOG_FATAL, "write fail %s", pidfname);
851 static void bend_stop(struct statserv_options_block *sob)
856 if (!sob->inetd && !sob->background && sob->handle)
859 zebra_pidfname(sob->handle, pidfname);
865 ZebraService service = sob->handle;
870 int main(int argc, char **argv)
872 struct statserv_options_block *sob;
874 sob = statserv_getcontrol();
875 strcpy(sob->configname, "zebra.cfg");
876 sob->bend_start = bend_start;
877 sob->bend_stop = bend_stop;
879 strcpy(sob->service_name, "zebrasrv");
880 strcpy(sob->service_display_name, "Zebra Server");
882 statserv_setcontrol(sob);
884 return statserv_main(argc, argv, bend_init, bend_close);
889 * c-file-style: "Stroustrup"
890 * indent-tabs-mode: nil
892 * vim: shiftwidth=4 tabstop=8 expandtab