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