home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / find_pre_val.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-14  |  942 b   |  43 lines

  1. /*
  2.    find_prev_value: given an old command structure, look through the
  3.    prior output for the output for name of type type.  Return it in the
  4.    struct pointed to by value or NULL if not found.
  5.  
  6.    Kenneth Ingham
  7.  
  8.    Copyright (C) 1987 The University of New Mexico
  9. */
  10.  
  11. #include "defs.h"
  12.  
  13. find_prev_value(cmd, field_name, key_val, value)
  14. struct old_cmd_st *cmd;
  15. char *field_name, *key_val;
  16. struct everything **value;
  17. {
  18.     struct val_st *vp;
  19.     struct key_st *kp;
  20.  
  21.     *value = NULL;
  22.  
  23.     /* is there anything to look for a value for? */
  24.     if (cmd == NULL || cmd->keys == NULL)
  25.         return;
  26.  
  27.     /* find the correct key */
  28.     kp = cmd->keys;
  29.     while (kp != NULL && strcmp(kp->key_value, key_val) != 0)
  30.             kp = kp->next;
  31.  
  32.     /* was a keyword and value found? */
  33.     if (kp == NULL || kp->vals == NULL)
  34.         return;
  35.  
  36.     /* find the value under the keyword */
  37.     vp = kp->vals;
  38.     while (vp != NULL && strcmp(vp->name, field_name) != 0)
  39.         vp = vp->next;
  40.  
  41.     *value = &(vp->val);
  42. }
  43.