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
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[] =
23 static String *zhash[STRING_HASH_TABLE_SIZE];
37 if (isascii(*p) && isupper(*p))
45 new_z = find_string(new_s,0);
53 /* Initialize new String */
57 new_z = (String *) malloc(sizeof(String));
58 new_z->string = new_s;
61 /* Add to beginning of hash table */
62 new_z->hash_val = hash(new_s);
63 i = new_z->hash_val % STRING_HASH_TABLE_SIZE;
75 free_string(String *z)
77 if (z == (String *) NULL)
84 /* delete string completely */
86 zhash[hash(z->string) % STRING_HASH_TABLE_SIZE] = z->next;
88 z->prev->next = z->next;
91 z->next->prev = z->prev;
108 if (isascii(*p) && isupper(*p))
116 z = zhash[hash(new_s) % STRING_HASH_TABLE_SIZE];
118 if (strcmp(new_s, z->string) == 0)
130 comp_string(String *a,
133 if (a->hash_val > b->hash_val)
135 if (a->hash_val < b->hash_val)
137 return strcmp(a->string,b->string);
141 print_string_table(FILE *f)
146 for(i = 0; i < STRING_HASH_TABLE_SIZE; i++) {
148 while (p != (String *) NULL) {
149 fprintf(f,"[%d] %s\n",p->ref_count,p->string);
156 dup_string(String *z)