summaryrefslogtreecommitdiffstats
path: root/libexec/revnetgroup
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-12-13 02:40:39 +0000
committerwpaul <wpaul@FreeBSD.org>1996-12-13 02:40:39 +0000
commitb738ab043277ed2967c84b7ba11654b8e0d99f19 (patch)
treee09ec5fe96b67a7888b27300f4d4e0ce43904751 /libexec/revnetgroup
parent5663e7faf1193426c1a06144854f3ddf60e8b4c0 (diff)
downloadFreeBSD-src-b738ab043277ed2967c84b7ba11654b8e0d99f19.zip
FreeBSD-src-b738ab043277ed2967c84b7ba11654b8e0d99f19.tar.gz
Close PR #2193: support backslash line continuations.
(Also did some minor cleanups.)
Diffstat (limited to 'libexec/revnetgroup')
-rw-r--r--libexec/revnetgroup/hash.h11
-rw-r--r--libexec/revnetgroup/parse_netgroup.c10
-rw-r--r--libexec/revnetgroup/revnetgroup.c17
3 files changed, 23 insertions, 15 deletions
diff --git a/libexec/revnetgroup/hash.h b/libexec/revnetgroup/hash.h
index 4de29e6..a8ad747 100644
--- a/libexec/revnetgroup/hash.h
+++ b/libexec/revnetgroup/hash.h
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: hash.h,v 1.1.1.1 1995/10/26 16:25:29 wpaul Exp $
+ * $Id: hash.h,v 1.2 1996/05/12 17:17:42 wpaul Exp $
*/
/* Groupname entry hung off a member_entry node. */
@@ -56,3 +56,12 @@ struct group_entry {
/* Table size (chosen arbitrarily). Not too big, not too small. */
#define TABLESIZE 256
#define HASH_MASK 0x000000FF
+
+#define LINSIZ 1024 * 10
+
+extern void store __P(( struct group_entry ** , char *, char * ));
+extern void mstore __P(( struct member_entry ** , char *, char *, char * ));
+extern char *lookup __P(( struct group_entry **, char * ));
+extern void __endnetgrent __P(( void ));
+extern void __setnetgrent __P(( char * ));
+extern int __getnetgrent __P(( char **, char **, char ** ));
diff --git a/libexec/revnetgroup/parse_netgroup.c b/libexec/revnetgroup/parse_netgroup.c
index bc048e1..7e7d824 100644
--- a/libexec/revnetgroup/parse_netgroup.c
+++ b/libexec/revnetgroup/parse_netgroup.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "$Id: parse_netgroup.c,v 1.1.1.1 1995/10/26 16:25:29 wpaul Exp $";
+static char sccsid[] = "$Id: parse_netgroup.c,v 1.2 1996/05/12 17:17:44 wpaul Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -52,7 +52,7 @@ static char sccsid[] = "$Id: parse_netgroup.c,v 1.1.1.1 1995/10/26 16:25:29 wpau
#include "hash.h"
#ifndef lint
-static const char rcsid[] = "$Id$";
+static const char rcsid[] = "$Id: parse_netgroup.c,v 1.2 1996/05/12 17:17:44 wpaul Exp $";
#endif
/*
@@ -92,8 +92,6 @@ static struct linelist *read_for_group();
void __setnetgrent(), __endnetgrent();
int __getnetgrent();
extern struct group_entry *gtable[];
-extern char *lookup __P(( struct group_entry *[], char * ));
-#define LINSIZ 1024 /* Length of netgroup file line */
/*
* setnetgrent()
@@ -296,12 +294,12 @@ static struct linelist *
read_for_group(group)
char *group;
{
- register char *pos, *spos, *linep, *olinep;
+ register char *pos, *spos, *linep = NULL, *olinep = NULL;
register int len, olen;
int cont;
struct linelist *lp;
char line[LINSIZ + 1];
- char *key = NULL, *data = NULL;
+ char *data = NULL;
data = lookup (gtable, group);
sprintf(line, "%s %s", group, data);
diff --git a/libexec/revnetgroup/revnetgroup.c b/libexec/revnetgroup/revnetgroup.c
index 70c0a2c..2789b85 100644
--- a/libexec/revnetgroup/revnetgroup.c
+++ b/libexec/revnetgroup/revnetgroup.c
@@ -35,7 +35,7 @@
* Center for Telecommunications Research
* Columbia University, New York City
*
- * $Id: revnetgroup.c,v 1.2 1996/05/12 17:17:45 wpaul Exp $
+ * $Id: revnetgroup.c,v 1.3 1996/08/04 19:17:15 wpaul Exp $
*/
#include <stdio.h>
@@ -46,11 +46,9 @@
#include "hash.h"
#ifndef lint
-static const char rcsid[] = "$Id: revnetgroup.c,v 1.2 1996/05/12 17:17:45 wpaul Exp $";
+static const char rcsid[] = "$Id: revnetgroup.c,v 1.3 1996/08/04 19:17:15 wpaul Exp $";
#endif
-#define LINSIZ 1024
-
/* Default location of netgroup file. */
char *netgroup = "/etc/netgroup";
@@ -63,10 +61,6 @@ struct group_entry *gtable[TABLESIZE];
*/
struct member_entry *mtable[TABLESIZE];
-extern void store __P(( struct group_entry ** , char *, char * ));
-extern void mstore __P(( struct member_entry ** , char *, char *, char * ));
-extern char *lookup __P(( struct group_entry **, char * ));
-
void usage(prog)
char *prog;
{
@@ -76,6 +70,7 @@ char *prog;
extern char *optarg;
+int
main(argc, argv)
int argc;
char *argv[];
@@ -132,6 +127,12 @@ main(argc, argv)
while (fgets(readbuf, LINSIZ, fp)) {
if (readbuf[0] == '#')
continue;
+ /* handle backslash line continuations */
+ while(readbuf[strlen(readbuf) - 2] == '\\') {
+ fgets((char *)&readbuf[strlen(readbuf) - 2],
+ sizeof(readbuf) - strlen(readbuf), fp);
+ }
+ data = NULL;
if ((data = (char *)(strpbrk(readbuf, " \t") + 1)) < (char *)2)
continue;
key = (char *)&readbuf;
OpenPOWER on IntegriCloud