YAZ 5.35.1
initopt.c
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
4 */
5
11#if HAVE_CONFIG_H
12#include <config.h>
13#endif
14
15#include <yaz/proto.h>
16
17static struct {
18 char *name;
19 int opt;
20} opt_array[] = {
21 {"search", Z_Options_search},
22 {"present", Z_Options_present},
23 {"delSet", Z_Options_delSet},
24 {"resourceReport", Z_Options_resourceReport},
25 {"triggerResourceCtrl", Z_Options_triggerResourceCtrl},
26 {"resourceCtrl", Z_Options_resourceCtrl},
27 {"accessCtrl", Z_Options_accessCtrl},
28 {"scan", Z_Options_scan},
29 {"sort", Z_Options_sort},
30 {"extendedServices", Z_Options_extendedServices},
31 {"level_1Segmentation", Z_Options_level_1Segmentation},
32 {"level_2Segmentation", Z_Options_level_2Segmentation},
33 {"concurrentOperations", Z_Options_concurrentOperations},
34 {"namedResultSets", Z_Options_namedResultSets},
35 {"encapsulation", Z_Options_encapsulation},
36 {"resultCount", Z_Options_resultCount},
37 {"negotiationModel", Z_Options_negotiationModel},
38 {"duplicationDetection", Z_Options_duplicateDetection},
39 {"queryType104", Z_Options_queryType104},
40 {"pQESCorrection", Z_Options_pQESCorrection},
41 {"stringSchema", Z_Options_stringSchema},
42 {0, 0}
43};
44
45int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos)
46{
47 const char *cp = opt_str;
48
50 while (*cp)
51 {
52 char this_opt[42];
53 size_t i, j;
54 if (*cp == ' ' || *cp == ',')
55 {
56 cp++;
57 continue;
58 }
59 for (i = 0; i < (sizeof(this_opt)-1) &&
60 cp[i] && cp[i] != ' ' && cp[i] != ','; i++)
61 this_opt[i] = cp[i];
62 this_opt[i] = 0;
63 for (j = 0; opt_array[j].name; j++)
64 {
65 if (yaz_matchstr(this_opt, opt_array[j].name) == 0)
66 {
68 break;
69 }
70 }
71 if (!opt_array[j].name)
72 {
73 if (error_pos)
74 {
75 *error_pos = cp - opt_str;
76 return -1;
77 }
78 }
79 cp += i;
80 }
81 return 0;
82}
83
84void yaz_init_opt_decode(Z_Options *opt, void (*pr)(const char *name,
85 void *clientData),
86 void *clientData)
87{
88 int i;
89 for (i = 0; opt_array[i].name; i++)
91 (*pr)(opt_array[i].name, clientData);
92}
93/*
94 * Local variables:
95 * c-basic-offset: 4
96 * c-file-style: "Stroustrup"
97 * indent-tabs-mode: nil
98 * End:
99 * vim: shiftwidth=4 tabstop=8 expandtab
100 */
101
int opt
Definition initopt.c:19
void yaz_init_opt_decode(Z_Options *opt, void(*pr)(const char *name, void *clientData), void *clientData)
Decodes Z39.50 Init Options - for printing.
Definition initopt.c:84
char * name
Definition initopt.c:18
int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos)
Encodes Z39.50 Init OPtions based on string mnemonics.
Definition initopt.c:45
static struct @2 opt_array[]
int yaz_matchstr(const char *s1, const char *s2)
match strings - independent of case and '-'
Definition matchstr.c:42
#define ODR_MASK_SET(mask, num)
Definition odr.h:204
#define ODR_MASK_ZERO(mask)
Definition odr.h:200
#define ODR_MASK_GET(mask, num)
Definition odr.h:211
Header for Z39.50 Protocol.
#define Z_Options_extendedServices
Definition z-core.h:438
#define Z_Options_resourceReport
Definition z-core.h:432
#define Z_Options_sort
Definition z-core.h:437
#define Z_Options_triggerResourceCtrl
Definition z-core.h:433
#define Z_Options_pQESCorrection
Definition z-core.h:448
#define Z_Options_stringSchema
Definition z-core.h:449
#define Z_Options_delSet
Definition z-core.h:431
#define Z_Options_present
Definition z-core.h:430
#define Z_Options_encapsulation
Definition z-core.h:443
#define Z_Options_level_1Segmentation
Definition z-core.h:439
#define Z_Options_search
Definition z-core.h:429
#define Z_Options_negotiationModel
Definition z-core.h:445
#define Z_Options_scan
Definition z-core.h:436
#define Z_Options_resultCount
Definition z-core.h:444
#define Z_Options_concurrentOperations
Definition z-core.h:441
#define Z_Options_resourceCtrl
Definition z-core.h:434
#define Z_Options_duplicateDetection
Definition z-core.h:446
#define Z_Options_accessCtrl
Definition z-core.h:435
#define Z_Options_level_2Segmentation
Definition z-core.h:440
#define Z_Options_namedResultSets
Definition z-core.h:442
#define Z_Options_queryType104
Definition z-core.h:447