home *** CD-ROM | disk | FTP | other *** search
- Path: comp-sources-3b1
- From: dave@galaxia.network23.com (David H. Brierley)
- Subject: v02i022: BSD style ln command for the 3b1, Part01/01
- Newsgroups: comp.sources.3b1
- Approved: dave@galaxia.network23.com
- X-Checksum-Snefru: 68486ca8 6eac5309 5899f837 63bfa8bc
-
- Submitted-by: dave@galaxia.network23.com (David H. Brierley)
- Posting-number: Volume 2, Issue 22
- Archive-name: bsdln/part01
-
- This is the README file for the Dave Brierley collection of miscellaneous
- source programs. The collection is posted in seven separate pieces but
- all of the source came from the "misc" directory on my machine. As a result
- of this, there is only one README file and only one Makefile, although each
- of the seven postings will contain a copy of these two files. I suggest
- that you obtain (or save) as many of these postings as you are interested
- in, unpack them all in a single directory, and then compile the sources.
- Note that some of the programs are actually shell scripts and therefore do
- not need compilation.
-
- bsdln.c
- A version of the ln command that follows the BSD behaviour. I.e. if the
- target file exists, the command will fail. The standard 3b1 version will
- remove the target.
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 1)."
- # Contents: MANIFEST Makefile README bsdln.c
- # Wrapped by dave@galaxia on Tue Jul 21 10:30:54 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'MANIFEST' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MANIFEST'\"
- else
- echo shar: Extracting \"'MANIFEST'\" \(220 characters\)
- sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
- X File Name Archive # Description
- X-----------------------------------------------------------
- X MANIFEST 1
- X Makefile 1
- X README 1
- X bsdln.c 1
- END_OF_FILE
- if test 220 -ne `wc -c <'MANIFEST'`; then
- echo shar: \"'MANIFEST'\" unpacked with wrong size!
- fi
- # end of 'MANIFEST'
- fi
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(374 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- XCFLAGS = -O
- X
- Xall: bsdln disktest email ndf techo wclipper
- X
- Xbsdln: bsdln.o
- X $(CC) bsdln.o
- X mv a.out bsdln
- X
- Xdisktest: disktest.o
- X $(CC) disktest.o
- X mv a.out disktest
- X
- Xemail: email.o
- X $(CC) email.o
- X mv a.out email
- X
- Xndf: ndf.o
- X $(CC) ndf.o
- X mv a.out ndf
- X
- Xtecho: techo.o
- X $(CC) techo.o
- X mv a.out techo
- X
- Xwclipper: wclipper.o
- X $(CC) wclipper.o
- X mv a.out wclipper
- X
- END_OF_FILE
- if test 374 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(4280 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XThis is the README file for the Dave Brierley collection of miscellaneous
- Xsource programs. The collection is posted in seven separate pieces but
- Xall of the source came from the "misc" directory on my machine. As a result
- Xof this, there is only one README file and only one Makefile, although each
- Xof the seven postings will contain a copy of these two files. I suggest
- Xthat you obtain (or save) as many of these postings as you are interested
- Xin, unpack them all in a single directory, and then compile the sources.
- XNote that some of the programs are actually shell scripts and therefore do
- Xnot need compilation.
- X
- XINSTALLATION INSTRUCTIONS:
- X1. Compile all the source programs by typing "make all". Edit the Makefile
- X if you did not unpack all seven of the pieces. Note that the Makefile
- X does not contain explicit commands for using the shared library. I always
- X depend on "ccc" to do this for me.
- X2. Copy the resultant executables to your favorite bin directory. I always
- X use "/usr/local/bin".
- X3. Copy the various shell scripts to the bin directory and make then executable
- X using the chmod command. The shell scripts are all distributed with a
- X suffix of ".sh". I suggest you remove this suffix when you install it, but
- X that is entirely up to you.
- X
- X
- XDescription of programs included in this package. There is a line of dashes
- Xseparating each of the seven pieces.
- X
- Xbsdln.c
- X A version of the ln command that follows the BSD behaviour. I.e. if the
- X target file exists, the command will fail. The standard 3b1 version will
- X remove the target.
- X
- X--------------------------------------------------------------------------
- X
- Xinstall.sh
- X A shell script version of the BSD install command.
- X
- Xnull.sh
- X Zero out one or more files.
- X
- Xtolower.sh
- X Convert file names to lower case. Requires ksh.
- X
- Xtoupper.sh
- X Convert file names to upper case. Requires ksh.
- X
- X--------------------------------------------------------------------------
- X
- Xndf.c
- X Almost emulates the BSD df command. I say "almost" because I chose to
- X display the numbers in terms of blocks instead of kbytes since everything
- X else on the machine displays sizes in blocks. Supports the "-i" option
- X to displays inode information. Also supports specifying any random
- X directory as an argument and it will figure out what file system it is.
- X
- X--------------------------------------------------------------------------
- X
- Xdisktest.c
- X A program used by the format script to test the floppy disk to be doubly
- X sure that it is usable.
- X
- Xformat.sh
- X Format a floppy disk. Asks questions to determine desired parameters, such
- X as number of cylinders and number of sectors. Will optionally run an
- X intensive surface test of the floppy (see disktest.c), build a file system
- X structure, and make the floppy bootable. The main processing is done in a
- X loop so you can format multiple floppies easily.
- X
- Xnewfs.sh
- X Reads the VHB from the floppy and then builds a file system structure on it.
- X
- X--------------------------------------------------------------------------
- X
- Xtecho.c
- X A version of echo that allows direct access to termcap capabilities. A lot
- X easier to use than intermixing calls to echo with calls to tput.
- X
- Xtecho.1
- X Hey, I actually wrote a man page for this one!
- X
- X--------------------------------------------------------------------------
- X
- Xwclipper.c
- X A program to read in the wtmp file and output the tail end of it. Useful
- X if you want to maintain an N-day history of who has been using your system.
- X The output size can be specified in terms of days or kbytes.
- X
- Xwtmp.fix.sh
- X A shell script to control the operation of wclipper.
- X
- X--------------------------------------------------------------------------
- X
- Xemail.c
- X A version of the "email" program. This program should be installed as
- X /usr/bin/email and it will be used by pcmgr (or by smgr) when you click
- X on the envelope icon. It provides a safe interface to the mail program
- X by making sure the uid is set correctly and by doing a chdir to the
- X users home directory (both of which are already being done by pcmgr).
- X This version also provides a unique feature of reading an "rc" file
- X from the users home directory (~/.email.rc), which can be used to specify
- X what mail program to use. See the sample provided.
- X
- Xemail.rc
- X Sample .email.rc file.
- END_OF_FILE
- if test 4280 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'bsdln.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bsdln.c'\"
- else
- echo shar: Extracting \"'bsdln.c'\" \(1544 characters\)
- sed "s/^X//" >'bsdln.c' <<'END_OF_FILE'
- X#include <stdio.h>
- X#include <errno.h>
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X#include <string.h>
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X int rc;
- X char path1[BUFSIZ];
- X char path2[BUFSIZ];
- X char *slash;
- X struct stat sbuf;
- X
- X switch (argc) {
- X case 3:
- X (void) strcpy (path1, argv[1]);
- X (void) strcpy (path2, argv[2]);
- X break;
- X case 2:
- X (void) strcpy (path1, argv[1]);
- X (void) strcpy (path2, ".");
- X break;
- X default:
- X fprintf (stderr, "Usage: bsdln from_file to_file\n");
- X exit (1);
- X }
- X
- X rc = stat (path1, &sbuf);
- X if (rc != 0) {
- X rc = errno;
- X perror ("bsdln");
- X (void) fprintf (stderr, "Unable to access file '%s'\n", path1);
- X exit (rc);
- X }
- X if ((sbuf.st_mode & S_IFMT) == S_IFDIR) {
- X (void) fprintf (stderr, "Error: source file cannot be a directory\n");
- X exit (1);
- X }
- X
- X rc = stat (path2, &sbuf);
- X if (rc == 0) {
- X if ((sbuf.st_mode & S_IFMT) == S_IFDIR) {
- X slash = strrchr (path1, '/');
- X if (slash == NULL) {
- X slash = path1;
- X }
- X else {
- X ++slash;
- X }
- X if (strlen (path2) + strlen (slash) + 2 > BUFSIZ) {
- X (void) fprintf (stderr, "Unable to concatonate file names - please contact system developer\n");
- X exit (1);
- X }
- X (void) strcat (path2, "/");
- X (void) strcat (path2, slash);
- X }
- X }
- X
- X rc = link (path1, path2);
- X if (rc != 0) {
- X rc = errno;
- X perror ("bsdln");
- X (void) fprintf (stderr, "Unable to link file '%s' to file '%s'\n",
- X path1, path2);
- X }
- X
- X exit (rc);
- X
- X}
- END_OF_FILE
- if test 1544 -ne `wc -c <'bsdln.c'`; then
- echo shar: \"'bsdln.c'\" unpacked with wrong size!
- fi
- # end of 'bsdln.c'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- David H. Brierley
- Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
- Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
- %% Can I be excused, my brain is full. **
-