1 |
/* This file is part of GNU RADIUS. |
/* This file is part of GNU Radius. |
2 |
Copyright (C) 2000, 2001 Sergey Poznyakoff |
Copyright (C) 2000,2001,2002,2003 Sergey Poznyakoff |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
GNU Radius is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
6 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
7 |
(at your option) any later version. |
(at your option) any later version. |
8 |
|
|
9 |
This program is distributed in the hope that it will be useful, |
GNU Radius is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
GNU General Public License for more details. |
13 |
|
|
14 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
15 |
along with this program; if not, write to the Free Software Foundation, |
along with GNU Radius; if not, write to the Free Software Foundation, |
16 |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
17 |
|
|
|
#ifndef lint |
|
|
static char rcsid[] = |
|
|
"$Id$"; |
|
|
#endif |
|
|
|
|
18 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
19 |
# include <config.h> |
# include <config.h> |
20 |
#endif |
#endif |
48 |
/* Free a RADIUS_REQ struct. |
/* Free a RADIUS_REQ struct. |
49 |
*/ |
*/ |
50 |
void |
void |
51 |
radreq_free(radreq) |
radreq_free(RADIUS_REQ *radreq) |
|
RADIUS_REQ *radreq; |
|
52 |
{ |
{ |
53 |
string_free(radreq->remote_user); |
string_free(radreq->remote_user); |
54 |
avl_free(radreq->reply_pairs); |
avl_free(radreq->reply_pairs); |
66 |
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; |
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; |
67 |
|
|
68 |
int |
int |
69 |
user_gettime(valstr, tm) |
user_gettime(char *valstr, struct tm *tm) |
|
char *valstr; |
|
|
struct tm *tm; |
|
70 |
{ |
{ |
71 |
int i; |
int i; |
72 |
|
|
106 |
* `whence' determines from where the offset is counted (seek-like) |
* `whence' determines from where the offset is counted (seek-like) |
107 |
*/ |
*/ |
108 |
void |
void |
109 |
rad_lock(fd, size, offset, whence) |
rad_lock(int fd, size_t size, off_t offset, int whence) |
|
int fd; |
|
|
size_t size; |
|
|
off_t offset; |
|
|
int whence; |
|
110 |
{ |
{ |
111 |
struct flock fl; |
struct flock fl; |
112 |
|
|
121 |
* `whence' determines from where the offset is counted (seek-like) |
* `whence' determines from where the offset is counted (seek-like) |
122 |
*/ |
*/ |
123 |
void |
void |
124 |
rad_unlock(fd, size, offset, whence) |
rad_unlock(int fd, size_t size, off_t offset, int whence) |
|
int fd; |
|
|
size_t size; |
|
|
off_t offset; |
|
|
int whence; |
|
125 |
{ |
{ |
126 |
struct flock fl; |
struct flock fl; |
127 |
|
|
136 |
* number if found. Otherwise return default value `def'. |
* number if found. Otherwise return default value `def'. |
137 |
*/ |
*/ |
138 |
int |
int |
139 |
xlat_keyword(kw, str, def) |
xlat_keyword(struct keyword *kw, char *str, int def) |
|
struct keyword *kw; |
|
|
char *str; |
|
|
int def; |
|
140 |
{ |
{ |
141 |
for ( ; kw->name; kw++) |
for ( ; kw->name; kw++) |
142 |
if (strcmp(str, kw->name) == 0) |
if (strcmp(str, kw->name) == 0) |
147 |
/* compose a full pathname from given path and filename |
/* compose a full pathname from given path and filename |
148 |
*/ |
*/ |
149 |
char * |
char * |
150 |
mkfilename(dir, name) |
mkfilename(char *dir, char *name) |
|
char *dir; |
|
|
char *name; |
|
151 |
{ |
{ |
152 |
int len = strlen(dir) + strlen(name); |
int len = strlen(dir) + strlen(name); |
153 |
char *p = emalloc(len+2); |
char *p = emalloc(len+2); |
158 |
/* compose a full pathname from given path, subdirectory and filename |
/* compose a full pathname from given path, subdirectory and filename |
159 |
*/ |
*/ |
160 |
char * |
char * |
161 |
mkfilename3(dir, subdir, name) |
mkfilename3(char *dir, char *subdir, char *name) |
|
char *dir; |
|
|
char *subdir; |
|
|
char *name; |
|
162 |
{ |
{ |
163 |
int len = strlen(dir) + strlen(subdir) + strlen(name); |
int len = strlen(dir) + strlen(subdir) + strlen(name); |
164 |
char *p = emalloc(len+3); /* two intermediate slashes and |
char *p = emalloc(len+3); /* two intermediate slashes and |
171 |
/* Convert second character of a backslash sequence to its ASCII |
/* Convert second character of a backslash sequence to its ASCII |
172 |
value: */ |
value: */ |
173 |
int |
int |
174 |
backslash(c) |
backslash(int c) |
|
int c; |
|
175 |
{ |
{ |
176 |
static char transtab[] = "b\bf\fn\nr\rt\t"; |
static char transtab[] = "b\bf\fn\nr\rt\t"; |
177 |
char *p; |
char *p; |
184 |
} |
} |
185 |
|
|
186 |
void |
void |
187 |
string_copy(d, s, len) |
string_copy(char *d, char *s, int len) |
|
char *d; |
|
|
char *s; |
|
|
int len; |
|
188 |
{ |
{ |
189 |
int slen = strlen(s); |
int slen = strlen(s); |
190 |
|
|
195 |
} |
} |
196 |
|
|
197 |
char * |
char * |
198 |
op_to_str(op) |
op_to_str(int op) |
|
int op; |
|
199 |
{ |
{ |
200 |
switch (op) { |
switch (op) { |
201 |
case OPERATOR_EQUAL: return "="; |
case OPERATOR_EQUAL: return "="; |
209 |
} |
} |
210 |
|
|
211 |
int |
int |
212 |
str_to_op(str) |
str_to_op(char *str) |
|
char *str; |
|
213 |
{ |
{ |
214 |
int op = NUM_OPERATORS; |
int op = NUM_OPERATORS; |
215 |
switch (*str++) { |
switch (*str++) { |
238 |
return op; |
return op; |
239 |
} |
} |
240 |
|
|
241 |
static int flush_seg(char **bufp, char *seg, char *ptr, int runlen); |
static int |
242 |
|
flush_seg(char **bufp, char *seg, char *ptr, int runlen) |
|
int |
|
|
flush_seg(bufp, seg, ptr, runlen) |
|
|
char **bufp; |
|
|
char *seg; |
|
|
char *ptr; |
|
|
int runlen; |
|
243 |
{ |
{ |
244 |
int outbytes = 0; |
int outbytes = 0; |
245 |
char *buf = *bufp; |
char *buf = *bufp; |
271 |
(not counting null terminator) is returned. */ |
(not counting null terminator) is returned. */ |
272 |
|
|
273 |
int |
int |
274 |
format_string_visual(buf, runlen, str, len) |
format_string_visual(char *buf, int runlen, char *str, int len) |
|
char *buf; |
|
|
int runlen; |
|
|
char *str; |
|
|
int len; |
|
275 |
{ |
{ |
276 |
char *seg, *ptr; |
char *seg, *ptr; |
277 |
int outbytes = 0; |
int outbytes = 0; |
309 |
} |
} |
310 |
|
|
311 |
int |
int |
312 |
format_vendor_pair(buf, pair) |
format_vendor_pair(char *buf, VALUE_PAIR *pair) |
|
char *buf; |
|
|
VALUE_PAIR *pair; |
|
313 |
{ |
{ |
314 |
int n; |
int n; |
315 |
UINT4 vendor; |
UINT4 vendor; |
332 |
} |
} |
333 |
|
|
334 |
char * |
char * |
335 |
format_pair(pair, savep) |
format_pair(VALUE_PAIR *pair, char **savep) |
|
VALUE_PAIR *pair; |
|
|
char **savep; |
|
336 |
{ |
{ |
337 |
char *buf1 = NULL; |
char *buf1 = NULL; |
338 |
char *buf2ptr = NULL; |
char *buf2ptr = NULL; |