Close PR #2193: support backslash line continuations.
(Also did some minor cleanups.)
This commit is contained in:
parent
5a4a0aacba
commit
79cc85d3ca
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20387
@ -29,7 +29,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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. */
|
/* 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. */
|
/* Table size (chosen arbitrarily). Not too big, not too small. */
|
||||||
#define TABLESIZE 256
|
#define TABLESIZE 256
|
||||||
#define HASH_MASK 0x000000FF
|
#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)
|
#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 */
|
#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"
|
#include "hash.h"
|
||||||
|
|
||||||
#ifndef lint
|
#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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,8 +92,6 @@ static struct linelist *read_for_group();
|
|||||||
void __setnetgrent(), __endnetgrent();
|
void __setnetgrent(), __endnetgrent();
|
||||||
int __getnetgrent();
|
int __getnetgrent();
|
||||||
extern struct group_entry *gtable[];
|
extern struct group_entry *gtable[];
|
||||||
extern char *lookup __P(( struct group_entry *[], char * ));
|
|
||||||
#define LINSIZ 1024 /* Length of netgroup file line */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setnetgrent()
|
* setnetgrent()
|
||||||
@ -296,12 +294,12 @@ static struct linelist *
|
|||||||
read_for_group(group)
|
read_for_group(group)
|
||||||
char *group;
|
char *group;
|
||||||
{
|
{
|
||||||
register char *pos, *spos, *linep, *olinep;
|
register char *pos, *spos, *linep = NULL, *olinep = NULL;
|
||||||
register int len, olen;
|
register int len, olen;
|
||||||
int cont;
|
int cont;
|
||||||
struct linelist *lp;
|
struct linelist *lp;
|
||||||
char line[LINSIZ + 1];
|
char line[LINSIZ + 1];
|
||||||
char *key = NULL, *data = NULL;
|
char *data = NULL;
|
||||||
|
|
||||||
data = lookup (gtable, group);
|
data = lookup (gtable, group);
|
||||||
sprintf(line, "%s %s", group, data);
|
sprintf(line, "%s %s", group, data);
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
* Center for Telecommunications Research
|
* Center for Telecommunications Research
|
||||||
* Columbia University, New York City
|
* 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>
|
#include <stdio.h>
|
||||||
@ -46,11 +46,9 @@
|
|||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
|
||||||
#ifndef lint
|
#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
|
#endif
|
||||||
|
|
||||||
#define LINSIZ 1024
|
|
||||||
|
|
||||||
/* Default location of netgroup file. */
|
/* Default location of netgroup file. */
|
||||||
char *netgroup = "/etc/netgroup";
|
char *netgroup = "/etc/netgroup";
|
||||||
|
|
||||||
@ -63,10 +61,6 @@ struct group_entry *gtable[TABLESIZE];
|
|||||||
*/
|
*/
|
||||||
struct member_entry *mtable[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)
|
void usage(prog)
|
||||||
char *prog;
|
char *prog;
|
||||||
{
|
{
|
||||||
@ -76,6 +70,7 @@ char *prog;
|
|||||||
|
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
|
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
@ -132,6 +127,12 @@ main(argc, argv)
|
|||||||
while (fgets(readbuf, LINSIZ, fp)) {
|
while (fgets(readbuf, LINSIZ, fp)) {
|
||||||
if (readbuf[0] == '#')
|
if (readbuf[0] == '#')
|
||||||
continue;
|
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)
|
if ((data = (char *)(strpbrk(readbuf, " \t") + 1)) < (char *)2)
|
||||||
continue;
|
continue;
|
||||||
key = (char *)&readbuf;
|
key = (char *)&readbuf;
|
||||||
|
Loading…
Reference in New Issue
Block a user