From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  9-JUN-1989 16:59
To:	MRGATE::"ARISIA::EVERHART"
Subj:	MAINT -- Full Screen File/Directory Maintenance (Part 11 of 11)

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri,  9 JUN 89 07:00:29 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 9 Jun 89 06:49:28 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA17247; Fri, 9 Jun 89 06:26:42 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 9 Jun 89 13:01:13 GMT
From: peirce@gumby.wisc.edu  (Leonard J. Peirce)
Organization: Western Michigan University, Kalamazoo, MI
Subject: MAINT -- Full Screen File/Directory Maintenance (Part 11 of 11)
Message-Id: <749@gumby.cc.wmich.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

+-+-+-+ Beginning of part 11 +-+-+-+
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S      `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
X`009 char`009  *cat(),
X`009`009  *strmcpy();
X
X`009 int`009  banystr(),
X`009`009  strindex(),
X`009`009  strins();
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009banystr
X
X  Purpose:`009Determine if a null-terminated character string contains
X`009`009any characters from a second null-terminated character
X`009`009string.
X
X  Formal parameters:
X
X`009Name`009`009`009Description
X`009----`009`009`009-----------
X`009str1`009`009`009string that is to be searched
X`009str2`009`009`009string containing the characters that are to
X`009`009`009`009be searched for in str1
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009none
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009>=0`009`009`009match found; return code is the offset into
X`009`009`009`009str1 where the character was found
X`009 -1`009`009`009no common characters in the two strings
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Xint banystr(str1,str2)
Xregister char`009  *str1,
X`009`009  *str2;
X
X`123`009/*** banystr ***/
X`009`009`009`009`009/********   LOCAL  VARIABLES   ********/
Xregister int`009  offset1,`009`009/* offset into string str1`009      */
X`009`009  offset2;`009`009/* offset into string str2`009      */
X
X
X   if(str1 == NULL `124`124 str2 == NULL)
X      return(-1);
X
X   if((*str1 == '\0') `124`124 (*str2 == '\0'))
X      return(-1);
X
X   offset1 = 0;
X
X   while(*(str1+offset1) != '\0')
X   `123
X      offset2 = 0;
X      while(*(str2+offset2) != '\0')
X      `123
X`009 if(*(str1+offset1) == *(str2+offset2))
X`009 `123
X`009    return(offset1);`009`009/* match found; return offset`009      */
X`009 `125
X`009 ++offset2;
X      `125
X      ++offset1;
X   `125
X
X   return(-1);`009`009`009`009/* no match; return -1`009`009      */
X
X`125`009/*** banystr ***/
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009cat
X
X  Purpose:`009Concatenate a variable number of NUL-terminated strings into
X`009`009one output string.
X
X  Description of Linkage:
X
X`009`009char`009*rc,
X`009`009`009*cat();
X
X`009`009rc = cat(dest,source1,source2,...sourcen);
X
X  Formal parameters:
X
X`009Name`009`009`009Description
X`009----`009`009`009-----------
X`009dest`009`009`009pointer to an array where the result will
X`009`009`009`009be stored
X`009`009`009`009be searched for in str1
X`009source1...sourcen`009NUL-terminated characters strings that are to
X`009`009`009`009be concatenated together
X
X
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009none
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009retval`009`009`009pointer to destination string
X`009nullptr`009`009`009pointer to NULL string; returned when no
X`009`009`009`009arguments are passed
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Xchar *cat(va_alist)
X`009`009`009`009`009/*******   FORMAL  PARAMETERS   *******/
X`009 va_dcl`009`009`009`009/* variable-length parameter list     */
X
X`123`009/*** cat ***/
X`009`009`009`009`009/********   LOCAL  VARIABLES   ********/
Xregister char`009  *dest,`009`009/* pointer to destination string      */
X`009`009  *source;`009`009/* pointer to current source string   */
X`009 char`009  *retval;`009`009/* to save pointer to destination     */
Xregister int`009  count;`009`009/* number of arguments passed`009      */
X`009 va_list  incrmtr;`009`009/* argument list incrementor`009      */
Xstatic`009 char`009  *nullptr = "";`009/* null string pointer`009`009      */
X
X
X   va_start(incrmtr);`009`009`009/* begin everything....`009`009      */
X
X   va_count(count);`009`009`009/* get number of arguments`009      */
X
X   if(count == 0)`009`009`009/* were any arguments specified?      */
X      return(nullptr);`009`009`009/* nope, get out of here...`009      */
X
V   dest = va_arg(incrmtr,char*);`009/* get the destination pointer`009      *
X/
X   retval = dest;`009`009`009/* save pointer to destination`009      */
X
V   source = va_arg(incrmtr,char*);`009/* get the first source pointer`009`032
X     */
X
X   while(--count > 0)`009`009`009/* process all of the source strings  */
X   `123
X      while(*dest++ = *source++)`009/* cat the source to the destination  */
X`009 ;
X
X      dest--;`009`009`009`009/* back over the null character`009      */
X      source = va_arg(incrmtr,char*);`009/* get the next argument`009      */
X   `125
X
X   *dest = '\0';`009`009`009/* terminate the destination`009      */
X   va_end(incrmtr);`009`009`009/* end varargs session`009`009      */
X
X   return(retval);`009`009`009/* return pointer to destination      */
X
X`125`009/*** cat ***/
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009strindex
X
X  Purpose:`009Return the offset of one NUL-terminated string in another.
X
X  Formal parameters:
X
X`009Name`009`009`009Description
X`009----`009`009`009-----------
X`009str`009`009`009string to search
X`009key`009`009`009string to search str for
X
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009none
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009 -1`009`009`009key not found in str or key is a null
X`009`009`009`009pointer or str is a null pointer
X`009offset `009`009`009offset into str where key is located
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Xint strindex(str,key)
Xregister char`009  *str,
X`009`009  *key;
X
X`123`009/*** strindex ***/
X`009`009`009`009`009/********   LOCAL  VARIABLES   ********/
Xregister int`009  i,`009`009`009/* primary pointer to str`009      */
X`009`009  j,`009`009`009/* secondary pointer to str for com-  */
X`009`009`009`009`009/* parison`009`009`009      */
X`009`009  k;`009`009`009/* pointer to key for comparison      */
X
X
V   if(str == NULL `124`124 key == NULL `124`124 *str == '\0' `124`124 *key ==
X '\0')
X      return(-1);
X
X   i = 0;
X   while(*(str+i) != '\0')
X   `123
X      j = i;
X      k = 0;
X
X      /* look for a match */
X
V      while((*(str+j) == *(key+k)) && (*(str+j) != '\0') && (*(key+k) != '\0'
X))
X      `123
X`009 ++j;
X`009 ++k;
X      `125
X
X      if(*(key+k) == '\0')
X`009 return(i);`009`009`009/* key was found`009`009      */
X      else if(*(str+j) == '\0')
X`009 return(-1);`009`009`009/* key was not found`009`009      */
X
X      ++i;`009`009`009`009/* not sure yet; keep trying...`009      */
X   `125
X
X   /* if we get to here, the key was not found */
X
X   return(-1);
X
X`125`009/*** strindex ***/
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009strins
X
X  Purpose:`009Insert a character string into another at a specified
X`009`009position.
X
X  Formal parameters:
X
X`009Name`009`009`009Description
X`009----`009`009`009-----------
X`009str`009`009`009string to be updated; should be large
X`009`009`009`009enough to accomodate the new string
X`009new`009`009`009string to be inserted
X`009position`009`009place to insert new into str
X
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009none
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009  0 `009`009`009string insert successful
X`009 -1`009`009`009unable to insert string because
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Xint strins(str,new,position)
Xregister char`009  *str,
X`009`009  *new;
Xregister int`009  position;
X
X`123`009/*** strins ***/
X`009`009`009`009`009/********   LOCAL  VARIABLES   ********/
Xregister int`009  i,`009`009`009/* loop and array index`009`009      */
X`009`009  j;`009`009`009/* temporary variable`009`009      */
X`009 int`009  new_len,`009`009/* length of string to insert`009      */
X`009`009  str_len;`009`009/* length of str`009`009      */
X
X
X   str_len = strlen(str);`009`009/* get length of current str`009      */
X
X   if((position > str_len) `124`124 (position < 0))
X      i = -1;
X   else
X   `123
X      new_len = strlen(new);`009`009/* get length of string to insert     */
X      i = new_len + str_len - 1;`009/* get where to start when we shift   */
X      *(str+i+1) = '\0'; `009`009/* terminate it first `009`009      */
X      j = str_len - 1;`009`009`009/* point to last char of str`009      */
X
X      /* now shift everything over to make room for the new string */
X
X      while(j >= position)
X      `123
X`009 *(str+i) = *(str+j);
X`009 --i;
X`009 --j;
X      `125
X
X      /* now add the new string in the right slot */
X
X      for(i = 0,j = position; *(new+i) != '\0'; i++,j++)
X         *(str+j) = *(new+i);     `032
X
X      i = 0;
X   `125
X
X   return(i);
X
X`125`009/*** strins ***/     `032
X/*eject*/
V/****************************************************************************
X***
V*****************************************************************************
X***
X
X  Function:`009strmcpy
X
X  Purpose:`009Copy at most max characters from the source string into the
X`009`009dest string.  The resultant string is guaranteed to be null-
X`009`009terminated.  This provides an alternative to strncpy() which
X`009`009does not guarantee that strings are null-terminated.
X
X  Formal parameters:
X
X`009Name`009`009`009Description
X`009----`009`009`009-----------
X`009dest`009`009`009pointer to destination string
X`009source`009`009`009pointer to source string
X`009max`009`009`009maximum number of characters to be
X`009`009`009`009copied
X
X  Global variables:
X
X`009Name`009`009`009Examine/Modify/Use/Read/Write
X`009----`009`009`009-----------------------------
X`009none
X
X  Return Codes:
X
X`009Code`009`009`009Reason
X`009----`009`009`009------
X`009dest`009`009`009pointer to destination string
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
Xchar *strmcpy(dest,source,max)
Xregister char`009  *dest,
X`009`009  *source;
Xregister int`009  max;
X
X`123`009/*** strmcpy ***/
X`009`009`009`009`009/********   LOCAL  VARIABLES   ********/
Xregister int`009  i;`009`009`009/* loop and array index`009`009      */
X
X
X   for(i = 0;i < max && *(source+i); i++)
X      *(dest+i) = *(source+i);
X
X   *(dest+i) = '\0';`009`009`009/* terminate the destination string   */
X
X   return(dest);
X
X`125`009/*** strmcpy ***/
$ GOSUB UNPACK_FILE

