Commit | Line | Data |
---|---|---|
95f51977 | 1 | /* |
e3419641 | 2 | * Copyright (c) 1986, 1988 Regents of the University of California. |
ca67e7b4 C |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that the above copyright notice and this paragraph are | |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
95f51977 C |
16 | */ |
17 | ||
ca67e7b4 | 18 | #ifndef lint |
e3419641 | 19 | static char sccsid[] = "@(#)db_reload.c 4.19 (Berkeley) 1/14/89"; |
ca67e7b4 C |
20 | #endif /* not lint */ |
21 | ||
95f51977 | 22 | #include <sys/types.h> |
ca67e7b4 | 23 | #include <sys/time.h> |
95f51977 C |
24 | #include <netinet/in.h> |
25 | #include <stdio.h> | |
ca67e7b4 | 26 | #include <syslog.h> |
95f51977 C |
27 | #include <arpa/nameser.h> |
28 | #include "ns.h" | |
29 | #include "db.h" | |
30 | ||
ca67e7b4 C |
31 | extern time_t resettime; |
32 | ||
95f51977 C |
33 | /* |
34 | * Flush and reload data base. | |
35 | */ | |
36 | ||
37 | db_reload() | |
38 | { | |
39 | extern char *bootfile; | |
40 | ||
41 | #ifdef DEBUG | |
42 | if (debug >= 3) | |
43 | fprintf(ddt,"reload()\n"); | |
44 | #endif | |
ca67e7b4 | 45 | syslog(LOG_NOTICE, "reloading nameserver\n"); |
95f51977 | 46 | |
ca67e7b4 C |
47 | qflush(); |
48 | sqflush(); | |
49 | fwdtab_free(); | |
ca67e7b4 | 50 | fwdtab_free(); |
95f51977 | 51 | ns_init(bootfile); |
ca67e7b4 | 52 | time(&resettime); |
95f51977 C |
53 | } |
54 | ||
55 | db_free(htp) | |
56 | struct hashbuf *htp; | |
57 | { | |
ca67e7b4 C |
58 | register struct databuf *dp, *nextdp; |
59 | register struct namebuf *np, *nextnp; | |
95f51977 C |
60 | struct namebuf **npp, **nppend; |
61 | ||
62 | npp = htp->h_tab; | |
63 | nppend = npp + htp->h_size; | |
64 | while (npp < nppend) { | |
ca67e7b4 | 65 | for (np = *npp++; np != NULL; np = nextnp) { |
95f51977 C |
66 | if (np->n_hash != NULL) |
67 | db_free(np->n_hash); | |
ca67e7b4 C |
68 | (void) free((char *)np->n_dname); |
69 | for (dp = np->n_data; dp != NULL; ) { | |
70 | nextdp = dp->d_next; | |
95f51977 | 71 | (void) free((char *)dp); |
ca67e7b4 C |
72 | dp = nextdp; |
73 | } | |
74 | nextnp = np->n_next; | |
75 | free((char *)np); | |
95f51977 C |
76 | } |
77 | } | |
78 | (void) free((char *)htp); | |
79 | } | |
80 | ||
81 | db_inv_free() | |
82 | { | |
83 | register struct invbuf *ip; | |
84 | register int i, j; | |
85 | ||
86 | for (i = 0; i < INVHASHSZ; i++) | |
87 | for (ip = invtab[i]; ip != NULL; ip = ip->i_next) | |
88 | for (j = 0; j < INVBLKSZ; j++) | |
89 | ip->i_dname[j] = NULL; | |
90 | } | |
91 | ||
ca67e7b4 C |
92 | fwdtab_free() |
93 | { | |
94 | extern struct fwdinfo *fwdtab; | |
95 | struct fwdinfo *fp, *nextfp; | |
96 | ||
97 | for (fp = fwdtab; fp != NULL; fp = nextfp) { | |
98 | nextfp = fp->next; | |
99 | free((char *)fp); | |
100 | } | |
101 | fwdtab = NULL; | |
102 | } |