38 |
#include <grp.h> |
#include <grp.h> |
39 |
#include <radius.h> |
#include <radius.h> |
40 |
#include <checkrad.h> |
#include <checkrad.h> |
41 |
|
#include <obstack1.h> |
42 |
|
|
43 |
RADIUS_REQ * |
RADIUS_REQ * |
44 |
radreq_alloc() |
radreq_alloc() |
174 |
int |
int |
175 |
backslash(int c) |
backslash(int c) |
176 |
{ |
{ |
177 |
static char transtab[] = "b\bf\fn\nr\rt\t"; |
static char transtab[] = "a\ab\bf\fn\nr\rt\t"; |
178 |
char *p; |
char *p; |
179 |
|
|
180 |
for (p = transtab; *p; p += 2) { |
for (p = transtab; *p; p += 2) { |
184 |
return c; |
return c; |
185 |
} |
} |
186 |
|
|
187 |
|
#define to_num(c) \ |
188 |
|
(isdigit(c) ? c - '0' : (isxdigit(c) ? toupper(c) - 'A' + 10 : -1 )) |
189 |
|
|
190 |
|
void |
191 |
|
obstack_grow_backslash_num(struct obstack *stk, char *text, int len, int base) |
192 |
|
{ |
193 |
|
int i; |
194 |
|
int c = 0; |
195 |
|
|
196 |
|
for (i = len-1; i >= 0 && text[i] != '\\'; i--) |
197 |
|
; |
198 |
|
if (i) |
199 |
|
obstack_grow(stk, text, i); |
200 |
|
if (base == 16) |
201 |
|
i++; |
202 |
|
for (i++; i < len; i++) |
203 |
|
c = c*base + to_num(text[i]); |
204 |
|
obstack_1grow(stk, c); |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
void |
209 |
|
obstack_grow_backslash(struct obstack *stk, char *text, char **endp) |
210 |
|
{ |
211 |
|
int c, i; |
212 |
|
|
213 |
|
switch (text[1]) { |
214 |
|
case '\\': |
215 |
|
obstack_1grow(stk, text[1]); |
216 |
|
text += 2; |
217 |
|
break; |
218 |
|
|
219 |
|
default: |
220 |
|
c = backslash(text[1]); |
221 |
|
obstack_1grow(stk, c); |
222 |
|
text += 2; |
223 |
|
break; |
224 |
|
|
225 |
|
case '0': |
226 |
|
for (i = 0; i < 3 && isdigit(text[i+1]) && text[i+1] < '8'; i++) |
227 |
|
; |
228 |
|
if (i != 3) |
229 |
|
break; |
230 |
|
obstack_grow_backslash_num(stk, text, 4, 8); |
231 |
|
text += 4; |
232 |
|
break; |
233 |
|
|
234 |
|
case 'x': |
235 |
|
case 'X': |
236 |
|
for (i = 0; i < 2 && isxdigit(text[i+2]); i++) |
237 |
|
; |
238 |
|
if (i != 2) |
239 |
|
break; |
240 |
|
obstack_grow_backslash_num(stk, text, 3, 16); |
241 |
|
text += 3; |
242 |
|
break; |
243 |
|
} |
244 |
|
*endp = text; |
245 |
|
} |
246 |
|
|
247 |
void |
void |
248 |
string_copy(char *d, char *s, int len) |
string_copy(char *d, char *s, int len) |
249 |
{ |
{ |