home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / maint / part01 < prev    next >
Encoding:
Text File  |  1992-05-13  |  86.5 KB  |  2,728 lines

  1. Newsgroups: comp.sources.unix
  2. From: peirce@gw.wmich.edu (Leonard J. Peirce)
  3. Subject: v26i049: maint - full-screen file and directory maintenance tool, Part01/07
  4. Sender: unix-sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: peirce@gw.wmich.edu (Leonard J. Peirce)
  8. Posting-Number: Volume 26, Issue 49
  9. Archive-Name: maint/part01
  10.  
  11.    Maint is a full-screen file and directory maintenance program.  It will
  12. allow you to do all sorts of things to files and directories with just a few
  13. keystrokes.  It also makes it easier to scan a bunch of directories and sub-
  14. directories very quickly.  It has a number of different startup options for
  15. formatting the information on the screen and the a whole slew of commands
  16. that may be specified.
  17.  
  18. Leonard J. Peirce               Internet:  peirce@mickey.acs.wmich.edu
  19. Western Michigan University                peirce@gw.wmich.edu
  20. Academic Computing Services
  21. Kalamazoo, MI  49008            Voice:     (616) 387-5469
  22.  
  23. #! /bin/sh
  24. # This is a shell archive.  Remove anything before this line, then unpack
  25. # it by saving it into a file and typing "sh file".  To overwrite existing
  26. # files, type "sh file -c".  You can also feed this as standard input via
  27. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  28. # will see the following message at the end:
  29. #        "End of archive 1 (of 7)."
  30. # Contents:  COPYRIGHT MANIFEST Makefile.dist README args.c edit.c
  31. #   help.c locate.c maint.1 maint.help mem.c select.c sort.c
  32. # Wrapped by vixie@cognition.pa.dec.com on Thu May 14 23:05:42 1992
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'COPYRIGHT'\"
  36. else
  37. echo shar: Extracting \"'COPYRIGHT'\" \(2928 characters\)
  38. sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
  39. X           Maint Directory/File Maintenance General Public License
  40. X
  41. X            (C) Copyright 1992 by Leonard J. Peirce
  42. X
  43. X
  44. X                  COPYING POLICIES
  45. X
  46. X   Permission is hereby  granted for copying and distribution of copies of the
  47. Maint source  files, and that of  any part  thereof, subject to  the following
  48. license conditions:
  49. X
  50. X    1. You may, without  additional permission from the author, distribute 
  51. X       Maint or components of  Maint, with or without  additions developed
  52. X       by you or by  others at no charge.   You may also  distribute Maint
  53. X       along with any other product  for sale, provided  that the  cost of
  54. X       the bundled  package is the same regardless of whether Maint is in-
  55. X       cluded, and provided that  those interested  only in Maint  must be
  56. X       notified that it is a product freely available from the author.
  57. X
  58. X    2. Furthermore, if you  distribute Maint  software or  parts of Maint,
  59. X       with or without additions developed by you or others, then you must 
  60. X       either  make  available the  source to  all  portions  of the Maint
  61. X       system (exclusive  of any additions made by  you or by others) upon
  62. X       request, or instead you may notify anyone requesting source that it
  63. X       is freely available from the author.
  64. X
  65. X    3. In  addition, you  may  not  omit any of the  copyright  notices on
  66. X       either the source files, the executable file, or the documentation.
  67. X
  68. X    4. Also, you  may not omit transmission of this License agreement with 
  69. X       whatever portions of Maint that are distributed.
  70. X
  71. X    5. Lastly, any  users of  this  software must be  notified that  it is
  72. X       without  warrantee or guarantee  of any nature, express or implied, 
  73. X       nor is there any fitness for use represented.
  74. X
  75. Software is  a malleable  thing and the  author can in  no way  guarantee that
  76. using this  program will not cause grevious  damage to your system.  Of course
  77. this  isn't anticipated, but  if it  does  happen, the author  cannot  be held
  78. liable for any damages either directly or indirectly caused by this event.
  79. X
  80. Modification of the  system is encouraged, providing  that the portions of the
  81. system that  are from the original still  carry the  appropriate copyright no-
  82. tices  and  that the  changed  sections  are clearly  delimited  as such.  The
  83. author requests copies of any changes made to ensure that the various versions
  84. stay reasonably in sync with each other.
  85. X
  86. Note that it is not  permitted to copy, sublicense, distribute or transfer any
  87. of the Maint software except as expressly  indicated herein.  Any  attempts to
  88. do otherwise will be considered a violation of this license and your rights to
  89. the Maint software will be voided.
  90. X
  91. X
  92. Comments on  the system  and/or this licensing agreement are encouraged.  Send
  93. electronic  mail to peirce@gw.wmich.edu.  The text  of this  copyright license
  94. was borrowed from the ELM(tm) Mail System with permission from Dave Taylor.
  95. END_OF_FILE
  96. if test 2928 -ne `wc -c <'COPYRIGHT'`; then
  97.     echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
  98. fi
  99. # end of 'COPYRIGHT'
  100. fi
  101. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  102.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  103. else
  104. echo shar: Extracting \"'MANIFEST'\" \(871 characters\)
  105. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  106. X   File Name        Archive #    Description
  107. X-----------------------------------------------------------
  108. X COPYRIGHT                  1    
  109. X MANIFEST                   1    
  110. X Makefile.dist              1    
  111. X README                     1    
  112. X args.c                     1    
  113. X edit.c                     1    
  114. X help.c                     1    
  115. X info.c                     2    
  116. X locate.c                   1    
  117. X main.c                     7    
  118. X maint.1                    1    
  119. X maint.h.dist               2    
  120. X maint.help                 1    
  121. X mark.c                     3    
  122. X mem.c                      1    
  123. X misc.c                     5    
  124. X misc.c.orig                6    
  125. X options.c                  2    
  126. X pool.c                     2    
  127. X screen.c                   4    
  128. X select.c                   1    
  129. X slot.c                     2    
  130. X sort.c                     1    
  131. X text.c                     3    
  132. X xecute.c                   3    
  133. END_OF_FILE
  134. if test 871 -ne `wc -c <'MANIFEST'`; then
  135.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  136. fi
  137. # end of 'MANIFEST'
  138. fi
  139. if test -f 'Makefile.dist' -a "${1}" != "-c" ; then 
  140.   echo shar: Will not clobber existing file \"'Makefile.dist'\"
  141. else
  142. echo shar: Extracting \"'Makefile.dist'\" \(3691 characters\)
  143. sed "s/^X//" >'Makefile.dist' <<'END_OF_FILE'
  144. X################################################################################
  145. X#
  146. X#   Installation:  Western Michigan University Academic Computer Center
  147. X#
  148. X#   System:    Software Tools
  149. X#
  150. X#   Program:    maint
  151. X#
  152. X#   Version=01    Level=00    05/31/90    Leonard J. Peirce
  153. X#
  154. X#   Purpose:    Makefile for building maint.
  155. X#
  156. X#   Syntax:    % make            to build maint
  157. X#        % make install        to install maint
  158. X#
  159. X#   Other:    (C) Copyright 1992, Leonard J. Peirce
  160. X#
  161. X###############################################################################
  162. X
  163. X# INSTRUCTIONS:
  164. X#
  165. X# Pick the correct CC, LIB, and CFLAGS for your site from the examples below.
  166. X# Default values are provided and might be pretty good choices if you're not
  167. X# sure what to use.  Also, set BINDIR, BINMODE, etc., if you want to use
  168. X# the makefile to install maint for you.  HELPFILE has a default below but
  169. X# you should make sure it's correct.
  170. X
  171. X# SunOS:
  172. X# The System V stuff must be installed because maint needs the System V
  173. X# curses.h and curses and termcap libraries; Terminfo must also be installed;
  174. X# gcc can be used but CFLAGS must be modified to include -I/usr/5include and
  175. X# and LFLAGS must be modified to pick up the curses and termcap libraries in
  176. X# /usr/5lib;
  177. X# Also, if you are running SunOS 3.X, you need to add -DSUNOS3 to CFLAGS.
  178. X# Examples:
  179. X#   The following works with the System V C compiler:
  180. X#
  181. X#CC = /usr/5bin/cc
  182. X#DEBUGOPT = -O4
  183. X#CFLAGS = $(DEBUGOPT) -c -DHELPFILE=\"${HELPDIR}/maint.help\"
  184. X#LIBS = -lcurses -ltermcap
  185. X#
  186. X#   If you want to use gcc, you might try:
  187. X#
  188. X#CC = gcc
  189. X#DEBUGOPT = -O
  190. X#CFLAGS = -I/usr/5include $(DEBUGOPT) -c -DHELPFILE=\"${HELPDIR}/maint.help\"
  191. X#LIBS = /usr/5lib/libcurses.a /usr/5lib/libtermcap.a
  192. X
  193. X
  194. X# ULTRIX:
  195. X# ULTRIX needs -lcursesX; realize that maint will only build for ULTRIX 3.0+;
  196. X# the curses library in the older versions won't work
  197. X# ULTRIX sites can also use vcc or gcc for the C compiler
  198. CC = cc
  199. DEBUGOPT = -O
  200. CFLAGS = $(DEBUGOPT) -c -DHELPFILE=\"${HELPDIR}/maint.help\"
  201. LIBS = -lcursesX -ltermcap
  202. X
  203. X# System V:
  204. X# Haven't done much testing in this environment.  It worked fine the last
  205. X# time someone tested it for me (System V Release 3 on a 3b2)
  206. X#CC = cc
  207. X#DEBUGOPT = -O
  208. X#CFLAGS = -DMAXPATHLEN=1024 -DSYSV $(DEBUGOPT) -c -DHELPFILE=\"${HELPDIR}/maint.help\"
  209. X#LIBS = -lcurses -ltermcap
  210. X
  211. X# Set these if you want to use the Makefile to install maint for you
  212. X#
  213. X# BINDIR - where the executable will live
  214. X# BINMODE - protection mode for the executable
  215. X# MANDIR - where the man page will live
  216. X# MANMODE - protection mode for the man page
  217. X# HELPDIR - where the on-line help file will live
  218. X# HELPMODE - protection mode for help file
  219. X# OWNER - of executable, the man page, and the help file
  220. X# GROUP - ditto
  221. X
  222. BINDIR = /usr/local/bin
  223. BINMODE = 755
  224. MANDIR = /usr/local/man/man1
  225. MANMODE = 644
  226. HELPDIR = /usr/local/lib
  227. HELPMODE = 644
  228. OWNER = root
  229. GROUP = daemon
  230. X
  231. X# End of configuration section
  232. X
  233. LDFLAGS = $(DEBUGOPT)
  234. X
  235. OBJECTS = main.o args.o edit.o help.o info.o locate.o mark.o mem.o\
  236. X      misc.o options.o pool.o screen.o select.o slot.o sort.o text.o\
  237. X      xecute.o
  238. X
  239. SOURCES = main.c args.c edit.c help.c info.c locate.c mark.c mem.c\
  240. X      misc.c options.c pool.c screen.c select.c slot.c sort.c text.c\
  241. X      xecute.c
  242. X
  243. INCLUDES = maint.h
  244. LINTFLAGS = -chxz
  245. X
  246. maint:        ${OBJECTS}
  247. X        ${CC} ${LDFLAGS} ${OBJECTS} ${LIBS} -o maint
  248. X
  249. X${OBJECTS}:    ${INCLUDES}
  250. X
  251. X.c.o:
  252. X        ${CC} ${CFLAGS} $*.c
  253. X
  254. clean:
  255. X        -rm -f *.o core a.out
  256. X
  257. lint:
  258. X        -lint ${LINTFLAGS} ${SOURCES} >lint.out
  259. X
  260. tags:        ${SOURCES} ${INCLUDES}
  261. X        ctags -t *.[ch]
  262. X
  263. install:    maint
  264. X        install -c -m ${BINMODE} -o ${OWNER} -g ${GROUP} maint ${BINDIR}
  265. X        install -c -m ${MANMODE} -o ${OWNER} -g ${GROUP} maint.1 ${MANDIR}
  266. X        install -c -m ${HELPMODE} -o ${OWNER} -g ${GROUP} maint.hlp ${HELPDIR}
  267. END_OF_FILE
  268. if test 3691 -ne `wc -c <'Makefile.dist'`; then
  269.     echo shar: \"'Makefile.dist'\" unpacked with wrong size!
  270. fi
  271. # end of 'Makefile.dist'
  272. fi
  273. if test -f 'README' -a "${1}" != "-c" ; then 
  274.   echo shar: Will not clobber existing file \"'README'\"
  275. else
  276. echo shar: Extracting \"'README'\" \(6597 characters\)
  277. sed "s/^X//" >'README' <<'END_OF_FILE'
  278. Last update:  01/24/90
  279. X
  280. INTRODUCTION
  281. X   Maint is a full-screen file and directory maintenance program.  It will
  282. allow you to do all sorts of things to files and directories with just a few
  283. keystrokes.  It also makes it easier to scan a bunch of directories and sub-
  284. directories very quickly.  It has a number of different startup options for
  285. formatting the information on the screen and the a whole slew of commands
  286. that may be specified.
  287. X
  288. X   I know the above paragraph seems a little sketchy but after you start using
  289. Maint, I think that you will find that it can be a very useful tool.  We have
  290. been using it for quite a while here and I have gotten a lot of positive feed-
  291. back on it, including many suggestions for improving it.
  292. X
  293. X   I also realize that there are things like Open Window's filemgr and
  294. DECwindows user executive for managing files and directories.  They are
  295. both nice but I personally find maint to be much faster and easier to use
  296. when I'm dealing with *lots* of files and directories.  I'm sure that some
  297. people won't agree with this but hey it's a free country, right? :-)
  298. X
  299. DISTRIBUTION
  300. X   The source code is included so feel free to redistribute it.  I don't
  301. mind as long as the copyright notice (COPYRIGHT) stays with it and you don't
  302. claim you wrote it or try to make money from it.
  303. X
  304. REQUIREMENTS
  305. X   About the only thing that is really needed to build and run maint is a
  306. good version of curses.  System V comes with them by default.  ULTRIX docu-
  307. mentation calls theirs X/Open curses and you have to link with a different
  308. curses library.  I've also heard them called the Terminfo curses.  Basically,
  309. if your curses library has the keypad() routine, you have a pretty good chance
  310. of making maint work.  Maint depends on it and won't build without it.  Systems
  311. that I *know* maint will build and run on are:
  312. X
  313. X    o ULTRIX (3.0 or higher; 2.X doesn't have keypad)
  314. X
  315. X    o SunOS 3.X, 4.X - you must have the System V software installed
  316. X      because needs the some header files and libraries that contain
  317. X      the necessary curses stuff.  You can use gcc to compile as long
  318. X      as you specify the right include directory and link with the
  319. X      necessary SysV libraries.  Check the Makefile for details.
  320. X
  321. X      If you're building on a 3.X system, you need to define -DSUNOS3;
  322. X      it's in the Makefile.
  323. X
  324. X    o System V Release 3
  325. X
  326. X   I would like to say that maint will work on HP/UX, AIX, etc., but I
  327. can't because I don't have access to them.  If you make it work on a system
  328. not listed above, let me know what you had to do and I'll see what I can do
  329. about including your fixes in the next release.
  330. X
  331. X   I'm also pretty anxious to get it ported to Xenix.  If anyone out there
  332. wants to take the time to port it and send me the diffs, I'll be more than
  333. happy to include them.
  334. X
  335. INSTALLATION
  336. X  1.  Copy Makefile.dist to Makefile and copy maint.h.dist to maint.h.
  337. X
  338. X  2.  Look at maint.h and change the #defines for MAX_SCREEN_ROWS and
  339. X      MAX_SCREEN_COLS maximum number of rows/columns for the screens at
  340. X      your site.  The default values are for terminals that are 24x80.  If
  341. X      you use workstations with big windows, adjust them accordingly.  For
  342. X      example, on a Sun 3/60 with a fullscreen window, 60 for MAX_SCREEN_ROWS
  343. X      and 140 for MAX_SCREEN_COLS is nice.  Making them larger than what
  344. X      you need won't cause any problems but might make the executable a
  345. X      little bigger.
  346. X
  347. X      Other things that you might want to change in maint.h:
  348. X
  349. X      - DEFAULT_PAGER - the default is more; make it whatever you want
  350. X      - DEFAULT_EDITOR - default is vi
  351. X      - DEFAULT_SHELL - default is csh
  352. X
  353. X  3.  Look at Makefile and pick what CC, LIBS, and CFLAGS should be used for
  354. X      your site.  Also, set the BINDIR, BINMODE, etc., if you want to use
  355. X      the Makefile to install maint for you.  Make sure to add -DSUNOS3
  356. X      to the CFLAGS definition if you're building on a Sun and you are
  357. X      running SunOS 3.X; this turns on a few typedefs that maint needs.
  358. X
  359. X  4.  Type "make" to build maint.
  360. X
  361. X  5.  Type "make install" if you feel like it.
  362. X
  363. X  6.  That's it.....
  364. X
  365. If you have problems building/installing maint, feel free to call me or send
  366. me some e-mail and let me know how I blew it.  I'll do what I can to make sure
  367. that maint can be installed at your site.
  368. X
  369. HACKING ON THE CODE
  370. X   Since the source is distributed, feel free to hack on the code.  There is
  371. nothing that is real complicated in maint; the code itself is pretty straight-
  372. forward (at least I think so! :^).  You might want to look at the comments at
  373. the top of main.c to get an idea about some of the data structures.
  374. X
  375. X   If you find a bug, you can either 1) fix it yourself, contact me, and
  376. send me the fix, or 2) let me know about it and I'll see what I can do.  I'll
  377. be sending out patches when appropriate.
  378. X
  379. THANKS
  380. X   To Dory Leifer and Mark Knopper @ Merit for letting me borrow a System V
  381. machine for testing and to Dan Bidwell @ Andrews University for doing the
  382. final System V testing.  Also to Steve Simmons at ITI for his suggestions and
  383. code improvements.
  384. X
  385. CONCLUSION
  386. X   I put a lot of work into maint and I would appreciate any comments/
  387. suggestions/flames that you might have.  If you get maint up and running, I
  388. would appreciate it if you would either send me e-mail or phone me, letting
  389. me know that you installed maint and what your thoughts are about it.
  390. X
  391. X   Also, if you port maint to a machine that wasn't listed above and you'd
  392. like the changes encorporated in the next release, send me e-mail describing
  393. what you did.  *DON'T* just send me the diffs.  First describe what you had
  394. to do and THEN send me the diffs.  I get a lot of mail and it is very easy
  395. for me delete the diffs by accident but if I know they're coming, I'll be
  396. especially careful.
  397. X
  398. X   There are a lot of things that I have planned but I haven't implemented
  399. them yet because I felt like maint was suffering from what someone once called
  400. X"creeping featurism."  Thus, if I waited until I had every possible option
  401. and nicety installed it would be quite a while before I could unleash this
  402. on the world.  I feel that in it's current state that it can be quite helpful.
  403. If you have a suggestion feel free to send me e-mail.
  404. X
  405. While I'm sure maint doesn't do everything that everyone could ever want,
  406. I still feel that you will find it useful.  At any rate, I use it quite a
  407. bit, even if no one else does. :-)
  408. X
  409. X--
  410. Leonard J. Peirce               Internet:  peirce@mickey.acs.wmich.edu
  411. Western Michigan University                peirce@gw.wmich.edu
  412. Academic Computing Services
  413. Kalamazoo, MI  49008            Voice:     (616) 387-5469
  414. END_OF_FILE
  415. if test 6597 -ne `wc -c <'README'`; then
  416.     echo shar: \"'README'\" unpacked with wrong size!
  417. fi
  418. # end of 'README'
  419. fi
  420. if test -f 'args.c' -a "${1}" != "-c" ; then 
  421.   echo shar: Will not clobber existing file \"'args.c'\"
  422. else
  423. echo shar: Extracting \"'args.c'\" \(6104 characters\)
  424. sed "s/^X//" >'args.c' <<'END_OF_FILE'
  425. X/******************************************************************************
  426. X*******************************************************************************
  427. X
  428. X   Site:    Western Michigan University Academic Computer Center
  429. X
  430. X   System:    Directory/File System Maintenance
  431. X
  432. X   Program:    maint
  433. X
  434. X   Version=01    Level=00    01/24/92    Leonard J. Peirce
  435. X
  436. X   Purpose:    Routine(s) for parsing run-time arguments.
  437. X
  438. X   Arguments:    See individual routine(s).
  439. X
  440. X   External variables:    See below
  441. X
  442. X   Maint external functions:
  443. X
  444. X    Defined:    get_args
  445. X
  446. X    Called:        None
  447. X
  448. X   Files accessed:    None
  449. X
  450. X   Return codes:    None
  451. X
  452. X   Compiling instructions:    See Makefile
  453. X
  454. X   Linking instructions:    See Makefile
  455. X
  456. X   Other information:    (C) Copyright 1992, Leonard J. Peirce
  457. X
  458. X********************************************************************************
  459. X*******************************************************************************/
  460. X
  461. X/******************************************************************************/
  462. X/*                                                                            */
  463. X/*                        # I N C L U D E   F I L E S                         */
  464. X/*                                                                            */
  465. X/******************************************************************************/
  466. X
  467. X#include <stdio.h>
  468. X#include <string.h>
  469. X#include "maint.h"
  470. X
  471. X/******************************************************************************/
  472. X/*                                                                            */
  473. X/*                             # D E F I N E S                                */
  474. X/*                                                                            */
  475. X/******************************************************************************/
  476. X
  477. X/******************************************************************************/
  478. X/*                                                                            */
  479. X/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S           */
  480. X/*                                                                            */
  481. X/******************************************************************************/
  482. X
  483. X/******************************************************************************/
  484. X/*                                                                            */
  485. X/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S    */
  486. X/*                                                                            */
  487. X/******************************************************************************/
  488. X
  489. extern     char      *optarg;        /* getopt() externals              */
  490. X
  491. extern     int      optind,
  492. X          opterr;
  493. X
  494. X     void      get_args();
  495. X
  496. X/******************************************************************************/
  497. X/*                                                                            */
  498. X/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S      */
  499. X/*                                                                            */
  500. X/******************************************************************************/
  501. X
  502. X/*******************************************************************************
  503. X********************************************************************************
  504. X
  505. X  Function:    get_args
  506. X
  507. X  Purpose:    Process the command-line arguments, setting the flags for
  508. X        what arguments are specified and determining the slot width.
  509. X        Also calculate the entry size memory allocation factor for
  510. X        allocating memory pools.
  511. X
  512. X  Global variables:
  513. X
  514. X    Name            Examine/Modify/Use/Read/Write
  515. X    ----            -----------------------------
  516. X    opt_size           X      X     X
  517. X    optarg               X        X
  518. X
  519. X  Return Codes:
  520. X
  521. X    Code            Reason
  522. X    ----            ------
  523. X    none
  524. X
  525. X********************************************************************************
  526. X*******************************************************************************/
  527. X
  528. void get_args(argc,argv,args)
  529. X                    /*******   FORMAL  PARAMETERS   *******/
  530. X     int      argc;            /* number of run-time arguments          */
  531. X     char      **argv;        /* run-time arguments              */
  532. register ARG_DEF  *args;        /* run-time argument flags          */
  533. X
  534. X{    /*** get_args ***/
  535. X                    /********   LOCAL  VARIABLES   ********/
  536. X     int      c;            /* argument from getopt()          */
  537. X     size_t      opt_size;        /* length of an option string          */
  538. X
  539. X
  540. X   /* start parsing the arguments; when we're done, look at what they
  541. X    * are and set some values accordingly
  542. X    */
  543. X
  544. X   args->sort = FILENAME;        /* assume we want to sort by filename */
  545. X
  546. X   while((c = getopt(argc,argv,"acdfgopstwAFS:")) != EOF)
  547. X   {
  548. X      switch(c)
  549. X      {
  550. X     case('a'):
  551. X
  552. X        args->dot_files = TRUE;
  553. X        break;
  554. X
  555. X     case('A'):
  556. X
  557. X        args->auto_feed = TRUE;
  558. X        break;
  559. X
  560. X     case('c'):
  561. X
  562. X        args->confirm = TRUE;
  563. X        break;
  564. X
  565. X     case('d'):
  566. X
  567. X        args->date = TRUE;
  568. X        break;
  569. X
  570. X     case('f'):
  571. X
  572. X        args->date = TRUE;
  573. X        args->size = TRUE;
  574. X        args->prot = TRUE;
  575. X        args->owner = TRUE;
  576. X        args->group = TRUE;
  577. X        break;
  578. X
  579. X     case('g'):
  580. X
  581. X        args->group = TRUE;
  582. X        break;
  583. X
  584. X     case('o'):
  585. X
  586. X        args->owner = TRUE;
  587. X        break;
  588. X
  589. X     case('p'):
  590. X
  591. X        args->prot = TRUE;
  592. X        break;
  593. X
  594. X     case('s'):
  595. X
  596. X        args->size = TRUE;
  597. X        break;
  598. X
  599. X     case('t'):
  600. X
  601. X        args->text = DISPLAY_TEXT;
  602. X        args->text_startup = TRUE;
  603. X        break;
  604. X
  605. X     case('w'):
  606. X
  607. X        args->wide = TRUE;
  608. X        break;
  609. X
  610. X     case('S'):
  611. X
  612. X        /* see what we should sort by */
  613. X
  614. X        opt_size = strlen(optarg);
  615. X
  616. X        if(opt_size)
  617. X        {
  618. X           /* something specified after the option; see what it is */
  619. X
  620. X           if(strncmp("date",optarg,opt_size) == 0)
  621. X           {
  622. X          args->sort = DATE;
  623. X           }
  624. X           else if(strncmp("size",optarg,opt_size) == 0)
  625. X           {
  626. X          args->sort = SIZE;
  627. X           }
  628. X           else if(strncmp("filename",optarg,opt_size) == 0)
  629. X           {
  630. X          args->sort = FILENAME;
  631. X           }
  632. X           else if(strncmp("none",optarg,opt_size) == 0)
  633. X           {
  634. X          args->sort = 0;
  635. X           }
  636. X           else
  637. X           {
  638. X          fprintf(stderr,"maint -- illegal sort option %s\n",optarg);
  639. X          exit(1);
  640. X           }
  641. X        }
  642. X
  643. X        break;
  644. X
  645. X     case('F'):
  646. X
  647. X        args->filemarks = TRUE;
  648. X        break;
  649. X
  650. X     default:
  651. X
  652. X        exit(1);
  653. X      }
  654. X   }
  655. X
  656. X   return;
  657. X
  658. X}    /*** get_args ***/
  659. END_OF_FILE
  660. if test 6104 -ne `wc -c <'args.c'`; then
  661.     echo shar: \"'args.c'\" unpacked with wrong size!
  662. fi
  663. # end of 'args.c'
  664. fi
  665. if test -f 'edit.c' -a "${1}" != "-c" ; then 
  666.   echo shar: Will not clobber existing file \"'edit.c'\"
  667. else
  668. echo shar: Extracting \"'edit.c'\" \(5188 characters\)
  669. sed "s/^X//" >'edit.c' <<'END_OF_FILE'
  670. X/******************************************************************************
  671. X*******************************************************************************
  672. X
  673. X   Site:    Western Michigan University Academic Computer Center
  674. X
  675. X   System:    Directory/File System Maintenance
  676. X  
  677. X   Program:    maint
  678. X
  679. X   Version=01    Level=00    01/24/92    Leonard J. Peirce
  680. X
  681. X   Purpose:    Call an editor for a file.  The EDITOR variable is first
  682. X        examined; if it's not defined, DEFAULT_EDITOR is used.
  683. X
  684. X   Arguments:    See individual routine(s).
  685. X
  686. X   External variables:    None
  687. X
  688. X   Maint external functions:
  689. X
  690. X    Defined:    edit
  691. X
  692. X    Called:        None
  693. X
  694. X   Files accessed:    File to be edited, passed through parameter list
  695. X
  696. X   Return codes:    See individual routine(s).
  697. X
  698. X   Compiling instructions:    See Makefile
  699. X
  700. X   Linking instructions:    See Makefile
  701. X
  702. X   Other information:    (C) Copyright 1992, Leonard J. Peirce
  703. X
  704. X********************************************************************************
  705. X*******************************************************************************/
  706. X
  707. X/******************************************************************************/
  708. X/*                                                                            */
  709. X/*                        # I N C L U D E   F I L E S                         */
  710. X/*                                                                            */
  711. X/******************************************************************************/
  712. X
  713. X#include <stdio.h>
  714. X#include <string.h>
  715. X#if !defined(SYSV) || defined(sun)
  716. X#include <sys/wait.h>
  717. X#endif
  718. X#include "maint.h"
  719. X
  720. X/******************************************************************************/
  721. X/*                                                                            */
  722. X/*                             # D E F I N E S                                */
  723. X/*                                                                            */
  724. X/******************************************************************************/
  725. X
  726. X/******************************************************************************/
  727. X/*                                                                            */
  728. X/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S           */
  729. X/*                                                                            */
  730. X/******************************************************************************/
  731. X
  732. X/******************************************************************************/
  733. X/*                                                                            */
  734. X/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S    */
  735. X/*                                                                            */
  736. X/******************************************************************************/
  737. X
  738. extern     char      *getenv();
  739. X
  740. extern     int      access(),
  741. X          wait(),
  742. X          fork(),
  743. X          execlp();
  744. X
  745. X     int      edit();
  746. X
  747. X/******************************************************************************/
  748. X/*                                                                            */
  749. X/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S      */
  750. X/*                                                                            */
  751. X/******************************************************************************/
  752. X
  753. X/*******************************************************************************
  754. X********************************************************************************
  755. X
  756. X  Function:    edit
  757. X
  758. X  Purpose:    Call an editor for a file.  If the user has an EDITOR
  759. X        environment variable, use it.  Otherwise, the default is
  760. X        DEFAULT_EDITOR.
  761. X
  762. X  Global variables:
  763. X
  764. X    Name            Examine/Modify/Use/Read/Write
  765. X    ----            -----------------------------
  766. X    none
  767. X
  768. X  Return Codes:
  769. X
  770. X    Code            Reason
  771. X    ----            ------
  772. X    SUCCESS
  773. X    FAILURE
  774. X
  775. X********************************************************************************
  776. X*******************************************************************************/
  777. X
  778. int edit(filename)
  779. X                    /*******   FORMAL  PARAMETERS   *******/
  780. X     char      *filename;        /* name of file to be edited          */
  781. X
  782. X{    /*** edit ***/
  783. X                    /********   LOCAL  VARIABLES   ********/
  784. X     char      *editor,        /* editor to use              */
  785. X          *tptr;        /* pointer to last level of command   */
  786. X     int      child,        /* pid of child process              */
  787. X          i;            /* loop and return value          */
  788. X#if !defined(SYSV) || defined(sun)
  789. union     wait      status;        /* exit status for child process      */
  790. X#else
  791. X     int      status;
  792. X#endif
  793. X
  794. X
  795. X   /* see if the user has an EDITOR */
  796. X
  797. X   editor = getenv("EDITOR");
  798. X
  799. X   if(editor == NULL || *editor == '\0')
  800. X      editor = DEFAULT_EDITOR;        /* user doesn't have an EDITOR          */
  801. X
  802. X   tptr = strrchr(editor,'/');        /* get last level to pass to execlp   */
  803. X
  804. X   if(tptr == NULL)
  805. X      tptr = editor;
  806. X   else
  807. X      tptr++;
  808. X
  809. X   if((child = vfork()) == 0)
  810. X   {
  811. X      /* we're in the child */
  812. X
  813. X      endwin();
  814. X      execlp(editor,tptr,filename,NULL);
  815. X      return(FAILURE);            /* execlp failed if we get here          */
  816. X   }
  817. X   else if(child > 0)
  818. X   {
  819. X      /* we're in the parent; wait for the child to finish */
  820. X
  821. X      while(((i = wait(&status)) != child) && i > 0)
  822. X     ;
  823. X   }
  824. X   else
  825. X      return(FAILURE);
  826. X
  827. X   return(SUCCESS);
  828. X
  829. X}    /*** edit ***/
  830. END_OF_FILE
  831. if test 5188 -ne `wc -c <'edit.c'`; then
  832.     echo shar: \"'edit.c'\" unpacked with wrong size!
  833. fi
  834. # end of 'edit.c'
  835. fi
  836. if test -f 'help.c' -a "${1}" != "-c" ; then 
  837.   echo shar: Will not clobber existing file \"'help.c'\"
  838. else
  839. echo shar: Extracting \"'help.c'\" \(7499 characters\)
  840. sed "s/^X//" >'help.c' <<'END_OF_FILE'
  841. X/******************************************************************************
  842. X*******************************************************************************
  843. X
  844. X   Site:    Western Michigan University Academic Computer Center
  845. X
  846. X   System:    Directory/File System Maintenance
  847. X  
  848. X   Program:    maint
  849. X
  850. X   Version=01    Level=00    01/24/92    Leonard J. Peirce
  851. X
  852. X   Purpose:    On-line help for maint.
  853. X
  854. X   Arguments:    See individual routine(s).
  855. X
  856. X   External variables:    None
  857. X
  858. X   Maint external functions:
  859. X
  860. X    Defined:    give_help
  861. X
  862. X    Called:        info_mess, clear_mess
  863. X
  864. X   Files accessed:    None
  865. X
  866. X   Return codes:    See individual routine(s).
  867. X
  868. X   Compiling instructions:    See Makefile
  869. X
  870. X   Linking instructions:    See Makefile
  871. X
  872. X   Other information:    (C) Copyright 1992, Leonard J. Peirce
  873. X
  874. X********************************************************************************
  875. X*******************************************************************************/
  876. X
  877. X/******************************************************************************/
  878. X/*                                                                            */
  879. X/*                        # I N C L U D E   F I L E S                         */
  880. X/*                                                                            */
  881. X/******************************************************************************/
  882. X
  883. X#ifdef ultrix
  884. X#include <cursesX.h>
  885. X#else
  886. X#include <curses.h>
  887. X#endif
  888. X#include "maint.h"
  889. X
  890. X/******************************************************************************/
  891. X/*                                                                            */
  892. X/*                             # D E F I N E S                                */
  893. X/*                                                                            */
  894. X/******************************************************************************/
  895. X
  896. X/******************************************************************************/
  897. X/*                                                                            */
  898. X/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S           */
  899. X/*                                                                            */
  900. X/******************************************************************************/
  901. X
  902. X/******************************************************************************/
  903. X/*                                                                            */
  904. X/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S    */
  905. X/*                                                                            */
  906. X/******************************************************************************/
  907. X
  908. extern     void      clear_mess();
  909. X
  910. X     void      give_help();
  911. X
  912. X/******************************************************************************/
  913. X/*                                                                            */
  914. X/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S      */
  915. X/*                                                                            */
  916. X/******************************************************************************/
  917. X
  918. X/*******************************************************************************
  919. X********************************************************************************
  920. X
  921. X  Function:    give_help
  922. X
  923. X  Purpose:    Give the user some on-line help for a single key.
  924. X
  925. X  Global variables:
  926. X
  927. X    Name            Examine/Modify/Use/Read/Write
  928. X    ----            -----------------------------
  929. X    none
  930. X
  931. X  Return Codes:
  932. X
  933. X    Code            Reason
  934. X    ----            ------
  935. X    none
  936. X
  937. X********************************************************************************
  938. X*******************************************************************************/
  939. X
  940. void give_help(window)
  941. X                    /*******   FORMAL  PARAMETERS   *******/
  942. X     WINDOW      *window;        /* where to read/write              */
  943. X
  944. X{    /*** give_help ***/
  945. X
  946. X     char      buf[MAXNAMLEN + 100];
  947. X
  948. X   
  949. X   info_mess("Key you want help with [use `?' for detailed help] ? ");
  950. X
  951. X   switch(wgetch(window))
  952. X   {
  953. X      case(CONTROL_I):
  954. X      case(' '):
  955. X      case('>'):
  956. X      case('L'):
  957. X      case('l'):
  958. X      case(KEY_RIGHT):
  959. X
  960. X     info_mess("Right -- Move right one column");
  961. X     break;
  962. X
  963. X      case(BACKSPACE):
  964. X      case('<'):
  965. X      case('H'):
  966. X      case(KEY_BACKSPACE):
  967. X      case('h'):
  968. X      case(KEY_LEFT):
  969. X
  970. X     info_mess("Left -- Move left one column");
  971. X     break;
  972. X
  973. X      case(LINEFEED):
  974. X      case('J'):
  975. X      case('j'):
  976. X      case(KEY_DOWN):
  977. X
  978. X     info_mess("Down -- Move down one row");
  979. X     break;
  980. X
  981. X      case('^'):
  982. X      case('K'):
  983. X      case('k'):
  984. X      case(KEY_UP):
  985. X
  986. X     info_mess("Up -- Move up one row");
  987. X         break;
  988. X
  989. X      case(CARRIAGE_RETURN):
  990. X
  991. X     info_mess("Down and Left -- Move down one row, left of screen");
  992. X     break;
  993. X
  994. X      case('='):
  995. X      case('+'):
  996. X      case(CONTROL_F):
  997. X      case(KEY_NPAGE):
  998. X
  999. X     info_mess("Next Page -- Move forward one page");
  1000. X     break;
  1001. X
  1002. X      case('_'):
  1003. X      case('-'):
  1004. X      case(CONTROL_B):
  1005. X      case(KEY_PPAGE):
  1006. X
  1007. X     info_mess("Previous Page -- Move backward one page");
  1008. X     break;
  1009. X
  1010. X      case('/'):
  1011. X
  1012. X     info_mess("/Search -- Search for filename");
  1013. X     break;
  1014. X      case('U'):
  1015. X      case('u'):
  1016. X
  1017. X     info_mess("Unmark -- Cancel all marks for a file");
  1018. X     break;
  1019. X
  1020. X      case('S'):
  1021. X      case('s'):
  1022. X
  1023. X     info_mess("Select -- Select file (browse) or directory (change \
  1024. directory)");
  1025. X     break;
  1026. X
  1027. X      case('B'):
  1028. X      case('b'):
  1029. X
  1030. X     info_mess("Branch -- Branch to another directory");
  1031. X     break;
  1032. X
  1033. X      case('X'):
  1034. X      case('x'):
  1035. X
  1036. X     info_mess("Xecute -- Perform the commands in the current directory");
  1037. X     break;
  1038. X
  1039. X      case(CONTROL_R):
  1040. X
  1041. X     info_mess("Rebuild -- Rebuild directory information");
  1042. X     break;
  1043. X
  1044. X      case('D'):
  1045. X      case('d'):
  1046. X
  1047. X     info_mess("Delete -- Delete file/directory");
  1048. X     break;
  1049. X
  1050. X      case('P'):
  1051. X      case('p'):
  1052. X
  1053. X     info_mess("Protect -- Set protection (mode) for file");
  1054. X     break;
  1055. X
  1056. X      case('F'):
  1057. X      case('f'):
  1058. X
  1059. X     info_mess("Finish -- Finish directory, returning to previous \
  1060. directory");
  1061. X     break;
  1062. X
  1063. X      case('E'):
  1064. X      case('e'):
  1065. X
  1066. X     info_mess("Edit -- Call editor for file");
  1067. X     break;
  1068. X
  1069. X      case('I'):
  1070. X      case('i'):
  1071. X
  1072. X     info_mess("Info -- Give full information for file");
  1073. X     break;
  1074. X
  1075. X      case('R'):
  1076. X      case('r'):
  1077. X
  1078. X     info_mess("Rename -- Rename file to another file");
  1079. X     break;
  1080. X
  1081. X      case('C'):
  1082. X      case('c'):
  1083. X
  1084. X     info_mess("Copy -- Copy file to another file");
  1085. X     break;
  1086. X
  1087. X      case('T'):
  1088. X      case('t'):
  1089. X
  1090. X     info_mess("Text -- Enter text mode or add/edit text descriptor for \
  1091. file");
  1092. X     break;
  1093. X
  1094. X      case('Q'):
  1095. X      case('q'):
  1096. X
  1097. X     info_mess("Quit -- Leave maint and return to shell");
  1098. X     break;
  1099. X
  1100. X      case('!'):
  1101. X
  1102. X     info_mess("! -- Escape to shell");
  1103. X     break;
  1104. X
  1105. X      case(CONTROL_W):
  1106. X      case(CONTROL_L):
  1107. X
  1108. X     info_mess("Refresh -- Refresh screen");
  1109. X     break;
  1110. X
  1111. X      case(CONTROL_G):
  1112. X
  1113. X     info_mess("^Goto -- Goto specific page in directory");
  1114. X     break;
  1115. X
  1116. X      case('W'):
  1117. X      case('w'):
  1118. X
  1119. X     info_mess("Who -- Display name of author");
  1120. X     break;
  1121. X
  1122. X      case('V'):
  1123. X      case('v'):
  1124. X
  1125. X     info_mess("Version -- Display current version");
  1126. X     break;
  1127. X
  1128. X      case('O'):
  1129. X      case('o'):
  1130. X
  1131. X     info_mess("Owner -- Change owner of file/directory");
  1132. X     break;
  1133. X     
  1134. X      case('G'):
  1135. X      case('g'):
  1136. X
  1137. X     info_mess("Group -- Change group of file/directory");
  1138. X     break;
  1139. X
  1140. X      case('.'):
  1141. X
  1142. X     info_mess("Repeat -- repeat last file command");
  1143. X     break;
  1144. X
  1145. X      case('?'):
  1146. X
  1147. X     if (!file_select(HELPFILE))
  1148. X     {
  1149. X       (void) sprintf(buf,"Error accessing help file `%s'",HELPFILE);
  1150. X       info_mess(buf);
  1151. X     }
  1152. X
  1153. X     /* fall through and clear the message */
  1154. X
  1155. X      case(ESCAPE):
  1156. X      default:
  1157. X
  1158. X     clear_mess(window);
  1159. X     break;
  1160. X   }
  1161. X
  1162. X   return;
  1163. X
  1164. X}    /*** give_help ***/
  1165. END_OF_FILE
  1166. if test 7499 -ne `wc -c <'help.c'`; then
  1167.     echo shar: \"'help.c'\" unpacked with wrong size!
  1168. fi
  1169. # end of 'help.c'
  1170. fi
  1171. if test -f 'locate.c' -a "${1}" != "-c" ; then 
  1172.   echo shar: Will not clobber existing file \"'locate.c'\"
  1173. else
  1174. echo shar: Extracting \"'locate.c'\" \(8424 characters\)
  1175. sed "s/^X//" >'locate.c' <<'END_OF_FILE'
  1176. X/******************************************************************************
  1177. X*******************************************************************************
  1178. X
  1179. X   Site:    Western Michigan University Academic Computer Center
  1180. X
  1181. X   System:    Directory/File System Maintenance
  1182. X  
  1183. X   Program:    maint
  1184. X
  1185. X   Version=01    Level=00    01/24/92    Leonard J. Peirce
  1186. X
  1187. X   Purpose:    Search for a file in the current directory and return its
  1188. X        location.
  1189. X
  1190. X   Arguments:    See individual routines
  1191. X
  1192. X   External variables:    See individual routines
  1193. X
  1194. X   Maint external functions:
  1195. X
  1196. X    Defined:    file_locate, file_ptr_locate
  1197. X
  1198. X    Called:        prompt_getstr
  1199. X
  1200. X   Files accessed:    None
  1201. X
  1202. X   Return codes:    See individual routines
  1203. X
  1204. X   Compiling instructions:    See Makefile
  1205. X
  1206. X   Linking instructions:    See Makefile
  1207. X
  1208. X   Other information:    (C) Copyright 1992, Leonard J. Peirce
  1209. X
  1210. X********************************************************************************
  1211. X*******************************************************************************/
  1212. X
  1213. X/******************************************************************************/
  1214. X/*                                                                            */
  1215. X/*                        # I N C L U D E   F I L E S                         */
  1216. X/*                                                                            */
  1217. X/******************************************************************************/
  1218. X
  1219. X#ifdef ultrix
  1220. X#include <cursesX.h>
  1221. X#else
  1222. X#include <curses.h>
  1223. X#endif
  1224. X#include <ctype.h>
  1225. X#include "maint.h"
  1226. X
  1227. X/******************************************************************************/
  1228. X/*                                                                            */
  1229. X/*                             # D E F I N E S                                */
  1230. X/*                                                                            */
  1231. X/******************************************************************************/
  1232. X
  1233. X/******************************************************************************/
  1234. X/*                                                                            */
  1235. X/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S           */
  1236. X/*                                                                            */
  1237. X/******************************************************************************/
  1238. X
  1239. X/******************************************************************************/
  1240. X/*                                                                            */
  1241. X/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S    */
  1242. X/*                                                                            */
  1243. X/******************************************************************************/
  1244. X
  1245. extern     int      main_rows;
  1246. X
  1247. extern     void      prompt_getstr();
  1248. X
  1249. X     int      file_locate(),
  1250. X          file_search(),
  1251. X          file_ptr_search();
  1252. X
  1253. X/******************************************************************************/
  1254. X/*                                                                            */
  1255. X/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S      */
  1256. X/*                                                                            */
  1257. X/******************************************************************************/
  1258. X
  1259. X/*******************************************************************************
  1260. X********************************************************************************
  1261. X
  1262. X  Function:    file_locate
  1263. X
  1264. X  Purpose:    Get the filename prefix that is desired by the user and
  1265. X        search for it.
  1266. X
  1267. X  Global variables:
  1268. X
  1269. X    Name            Examine/Modify/Use/Read/Write
  1270. X    ----            -----------------------------
  1271. X    main_rows                X
  1272. X
  1273. X  Return Codes:
  1274. X
  1275. X    Code            Reason
  1276. X    ----            ------
  1277. X    file_search()        return code from file_search
  1278. X
  1279. X********************************************************************************
  1280. X*******************************************************************************/
  1281. X
  1282. int file_locate(window,dirptr,num_file)
  1283. X                    /*******   FORMAL  PARAMETERS   *******/
  1284. X     WINDOW      *window;        /* where to read/write              */
  1285. X     ENT_DEF  *dirptr;        /* pointer to directory entry memory  */
  1286. X     short      num_file;        /* number of files in directory          */
  1287. X
  1288. X{    /*** file_locate ***/
  1289. X                    /********   LOCAL  VARIABLES   ********/
  1290. X     char      prefix[SPEC_MAX+1];    /* filename prefix read in          */
  1291. X
  1292. X
  1293. X   /* prompt and ye shall receive....... */
  1294. X
  1295. X   prompt_getstr(window,"Search for: ",prefix,main_rows,SPEC_MAX);
  1296. X
  1297. X   /* now search for the filename prefix in the directory entries */
  1298. X
  1299. X   return(file_search(dirptr,prefix,num_file,strlen(prefix)));
  1300. X
  1301. X}    /*** file_locate ***/
  1302. X
  1303. X/*******************************************************************************
  1304. X********************************************************************************
  1305. X
  1306. X  Function:    file_search
  1307. X
  1308. X  Purpose:    Search for the filename prefix specified
  1309. X
  1310. X  Global variables:
  1311. X
  1312. X    Name            Examine/Modify/Use/Read/Write
  1313. X    ----            -----------------------------
  1314. X    none
  1315. X
  1316. X  Return Codes:
  1317. X
  1318. X    Code            Reason
  1319. X    ----            ------
  1320. X     i            number of file in directory
  1321. X     -1            file prefix not found in directory
  1322. X
  1323. X********************************************************************************
  1324. X*******************************************************************************/
  1325. X                                   
  1326. int file_search(dirptr,prefix,num_file,length)
  1327. X                    /*******   FORMAL  PARAMETERS   *******/
  1328. register ENT_DEF  *dirptr;        /* pointer to directory entries          */
  1329. register char      *prefix;        /* filename prefix to find          */
  1330. register short      num_file;        /* number of files in directory          */
  1331. X     int      length;        /* length of prefix string          */
  1332. X
  1333. X{    /*** file_search ***/
  1334. X                    /********   LOCAL  VARIABLES   ********/
  1335. register short      i = 0;        /* loop index and file entry counter  */
  1336. X     short      done = 0;        /* loop control flag              */
  1337. X
  1338. X
  1339. X   /* search from the beginning for the filename prefix until 1) we find
  1340. X    * what we are looking for or 2) we run out of files; when we exit the
  1341. X    * loop we look at why we exited to see if we found the file or not
  1342. X    */
  1343. X
  1344. X   while((i < num_file) && (!done))
  1345. X   {
  1346. X      if(!strncmp(dirptr->filename,prefix,length))
  1347. X     done++;            /* we found it; stop searching....    */
  1348. X      else
  1349. X      {
  1350. X     ++i;                /* count this file entry          */
  1351. X     ++dirptr;            /* go to next file entry          */
  1352. X      }
  1353. X   }
  1354. X
  1355. X   /* did we find what we were looking for? */
  1356. X
  1357. X   if(i == num_file)            /* did we find the filename prefix?   */
  1358. X      i = -1;                /* nope.....                  */
  1359. X
  1360. X   return((int) i);            /* say whether or not we found it...  */
  1361. X
  1362. X}    /*** file_search ***/
  1363. X
  1364. X/*******************************************************************************
  1365. X********************************************************************************
  1366. X
  1367. X  Function:    file_ptr_search
  1368. X
  1369. X  Purpose:    Search for the filename by comparing pointers to the
  1370. X        memory in the memory pool holding the memory.
  1371. X
  1372. X  Global variables:
  1373. X
  1374. X    Name            Examine/Modify/Use/Read/Write
  1375. X    ----            -----------------------------
  1376. X    none
  1377. X
  1378. X  Return Codes:
  1379. X
  1380. X    Code            Reason
  1381. X    ----            ------
  1382. X     i            number of file in directory
  1383. X     -1            file prefix not found in directory
  1384. X
  1385. X********************************************************************************
  1386. X*******************************************************************************/
  1387. X
  1388. int file_ptr_search(dirptr,filename,num_file)
  1389. X                    /*******   FORMAL  PARAMETERS   *******/
  1390. register ENT_DEF  *dirptr;        /* pointer to directory entries          */
  1391. register char      *filename;        /* pointer to memory holding filename */
  1392. register short      num_file;        /* number of files in directory          */
  1393. X
  1394. X{    /*** file_ptr_search ***/
  1395. X                    /********   LOCAL  VARIABLES   ********/
  1396. register short      i = 0;        /* loop index and file entry counter  */
  1397. X     short      done = 0;        /* loop control flag              */
  1398. X
  1399. X
  1400. X   /* search from the beginning for the filename pointer until 1) we find
  1401. X    * what we are looking for or 2) we run out of files; when we exit the
  1402. X    * loop we look at why we exited to see if we found the file or not
  1403. X    */
  1404. X
  1405. X   while((i < num_file) && (!done))
  1406. X   {
  1407. X      if(dirptr->filename == filename)
  1408. X     done++;            /* we found it; stop searching....    */
  1409. X      else
  1410. X      {
  1411. X     ++i;                /* count this file entry          */
  1412. X     ++dirptr;            /* go to next file entry          */
  1413. X      }
  1414. X   }
  1415. X
  1416. X   /* did we find what we were looking for? */
  1417. X
  1418. X   if(i == num_file)            /* did we find the filename prefix?   */
  1419. X      i = -1;                /* nope.....                  */
  1420. X
  1421. X   return((int) i);            /* say whether or not we found it...  */
  1422. X
  1423. X}    /*** file_ptr_search ***/
  1424. END_OF_FILE
  1425. if test 8424 -ne `wc -c <'locate.c'`; then
  1426.     echo shar: \"'locate.c'\" unpacked with wrong size!
  1427. fi
  1428. # end of 'locate.c'
  1429. fi
  1430. if test -f 'maint.1' -a "${1}" != "-c" ; then 
  1431.   echo shar: Will not clobber existing file \"'maint.1'\"
  1432. else
  1433. echo shar: Extracting \"'maint.1'\" \(10994 characters\)
  1434. sed "s/^X//" >'maint.1' <<'END_OF_FILE'
  1435. X.TH MAINT 1 "1 Jan 1992"
  1436. X.ad
  1437. X.SH "NAME"
  1438. maint - Full-screen file/directory maintenance
  1439. X.SH "SYNOPSIS"
  1440. maint [-acdfgopst] [-S [\fIsort-field\fR]]
  1441. X.SH "DESCRIPTION"
  1442. X.I maint
  1443. is a file/directory maintenance utility that combines the functionality of
  1444. many well-known Unix utilities, adds some new capabilities, and packages
  1445. them into a full-screen interface that gives you the capability of working
  1446. with entire directories at one time instead of working with a few files and
  1447. having to run
  1448. X.IR ls (1)
  1449. to see the current state of the directory.
  1450. X
  1451. Directories are presented as a series of one or more screens, making it possible
  1452. to associate individual commands with each file/directory.  These commands are
  1453. not actually performed until the directory is "executed" and then all of the
  1454. commands in the directory will be performed.  This allows plenty of time to
  1455. change or cancel commands with individual files before a possible catastrophe.
  1456. X
  1457. Other capabilities, such as browsing and editing files, changing directories,
  1458. and associating "text descriptors" with files and directories make it possible
  1459. manage multiple files/directories quickly, easily, and efficiently.
  1460. X.SH "OPTIONS"
  1461. X.IP -a
  1462. Include all files, including those beginning with a period (.).
  1463. X.IP -c
  1464. Ask for confirmation before eXecuting commands in a directory.
  1465. X.IP -d
  1466. Include date field for files.
  1467. X.IP -f
  1468. Include full information for files.  Implies -odgsp.
  1469. X.IP -g
  1470. Include group name for files.
  1471. X.IP -o
  1472. Include owner field for files.
  1473. X.IP -p
  1474. Include protection (mode) field for files.
  1475. X.IP -s
  1476. Include size (in bytes) field for files.
  1477. X.IP -t
  1478. Start up in text mode.  If maint.tdf does not exist in current directory,
  1479. this flag is ignored.
  1480. X.IP -A
  1481. Auto-advance the cursor on Delete or Unmark commands.
  1482. X.IP -F
  1483. Marks directories with trailing slash (/), sockets with a trailing equal sign
  1484. X(=), symbolic links with a trailing at sign (@), and executable files with a
  1485. trailing asterisk (*).
  1486. X.IP \fB-S\fIsort-field\fR 0.3i
  1487. Sort files by sort-field; legal value are: size, date, filename.
  1488. Default is filename.
  1489. X.SH "DISPLAY"
  1490. The screen is divided into three regions.  The first region is the directory
  1491. specification window, along the top of the screen.  This window is two lines
  1492. and contains:
  1493. X.IP o
  1494. The current directory specification.  If the current directory is a descendant
  1495. of your home directory, the home directory portion will not be specified in
  1496. order to save space.  If the current directory is your home directory, the
  1497. full directory specification will be used.
  1498. X.IP o
  1499. The current page and the total number of pages in the directory.
  1500. X.IP o
  1501. The text descriptor for the directory (if you are in Text mode).
  1502. X.PP
  1503. The middle section is the main screen, and will contain information about the
  1504. individual files and directories.  Each file/directory on the screen occupies
  1505. a "slot".  Each file slot can have different characteristics, depending on
  1506. filename length and commands.
  1507. X.IP o
  1508. If for any reason the full filename of a file won't fit in a file slot, it
  1509. will be flagged with an asterisk.
  1510. X.IP o
  1511. If the file has any commands associated with it, it will be displayed in
  1512. bold (or possibly reverse, if your terminal doesn't support bolding).  If
  1513. the file has been marked for deletion, a string signifying such will also
  1514. appear.
  1515. X.PP
  1516. The bottom section is the option line that will display the most commonly-used
  1517. commands with the character used to invoke them displayed in bold (or reverse).
  1518. The number of files and the total number of blocks in the directory are
  1519. also displayed.
  1520. X.SH "FEATURES"
  1521. X.BR "Moving Around."
  1522. X.PP
  1523. There are a number of different ways to move around the screen and change
  1524. the current screen.  The following table describes the keystrokes that can
  1525. be used; be aware that not all keys may be defined on every terminal.  If there
  1526. is a key that looks like it might work, try it. :-)
  1527. X.IP "right (move right one column)"
  1528. l, Right Arrow, Space, Tab, Greater Than >
  1529. X.IP "left (move left one column)"
  1530. h, Left Arrow, Less Than <
  1531. X.IP "up (move up one row)"
  1532. k, Up Arrow, Caret ^
  1533. X.IP "down (move down one row)"
  1534. j, Down Arrow
  1535. X.IP "plus page (go to next screen in directory)"
  1536. X+, =, Next Screen, control-F
  1537. X.IP "minus page (go to previous screen in directory)"
  1538. X-, _, Previous Screen, control-B
  1539. X.IP "go to page (go to a specific screen in directory)"
  1540. control-G; prompt will appear for specific page number.
  1541. X.PP
  1542. X.BR "File Commands."
  1543. X.PP
  1544. XEach file/directory can one or more individual commands associated with it.
  1545. These commands will not be performed until you actually "execute" them with
  1546. the Xecute command (see below).  To add a command to a file/directory,
  1547. position the cursor next to it and press the appropriate key.  You will be
  1548. prompted for any necessary information.
  1549. X
  1550. To see what commands are associated with a file/directory, use the Information
  1551. command.
  1552. X
  1553. The individual commands and appropriate keystrokes are:
  1554. X.IP "Copy file (C or c)"
  1555. Copy file to another file.  Invalid for directories.
  1556. X.IP "Delete file (D, d, Remove)"
  1557. Delete file/directory.
  1558. X.IP "Rename file (R or r)"
  1559. Rename the file to a new filename.
  1560. X.IP "Change group (G or g)"
  1561. Change group of file/directory.  Usually only works for superuser on non-System
  1562. V machines.
  1563. X.IP "Change owner (o)"
  1564. Change owner of file/directory.  Usually only works for superuser on non-System
  1565. V machines.
  1566. X.IP "Change protection (P or p)"
  1567. Change the protection (mode) of a file/directory.  The mode can be specified
  1568. in one of two forms:  1) the way it appears on screen, i.e. rw-r--r--, or 2)
  1569. octal format, i.e. 755.
  1570. X.IP "Repeat previous file command (.)"
  1571. Repeat the last file command specified in the current directory.
  1572. X.IP "Text descriptor (T or t)"
  1573. Add/change a text descriptor for a file/directory.  See below for more
  1574. information about text descriptors.
  1575. X.PP
  1576. X.BR "Other Commands."
  1577. X.PP
  1578. Other commands and non-eXecutable file commands available in
  1579. X.I maint
  1580. are:
  1581. X.IP "Escape to shell (!)"
  1582. Starts up a subshell.  Exiting the subshell will cause a return to
  1583. X.I maint.
  1584. X.IP "Search for a file (/)"
  1585. Search for a filename in the current directory.  A prefix search is done so
  1586. only enough of the filename to identify it is necessary.
  1587. X.IP "Rebuild directory (control-R)"
  1588. Rebuild the current directory, discarding all file commands for the directory.
  1589. This is sometimes necessary in very volatile directories where the information
  1590. in
  1591. X.I maint
  1592. might not be in sync with the current state of the directory.
  1593. X.IP "Edit file (E or e)
  1594. XEdit the current file.  The EDITOR environment variable will be used for
  1595. the editor if it is defined.  The default is vi.
  1596. X.IP "Finish directory (F or f)"
  1597. XExit the current directory and return to previous directory if one exists.  If
  1598. the current directory is the top-level directory, this key is invalid.  If
  1599. any commands exist in the current directory,
  1600. X.I maint
  1601. will ask for confirmation before leaving the directory.
  1602. X.IP "Quit (Q or q)"
  1603. XExit
  1604. X.I maint
  1605. immediately.  If file commands exist in
  1606. X.I any
  1607. directory,
  1608. X.I maint
  1609. will ask for confirmation before quitting.
  1610. X.IP "Information (I or i)"
  1611. Give full information on file/directory including size, mode, access date,
  1612. modification date, creation date, owner, group, text descriptor (if any), and
  1613. any file commands.
  1614. X.IP "Unmark file (U or u)"
  1615. Cancel all marks for the file/directory.
  1616. X.IP "Select file/directory (S, s, Select)"
  1617. If Selecting a file, invoke the a pager on it to allow the file to be browsed.
  1618. The PAGER environment variable is checked first.   If PAGER is not set, the
  1619. default pager for the system is used.  Exiting the pager will cause a return
  1620. to
  1621. X.I maint.
  1622. X
  1623. If Selecting a directory, change to that directory, saving the state of the
  1624. current directory.
  1625. X.IP Repaint screen (control-W)
  1626. Refresh the current screen.
  1627. X.IP Options (O)
  1628. Change the current configuration for maint.  The Configuration Menu will be
  1629. displayed, showing the current configuration values.  Use j and k to select
  1630. a parameter (or use the run-time argument letter (for example, g for Group))
  1631. and press the space bar to turn the parameter on/off.  Enter control-D to
  1632. return to the main display.  The display will be updated to reflect the new
  1633. configuration.
  1634. X.PP
  1635. X.BR "Text Descriptors."
  1636. X.PP
  1637. X.I maint
  1638. has the ability to maintain extended textual descriptors for files
  1639. within a given directory.  What text descriptors do is allow you to associate
  1640. up to a 40-character description with any file in a directory, along
  1641. with having up to a 70-character description of the directory itself.  This
  1642. is particularly useful when maintaining directories with a large number of
  1643. files.  To use the extended file descriptor facility, do the following:
  1644. X.IP 1.
  1645. Run
  1646. X.I maint.
  1647. X.IP 2.
  1648. Type a T (Text) command.
  1649. X.IP 3.
  1650. X.I maint
  1651. will ask
  1652. X.nf
  1653. Text descriptor file maint.tdf does not exist.  Create it [y]?
  1654. X.fi
  1655. X.IP 4.
  1656. Respond with something other than N or n for the file to be created.
  1657. X.IP 5.
  1658. X.I maint
  1659. will then ask
  1660. X.nf
  1661. Text descriptor for directory:
  1662. X.fi
  1663. X.IP 6.
  1664. XEnter a text descriptor (up to 70 characters) for the DIRECTORY.  This will
  1665. serve as a descriptor of the group of files in the DIRECTORY and will appear
  1666. at the top of the screen.
  1667. X.IP 7.
  1668. X.I maint
  1669. will then ask
  1670. X.nf
  1671. Commands will be wiped out.  eXecute them? [y]
  1672. X.fi
  1673. X.IP 8.
  1674. XEnter something other than N or n to have all of the current file commands
  1675. eXecuted when the text descriptor file maint.tdf.
  1676. X.IP 9.
  1677. X.I maint
  1678. will rebuild the directory information and rebuild the screen, including the
  1679. text descriptors for the directory and text descriptor file itself, provided
  1680. they will fit on the screen.  Even if they can't fit on the screen, they are
  1681. still available for each file via the I (Info) command.
  1682. X.PP
  1683. The text descriptor file has now been created.  To add or modify a text
  1684. descriptor for a file, move to a the file and type a T (Text) command.  You
  1685. will be prompted for the text descriptor for the file.  It will be updated
  1686. when you Xecute the commands for the directory.
  1687. X.PP
  1688. On subsequent uses of
  1689. X.I maint,
  1690. text mode may be entered by one of two methods:
  1691. X.IP 1.
  1692. Use the -t on the command line.  This will cause
  1693. X.I maint
  1694. to use text mode if the file maint.tdf exists.
  1695. X.IP 2.
  1696. Use the T (Text) command.  Again, if maint.tdf exists,
  1697. X.I maint
  1698. will enter text mode.
  1699. X.PP
  1700. XEither way, once in text mode, the T (Text) command may be used to add or
  1701. change the text descriptor for a file.
  1702. X.PP
  1703. X.SH "ENVIRONMENT"
  1704. X.nf
  1705. XEDITOR   used for Edit command
  1706. PAGER    pager to use for Select command on a file
  1707. SHELL    shell to invoke for shell escapes
  1708. X.SH "RESTRICTIONS"
  1709. Could experience unpredictable results on terminals with that are less
  1710. than 24 X 80.
  1711. X
  1712. There is no limitation on the number of files in a directory that
  1713. X.I maint
  1714. can handle other than the amount of memory that it can request from the
  1715. operating system.
  1716. X
  1717. As of this writing, the function and arrow keys won't work on Ultrix 3.0. :-(
  1718. X.SH "SEE ALSO "
  1719. X.IR chmod (1),
  1720. X.IR chgrp (1),
  1721. X.IR chown (1),
  1722. X.IR csh (1),
  1723. X.IR more (1),
  1724. X.IR ls (1),
  1725. X.IR mv (1),
  1726. X.IR rm (1),
  1727. X.IR sh (1).
  1728. X.SH AUTHOR
  1729. Leonard J. Peirce @ Western Michigan University Academic Computing Services
  1730. X(peirce@gw.wmich.edu).
  1731. END_OF_FILE
  1732. if test 10994 -ne `wc -c <'maint.1'`; then
  1733.     echo shar: \"'maint.1'\" unpacked with wrong size!
  1734. fi
  1735. # end of 'maint.1'
  1736. fi
  1737. if test -f 'maint.help' -a "${1}" != "-c" ; then 
  1738.   echo shar: Will not clobber existing file \"'maint.help'\"
  1739. else
  1740. echo shar: Extracting \"'maint.help'\" \(4568 characters\)
  1741. sed "s/^X//" >'maint.help' <<'END_OF_FILE'
  1742. Maint is a program for browsing through your files and doing basic
  1743. tasks on them.  It prints a full screen of file data and allows you
  1744. to operate on the 'current' file.  The 'current file' is the file the
  1745. cursor is next to.
  1746. X
  1747. Maint does a number of functions on the files and directories:
  1748. X
  1749. X    o  Move around among your files within a directory.
  1750. X    o  Move from directory to directory.
  1751. X    o  Mark a file for change (copy, delete or rename).
  1752. X    o  Mark a file to changing characteristics.
  1753. X    o  Execute or cancel pending marks.
  1754. X    o  Examine a file (edit, view, list characteristics).
  1755. X    o  Assign descriptive text to a file or directory.
  1756. X    o  Other misc. commands
  1757. X
  1758. XEach of these groups is described individually below.
  1759. X
  1760. Sometimes there is more than one command to do the same thing.  Multiple
  1761. commands are separated by commas.  Upper and lower case are the same.
  1762. X
  1763. Maint has a number of commands selecting the current file from those
  1764. on the screen.  You may simply move around the screen by giving the
  1765. following motion commands.
  1766. X
  1767. X    l,>,space,tab    - move right one column.
  1768. X    h,<        - move left one column.
  1769. X    k,^        - move up one row.
  1770. X    j        - move down one row.
  1771. X
  1772. You may ask for a file by name:
  1773. X    /    - search for a file by name.  Make it the new current
  1774. X          file.
  1775. X
  1776. If you have more files than will fit on the screen, maint breaks them
  1777. up into pages.
  1778. X
  1779. X    +,=    - go to next page of files (if you have more files
  1780. X          than can be printed in a single screenful)
  1781. X    -,_    - go to next page of files (if you have more files
  1782. X          than can be printed in a single screenful)
  1783. X
  1784. Maint offers you a number of ways of moving from directory to directory:
  1785. X
  1786. X    b - BRANCH to a directory.  You will be prompted for the
  1787. X        name of the new directory.
  1788. X    s - SELECT current file to become the new directory.
  1789. X        If the file is not a directory, it is viewed instead.
  1790. X
  1791. The maint commands for changing individual files are:
  1792. X
  1793. X    c - COPY current to another file (same directory only).
  1794. X        You will be prompted for a file to be copied to.
  1795. X    r - mark the current file to be RENAMED.  You will
  1796. X        be prompted for the new name, which must be in the
  1797. X        same directory only.
  1798. X    d - mark the current file for DELETE.
  1799. X
  1800. Maint allow you to change various characteristics of a file:
  1801. X
  1802. X    g - Mark the current file to change the GROUP membership of
  1803. X        the file.  This command can only be used by the system manager.
  1804. X    o - Mark a file to change the OWNER of the file.  This command
  1805. X        can only be used by the system manager.
  1806. X    p - Mark a file to change the PROTECTION of the file.  Currently
  1807. X        you must set the protection either by typing the individual
  1808. X        bits (eg, 755) or by mimicing the permission string
  1809. X        (eg `rw-r--r--', etc.)
  1810. X
  1811. Commands which mark a file are not executed immediately.  The marks
  1812. be marked
  1813. X
  1814. X    x -    EXECUTE all marks immediately.  This causes all
  1815. X        pending deletions, renames, etc, to be done.
  1816. X    u -    UNMARK (cancel) pending marks for the current file.
  1817. X    control-r - REBUILD the current directory.  This
  1818. X        cancels all pending marks.
  1819. X
  1820. Maint will let you get various information and views of a file:
  1821. X
  1822. X    i - give INFORMATION about characteristics of the current
  1823. X        file.  This includes type, size, last usage, etc.
  1824. X    e - EDIT the current file.  The editor used will be
  1825. X        whatever is specified in your EDITOR environment,
  1826. X        or the system default (vi).
  1827. X    s - SELECT current file for viewing (if an ordinary file).
  1828. X        The viewer used will be whatever is specified in your
  1829. X        PAGER environment, or the system default (less).  If
  1830. X        the file is a directory, it is BRANCHED to (see 'b')
  1831. X
  1832. Maint will let you assign descriptive text to a file or directory.
  1833. The 't' command functions as follows:
  1834. X
  1835. If there is no descriptive text in the current directory, you will
  1836. prompted for the creation of a 'Text descriptor file'.  Type [y] if
  1837. you really want to add descriptions.  If you say [y], you will then
  1838. be prompted for a brief description of the directory (up to 70 letters).
  1839. X
  1840. Once there is a text descriptor file, you may then added up to 40
  1841. characters of description for any file in the directory.  Select the
  1842. file with the motion commands, then type 't'.
  1843. X
  1844. Misc maint commands:
  1845. X
  1846. X    ! - go to the system to execute commands, return to
  1847. X        maint when done.
  1848. X    q - QUIT maint.  If there are pending marks, you will
  1849. X        be asked if they should be EXECUTED.
  1850. X    O - Change display options.  A menu will be displayed and
  1851. X        you will allowed to select what information should be
  1852. X        displayed for each file.
  1853. X    ^L/^W (control-L or control-W) - redraw the screen.
  1854. X
  1855. There are more maint commands; try '!man maint' to see them all.
  1856. END_OF_FILE
  1857. if test 4568 -ne `wc -c <'maint.help'`; then
  1858.     echo shar: \"'maint.help'\" unpacked with wrong size!
  1859. fi
  1860. # end of 'maint.help'
  1861. fi
  1862. if test -f 'mem.c' -a "${1}" != "-c" ; then 
  1863.   echo shar: Will not clobber existing file \"'mem.c'\"
  1864. else
  1865. echo shar: Extracting \"'mem.c'\" \(7083 characters\)
  1866. sed "s/^X//" >'mem.c' <<'END_OF_FILE'
  1867. X/******************************************************************************
  1868. X*******************************************************************************
  1869. X
  1870. X   Site:    Western Michigan University Academic Computer Center
  1871. X
  1872. X   System:    Directory/File System Maintenance
  1873. X  
  1874. X   Program:    maint
  1875. X
  1876. X   Version=01    Level=00    01/24/92    Leonard J. Peirce
  1877. X
  1878. X   Purpose:    Memory allocation/initialization routines for command
  1879. X        structures.
  1880. X
  1881. X   Arguments:    See individual routines
  1882. X
  1883. X   External variables:    See individual routines
  1884. X
  1885. X   External functions:
  1886. X
  1887. X          Defined:    free_com, free_comstr, new_comm
  1888. X
  1889. X          Called:    None
  1890. X
  1891. X   Files accessed:    None
  1892. X
  1893. X   Return codes:    See individual routines
  1894. X
  1895. X   Compiling instructions:    See Makefile
  1896. X
  1897. X   Linking instructions:    See Makefile
  1898. X
  1899. X   Other information:    (C) Copyright 1992, Leonard J. Peirce
  1900. X
  1901. X********************************************************************************
  1902. X*******************************************************************************/
  1903. X
  1904. X/******************************************************************************/
  1905. X/*                                                                            */
  1906. X/*                        # I N C L U D E   F I L E S                         */
  1907. X/*                                                                            */
  1908. X/******************************************************************************/
  1909. X
  1910. X#include <malloc.h>
  1911. X#if defined(SYSV) || !defined(sun)
  1912. X#include <stdio.h>
  1913. X#endif
  1914. X#include "maint.h"
  1915. X
  1916. X/******************************************************************************/
  1917. X/*                                                                            */
  1918. X/*                             # D E F I N E S                                */
  1919. X/*                                                                            */
  1920. X/******************************************************************************/
  1921. X
  1922. X/******************************************************************************/
  1923. X/*                                                                            */
  1924. X/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S           */
  1925. X/*                                                                            */
  1926. X/******************************************************************************/
  1927. X
  1928. X/******************************************************************************/
  1929. X/*                                                                            */
  1930. X/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S    */
  1931. X/*                                                                            */
  1932. X/******************************************************************************/
  1933. X
  1934. X#ifndef ultrix
  1935. extern     void      free();
  1936. X#endif
  1937. X
  1938. X     void      free_comm(),
  1939. X          free_comstr();
  1940. X
  1941. X     COM_DEF  *new_comm();
  1942. X
  1943. X/******************************************************************************/
  1944. X/*                                                                            */
  1945. X/*     ST A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S       */
  1946. X/*                                                                            */
  1947. X/******************************************************************************/
  1948. X
  1949. X/*******************************************************************************
  1950. X********************************************************************************
  1951. X
  1952. X  Function:    free_com
  1953. X
  1954. X  Purpose:    Free the memory that was allocated for all of the command
  1955. X        structures for a directory, including all of the memory that
  1956. X        may have been allocated to hold things such as the copy name,
  1957. X        the rename name, and the text descriptor.
  1958. X
  1959. X  Global variables:
  1960. X
  1961. X    Name            Examine/Modify/Use/Read/Write
  1962. X    ----            -----------------------------
  1963. X    none
  1964. X
  1965. X  Return Codes:
  1966. X
  1967. X    Code            Reason
  1968. X    ----            ------
  1969. X    none
  1970. X
  1971. X********************************************************************************
  1972. X*******************************************************************************/
  1973. X
  1974. void free_comm(dirptr,num_file)
  1975. X                    /*******   FORMAL  PARAMETERS   *******/
  1976. register ENT_DEF  *dirptr;        /* pointer to directory entries          */
  1977. register short      num_file;        /* number of files in directory          */
  1978. X
  1979. X{    /*** free_comm ***/
  1980. X
  1981. X
  1982. X   while(num_file-- > 0)        /* delete all command structs          */
  1983. X   {
  1984. X      if(dirptr->command != NULL)     /* command struct for this entry?     */
  1985. X      {
  1986. X     /* free up the command structure and everything associated with it */
  1987. X
  1988. X     free_comstr(dirptr->command);
  1989. X      }
  1990. X
  1991. X      dirptr++;                /* go to next command strucure          */
  1992. X   }
  1993. X
  1994. X   return;
  1995. X
  1996. X}    /*** free_comm ***/
  1997. X
  1998. X/*******************************************************************************
  1999. X********************************************************************************
  2000. X
  2001. X  Function:    free_comstr
  2002. X
  2003. X  Purpose:    Free the memory that belongs to a specific command structure.
  2004. X
  2005. X  Global variables:
  2006. X
  2007. X    Name            Examine/Modify/Use/Read/Write
  2008. X    ----            -----------------------------
  2009. X    none
  2010. X
  2011. X  Return Codes:
  2012. X
  2013. X    Code            Reason
  2014. X    ----            ------
  2015. X    none
  2016. X
  2017. X  Termination Codes:
  2018. X
  2019. X    Code            Reason
  2020. X    ----            ------
  2021. X    status            failure freeing memory
  2022. X
  2023. X********************************************************************************
  2024. X*******************************************************************************/
  2025. void free_comstr(command_str)
  2026. X                           /*******   FORMAL  PARAMETERS   *******/
  2027. register COM_DEF  *command_str;        /* pointer to structure to be freed   */
  2028. X
  2029. X{    /*** free_comstr ***/
  2030. X
  2031. X   if(command_str->copy_name != NULL)
  2032. X   {
  2033. X      /* free up the memory for the copy name */
  2034. X
  2035. X      free(command_str->copy_name);
  2036. X   }
  2037. X
  2038. X   if(command_str->ren_name != NULL)
  2039. X   {
  2040. X      /* free up the memory for the rename name */
  2041. X
  2042. X      free(command_str->ren_name);
  2043. X   }
  2044. X
  2045. X   if(command_str->text != NULL)
  2046. X   {
  2047. X      /* free up the memory for the copy name */
  2048. X
  2049. X      free(command_str->text);
  2050. X   }
  2051. X
  2052. X   /* now free up the command structure itself */
  2053. X
  2054. X   free((char *) command_str);
  2055. X
  2056. X   return;
  2057. X
  2058. X}    /*** free_comstr ***/
  2059. X
  2060. X/*******************************************************************************
  2061. X********************************************************************************
  2062. X
  2063. X  Function:    new_comm
  2064. X
  2065. X  Purpose:    Allocate memory for a new command structure and return a
  2066. X        pointer to the memory.
  2067. X
  2068. X  Global variables:
  2069. X
  2070. X    Name            Examine/Modify/Use/Read/Write
  2071. X    ----            -----------------------------
  2072. X    none
  2073. X
  2074. X  Return Codes:
  2075. X
  2076. X    Code            Reason
  2077. X    ----            ------
  2078. X    ptr            pointer to allocated memory
  2079. X    NULL            problems allocating memory
  2080. X
  2081. X********************************************************************************
  2082. X*******************************************************************************/
  2083. X
  2084. COM_DEF *new_comm()
  2085. X
  2086. X{    /*** new_comm ***/
  2087. X                    /*******   FORMAL  PARAMETERS   *******/
  2088. register COM_DEF  *ptr;            /* pointer to allocated memory          */
  2089. X
  2090. X
  2091. X   ptr = (COM_DEF *) malloc((u_int) sizeof(COM_DEF));
  2092. X
  2093. X   if(ptr == NULL)
  2094. X      return(NULL);
  2095. X
  2096. X   memset(ptr,0,sizeof(COM_DEF));    /* initialize it              */
  2097. X   ptr->copy_name = NULL;
  2098. X   ptr->text = NULL;
  2099. X   ptr->ren_name = NULL;
  2100. X
  2101. X   return(ptr);                /* return pointer to the structure    */
  2102. X
  2103. X}    /*** new_comm ***/
  2104. END_OF_FILE
  2105. if test 7083 -ne `wc -c <'mem.c'`; then
  2106.     echo shar: \"'mem.c'\" unpacked with wrong size!
  2107. fi
  2108. # end of 'mem.c'
  2109. fi
  2110. if test -f 'select.c' -a "${1}" != "-c" ; then 
  2111.   echo shar: Will not clobber existing file \"'select.c'\"
  2112. else
  2113. echo shar: Extracting \"'select.c'\" \(5472 characters\)
  2114. sed "s/^X//" >'select.c' <<'END_OF_FILE'
  2115. X/******************************************************************************
  2116. X*******************************************************************************
  2117. X
  2118. X   Site:    Western Michigan University Academic Computer Center
  2119. X
  2120. X   System:    Directory/File System Maintenance
  2121. X  
  2122. X   Program:    maint
  2123. X
  2124. X   Version=01    Level=00    01/24/92    Leonard J. Peirce
  2125. X
  2126. X   Purpose:    Allow a user to browse a file using a "pager" of some sort.
  2127. X        If the user has a PAGER environment variable, use it.  The
  2128. X        default is DEFAULT_PAGER
  2129. X
  2130. X   Arguments:    See individual routine(s)
  2131. X
  2132. X   External variables:    See individual routine(s)
  2133. X
  2134. X   Maint external functions:
  2135. X
  2136. X          Defined:    file_select
  2137. X
  2138. X          Called:    none
  2139. X
  2140. X   Files accessed:    filename    file to be browsed
  2141. X
  2142. X   Return codes:    See individual routine(s)
  2143. X
  2144. X   Compiling instructions:    See Makefile
  2145. X
  2146. X   Linking instructions:    See Makefile
  2147. X
  2148. X   Other information:    (C) Copyright 1992, Leonard J. Peirce
  2149. X
  2150. X********************************************************************************
  2151. X*******************************************************************************/
  2152. X
  2153. X/******************************************************************************/
  2154. X/*                                                                            */
  2155. X/*                        # I N C L U D E   F I L E S                         */
  2156. X/*                                                                            */
  2157. X/******************************************************************************/
  2158. X
  2159. X#include "maint.h"
  2160. X#include <stdio.h>
  2161. X#ifdef ultrix
  2162. X#include <cursesX.h>
  2163. X#include <unistd.h>            /* recommended for access(2)          */
  2164. X#else
  2165. X#include <curses.h>
  2166. X#include <sys/file.h>
  2167. X#endif
  2168. X#include <string.h>
  2169. X#if !defined(SYSV) || defined(sun)
  2170. X#include <sys/wait.h>
  2171. X#endif
  2172. X#include <sys/stat.h>
  2173. X
  2174. X/******************************************************************************/
  2175. X/*                                                                            */
  2176. X/*                             # D E F I N E S                                */
  2177. X/*                                                                            */
  2178. X/******************************************************************************/
  2179. X
  2180. X/******************************************************************************/
  2181. X/*                                                                            */
  2182. X/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S           */
  2183. X/*                                                                            */
  2184. X/******************************************************************************/
  2185. X
  2186. X/******************************************************************************/
  2187. X/*                                                                            */
  2188. X/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S    */
  2189. X/*                                                                            */
  2190. X/******************************************************************************/
  2191. X
  2192. extern     char      *getenv();
  2193. X
  2194. extern     int      access(),
  2195. X          wait(),
  2196. X          fork(),
  2197. X          execlp();
  2198. X
  2199. X     int      file_select();
  2200. X
  2201. X/******************************************************************************/
  2202. X/*                                                                            */
  2203. X/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S      */
  2204. X/*                                                                            */
  2205. X/******************************************************************************/
  2206. X
  2207. X/*******************************************************************************
  2208. X********************************************************************************
  2209. X
  2210. X  Function:    file_select
  2211. X
  2212. X  Purpose:    Process a file that has been selected.  If the user has a
  2213. X        PAGER environment variable, use the pager specified.  The
  2214. X        default pager is DEFAULT_PAGER.
  2215. X
  2216. X  Global variables:
  2217. X
  2218. X    Name            Examine/Modify/Use/Read/Write
  2219. X    ----            -----------------------------
  2220. X    none
  2221. X
  2222. X  Return Codes:
  2223. X
  2224. X    Code            Reason
  2225. X    ----            ------
  2226. X    SUCCESS
  2227. X    FAILURE
  2228. X
  2229. X********************************************************************************
  2230. X*******************************************************************************/
  2231. X
  2232. int file_select(filename)
  2233. X                    /*******   FORMAL  PARAMETERS   *******/
  2234. X     char      *filename;        /* name of file to be accessed          */
  2235. X
  2236. X{    /*** file_select ***/
  2237. X                    /********   LOCAL  VARIABLES   ********/
  2238. X     char      *pager,        /* pager for looking at a file          */
  2239. X          *tptr;        /* pointer to last level of command   */
  2240. X     int      child,        /* pid of child process              */
  2241. X          i;            /* loop and return value          */
  2242. X#if !defined(SYSV) || defined(sun)
  2243. union     wait      status;        /* exit status for child process      */
  2244. X#else
  2245. X     int      status;
  2246. X#endif
  2247. X
  2248. X   /* see if the user has a PAGER */
  2249. X
  2250. X   pager = getenv("PAGER");
  2251. X
  2252. X   if(pager == NULL || *pager == '\0')
  2253. X      pager = DEFAULT_PAGER;        /* user doesn't have a PAGER          */
  2254. X
  2255. X   tptr = strrchr(pager,'/');        /* get last level to pass to execlp   */
  2256. X
  2257. X   if(tptr == NULL)
  2258. X      tptr = pager;
  2259. X   else
  2260. X      tptr++;
  2261. X
  2262. X   if((child = vfork()) == 0)
  2263. X   {
  2264. X      /* we're in the child */
  2265. X
  2266. X      endwin();
  2267. X      execlp(pager,tptr,filename,NULL);
  2268. X      return(FAILURE);            /* execlp failed if we get here          */
  2269. X   }
  2270. X   else if(child > 0)
  2271. X   {
  2272. X      /* we're in the parent; wait for the child to finish */
  2273. X
  2274. X      while(((i = wait(&status)) != child) && i > 0)
  2275. X     ;
  2276. X   }
  2277. X   else
  2278. X      return(FAILURE);
  2279. X
  2280. X   return(SUCCESS);
  2281. X
  2282. X}    /*** file_select ***/
  2283. END_OF_FILE
  2284. if test 5472 -ne `wc -c <'select.c'`; then
  2285.     echo shar: \"'select.c'\" unpacked with wrong size!
  2286. fi
  2287. # end of 'select.c'
  2288. fi
  2289. if test -f 'sort.c' -a "${1}" != "-c" ; then 
  2290.   echo shar: Will not clobber existing file \"'sort.c'\"
  2291. else
  2292. echo shar: Extracting \"'sort.c'\" \(10451 characters\)
  2293. sed "s/^X//" >'sort.c' <<'END_OF_FILE'
  2294. X/******************************************************************************
  2295. X*******************************************************************************
  2296. X
  2297. X   Site:    Western Michigan University Academic Computer Center
  2298. X
  2299. X   System:    Directory/File System Maintenance
  2300. X  
  2301. X   Program:    maint
  2302. X
  2303. X   Version=01    Level=00    01/24/92    Leonard J. Peirce
  2304. X
  2305. X   Purpose:    Sort routines for the different sort options.
  2306. X
  2307. X   Arguments:    See individual routines.
  2308. X
  2309. X   External variables:    None
  2310. X
  2311. X   External functions:
  2312. X
  2313. X          Defined:    date_qsort, name_qsort, size_qsort, sort_files
  2314. X
  2315. X          Called:    None
  2316. X
  2317. X   Files accessed:    See individual routines.
  2318. X
  2319. X   Return codes:    See individual routines.
  2320. X
  2321. X   Compiling instructions:    See Makefile
  2322. X
  2323. X   Linking instructions:    See Makefile
  2324. X
  2325. X   Other information:    (C) Copyright 1992, Leonard J. Peirce
  2326. X
  2327. X********************************************************************************
  2328. X*******************************************************************************/
  2329. X
  2330. X/******************************************************************************/
  2331. X/*                                                                            */
  2332. X/*                        # I N C L U D E   F I L E S                         */
  2333. X/*                                                                            */
  2334. X/******************************************************************************/
  2335. X
  2336. X#include <string.h>
  2337. X#include "maint.h"
  2338. X
  2339. X/******************************************************************************/
  2340. X/*                                                                            */
  2341. X/*                             # D E F I N E S                                */
  2342. X/*                                                                            */
  2343. X/******************************************************************************/
  2344. X
  2345. X/******************************************************************************/
  2346. X/*                                                                            */
  2347. X/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S           */
  2348. X/*                                                                            */
  2349. X/******************************************************************************/
  2350. X
  2351. X/******************************************************************************/
  2352. X/*                                                                            */
  2353. X/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S    */
  2354. X/*                                                                            */
  2355. X/******************************************************************************/
  2356. X
  2357. extern     ENT_DEF  *baseptr;
  2358. X
  2359. X     void      date_qsort(),
  2360. X          size_qsort(),
  2361. X          name_qsort(),
  2362. X          sort_files();
  2363. X
  2364. X/******************************************************************************/
  2365. X/*                                                                            */
  2366. X/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S      */
  2367. X/*                                                                            */
  2368. X/******************************************************************************/
  2369. X
  2370. static     void      swap_entries();
  2371. X
  2372. X/*******************************************************************************
  2373. X********************************************************************************
  2374. X
  2375. X  Function:    size_qsort
  2376. X
  2377. X  Purpose:    Sort the directory entries by size.
  2378. X
  2379. X        Algorithm for quicksort from "Fundamentals of Data Structures",
  2380. X        Ellis Horowitz and Sartaj Sahni, page 137.
  2381. X
  2382. X  Global variables:
  2383. X
  2384. X    Name            Examine/Modify/Use/Read/Write
  2385. X    ----            -----------------------------
  2386. X    baseptr                    X
  2387. X
  2388. X  Return Codes:
  2389. X
  2390. X    Code            Reason
  2391. X    ----            ------
  2392. X    none
  2393. X
  2394. X********************************************************************************
  2395. X*******************************************************************************/
  2396. X
  2397. void size_qsort(m,n)
  2398. X                    /*******   FORMAL  PARAMETERS   *******/
  2399. register short      m,            /* lower-bound of sub-array to be     */
  2400. X                    /* sorted                  */
  2401. X          n;            /* upper-bound of sub-array to be     */
  2402. X                    /* sorted                  */
  2403. X
  2404. X{    /*** size_qsort ***/
  2405. X                    /********   LOCAL  VARIABLES   ********/
  2406. register short      i,            /* loop and array index              */
  2407. X          j;            /*  "    "    "     "              */
  2408. static     u_long      key;            /* key size entry for sorting          */
  2409. X
  2410. X
  2411. X   if(m < n)
  2412. X   {
  2413. X      i = m;
  2414. X      j = n + 1;
  2415. X      key = baseptr[m].size;
  2416. X
  2417. X      for(;;)
  2418. X      {
  2419. X     do
  2420. X     {
  2421. X        ++i;
  2422. X     }
  2423. X     while(baseptr[i].size < key);
  2424. X
  2425. X     do
  2426. X     {
  2427. X        --j;
  2428. X     }
  2429. X     while(baseptr[j].size > key);
  2430. X
  2431. X     if(i < j)
  2432. X     {
  2433. X        /* swap the file entries */
  2434. X
  2435. X        swap_entries(&baseptr[i],&baseptr[j]);
  2436. X     }
  2437. X     else
  2438. X        break;
  2439. X
  2440. X      } /* for(;;) */
  2441. X
  2442. X      swap_entries(&baseptr[m],&baseptr[j]);
  2443. X      size_qsort(m,j-1);
  2444. X      size_qsort(j+1,n);
  2445. X
  2446. X   } /* if(m < n) */
  2447. X
  2448. X   return;
  2449. X
  2450. X}    /*** size_qsort ***/
  2451. X
  2452. X/*******************************************************************************
  2453. X********************************************************************************
  2454. X
  2455. X  Function:    date_qsort
  2456. X
  2457. X  Purpose:    Sort the directory entries by last access date.
  2458. X
  2459. X        Algorithm for quicksort from "Fundamentals of Data Structures",
  2460. X        Ellis Horowitz and Sartaj Sahni, page 137.
  2461. X
  2462. X  Global variables:
  2463. X
  2464. X    Name            Examine/Modify/Use/Read/Write
  2465. X    ----            -----------------------------
  2466. X    baseptr                    X
  2467. X
  2468. X  Return Codes:
  2469. X
  2470. X    Code            Reason
  2471. X    ----            ------
  2472. X    none
  2473. X
  2474. X********************************************************************************
  2475. X*******************************************************************************/
  2476. X
  2477. void date_qsort(m,n)
  2478. X                    /*******   FORMAL  PARAMETERS   *******/
  2479. register short      m,            /* lower-bound of sub-array to be     */
  2480. X                    /* sorted                  */
  2481. X          n;            /* upper-bound of sub-array to be     */
  2482. X                    /* sorted                  */
  2483. X
  2484. X{    /*** date_qsort ***/
  2485. X                    /********   LOCAL  VARIABLES   ********/
  2486. register short      i,            /* loop and array index              */
  2487. X          j;            /*  "    "    "     "              */
  2488. static     time_t      key;            /* key size entry for sorting          */
  2489. X
  2490. X
  2491. X   if(m < n)
  2492. X   {
  2493. X      i = m;
  2494. X      j = n + 1;
  2495. X      key = baseptr[m].time;
  2496. X
  2497. X      for(;;)
  2498. X      {
  2499. X     do
  2500. X     {
  2501. X        ++i;
  2502. X     }
  2503. X     while(baseptr[i].time < key);
  2504. X
  2505. X     do
  2506. X     {
  2507. X        --j;
  2508. X     }
  2509. X     while(baseptr[j].time > key);
  2510. X
  2511. X     if(i < j)
  2512. X     {
  2513. X        /* swap the file entries */
  2514. X
  2515. X        swap_entries(&baseptr[i],&baseptr[j]);
  2516. X     }
  2517. X     else
  2518. X        break;
  2519. X
  2520. X      } /* for(;;) */
  2521. X
  2522. X      swap_entries(&baseptr[m],&baseptr[j]);
  2523. X      date_qsort(m,j-1);
  2524. X      date_qsort(j+1,n);
  2525. X
  2526. X   } /* if(m < n) */
  2527. X
  2528. X   return;
  2529. X
  2530. X}    /*** date_qsort ***/
  2531. X
  2532. X/*******************************************************************************
  2533. X********************************************************************************
  2534. X
  2535. X  Function:    swap_entries
  2536. X
  2537. X  Purpose:    Swap two file entries.
  2538. X
  2539. X  Global variables:
  2540. X
  2541. X    Name            Examine/Modify/Use/Read/Write
  2542. X    ----            -----------------------------
  2543. X    none
  2544. X
  2545. X  Return Codes:
  2546. X
  2547. X    Code            Reason
  2548. X    ----            ------
  2549. X    none
  2550. X
  2551. X********************************************************************************
  2552. X*******************************************************************************/
  2553. X
  2554. static void swap_entries(a,b)
  2555. X                    /*******   FORMAL  PARAMETERS   *******/
  2556. X     ENT_DEF  *a,            /* first to be swapped               */
  2557. X          *b;            /* other entry to be swapped          */
  2558. X
  2559. X{    /*** swap_entries ***/
  2560. X                    /********   LOCAL  VARIABLES   ********/
  2561. static     ENT_DEF  temp;            /* temporary entry for swapping          */
  2562. X
  2563. X   memcpy((char *) &temp,(char *) a, sizeof(temp));
  2564. X   memcpy((char *) a,(char *) b, sizeof(temp));
  2565. X   memcpy((char *) b,(char *) &temp, sizeof(temp));
  2566. X
  2567. X}    /*** swap_entries ***/
  2568. X
  2569. X/*******************************************************************************
  2570. X********************************************************************************
  2571. X
  2572. X  Function:    name_qsort
  2573. X
  2574. X  Purpose:    Sort the directory entries by filename.
  2575. X
  2576. X        Algorithm for quicksort from "Fundamentals of Data Structures",
  2577. X        Ellis Horowitz and Sartaj Sahni, page 137.
  2578. X
  2579. X  Global variables:
  2580. X
  2581. X    Name            Examine/Modify/Use/Read/Write
  2582. X    ----            -----------------------------
  2583. X    baseptr                    X
  2584. X
  2585. X  Return Codes:
  2586. X
  2587. X    Code            Reason
  2588. X    ----            ------
  2589. X    none
  2590. X
  2591. X********************************************************************************
  2592. X*******************************************************************************/
  2593. X
  2594. void name_qsort(m,n)
  2595. X                    /*******   FORMAL  PARAMETERS   *******/
  2596. register short      m,            /* lower-bound of sub-array to be     */
  2597. X                    /* sorted                  */
  2598. X          n;            /* upper-bound of sub-array to be     */
  2599. X                    /* sorted                  */
  2600. X
  2601. X{    /*** name_qsort ***/
  2602. X                    /********   LOCAL  VARIABLES   ********/
  2603. register short      i,            /* loop and array index              */
  2604. X          j;            /*  "    "    "     "              */
  2605. static     char      *key;            /* pointer to key value              */
  2606. X
  2607. X
  2608. X   if(m < n)
  2609. X   {
  2610. X      i = m;
  2611. X      j = n + 1;
  2612. X      key = (baseptr+m)->filename;    /* get pointer to filename key          */
  2613. X
  2614. X      for(;;)
  2615. X      {
  2616. X     do
  2617. X     {
  2618. X        ++i;
  2619. X     }
  2620. X     while(strcmp((baseptr+i)->filename,key) < 0);
  2621. X
  2622. X     do
  2623. X     {
  2624. X        --j;
  2625. X     }
  2626. X     while(strcmp((baseptr+j)->filename,key) > 0);
  2627. X
  2628. X     if(i < j)
  2629. X     {
  2630. X        /* swap the pointers to the filenames and the flags that indicate
  2631. X         * whether or not the filename is too long for all of it to be
  2632. X         * displayed on the screen
  2633. X         */
  2634. X
  2635. X        swap_entries(&baseptr[i],&baseptr[j]);
  2636. X     }
  2637. X     else
  2638. X        break;
  2639. X
  2640. X      } /* for(;;) */
  2641. X
  2642. X      swap_entries(&baseptr[m],&baseptr[j]);
  2643. X      name_qsort(m,j-1);
  2644. X      name_qsort(j+1,n);
  2645. X
  2646. X   } /* if(m < n) */
  2647. X
  2648. X   return;
  2649. X
  2650. X}    /*** name_qsort ***/
  2651. X
  2652. X/*******************************************************************************
  2653. X********************************************************************************
  2654. X
  2655. X  Function:    sort_files
  2656. X
  2657. X  Purpose:    Sort the directory based on the sort type.
  2658. X
  2659. X  Global variables:
  2660. X
  2661. X    Name            Examine/Modify/Use/Read/Write
  2662. X    ----            -----------------------------
  2663. X    baseptr                    X
  2664. X
  2665. X  Return Codes:
  2666. X
  2667. X    Code            Reason
  2668. X    ----            ------
  2669. X    none
  2670. X
  2671. X********************************************************************************
  2672. X*******************************************************************************/
  2673. X
  2674. void sort_files(num_file,sort_type)
  2675. X                    /*******   FORMAL  PARAMETERS   *******/
  2676. X    short      num_file,        /* number of files in directory          */
  2677. X          sort_type;        /* field to sort on              */
  2678. X
  2679. X{    /*** sort_files ***/
  2680. X
  2681. X
  2682. X   switch(sort_type)
  2683. X   {
  2684. X      case(FILENAME):
  2685. X     name_qsort(0,num_file);
  2686. X     break;
  2687. X
  2688. X      case(DATE):
  2689. X     date_qsort(0,num_file);
  2690. X     break;
  2691. X
  2692. X      case(SIZE):
  2693. X     size_qsort(0,num_file);
  2694. X     break;
  2695. X
  2696. X      default:
  2697. X     break;
  2698. X   }
  2699. X
  2700. X   return;
  2701. X
  2702. X}    /*** sort_files ***/
  2703. END_OF_FILE
  2704. if test 10451 -ne `wc -c <'sort.c'`; then
  2705.     echo shar: \"'sort.c'\" unpacked with wrong size!
  2706. fi
  2707. # end of 'sort.c'
  2708. fi
  2709. echo shar: End of archive 1 \(of 7\).
  2710. cp /dev/null ark1isdone
  2711. MISSING=""
  2712. for I in 1 2 3 4 5 6 7 ; do
  2713.     if test ! -f ark${I}isdone ; then
  2714.     MISSING="${MISSING} ${I}"
  2715.     fi
  2716. done
  2717. if test "${MISSING}" = "" ; then
  2718.     echo You have unpacked all 7 archives.
  2719.     rm -f ark[1-9]isdone
  2720. else
  2721.     echo You still need to unpack the following archives:
  2722.     echo "        " ${MISSING}
  2723. fi
  2724. ##  End of shell archive.
  2725. exit 0
  2726.