1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains the main loop of the Zephyr server
4 * Created by: Lucien W. Van Elsen
6 * $Id: zstring.c,v 1.5 1999/01/22 23:19:55 ghudson Exp $
8 * Copyright (c) 1991 by the Massachusetts Institute of Technology.
9 * For copying and distribution information, see the file
13 #include <zephyr/mit-copyright.h>
18 static const char rcsid_zstring_c[] =
19 "$Id: zstring.c,v 1.5 1999/01/22 23:19:55 ghudson Exp $";
23 static String *zhash[STRING_HASH_TABLE_SIZE];
26 make_string(s, downcase)
38 if (isascii(*p) && isupper(*p))
46 new_z = find_string(new_s,0);
54 /* Initialize new String */
58 new_z = (String *) malloc(sizeof(String));
59 new_z->string = new_s;
62 /* Add to beginning of hash table */
63 new_z->hash_val = hash(new_s);
64 i = new_z->hash_val % STRING_HASH_TABLE_SIZE;
79 if (z == (String *) NULL)
86 /* delete string completely */
88 zhash[hash(z->string) % STRING_HASH_TABLE_SIZE] = z->next;
90 z->prev->next = z->next;
93 z->next->prev = z->prev;
100 find_string(s,downcase)
111 if (isascii(*p) && isupper(*p))
119 z = zhash[hash(new_s) % STRING_HASH_TABLE_SIZE];
121 if (strcmp(new_s, z->string) == 0)
136 if (a->hash_val > b->hash_val)
138 if (a->hash_val < b->hash_val)
140 return strcmp(a->string,b->string);
144 print_string_table(f)
150 for(i = 0; i < STRING_HASH_TABLE_SIZE; i++) {
152 while (p != (String *) NULL) {
153 fprintf(f,"[%d] %s\n",p->ref_count,p->string);