home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume35 / describe / part03 < prev    next >
Encoding:
Text File  |  1993-02-03  |  7.7 KB  |  268 lines

  1. Newsgroups: comp.sources.misc
  2. From: tim@deakin.edu.au (Tim Cook)
  3. Subject: v35i014:  describe - File Descriptions, Part03/03
  4. Message-ID: <1993Feb2.061638.20545@sparky.imd.sterling.com>
  5. X-Md4-Signature: c5f489ec70b36f945ef42cd0628c0f84
  6. Date: Tue, 2 Feb 1993 06:16:38 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: tim@deakin.edu.au (Tim Cook)
  10. Posting-number: Volume 35, Issue 14
  11. Archive-name: describe/part03
  12. Environment: UNIX, DBM
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  allocate.c list.h pathname.c strpbrk.c version.h
  19. # Wrapped by kent@sparky on Mon Feb  1 10:15:04 1993
  20. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  21. echo If this archive is complete, you will see the following message:
  22. echo '          "shar: End of archive 3 (of 3)."'
  23. if test -f 'allocate.c' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'allocate.c'\"
  25. else
  26.   echo shar: Extracting \"'allocate.c'\" \(1000 characters\)
  27.   sed "s/^X//" >'allocate.c' <<'END_OF_FILE'
  28. X/* allocate.c -    Interface to malloc/realloc
  29. X *
  30. X * DESCRIPTION
  31. X *    These routines, allocate and re_allocate call malloc(3) and
  32. X *    realloc(3) respectively.  If malloc or realloc returns NULL,
  33. X *    an error message is printed and execution is terminated,
  34. X *    otherwise, the value returned by malloc/realloc is returned.
  35. X *
  36. X * Copyright (c) 1991,1992 Tim Cook.
  37. X * Non-profit distribution allowed.  See README for details.
  38. X */
  39. X
  40. Xstatic char rcsid[] = "$Id: allocate.c,v 1.1 1992/10/30 06:19:34 tim Exp $";
  41. X
  42. X#include "config.h"
  43. X
  44. Xextern VOID_PTR malloc () ;
  45. Xextern VOID_PTR realloc () ;
  46. X
  47. X
  48. XVOID_PTR allocate (length)
  49. X   size_t length ;
  50. X{
  51. X   VOID_PTR tmp ;
  52. X
  53. X   if ((tmp = malloc (length)) == (VOID_PTR) NULL) {
  54. X      perror ("malloc") ;
  55. X      exit (1) ; }
  56. X   else
  57. X      return tmp ;
  58. X   }
  59. X
  60. X
  61. XVOID_PTR re_allocate (p, length)
  62. X   VOID_PTR p ;
  63. X   size_t length ;
  64. X{
  65. X   VOID_PTR tmp ;
  66. X
  67. X   if ((tmp = realloc (p, length)) == (VOID_PTR) NULL) {
  68. X      perror ("realloc") ;
  69. X      exit (1) ; }
  70. X   else
  71. X      return tmp ;
  72. X   }
  73. END_OF_FILE
  74.   if test 1000 -ne `wc -c <'allocate.c'`; then
  75.     echo shar: \"'allocate.c'\" unpacked with wrong size!
  76.   fi
  77.   # end of 'allocate.c'
  78. fi
  79. if test -f 'list.h' -a "${1}" != "-c" ; then 
  80.   echo shar: Will not clobber existing file \"'list.h'\"
  81. else
  82.   echo shar: Extracting \"'list.h'\" \(1288 characters\)
  83.   sed "s/^X//" >'list.h' <<'END_OF_FILE'
  84. X/* list.h -    Definitions for list manipulation
  85. X *
  86. X * Copyright (c) 1991, 1992 Tim Cook.
  87. X * Non-profit distribution allowed.  See README for details.
  88. X *
  89. X * $Id: list.h,v 1.5 1992/12/02 03:54:10 tim Exp $
  90. X */
  91. X
  92. X#ifndef _LIST_H_
  93. X#define _LIST_H_
  94. X
  95. X#include "config.h"
  96. X
  97. Xstruct list {
  98. X   VOID_PTR_PTR start ;        /* First element (NULL if empty) */
  99. X   VOID_PTR_PTR end ;        /* Last element */
  100. X   VOID_PTR_PTR s_start ;    /* Beginning of storage */
  101. X   VOID_PTR_PTR s_end ;        /* Just past end of storage */
  102. X   VOID_PTR_PTR data ;        /* List of pointers to blocks of storage to
  103. X                   hold data pointed to by list items. */
  104. X   } ;
  105. X
  106. X#define list_init(l)    ((l)->start = (l)->data = (VOID_PTR_PTR) 0)
  107. X
  108. X/*
  109. X * NOTE:  For list_elements to work, we must be able to cast
  110. X * VOID_PTR_PTR to "unsigned long" without losing anything.
  111. X */
  112. X
  113. X#define list_elements(l) \
  114. X       ((l)->start ? ((unsigned long) (l)->end - (unsigned long) \
  115. X          (l)->start) / sizeof (VOID_PTR_PTR) : 0)
  116. X#define list_element(l,n) \
  117. X       ((l)->start ? (l)->start[n] : (VOID_PTR) 0)
  118. X#define list_empty(l) \
  119. X       ((l)->start == (VOID_PTR_PTR) 0)
  120. X
  121. X#ifndef _LIST_C_
  122. Xextern VOID list_push () ;
  123. Xextern VOID_PTR list_pop () ;
  124. Xextern VOID_PTR list_shift () ;
  125. Xextern VOID list_sort () ;
  126. Xextern VOID list_free () ;
  127. X#endif    /* _LIST_C_ */
  128. X
  129. X#endif    /* _LIST_H_ */
  130. END_OF_FILE
  131.   if test 1288 -ne `wc -c <'list.h'`; then
  132.     echo shar: \"'list.h'\" unpacked with wrong size!
  133.   fi
  134.   # end of 'list.h'
  135. fi
  136. if test -f 'pathname.c' -a "${1}" != "-c" ; then 
  137.   echo shar: Will not clobber existing file \"'pathname.c'\"
  138. else
  139.   echo shar: Extracting \"'pathname.c'\" \(867 characters\)
  140.   sed "s/^X//" >'pathname.c' <<'END_OF_FILE'
  141. X/* pathname.c -    Construct a pathname from a directory and basename
  142. X *
  143. X * SYNOPSIS
  144. X *    char *pathname (char *directory, char *name)
  145. X *
  146. X * RETURNS
  147. X *    Returns "directory" + "/" + "name" (copied into static
  148. X *    storage), or a pointer to "name" if "directory" is null.
  149. X *
  150. X * Copyright (c) 1991, 1992 Tim Cook.
  151. X * Non-profit distribution allowed.  See README for details.
  152. X */
  153. X
  154. Xstatic char rcsid[] = "$Id: pathname.c,v 1.1 1992/12/02 03:48:38 tim Exp $";
  155. X
  156. X#include "config.h"
  157. X#include <sys/param.h>
  158. X
  159. X#ifndef MAXPATHLEN
  160. X#define MAXPATHLEN    1024
  161. X#endif
  162. X
  163. X
  164. Xchar *pathname (directory, name)
  165. X   char *directory, *name ;
  166. X{
  167. X   static char return_value[MAXPATHLEN+1] ;
  168. X
  169. X   if (directory && *directory != EOS) {
  170. X      strcpy (return_value, directory) ;
  171. X      strcat (return_value, "/") ;
  172. X      strcat (return_value, name) ;
  173. X      return return_value ; }
  174. X   else
  175. X      return name ;
  176. X   }
  177. END_OF_FILE
  178.   if test 867 -ne `wc -c <'pathname.c'`; then
  179.     echo shar: \"'pathname.c'\" unpacked with wrong size!
  180.   fi
  181.   # end of 'pathname.c'
  182. fi
  183. if test -f 'strpbrk.c' -a "${1}" != "-c" ; then 
  184.   echo shar: Will not clobber existing file \"'strpbrk.c'\"
  185. else
  186.   echo shar: Extracting \"'strpbrk.c'\" \(1162 characters\)
  187.   sed "s/^X//" >'strpbrk.c' <<'END_OF_FILE'
  188. X/*
  189. X * Copyright (c) 1985 Regents of the University of California.
  190. X * All rights reserved.
  191. X *
  192. X * Redistribution and use in source and binary forms are permitted
  193. X * provided that the above copyright notice and this paragraph are
  194. X * duplicated in all such forms and that any documentation,
  195. X * advertising materials, and other materials related to such
  196. X * distribution and use acknowledge that the software was developed
  197. X * by the University of California, Berkeley.  The name of the
  198. X * University may not be used to endorse or promote products derived
  199. X * from this software without specific prior written permission.
  200. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  201. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  202. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  203. X */
  204. X
  205. X#if defined(LIBC_SCCS) && !defined(lint)
  206. Xstatic char sccsid[] = "@(#)strpbrk.c    5.5 (Berkeley) 5/10/89";
  207. X#endif /* LIBC_SCCS and not lint */
  208. X
  209. Xchar *
  210. Xstrpbrk(s1, s2)
  211. X    register char *s1, *s2;
  212. X{
  213. X    register int c, sc;
  214. X    register char *scanp;
  215. X
  216. X    for (; c = *s1; ++s1)
  217. X        for (scanp = s2; sc = *scanp++;)
  218. X            if (sc == c)
  219. X                return(s1);
  220. X    return(0);
  221. X}
  222. END_OF_FILE
  223.   if test 1162 -ne `wc -c <'strpbrk.c'`; then
  224.     echo shar: \"'strpbrk.c'\" unpacked with wrong size!
  225.   fi
  226.   # end of 'strpbrk.c'
  227. fi
  228. if test -f 'version.h' -a "${1}" != "-c" ; then 
  229.   echo shar: Will not clobber existing file \"'version.h'\"
  230. else
  231.   echo shar: Extracting \"'version.h'\" \(223 characters\)
  232.   sed "s/^X//" >'version.h' <<'END_OF_FILE'
  233. X/* version.h -    Describe version
  234. X *
  235. X * This version definition is fairly arbitrary at the moment
  236. X */
  237. X
  238. X#ifndef PACKAGE_NAME
  239. X#define PACKAGE_NAME    "describe"
  240. X#endif
  241. X
  242. X#ifndef PACKAGE_VERSION
  243. X#define PACKAGE_VERSION    "2.0"
  244. X#endif
  245. END_OF_FILE
  246.   if test 223 -ne `wc -c <'version.h'`; then
  247.     echo shar: \"'version.h'\" unpacked with wrong size!
  248.   fi
  249.   # end of 'version.h'
  250. fi
  251. echo shar: End of archive 3 \(of 3\).
  252. cp /dev/null ark3isdone
  253. MISSING=""
  254. for I in 1 2 3 ; do
  255.     if test ! -f ark${I}isdone ; then
  256.     MISSING="${MISSING} ${I}"
  257.     fi
  258. done
  259. if test "${MISSING}" = "" ; then
  260.     echo You have unpacked all 3 archives.
  261.     rm -f ark[1-9]isdone
  262. else
  263.     echo You still must unpack the following archives:
  264.     echo "        " ${MISSING}
  265. fi
  266. exit 0
  267. exit 0 # Just in case...
  268.