$ FILE_IS = "UTYPE.H"
$ CHECKSUM_IS = 1863473039
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X#ifndef UTYPE_H
V/****************************************************************************
X**
V*****************************************************************************
X**
X
X   Installation:  Western Michigan University Academic Computer Center
X
X   System:  General Purpose Headers
X `032
X   Header name:  utype
X
X   Version=01   Level=01           12/01/86  Leonard J. Peirce
X
V   Purpose:  Define typedefs for various sundry unsigned data types, ones tha
Xt
X`009     C should have built-in but doesn't.
X
X   Other information:  none
X
V*****************************************************************************
X***
V*****************************************************************************
X**/
X
X#define UTYPE_H 1`009`009`009/* to prevent multiple inclusion      */
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*                        # I N C L U D E   F I L E S                    `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*                             # D E F I N E S                           `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S      `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
Xtypedef`009 unsigned  int   UINT;`009`009/* for unsigned integers`009      */
Vtypedef`009 unsigned  long  ULONG;`009`009/* for unsigned long integers`009
X      */
Vtypedef`009 unsigned  short USHORT;`009/* for unsigned short integers`009`032
X     */
Vtypedef`009 unsigned  char  UCHAR;`009`009/* for unsigned characters`009 `032
X    */
Vtypedef`009 unsigned  char  TINY;`009`009/* more descriptive for using un-
X     */
X`009`009`009`009`009/* characters as integers`009      */
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
X
V/****************************************************************************
X**/
V/*                                                                       `032
X    */
V/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S `032
X    */
V/*                                                                       `032
X    */
V/****************************************************************************
X**/
X
X#endif
$ GOSUB UNPACK_FILE
$ EXIT
-+-+-+-+-+ End of part 11 +-+-+-+-+-

