X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Finitopt.c;h=01fbd5771a19f0648ac6e7aa300c381c745b75e2;hp=a0eef33e7c29e6a8b1495de6249b6b33368addc0;hb=01e36a11adc97a240cc595f89280c8a619770251;hpb=6d9e8305bb173398dc9b886070a72b40618304ca diff --git a/src/initopt.c b/src/initopt.c index a0eef33..01fbd57 100644 --- a/src/initopt.c +++ b/src/initopt.c @@ -1,8 +1,11 @@ -/* - * Copyright (c) 1995-2004, Index Data +/* This file is part of the YAZ toolkit. + * Copyright (C) Index Data * See the file LICENSE for details. - * - * $Id: initopt.c,v 1.1 2004-01-12 12:11:57 adam Exp $ + */ + +/** + * \file initopt.c + * \brief Implements Z39.50 Init Options Utility */ #if HAVE_CONFIG_H @@ -42,46 +45,57 @@ static struct { int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos) { const char *cp = opt_str; - + ODR_MASK_ZERO(opt); while (*cp) { - char this_opt[20]; - int i, j; - if (*cp == ' ' || *cp == ',') - { - cp++; - continue; - } - for (i = 0; i < (sizeof(this_opt)-1) && - cp[i] && cp[i] != ' ' && cp[i] != ','; i++) - this_opt[i] = cp[i]; - this_opt[i] = 0; - for (j = 0; opt_array[j].name; j++) - { - if (yaz_matchstr(this_opt, opt_array[j].name) == 0) - { - ODR_MASK_SET(opt, opt_array[j].opt); - break; - } - } - if (!opt_array[j].name) - { - if (error_pos) - { - *error_pos = cp - opt_str; - return -1; - } - } - cp += i; + char this_opt[42]; + size_t i, j; + if (*cp == ' ' || *cp == ',') + { + cp++; + continue; + } + for (i = 0; i < (sizeof(this_opt)-1) && + cp[i] && cp[i] != ' ' && cp[i] != ','; i++) + this_opt[i] = cp[i]; + this_opt[i] = 0; + for (j = 0; opt_array[j].name; j++) + { + if (yaz_matchstr(this_opt, opt_array[j].name) == 0) + { + ODR_MASK_SET(opt, opt_array[j].opt); + break; + } + } + if (!opt_array[j].name) + { + if (error_pos) + { + *error_pos = cp - opt_str; + return -1; + } + } + cp += i; } return 0; } -void yaz_init_opt_decode(Z_Options *opt, void (*pr)(const char *name)) +void yaz_init_opt_decode(Z_Options *opt, void (*pr)(const char *name, + void *clientData), + void *clientData) { int i; for (i = 0; opt_array[i].name; i++) - if (ODR_MASK_GET(opt, opt_array[i].opt)) - (*pr)(opt_array[i].name); + if (ODR_MASK_GET(opt, opt_array[i].opt)) + (*pr)(opt_array[i].name, clientData); } +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +