Allow for full RFC822 addresses.
Showing
1 changed file
with
58 additions
and
2 deletions
... | @@ -45,6 +45,47 @@ list_create_or_die () | ... | @@ -45,6 +45,47 @@ list_create_or_die () |
45 | return list; | 45 | return list; |
46 | } | 46 | } |
47 | 47 | ||
48 | static char * | ||
49 | ali_list_to_string (list_t *plist) | ||
50 | { | ||
51 | size_t n; | ||
52 | char *string; | ||
53 | |||
54 | list_count (*plist, &n); | ||
55 | if (n == 1) | ||
56 | { | ||
57 | list_get (*plist, 0, (void **)&string); | ||
58 | } | ||
59 | else | ||
60 | { | ||
61 | char *p; | ||
62 | size_t length = 0; | ||
63 | iterator_t itr; | ||
64 | iterator_create (&itr, *plist); | ||
65 | for (iterator_first (itr); !iterator_is_done (itr); iterator_next(itr)) | ||
66 | { | ||
67 | char *s; | ||
68 | iterator_current (itr, (void**) &s); | ||
69 | length += strlen (s) + 1; | ||
70 | } | ||
71 | |||
72 | string = xmalloc (length + 1); | ||
73 | p = string; | ||
74 | for (iterator_first (itr); !iterator_is_done (itr); iterator_next(itr)) | ||
75 | { | ||
76 | char *s; | ||
77 | iterator_current (itr, (void**) &s); | ||
78 | strcpy (p, s); | ||
79 | p += strlen (s); | ||
80 | *p++ = ' '; | ||
81 | } | ||
82 | *--p = 0; | ||
83 | iterator_destroy (&itr); | ||
84 | } | ||
85 | list_destroy (plist); | ||
86 | return string; | ||
87 | } | ||
88 | |||
48 | static list_t unix_group_to_list __P((char *name)); | 89 | static list_t unix_group_to_list __P((char *name)); |
49 | static list_t unix_gid_to_list __P((char *name)); | 90 | static list_t unix_gid_to_list __P((char *name)); |
50 | static list_t unix_passwd_to_list __P((void)); | 91 | static list_t unix_passwd_to_list __P((void)); |
... | @@ -61,7 +102,7 @@ int yylex __P((void)); | ... | @@ -61,7 +102,7 @@ int yylex __P((void)); |
61 | } | 102 | } |
62 | 103 | ||
63 | %token <string> STRING | 104 | %token <string> STRING |
64 | %type <list> address_list address_group | 105 | %type <list> address_list address_group string_list |
65 | %type <string> address | 106 | %type <string> address |
66 | %type <alias> alias | 107 | %type <alias> alias |
67 | 108 | ||
... | @@ -133,7 +174,22 @@ address_list : address | ... | @@ -133,7 +174,22 @@ address_list : address |
133 | } | 174 | } |
134 | ; | 175 | ; |
135 | 176 | ||
136 | address : STRING | 177 | address : string_list |
178 | { | ||
179 | $$ = ali_list_to_string (&$1); | ||
180 | } | ||
181 | ; | ||
182 | |||
183 | string_list : STRING | ||
184 | { | ||
185 | list_create(&$$); | ||
186 | list_append($$, $1); | ||
187 | } | ||
188 | | string_list STRING | ||
189 | { | ||
190 | list_append($1, $2); | ||
191 | $$ = $1; | ||
192 | } | ||
137 | ; | 193 | ; |
138 | 194 | ||
139 | %% | 195 | %% | ... | ... |
-
Please register or sign in to post a comment