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

1.1     ! root        1: /* paramc.c
        !             2:    Handle protocol-parameter commands.
        !             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_paramc_rcsid[] = "$Id: paramc.c,v 1.1 93/07/30 08:07:26 bin Exp Locker: bin $";
        !            30: #endif
        !            31: 
        !            32: #include <errno.h>
        !            33: 
        !            34: /* Handle protocol-parameter commands by inserting them into an array
        !            35:    of structures.  The return value may include UUCONF_CMDTABRET_KEEP
        !            36:    and UUCONF_CMDTABRET_EXIT, if appropriate.  */
        !            37: 
        !            38: int
        !            39: _uuconf_iadd_proto_param (qglobal, argc, argv, pqparam, pblock)
        !            40:      struct sglobal *qglobal;
        !            41:      int argc;
        !            42:      char **argv;
        !            43:      struct uuconf_proto_param **pqparam;
        !            44:      pointer pblock;
        !            45: {
        !            46:   struct uuconf_proto_param *q;
        !            47:   size_t c;
        !            48:   struct uuconf_proto_param_entry *qentry;
        !            49: 
        !            50:   if (argc < 2)
        !            51:     return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
        !            52: 
        !            53:   /* The first argument is the protocol character.  */
        !            54:   if (argv[0][1] != '\0')
        !            55:     return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
        !            56: 
        !            57:   if (*pqparam == NULL)
        !            58:     {
        !            59:       *pqparam = ((struct uuconf_proto_param *)
        !            60:                  uuconf_malloc (pblock,
        !            61:                                 2 * sizeof (struct uuconf_proto_param)));
        !            62:       if (*pqparam == NULL)
        !            63:        {
        !            64:          qglobal->ierrno = errno;
        !            65:          return (UUCONF_MALLOC_FAILED
        !            66:                  | UUCONF_ERROR_ERRNO
        !            67:                  | UUCONF_CMDTABRET_EXIT);
        !            68:        }
        !            69:       (*pqparam)[1].uuconf_bproto = '\0';
        !            70:       q = *pqparam;
        !            71:       q->uuconf_bproto = argv[0][0];
        !            72:       q->uuconf_qentries = NULL;
        !            73:     }
        !            74:   else
        !            75:     {
        !            76:       c = 0;
        !            77:       for (q = *pqparam; q->uuconf_bproto != '\0'; q++)
        !            78:        {
        !            79:          if (q->uuconf_bproto == argv[0][0])
        !            80:            break;
        !            81:          ++c;
        !            82:        }
        !            83: 
        !            84:       if (q->uuconf_bproto == '\0')
        !            85:        {
        !            86:          struct uuconf_proto_param *qnew;
        !            87: 
        !            88:          qnew = ((struct uuconf_proto_param *)
        !            89:                  uuconf_malloc (pblock,
        !            90:                                 ((c + 2)
        !            91:                                  * sizeof (struct uuconf_proto_param))));
        !            92:          if (qnew == NULL)
        !            93:            {
        !            94:              qglobal->ierrno = errno;
        !            95:              return (UUCONF_MALLOC_FAILED
        !            96:                      | UUCONF_ERROR_ERRNO
        !            97:                      | UUCONF_CMDTABRET_EXIT);
        !            98:            }
        !            99: 
        !           100:          memcpy ((pointer) qnew, (pointer) *pqparam,
        !           101:                  c * sizeof (struct uuconf_proto_param));
        !           102:          qnew[c + 1].uuconf_bproto = '\0';
        !           103: 
        !           104:          uuconf_free (pblock, *pqparam);
        !           105:          *pqparam = qnew;
        !           106: 
        !           107:          q = qnew + c;
        !           108:          q->uuconf_bproto = argv[0][0];
        !           109:          q->uuconf_qentries = NULL;
        !           110:        }
        !           111:     }
        !           112: 
        !           113:   if (q->uuconf_qentries == NULL)
        !           114:     {
        !           115:       qentry = ((struct uuconf_proto_param_entry *)
        !           116:                uuconf_malloc (pblock,
        !           117:                               2 * sizeof (struct uuconf_proto_param_entry)));
        !           118:       if (qentry == NULL)
        !           119:        {
        !           120:          qglobal->ierrno = errno;
        !           121:          return (UUCONF_MALLOC_FAILED
        !           122:                  | UUCONF_ERROR_ERRNO
        !           123:                  | UUCONF_CMDTABRET_EXIT);
        !           124:        }
        !           125: 
        !           126:       qentry[1].uuconf_cargs = 0;
        !           127:       q->uuconf_qentries = qentry;
        !           128:     }
        !           129:   else
        !           130:     {
        !           131:       struct uuconf_proto_param_entry *qnewent;
        !           132: 
        !           133:       c = 0;
        !           134:       for (qentry = q->uuconf_qentries; qentry->uuconf_cargs != 0; qentry++)
        !           135:        ++c;
        !           136: 
        !           137:       qnewent = ((struct uuconf_proto_param_entry *)
        !           138:                 uuconf_malloc (pblock,
        !           139:                                ((c + 2) *
        !           140:                                 sizeof (struct uuconf_proto_param_entry))));
        !           141:       if (qnewent == NULL)
        !           142:        {
        !           143:          qglobal->ierrno = errno;
        !           144:          return (UUCONF_MALLOC_FAILED
        !           145:                  | UUCONF_ERROR_ERRNO
        !           146:                  | UUCONF_CMDTABRET_EXIT);
        !           147:        }
        !           148: 
        !           149:       memcpy ((pointer) qnewent, (pointer) q->uuconf_qentries,
        !           150:              c * sizeof (struct uuconf_proto_param_entry));
        !           151:       qnewent[c + 1].uuconf_cargs = 0;
        !           152: 
        !           153:       uuconf_free (pblock, q->uuconf_qentries);
        !           154:       q->uuconf_qentries = qnewent;
        !           155: 
        !           156:       qentry = qnewent + c;
        !           157:     }
        !           158: 
        !           159:   qentry->uuconf_cargs = argc - 1;
        !           160:   qentry->uuconf_pzargs = (char **) uuconf_malloc (pblock,
        !           161:                                                   ((argc - 1)
        !           162:                                                    * sizeof (char *)));
        !           163:   if (qentry->uuconf_pzargs == NULL)
        !           164:     {
        !           165:       qglobal->ierrno = errno;
        !           166:       qentry->uuconf_cargs = 0;
        !           167:       return (UUCONF_MALLOC_FAILED
        !           168:              | UUCONF_ERROR_ERRNO
        !           169:              | UUCONF_CMDTABRET_EXIT);
        !           170:     }
        !           171:   memcpy ((pointer) qentry->uuconf_pzargs, (pointer) (argv + 1),
        !           172:          (argc - 1) * sizeof (char *));
        !           173: 
        !           174:   return UUCONF_CMDTABRET_KEEP;
        !           175: }

unix.superglobalmegacorp.com

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