home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / 3b1 / volume02 / bsdln / part01 < prev    next >
Encoding:
Internet Message Format  |  1992-07-20  |  10.0 KB

  1. Path: comp-sources-3b1
  2. From: dave@galaxia.network23.com (David H. Brierley)
  3. Subject:  v02i022:  BSD style ln command for the 3b1, Part01/01
  4. Newsgroups: comp.sources.3b1
  5. Approved: dave@galaxia.network23.com
  6. X-Checksum-Snefru: 68486ca8 6eac5309 5899f837 63bfa8bc
  7.  
  8. Submitted-by: dave@galaxia.network23.com (David H. Brierley)
  9. Posting-number: Volume 2, Issue 22
  10. Archive-name: bsdln/part01
  11.  
  12. This is the README file for the Dave Brierley collection of miscellaneous
  13. source programs.  The collection is posted in seven separate pieces but
  14. all of the source came from the "misc" directory on my machine.  As a result
  15. of this, there is only one README file and only one Makefile, although each
  16. of the seven postings will contain a copy of these two files.  I suggest
  17. that you obtain (or save) as many of these postings as you are interested
  18. in, unpack them all in a single directory, and then compile the sources.
  19. Note that some of the programs are actually shell scripts and therefore do
  20. not need compilation.
  21.  
  22. bsdln.c
  23.  A version of the ln command that follows the BSD behaviour.  I.e. if the
  24.  target file exists, the command will fail.  The standard 3b1 version will
  25.  remove the target.
  26.  
  27. #! /bin/sh
  28. # This is a shell archive.  Remove anything before this line, then unpack
  29. # it by saving it into a file and typing "sh file".  To overwrite existing
  30. # files, type "sh file -c".  You can also feed this as standard input via
  31. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  32. # will see the following message at the end:
  33. #        "End of archive 1 (of 1)."
  34. # Contents:  MANIFEST Makefile README bsdln.c
  35. # Wrapped by dave@galaxia on Tue Jul 21 10:30:54 1992
  36. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  37. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  39. else
  40. echo shar: Extracting \"'MANIFEST'\" \(220 characters\)
  41. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  42. X   File Name        Archive #    Description
  43. X-----------------------------------------------------------
  44. X MANIFEST                   1    
  45. X Makefile                   1    
  46. X README                     1    
  47. X bsdln.c                    1    
  48. END_OF_FILE
  49. if test 220 -ne `wc -c <'MANIFEST'`; then
  50.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  51. fi
  52. # end of 'MANIFEST'
  53. fi
  54. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  55.   echo shar: Will not clobber existing file \"'Makefile'\"
  56. else
  57. echo shar: Extracting \"'Makefile'\" \(374 characters\)
  58. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  59. XCFLAGS    = -O
  60. X
  61. Xall:        bsdln disktest email ndf techo wclipper
  62. X
  63. Xbsdln:        bsdln.o
  64. X        $(CC) bsdln.o
  65. X        mv a.out bsdln
  66. X
  67. Xdisktest:    disktest.o
  68. X        $(CC) disktest.o
  69. X        mv a.out disktest
  70. X
  71. Xemail:        email.o
  72. X        $(CC) email.o
  73. X        mv a.out email
  74. X
  75. Xndf:        ndf.o
  76. X        $(CC) ndf.o
  77. X        mv a.out ndf
  78. X
  79. Xtecho:        techo.o
  80. X        $(CC) techo.o
  81. X        mv a.out techo
  82. X
  83. Xwclipper:    wclipper.o
  84. X        $(CC) wclipper.o
  85. X        mv a.out wclipper
  86. X
  87. END_OF_FILE
  88. if test 374 -ne `wc -c <'Makefile'`; then
  89.     echo shar: \"'Makefile'\" unpacked with wrong size!
  90. fi
  91. # end of 'Makefile'
  92. fi
  93. if test -f 'README' -a "${1}" != "-c" ; then 
  94.   echo shar: Will not clobber existing file \"'README'\"
  95. else
  96. echo shar: Extracting \"'README'\" \(4280 characters\)
  97. sed "s/^X//" >'README' <<'END_OF_FILE'
  98. XThis is the README file for the Dave Brierley collection of miscellaneous
  99. Xsource programs.  The collection is posted in seven separate pieces but
  100. Xall of the source came from the "misc" directory on my machine.  As a result
  101. Xof this, there is only one README file and only one Makefile, although each
  102. Xof the seven postings will contain a copy of these two files.  I suggest
  103. Xthat you obtain (or save) as many of these postings as you are interested
  104. Xin, unpack them all in a single directory, and then compile the sources.
  105. XNote that some of the programs are actually shell scripts and therefore do
  106. Xnot need compilation.
  107. X
  108. XINSTALLATION INSTRUCTIONS:
  109. X1. Compile all the source programs by typing "make all".  Edit the Makefile
  110. X   if you did not unpack all seven of the pieces.  Note that the Makefile
  111. X   does not contain explicit commands for using the shared library.  I always
  112. X   depend on "ccc" to do this for me.
  113. X2. Copy the resultant executables to your favorite bin directory.  I always
  114. X   use "/usr/local/bin".
  115. X3. Copy the various shell scripts to the bin directory and make then executable
  116. X   using the chmod command.  The shell scripts are all distributed with a
  117. X   suffix of ".sh".  I suggest you remove this suffix when you install it, but
  118. X   that is entirely up to you.
  119. X
  120. X
  121. XDescription of programs included in this package.  There is a line of dashes
  122. Xseparating each of the seven pieces.
  123. X
  124. Xbsdln.c
  125. X A version of the ln command that follows the BSD behaviour.  I.e. if the
  126. X target file exists, the command will fail.  The standard 3b1 version will
  127. X remove the target.
  128. X
  129. X--------------------------------------------------------------------------
  130. X
  131. Xinstall.sh
  132. X A shell script version of the BSD install command.
  133. X
  134. Xnull.sh
  135. X Zero out one or more files.
  136. X
  137. Xtolower.sh
  138. X Convert file names to lower case.  Requires ksh.
  139. X
  140. Xtoupper.sh
  141. X Convert file names to upper case.  Requires ksh.
  142. X
  143. X--------------------------------------------------------------------------
  144. X
  145. Xndf.c
  146. X Almost emulates the BSD df command.  I say "almost" because I chose to
  147. X display the numbers in terms of blocks instead of kbytes since everything
  148. X else on the machine displays sizes in blocks.  Supports the "-i" option
  149. X to displays inode information.  Also supports specifying any random
  150. X directory as an argument and it will figure out what file system it is.
  151. X
  152. X--------------------------------------------------------------------------
  153. X
  154. Xdisktest.c
  155. X A program used by the format script to test the floppy disk to be doubly
  156. X sure that it is usable.
  157. X
  158. Xformat.sh
  159. X Format a floppy disk.  Asks questions to determine desired parameters, such
  160. X as number of cylinders and number of sectors.  Will optionally run an
  161. X intensive surface test of the floppy (see disktest.c), build a file system
  162. X structure, and make the floppy bootable.  The main processing is done in a
  163. X loop so you can format multiple floppies easily.
  164. X
  165. Xnewfs.sh
  166. X Reads the VHB from the floppy and then builds a file system structure on it.
  167. X
  168. X--------------------------------------------------------------------------
  169. X
  170. Xtecho.c
  171. X A version of echo that allows direct access to termcap capabilities.  A lot
  172. X easier to use than intermixing calls to echo with calls to tput.
  173. X
  174. Xtecho.1
  175. X Hey, I actually wrote a man page for this one!
  176. X
  177. X--------------------------------------------------------------------------
  178. X
  179. Xwclipper.c
  180. X A program to read in the wtmp file and output the tail end of it.  Useful
  181. X if you want to maintain an N-day history of who has been using your system.
  182. X The output size can be specified in terms of days or kbytes.
  183. X
  184. Xwtmp.fix.sh
  185. X A shell script to control the operation of wclipper.
  186. X
  187. X--------------------------------------------------------------------------
  188. X
  189. Xemail.c
  190. X A version of the "email" program.  This program should be installed as
  191. X /usr/bin/email and it will be used by pcmgr (or by smgr) when you click
  192. X on the envelope icon.  It provides a safe interface to the mail program
  193. X by making sure the uid is set correctly and by doing a chdir to the
  194. X users home directory (both of which are already being done by pcmgr).
  195. X This version also provides a unique feature of reading an "rc" file
  196. X from the users home directory (~/.email.rc), which can be used to specify
  197. X what mail program to use.  See the sample provided.
  198. X
  199. Xemail.rc
  200. X Sample .email.rc file.
  201. END_OF_FILE
  202. if test 4280 -ne `wc -c <'README'`; then
  203.     echo shar: \"'README'\" unpacked with wrong size!
  204. fi
  205. # end of 'README'
  206. fi
  207. if test -f 'bsdln.c' -a "${1}" != "-c" ; then 
  208.   echo shar: Will not clobber existing file \"'bsdln.c'\"
  209. else
  210. echo shar: Extracting \"'bsdln.c'\" \(1544 characters\)
  211. sed "s/^X//" >'bsdln.c' <<'END_OF_FILE'
  212. X#include <stdio.h>
  213. X#include <errno.h>
  214. X#include <sys/types.h>
  215. X#include <sys/stat.h>
  216. X#include <string.h>
  217. X
  218. Xmain (argc, argv)
  219. Xint             argc;
  220. Xchar           *argv[];
  221. X{
  222. X    int             rc;
  223. X    char            path1[BUFSIZ];
  224. X    char            path2[BUFSIZ];
  225. X    char           *slash;
  226. X    struct stat     sbuf;
  227. X
  228. X    switch (argc) {
  229. X    case 3:
  230. X    (void) strcpy (path1, argv[1]);
  231. X    (void) strcpy (path2, argv[2]);
  232. X    break;
  233. X    case 2:
  234. X    (void) strcpy (path1, argv[1]);
  235. X    (void) strcpy (path2, ".");
  236. X    break;
  237. X    default:
  238. X    fprintf (stderr, "Usage: bsdln from_file to_file\n");
  239. X    exit (1);
  240. X    }
  241. X
  242. X    rc = stat (path1, &sbuf);
  243. X    if (rc != 0) {
  244. X    rc = errno;
  245. X    perror ("bsdln");
  246. X    (void) fprintf (stderr, "Unable to access file '%s'\n", path1);
  247. X    exit (rc);
  248. X    }
  249. X    if ((sbuf.st_mode & S_IFMT) == S_IFDIR) {
  250. X    (void) fprintf (stderr, "Error: source file cannot be a directory\n");
  251. X    exit (1);
  252. X    }
  253. X
  254. X    rc = stat (path2, &sbuf);
  255. X    if (rc == 0) {
  256. X    if ((sbuf.st_mode & S_IFMT) == S_IFDIR) {
  257. X        slash = strrchr (path1, '/');
  258. X        if (slash == NULL) {
  259. X        slash = path1;
  260. X        }
  261. X        else {
  262. X        ++slash;
  263. X        }
  264. X        if (strlen (path2) + strlen (slash) + 2 > BUFSIZ) {
  265. X        (void) fprintf (stderr, "Unable to concatonate file names - please contact system developer\n");
  266. X        exit (1);
  267. X        }
  268. X        (void) strcat (path2, "/");
  269. X        (void) strcat (path2, slash);
  270. X    }
  271. X    }
  272. X
  273. X    rc = link (path1, path2);
  274. X    if (rc != 0) {
  275. X    rc = errno;
  276. X    perror ("bsdln");
  277. X    (void) fprintf (stderr, "Unable to link file '%s' to file '%s'\n",
  278. X            path1, path2);
  279. X    }
  280. X
  281. X    exit (rc);
  282. X
  283. X}
  284. END_OF_FILE
  285. if test 1544 -ne `wc -c <'bsdln.c'`; then
  286.     echo shar: \"'bsdln.c'\" unpacked with wrong size!
  287. fi
  288. # end of 'bsdln.c'
  289. fi
  290. echo shar: End of archive 1 \(of 1\).
  291. cp /dev/null ark1isdone
  292. MISSING=""
  293. for I in 1 ; do
  294.     if test ! -f ark${I}isdone ; then
  295.     MISSING="${MISSING} ${I}"
  296.     fi
  297. done
  298. if test "${MISSING}" = "" ; then
  299.     echo You have the archive.
  300.     rm -f ark[1-9]isdone
  301. else
  302.     echo You still need to unpack the following archives:
  303.     echo "        " ${MISSING}
  304. fi
  305. ##  End of shell archive.
  306. exit 0
  307. -- 
  308. David H. Brierley
  309. Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
  310. Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
  311. %% Can I be excused, my brain is full. **
  312.