Annotation of coherent/g/usr/lib/uucp/tay104/uuconf/hdial.c, revision 1.1

1.1     ! root        1: /* hdial.c
        !             2:    Find a dialer in the HDB configuration files.
        !             3: 
        !             4:    Copyright (C) 1992 Ian Lance Taylor
        !             5: 
        !             6:    This file is part of the Taylor UUCP uuconf library.
        !             7: 
        !             8:    This library is free software; you can redistribute it and/or
        !             9:    modify it under the terms of the GNU Library General Public License
        !            10:    as published by the Free Software Foundation; either version 2 of
        !            11:    the License, or (at your option) any later version.
        !            12: 
        !            13:    This library is distributed in the hope that it will be useful, but
        !            14:    WITHOUT ANY WARRANTY; without even the implied warranty of
        !            15:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        !            16:    Library General Public License for more details.
        !            17: 
        !            18:    You should have received a copy of the GNU Library General Public
        !            19:    License along with this library; if not, write to the Free Software
        !            20:    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
        !            21: 
        !            22:    The author of the program may be contacted at [email protected] or
        !            23:    c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
        !            24:    */
        !            25: 
        !            26: #include "uucnfi.h"
        !            27: 
        !            28: #if USE_RCS_ID
        !            29: const char _uuconf_hdial_rcsid[] = "$Id: hdial.c,v 1.1 93/07/30 08:07:13 bin Exp Locker: bin $";
        !            30: #endif
        !            31: 
        !            32: #include <errno.h>
        !            33: #include <ctype.h>
        !            34: 
        !            35: /* Find a dialer in the HDB configuration files by name.  */
        !            36: 
        !            37: int
        !            38: uuconf_hdb_dialer_info (pglobal, zname, qdialer)
        !            39:      pointer pglobal;
        !            40:      const char *zname;
        !            41:      struct uuconf_dialer *qdialer;
        !            42: {
        !            43:   struct sglobal *qglobal = (struct sglobal *) pglobal;
        !            44:   char **pz;
        !            45:   char *zline;
        !            46:   size_t cline;
        !            47:   char **pzsplit;
        !            48:   size_t csplit;
        !            49:   int iret;
        !            50: 
        !            51:   zline = NULL;
        !            52:   cline = 0;
        !            53:   pzsplit = NULL;
        !            54:   csplit = 0;
        !            55: 
        !            56:   iret = UUCONF_NOT_FOUND;
        !            57: 
        !            58:   for (pz = qglobal->qprocess->pzhdb_dialers; *pz != NULL; pz++)
        !            59:     {
        !            60:       FILE *e;
        !            61:       int cchars;
        !            62: 
        !            63:       qglobal->ilineno = 0;
        !            64: 
        !            65:       e = fopen (*pz, "r");
        !            66:       if (e == NULL)
        !            67:        {
        !            68:          if (FNO_SUCH_FILE ())
        !            69:            continue;
        !            70:          qglobal->ierrno = errno;
        !            71:          iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
        !            72:          break;
        !            73:        }
        !            74: 
        !            75:       while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)
        !            76:        {
        !            77:          int ctoks;
        !            78:          pointer pblock;
        !            79: 
        !            80:          ++qglobal->ilineno;
        !            81: 
        !            82:          --cchars;
        !            83:          if (zline[cchars] == '\n')
        !            84:            zline[cchars] = '\0';
        !            85:          if (isspace (BUCHAR (zline[0])) || zline[0] == '#')
        !            86:            continue;
        !            87: 
        !            88:          ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit);
        !            89:          if (ctoks < 0)
        !            90:            {
        !            91:              qglobal->ierrno = errno;
        !            92:              iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
        !            93:              break;
        !            94:            }
        !            95: 
        !            96:          if (ctoks < 1)
        !            97:            continue;
        !            98: 
        !            99:          if (strcmp (zname, pzsplit[0]) != 0)
        !           100:            continue;
        !           101: 
        !           102:          /* We found the dialer.  */
        !           103:          pblock = uuconf_malloc_block ();
        !           104:          if (pblock == NULL)
        !           105:            {
        !           106:              qglobal->ierrno = errno;
        !           107:              iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
        !           108:              break;
        !           109:            }
        !           110:          if (uuconf_add_block (pblock, zline) != 0)
        !           111:            {
        !           112:              qglobal->ierrno = errno;
        !           113:              uuconf_free_block (pblock);
        !           114:              iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
        !           115:              break;
        !           116:            }
        !           117:          zline = NULL;
        !           118: 
        !           119:          _uuconf_uclear_dialer (qdialer);
        !           120:          qdialer->uuconf_zname = pzsplit[0];
        !           121:          qdialer->uuconf_palloc = pblock;
        !           122: 
        !           123:          if (ctoks > 1)
        !           124:            {
        !           125:              /* The second field is characters to send instead of "="
        !           126:                 and "-" in phone numbers.  */
        !           127:              if (strcmp (pzsplit[1], "\"\"") == 0)
        !           128:                {
        !           129:                  char *zsubs;
        !           130:                  char bnext;
        !           131: 
        !           132:                  zsubs = pzsplit[1];
        !           133:                  bnext = *zsubs;
        !           134:                  while (bnext != '\0')
        !           135:                    {
        !           136:                      if (bnext == '=') 
        !           137:                        qdialer->uuconf_zdialtone = zsubs + 1;
        !           138:                      else if (bnext == '-')
        !           139:                        qdialer->uuconf_zpause = zsubs + 1;
        !           140:                      if (zsubs[1] == '\0')
        !           141:                        break;
        !           142:                      zsubs += 2;
        !           143:                      bnext = *zsubs;
        !           144:                      *zsubs = '\0';
        !           145:                    }
        !           146:                }
        !           147: 
        !           148:              /* Any remaining fields form a chat script.  */
        !           149:              if (ctoks > 2)
        !           150:                {
        !           151:                  pzsplit[1] = (char *) "chat";
        !           152:                  iret = _uuconf_ichat_cmd (qglobal, ctoks - 1,
        !           153:                                            pzsplit + 1,
        !           154:                                            &qdialer->uuconf_schat,
        !           155:                                            pblock);
        !           156:                  iret &=~ UUCONF_CMDTABRET_KEEP;
        !           157:                  if (iret != UUCONF_SUCCESS)
        !           158:                    {
        !           159:                      uuconf_free_block (pblock);
        !           160:                      break;
        !           161:                    }
        !           162:                }
        !           163:            }
        !           164: 
        !           165:          iret = UUCONF_SUCCESS;
        !           166:          break;
        !           167:        }
        !           168: 
        !           169:       (void) fclose (e);
        !           170: 
        !           171:       if (iret != UUCONF_NOT_FOUND)
        !           172:        break;
        !           173:     }
        !           174: 
        !           175:   if (zline != NULL)
        !           176:     free ((pointer) zline);
        !           177:   if (pzsplit != NULL)
        !           178:     free ((pointer) pzsplit);
        !           179: 
        !           180:   if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND)
        !           181:     {
        !           182:       qglobal->zfilename = *pz;
        !           183:       iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
        !           184:     }
        !           185: 
        !           186:   return iret;
        !           187: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.