00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 #include <soi_key.h>
00083 #include <soi_error.h>
00084 #include "SUM.h"
00085
00086 #define VERSION_NUM (4.5)
00087
00088 int kludge = 2;
00089
00090 KEY *newkeylist () {
00091 return NULL;
00092 }
00093
00094 void freekeylist (KEY **list) {
00095 KEY *node;
00096 while (*list) {
00097 free ((*list)->name);
00098 free ((*list)->val);
00099 node = *list;
00100 *list = (*list)->next;
00101 free (node);
00102 }
00103 }
00104
00105 KEY *findkey (KEY *list, char *key) {
00106 KEY *walker = list;
00107
00108 soi_errno = NO_ERROR;
00109 if (!key) {
00110 soi_errno = KEY_NOT_FOUND;
00111 return NULL;
00112 }
00113 while (walker) {
00114 if (strcmp (walker->name, key))
00115 walker = walker->next;
00116 else
00117 return walker;
00118 }
00119 soi_errno = KEY_NOT_FOUND;
00120 return walker;
00121 }
00122
00123 char *key_strdup (char *s) {
00124 char *duped;
00125
00126 if (!s) return NULL;
00127 duped = (char *)malloc (kludge*(strlen (s) + 1));
00128 strcpy (duped, s);
00129 return duped;
00130 }
00131
00132 void getkey_any (KEY *list, char *key, void *valptr) {
00133
00134
00135
00136 KEY *the_one = findkey (list, key);
00137 if (the_one)
00138 if (the_one->type == KEYTYP_STRING)
00139 *(char **)valptr = key_strdup(the_one->val);
00140 else if (the_one->type == KEYTYP_FILEP)
00142 *(FILE **)valptr = *(FILE **)the_one->val;
00143 else if (the_one->type == KEYTYP_DOUBLE)
00144 *(double *)valptr = *(double *)the_one->val;
00145 else if (the_one->type == KEYTYP_FLOAT)
00146 *(float *)valptr = *(float *)the_one->val;
00147 else if (the_one->type == KEYTYP_INT)
00148 *(int *)valptr = *(int *)the_one->val;
00149 else if (the_one->type == KEYTYP_SHORT)
00150 *(short *)valptr = *(short *)the_one->val;
00151 else if (the_one->type == KEYTYP_BYTE)
00152 *(signed char *)valptr = *(signed char *)the_one->val;
00153 else if (the_one->type == KEYTYP_LONG)
00154 *(long *)valptr = *(long *)the_one->val;
00155 else if (the_one->type == KEYTYP_UINT)
00156 *(unsigned int *)valptr = *(unsigned int *)the_one->val;
00157 else if (the_one->type == KEYTYP_USHORT)
00158 *(unsigned short *)valptr = *(unsigned short *)the_one->val;
00159 else if (the_one->type == KEYTYP_UBYTE)
00160 *(unsigned char *)valptr = *(unsigned char *)the_one->val;
00161 else if (the_one->type == KEYTYP_ULONG)
00162 *(unsigned long *)valptr = *(unsigned long *)the_one->val;
00163 else if (the_one->type == KEYTYP_UINT64)
00164 *(uint64_t *)valptr = *(uint64_t *)the_one->val;
00165 else if (the_one->type == KEYTYP_UINT32)
00166 *(uint32_t *)valptr = *(uint32_t *)the_one->val;
00167 else
00168 soi_errno = KEY_WRONG_TYPE;
00169 else
00170 soi_errno = KEY_NOT_FOUND;
00171 }
00172
00173 void setkey_any (KEY **list, char *key, void *val, int type) {
00174
00175 KEY *the_one;
00176 KEY *new_one;
00177
00178 if (!key) return;
00179 if (!val) return;
00180
00181 the_one = findkey (*list, key);
00182 soi_errno = NO_ERROR;
00183 if (the_one) {
00184 free (the_one->val);
00185 }
00186 else {
00187 new_one = (KEY *)malloc (kludge*sizeof (KEY));
00188 new_one->next = *list;
00189 new_one->name = key_strdup (key);
00190 *list = new_one;
00191 the_one = new_one;
00192 }
00193 the_one->type = type;
00194 switch (type) {
00195 case KEYTYP_STRING:
00196 the_one->val = key_strdup (val);
00197 break;
00198 case KEYTYP_BYTE:
00199 the_one->val = (signed char *)malloc (kludge*1);
00200 *(signed char *)the_one->val = *(signed char *)val;
00201 break;
00202 case KEYTYP_UBYTE:
00203 the_one->val = (char *)malloc (kludge*1);
00204 *(unsigned char *)the_one->val = *(unsigned char *)val;
00205 break;
00206 case KEYTYP_SHORT:
00207 the_one->val = (short *)malloc (kludge*sizeof (short));
00208 *(short *)the_one->val = *(short *)val;
00209 break;
00210 case KEYTYP_USHORT:
00211 the_one->val =
00212 (unsigned short *)malloc (kludge*sizeof (unsigned short));
00213 *(unsigned short *)the_one->val = *(unsigned short *)val;
00214 break;
00215 case KEYTYP_INT:
00216 the_one->val = (int *)malloc (kludge*sizeof (int));
00217 *(int *)the_one->val = *(int *)val;
00218 break;
00219 case KEYTYP_UINT:
00220 the_one->val = (unsigned int *)malloc (kludge*sizeof (unsigned int));
00221 *(unsigned int *)the_one->val = *(unsigned int *)val;
00222 break;
00223 case KEYTYP_LONG:
00224 the_one->val = (long *)malloc (kludge*sizeof (long));
00225 *(long *)the_one->val = *(long *)val;
00226 break;
00227 case KEYTYP_ULONG:
00228 the_one->val =
00229 (unsigned long *)malloc (kludge*sizeof (unsigned long));
00230 *(unsigned long *)the_one->val = *(unsigned long *)val;
00231 break;
00232 case KEYTYP_UINT64:
00233 the_one->val = (uint64_t *)malloc (kludge*sizeof (uint64_t));
00234 *(uint64_t *)the_one->val = *(uint64_t *)val;
00235 break;
00236 case KEYTYP_UINT32:
00237 the_one->val = (uint32_t *)malloc (kludge*sizeof (uint32_t));
00238 *(uint32_t *)the_one->val = *(uint32_t *)val;
00239 break;
00240 case KEYTYP_FLOAT:
00241 the_one->val = (float *)malloc (kludge*sizeof (float));
00242 *(float *)the_one->val = *(float *)val;
00243 break;
00244 case KEYTYP_DOUBLE:
00245 the_one->val = (double *)malloc (kludge*sizeof (double));
00246 *(double *)the_one->val = *(double *)val;
00247 break;
00248 case KEYTYP_FILEP:
00250 the_one->val = (FILE **)malloc (kludge*sizeof (FILE *));
00251 *(FILE **)the_one->val = (FILE *)val;
00252 break;
00253 case KEYTYP_TIME:
00254 the_one->val = (TIME *)malloc (kludge*sizeof (TIME));
00255 *(TIME *)the_one->val = *(TIME *)val;
00256 break;
00257 default:
00258
00259 soi_errno = KEYTYPE_NOT_IMPLEMENTED;
00260 break;
00261 }
00262 }
00263
00264 void addkey (KEY **list, char *key, void *val, int type) {
00266 KEY *new_one;
00267
00268 if (!key) return;
00269 if (!val) return;
00270
00271 new_one = (KEY *)malloc (kludge*sizeof (KEY));
00272 new_one->next = *list;
00273 new_one->name = key_strdup (key);
00274 new_one->type = type;
00275 *list = new_one;
00276
00277 switch (type) {
00278 case KEYTYP_STRING:
00279 new_one->val = key_strdup (val);
00280 break;
00281 case KEYTYP_BYTE:
00282 new_one->val = (signed char *)malloc (kludge*1);
00283 *(signed char *)new_one->val = *(signed char *)val;
00284 break;
00285 case KEYTYP_UBYTE:
00286 new_one->val = (char *)malloc (kludge*1);
00287 *(unsigned char *)new_one->val = *(unsigned char *)val;
00288 break;
00289 case KEYTYP_SHORT:
00290 new_one->val = (short *)malloc (kludge*sizeof (short));
00291 *(short *)new_one->val = *(short *)val;
00292 break;
00293 case KEYTYP_USHORT:
00294 new_one->val =
00295 (unsigned short *)malloc (kludge*sizeof (unsigned short));
00296 *(unsigned short *)new_one->val = *(unsigned short *)val;
00297 break;
00298 case KEYTYP_INT:
00299 new_one->val = (int *)malloc (kludge*sizeof (int));
00300 *(int *)new_one->val = *(int *)val;
00301 break;
00302 case KEYTYP_UINT:
00303 new_one->val = (unsigned int *)malloc (kludge*sizeof (unsigned int));
00304 *(unsigned int *)new_one->val = *(unsigned int *)val;
00305 break;
00306 case KEYTYP_LONG:
00307 new_one->val = (long *)malloc (kludge*sizeof (long));
00308 *(long *)new_one->val = *(long *)val;
00309 break;
00310 case KEYTYP_ULONG:
00311 new_one->val =
00312 (unsigned long *)malloc (kludge*sizeof (unsigned long));
00313 *(unsigned long *)new_one->val = *(unsigned long *)val;
00314 break;
00315 case KEYTYP_UINT64:
00316 new_one->val = (uint64_t *)malloc (kludge*sizeof (uint64_t));
00317 *(uint64_t *)new_one->val = *(uint64_t *)val;
00318 break;
00319 case KEYTYP_UINT32:
00320 new_one->val = (uint32_t *)malloc (kludge*sizeof (uint32_t));
00321 *(uint32_t *)new_one->val = *(uint32_t *)val;
00322 break;
00323 case KEYTYP_FLOAT:
00324 new_one->val = (float *)malloc (kludge*sizeof (float));
00325 *(float *)new_one->val = *(float *)val;
00326 break;
00327 case KEYTYP_DOUBLE:
00328 new_one->val = (double *)malloc (kludge*sizeof (double));
00329 *(double *)new_one->val = *(double *)val;
00330 break;
00331 case KEYTYP_FILEP:
00333 new_one->val = (FILE **)malloc (kludge*sizeof (FILE *));
00334 *(FILE **)new_one->val = (FILE *)val;
00335 break;
00336 case KEYTYP_TIME:
00337 new_one->val = (TIME *)malloc (kludge*sizeof (TIME));
00338 *(TIME *)new_one->val = *(TIME *)val;
00339 break;
00340 default:
00341
00342 soi_errno = KEYTYPE_NOT_IMPLEMENTED;
00343 break;
00344 }
00345 }
00346
00347 void deletekey (KEY **list, char *key) {
00348 KEY *walker = *list;
00349 KEY *trailer = NULL;
00350
00351 if (!key) return;
00352
00353 while (walker) {
00354 if (strcmp (walker->name, key)) {
00355 trailer = walker;
00356 walker = walker->next;
00357 } else {
00358 if (trailer)
00359 trailer->next = walker->next;
00360 else
00361 *list = walker->next;
00362 free (walker->name);
00363 free (walker->val);
00364 free (walker);
00365 walker = NULL;
00366 }
00367 }
00368 }
00369
00370
00371 void keyiterate (void (*action)(), KEY *overlist) {
00372 KEY * walker = overlist;
00373 while (walker) {
00374 (*action)(walker);
00375 walker = walker->next;
00376 }
00377 }
00378
00379 int getkeytype (KEY *list, char *key) {
00380 KEY *the_one = findkey (list, key);
00381 if (the_one)
00382 return (the_one->type);
00383 return KEYTYP_VOID;
00384 }
00385
00386 char *GETKEY_str(KEY *params, char *key) {
00387 static char tmp[KEY_MAXSTR];
00388 char *c = getkey_str(params,key);
00389 if (c) {
00390 strcpy(tmp, c);
00391 free(c);
00392 } else
00393 tmp[0] = '\0';
00394 return(tmp);
00395 }
00396
00397 char *getkey_str (KEY *list, char *key) {
00398 KEY *the_one = findkey (list, key);
00399 if (the_one) {
00400 if (the_one->type == KEYTYP_STRING)
00401 return key_strdup (the_one->val);
00402 else
00403 soi_errno = KEY_WRONG_TYPE;
00404 }
00405 return NULL;
00406 }
00407
00408 FILE *getkey_fileptr (KEY *list, char *key) {
00409 KEY *the_one = findkey (list, key);
00410 if (the_one) {
00411 if (the_one->type == KEYTYP_FILEP)
00412 return *(FILE **)(the_one->val);
00413 else
00414 soi_errno = KEY_WRONG_TYPE;
00415 }
00416 return NULL;
00417 }
00418
00419 int getkey_byte (KEY *list, char *key) {
00420 int return_val;
00421 KEY *the_one = findkey (list, key);
00422 if (the_one) {
00423 switch (the_one->type) {
00424 case KEYTYP_BYTE:
00425 return_val = *(signed char *)the_one->val;
00426 return (return_val);
00427 case KEYTYP_UBYTE:
00428 return_val = *(unsigned char *)the_one->val;
00429 return (return_val);
00430 case KEYTYP_SHORT:
00431 return_val = *(short *)the_one->val;
00432 return (return_val);
00433 case KEYTYP_USHORT:
00434 return_val = *(unsigned short *)the_one->val;
00435 return (return_val);
00436 case KEYTYP_INT:
00437 return_val = *(int *)the_one->val;
00438 return (return_val);
00439 default:
00440 soi_errno = KEY_WRONG_TYPE;
00441 }
00442 }
00443 return INT_MIN;
00444 }
00445
00446 int getkey_ubyte (KEY *list, char *key) {
00447 int return_val;
00448 KEY *the_one = findkey (list, key);
00449 if (the_one)
00450 switch (the_one->type) {
00451 case KEYTYP_UBYTE:
00452 return_val = *(unsigned char *)the_one->val;
00453 return (return_val);
00454 case KEYTYP_BYTE:
00455 return_val = *(signed char *)the_one->val;
00456 if (return_val >= 0)
00457 return (return_val);
00458 else
00459 soi_errno = KEY_WRONG_TYPE;
00460 break;
00461 case KEYTYP_SHORT:
00462 return_val = *(short *)the_one->val;
00463 if (return_val >= 0)
00464 return (return_val);
00465 else
00466 soi_errno = KEY_WRONG_TYPE;
00467 break;
00468 case KEYTYP_USHORT:
00469 return_val = *(unsigned short *)the_one->val;
00470 return (return_val);
00471 case KEYTYP_INT:
00472 return_val = *(int *)the_one->val;
00473 if (return_val >= 0)
00474 return (return_val);
00475 else
00476 soi_errno = KEY_WRONG_TYPE;
00477 break;
00478 default:
00479 soi_errno = KEY_WRONG_TYPE;
00480 }
00481 return INT_MIN;
00482 }
00483
00484 int getkey_short (KEY *list, char *key) {
00485 int return_val;
00486 KEY *the_one = findkey (list, key);
00487 if (the_one)
00488 switch (the_one->type) {
00489 case KEYTYP_SHORT:
00490 return_val = *(short *)the_one->val;
00491 return (return_val);
00492 case KEYTYP_BYTE:
00493 return_val = *(signed char *)the_one->val;
00494 return (return_val);
00495 case KEYTYP_UBYTE:
00496 return_val = *(unsigned char *)the_one->val;
00497 return (return_val);
00498 case KEYTYP_USHORT:
00499 return_val = *(unsigned short *)the_one->val;
00500 return (return_val);
00501 case KEYTYP_INT:
00502 return_val = *(int *)the_one->val;
00503 return (return_val);
00504 default:
00505 soi_errno = KEY_WRONG_TYPE;
00506 }
00507 return INT_MIN;
00508 }
00509
00510 int getkey_ushort (KEY *list, char *key) {
00511 int return_val;
00512 KEY *the_one = findkey (list, key);
00513 soi_errno = NO_ERROR;
00514 if (the_one)
00515 switch (the_one->type) {
00516 case KEYTYP_USHORT:
00517 return_val = *(unsigned short *)the_one->val;
00518 return (return_val);
00519 case KEYTYP_BYTE:
00520 return_val = *(signed char *)the_one->val;
00521 if (return_val >= 0)
00522 return (return_val);
00523 else
00524 soi_errno = KEY_WRONG_TYPE;
00525 break;
00526 case KEYTYP_UBYTE:
00527 return_val = *(unsigned char *)the_one->val;
00528 return (return_val);
00529 case KEYTYP_SHORT:
00530 return_val = *(short *)the_one->val;
00531 if (return_val >= 0)
00532 return (return_val);
00533 else
00534 soi_errno = KEY_WRONG_TYPE;
00535 break;
00536 case KEYTYP_INT:
00537 return_val = *(int *)the_one->val;
00538 if (return_val >= 0)
00539 return (return_val);
00540 else
00541 soi_errno = KEY_WRONG_TYPE;
00542 break;
00543 default:
00544 soi_errno = KEY_WRONG_TYPE;
00545 }
00546 return INT_MIN;
00547 }
00548
00549 int getkey_int (KEY *list, char *key) {
00550 int return_val;
00551 KEY *the_one = findkey (list, key);
00552 if (the_one)
00553 switch (the_one->type) {
00554 case KEYTYP_INT:
00555 return_val = *(int *)the_one->val;
00556 return (return_val);
00557 case KEYTYP_BYTE:
00558 return_val = *(signed char *)the_one->val;
00559 return (return_val);
00560 case KEYTYP_UBYTE:
00561 return_val = *(unsigned char *)the_one->val;
00562 return (return_val);
00563 case KEYTYP_SHORT:
00564 return_val = *(short *)the_one->val;
00565 return (return_val);
00566 case KEYTYP_USHORT:
00567 return_val = *(unsigned short *)the_one->val;
00568 return (return_val);
00569 default:
00570 soi_errno = KEY_WRONG_TYPE;
00571 }
00572 return INT_MIN;
00573 }
00574
00575 unsigned int getkey_uint (KEY *list, char *key) {
00576 unsigned int return_val;
00577 int int_val;
00578 KEY *the_one = findkey (list, key);
00579 if (the_one)
00580 switch (the_one->type) {
00581 case KEYTYP_UINT:
00582 return_val = *(unsigned int *)the_one->val;
00583 return (return_val);
00584 case KEYTYP_BYTE:
00585 int_val = *(signed char *)the_one->val;
00586 if (int_val >= 0)
00587 return (return_val=int_val);
00588 else
00589 soi_errno = KEY_WRONG_TYPE;
00590 break;
00591 case KEYTYP_UBYTE:
00592 return_val = *(unsigned char *)the_one->val;
00593 return (return_val);
00594 case KEYTYP_SHORT:
00595 int_val = *(short *)the_one->val;
00596 if (int_val >= 0)
00597 return (return_val=int_val);
00598 else
00599 soi_errno = KEY_WRONG_TYPE;
00600 break;
00601 case KEYTYP_USHORT:
00602 return_val = *(unsigned short *)the_one->val;
00603 return (return_val);
00604 case KEYTYP_INT:
00605 int_val = *(int *)the_one->val;
00606 if (int_val >= 0)
00607 return (return_val=int_val);
00608 else
00609 soi_errno = KEY_WRONG_TYPE;
00610 break;
00611 default:
00612 soi_errno = KEY_WRONG_TYPE;
00613 }
00614 return UINT_MAX;
00615 }
00616
00617 int getkey_flag (KEY *list, char *key) {
00618 int return_val;
00619 KEY *the_one = findkey (list, key);
00620 if (the_one)
00621 switch (the_one->type) {
00622 case KEYTYP_BYTE:
00623 return_val = *(signed char *)the_one->val;
00624 return (return_val);
00625 case KEYTYP_UBYTE:
00626 return_val = *(unsigned char *)the_one->val;
00627 return (return_val);
00628 case KEYTYP_SHORT:
00629 return_val = *(short *)the_one->val;
00630 return (return_val);
00631 case KEYTYP_USHORT:
00632 return_val = *(unsigned short *)the_one->val;
00633 return (return_val);
00634 case KEYTYP_INT:
00635 return_val = *(int *)the_one->val;
00636 return (return_val);
00637 default:
00638 soi_errno = KEY_WRONG_TYPE;
00639 }
00640 return INT_MIN;
00641 }
00642
00643 long getkey_long (KEY *list, char *key) {
00644 long return_val;
00645 KEY *the_one = findkey (list, key);
00646 if (the_one)
00647 switch (the_one->type) {
00648 case KEYTYP_LONG:
00649 return_val = *(long *)the_one->val;
00650 return (return_val);
00651 case KEYTYP_BYTE:
00652 return_val = *(signed char *)the_one->val;
00653 return (return_val);
00654 case KEYTYP_UBYTE:
00655 return_val = *(unsigned char *)the_one->val;
00656 return (return_val);
00657 case KEYTYP_SHORT:
00658 return_val = *(short *)the_one->val;
00659 return (return_val);
00660 case KEYTYP_USHORT:
00661 return_val = *(unsigned short *)the_one->val;
00662 return (return_val);
00663 case KEYTYP_INT:
00664 return_val = *(int *)the_one->val;
00665 return (return_val);
00666 case KEYTYP_UINT:
00667 return_val = *(unsigned int *)the_one->val;
00668 return (return_val);
00669 default:
00670 soi_errno = KEY_WRONG_TYPE;
00671 }
00672 return LONG_MIN;
00673 }
00674
00675 unsigned long getkey_ulong (KEY *list, char *key) {
00676 unsigned long return_val;
00677 unsigned long long_val;
00678 KEY *the_one = findkey (list, key);
00679 if (the_one)
00680 switch (the_one->type) {
00681 case KEYTYP_ULONG:
00682 return_val = *(unsigned long *)the_one->val;
00683 return (return_val);
00684 case KEYTYP_BYTE:
00685 long_val = *(signed char *)the_one->val;
00686 if (long_val >= 0)
00687 return (return_val=long_val);
00688 else
00689 soi_errno = KEY_WRONG_TYPE;
00690 break;
00691 case KEYTYP_UBYTE:
00692 return_val = *(unsigned char *)the_one->val;
00693 return (return_val);
00694 case KEYTYP_SHORT:
00695 long_val = *(short *)the_one->val;
00696 if (long_val >= 0)
00697 return (return_val=long_val);
00698 else
00699 soi_errno = KEY_WRONG_TYPE;
00700 break;
00701 case KEYTYP_USHORT:
00702 return_val = *(unsigned short *)the_one->val;
00703 return (return_val);
00704 case KEYTYP_INT:
00705 long_val = *(int *)the_one->val;
00706 if (long_val >= 0)
00707 return (return_val=long_val);
00708 else
00709 soi_errno = KEY_WRONG_TYPE;
00710 break;
00711 case KEYTYP_UINT:
00712 return_val = *(unsigned int *)the_one->val;
00713 return (return_val);
00714 case KEYTYP_LONG:
00715 long_val = *(long *)the_one->val;
00716 if (long_val >= 0)
00717 return (return_val=long_val);
00718 else
00719 soi_errno = KEY_WRONG_TYPE;
00720 break;
00721 default:
00722 soi_errno = KEY_WRONG_TYPE;
00723 }
00724 return ULONG_MAX;
00725 }
00726
00727 uint64_t getkey_uint64 (KEY *list, char *key) {
00728 uint64_t return_val;
00729 KEY *the_one = findkey (list, key);
00730 if (the_one)
00731 switch (the_one->type) {
00732 case KEYTYP_UINT64:
00733 return_val = *(uint64_t *)the_one->val;
00734 return (return_val);
00735 default:
00736 soi_errno = KEY_WRONG_TYPE;
00737 }
00738 return (uint64_t)ULONG_MAX;
00739 }
00740
00741 uint32_t getkey_uint32 (KEY *list, char *key) {
00742 uint32_t return_val;
00743 KEY *the_one = findkey (list, key);
00744 if (the_one)
00745 switch (the_one->type) {
00746 case KEYTYP_UINT32:
00747 return_val = *(uint32_t *)the_one->val;
00748 return (return_val);
00749 default:
00750 soi_errno = KEY_WRONG_TYPE;
00751 }
00752 return (uint32_t)ULONG_MAX;
00753 }
00754
00755 double getkey_float (KEY *list, char *key) {
00756 double return_val;
00757 KEY *the_one = findkey (list, key);
00758 if (the_one) {
00759 switch (the_one->type) {
00760 case KEYTYP_FLOAT:
00761 return_val = *(float *)the_one->val;
00762 return (return_val);
00763 case KEYTYP_DOUBLE:
00764 return_val = *(double *)the_one->val;
00765 return (return_val);
00766 default:
00767 soi_errno = KEY_WRONG_TYPE;
00768 }
00769 }
00770 return D_NAN;
00771 }
00772
00773 double getkey_double (KEY *list, char *key) {
00774 double return_val;
00775 KEY *the_one = findkey (list, key);
00776 if (the_one)
00777 switch (the_one->type)
00778 {
00779 case KEYTYP_DOUBLE:
00780 return_val = *(double *)the_one->val;
00781 return (return_val);
00782 case KEYTYP_FLOAT:
00783 return_val = *(float *)the_one->val;
00784 return (return_val);
00785 default:
00786 soi_errno = KEY_WRONG_TYPE;
00787 }
00788 return D_NAN;
00789 }
00790
00791 TIME getkey_time (KEY *list, char *key) {
00792 double return_val;
00793 KEY *the_one = findkey (list, key);
00794 if (the_one) {
00795 if (the_one->type == KEYTYP_TIME) {
00796 return_val = *(TIME *)the_one->val;
00797 return (return_val);
00798 }
00799 else
00800 soi_errno = KEY_WRONG_TYPE;
00801 }
00802 return D_NAN;
00803 }
00804
00805 void setkey_str (KEY **list, char *key, char *val) {
00806 setkey_any (list, key, val, KEYTYP_STRING);
00807 }
00808
00809 void addkey_str (KEY **list, char *key, char *val) {
00811 addkey (list, key, val, KEYTYP_STRING);
00812 }
00813
00814 void setkey_fileptr (KEY **list, char *key, FILE *val) {
00815 setkey_any (list, key, val, KEYTYP_FILEP);
00816 }
00817
00818 void setkey_byte (KEY **list, char *key, char val) {
00819 setkey_any (list, key, &val, KEYTYP_BYTE);
00820 }
00821
00822 void setkey_ubyte (KEY **list, char *key, unsigned char val) {
00823 setkey_any (list, key, &val, KEYTYP_UBYTE);
00824 }
00825
00826 void setkey_short (KEY **list, char *key, short val) {
00827 setkey_any (list, key, &val, KEYTYP_SHORT);
00828 }
00829
00830 void setkey_ushort (KEY **list, char *key, unsigned short val) {
00831 setkey_any (list, key, &val, KEYTYP_USHORT);
00832 }
00833
00834 void setkey_int (KEY **list, char *key, int val) {
00835 setkey_any (list, key, &val, KEYTYP_INT);
00836 }
00837
00838 void setkey_uint (KEY **list, char *key, unsigned int val) {
00839 setkey_any (list, key, &val, KEYTYP_UINT);
00840 }
00841
00842 void setkey_long (KEY **list, char *key, long val) {
00843 setkey_any (list, key, &val, KEYTYP_LONG);
00844 }
00845
00846 void setkey_ulong (KEY **list, char *key, unsigned long val) {
00847 setkey_any (list, key, &val, KEYTYP_ULONG);
00848 }
00849
00850 void setkey_uint64 (KEY **list, char *key, uint64_t val) {
00851 setkey_any (list, key, &val, KEYTYP_UINT64);
00852 }
00853
00854 void setkey_uint32 (KEY **list, char *key, uint32_t val) {
00855 setkey_any (list, key, &val, KEYTYP_UINT32);
00856 }
00857
00858 void setkey_float (KEY **list, char *key, float val) {
00859 setkey_any (list, key, &val, KEYTYP_FLOAT);
00860 }
00861
00862 void setkey_double (KEY **list, char *key, double val) {
00863 setkey_any (list, key, &val, KEYTYP_DOUBLE);
00864 }
00865
00866 void setkey_time (KEY **list, char *key, TIME val) {
00867 setkey_any (list, key, &val, KEYTYP_TIME);
00868 }
00869
00870 void add_keys (KEY *inlist, KEY **tolist) {
00871 KEY *walker = inlist;
00872
00873 while (walker) {
00874 setkey_any (tolist, walker->name, walker->val, walker->type);
00875 walker = walker->next;
00876 }
00877 }
00878
00879 void delete_keys (KEY *inlist, KEY **fromlist) {
00880 KEY *walker = inlist;
00881
00882 while (walker) {
00883 deletekey (fromlist, walker->name);
00884 walker = walker->next;
00885 }
00886 }