1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
3*0Sstevel@tonic-gate * Use is subject to license terms.
4*0Sstevel@tonic-gate */
5*0Sstevel@tonic-gate
6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gate /****************************************************************************
9*0Sstevel@tonic-gate Copyright (c) 1999,2000 WU-FTPD Development Group.
10*0Sstevel@tonic-gate All rights reserved.
11*0Sstevel@tonic-gate
12*0Sstevel@tonic-gate Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994
13*0Sstevel@tonic-gate The Regents of the University of California.
14*0Sstevel@tonic-gate Portions Copyright (c) 1993, 1994 Washington University in Saint Louis.
15*0Sstevel@tonic-gate Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc.
16*0Sstevel@tonic-gate Portions Copyright (c) 1989 Massachusetts Institute of Technology.
17*0Sstevel@tonic-gate Portions Copyright (c) 1998 Sendmail, Inc.
18*0Sstevel@tonic-gate Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman.
19*0Sstevel@tonic-gate Portions Copyright (c) 1997 by Stan Barber.
20*0Sstevel@tonic-gate Portions Copyright (c) 1997 by Kent Landfield.
21*0Sstevel@tonic-gate Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
22*0Sstevel@tonic-gate Free Software Foundation, Inc.
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gate Use and distribution of this software and its source code are governed
25*0Sstevel@tonic-gate by the terms and conditions of the WU-FTPD Software License ("LICENSE").
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate If you did not receive a copy of the license, it may be obtained online
28*0Sstevel@tonic-gate at http://www.wu-ftpd.org/license.html.
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate $Id: rdservers.c,v 1.4 2000/07/01 18:17:39 wuftpd Exp $
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gate ****************************************************************************/
33*0Sstevel@tonic-gate /*
34*0Sstevel@tonic-gate * rdservers - read ftpservers file
35*0Sstevel@tonic-gate *
36*0Sstevel@tonic-gate * INITIAL AUTHOR - Kent Landfield <kent@landfield.com>
37*0Sstevel@tonic-gate */
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gate #include "config.h"
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate #ifdef VIRTUAL
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate #include <stdio.h>
44*0Sstevel@tonic-gate #include <string.h>
45*0Sstevel@tonic-gate #include <ctype.h>
46*0Sstevel@tonic-gate #include "proto.h"
47*0Sstevel@tonic-gate
read_servers_line(FILE * svrfp,char * hostaddress,size_t hsize,char * accesspath,size_t asize)48*0Sstevel@tonic-gate int read_servers_line(FILE *svrfp, char *hostaddress, size_t hsize,
49*0Sstevel@tonic-gate char *accesspath, size_t asize)
50*0Sstevel@tonic-gate {
51*0Sstevel@tonic-gate static char buffer[BUFSIZ];
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate char *hcp, *acp;
54*0Sstevel@tonic-gate char *bcp, *ecp;
55*0Sstevel@tonic-gate char *ap;
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gate while (fgets(buffer, BUFSIZ, svrfp) != NULL) {
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gate /* Find first non-whitespace character */
60*0Sstevel@tonic-gate for (bcp = buffer; ((*bcp == '\t') || (*bcp == ' ')); bcp++);
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate /* Get rid of comments */
63*0Sstevel@tonic-gate if ((ecp = strchr(buffer, '#')) != NULL)
64*0Sstevel@tonic-gate *ecp = '\0';
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate /* Skip empty lines */
67*0Sstevel@tonic-gate if ((bcp == ecp) || (*bcp == '\n'))
68*0Sstevel@tonic-gate continue;
69*0Sstevel@tonic-gate
70*0Sstevel@tonic-gate /* separate parts */
71*0Sstevel@tonic-gate
72*0Sstevel@tonic-gate hcp = bcp;
73*0Sstevel@tonic-gate for (acp = hcp;
74*0Sstevel@tonic-gate (*acp && !isspace(*acp)); acp++);
75*0Sstevel@tonic-gate
76*0Sstevel@tonic-gate /* better have something in access path or skip the line */
77*0Sstevel@tonic-gate if (!*acp)
78*0Sstevel@tonic-gate continue;
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gate *acp++ = '\0';
81*0Sstevel@tonic-gate
82*0Sstevel@tonic-gate while (*acp && isspace(*acp))
83*0Sstevel@tonic-gate acp++;
84*0Sstevel@tonic-gate
85*0Sstevel@tonic-gate /* again better have something in access path or skip the line */
86*0Sstevel@tonic-gate if (!*acp)
87*0Sstevel@tonic-gate continue;
88*0Sstevel@tonic-gate
89*0Sstevel@tonic-gate ecp = acp;
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate while (*ecp && (!isspace(*ecp)) && *ecp != '\n')
92*0Sstevel@tonic-gate ++ecp;
93*0Sstevel@tonic-gate
94*0Sstevel@tonic-gate *ecp = '\0';
95*0Sstevel@tonic-gate
96*0Sstevel@tonic-gate if ((ap = inet_htop(hcp)) != NULL)
97*0Sstevel@tonic-gate (void) strlcpy(hostaddress, ap, hsize);
98*0Sstevel@tonic-gate else
99*0Sstevel@tonic-gate (void) strlcpy(hostaddress, hcp, hsize);
100*0Sstevel@tonic-gate
101*0Sstevel@tonic-gate (void) strlcpy(accesspath, acp, asize);
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gate return (1);
104*0Sstevel@tonic-gate }
105*0Sstevel@tonic-gate return (0);
106*0Sstevel@tonic-gate }
107*0Sstevel@tonic-gate #endif
108