BSD 4_3_Tahoe release
[unix-history] / usr / src / lib / libc / gen / getgrent.c
index 6cce19e..38bda49 100644 (file)
@@ -1,13 +1,13 @@
-/* @(#)getgrent.c      4.1 (Berkeley) %G% */
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getgrent.c 5.3 (Berkeley) 11/5/87";
+#endif LIBC_SCCS and not lint
+
 #include <stdio.h>
 #include <grp.h>
 
 #include <stdio.h>
 #include <grp.h>
 
-#define        CL      ':'
-#define        CM      ','
-#define        NL      '\n'
-#define        MAXGRP  100
+#define        MAXGRP  200
 
 
-static char GROUP[] = "/etc/group";
+static char *GROUP = "/etc/group";
 static FILE *grf = NULL;
 static char line[BUFSIZ+1];
 static struct group group;
 static FILE *grf = NULL;
 static char line[BUFSIZ+1];
 static struct group group;
@@ -49,16 +49,23 @@ getgrent()
        if( !(p = fgets( line, BUFSIZ, grf )) )
                return(NULL);
        group.gr_name = p;
        if( !(p = fgets( line, BUFSIZ, grf )) )
                return(NULL);
        group.gr_name = p;
-       group.gr_passwd = p = grskip(p,CL);
-       group.gr_gid = atoi( p = grskip(p,CL) );
+       group.gr_passwd = p = grskip(p,':');
+       group.gr_gid = atoi( p = grskip(p,':') );
        group.gr_mem = gr_mem;
        group.gr_mem = gr_mem;
-       p = grskip(p,CL);
-       grskip(p,NL);
+       p = grskip(p,':');
+       grskip(p,'\n');
        q = gr_mem;
        while( *p ){
        q = gr_mem;
        while( *p ){
-               *q++ = p;
-               p = grskip(p,CM);
+               if (q < &gr_mem[MAXGRP-1])
+                       *q++ = p;
+               p = grskip(p,',');
        }
        *q = NULL;
        return( &group );
 }
        }
        *q = NULL;
        return( &group );
 }
+
+setgrfile(file)
+       char *file;
+{
+       GROUP = file;
+}