Close PR #2193: support backslash line continuations.
(Also did some minor cleanups.)
This commit is contained in:
parent
5a4a0aacba
commit
79cc85d3ca
@ -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 ** ));
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user