]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/radius/radiusclient/lib/clientid.c
Large patch from Frank Cusack <fcusack@fcusack.com> to add proper
[ppp.git] / pppd / plugins / radius / radiusclient / lib / clientid.c
index e86cac0e7513696d1ab23861846a2125b4dd36ad..f15084bda564e89c2ff428f5adf5e9daf4cee40b 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * $Id: clientid.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: clientid.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
  *
  * Copyright (C) 1995,1996,1997 Lars Fenneberg
  *
- * See the file COPYRIGHT for the respective terms and conditions. 
- * If the file is missing contact me at lf@elemental.net 
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
  * and I'll send you a copy.
  *
  */
@@ -20,7 +20,7 @@ struct map2id_s {
        struct map2id_s *next;
 };
 
-static struct map2id_s *map2id_list = NULL; 
+static struct map2id_s *map2id_list = NULL;
 
 /*
  * Function: rc_read_mapfile
@@ -29,7 +29,7 @@ static struct map2id_s *map2id_list = NULL;
  *
  * Arguments: the file name of the map file
  *
- * Returns: zero on success, negative integer on failure 
+ * Returns: zero on success, negative integer on failure
  */
 
 int rc_read_mapfile(char *filename)
@@ -40,51 +40,51 @@ int rc_read_mapfile(char *filename)
        struct map2id_s *p;
        int lnr = 0;
 
-        if ((mapfd = fopen(filename,"r")) == NULL)
-        {
-               rc_log(LOG_ERR,"rc_read_mapfile: can't read %s: %s", filename, strerror(errno));                                                        
+       if ((mapfd = fopen(filename,"r")) == NULL)
+       {
+               rc_log(LOG_ERR,"rc_read_mapfile: can't read %s: %s", filename, strerror(errno));
                return (-1);
        }
-       
+
 #define SKIP(p) while(*p && isspace(*p)) p++;
 
-        while (fgets(buffer, sizeof(buffer), mapfd) != NULL)
-        {
-               lnr++;
-        
+       while (fgets(buffer, sizeof(buffer), mapfd) != NULL)
+       {
+               lnr++;
+
                q = buffer;
-               
-                SKIP(q);
-                                                
-                if ((*q == '\n') || (*q == '#') || (*q == '\0'))
+
+               SKIP(q);
+
+               if ((*q == '\n') || (*q == '#') || (*q == '\0'))
                        continue;
 
                if (( c = strchr(q, ' ')) || (c = strchr(q,'\t'))) {
 
                        *c = '\0'; c++;
                        SKIP(c);
-                       
+
                        name = q;
                        id = c;
-                       
+
                        if ((p = (struct map2id_s *)malloc(sizeof(*p))) == NULL) {
                                rc_log(LOG_CRIT,"rc_read_mapfile: out of memory");
                                return (-1);
                        }
-                       
+
                        p->name = strdup(name);
                        p->id = atoi(id);
                        p->next = map2id_list;
-                       map2id_list = p;                        
-               
+                       map2id_list = p;
+
                } else {
-                       
-                       rc_log(LOG_ERR, "rc_read_mapfile: malformed line in %s, line %d", filename, lnr);  
+
+                       rc_log(LOG_ERR, "rc_read_mapfile: malformed line in %s, line %d", filename, lnr);
                        return (-1);
 
                }
        }
-       
+
 #undef SKIP
 
        fclose(mapfd);
@@ -110,13 +110,13 @@ UINT4 rc_map2id(char *name)
        *ttyname = '\0';
        if (*name != '/')
                strcpy(ttyname, "/dev/");
-               
+
        strncat(ttyname, name, sizeof(ttyname));
-       
+
        for(p = map2id_list; p; p = p->next)
                if (!strcmp(ttyname, p->name)) return p->id;
 
        rc_log(LOG_WARNING,"rc_map2id: can't find tty %s in map database", ttyname);
-       
+
        return 0;
 }