1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)utility.c	5.1 (Berkeley) 5/30/85";
   9: #endif not lint
  10: 
  11: /*
  12: **  ASSORTED UTILITY ROUTINES
  13: */
  14: 
  15: /*
  16: **  BLOCK MOVE
  17: **
  18: **	Moves a block of storage of length `l' bytes from the data
  19: **	area pointed to by `a' to the area pointed to by `b'.
  20: **	Returns the address of the byte following the `b' field.
  21: **	Overflow of `b' is not tested.
  22: */
  23: 
  24: char *bmove(a, b, l)
  25: char    *a, *b;
  26: int l;
  27: {
  28:     register int        n;
  29:     register char       *p, *q;
  30: 
  31:     p = a;
  32:     q = b;
  33:     n = l;
  34:     while (n--)
  35:         *q++ = *p++;
  36:     return (q);
  37: }
  38: 
  39: 
  40: /*
  41: **  STRING EQUALITY TEST
  42: **	null-terminated strings `a' and `b' are tested for
  43: **	absolute equality.
  44: **	returns one if equal, zero otherwise.
  45: */
  46: 
  47: sequal(a, b)
  48: char    *a, *b;
  49: {
  50:     register char       *p, *q;
  51: 
  52:     p = a;
  53:     q = b;
  54:     while (*p || *q)
  55:         if (*p++ != *q++)
  56:             return(0);
  57:     return(1);
  58: }
  59: 
  60: 
  61: /*
  62: **  STRING CONCATENATE
  63: **
  64: **	The strings `s1' and `s2' are concatenated and stored into
  65: **	`s3'.  It is ok for `s1' to equal `s3', but terrible things
  66: **	will happen if `s2' equals `s3'.  The return value is is a
  67: **	pointer to the end of `s3' field.
  68: */
  69: 
  70: char *concat(s1, s2, s3)
  71: char    *s1, *s2, *s3;
  72: {
  73:     register char       *p;
  74:     register char       *q;
  75: 
  76:     p = s3;
  77:     q = s1;
  78:     while (*q)
  79:         *p++ = *q++;
  80:     q = s2;
  81:     while (*q)
  82:         *p++ = *q++;
  83:     *p = 0;
  84:     return (p);
  85: }
  86: 
  87: 
  88: /*
  89: **  FIND STRING LENGTH
  90: **
  91: **	The length of string `s' (excluding the null byte which
  92: **		terminates the string) is returned.
  93: */
  94: 
  95: length(s)
  96: char    *s;
  97: {
  98:     register int    l;
  99:     register char   *p;
 100: 
 101:     l = 0;
 102:     p = s;
 103:     while (*p++)
 104:         l++;
 105:     return(l);
 106: }
 107: 
 108: 
 109: /*
 110: **  SYSTEM ERROR
 111: */
 112: 
 113: syserr(p0, p1, p2, p3, p4, p5)
 114: {
 115:     extern int  errno;
 116: 
 117:     printf("\n\07TREK SYSERR: ");
 118:     printf(p0, p1, p2, p3, p4, p5);
 119:     printf("\n");
 120:     if (errno)
 121:         printf("\tsystem error %d\n", errno);
 122:     exit(-1);
 123: }

Defined functions

concat defined in line 70; used 1 times
length defined in line 95; used 1 times
sequal defined in line 47; used 2 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-05-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2121
Valid CSS Valid XHTML 1.0 Strict