home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sources / 3b1 / 75 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  10.2 KB

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