1: #ifndef lint
   2: static char sccsid[] = "@(#)bind.c	4.2 (Berkeley) 7/7/83";
   3: #endif
   4: 
   5: /*
   6:  * Courier connection management.
   7:  */
   8: #include <stdio.h>
   9: #include "courier.h"
  10: 
  11: #if DEBUG
  12: extern int CourierClientDebuggingFlag;
  13: #endif
  14: 
  15: #define NBINDINGS   10
  16: 
  17: struct binding {
  18:     char *program;      /* Courier program name or 0 */
  19:     char *machine;      /* machine name */
  20:     int connection;     /* open connection descriptor */
  21: } btab[NBINDINGS];
  22: 
  23: CourierProgram(program, machine)
  24:     char *program, *machine;
  25: {
  26:     register struct binding *bp, *x;
  27:     extern char *malloc();
  28: 
  29:     x = 0;
  30:     for (bp = &btab[0]; bp < &btab[NBINDINGS]; bp++)
  31:         if (bp->program != 0) {
  32:             if (strcmp(bp->program, program) == 0 &&
  33:                 strcmp(bp->machine, machine) == 0)
  34:                 if (bp->connection >= 0)
  35:                     return (bp->connection);
  36:                 else
  37:                     goto connect;
  38:         } else
  39:             x = bp;
  40:     if (x == 0) {
  41:         fprintf(stderr, "Too many active Courier programs.\n");
  42:         exit(1);
  43:     }
  44:     bp = x;
  45:     bp->program = malloc(strlen(program)+1);
  46:     strcpy(bp->program, program);
  47:     bp->machine = malloc(strlen(machine)+1);
  48:     strcpy(bp->machine, machine);
  49: connect:
  50:     bp->connection = CourierActivate(bp->program, bp->machine);
  51:     if (bp->connection >= 0)
  52:         return (bp->connection);
  53: }
  54: 
  55: CourierDeactivate(program, machine)
  56:     char *program, *machine;
  57: {
  58:     register struct binding *bp;
  59: 
  60:     for (bp = &btab[0]; bp < &btab[NBINDINGS]; bp++)
  61:         if (bp->program != 0 &&
  62:             strcmp(bp->program, program) == 0 &&
  63:             strcmp(bp->machine, machine) == 0) {
  64:             free(bp->program);
  65:             free(bp->machine);
  66:             close(bp->connection);
  67:             bp->program = 0;
  68:             bp->machine = 0;
  69:             bp->connection = -1;
  70:             return;
  71:         }
  72: }

Defined functions

CourierDeactivate defined in line 55; never used
CourierProgram defined in line 23; never used

Defined variables

btab defined in line 21; used 4 times
  • in line 30(2), 60(2)
sccsid defined in line 2; never used

Defined struct's

binding defined in line 17; used 4 times
  • in line 26(2), 58(2)

Defined macros

NBINDINGS defined in line 15; used 3 times
Last modified: 1983-07-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 593
Valid CSS Valid XHTML 1.0 Strict