13d6b86c01c0eacc7a082a2b51a33212193fd4fe
[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
14     ("$Header$");
15
16 #include <afs/stds.h>
17 #include <rx/rxkad.h>
18 #include "global.h"
19 #ifdef AFS_NT40_ENV
20 #include <afs/errmap_nt.h>
21 #include <afs/afsutil.h>
22 #include <WINNT/afssw.h>
23 #endif
24 #include <stdio.h>
25 #ifdef HAVE_STRING_H
26 #include <string.h>
27 #else
28 #ifdef HAVE_STRINGS_H
29 #include <strings.h>
30 #endif
31 #endif
32 #ifdef HAVE_UNISTD_H
33 #include <unistd.h>
34 #endif
35 #include <stdlib.h>
36
37 int
38 AddToList(struct filestr **ah, char *aname)
39 {
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(struct filestr **ah)
51 {
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 = NULL;
59     return 0;
60 }