diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-08-24 20:38:54 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-08-24 20:38:54 +0000 |
commit | ab736c0b1959c6c605c210d5fd9665bfe002042e (patch) | |
tree | e23a335c9a0e81505c9c06ba089e776200e1d443 | |
parent | ed4ec220dcfcba29a7fc8ff161999c32a98e4430 (diff) | |
download | alck-ab736c0b1959c6c605c210d5fd9665bfe002042e.tar.gz alck-ab736c0b1959c6c605c210d5fd9665bfe002042e.tar.bz2 |
* lib/version.c: New file
* lib/gsc.h (gsc_version): New function
* cvs/Makefile.am, ckaliases/Makefile.am, wydawca/Makefile.am,
lib/Makefile.am, jabberd/Makefile.am: Fix include dirs
* ckaliases/ckaliases.c, ckaliases/lex.l, ckaliases/ckaliases.h,
ckaliases/gram.y: Use long options. Implement --version
* wydawca/wydawca.c, jabberd/main.c: Use gsc_version to display
program version.
* doc/gsc.texi: Update
* bootstrap: Add vasprintf
git-svn-id: file:///svnroot/gsc/trunk@289 d2de0444-eb31-0410-8365-af798a554d48
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | ckaliases.c | 416 | ||||
-rw-r--r-- | ckaliases.h | 62 | ||||
-rw-r--r-- | gram.y | 336 | ||||
-rw-r--r-- | lex.l | 213 |
5 files changed, 522 insertions, 508 deletions
diff --git a/Makefile.am b/Makefile.am index c43b7a3..12f531c 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -11,12 +11,13 @@ | |||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with GSC. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with GSC. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=ckaliases | ||
18 | AM_YFLAGS=-vtd | 17 | AM_YFLAGS=-vtd |
19 | AM_LFLAGS=-d | 18 | AM_LFLAGS=-d |
20 | sbin_PROGRAMS=ckaliases | 19 | sbin_PROGRAMS=ckaliases |
21 | noinst_HEADERS=gram.h | 20 | noinst_HEADERS=gram.h |
22 | ckaliases_SOURCES=gram.y lex.l ckaliases.c ckaliases.h | 21 | ckaliases_SOURCES=gram.y lex.l ckaliases.c ckaliases.h |
22 | LDADD=../lib/libgsc.a ../gnu/libgnu.a | ||
23 | INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gnu -I../gnu | ||
diff --git a/ckaliases.c b/ckaliases.c index 343a52f..d77e62d 100644 --- a/ckaliases.c +++ b/ckaliases.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* ckaliases - verify syntax of sendmail-style alias files | 1 | /* ckaliases - verify syntax of sendmail-style alias files |
2 | Copyright (C) 2005 Sergey Poznyakoff | 2 | Copyright (C) 2005, 2007 Sergey Poznyakoff |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify it | 4 | This program is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU General Public License as published by the | 5 | under the terms of the GNU General Public License as published by the |
6 | Free Software Foundation; either version 3 of the License, or (at your | 6 | Free Software Foundation; either version 3 of the License, or (at your |
7 | option) any later version. | 7 | option) any later version. |
8 | 8 | ||
@@ -11,34 +11,14 @@ | |||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU General Public License along | 14 | You should have received a copy of the GNU General Public License along |
15 | with this program. If not, see <http://www.gnu.org/licenses/>. */ | 15 | with this program. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #ifdef HAVE_CONFIG_H | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <stdio.h> | ||
21 | #include <stdlib.h> | ||
22 | #define obstack_chunk_alloc malloc | ||
23 | #define obstack_chunk_free free | ||
24 | #include <obstack.h> | ||
25 | #include "ckaliases.h" | 17 | #include "ckaliases.h" |
26 | 18 | ||
27 | void * | ||
28 | xmalloc(size_t size) | ||
29 | { | ||
30 | void *p = malloc(size); | ||
31 | if (!p) { | ||
32 | fprintf(stderr, "not enough memory\n"); | ||
33 | exit(1); | ||
34 | } | ||
35 | return p; | ||
36 | } | ||
37 | |||
38 | |||
39 | #ifndef CHAR_BIT | 19 | #ifndef CHAR_BIT |
40 | # define CHAR_BIT 8 | 20 | # define CHAR_BIT 8 |
41 | #endif | 21 | #endif |
42 | #define BITS_PER_WORD (sizeof(unsigned)*CHAR_BIT) | 22 | #define BITS_PER_WORD (sizeof(unsigned)*CHAR_BIT) |
43 | #define MAXTABLE 32767 | 23 | #define MAXTABLE 32767 |
44 | 24 | ||
@@ -48,274 +28,294 @@ xmalloc(size_t size) | |||
48 | #define BITISSET(x, i) (((x)[(i)/BITS_PER_WORD] & (1<<((i) % BITS_PER_WORD))) != 0) | 28 | #define BITISSET(x, i) (((x)[(i)/BITS_PER_WORD] & (1<<((i) % BITS_PER_WORD))) != 0) |
49 | 29 | ||
50 | /* given n by n matrix of bits R, modify its contents | 30 | /* given n by n matrix of bits R, modify its contents |
51 | to be the transitive closure of what was given. */ | 31 | to be the transitive closure of what was given. */ |
52 | 32 | ||
53 | void | 33 | void |
54 | TC(unsigned *R, int n) | 34 | TC (unsigned *R, int n) |
55 | { | 35 | { |
56 | register int rowsize; | 36 | register int rowsize; |
57 | register unsigned mask; | 37 | register unsigned mask; |
58 | register unsigned *rowj; | 38 | register unsigned *rowj; |
59 | register unsigned *rp; | 39 | register unsigned *rp; |
60 | register unsigned *rend; | 40 | register unsigned *rend; |
61 | register unsigned *ccol; | 41 | register unsigned *ccol; |
62 | 42 | ||
63 | unsigned *relend; | 43 | unsigned *relend; |
64 | unsigned *cword; | 44 | unsigned *cword; |
65 | unsigned *rowi; | 45 | unsigned *rowi; |
66 | 46 | ||
67 | rowsize = WORDSIZE(n) * sizeof(unsigned); | 47 | rowsize = WORDSIZE (n) * sizeof (unsigned); |
68 | relend = (unsigned *) ((char *) R + (n * rowsize)); | 48 | relend = (unsigned *) ((char *) R + (n * rowsize)); |
69 | 49 | ||
70 | cword = R; | 50 | cword = R; |
71 | mask = 1; | 51 | mask = 1; |
72 | rowi = R; | 52 | rowi = R; |
73 | while (rowi < relend) { | 53 | while (rowi < relend) |
74 | ccol = cword; | 54 | { |
75 | rowj = R; | 55 | ccol = cword; |
76 | 56 | rowj = R; | |
77 | while (rowj < relend) { | 57 | |
78 | if (*ccol & mask) { | 58 | while (rowj < relend) |
79 | rp = rowi; | 59 | { |
80 | rend = (unsigned *) ((char *) rowj + rowsize); | 60 | if (*ccol & mask) |
81 | 61 | { | |
82 | while (rowj < rend) | 62 | rp = rowi; |
83 | *rowj++ |= *rp++; | 63 | rend = (unsigned *) ((char *) rowj + rowsize); |
84 | } else { | 64 | |
85 | rowj = (unsigned *) ((char *) rowj + rowsize); | 65 | while (rowj < rend) |
86 | } | 66 | *rowj++ |= *rp++; |
87 | 67 | } | |
88 | ccol = (unsigned *) ((char *) ccol + rowsize); | 68 | else |
89 | } | 69 | { |
90 | 70 | rowj = (unsigned *) ((char *) rowj + rowsize); | |
91 | mask <<= 1; | 71 | } |
92 | if (mask == 0) { | 72 | |
93 | mask = 1; | 73 | ccol = (unsigned *) ((char *) ccol + rowsize); |
94 | cword++; | 74 | } |
95 | } | ||
96 | rowi = (unsigned *) ((char *) rowi + rowsize); | ||
97 | } | ||
98 | } | ||
99 | 75 | ||
76 | mask <<= 1; | ||
77 | if (mask == 0) | ||
78 | { | ||
79 | mask = 1; | ||
80 | cword++; | ||
81 | } | ||
82 | rowi = (unsigned *) ((char *) rowi + rowsize); | ||
83 | } | ||
84 | } | ||
100 | 85 | ||
101 | 86 | ||
102 | void | 87 | void |
103 | slist_add(SLIST **plist, char *str) | 88 | slist_add (SLIST **plist, char *str) |
104 | { | 89 | { |
105 | struct string_list *p = xmalloc(sizeof(*p)); | 90 | struct string_list *p = xmalloc (sizeof (*p)); |
106 | p->str = str; | 91 | p->str = str; |
107 | p->next = NULL; | 92 | p->next = NULL; |
108 | 93 | ||
109 | if (!*plist) { | 94 | if (!*plist) |
110 | *plist = xmalloc(sizeof(**plist)); | 95 | { |
111 | (*plist)->head = NULL; | 96 | *plist = xmalloc (sizeof (**plist)); |
112 | } | 97 | (*plist)->head = NULL; |
113 | 98 | } | |
114 | if ((*plist)->head == NULL) { | 99 | |
115 | (*plist)->head = p; | 100 | if ((*plist)->head == NULL) |
116 | (*plist)->count = 0; | 101 | { |
117 | } else { | 102 | (*plist)->head = p; |
118 | (*plist)->tail->next = p; | 103 | (*plist)->count = 0; |
119 | (*plist)->count++; | 104 | } |
120 | } | 105 | else |
121 | (*plist)->tail = p; | 106 | { |
107 | (*plist)->tail->next = p; | ||
108 | (*plist)->count++; | ||
109 | } | ||
110 | (*plist)->tail = p; | ||
122 | } | 111 | } |
123 | 112 | ||
124 | void | 113 | void |
125 | slist_append(SLIST **pdst, SLIST *src) | 114 | slist_append (SLIST **pdst, SLIST *src) |
126 | { | 115 | { |
127 | struct string_list *tail; | 116 | struct string_list *tail; |
128 | 117 | ||
129 | if (!*pdst) { | 118 | if (!*pdst) |
130 | *pdst = xmalloc(sizeof(**pdst)); | 119 | { |
131 | (*pdst)->head = NULL; | 120 | *pdst = xmalloc (sizeof (**pdst)); |
132 | (*pdst)->count = 0; | 121 | (*pdst)->head = NULL; |
133 | } | 122 | (*pdst)->count = 0; |
123 | } | ||
124 | |||
125 | if ((*pdst)->head = NULL) | ||
126 | (*pdst)->head = src->head; | ||
127 | |||
128 | for (tail = src->tail; tail->next; tail = tail->next) | ||
129 | ; | ||
134 | 130 | ||
135 | if ((*pdst)->head = NULL) | 131 | (*pdst)->tail = tail; |
136 | (*pdst)->head = src->head; | 132 | (*pdst)->count += src->count; |
137 | |||
138 | for (tail = src->tail; tail->next; tail = tail->next) | ||
139 | ; | ||
140 | |||
141 | (*pdst)->tail = tail; | ||
142 | (*pdst)->count += src->count; | ||
143 | } | 133 | } |
144 | 134 | ||
145 | char * | 135 | char * |
146 | slist_member(SLIST *plist, char *name) | 136 | slist_member (SLIST *plist, char *name) |