/[radius]/radius/lib/util.c
ViewVC logotype

Diff of /radius/lib/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by gray, Fri Aug 2 11:18:43 2002 UTC revision 1.7 by gray, Wed Apr 30 08:44:33 2003 UTC
# Line 1  Line 1 
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
# Line 53  radreq_alloc() Line 48  radreq_alloc()
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);
# Line 72  static char *months[] = { Line 66  static char *months[] = {
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    
# Line 114  user_gettime(valstr, tm) Line 106  user_gettime(valstr, tm)
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    
# Line 133  rad_lock(fd, size, offset, whence) Line 121  rad_lock(fd, size, offset, whence)
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    
# Line 152  rad_unlock(fd, size, offset, whence) Line 136  rad_unlock(fd, size, offset, whence)
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)
# Line 166  xlat_keyword(kw, str, def) Line 147  xlat_keyword(kw, str, def)
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);
# Line 179  mkfilename(dir, name) Line 158  mkfilename(dir, name)
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
# Line 195  mkfilename3(dir, subdir, name) Line 171  mkfilename3(dir, subdir, name)
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;
# Line 209  backslash(c) Line 184  backslash(c)
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                    
# Line 223  string_copy(d, s, len) Line 195  string_copy(d, s, len)
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 "=";
# Line 238  op_to_str(op) Line 209  op_to_str(op)
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++) {
# Line 268  str_to_op(str) Line 238  str_to_op(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;
# Line 307  flush_seg(bufp, seg, ptr, runlen) Line 271  flush_seg(bufp, seg, ptr, runlen)
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;
# Line 349  format_string_visual(buf, runlen, str, l Line 309  format_string_visual(buf, runlen, str, l
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;
# Line 374  format_vendor_pair(buf, pair) Line 332  format_vendor_pair(buf, pair)
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;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26