1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains functions for general use within the Zephyr server.
4 * Created by: John T. Kohl
8 * Copyright (c) 1987 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_common_c[] =
23 /* common routines for the server */
25 /* copy a string into a newly allocated area */
28 strsave (const char *sp)
34 syslog(LOG_CRIT, "no mem strdup'ing");
40 /* The "& 0x5f" provides case-insensitivity for ASCII. */
43 hash(const char *string)
45 unsigned long hval = 0;
57 hval += (cp & 0x5f) * (3 + (1 << 16));
62 hval += (cp & 0x5f) * (1 + (1 << 8));
67 hval += (cp & 0x5f) * (1 + (1 << 12));
72 hval += (cp & 0x5f) * (1 + (1 << 4));
74 hval += ((long) hval) >> 18;
81 /* Output a name, replacing newlines with \n and single quotes with \q. */
82 void dump_quote(char *p, FILE *fp)
88 } else if (*p == '\n') {