v14i010: visual directory tree
Mr System
root at lsrhs.UUCP
Mon Jul 16 09:17:35 AEST 1990
Posting-number: Volume 14, Issue 10
Submitted-by: root at lsrhs.UUCP (Mr System)
Archive-name: vdd/part01
This is version 1.0 of a visual directory tree displayer. Please read
the readme file before you compile everything. Brandon - please distribute
this to everyone! Thanks - Jim.
-- Cut Here -- -- Cut Here -- -- Cut Here -- -- Cut Here -- -- Cut Here --
#! /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 shell archive."
# Contents: Makefile README VERSION cleanup.c disp.c init.c main.c
# readin.c redraw.c req.c stopme.c tags vars.h
# Wrapped by pulsar at lsrhs on Sat Jul 14 01:33:35 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(4945 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
CC = gcc
CFLAGS = -W -ansi -g
DEST = .
XEXTHDRS = /usr/include/curses.h \
X /usr/include/errno.h \
X /usr/include/grp.h \
X /usr/include/pwd.h \
X /usr/include/sgtty.h \
X /usr/include/signal.h \
X /usr/include/stdio.h \
X /usr/include/sys/dir.h \
X /usr/include/sys/file.h \
X /usr/include/sys/ioctl.h \
X /usr/include/sys/stat.h \
X /usr/include/sys/ttychars.h \
X /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h \
X /usr/include/sys/types.h \
X /usr/include/time.h
HDRS = vars.h
LDFLAGS = -W -ansi -g
LIBS = -lcurses -ltermcap
LINKER = gcc
MAKEFILE = Makefile
OBJS = cleanup.o \
X disp.o \
X init.o \
X main.o \
X readin.o \
X redraw.o \
X stopme.o
PRINT = lpr
PROGRAM = vdd
SRCS = cleanup.c \
X disp.c \
X init.c \
X main.c \
X readin.c \
X redraw.c \
X req.c \
X stopme.c
X
all: $(PROGRAM)
X
X$(PROGRAM): $(OBJS)
X gcc -ansi -O req.c -o req
X req
X @echo -n "Loading $(PROGRAM) ... "
X @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
X @echo "done"
X
clean:; @rm -f $(OBJS)
X
depend:; @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
X
index:; @ctags -wx $(HDRS) $(SRCS)
X
install: $(PROGRAM)
X @echo Installing $(PROGRAM) in $(DEST)
X @install -s $(PROGRAM) $(DEST)
X
print:; @$(PRINT) $(HDRS) $(SRCS)
X
program: $(PROGRAM)
X
tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
X
update: $(DEST)/$(PROGRAM)
X
X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
X @make -f $(MAKEFILE) DEST=$(DEST)
X###
cleanup.o: vars.h /usr/include/sys/types.h /usr/include/sys/dir.h \
X /usr/include/sys/stat.h /usr/include/sys/file.h /usr/include/stdio.h \
X /usr/include/errno.h /usr/include/signal.h /usr/include/curses.h \
X /usr/include/sgtty.h /usr/include/sys/ioctl.h /usr/sys/h/ttychars.h \
X /usr/sys/h/ttydev.h /usr/sys/h/ttyio.h /usr/sys/h/sgtty.h \
X /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h
disp.o: vars.h /usr/include/sys/types.h /usr/include/sys/dir.h \
X /usr/include/sys/stat.h /usr/include/sys/file.h /usr/include/stdio.h \
X /usr/include/errno.h /usr/include/signal.h /usr/include/curses.h \
X /usr/include/sgtty.h /usr/include/sys/ioctl.h /usr/sys/h/ttychars.h \
X /usr/sys/h/ttydev.h /usr/sys/h/ttyio.h /usr/sys/h/sgtty.h \
X /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h /usr/include/time.h /usr/include/pwd.h \
X /usr/include/grp.h
init.o: vars.h /usr/include/sys/types.h /usr/include/sys/dir.h \
X /usr/include/sys/stat.h /usr/include/sys/file.h /usr/include/stdio.h \
X /usr/include/errno.h /usr/include/signal.h /usr/include/curses.h \
X /usr/include/sgtty.h /usr/include/sys/ioctl.h /usr/sys/h/ttychars.h \
X /usr/sys/h/ttydev.h /usr/sys/h/ttyio.h /usr/sys/h/sgtty.h \
X /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h
main.o: vars.h /usr/include/sys/types.h /usr/include/sys/dir.h \
X /usr/include/sys/stat.h /usr/include/sys/file.h /usr/include/stdio.h \
X /usr/include/errno.h /usr/include/signal.h /usr/include/curses.h \
X /usr/include/sgtty.h /usr/include/sys/ioctl.h /usr/sys/h/ttychars.h \
X /usr/sys/h/ttydev.h /usr/sys/h/ttyio.h /usr/sys/h/sgtty.h \
X /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h
readin.o: vars.h /usr/include/sys/types.h /usr/include/sys/dir.h \
X /usr/include/sys/stat.h /usr/include/sys/file.h /usr/include/stdio.h \
X /usr/include/errno.h /usr/include/signal.h /usr/include/curses.h \
X /usr/include/sgtty.h /usr/include/sys/ioctl.h /usr/sys/h/ttychars.h \
X /usr/sys/h/ttydev.h /usr/sys/h/ttyio.h /usr/sys/h/sgtty.h \
X /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h
redraw.o: vars.h /usr/include/sys/types.h /usr/include/sys/dir.h \
X /usr/include/sys/stat.h /usr/include/sys/file.h /usr/include/stdio.h \
X /usr/include/errno.h /usr/include/signal.h /usr/include/curses.h \
X /usr/include/sgtty.h /usr/include/sys/ioctl.h /usr/sys/h/ttychars.h \
X /usr/sys/h/ttydev.h /usr/sys/h/ttyio.h /usr/sys/h/sgtty.h \
X /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h
req.o: vars.h /usr/include/sys/types.h /usr/include/sys/dir.h \
X /usr/include/sys/stat.h /usr/include/sys/file.h /usr/include/stdio.h \
X /usr/include/errno.h /usr/include/signal.h /usr/include/curses.h \
X /usr/include/sgtty.h /usr/include/sys/ioctl.h /usr/sys/h/ttychars.h \
X /usr/sys/h/ttydev.h /usr/sys/h/ttyio.h /usr/sys/h/sgtty.h \
X /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h
stopme.o: vars.h /usr/include/sys/types.h /usr/include/sys/dir.h \
X /usr/include/sys/stat.h /usr/include/sys/file.h /usr/include/stdio.h \
X /usr/include/errno.h /usr/include/signal.h /usr/include/curses.h \
X /usr/include/sgtty.h /usr/include/sys/ioctl.h /usr/sys/h/ttychars.h \
X /usr/sys/h/ttydev.h /usr/sys/h/ttyio.h /usr/sys/h/sgtty.h \
X /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h \
X /usr/include/sys/ttyio.h
END_OF_FILE
if test 4945 -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'\" \(815 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
VDD - Visual Directory Display Copyright (C) 1990 pulsar
X-------------------------------------------------------------------------------
X
Vdd is a formerly vt100 dependant now curses directory listing package.
It is not like your normal directory program, it is quite different.
read the file VERSION for version update reports.
X
XFeel free to make any bugfixes OR changes to the program, but make sure
the whole program stays together and any change be mailed to me and not
distributed to the net. Please let me take care of that!
X
This is only version 1.0.. more shall come depending on the response.
X
This program may have one bug in it. It assumes that arrow keys will
produce vt100 arrow key sequences.. (example: up arrow = ^[[A)
This can be changed with a minor fix to main.c
X
xait.xerox.com!lsrhs!pulsar
END_OF_FILE
if test 815 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
chmod +x 'README'
# end of 'README'
fi
if test -f 'VERSION' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'VERSION'\"
else
echo shar: Extracting \"'VERSION'\" \(583 characters\)
sed "s/^X//" >'VERSION' <<'END_OF_FILE'
Version update report Last Revision Friday July 13, 1990 11:25pm
X
Version By What happened
X-------------------------------------------------------------------------------
X1.0l JEK Basic plans and program written, slow & sloppy
X1.1l JEK Major progam flaws fixed
X2.0l JEK Rewrote code, commented, faster
X3.0l JEK Converted code to Curses to make it portable
X3.1l JEK Bug Fixes
X3.2l JEK Options added
X3.3l JEK ^Z handling
X3.4l JEK Bug fixes, directory '.' handling, speed improved
X
X1.0 JEK First network release - will add file status changing after
X response and/or feedback (if any)
END_OF_FILE
if test 583 -ne `wc -c <'VERSION'`; then
echo shar: \"'VERSION'\" unpacked with wrong size!
fi
chmod +x 'VERSION'
# end of 'VERSION'
fi
if test -f 'cleanup.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cleanup.c'\"
else
echo shar: Extracting \"'cleanup.c'\" \(427 characters\)
sed "s/^X//" >'cleanup.c' <<'END_OF_FILE'
X/*
X * vdd - visual directory display (C) 1988 (pulsar at lsrhs) Jim King
X *
X * cleanup.c - contains the cleanup subroutine cleanup()
X * contains the cleanup routine without clear cleanupwoc()
X */
X
X#include "vars.h"
X
cleanup(x)
int x;
X{
X clear();
X refresh();
X echo();
X nocrmode();
X endwin();
X fflush(stdout);
X exit(x);
X}
X
cleanupwoc(x)
int x;
X{
X refresh();
X echo();
X nocrmode();
X endwin();
X fflush(stdout);
X exit(x);
X}
END_OF_FILE
if test 427 -ne `wc -c <'cleanup.c'`; then
echo shar: \"'cleanup.c'\" unpacked with wrong size!
fi
chmod +x 'cleanup.c'
# end of 'cleanup.c'
fi
if test -f 'disp.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'disp.c'\"
else
echo shar: Extracting \"'disp.c'\" \(5314 characters\)
sed "s/^X//" >'disp.c' <<'END_OF_FILE'
X/*
X * vdd - visual directory display (C) 1988 (pulsar at lsrhs) Jim King
X *
X * disp.c - contains
X * Redraw subroutine dlev();
X * Main program loop disp();
X * Strp function turns /tmp/jove/../ into /tmp/
X */
X
X#include "vars.h"
X#include <time.h>
X#include <pwd.h>
X#include <grp.h>
X
X#define USRGROUP
X
struct passwd *getpwuid(), *pwd;
struct group *getgruid(), *grp;
X
char *strcpy();
X
extern char *rindex();
X
char *strp(ln)
char *ln;
X{
X char *p = &ln[strlen(ln) - 1];
X
X if (*p = '/')
X *p = (char) 0;
X
X if ((p = rindex(ln, '/')) != (char *) 0)
X *p = (char) 0;
X
X return ln;
X}
X
disp()
X{
X struct stat fil;
X char buf[10];
X int mult;
X
X ypos = lasty = 1;
X
X for (;;) {
X mult = (level * 22);
X wclear(err);
X posyf(fils, lasty, 0, l[lasty+mult].name, NO);
X posyf(fils, ypos, 0, l[ypos+mult].name, YES);
X lasty = ypos;
X c = getchar();
X switch (c) {
X case 'd': /* DIVE RIGHT IN */
X if (strcmp(l[ypos+mult].name, "./") == 0) {
X wmove(err, 0, 0);
X wprintw(err, "Already there!");
X refresh();
X wrefresh(err);
X break;
X }
X if (strcmp(l[ypos+mult].name, "../") == 0) {
X sprintf(str, "%s%s", dname, l[ypos+mult].name);
X strcpy(dname, strp(strp(str)));
X strncat(dname, "/\0", 2);
X goto lo2;
X }
X if (l[ypos+mult].dir) {
X if (l[ypos+mult].f.st_uid == getuid()) {
X if (l[ypos+mult].f.st_mode & 0000400)
X goto cont;
X else
X goto nop;
X }
X if (l[ypos+mult].f.st_mode & 0000004)
X goto cont;
X else {
nop: wmove(err, 0, 0);
X wprintw(err, "Directory is unreadable.\007");
X refresh();
X wrefresh(err);
X break;
X }
cont: sprintf(str, "%s%s", dname, l[ypos+mult].name);
X strcpy(dname, str);
X } else {
X wmove(err, 0, 0);
X wprintw(err, "Not a directory!\007");
X refresh();
X wrefresh(err);
X break;
X }
lo2: readin();
X wclear(dnm); wclear(fils);
X refresh();
X wrefresh(dnm);
X wrefresh(fils);
X delwin(dnm); delwin(fils);
X fils = newwin(22, 20, 1, strlen(dname)+3);
X dnm = newwin(1, strlen(dname), 12, 0);
X wmove(dnm, 0, 0);
X wprintw(dnm, dname);
X refresh();
X wrefresh(dnm);
X level = 0;
X ypos = 1;
X dlev();
X break;
X case 's':
X wmove(err, 0, 0);
X wprintw(err, "Search in ");
X refresh();
X wrefresh(err);
X echo();
X nocrmode();
X gets(str);
X strcat(str, '/'); /* TMPFIX */
X noecho();
X crmode();
X if (stat(str, &fil) == -1) {
X perror("stat");
X cleanupwoc();
X }
X if (fil.st_uid == getuid()) {
X if (fil.st_mode & 0000400)
X goto ho;
X } else if (open(str, O_RDONLY) == -1) {
X wmove(err, 0, 0);
X wprintw(err, "Directory does not exist.\007");
X refresh();
X wrefresh(err);
X break;
X }
ho: strcpy(dname, str);
X goto lo2;
X break;
X case '\022':
X redraw();
X break;
X case 'q':
X cleanup();
X break;
X case '\033':
X getchar();
X switch(getchar()) {
X case 'A': /* UP */
X ypos--;
X if (ypos < 1)
X ypos = 1;
X break;
X case 'B': /* DN */
X ypos++;
X if (ypos > 22)
X ypos = 22;
X break;
X default:
X break;
X }
X break;
X case '>':
X level++;
X dlev();
X break;
X case '<':
X level--;
X if (level < 0)
X level = 0;
X dlev();
X break;
X case '\012':
X i = ypos+mult;
X wmove(fst, 0, 0);
X wprintw(fst, "File: %s", l[i].name); wclrtoeol(fst);
X wmove(fst, 1, 0);
X wprintw(fst, "Inode: %d", l[i].f.st_ino); wclrtoeol(fst);
X wmove(fst, 2, 0);
X wprintw(fst, "Links: %d", l[i].f.st_nlink); wclrtoeol(fst);
X setpwent();
X pwd = getpwuid(l[i].f.st_uid);
X setgrent();
X grp = getgrgid(l[i].f.st_gid);
X (void) strcpy(buf,"----------");
X if(l[i].f.st_mode & 0000001) buf[9] = 'x';
X if(l[i].f.st_mode & 0000002) buf[8] = 'w';
X if(l[i].f.st_mode & 0000004) buf[7] = 'r';
X if(l[i].f.st_mode & 0000010) buf[6] = 'x';
X if(l[i].f.st_mode & 0000020) buf[5] = 'w';
X if(l[i].f.st_mode & 0000040) buf[4] = 'r';
X if(l[i].f.st_mode & 0000100) buf[3] = 'x';
X if(l[i].f.st_mode & 0000200) buf[2] = 'w';
X if(l[i].f.st_mode & 0000400) buf[1] = 'r';
X if(l[i].f.st_mode & 0001000) buf[9] = 't';
X if(l[i].f.st_mode & 0002000) buf[6] = 's';
X if(l[i].f.st_mode & 0004000) buf[4] = 's';
X switch(l[i].f.st_mode & S_IFMT) {
X case S_IFDIR:
X buf[0] = 'd';
X break;
X case S_IFCHR:
X buf[0] = 'c';
X break;
X case S_IFBLK:
X buf[0] = 'b';
X break;
X case S_IFREG:
X buf[0] = '-';
X break;
X case S_IFLNK:
X buf[0] = 'l';
X break;
X case S_IFSOCK:
X buf[0] = 's';
X break;
X default:
X buf[0] = '?';
X }
X wmove(fst, 3, 0);
X wprintw(fst, "Protection: (%04o) %s", l[i].f.st_mode & 07777, buf);
X wmove(fst, 4, 0);
X wprintw(fst, "UID: %d (%s)", l[i].f.st_uid, pwd->pw_name); wclrtoeol(fst);
X wmove(fst, 5, 0);
X wprintw(fst, "GID: %d (%s)", l[i].f.st_gid, grp->gr_name); wclrtoeol(fst);
X wmove(fst, 6, 0);
X wprintw(fst, "Size: %d blocks (%d)", (l[i].f.st_size + 1023)/1024, l[i].f.st_size); wclrtoeol(fst);
X refresh();
X wrefresh(fst);
X break;
X default:
X break;
X }
X wclear(err);
X wrefresh(err);
X }
X}
X
dlev()
X{
X int dnlen = strlen(dname) + 3;
X int mult = (level * 22);
X for (i = 1 + mult; i < 23 + mult; i++)
X posyf(fils, i-mult, 0, l[i].name, NO);
X
X}
X
END_OF_FILE
if test 5314 -ne `wc -c <'disp.c'`; then
echo shar: \"'disp.c'\" unpacked with wrong size!
fi
chmod +x 'disp.c'
# end of 'disp.c'
fi
if test -f 'init.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'init.c'\"
else
echo shar: Extracting \"'init.c'\" \(933 characters\)
sed "s/^X//" >'init.c' <<'END_OF_FILE'
X/*
X * vdd - visual directory display (C) 1988 (pulsar at lsrhs) Jim King
X *
X * init - contains init() which is called first by main ..
X * contains sinit() which inits the curses screen
X * Use init() to setup any local things or SIGNALS.
X */
X
X#include "vars.h"
X
extern int cleanup(), cleanupwoc(), stopme();
X
sinit()
X{
X noecho();
X crmode();
X err = newwin(1, 80, 0, 0);
X hlp = newwin(10, 30, 10, 50);
X dnm = newwin(1, strlen(dname), 12, 0);
X fils = newwin(22, (50 - strlen(dname) + 3), 1, strlen(dname)+3);
X fst = newwin(10, 30, 1, 50);
X refresh();
X scrollok(err, FALSE);
X scrollok(hlp, FALSE);
X scrollok(dnm, FALSE);
X scrollok(fils, FALSE);
X scrollok(fst, FALSE);
X}
X
init()
X{
X signal(SIGINT, cleanup); /* ^C */
X signal(SIGTERM, cleanupwoc); /* -TERM */
X signal(SIGHUP, cleanup); /* ^D */
X signal(SIGSTOP, cleanupwoc); /* -STOP */
X signal(SIGTSTP, stopme); /* ^Z */
X signal(SIGSEGV, cleanup); /* Segmentation Violation */
X}
END_OF_FILE
if test 933 -ne `wc -c <'init.c'`; then
echo shar: \"'init.c'\" unpacked with wrong size!
fi
chmod +x 'init.c'
# end of 'init.c'
fi
if test -f 'main.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'main.c'\"
else
echo shar: Extracting \"'main.c'\" \(1621 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
X/*
X * vdd - visual directory display (C) 1988 (pulsar at lsrhs) Jim King
X *
X * main.c - contains
X * main() - the main program
X * posy() - A nice screen print utility
X */
X
X#include "vars.h" /* This includes everything else */
X
main(argc, argv)
int argc;
char *argv[];
X{
X initscr();
X init(); /* Signal initialization routine */
X
X if (argc != 2)
X printf("vdd: usage: vdd directory\n"), exit(2);
X
X/* Lets make sure the file is there */
X if (open(argv[1], O_RDONLY) == NULL) {
X perror(argv[1]);
X exit(2);
X }
X
X/* Throw argv[1] stat entry into l[0].f */
X if (stat(argv[1], &l[0].f) == -1) {
X perror(argv[1]);
X exit(2);
X }
X
X if (l[0].f.st_mode & 0000004)
X goto jm1;
X else {
X printf("vdd: directory %s is unreadable.\n", argv[1]);
X exit(1);
X }
X
jm1: switch(l[0].f.st_mode & S_IFMT) {
X case S_IFDIR:
X strcpy(dname, argv[1]);
X if (strncmp(dname, "/\0", 2) != 0)
X strncat(dname, "/\0", 2);
X break;
X default:
X printf("vdd: usage: vdd directory\n"), exit(2);
X break;
X }
X
X sinit();
X readin();
X
X redraw();
X disp(); /* Main display routine */
X}
X
X/* POSY - Position Y.. Variables
X * w - window - WINDOW *w defined in vars.h
X * a - Line position
X * b - Column position
X * c - Reverse image (YES or NO)
X * foo - string to print
X */
X
posy(w, a, b, foo, c)
int a, b, c;
char *foo;
X{
X if (c)
X wstandout(w);
X wmove(w, a, b);
X wprintw(w, foo);
X wclrtoeol(w);
X wstandend(w);
X refresh();
X wrefresh(w);
X}
X
X/* POSYF - posy for the fils window .. -1 */
X
posyf(w, a, b, foo, c)
int a, b, c;
char *foo;
X{
X if (c)
X wstandout(w);
X wmove(w, a-1, b);
X wprintw(w, foo);
X wclrtoeol(w);
X wstandend(w);
X refresh();
X wrefresh(w);
X}
END_OF_FILE
if test 1621 -ne `wc -c <'main.c'`; then
echo shar: \"'main.c'\" unpacked with wrong size!
fi
chmod +x 'main.c'
# end of 'main.c'
fi
if test -f 'readin.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'readin.c'\"
else
echo shar: Extracting \"'readin.c'\" \(874 characters\)
sed "s/^X//" >'readin.c' <<'END_OF_FILE'
X/*
X * vdd - visual directory display (C) 1988 (pulsar at lsrhs) Jim King
X *
X * readin.c - contains readin() which reads in dirs
X */
X
X#include "vars.h"
X
readin()
X{
X total = 0;
X if ((dir = opendir(dname)) == NULL)
X printf("Cannot open dir %s\n", dname), exit(1);
X while ((ent = readdir(dir)) != NULL) {
X total++; /* Just in case I ever need it */
X sprintf(str, "%s/%s", dname, ent->d_name);
X if (stat(str, &l[total].f) == -1) {
X perror(ent->d_name);
X exit(2);
X }
X strcpy(l[total].name, ent->d_name);
X switch(l[total].f.st_mode & S_IFMT) {
X case S_IFDIR:
X l[total].dir = YES;
X/* fudge */ if (strncmp(l[total].name, "/\0", 2) != 0)
X strncat(l[total].name, "/\0", 2);
X break;
X default:
X l[total].dir = NO;
X break;
X }
X }
X closedir(dir); /* Directory(3) */
X for (i = total+1; i < total+40; i++) {
X strncpy(l[i].name, "\0", 1);
X l[i].dir = NO;
X }
X}
END_OF_FILE
if test 874 -ne `wc -c <'readin.c'`; then
echo shar: \"'readin.c'\" unpacked with wrong size!
fi
chmod +x 'readin.c'
# end of 'readin.c'
fi
if test -f 'redraw.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'redraw.c'\"
else
echo shar: Extracting \"'redraw.c'\" \(892 characters\)
sed "s/^X//" >'redraw.c' <<'END_OF_FILE'
X/*
X * vdd - visual directory display (C) 1988 (pulsar at lsrhs) Jim King
X *
X * redraw.c - redraw utility
X */
X
X#include "vars.h"
X
redraw()
X{
X clear();
X wclear(err);
X wclear(dnm);
X wclear(fils);
X
X wmove(dnm, 0, 0);
X wprintw(dnm, dname);
X
X wmove(hlp, 0, 0);
X wprintw(hlp, "UP ARROW- Up");
X wmove(hlp, 1, 0);
X wprintw(hlp, "DN ARROW- Down");
X wmove(hlp, 2, 0);
X wprintw(hlp, "ENTER - Status");
X wmove(hlp, 3, 0);
X wprintw(hlp, "q, ^C - Quit");
X wmove(hlp, 4, 0);
X wprintw(hlp, "^Z - Suspend");
X wmove(hlp, 5, 0);
X wprintw(hlp, "d - Dir Dive");
X wmove(hlp, 6, 0);
X wprintw(hlp, "s - Dir Search");
X wmove(hlp, 7, 0);
X wprintw(hlp, "> - + page");
X wmove(hlp, 8, 0);
X wprintw(hlp, "< - - page");
X wmove(hlp, 9, 0);
X wprintw(hlp, "VDD V%1.1f (C) 1988 Oct", VERSION);
X
X touchwin(hlp);
X touchwin(fst);
X refresh();
X wrefresh(err);
X wrefresh(hlp);
X wrefresh(dnm);
X dlev();
X}
END_OF_FILE
if test 892 -ne `wc -c <'redraw.c'`; then
echo shar: \"'redraw.c'\" unpacked with wrong size!
fi
chmod +x 'redraw.c'
# end of 'redraw.c'
fi
if test -f 'req.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'req.c'\"
else
echo shar: Extracting \"'req.c'\" \(800 characters\)
sed "s/^X//" >'req.c' <<'END_OF_FILE'
X/*
X * vdd - visual diectory display (C) 1988 (pulsar at lsrhs) Jim King
X *
X * req.c - contains program to tell you how much memory
X * you need to make use of the full capability
X * of this program.
X */
X
X#include "vars.h"
X
main()
X{
X int kb;
X
X kb = ((sizeof(l) + 1023) / 1024) + 112;
X printf("In order to use the visual directory display utility at present,\n");
X printf("you will need %d bytes of memory. This amounts to app. %d KB of memory.\n", sizeof(l), (sizeof(l)+1023)/1024);
X printf("This means you will need a good %d KB of memory to run safely w/o munging.\n", kb);
X if (kb / 1024)
X printf("Another perspective: %3d MB\n", kb / 1024);
X printf("If you would like to cut this down, change the MAXDSIZE definition\n");
X printf("in vars.h. Then recompile and run this program again.\n");
X}
END_OF_FILE
if test 800 -ne `wc -c <'req.c'`; then
echo shar: \"'req.c'\" unpacked with wrong size!
fi
chmod +x 'req.c'
# end of 'req.c'
fi
if test -f 'stopme.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'stopme.c'\"
else
echo shar: Extracting \"'stopme.c'\" \(360 characters\)
sed "s/^X//" >'stopme.c' <<'END_OF_FILE'
X/*
X * vdd - visual directory display (C) 1988 (pulsar at lsrhs) Jim King
X *
X * stopme.c - contains stopme for ^Z
X */
X
X#include "vars.h"
X
stopme()
X{
X char *sh;
X move(24, 0);
X refresh();
X endwin();
X fflush(stdout);
X sh = (char *)getenv("SHELL");
X if (sh == NULL)
X sh = "/bin/sh";
X system(sh);
X signal(SIGTSTP, stopme);
X crmode();
X noecho();
X clear();
X redraw();
X}
END_OF_FILE
if test 360 -ne `wc -c <'stopme.c'`; then
echo shar: \"'stopme.c'\" unpacked with wrong size!
fi
chmod +x 'stopme.c'
# end of 'stopme.c'
fi
if test -f 'tags' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'tags'\"
else
echo shar: Extracting \"'tags'\" \(391 characters\)
sed "s/^X//" >'tags' <<'END_OF_FILE'
Mmain main.c /^main(argc, argv)$/
cleanup cleanup.c /^cleanup(x)$/
cleanupwoc cleanup.c /^cleanupwoc(x)$/
disp disp.c /^disp()$/
dlev disp.c /^dlev()$/
init init.c /^init()$/
posy main.c /^posy(w, a, b, foo, c)$/
posyf main.c /^posyf(w, a, b, foo, c)$/
readin readin.c /^readin()$/
redraw redraw.c /^redraw()$/
sinit init.c /^sinit()$/
stopme stopme.c /^stopme()$/
strip disp.c /^strip(s)$/
END_OF_FILE
if test 391 -ne `wc -c <'tags'`; then
echo shar: \"'tags'\" unpacked with wrong size!
fi
# end of 'tags'
fi
if test -f 'vars.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vars.h'\"
else
echo shar: Extracting \"'vars.h'\" \(1370 characters\)
sed "s/^X//" >'vars.h' <<'END_OF_FILE'
X/*
X * vdd - visual diectory display (C) 1988 pulsar at lsrhs
X *
X * vars.h - general include file for all of vdd
X */
X
X/* Include Files */
X
X#include <sys/types.h>
X#include <sys/dir.h>
X#include <sys/stat.h>
X#include <sys/file.h>
X#include <stdio.h>
X#include <errno.h>
X#include <stdio.h>
X#include <signal.h>
X#include <curses.h>
X
X/* Some defines */
X
X#define NO 0 /* Used mostly in posy() */
X#define YES 1 /* Ditto */
X
X#define MAXDSIZE 10000 /* Max number of files that can be read
X before munging */ /* Tunable */
X
X#define VERSION 1.0 /* version # */
X
X/* Windows */
X
WINDOW *err, *hlp, *fils, *fst, *dnm, *w;
X
X/* Structures */
X
X/* structure listing is where all directory listings are held */
struct listing {
X char name[50]; /* Name of file */
X int dir; /* YES or NO */
X struct stat f; /* contains the stat(name) information */
X};
X
extern struct direct *readdir();
X
struct listing l[MAXDSIZE]; /* Make sure we have enough room */
struct direct *ent; /* Used when reading in directory lists */
X
X/* Global definitions */
X
char str[80], /* Randomly used string */
X dname[255], /* Original (argv[1]) Dirname */
X c; /* Used with getchar() */
X
int i,
X j, /* for loop ints */
X total, /* used in readin() to read in dirs */
X level, /* used in disp() for screen display */
X xpos,
X ypos,
X lastx,
X lasty; /* screen display info */
X
X
DIR *dir; /* Used when reading dname */
X
END_OF_FILE
if test 1370 -ne `wc -c <'vars.h'`; then
echo shar: \"'vars.h'\" unpacked with wrong size!
fi
chmod +x 'vars.h'
# end of 'vars.h'
fi
echo shar: End of shell archive.
exit 0
More information about the Comp.sources.misc
mailing list