invert-sense-of-strings-string-header-inclusion-20010806
[openafs.git] / src / update / utils.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <afsconfig.h>
11 #include <afs/param.h>
12
13 RCSID("$Header$");
14
15 #include <afs/stds.h>
16 #include <rx/rxkad.h>
17 #include "global.h"
18 #ifdef AFS_NT40_ENV
19 #include <afs/errmap_nt.h>
20 #include <afs/afsutil.h>
21 #include <WINNT/afssw.h>
22 #endif
23 #include <stdio.h>
24 #ifdef HAVE_STRING_H
25 #include <string.h>
26 #else
27 #ifdef HAVE_STRINGS_H
28 #include <strings.h>
29 #endif
30 #endif
31 #ifdef HAVE_UNISTD_H
32 #include <unistd.h>
33 #endif
34 #include <stdlib.h>
35
36 int
37 AddToList(ah, aname)
38 struct filestr **ah;
39 char *aname; {
40     register struct filestr *tf;
41     tf = (struct filestr *) malloc(sizeof(struct filestr));
42     tf->next = *ah;
43     *ah = tf;
44     tf->name = (char *) malloc(strlen(aname)+1);
45     strcpy(tf->name, aname);
46     return 0;
47 }
48
49 int
50 ZapList(ah)
51 struct filestr **ah; {
52     register struct filestr *tf, *nf;
53     for(tf = *ah; tf; tf=nf) {
54         nf = tf->next;      /* save before freeing */
55         free(tf->name);
56         free(tf);
57     }
58     *ah = (struct filestr *) 0;
59     return 0;
60 }
61
62 /* StringToLevel - converts the name of an rxkad security level to a integer
63  * suitable for calling rxkad_New*SecurityObject. */
64
65 rxkad_level StringToLevel (name)
66   char *name;
67 {
68     if (strcmp (name, "clear") == 0) return rxkad_clear;
69     if (strcmp (name, "auth") == 0) return rxkad_auth;
70     if (strcmp (name, "crypt") == 0) return rxkad_crypt;
71     return -1;
72 }