Print this page
*** NO COMMENTS ***

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ypcmd/revnetgroup/table.c
          +++ new/usr/src/cmd/ypcmd/revnetgroup/table.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright (c) 1994, by Sun Microsystems, Inc.
  24   24   * All rights reserved.
       25 + *
       26 + * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  25   27   */
  26      -                                                            
  27      -#ident  "%Z%%M% %I%     %E% SMI"        /* SMI4.1 1.4 */
  28   28  
       29 +#include <stdlib.h>
       30 +#include <strings.h>
  29   31  #include <ctype.h>
  30   32  #include "util.h"
  31   33  #include "table.h"
  32   34  
  33   35  
  34   36  
  35   37  /*
  36   38   * Hash table manager. Store/lookup strings, keyed by string
  37   39   */
  38   40  
↓ open down ↓ 17 lines elided ↑ open up ↑
  56   58                  c2 = EOS;       /* just in case */
  57   59          }
  58   60          c1 = TOLOWER(c1) - 'a';
  59   61          c2 = TOLOWER(c2) - 'a';
  60   62          return (c1*NUMLETTERS + c2);
  61   63  }
  62   64  
  63   65  
  64   66  void
  65   67  store(table, key, datum)
  66      -        stringtable table;
       68 +        tablelist *table;
  67   69          char *key;
  68   70          char *datum;
  69   71  {
  70   72          int index;
  71   73          tablelist cur, new;
  72   74  
  73   75          index = tablekey(key);
  74   76          cur = table[index];
  75   77  
  76   78          new = MALLOC(tablenode);
  77   79          new->key = key;
  78   80          new->datum = datum;
  79   81          new->next = cur;
  80   82          table[index] = new;
  81   83  }
  82   84  
  83   85  
  84   86  char *
  85   87  lookup(table, key)
  86      -        stringtable table;
       88 +        tablelist *table;
  87   89          char *key;
  88   90  {
  89   91          tablelist cur;
  90   92  
  91   93          cur = table[tablekey(key)];
  92   94          while (cur && strcmp(cur->key, key)) {
  93   95                  cur = cur->next;
  94   96          }
  95   97          if (cur) {
  96   98                  return (cur->datum);
  97   99          } else {
  98  100                  return (NULL);
  99  101          }
 100  102  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX