1: #include    "link.h"
   2: /* linker support functions */
   3: 
   4: 
   5: 
   6: char *strcpy(), *strcat();
   7: /************************  lerror  ****************************************/
   8: 
   9: 
  10: lerror(mess)    /* linker program error, print message and exit */
  11: register char   *mess;
  12: {
  13:     fprintf(stderr, "linker program error: %s\n", mess);
  14:     bail_out();
  15: }
  16: 
  17: 
  18: /**************************  dc_symbol  **************************************/
  19: 
  20: 
  21: dc_symbol(s)    /* decode rad50 symbol in input stream and place in */
  22:         /* the buffer s. */
  23: register char   *s;
  24: 
  25: {
  26:     WORD getword();
  27: 
  28:     derad50(getword(), s);
  29:     derad50(getword(), s + 3);
  30:     *(s + 6) = '\0';
  31: }
  32: 
  33: 
  34: /******************************  derad50  ************************************/
  35: 
  36: 
  37: derad50(x,s)        /* decode a word in which 3 characters are coded by */
  38:             /* the RAD50 scheme. */
  39: register unsigned short x;
  40: register char   *s;
  41: 
  42: {
  43:     s[2] = returnchar(x % 40);
  44:     x /= 40;
  45:     s[1] = returnchar(x % 40);
  46:     x /= 40;
  47:     s[0] = returnchar(x % 40);
  48: }
  49: 
  50: 
  51: /******************************  returnchar  *******************************/
  52: 
  53: 
  54: returnchar(k)       /* return a character according to RAD50 coding */
  55:             /* scheme, called by derad50 */
  56: register unsigned short k;
  57: {
  58:     if (k >= 1 && k <= 26)
  59:         /* k represents a letter */
  60:         return('a' + k - 1);
  61: 
  62:     else if (k >= 30 && k <= 39)
  63:         /* k represents a digit */
  64:         return('0' + k - 30);
  65: 
  66:     else switch (k)
  67:     {
  68:         case 0:
  69:             return(' ');
  70: 
  71:         case 27:
  72:             return('$');
  73: 
  74:         case 28:
  75:             return('.');
  76: 
  77:         case 29:
  78:             return ('_');
  79: 
  80:         default:
  81:             lerror("RAD50 non-character");
  82:             /* NOTREACHED */
  83:     }
  84: 
  85: }
  86: 
  87: 
  88: /*****************************  lalloc  **************************************/
  89: 
  90: 
  91: char    *lalloc(amount)     /* storage allocator, calls calloc and if */
  92:                 /* null is returned calls error */
  93: register int    amount;     /* number of bytes of storage needed */
  94: {
  95:     char *calloc();
  96:     register char   *temp;
  97: 
  98:     if ((temp = calloc(1, (unsigned)amount)) == NULL)
  99:     {
 100:         fprintf(stderr, "Error: core size exceeded.\n");
 101:         bail_out();
 102:         /* NOTREACHED */
 103:     }
 104:     else
 105:         return (temp);
 106: }
 107: 
 108: 
 109: /**********************************  tack  ***********************************/
 110: 
 111: 
 112: char    *tack(s, t) /* catenate s with t if s does not already end with t */
 113: 
 114: register char   *s;
 115: register char   *t;
 116: {
 117:     register char   *new;
 118:     int         s_len;
 119:     int     t_len;
 120: 
 121:     s_len = strlen(s);
 122:     t_len = strlen(t);
 123:     if (s_len < t_len || strcmp(s + s_len - t_len, t))
 124:     {
 125:         new = lalloc(s_len + t_len + 1);
 126:         strcpy(new, s);
 127:         strcat(new, t);
 128:         return(new);
 129:     }
 130:     else
 131:         return (s);
 132: }
 133: 
 134: 
 135: /******************************  strip  ************************************/
 136: 
 137: 
 138: strip(s, t) /* strip t off the end of s if it is there */
 139: 
 140: register char   *s;
 141: register char   *t;
 142: {
 143:     register int    s_len;
 144:     int     t_len;
 145: 
 146:     s_len = strlen(s);
 147:     t_len = strlen(t);
 148:     if (s_len >= t_len && !strcmp(s + s_len - t_len, t))
 149:         *(s + s_len - t_len) = '\0';
 150: }

Defined functions

dc_symbol defined in line 21; used 19 times
derad50 defined in line 37; used 2 times
lalloc defined in line 91; used 9 times
lerror defined in line 10; used 15 times
returnchar defined in line 54; used 3 times
strip defined in line 138; used 3 times
tack defined in line 112; used 8 times
Last modified: 1982-12-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2795
Valid CSS Valid XHTML 1.0 Strict