home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso
/
altsrc
/
articles
/
7000-7999
/
7775
< prev
next >
Wrap
Text File
|
1993-04-14
|
55KB
|
1,845 lines
Newsgroups: alt.sources
Path: wupost!darwin.sura.net!spool.mu.edu!torn!watserv2.uwaterloo.ca!watserv1!news
From: pfratar@fpg.uwaterloo.ca (Paul Frattaroli)
Subject: files, curses-based file manager for UNIX (01/05)
Message-ID: <C5Hops.MtD@watserv1.uwaterloo.ca>
Keywords: file manager files UNIX
Sender: news@watserv1.uwaterloo.ca
Organization: Despotic Coders Society
Date: Wed, 14 Apr 1993 19:56:16 GMT
Lines: 1833
files - a file manager for UNIX
by
Paul Frattaroli
<pfratar@fpg.uwaterloo.ca>
Files is, as the above title would suggest, a file manager for UNIX.
There are increasingly more and more of these programs becoming
available for UNIX but the author has never liked any of them. When I
talk about file managers for UNIX, I mean ones which run in text mode.
There are very nice graphical file managers for Graphical User
Interfaces (GUI's) like Sun's OpenWindows(tm) or OSF's Motif(tm) etc.
However a great number of UNIX users lack the appropriate equipment to
run these graphical file managers.
Files was written using the curses library for handling text-based
terminals. Files for UNIX was also modelled after a file manager for
IBM VM/CMS systems which was written at the University of Waterloo,
called FILELIST. This was an attempt to help migrate users off of our
aging VM system here at UW and onto UNIX systems.
Files has been tested on the following systems:
Sun4, SunOS 4.1.X
DEC MIPS, Ultrix 4.2x, 4.3
SGI, IRIX
RS/6000, AIX 3
MIPS, RISC/os
The source provided should compile with the standard cc on every system
except Sun. You must use gcc on the Sun. However, K&R source can be
provided which should work with Sun's cc.
The source for "files" is also available by anonymous ftp from:
fpg.uwaterloo.ca [129.97.108.41]
/pub/files/
Enjoy...
Paul Frattaroli
--- cut here and feed remainder to sh ---
#! /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 5)."
# Contents: files-2.1 files-2.1/INSTALL files-2.1/attributes.c
# files-2.1/config.h files-2.1/helpsys.c files-2.1/lib files-2.1/man
# files-2.1/mark.c files-2.1/myaddstr.c files-2.1/paths.c
# files-2.1/proto.h files-2.1/rc.h files-2.1/shells.c
# files-2.1/show.c files-2.1/sorting.c files-2.1/struct.h
# files-2.1/util files-2.1/util/Makefile files-2.1/util/tag.c
# Wrapped by pfratar@fpg on Wed Apr 14 15:28:20 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d 'files-2.1' ; then
echo shar: Creating directory \"'files-2.1'\"
mkdir 'files-2.1'
fi
if test -f 'files-2.1/INSTALL' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/INSTALL'\"
else
echo shar: Extracting \"'files-2.1/INSTALL'\" \(825 characters\)
sed "s/^X//" >'files-2.1/INSTALL' <<'END_OF_FILE'
X
X Installation document for "Files"
X
XThis document will attempt to ease the installation of "files" at your
Xsite. About all there is to do (hopefully) is to edit the files
Xconfig.h and Makefile.
X
XCONFIG.H
X
X- Modfiy the values for DEF_EDITOR, DEF_VIEWER and DEF_SHELL (if desired)
X- Ensure that the definition for FILES_LIB_DIR matches the definition
X of LIBDIR in Makefile
X- Change any of the paths to various executibles as necessary
X
XMAKEFILE
X
X- Make sure the definition for MACHINE is correct
X- Set the values for BINDIR, LIBDIR and MANDIR
X- Set the values for any other variables in the Makefile. eg. CFLAGS, LDFLAGS,
X CC, LD, LIBS, INSTALL, INSTALLOPTS and CP
X
XAfter you finish editing these files, type 'make' and/or 'make install'
Xand if all goes well, "files" should be installed.
X
XPaul Frattaroli
X
END_OF_FILE
if test 825 -ne `wc -c <'files-2.1/INSTALL'`; then
echo shar: \"'files-2.1/INSTALL'\" unpacked with wrong size!
fi
# end of 'files-2.1/INSTALL'
fi
if test -f 'files-2.1/attributes.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/attributes.c'\"
else
echo shar: Extracting \"'files-2.1/attributes.c'\" \(3927 characters\)
sed "s/^X//" >'files-2.1/attributes.c' <<'END_OF_FILE'
X/*
X * $Source: /u/pfratar/src/files-2.1/src/RCS/attributes.c,v $
X *
X * $Id: attributes.c,v 6.8 1993/03/30 22:12:20 pfratar v2_1pl10 $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X#define EXTERN
X#include "global.h"
X#undef EXTERN
X
X#ifndef lint
Xstatic char *rcsid = "$Id: attributes.c,v 6.8 1993/03/30 22:12:20 pfratar v2_1pl10 $";
X#endif
X
X/*
X * toggle_mode_bits() - Toggle the bit at the correct position.
X */
Xvoid
Xtoggle_mode_bits(mode_t *m, int p)
X{
X mode_t tm;
X
X switch(p) {
X case 0:
X case 1:
X case 3:
X case 4:
X case 6:
X case 7:
X *m ^= (1 << (8 - p));
X break;
X case 2:
X tm = ((*m & 04000) >> 10) ^ ((*m & 0100) >> 6);
X tm++;
X tm %= 4;
X *m &= 03677;
X *m |= ((tm & 02) << 10);
X *m |= ((tm & 1) << 6);
X break;
X case 5:
X tm = ((*m & 02000) >> 9) ^ ((*m & 010) >> 3);
X tm++;
X tm %= 4;
X *m &= 05767;
X *m |= ((tm & 02) << 9);
X *m |= ((tm & 1) << 3);
X break;
X case 8:
X tm = ((*m & 01000) >> 8) ^ (*m & 1);
X tm++;
X tm %= 4;
X *m &= 06776;
X *m |= ((tm & 02) << 8);
X *m |= (tm & 1);
X break;
X }
X}
X
X/*
X * change_attr() - Change the read/write/execute attributes on a file.
X */
Xint
Xchange_attr(void)
X{
X int position, i, escstat;
X mode_t mode;
X char *modestr;
X int chr;
X
X position = 0;
X escstat = 0;
X modestr = (char *)Alloc(MAXPATHLEN * sizeof(char));
X mode = (entries + *marked_list)->e_stat.st_mode;
X mod2str((entries + *marked_list)->e_stat.st_mode, modestr);
X clear_cwin();
X cwin_yxaddstr(0, 0,
X "Use: 'h' and 'l' (or cursor keys) to move left or right,");
X cwin_yxaddstr(1, 0,
X " spacebar to toggle, enter/return to set");
X
X /*
X * Don't want to display the file's I_FMT character.
X */
X cwin_yxaddstr(2, 0, modestr + 1);
X cwin_move(2, position);
X
X mode &= 07777;
X chr = my_getch(cwin);
X if(isupper(chr) && chr < 256)
X chr = tolower(chr);
X while(!(chr == '\n' || chr == '\r')) {
X switch(chr) {
X case 'h':
X case CSR_LFT:
X position -= (position == 0) ? 0 : 1;
X break;
X case 'l':
X case CSR_RHT: /* char from escape_seq */
X position += (position == ATTRIBWIDTH - 2) ? 0 : 1;
X break;
X case ' ':
X toggle_mode_bits(&mode, position);
X mod2str(mode, modestr);
X cwin_yxaddstr(2, 0, modestr + 1);
X break;
X case '\033':
X goto leave_change_attr;
X break;
X }
X cwin_move(2, position);
X chr = my_getch(cwin);
X }
X for( i = 0; i < num_marked; i++ ) {
X if(chmod((entries + *(marked_list + i))->e_name, (mode_t)mode))
X print_error("Could not change mode:");
X restat_file((entries + *(marked_list + i)));
X }
Xleave_change_attr:
X Free(modestr);
X num_marked = 0;
X new_dir(".", curfilter);
X return(RCNOERR);
X}
X
END_OF_FILE
if test 3927 -ne `wc -c <'files-2.1/attributes.c'`; then
echo shar: \"'files-2.1/attributes.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/attributes.c'
fi
if test -f 'files-2.1/config.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/config.h'\"
else
echo shar: Extracting \"'files-2.1/config.h'\" \(2496 characters\)
sed "s/^X//" >'files-2.1/config.h' <<'END_OF_FILE'
X/*
X * config.h - contains definitions which should be configured by the user.
X *
X * $Source: /u/pfratar/src/files-2.1/src/RCS/config.h,v $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X
X#ifndef __Config_h_
X#define __Config_h_
X
X/*
X * These defines will configure 'files' to your local environment.
X * See also the variables in Makefile
X */
X
X/*
X * DEF_EDITOR: The default editor to start if EDITOR is not defined.
X * DEF_VIEWER: The default pager to use if FILESVIEWER is not defined.
X * DEF_SHELL: The default shell to use if SHELL is not defined.
X */
X#define DEF_EDITOR "vi"
X#define DEF_VIEWER "more -c"
X#define DEF_SHELL "csh"
X
X/*
X * Various defines for the help system.
X * FILES will use a "gopher" based help system if GOPHER_HELP is defined.
X */
X/*
X * Define GOPHER_HELP if you want to use the gopher help system.
X * Define GOPHER_PATH to the initial path for the gopher based
X * documentation. You probably shouldn`t change this unless you have the
X * docs on a local gopher server. [fpg.uwaterloo.ca -> 129.97.108.41]
X * Define GOPHER_CLIENT to the path of your site's gopher client.
X * Define FILES_LIB_DIR to the path where files can find its standard help
X * files. These help files are only used if GOPHER_HELP is not defined.
X */
X/* #define GOPHER_HELP */
X#define GOPHER_PATH "-p \"Software Documentation\"/files fpg.uwaterloo.ca"
X#define GOPHER_CLIENT "/software/gopher/bin/gopher"
X#define FILES_LIB_DIR "/software/files/lib"
X#define HELPFILE "files.help"
X#define INDEXFILE "files.index"
X
X/*
X * Paths to various executibles
X */
X#ifdef MIPS
X#define PATH_CP "/bsd43/bin/cp"
X#else
X#define PATH_CP "/bin/cp"
X#endif
X#define PATH_MV "/bin/mv"
X#define PATH_GREP "grep"
X#define PATH_RM "/bin/rm"
X
X#endif /* #ifndef __Config_h__ */
X
END_OF_FILE
if test 2496 -ne `wc -c <'files-2.1/config.h'`; then
echo shar: \"'files-2.1/config.h'\" unpacked with wrong size!
fi
# end of 'files-2.1/config.h'
fi
if test -f 'files-2.1/helpsys.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/helpsys.c'\"
else
echo shar: Extracting \"'files-2.1/helpsys.c'\" \(4496 characters\)
sed "s/^X//" >'files-2.1/helpsys.c' <<'END_OF_FILE'
X/*
X * $Source: /u/pfratar/src/files-2.1/src/RCS/helpsys.c,v $
X *
X * $Id: helpsys.c,v 6.9 1993/04/14 19:23:53 pfratar v2_1pl10 $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X
X#include <stdio.h>
X#define EXTERN
X#include "global.h"
X#undef EXTERN
X
X#ifndef lint
Xstatic char *rcsid = "$Id: helpsys.c,v 6.9 1993/04/14 19:23:53 pfratar v2_1pl10 $";
X#endif
X
X#define NUM_IDHELPLINES 11
X
Xchar id_lines[NUM_IDHELPLINES][75] = {
X "Use the normal navigation keys to move to the destination directory.",
X "",
X "If you DO NOT wish to change the name of the source:",
X " Press 'd' to complete the [c]opy or [r]ename once you reach the",
X " destination directory.",
X "",
X "If you wish to change the name of the source:",
X " Press 'n' and type the new name once you reach the destination",
X " directory.",
X "",
X "Press 'a' to abort the [c]opy/[r]ename at any time."
X};
X
X/*
X * help_sys() - Start files's help system.
X */
Xint
Xhelp_sys(void)
X{
X FILE *fp, *ifp;
X char hfn[MAXPATHLEN], ifn[MAXPATHLEN], line[MAXPATHLEN];
X int cc, index, tind, ypos, FOUND;
X long toff;
X char *p;
X
X sprintf(hfn, "%s/%s", FILES_LIB_DIR, HELPFILE);
X sprintf(ifn, "%s/%s", FILES_LIB_DIR, INDEXFILE);
X
X if((fp = fopen(hfn, "r")) == NULL) {
X warn_user("Could not open help file");
X goto __help_exit;
X }
X if((ifp = fopen(ifn, "r")) == NULL) {
X warn_user("Could not open index file");
X goto __help_exit;
X }
X
X clear_fwin();
X clear_cwin();
X
X sprintf(line, "Paul's File Manager: %s. Version: %s Patchlevel: %s",
X progname, VERSION, PATCHLEVEL);
X fwin_yxaddstr(3, 2, line);
X fwin_yxaddstr(4, 2, copyright);
X fwin_yxaddstr(6, 2,
X "This program comes with ABSOLUTELY NO WARRANTY");
X fwin_yxaddstr(7, 2,
X "This is free software, and you are welcome to redistribute it");
X fwin_yxaddstr(8, 2,
X "under certain conditions. See the file COPYING for more details");
X
X cwin_yxaddstr(0, 0, "Press the key you want help on. ('h' to exit help)");
X
X do {
X cc = my_getch(fwin);
X FOUND = FALSE;
X if(cc != 'h') {
X index = (int)cc;
X while(fgets(line, sizeof line, ifp) && !FOUND) {
X p = line;
X line[strlen(line) - 1] = '\0';
X
X while(*p && *p != ':') p++;
X *p = '\0';
X tind = atoi(line);
X if(tind == index) {
X toff = atol(p+1);
X FOUND = TRUE;
X }
X }
X
X ypos = 0;
X clear_fwin();
X if(FOUND) {
X fseek(fp, toff, 0);
X while(fgets(line, sizeof line, fp) && strncmp(line, "@@", 2)) {
X fwin_yxaddstr(++ypos, 0, line);
X if(ypos >= fwinlines - 3) {
X ypos++;
X fwin_yxaddstr(++ypos, 0,
X "... More: press enter/return ...");
X fwin_wait();
X clear_fwin();
X ypos = 0;
X }
X }
X } else {
X fwin_yxaddstr(++ypos, 0, "No help found on that key");
X }
X rewind(ifp);
X }
X } while(cc != 'h');
X
X fclose(fp);
X fclose(ifp);
X
X__help_exit:
X new_dir(".", curfilter);
X return(RCNOERR);
X}
X
X/*
X * interdest_help() - Give help on interactive destination choosing.
X */
Xint
Xinterdest_help(void)
X{
X int ypos;
X
X clear_fwin();
X for(ypos = 0; ypos < NUM_IDHELPLINES; ypos++) {
X fwin_yxaddstr(ypos, 0, id_lines[ypos]);
X }
X fwin_yxaddstr(++ypos, 0, ENTRET_PROMPT);
X fwin_wait();
X new_dir(".", curfilter);
X return(RCNOERR);
X}
X
END_OF_FILE
if test 4496 -ne `wc -c <'files-2.1/helpsys.c'`; then
echo shar: \"'files-2.1/helpsys.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/helpsys.c'
fi
if test ! -d 'files-2.1/lib' ; then
echo shar: Creating directory \"'files-2.1/lib'\"
mkdir 'files-2.1/lib'
fi
if test ! -d 'files-2.1/man' ; then
echo shar: Creating directory \"'files-2.1/man'\"
mkdir 'files-2.1/man'
fi
if test -f 'files-2.1/mark.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/mark.c'\"
else
echo shar: Extracting \"'files-2.1/mark.c'\" \(3739 characters\)
sed "s/^X//" >'files-2.1/mark.c' <<'END_OF_FILE'
X/*
X * $Source: /u/pfratar/src/files-2.1/src/RCS/mark.c,v $
X *
X * $Id: mark.c,v 6.8 1993/03/30 22:12:20 pfratar v2_1pl10 $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X#define EXTERN
X#include "global.h"
X#undef EXTERN
X
X#ifndef lint
Xstatic char *rcsid = "$Id: mark.c,v 6.8 1993/03/30 22:12:20 pfratar v2_1pl10 $";
X#endif
X
X/*
X * include_files() - Include or exclude files from marked list by wildcard
X * match on name.
X */
Xint
Xinclude_files(void)
X{
X FILE *pr;
X char str[MAXPATHLEN], cmd[MAXPATHLEN];
X int chr, i, INC = 0, j, tmpfd;
X
X clear_cwin();
X str[0] = '\0';
X chr = get_char_ans("Choose: [i]nclude, [e]xclude, [s]elect or [u]nselect ");
X switch(chr) {
X case 'i':
X INC = 1;
X case 'e':
X get_user_input("Enter wildcard expression:", str);
X if(!*str)
X break;
X sprintf(cmd, "ls -1ad %s | uniq", str);
X i = 0;
X
X /*
X * In order for the next part to work we have to sort by name.
X */
X if(sort_type != SBYNAME) {
X qsort(entries, count, sizeof(struct entry), fl_name_sort);
X warn_user("Warning: I have to sort by name to do this...");
X sort_type = SBYNAME;
X }
X
X tmpfd = dup(2);
X freopen("/dev/null", "w", stderr);
X pr = popen(cmd, "r");
X while(fgets(str, MAXPATHLEN, pr)) {
X *(str + strlen(str) - 1) = '\0';
X while(strcmp(str, (entries + i)->e_name)) {
X if(!INC) {
X if(marked(i) == -1) {
X *(marked_list + num_marked) = i;
X num_marked++;
X }
X }
X i++;
X }
X if(INC) {
X if(marked(i) == -1) {
X *(marked_list + num_marked) = i;
X num_marked++;
X }
X } else {
X if((j = marked(i)) != -1) {
X remove_mark(j);
X }
X }
X i++;
X }
X
X /*
X * If we are excluding files, we have to mark the files from the
X * last match to the end.
X */
X if(i < count && !INC) {
X for(; i < count; i++) {
X *(marked_list + num_marked) = i;
X num_marked++;
X }
X }
X pclose(pr);
X fclose(stderr);
X dup2(tmpfd, 2);
X fdopen(2, "w");
X close(tmpfd);
X break;
X case 's':
X for( i = 0; i < count; i++ )
X *(marked_list + i) = i;
X num_marked = count;
X break;
X case 'u':
X num_marked = 0;
X break;
X default:
X break;
X }
X new_dir(".", curfilter);
X return(RCNOERR);
X}
END_OF_FILE
if test 3739 -ne `wc -c <'files-2.1/mark.c'`; then
echo shar: \"'files-2.1/mark.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/mark.c'
fi
if test -f 'files-2.1/myaddstr.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/myaddstr.c'\"
else
echo shar: Extracting \"'files-2.1/myaddstr.c'\" \(2630 characters\)
sed "s/^X//" >'files-2.1/myaddstr.c' <<'END_OF_FILE'
X/*
X * mywaddstr and mymvwaddstr - Implement special highlighting and attributes
X * using \c type codes.
X *
X * $Source: /u/pfratar/src/files-2.1/src/RCS/myaddstr.c,v $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X
X#include <curses.h>
X
X#ifndef lint
Xstatic char *rcsid = "$Id: myaddstr.c,v 6.8 1993/03/30 22:12:20 pfratar v2_1pl10 $";
X#endif
X
Xint highlight;
X
X/*
X * mywaddstr() - Adds strings to a curses window. Special codes are
X * expanded into highlighting of some sort.
X */
Xvoid
Xmywaddstr(WINDOW *w, char *s)
X{
X char *p, *q, tmp[1024];
X int BOLDON = FALSE;
X
X strcpy(tmp, s);
X q = p = tmp;
X while(*p) {
X switch(*p) {
X case '\\':
X *p = '\0';
X switch(*++p) {
X case 'H':
X waddstr(w, q);
X wrefresh(w);
X#ifndef AIX
X if(MD) fputs(MD, stdout);
X wrefresh(w);
X#endif
X BOLDON = TRUE;
X break;
X case 'h':
X waddstr(w, q);
X wrefresh(w);
X#ifndef AIX
X if(ME) fputs(ME, stdout);
X wrefresh(w);
X#endif
X BOLDON = FALSE;
X break;
X case '\\':
X waddstr(w, "\\");
X wrefresh(w);
X break;
X default:
X break;
X }
X q = p + 1;
X break;
X default:
X break;
X }
X p++;
X }
X waddstr(w, q);
X wrefresh(w);
X}
X
X/*
X * mymvwaddstr() - A mvwaddstr replacement. Uses mywaddstr() above.
X */
Xvoid
Xmymvwaddstr(WINDOW *w, int y, int x, char *s)
X{
X wmove(w, y, x);
X mywaddstr(w, s);
X}
X
END_OF_FILE
if test 2630 -ne `wc -c <'files-2.1/myaddstr.c'`; then
echo shar: \"'files-2.1/myaddstr.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/myaddstr.c'
fi
if test -f 'files-2.1/paths.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/paths.c'\"
else
echo shar: Extracting \"'files-2.1/paths.c'\" \(2470 characters\)
sed "s/^X//" >'files-2.1/paths.c' <<'END_OF_FILE'
X/*
X * $Source: /u/pfratar/src/files-2.1/src/RCS/paths.c,v $
X *
X * $Id: paths.c,v 6.8 1993/03/30 22:12:20 pfratar v2_1pl10 $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X#define EXTERN
X#include "global.h"
X#undef EXTERN
X
X#ifndef lint
Xstatic char *rcsid = "$Id: paths.c,v 6.8 1993/03/30 22:12:20 pfratar v2_1pl10 $";
X#endif
X
X/*
X * expand_dir() - expand normal shell special characters into paths.
X * Example: ~ or ~joeblo
X */
Xchar *
Xexpand_dir(char *dir)
X{
X static char tmp[MAXPATHLEN];
X char *p, *q, *r, *u;
X int was_slash = FALSE;
X struct passwd *pwtmp;
X
X p = dir;
X q = tmp;
X switch(*p) {
X case '~':
X p++;
X for(u = p; *u && *u != '/'; u++);
X if(*u == '/') was_slash = TRUE;
X *u = '\0';
X if(*p) {
X if((pwtmp = getpwnam(p)) != NULL)
X r = pwtmp->pw_dir;
X else
X return((char *)NULL);
X } else {
X r = homedir;
X }
X while(*r) *q++ = *r++;
X *q++ = '/';
X if(was_slash)
X p = u + 1;
X else
X p = u;
X break;
X default:
X break;
X }
X while(*q++ = *p++);
X return(tmp);
X}
X
X/*
X * new_path() - Prompt user for a new absolute or relative path and
X * chdir() there.
X */
Xint
Xnew_path(void)
X{
X static char np[MAXPATHLEN];
X
X get_user_input("Enter new path (Press ^R to retrieve last):", np);
X if(*np) {
X strcpy(cur_wd, "Reading new directory...");
X display_cwd();
X refresh_cwin();
X new_dir(expand_dir(np), curfilter);
X } else
X new_dir(".", curfilter);
X return(RCNOERR);
X}
X
END_OF_FILE
if test 2470 -ne `wc -c <'files-2.1/paths.c'`; then
echo shar: \"'files-2.1/paths.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/paths.c'
fi
if test -f 'files-2.1/proto.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/proto.h'\"
else
echo shar: Extracting \"'files-2.1/proto.h'\" \(4237 characters\)
sed "s/^X//" >'files-2.1/proto.h' <<'END_OF_FILE'
X/* attributes.c */
Xvoid toggle_mode_bits(mode_t *m, int p);
Xint change_attr(void);
X/* configure.c */
Xint configure_files(void);
Xint read_configuration(void);
Xint write_configuration(void);
X/* dir.c */
Xvoid read_cur_dir(char *filt);
Xint check_dirperms(char *path);
Xvoid new_dir(char *path, char *filt);
Xint check_dirinfo(char *filt);
Xvoid save_old_dir(struct dirst *dip);
Xvoid free_old_dir(struct dirst *dip);
Xvoid restat_file(struct entry *fep);
Xvoid free_all_info(void);
Xvoid waitkey(void);
Xvoid get_home_directory(void);
X/* display.c */
Xvoid init_screen(void);
Xvoid end_screen(void);
Xvoid start_win(void);
Xvoid refresh_screen(void);
Xvoid refresh_fwin(void);
Xvoid refresh_cwin(void);
Xvoid init_cwin(void);
Xvoid display_cwd(void);
Xvoid fix_cwd(char *p);
Xvoid init_keywin(void);
Xvoid update_keywin(void);
Xvoid repaint_screen(void);
Xvoid page_up(void);
Xvoid page_down(void);
Xvoid scroll_up(void);
Xvoid scroll_down(void);
Xint cursor_up(int current, int beep);
Xint cursor_down(int current, int beep);
Xvoid go_top(void);
Xvoid go_end(void);
Xvoid display_fwin(void);
Xvoid display_marks(void);
Xvoid warn_user(char *warn);
Xvoid clear_cwin(void);
Xvoid clear_fwin(void);
Xint ask_user(char *ques, char def);
Xint get_char_ans(char *ques);
Xvoid get_user_input(char *ques, char *ans);
Xvoid mygetstr(struct _win_st *ww, char *str);
Xvoid place_mark(void);
Xvoid remove_mark(int which);
Xvoid set_menu(void);
Xvoid display_version(void);
Xvoid cwin_yxaddstr(int y, int x, char *str);
Xvoid cwin_move(int y, int x);
Xvoid fwin_yxaddstr(int y, int x, char *str);
Xvoid fwin_wait(void);
Xvoid display_file_info(char *fn, char *o, char *g, ino_t inod, nlink_t numl, char *atm, char *ctm);
Xvoid calc_fmt_strings(void);
Xvoid window_change_size(void);
Xint my_getch(struct _win_st *w);
Xint escape_seq(int *status, int chr);
Xvoid set_isig(void);
Xvoid init_syswin(void);
Xvoid end_syswin(void);
Xvoid syswin_addstr(char *str);
Xvoid syswin_msg(char *warn);
Xvoid syswin_wait(void);
X/* fileops.c */
Xint backup_file(void);
Xint copy_file(int newnm, int indest);
Xint create_file_dir(void);
Xint delete_file(void);
Xint edit_file(void);
Xint filter_files(void);
Xint grep_file(void);
Xint file_info(void);
Xint rename_file(int newnm, int indest);
X/* helpsys.c */
Xint help_sys(void);
Xint interdest_help(void);
X/* macro.c */
Xvoid read_a_file(char *fn, char **l, int *nm);
Xvoid read_startup_files(void);
Xvoid write_a_file(char *fn, char **l, int nlm);
Xvoid write_startup_file(void);
Xint valid_cmd_string(char *test);
Xvoid preproc_cmd(char *cmd);
Xint expand_cmd(char *cmd, struct entry *eptr);
Xchar *fix_file_name(char *fn);
Xint define_macro(void);
Xvoid execute_macro(char **mpl, int nmp);
Xint print_file(void);
Xint your_cmd(void);
X/* main.c */
Xint main(int argc, char *argv[]);
Xvoid exit_program(void);
Xvoid tm2str(struct tm *tt, char *tstr);
Xvoid mod2str(mode_t m, char *mstr);
Xvoid fl_str(struct entry *ep);
Xvoid fixname(char *orig, char *new);
Xvoid set_fl_indices(int newfl_first, int warp);
Xvoid *Alloc(int size);
Xvoid *RealFree(void *to_free);
Xvoid my_system(char *cmd, int pause);
Xint check_recursive_cp(char *a, char *b);
Xvoid setup_stderr(void);
Xvoid undo_stderr(void);
Xvoid pass_signal(int s);
Xvoid syswin_system(char *bin, char *swch, char *f2);
Xvoid get_error_str(int status);
Xvoid print_error(char *basemsg);
Xint marked(int which);
Xvoid sort_marked_list(void);
Xint intp_cmp(int *a, int *b);
Xvoid handle_sigsegv(void);
Xchar *basename(char *fullname);
X/* mark.c */
Xint include_files(void);
X/* myaddstr.c */
Xvoid mywaddstr(struct _win_st *w, char *s);
Xvoid mymvwaddstr(struct _win_st *w, int y, int x, char *s);
X/* ops.c */
Xint do_command(int cha);
Xint menu_switch(void);
Xint quit_prog(void);
Xint show_version(void);
X/* paths.c */
Xchar *expand_dir(char *dir);
Xint new_path(void);
X/* shells.c */
Xint goto_shell(void);
Xint user_cmd(void);
X/* show.c */
Xvoid view_file(char *fname);
Xint show_file_dir(void);
X/* sorting.c */
Xint fl_extn_sort(struct entry *e1, struct entry *e2);
Xint fl_time_sort(struct entry *e1, struct entry *e2);
Xint time_t_cmp(time_t a, time_t b);
Xint fl_size_sort(struct entry *e1, struct entry *e2);
Xint off_t_cmp(off_t a, off_t b);
Xint fl_name_sort(struct entry *e1, struct entry *e2);
Xint fl_def_sort(struct entry *e1, struct entry *e2);
Xint sort_display(void);
END_OF_FILE
if test 4237 -ne `wc -c <'files-2.1/proto.h'`; then
echo shar: \"'files-2.1/proto.h'\" unpacked with wrong size!
fi
# end of 'files-2.1/proto.h'
fi
if test -f 'files-2.1/rc.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/rc.h'\"
else
echo shar: Extracting \"'files-2.1/rc.h'\" \(966 characters\)
sed "s/^X//" >'files-2.1/rc.h' <<'END_OF_FILE'
X/*
X * rc.h - contains definitions of various return values.
X *
X * $Source: /u/pfratar/src/files-2.1/src/RCS/rc.h,v $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X
X#define RCNOCMD 0
X#define RCNOERR 1
X#define RCQUIT 50
X
END_OF_FILE
if test 966 -ne `wc -c <'files-2.1/rc.h'`; then
echo shar: \"'files-2.1/rc.h'\" unpacked with wrong size!
fi
# end of 'files-2.1/rc.h'
fi
if test -f 'files-2.1/shells.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/shells.c'\"
else
echo shar: Extracting \"'files-2.1/shells.c'\" \(2387 characters\)
sed "s/^X//" >'files-2.1/shells.c' <<'END_OF_FILE'
X/*
X * $Source: /u/pfratar/src/files-2.1/src/RCS/shells.c,v $
X *
X * $Id: shells.c,v 6.9 1993/03/30 22:12:20 pfratar v2_1pl10 $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X#define EXTERN
X#include "global.h"
X#undef EXTERN
X
X#ifndef lint
Xstatic char *rcsid = "$Id: shells.c,v 6.9 1993/03/30 22:12:20 pfratar v2_1pl10 $";
X#endif
X
X/*
X * goto_shell() - Start an interactive shell.
X */
Xint
Xgoto_shell(void)
X{
X char shell[MAXPATHLEN], *tmp;
X
X end_screen();
X tmp = getenv("SHELL");
X if(tmp) {
X strcpy(shell, tmp);
X my_system(shell, NOPAUSE);
X } else
X my_system(DEF_SHELL, NOPAUSE);
X num_marked = 0;
X start_win();
X new_dir(".", curfilter);
X return(RCNOERR);
X}
X
X/*
X * user_cmd() - Escape to the shell for a command.
X */
Xint
Xuser_cmd(void)
X{
X static char ocmd[MAXPATHLEN];
X char cmd[MAXPATHLEN];
X int i;
X
X get_user_input("Enter command (Press ^R to retrieve last command):", ocmd);
X if(*ocmd) {
X end_screen();
X for(i = 0; i < num_marked; i++) {
X strcpy(cmd, ocmd);
X preproc_cmd(cmd);
X expand_cmd(cmd, (entries + *(marked_list + i)));
X if(cmd[0]) {
X if( i == num_marked - 1 || num_marked == 0 )
X my_system(cmd, PAUSE);
X else
X my_system(cmd, NOPAUSE);
X } else {
X fprintf(stderr, "Command line too long\n");
X waitkey();
X }
X restat_file((entries + *(marked_list + i)));
X }
X num_marked = 0;
X start_win();
X }
X num_marked = 0;
X new_dir(".", curfilter);
X return(RCNOERR);
X}
END_OF_FILE
if test 2387 -ne `wc -c <'files-2.1/shells.c'`; then
echo shar: \"'files-2.1/shells.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/shells.c'
fi
if test -f 'files-2.1/show.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/show.c'\"
else
echo shar: Extracting \"'files-2.1/show.c'\" \(3501 characters\)
sed "s/^X//" >'files-2.1/show.c' <<'END_OF_FILE'
X/*
X * $Source: /u/pfratar/src/files-2.1/src/RCS/show.c,v $
X *
X * $Id: show.c,v 6.9 1993/03/30 22:12:20 pfratar v2_1pl10 $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X#define EXTERN
X#include "global.h"
X#undef EXTERN
X
X#ifndef lint
Xstatic char *rcsid = "$Id: show.c,v 6.9 1993/03/30 22:12:20 pfratar v2_1pl10 $";
X#endif
X
X/*
X * view_file() - View the file using the user's file viewer or
X * DEF_VIEWER if one isn't defined.
X */
Xvoid
Xview_file(char *fname)
X{
X char cmd[MAXPATHLEN], viewer[MAXPATHLEN], *tmp;
X
X tmp = getenv("FILESVIEWER");
X if(tmp) {
X strcpy(viewer, tmp);
X sprintf(cmd, "%s '%s'", viewer, fix_file_name(fname));
X } else
X sprintf(cmd, "%s '%s'", DEF_VIEWER, fix_file_name(fname));
X end_screen();
X my_system(cmd, PAUSE);
X num_marked = 0;
X start_win();
X}
X
X/*
X * show_file_dir() - Change to a new directory to display or show a file
X * using view/more.
X */
Xint
Xshow_file_dir(void)
X{
X mode_t x;
X struct stat *tmpst;
X char cmd[MAXPATHLEN], args[MAXPATHLEN];
X
X x = (entries + (fl_first + cursor_pos))->e_stat.st_mode;
X x &= 0170000;
X x >>= 12;
X if(x == 012) {
X tmpst = (struct stat *)Alloc(sizeof(struct stat));
X stat((entries + fl_first + cursor_pos)->e_name, tmpst);
X x = tmpst->st_mode;
X x &= 0170000;
X x >>= 12;
X Free(tmpst);
X }
X if(x == 004) {
X strcpy(cur_wd, "Reading new directory...");
X display_cwd();
X refresh_cwin();
X new_dir((entries + fl_first + cursor_pos)->e_name, curfilter);
X }
X if(x == 010) {
X x = (entries + (fl_first + cursor_pos))->e_stat.st_mode;
X if(((x & 07777) & 06111)) {
X sprintf(cmd, "Execute \"%s\" (y/n)? ",
X (entries + (fl_first + cursor_pos))->e_name);
X if(ask_user(cmd, 'n')) {
X sprintf(cmd, "Arguments to '%s'?",
X (entries + (fl_first + cursor_pos))->e_name);
X args[0] = '\0';
X get_user_input(cmd, args);
X sprintf(cmd, "./%s %s",
X (entries + (fl_first + cursor_pos))->e_name,
X (args) ? args : "");
X end_screen();
X my_system(cmd, PAUSE);
X num_marked = 0;
X start_win();
X } else {
X /*
X * If the user doesn't want to run an executable file
X * perhaps its a shell script, so lets view it.
X */
X view_file((entries + fl_first + cursor_pos)->e_name);
X }
X } else {
X view_file((entries + fl_first + cursor_pos)->e_name);
X }
X new_dir(".", curfilter);
X }
X return(RCNOERR);
X}
END_OF_FILE
if test 3501 -ne `wc -c <'files-2.1/show.c'`; then
echo shar: \"'files-2.1/show.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/show.c'
fi
if test -f 'files-2.1/sorting.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/sorting.c'\"
else
echo shar: Extracting \"'files-2.1/sorting.c'\" \(4785 characters\)
sed "s/^X//" >'files-2.1/sorting.c' <<'END_OF_FILE'
X/*
X * $Source: /u/pfratar/src/files-2.1/src/RCS/sorting.c,v $
X *
X * $Id: sorting.c,v 6.7 1993/03/30 22:12:20 pfratar v2_1pl10 $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X#define EXTERN
X#include "global.h"
X#undef EXTERN
X
X#ifndef lint
Xstatic char *rcsid = "$Id: sorting.c,v 6.7 1993/03/30 22:12:20 pfratar v2_1pl10 $";
X#endif
X
X/*
X * fl_extn_sort() - Used by sort_display() to sort on extension.
X */
Xint
Xfl_extn_sort(struct entry *e1, struct entry *e2)
X{
X char *p, *q;
X
X p = index(e1->e_name, '.');
X q = index(e2->e_name, '.');
X if(!p && !q) {
X return(strcmp(e1->e_name, e2->e_name));
X } else if(!p && q) {
X return(-1);
X } else if(p && !q) {
X return(1);
X } else {
X p++;
X q++;
X return(strcmp(p, q));
X }
X}
X
X/*
X * fl_time_sort(), time_t_cmp() - Used by sort_display() to sort on time.
X */
Xint
Xfl_time_sort(struct entry *e1, struct entry *e2)
X{
X return(time_t_cmp(e1->e_stat.st_mtime, e2->e_stat.st_mtime));
X}
X
Xint
Xtime_t_cmp(time_t a, time_t b)
X{
X return((a > b) ? -1 : (a == b) ? 0 : 1);
X}
X
X/*
X * fl_size_sort(), off_t_cmp() - Used by sort_display() to sort on size.
X */
Xint
Xfl_size_sort(struct entry *e1, struct entry *e2)
X{
X return(off_t_cmp(e1->e_stat.st_size, e2->e_stat.st_size));
X}
X
Xint
Xoff_t_cmp(off_t a, off_t b)
X{
X return((a > b) ? -1 : (a == b) ? 0 : 1);
X}
X
X/*
X * fl_name_sort() - Used by sort_display() to sort on name.
X */
Xint
Xfl_name_sort(struct entry *e1, struct entry *e2)
X{
X return(strcmp(e1->e_name, e2->e_name));
X}
X
X/*
X * fl_def_sort() - Used by sort_display() to sort in FILES's default
X * manner.
X */
Xint
Xfl_def_sort(struct entry *e1, struct entry *e2)
X{
X int num_of_dirs = 0, x, y, rc;
X struct stat *tmpst;
X
X /*
X * Various cases:
X * 1) . and ..
X * 2) directory and file
X * 3) 2 directories
X * 4) 2 files
X */
X x = e1->e_stat.st_mode;
X y = e2->e_stat.st_mode;
X x &= 0170000;
X y &= 0170000;
X x >>= 12;
X y >>= 12;
X
X if(x == 012) {
X tmpst = (struct stat *)Alloc(sizeof(struct stat));
X stat(e1->e_name, tmpst);
X x = tmpst->st_mode;
X x &= 0170000;
X x >>= 12;
X Free(tmpst);
X }
X if(y == 012) {
X tmpst = (struct stat *)Alloc(sizeof(struct stat));
X stat(e2->e_name, tmpst);
X y = tmpst->st_mode;
X y &= 0170000;
X y >>= 12;
X Free(tmpst);
X }
X
X /*
X * num_of_dirs
X * neither e1 or e2 are directories: 0
X * e1 is a directory: 1
X * e2 is a directory: 2
X * both e1 and e2 are directories: 3
X */
X if(x == 004) num_of_dirs |= 0x01;
X if(y == 004) num_of_dirs |= 0x02;
X
X switch(num_of_dirs) {
X case 0:
X return(fl_name_sort(e1, e2));
X break;
X case 1:
X return(-1);
X break;
X case 2:
X return(1);
X break;
X case 3:
X if(!strcmp(e1->e_name, ".")) {
X rc = -1;
X } else if(!strcmp(e2->e_name, ".")) {
X rc = 1;
X } else if(!strcmp(e1->e_name, "..")) {
X rc = -1;
X } else if(!strcmp(e2->e_name, "..")) {
X rc = 1;
X } else {
X rc = fl_name_sort(e1, e2);
X }
X break;
X }
X return(rc);
X}
X
X/*
X * sort_display() - Sort the file list display in a different order.
X */
Xint
Xsort_display(void)
X{
X int stype;
X
X stype =
X get_char_ans("Sort: [d]efault, [e]xtension, [n]ame, [t]ime, [s]ize? ");
X switch(stype) {
X case 'e':
X sort_type = SBYEXTN;
X break;
X case 't':
X sort_type = SBYTIME;
X break;
X case 's':
X sort_type = SBYSIZE;
X break;
X case 'n':
X sort_type = SBYNAME;
X break;
X default:
X sort_type = SBYDFLT;
X }
X num_marked = 0;
X new_dir(".", curfilter);
X return(RCNOERR);
X}
X
END_OF_FILE
if test 4785 -ne `wc -c <'files-2.1/sorting.c'`; then
echo shar: \"'files-2.1/sorting.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/sorting.c'
fi
if test -f 'files-2.1/struct.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/struct.h'\"
else
echo shar: Extracting \"'files-2.1/struct.h'\" \(1660 characters\)
sed "s/^X//" >'files-2.1/struct.h' <<'END_OF_FILE'
X/*
X * struct.h - contains definition of entry structure.
X *
X * $Source: /u/pfratar/src/files-2.1/src/RCS/struct.h,v $
X *
X * files - full screen file manager for UNIX
X * Copyright (C) 1993 Paul Frattaroli
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X */
X
X/*
X * structure to hold a single directory entry.
X */
Xtypedef struct entry {
X char *e_name;
X char *e_flstr;
X struct stat e_stat;
X u_long e_flags;
X} entry;
X
X/*
X * structure to hold all the necessary info needed to return to a
X * directory that has already been read.
X */
Xtypedef struct dirst {
X char *d_name;
X int d_sort_type;
X int d_count;
X int d_fl_first;
X int d_fl_last;
X int d_cursor_pos;
X int d_num_marked;
X int *d_marked_list;
X int d_kw_mode;
X u_long d_mrk_sum;
X struct stat *d_stat;
X struct entry *d_entries;
X u_long d_flags;
X} dirst;
X
Xtypedef struct conf_t {
X char ct_name[32];
X char ct_desc[64];
X int ct_val;
X int ct_ny;
X int ct_nx;
X int ct_dy;
X int ct_dx;
X} conf_t;
X
END_OF_FILE
if test 1660 -ne `wc -c <'files-2.1/struct.h'`; then
echo shar: \"'files-2.1/struct.h'\" unpacked with wrong size!
fi
# end of 'files-2.1/struct.h'
fi
if test ! -d 'files-2.1/util' ; then
echo shar: Creating directory \"'files-2.1/util'\"
mkdir 'files-2.1/util'
fi
if test -f 'files-2.1/util/Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/util/Makefile'\"
else
echo shar: Extracting \"'files-2.1/util/Makefile'\" \(279 characters\)
sed "s/^X//" >'files-2.1/util/Makefile' <<'END_OF_FILE'
XPROG = tag
X
XSRCS = tag.c
X
XOBJS = tag.o
X
XLIBS =
X
XHELPFILE = ../lib/files.help
XINDEXFILE = ../lib/files.index
X
Xall: tag index
X
Xtag: tag.c
X gcc -O -o $(PROG) $(SRCS) $(LIBS)
X
Xindex: $(INDEXFILE)
X
X$(INDEXFILE): $(HELPFILE)
X ./tag $(HELPFILE) $(INDEXFILE)
X
Xclean:
X rm -f *.o $(PROG)
X
END_OF_FILE
if test 279 -ne `wc -c <'files-2.1/util/Makefile'`; then
echo shar: \"'files-2.1/util/Makefile'\" unpacked with wrong size!
fi
# end of 'files-2.1/util/Makefile'
fi
if test -f 'files-2.1/util/tag.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'files-2.1/util/tag.c'\"
else
echo shar: Extracting \"'files-2.1/util/tag.c'\" \(4879 characters\)
sed "s/^X//" >'files-2.1/util/tag.c' <<'END_OF_FILE'
X/*
X * tag.c - Create an index from a tagged input file
X * Due to the nature of the algorithm, anything that appears in
X * the input file before the first tag is actually a comment
X * since a key/offset value will not appear in the index for it.
X *
X * $Source: /u/pfratar/src/files-2.1/util/RCS/tag.c,v $
X *
X * $Log: tag.c,v $
X * Revision 1.2 1993/03/04 23:17:59 pfratar
X * Made a few minor formatting changes and added a few comments.
X *
X * Revision 1.1 1993/03/04 23:03:13 pfratar
X * Initial revision
X *
X */
X
X#ifndef lint
Xstatic char *rcsid = "$Id: tag.c,v 1.2 1993/03/04 23:17:59 pfratar Exp $";
X#endif
X
X#include <stdio.h>
X#include <string.h>
X#include <strings.h>
X
X#define KEY_TAG "@@key:"
X#define KEY_TAG_LEN 6
X#define TABLE_SIZE 256
X
Xchar Pname[1024];
X
X/*
X * Table structure to hold the key and the offset for that key
X */
Xtypedef struct tab {
X int ind;
X long off;
X} tab_t;
X
X/*
X * The user fucked up, print out a usage message to help them
X */
Xvoid
Xusage(void)
X{
X printf("Usage: %s [ infile [ outfile ] ]\n", Pname);
X return;
X}
X
X/*
X * We want to sort the table of key/offset pairs, here is our comparison
X * routine to pass to qsort
X */
Xint
Xcompar(tab_t *a, tab_t *b)
X{
X if(a->ind > b->ind) return(1);
X else if(a->ind < b->ind) return(-1);
X else return(0);
X}
X
X/*
X * Run through the input file, find the keys, grab the offset, store
X * the key/value pairs in the table, sort the table, output the
X * table to the output file
X */
Xint
Xcreate_index(FILE *fp, FILE *ofp)
X{
X char line[1024], *p, *q;
X long current;
X tab_t *table, *t;
X int tsize, tind = 0, i;
X
X /*
X * Get an initial table
X */
X tsize = TABLE_SIZE;
X table = (tab_t *)malloc(tsize * sizeof(tab_t));
X if(!table) return(1);
X t = table;
X
X while(fgets(line, sizeof line, fp)) {
X
X /* Get the current offset in the file */
X current = ftell(fp);
X
X /* Did we just read a key tag? */
X if(!strncmp(line, KEY_TAG, KEY_TAG_LEN)) {
X
X /*
X * We have found a new key, do we have enough space
X * in the table? If not, allocate more space.
X */
X if(tind >= tsize) {
X tsize *= 2;
X table = (tab_t *)realloc(table, tsize * sizeof(tab_t));
X t = table + tind;
X }
X
X /* NULL out the newline */
X line[strlen(line) - 1] = '\0';
X
X /* Skip over the tag */
X p = line + KEY_TAG_LEN;
X
X /* Skip over white space */
X while(*p && *p == ' ') p++;
X
X /*
X * Convert the comma separated numbers and place
X * into the table.
X */
X q = p;
X while(*q) {
X /* Find a comma or EOL */
X while(*p && *p != ',') p++;
X if(*p == ',') {
X *p = '\0';
X t->ind = atoi(q);
X t->off = current;
X *p++ = ',';
X } else {
X t->ind = atoi(q);
X t->off = current;
X }
X t++, tind++;
X q = p;
X }
X }
X }
X
X /* Sort the index list */
X qsort(table, tind, sizeof(tab_t), compar);
X
X /* Print out the index list */
X t = table;
X for(i = 0; i < tind; i++) {
X sprintf(line, "%d:%ld\n", t->ind, t->off);
X fputs(line, ofp);
X t++;
X }
X
X if(table) free(table);
X return(0);
X}
X
Xint
Xmain(int argc, char **argv)
X{
X char *cp;
X FILE *ifp, *ofp;
X
X /*
X * Get the program name
X */
X if(cp = rindex(argv[0], '/'))
X strcpy(Pname, cp+1);
X else
X strcpy(Pname, argv[0]);
X
X /*
X * Assume initially that we will be using stdin and stdout.
X */
X ifp = stdin;
X ofp = stdout;
X
X /*
X * If there were arguments, do create_index() once for each,
X * otherwise, use stdin.
X */
X switch(argc) {
X case 1:
X if(create_index(ifp, ofp))
X fprintf(stderr, "%s: %s\n", Pname, "Error creating index");
X break;
X case 3:
X if((ofp = fopen(argv[2], "w")) == NULL) {
X fprintf(stderr, "%s: %s '%s'\n", Pname,
X "Could not open output file", argv[2]
X );
X }
X /* FALL THROUGH */
X case 2:
X if((ifp = fopen(argv[1], "r")) == NULL) {
X fprintf(stderr, "%s: %s '%s'\n",
X Pname, "Could not open file", argv[1]
X );
X } else {
X if(create_index(ifp, ofp))
X fprintf(stderr, "%s: %s '%s'\n",
X Pname, "Error creating index for", argv[1]
X );
X fclose(ifp);
X fclose(ofp);
X }
X break;
X default:
X fprintf(stderr, "%s: Invalid arguments\n", Pname);
X usage();
X break;
X }
X return(0);
X}
X
END_OF_FILE
if test 4879 -ne `wc -c <'files-2.1/util/tag.c'`; then
echo shar: \"'files-2.1/util/tag.c'\" unpacked with wrong size!
fi
# end of 'files-2.1/util/tag.c'
fi
echo shar: End of archive 1 \(of 5\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 5 archives.
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
--
Paul "vi joe" Frattaroli - Department of Computing Services
University of Waterloo Waterloo, Ontario Canada N2L-3G1
< pfratar@fpg.UWaterloo.CA > < pfratar@watserv1.UWaterloo.CA >