aix-strings-h-preferred-over-string-h-20010628
[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 <afs/param.h>
11 #include <afsconfig.h>
12 #include <afs/stds.h>
13 #include <rx/rxkad.h>
14 #include "global.h"
15 #ifdef AFS_NT40_ENV
16 #include <afs/errmap_nt.h>
17 #include <afs/afsutil.h>
18 #include <WINNT/afssw.h>
19 #endif
20 #include <stdio.h>
21 #ifdef HAVE_STRINGS_H
22 #include <strings.h>
23 #else
24 #ifdef HAVE_STRING_H
25 #include <string.h>
26 #endif
27 #endif
28 #ifdef HAVE_UNISTD_H
29 #include <unistd.h>
30 #endif
31 #include <stdlib.h>
32
33 RCSID("$Header$");
34
35 int
36 AddToList(ah, aname)
37 struct filestr **ah;
38 char *aname; {
39     register struct filestr *tf;
40     tf = (struct filestr *) malloc(sizeof(struct filestr));
41     tf->next = *ah;
42     *ah = tf;
43     tf->name = (char *) malloc(strlen(aname)+1);
44     strcpy(tf->name, aname);
45     return 0;
46 }
47
48 int
49 ZapList(ah)
50 struct filestr **ah; {
51     register struct filestr *tf, *nf;
52     for(tf = *ah; tf; tf=nf) {
53         nf = tf->next;      /* save before freeing */
54         free(tf->name);
55         free(tf);
56     }
57     *ah = (struct filestr *) 0;
58     return 0;
59 }
60
61 /* StringToLevel - converts the name of an rxkad security level to a integer
62  * suitable for calling rxkad_New*SecurityObject. */
63
64 rxkad_level StringToLevel (name)
65   char *name;
66 {
67     if (strcmp (name, "clear") == 0) return rxkad_clear;
68     if (strcmp (name, "auth") == 0) return rxkad_auth;
69     if (strcmp (name, "crypt") == 0) return rxkad_crypt;
70     return -1;
71 }