Annotation of coherent/g/usr/lib/uucp/tay104/uuconf/tcalou.c, revision 1.1.1.1

1.1       root        1: /* tcalou.c
                      2:    Find callout login name and password from Taylor UUCP 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_tcalou_rcsid[] = "$Id: tcalou.c,v 1.1 93/07/30 08:07:38 bin Exp Locker: bin $";
                     30: #endif
                     31: 
                     32: #include <errno.h>
                     33: 
                     34: static int icsys P((pointer pglobal, int argc, char **argv, pointer pvar,
                     35:                    pointer pinfo));
                     36: 
                     37: /* Find the callout login name and password for a system from the
                     38:    Taylor UUCP configuration files.  */
                     39: 
                     40: int
                     41: uuconf_taylor_callout (pglobal, qsys, pzlog, pzpass)
                     42:      pointer pglobal;
                     43:      const struct uuconf_system *qsys;
                     44:      char **pzlog;
                     45:      char **pzpass;
                     46: {
                     47:   struct sglobal *qglobal = (struct sglobal *) pglobal;
                     48:   boolean flookup;
                     49:   struct uuconf_cmdtab as[2];
                     50:   char **pz;
                     51:   int iret;
                     52:   pointer pinfo;
                     53: 
                     54:   *pzlog = NULL;
                     55:   *pzpass = NULL;
                     56: 
                     57:   flookup = FALSE;
                     58: 
                     59:   if (qsys->uuconf_zcall_login != NULL)
                     60:     {
                     61:       if (strcmp (qsys->uuconf_zcall_login, "*") == 0)
                     62:        flookup = TRUE;
                     63:       else
                     64:        {
                     65:          *pzlog = strdup (qsys->uuconf_zcall_login);
                     66:          if (*pzlog == NULL)
                     67:            {
                     68:              qglobal->ierrno = errno;
                     69:              return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
                     70:            }
                     71:        }
                     72:     }
                     73: 
                     74:   if (qsys->uuconf_zcall_password != NULL)
                     75:     {
                     76:       if (strcmp (qsys->uuconf_zcall_password, "*") == 0)
                     77:        flookup = TRUE;
                     78:       else
                     79:        {
                     80:          *pzpass = strdup (qsys->uuconf_zcall_password);
                     81:          if (*pzpass == NULL)
                     82:            {
                     83:              qglobal->ierrno = errno;
                     84:              if (*pzlog != NULL)
                     85:                {
                     86:                  free ((pointer) *pzlog);
                     87:                  *pzlog = NULL;
                     88:                }
                     89:              return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
                     90:            }
                     91:        }
                     92:     }
                     93: 
                     94:   if (! flookup)
                     95:     {
                     96:       if (*pzlog == NULL && *pzpass == NULL)
                     97:        return UUCONF_NOT_FOUND;
                     98:       return UUCONF_SUCCESS;
                     99:     }
                    100: 
                    101:   as[0].uuconf_zcmd = qsys->uuconf_zname;
                    102:   as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 3;
                    103:   if (*pzlog == NULL)
                    104:     as[0].uuconf_pvar = (pointer) pzlog;
                    105:   else
                    106:     as[0].uuconf_pvar = NULL;
                    107:   as[0].uuconf_pifn = icsys;
                    108: 
                    109:   as[1].uuconf_zcmd = NULL;
                    110: 
                    111:   if (*pzpass == NULL)
                    112:     pinfo = (pointer) pzpass;
                    113:   else
                    114:     pinfo = NULL;
                    115: 
                    116:   iret = UUCONF_SUCCESS;
                    117: 
                    118:   for (pz = qglobal->qprocess->pzcallfiles; *pz != NULL; pz++)
                    119:     {
                    120:       FILE *e;
                    121: 
                    122:       e = fopen (*pz, "r");
                    123:       if (e == NULL)
                    124:        {
                    125:          if (FNO_SUCH_FILE ())
                    126:            continue;
                    127:          qglobal->ierrno = errno;
                    128:          iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
                    129:          break;
                    130:        }
                    131: 
                    132:       iret = uuconf_cmd_file (pglobal, e, as, pinfo,
                    133:                              (uuconf_cmdtabfn) NULL, 0,
                    134:                              qsys->uuconf_palloc);
                    135:       (void) fclose (e);
                    136: 
                    137:       if (iret != UUCONF_SUCCESS)
                    138:        break;
                    139:       if (*pzlog != NULL)
                    140:        break;
                    141:     }
                    142: 
                    143:   if (iret != UUCONF_SUCCESS)
                    144:     {
                    145:       qglobal->zfilename = *pz;
                    146:       return iret | UUCONF_ERROR_FILENAME;
                    147:     }
                    148: 
                    149:   if (*pzlog == NULL && *pzpass == NULL)
                    150:     return UUCONF_NOT_FOUND;
                    151: 
                    152:   return UUCONF_SUCCESS;
                    153: }
                    154: 
                    155: /* Copy the login name and password onto the heap and set the
                    156:    pointers.  The pzlog argument is passed in pvar, and the pzpass
                    157:    argument is passed in pinfo.  */
                    158: 
                    159: static int
                    160: icsys (pglobal, argc, argv, pvar, pinfo)
                    161:      pointer pglobal;
                    162:      int argc;
                    163:      char **argv;
                    164:      pointer pvar;
                    165:      pointer pinfo;
                    166: {
                    167:   struct sglobal *qglobal = (struct sglobal *) pglobal;
                    168:   char **pzlog = (char **) pvar;
                    169:   char **pzpass = (char **) pinfo;
                    170: 
                    171:   if (pzlog != NULL)
                    172:     {
                    173:       *pzlog = strdup (argv[1]);
                    174:       if (*pzlog == NULL)
                    175:        {
                    176:          qglobal->ierrno = errno;
                    177:          return (UUCONF_MALLOC_FAILED
                    178:                  | UUCONF_ERROR_ERRNO
                    179:                  | UUCONF_CMDTABRET_EXIT);
                    180:        }
                    181:     }
                    182: 
                    183:   if (pzpass != NULL)
                    184:     {
                    185:       *pzpass = strdup (argv[2]);
                    186:       if (*pzpass == NULL)
                    187:        {
                    188:          qglobal->ierrno = errno;
                    189:          if (pzlog != NULL)
                    190:            {
                    191:              free ((pointer) *pzlog);
                    192:              *pzlog = NULL;
                    193:            }
                    194:          return (UUCONF_MALLOC_FAILED
                    195:                  | UUCONF_ERROR_ERRNO
                    196:                  | UUCONF_CMDTABRET_EXIT);
                    197:        }
                    198:     }
                    199: 
                    200:   return UUCONF_CMDTABRET_EXIT;
                    201: }

unix.superglobalmegacorp.com

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