41long scanItemList(
unsigned long *flags,
char **item,
long *items,
unsigned long mode, ...)
44 long i, j, type, flag, retval, length, number, match;
47 static char **valueptr = NULL;
48 static long *keylength = NULL;
49 static short *item_matched = NULL, *has_equals = NULL;
50 static long maxitems = 0;
53 return bombre(
"null flags pointer seen (scanItemList)", NULL, 0);
55 return bombre(
"null item pointer seen (scanItemList)", NULL, 0);
57 return bombre(
"null items pointer seen (scanItemList)", NULL, 0);
62 if (*items > maxitems) {
63 valueptr =
trealloc(valueptr,
sizeof(*valueptr) * (maxitems = *items));
64 keylength =
trealloc(keylength,
sizeof(*keylength) * maxitems);
65 item_matched =
trealloc(item_matched,
sizeof(*item_matched) * maxitems);
66 has_equals =
trealloc(has_equals,
sizeof(*has_equals) * maxitems);
69 for (i = 0; i < *items; i++) {
72 fprintf(stderr,
"item %ld: %s\n", i, item[i]);
74 if ((valueptr[i] = strchr(item[i],
'='))) {
75 if ((keylength[i] = valueptr[i] - item[i]) <= 0)
76 return bombre(
"zero-length keyword seen (scanItemList)", NULL, 0);
80 keylength[i] = strlen(item[i]);
85 fprintf(stderr,
" keyword: %s valueptr: %s\n", item[i], valueptr[i]);
89 va_start(argptr, mode);
92 if (!(keyword = va_arg(argptr,
char *)))
94 type = va_arg(argptr, int32_t);
95 data = va_arg(argptr,
void *);
96 number = va_arg(argptr, int32_t);
97 flag = va_arg(argptr, uint32_t);
98 length = strlen(keyword);
100 for (i = 0; i < *items; i++)
103 fprintf(stderr,
"ambiguous item %s seen\n", keyword);
110 fprintf(stderr,
"keyword %s and item %ld (%s) match\n", keyword, match, item[match]);
112 fprintf(stderr,
"no match for keyword %s\n", keyword);
118 if (!has_equals[match] && number && mode & SCANITEMLIST_IGNORE_VALUELESS)
120 if (item_matched[match]) {
121 fprintf(stderr,
"error: ambiguous qualifier %s seen\n", item[match]);
125 item_matched[match] = 1;
127 if (!valueptr[match]) {
130 fprintf(stderr,
"error: value not given for %s\n", keyword);
137 fprintf(stderr,
"error: SDDS_LONGDOUBLE is not supported on vxWorks yet\n");
140 *((
long double *)data) = (
long double)strtold(valueptr[match], NULL);
144 *((
double *)data) = atof(valueptr[match]);
147 *((
float *)data) = (float)atof(valueptr[match]);
151 epicsParseInt64(valueptr[match], (int64_t *)data, 10, NULL);
153 *((int64_t *)data) = (uint64_t)atoll(valueptr[match]);
157 *((uint64_t *)data) = (uint64_t)strtoull(valueptr[match], NULL, 10);
160 *((int32_t *)data) = (int32_t)atol(valueptr[match]);
163 *((uint32_t *)data) = (uint32_t)strtoul(valueptr[match], NULL, 10);
166 *((
short *)data) = (short)atol(valueptr[match]);
169 *((
unsigned short *)data) = (
unsigned short)atol(valueptr[match]);
172 cp_str((
char **)data, valueptr[match]);
175 *((
char *)data) = valueptr[match][0];
178 fprintf(stderr,
"Error: value not accepted for qualifier %s\n",
182 }
while (retval == 1);
184 for (i = 0; i < *items; i++) {
185 if (!item_matched[i]) {
186 if (!has_equals[i] && mode & SCANITEMLIST_UNKNOWN_VALUE_OK)
188 if (has_equals[i] && mode & SCANITEMLIST_UNKNOWN_KEYVALUE_OK)
190 fprintf(stderr,
"unknown keyword/value given: %s\n", item[i]);
194 if (mode & SCANITEMLIST_REMOVE_USED_ITEMS) {
195 for (i = j = 0; i < *items; i++) {
196 if (!item_matched[i]) {
226long scanItemListLong(
unsigned long long *flags,
char **item,
long *items,
unsigned long mode, ...)
229 long i, j, type, retval, length, number, match;
233 static char **valueptr = NULL;
234 static long *keylength = NULL;
235 static short *item_matched = NULL, *has_equals = NULL;
236 static long maxitems = 0;
239 return bombre(
"null flags pointer seen (scanItemList)", NULL, 0);
241 return bombre(
"null item pointer seen (scanItemList)", NULL, 0);
243 return bombre(
"null items pointer seen (scanItemList)", NULL, 0);
248 if (*items > maxitems) {
249 valueptr =
trealloc(valueptr,
sizeof(*valueptr) * (maxitems = *items));
250 keylength =
trealloc(keylength,
sizeof(*keylength) * maxitems);
251 item_matched =
trealloc(item_matched,
sizeof(*item_matched) * maxitems);
252 has_equals =
trealloc(has_equals,
sizeof(*has_equals) * maxitems);
255 for (i = 0; i < *items; i++) {
258 fprintf(stderr,
"item %ld: %s\n", i, item[i]);
260 if ((valueptr[i] = strchr(item[i],
'='))) {
261 if ((keylength[i] = valueptr[i] - item[i]) <= 0)
262 return bombre(
"zero-length keyword seen (scanItemList)", NULL, 0);
266 keylength[i] = strlen(item[i]);
271 fprintf(stderr,
" keyword: %s valueptr: %s\n", item[i], valueptr[i]);
275 va_start(argptr, mode);
278 if (!(keyword = va_arg(argptr,
char *)))
280 type = va_arg(argptr, int32_t);
281 data = va_arg(argptr,
void *);
282 number = va_arg(argptr, int32_t);
283 flag = va_arg(argptr, uint64_t);
284 length = strlen(keyword);
286 for (i = 0; i < *items; i++)
289 fprintf(stderr,
"ambiguous item %s seen\n", keyword);
296 fprintf(stderr,
"keyword %s and item %ld (%s) match\n", keyword, match, item[match]);
298 fprintf(stderr,
"no match for keyword %s\n", keyword);
304 if (!has_equals[match] && number && mode & SCANITEMLIST_IGNORE_VALUELESS)
306 if (item_matched[match]) {
307 fprintf(stderr,
"error: ambiguous qualifier %s seen\n", item[match]);
311 item_matched[match] = 1;
313 if (!valueptr[match]) {
316 fprintf(stderr,
"error: value not given for %s\n", keyword);
322 *((
double *)data) = atof(valueptr[match]);
325 *((
float *)data) = (float)atof(valueptr[match]);
328 *((int32_t *)data) = atol(valueptr[match]);
332 *((uint32_t *)data) = (uint32_t)_atoi64(valueptr[match]);
335 epicsParseUInt32(valueptr[match], (uint32_t *)data, 10, NULL);
337 *((uint32_t *)data) = (uint32_t)atoll(valueptr[match]);
342 *((
short *)data) = (short)atol(valueptr[match]);
345 *((
unsigned short *)data) = (
unsigned short)atol(valueptr[match]);
348 cp_str((
char **)data, valueptr[match]);
351 *((
char *)data) = valueptr[match][0];
354 fprintf(stderr,
"Error: value not accepted for qualifier %s\n",
358 }
while (retval == 1);
360 for (i = 0; i < *items; i++) {
361 if (!item_matched[i]) {
362 if (!has_equals[i] && mode & SCANITEMLIST_UNKNOWN_VALUE_OK)
364 if (has_equals[i] && mode & SCANITEMLIST_UNKNOWN_KEYVALUE_OK)
366 fprintf(stderr,
"unknown keyword/value given: %s\n", item[i]);
370 if (mode & SCANITEMLIST_REMOVE_USED_ITEMS) {
371 for (i = j = 0; i < *items; i++) {
372 if (!item_matched[i]) {
403 long i, j, type, flag, retval, length, match;
407 static char **valueptr = NULL;
408 static long *keylength = NULL, *item_matched = NULL;
409 static long maxitems = 0;
412 return bombre(
"null flags pointer seen (scan_item_list)", NULL, 0);
414 return bombre(
"null item pointer seen (scan_item_list)", NULL, 0);
416 return bombre(
"null items pointer seen (scan_item_list)", NULL, 0);
421 if (*items > maxitems) {
422 valueptr =
trealloc(valueptr,
sizeof(*valueptr) * (maxitems = *items));
423 keylength =
trealloc(keylength,
sizeof(*keylength) * maxitems);
424 item_matched =
trealloc(item_matched,
sizeof(*item_matched) * maxitems);
427 for (i = 0; i < *items; i++) {
430 fprintf(stderr,
"item %ld: %s\n", i, item[i]);
432 if ((valueptr[i] = strchr(item[i],
'='))) {
433 if ((keylength[i] = valueptr[i] - item[i]) <= 0)
434 return bombre(
"zero-length keyword seen (scan_item_list)", NULL, 0);
437 keylength[i] = strlen(item[i]);
439 fprintf(stderr,
" keyword: %s valueptr: %s\n", item[i], valueptr[i]);
443 va_start(argptr, items);
446 if (!(keyword = va_arg(argptr,
char *)))
448 type = va_arg(argptr, int32_t);
449 data = va_arg(argptr,
void *);
451 va_arg(argptr, int32_t);
452 flag = va_arg(argptr, uint32_t);
453 length = strlen(keyword);
455 for (i = 0; i < *items; i++)
458 fprintf(stderr,
"ambiguous item %s seen\n", keyword);
465 fprintf(stderr,
"keyword %s and item %ld (%s) match\n", keyword, match, item[match]);
467 fprintf(stderr,
"no match for keyword %s\n", keyword);
473 if (item_matched[match]) {
474 fprintf(stderr,
"error: ambiguous qualifier %s seen\n", item[match]);
478 item_matched[match] = 1;
480 if (!valueptr[match]) {
483 fprintf(stderr,
"error: value not given for %s\n", keyword);
489 *((
double *)data) = atof(valueptr[match]);
492 *((
float *)data) = (float)atof(valueptr[match]);
495 *((int32_t *)data) = atol(valueptr[match]);
499 *((uint32_t *)data) = (uint32_t)_atoi64(valueptr[match]);
502 epicsParseUInt32(valueptr[match], (uint32_t *)data, 10, NULL);
504 *((uint32_t *)data) = (uint32_t)atoll(valueptr[match]);
509 *((
short *)data) = (short)atol(valueptr[match]);
512 *((
unsigned short *)data) = (
unsigned short)atol(valueptr[match]);
515 cp_str((
char **)data, valueptr[match]);
518 *((
char *)data) = valueptr[match][0];
521 fprintf(stderr,
"Error: value not accepted for qualifier %s\n", item[match]);
526 for (j = match; j < *items; j++) {
527 item[j] = item[j + 1];
528 valueptr[j] = valueptr[j + 1];
529 keylength[j] = keylength[j + 1];
531 }
while (retval == 1 && *items);
long scanItemListLong(unsigned long long *flags, char **item, long *items, unsigned long mode,...)
Scans a list of items with extended flag support and assigns values based on provided keywords and ty...
long scanItemList(unsigned long *flags, char **item, long *items, unsigned long mode,...)
Scans a list of items and assigns values based on provided keywords and types.
long scan_item_list(unsigned long *flags, char **item, long *items,...)
Scans a list of items without flag extension and assigns values based on provided keywords and types.