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

1.1     ! root        1: /* syssub.c
        !             2:    System information subroutines.
        !             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_syssub_rcsid[] = "$Id: syssub.c,v 1.1 93/07/30 08:07:35 bin Exp Locker: bin $";
        !            30: #endif
        !            31: 
        !            32: #include <errno.h>
        !            33: 
        !            34: /* This macro operates on every string (char *) field in struct
        !            35:    uuconf_system.  */
        !            36: #define SYSTEM_STRINGS(OP) \
        !            37:   do \
        !            38:     { \
        !            39:       OP (uuconf_zname); \
        !            40:       OP (uuconf_zalternate); \
        !            41:       OP (uuconf_zdebug); \
        !            42:       OP (uuconf_zmax_remote_debug); \
        !            43:       OP (uuconf_zphone); \
        !            44:       OP (uuconf_zcall_login); \
        !            45:       OP (uuconf_zcall_password); \
        !            46:       OP (uuconf_zcalled_login); \
        !            47:       OP (uuconf_zprotocols); \
        !            48:       OP (uuconf_zpubdir); \
        !            49:       OP (uuconf_zlocalname); \
        !            50:     } \
        !            51:   while (0)
        !            52: 
        !            53: /* This macro operates on every string array (char **) field in struct
        !            54:    uuconf_system.  */
        !            55: #define SYSTEM_STRING_ARRAYS(OP) \
        !            56:   do \
        !            57:     { \
        !            58:       OP (uuconf_pzalias); \
        !            59:       OP (uuconf_pzlocal_send); \
        !            60:       OP (uuconf_pzremote_send); \
        !            61:       OP (uuconf_pzlocal_receive); \
        !            62:       OP (uuconf_pzremote_receive); \
        !            63:       OP (uuconf_pzpath); \
        !            64:       OP (uuconf_pzcmds); \
        !            65:       OP (uuconf_pzforward_from); \
        !            66:       OP (uuconf_pzforward_to); \
        !            67:       OP (uuconf_schat.uuconf_pzchat); \
        !            68:       OP (uuconf_schat.uuconf_pzprogram); \
        !            69:       OP (uuconf_schat.uuconf_pzfail); \
        !            70:       OP (uuconf_scalled_chat.uuconf_pzchat); \
        !            71:       OP (uuconf_scalled_chat.uuconf_pzprogram); \
        !            72:       OP (uuconf_scalled_chat.uuconf_pzfail); \
        !            73:     } \
        !            74:   while (0)
        !            75: 
        !            76: /* This macro operations on every timespan pointer (struct
        !            77:    uuconf_timespan *) in struct uuconf_system.  */
        !            78: #define SYSTEM_TIMESPANS(OP) \
        !            79:   do \
        !            80:     { \
        !            81:       OP (uuconf_qtimegrade); \
        !            82:       OP (uuconf_qcalltimegrade); \
        !            83:       OP (uuconf_qcall_local_size); \
        !            84:       OP (uuconf_qcall_remote_size); \
        !            85:       OP (uuconf_qcalled_local_size); \
        !            86:       OP (uuconf_qcalled_remote_size); \
        !            87:     } \
        !            88:   while (0)
        !            89: 
        !            90: /* This macro operates on every boolean value (of type int, although
        !            91:    some type int are not boolean) field in uuconf_system.  */
        !            92: #define SYSTEM_BOOLEANS(OP) \
        !            93:   do \
        !            94:     { \
        !            95:       OP (uuconf_fcall); \
        !            96:       OP (uuconf_fcalled); \
        !            97:       OP (uuconf_fcallback); \
        !            98:       OP (uuconf_fsequence); \
        !            99:       OP (uuconf_fsend_request); \
        !           100:       OP (uuconf_frec_request); \
        !           101:       OP (uuconf_fcall_transfer); \
        !           102:       OP (uuconf_fcalled_transfer); \
        !           103:       OP (uuconf_schat.uuconf_fstrip); \
        !           104:       OP (uuconf_scalled_chat.uuconf_fstrip); \
        !           105:     } \
        !           106:   while (0)
        !           107: 
        !           108: /* This macro operates on every generic integer (type int or long) in
        !           109:    uuconf_system.  */
        !           110: #define SYSTEM_INTEGERS(OP) \
        !           111:   do \
        !           112:     { \
        !           113:       OP (uuconf_cmax_retries); \
        !           114:       OP (uuconf_csuccess_wait); \
        !           115:       OP (uuconf_ibaud); \
        !           116:       OP (uuconf_ihighbaud); \
        !           117:       OP (uuconf_cfree_space); \
        !           118:       OP (uuconf_schat.uuconf_ctimeout); \
        !           119:       OP (uuconf_scalled_chat.uuconf_ctimeout); \
        !           120:     } \
        !           121:   while (0)
        !           122: 
        !           123: /* There is no macro for uuconf_qalternate, uuconf_zport,
        !           124:    uuconf_qport, uuconf_qproto_params, or uuconf_palloc.  */
        !           125: 
        !           126: /* Clear the contents of a struct uuconf_system.  */
        !           127: 
        !           128: void
        !           129: _uuconf_uclear_system (q)
        !           130:      struct uuconf_system *q;
        !           131: {
        !           132: #define CLEAR(x) q->x = (char *) &_uuconf_unset
        !           133:   SYSTEM_STRINGS (CLEAR);
        !           134: #undef CLEAR
        !           135: #define CLEAR(x) q->x = (char **) &_uuconf_unset
        !           136:   SYSTEM_STRING_ARRAYS (CLEAR);
        !           137: #undef CLEAR
        !           138: #define CLEAR(x) q->x = (struct uuconf_timespan *) &_uuconf_unset
        !           139:   SYSTEM_TIMESPANS (CLEAR);
        !           140: #undef CLEAR
        !           141: #define CLEAR(x) q->x = -1
        !           142:   SYSTEM_BOOLEANS (CLEAR);
        !           143:   SYSTEM_INTEGERS (CLEAR);
        !           144: #undef CLEAR
        !           145:   q->uuconf_qalternate = NULL;
        !           146:   q->uuconf_zport = (char *) &_uuconf_unset;
        !           147:   q->uuconf_qport = (struct uuconf_port *) &_uuconf_unset;
        !           148:   q->uuconf_qproto_params = (struct uuconf_proto_param *) &_uuconf_unset;
        !           149:   q->uuconf_palloc = NULL;
        !           150: }
        !           151: 
        !           152: /* Default the contents of one struct uuconf_system to the contents of
        !           153:    another.  This default alternate by alternate.  Any additional
        !           154:    alternates in q default to the last alternate of qdefault.  If the
        !           155:    faddalternates arguments is TRUE, additional alternates or qdefault
        !           156:    are added to q; these alternates are copies of the first alternate
        !           157:    of q, and defaults are set from the additional alternates of
        !           158:    qdefault.  */
        !           159: 
        !           160: int
        !           161: _uuconf_isystem_default (qglobal, qset, qdefault, faddalternates)
        !           162:      struct sglobal *qglobal;
        !           163:      struct uuconf_system *qset;
        !           164:      struct uuconf_system *qdefault;
        !           165:      boolean faddalternates;
        !           166: {
        !           167:   struct uuconf_system *qalt;
        !           168: 
        !           169:   if (qset->uuconf_palloc != qdefault->uuconf_palloc)
        !           170:     qset->uuconf_palloc =
        !           171:       _uuconf_pmalloc_block_merge (qset->uuconf_palloc,
        !           172:                                   qdefault->uuconf_palloc);
        !           173: 
        !           174:   /* If we are adding alternates from the default, make sure we have
        !           175:      at least as many alternates in qset as we do in qdefault.  Each
        !           176:      new alternate we create gets initialized to the first alternate
        !           177:      of the system.  */
        !           178:   if (faddalternates)
        !           179:     {
        !           180:       struct uuconf_system **pq, *qdef;
        !           181: 
        !           182:       for (qdef = qdefault, pq = &qset;
        !           183:           qdef != NULL;
        !           184:           qdef = qdef->uuconf_qalternate, pq = &(*pq)->uuconf_qalternate)
        !           185:        {
        !           186:          if (*pq == NULL)
        !           187:            {
        !           188:              *pq = ((struct uuconf_system *)
        !           189:                     uuconf_malloc (qset->uuconf_palloc,
        !           190:                                    sizeof (struct uuconf_system)));
        !           191:              if (*pq == NULL)
        !           192:                {
        !           193:                  qglobal->ierrno = errno;
        !           194:                  return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
        !           195:                }
        !           196:              **pq = *qset;
        !           197:              (*pq)->uuconf_qalternate = NULL;
        !           198:            }
        !           199:        }
        !           200:     }
        !           201: 
        !           202:   for (qalt = qset; qalt != NULL; qalt = qalt->uuconf_qalternate)
        !           203:     {
        !           204: #define DEFAULT(x) \
        !           205:   if (qalt->x == (char *) &_uuconf_unset) qalt->x = qdefault->x
        !           206:       SYSTEM_STRINGS (DEFAULT);
        !           207: #undef DEFAULT
        !           208: #define DEFAULT(x) \
        !           209:   if (qalt->x == (char **) &_uuconf_unset) qalt->x = qdefault->x
        !           210:       SYSTEM_STRING_ARRAYS (DEFAULT);
        !           211: #undef DEFAULT
        !           212: #define DEFAULT(x) \
        !           213:   if (qalt->x == (struct uuconf_timespan *) &_uuconf_unset) \
        !           214:     qalt->x = qdefault->x
        !           215:       SYSTEM_TIMESPANS (DEFAULT);
        !           216: #undef DEFAULT
        !           217: #define DEFAULT(x) if (qalt->x < 0) qalt->x = qdefault->x
        !           218:       SYSTEM_BOOLEANS (DEFAULT);
        !           219:       SYSTEM_INTEGERS (DEFAULT);
        !           220: #undef DEFAULT
        !           221: 
        !           222:       /* We only copy over zport if both zport and qport are NULL,
        !           223:         because otherwise a default zport would override a specific
        !           224:         qport.  */
        !           225:       if (qalt->uuconf_zport == (char *) &_uuconf_unset
        !           226:          && qalt->uuconf_qport == (struct uuconf_port *) &_uuconf_unset)
        !           227:        qalt->uuconf_zport = qdefault->uuconf_zport;
        !           228:       if (qalt->uuconf_qport == (struct uuconf_port *) &_uuconf_unset)
        !           229:        qalt->uuconf_qport = qdefault->uuconf_qport;
        !           230: 
        !           231:       if (qalt->uuconf_qproto_params
        !           232:          == (struct uuconf_proto_param *) &_uuconf_unset)
        !           233:        qalt->uuconf_qproto_params = qdefault->uuconf_qproto_params;
        !           234: 
        !           235:       if (qdefault->uuconf_qalternate != NULL)
        !           236:        qdefault = qdefault->uuconf_qalternate;
        !           237:     }
        !           238: 
        !           239:   return UUCONF_SUCCESS;
        !           240: }
        !           241: 
        !           242: /* Put in the basic defaults.  This ensures that the fields are valid
        !           243:    on every uuconf_system structure.  */
        !           244: 
        !           245: int
        !           246: _uuconf_isystem_basic_default (qglobal, q)
        !           247:      struct sglobal *qglobal;
        !           248:      register struct uuconf_system *q;
        !           249: {
        !           250:   int iret;
        !           251: 
        !           252:   iret = UUCONF_SUCCESS;
        !           253: 
        !           254:   for (; q != NULL && iret == UUCONF_SUCCESS; q = q->uuconf_qalternate)
        !           255:     {
        !           256:       /* The default of 26 allowable retries is traditional.  */
        !           257:       if (q->uuconf_cmax_retries < 0)
        !           258:        q->uuconf_cmax_retries = 26;
        !           259:       if (q->uuconf_schat.uuconf_pzchat == (char **) &_uuconf_unset)
        !           260:        {
        !           261:          q->uuconf_schat.uuconf_pzchat = NULL;
        !           262:          iret = _uuconf_iadd_string (qglobal, (char *) "\"\"", FALSE,
        !           263:                                      FALSE,
        !           264:                                      &q->uuconf_schat.uuconf_pzchat,
        !           265:                                      q->uuconf_palloc);
        !           266:          if (iret != UUCONF_SUCCESS)
        !           267:            return iret;
        !           268:          iret = _uuconf_iadd_string (qglobal, (char *) "\\r\\c", FALSE,
        !           269:                                      FALSE,
        !           270:                                      &q->uuconf_schat.uuconf_pzchat,
        !           271:                                      q->uuconf_palloc);
        !           272:          if (iret != UUCONF_SUCCESS)
        !           273:            return iret;
        !           274:          iret = _uuconf_iadd_string (qglobal, (char *) "ogin:", FALSE,
        !           275:                                      FALSE,
        !           276:                                      &q->uuconf_schat.uuconf_pzchat,
        !           277:                                      q->uuconf_palloc);
        !           278:          if (iret != UUCONF_SUCCESS)
        !           279:            return iret;
        !           280:          iret = _uuconf_iadd_string (qglobal, (char *) "-BREAK", FALSE,
        !           281:                                      FALSE,
        !           282:                                      &q->uuconf_schat.uuconf_pzchat,
        !           283:                                      q->uuconf_palloc);
        !           284:          if (iret != UUCONF_SUCCESS)
        !           285:            return iret;
        !           286:          iret = _uuconf_iadd_string (qglobal, (char *) "-ogin:", FALSE,
        !           287:                                      FALSE,
        !           288:                                      &q->uuconf_schat.uuconf_pzchat,
        !           289:                                      q->uuconf_palloc);
        !           290:          if (iret != UUCONF_SUCCESS)
        !           291:            return iret;
        !           292:          iret = _uuconf_iadd_string (qglobal, (char *) "-BREAK", FALSE,
        !           293:                                      FALSE,
        !           294:                                      &q->uuconf_schat.uuconf_pzchat,
        !           295:                                      q->uuconf_palloc);
        !           296:          if (iret != UUCONF_SUCCESS)
        !           297:            return iret;
        !           298:          iret = _uuconf_iadd_string (qglobal, (char *) "-ogin:", FALSE,
        !           299:                                      FALSE,
        !           300:                                      &q->uuconf_schat.uuconf_pzchat,
        !           301:                                      q->uuconf_palloc);
        !           302:          if (iret != UUCONF_SUCCESS)
        !           303:            return iret;
        !           304:          iret = _uuconf_iadd_string (qglobal, (char *) "\\L", FALSE,
        !           305:                                      FALSE,
        !           306:                                      &q->uuconf_schat.uuconf_pzchat,
        !           307:                                      q->uuconf_palloc);
        !           308:          if (iret != UUCONF_SUCCESS)
        !           309:            return iret;
        !           310:          iret = _uuconf_iadd_string (qglobal, (char *) "word:", FALSE,
        !           311:                                      FALSE,
        !           312:                                      &q->uuconf_schat.uuconf_pzchat,
        !           313:                                      q->uuconf_palloc);
        !           314:          if (iret != UUCONF_SUCCESS)
        !           315:            return iret;
        !           316:          iret = _uuconf_iadd_string (qglobal, (char *) "\\P", FALSE,
        !           317:                                      FALSE,
        !           318:                                      &q->uuconf_schat.uuconf_pzchat,
        !           319:                                      q->uuconf_palloc);
        !           320:          if (iret != UUCONF_SUCCESS)
        !           321:            return iret;
        !           322:        }
        !           323:       if (q->uuconf_schat.uuconf_ctimeout < 0)
        !           324:        q->uuconf_schat.uuconf_ctimeout = 10;
        !           325:       if (q->uuconf_schat.uuconf_fstrip < 0)
        !           326:        q->uuconf_schat.uuconf_fstrip = TRUE;
        !           327:       if (q->uuconf_scalled_chat.uuconf_ctimeout < 0)
        !           328:        q->uuconf_scalled_chat.uuconf_ctimeout = 60;
        !           329:       if (q->uuconf_scalled_chat.uuconf_fstrip < 0)
        !           330:        q->uuconf_scalled_chat.uuconf_fstrip = TRUE;
        !           331:       if (q->uuconf_fsend_request < 0)
        !           332:        q->uuconf_fsend_request = TRUE;
        !           333:       if (q->uuconf_frec_request < 0)
        !           334:        q->uuconf_frec_request = TRUE;
        !           335:       if (q->uuconf_fcall_transfer < 0)
        !           336:        q->uuconf_fcall_transfer = TRUE;
        !           337:       if (q->uuconf_fcalled_transfer < 0)
        !           338:        q->uuconf_fcalled_transfer = TRUE;
        !           339:       if (q->uuconf_pzlocal_send == (char **) &_uuconf_unset)
        !           340:        {
        !           341:          q->uuconf_pzlocal_send = NULL;
        !           342:          iret = _uuconf_iadd_string (qglobal, (char *) ZROOTDIR, FALSE,
        !           343:                                      FALSE, &q->uuconf_pzlocal_send,
        !           344:                                      q->uuconf_palloc);
        !           345:          if (iret != UUCONF_SUCCESS)
        !           346:            return iret;
        !           347:        }
        !           348:       if (q->uuconf_pzremote_send == (char **) &_uuconf_unset)
        !           349:        {
        !           350:          q->uuconf_pzremote_send = NULL;
        !           351:          iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE,
        !           352:                                      &q->uuconf_pzremote_send,
        !           353:                                      q->uuconf_palloc);
        !           354:          if (iret != UUCONF_SUCCESS)
        !           355:            return iret;
        !           356:        }
        !           357:       if (q->uuconf_pzlocal_receive == (char **) &_uuconf_unset)
        !           358:        {
        !           359:          q->uuconf_pzlocal_receive = NULL;
        !           360:          iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE,
        !           361:                                      &q->uuconf_pzlocal_receive,
        !           362:                                      q->uuconf_palloc);
        !           363:          if (iret != UUCONF_SUCCESS)
        !           364:            return iret;
        !           365:        }
        !           366:       if (q->uuconf_pzremote_receive == (char **) &_uuconf_unset)
        !           367:        {
        !           368:          q->uuconf_pzremote_receive = NULL;
        !           369:          iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE,
        !           370:                                      &q->uuconf_pzremote_receive,
        !           371:                                      q->uuconf_palloc);
        !           372:          if (iret != UUCONF_SUCCESS)
        !           373:            return iret;
        !           374:        }
        !           375: 
        !           376:       if (q->uuconf_pzpath == (char **) &_uuconf_unset)
        !           377:        {
        !           378:          char *zdup;
        !           379:          char **pz;
        !           380:          size_t csplit;
        !           381:          int c;
        !           382: 
        !           383:          zdup = (char *) uuconf_malloc (q->uuconf_palloc, sizeof CMDPATH);
        !           384:          if (zdup == NULL)
        !           385:            {
        !           386:              qglobal->ierrno = errno;
        !           387:              return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
        !           388:            }
        !           389:                  
        !           390:          memcpy ((pointer) zdup, (pointer) CMDPATH, sizeof CMDPATH);
        !           391:          pz = NULL;
        !           392:          csplit = 0;
        !           393:          if ((c = _uuconf_istrsplit (zdup, '\0', &pz, &csplit)) < 0)
        !           394:            {
        !           395:              qglobal->ierrno = errno;
        !           396:              return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
        !           397:            }
        !           398:          q->uuconf_pzpath = (char **) uuconf_malloc (q->uuconf_palloc,
        !           399:                                                      ((c + 1)
        !           400:                                                       * sizeof (char *)));
        !           401:          if (q->uuconf_pzpath == NULL)
        !           402:            {
        !           403:              qglobal->ierrno = errno;
        !           404:              return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
        !           405:            }
        !           406:          memcpy ((pointer) q->uuconf_pzpath, (pointer) pz,
        !           407:                  c * sizeof (char *));
        !           408:          q->uuconf_pzpath[c] = NULL;
        !           409:          free ((pointer) pz);
        !           410:        }
        !           411: 
        !           412:       if (q->uuconf_pzcmds == (char **) &_uuconf_unset)
        !           413:        {
        !           414:          q->uuconf_pzcmds = ((char **)
        !           415:                              uuconf_malloc (q->uuconf_palloc,
        !           416:                                             3 * sizeof (const char *)));
        !           417:          if (q->uuconf_pzcmds == NULL)
        !           418:            {
        !           419:              qglobal->ierrno = errno;
        !           420:              return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
        !           421:            }
        !           422:          q->uuconf_pzcmds[0] = (char *) "rnews";
        !           423:          q->uuconf_pzcmds[1] = (char *) "rmail";
        !           424:          q->uuconf_pzcmds[2] = NULL;
        !           425:        }
        !           426: 
        !           427:       if (q->uuconf_cfree_space < 0)
        !           428:        q->uuconf_cfree_space = DEFAULT_FREE_SPACE;
        !           429: 
        !           430:       if (q->uuconf_zpubdir == (const char *) &_uuconf_unset)
        !           431:        q->uuconf_zpubdir = qglobal->qprocess->zpubdir;
        !           432: 
        !           433: #define SET(x) if (q->x == (char *) &_uuconf_unset) q->x = NULL
        !           434:       SYSTEM_STRINGS(SET);
        !           435: #undef SET
        !           436: #define SET(x) if (q->x == (char **) &_uuconf_unset) q->x = NULL
        !           437:       SYSTEM_STRING_ARRAYS(SET);
        !           438: #undef SET
        !           439: #define SET(x) \
        !           440:   if (q->x == (struct uuconf_timespan *) &_uuconf_unset) q->x = NULL
        !           441:       SYSTEM_TIMESPANS (SET);
        !           442: #undef SET
        !           443: #define SET(x) if (q->x < 0) q->x = 0
        !           444:       SYSTEM_BOOLEANS (SET);
        !           445:       SYSTEM_INTEGERS (SET);
        !           446: #undef SET
        !           447: 
        !           448:       if (q->uuconf_zport == (char *) &_uuconf_unset)
        !           449:        q->uuconf_zport = NULL;
        !           450:       if (q->uuconf_qport == (struct uuconf_port *) &_uuconf_unset)
        !           451:        q->uuconf_qport = NULL;
        !           452:       if (q->uuconf_qproto_params
        !           453:          == (struct uuconf_proto_param *) &_uuconf_unset)
        !           454:        q->uuconf_qproto_params = NULL;
        !           455:     }
        !           456: 
        !           457:   return iret;
        !           458: }

unix.superglobalmegacorp.com

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