home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / cwish / part05 < prev    next >
Encoding:
Text File  |  1993-11-01  |  35.3 KB  |  1,035 lines

  1. Newsgroups: comp.sources.misc
  2. From: hm@hcshh.hcs.de (Hellmuth Michaelis)
  3. Subject: v40i072:  cwish - Window Shell / Filemanager v2.00, Part05/05
  4. Message-ID: <1993Nov1.220812.9651@sparky.sterling.com>
  5. X-Md4-Signature: dcf0e3012b99fd2c103b4da69dea30ea
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Mon, 1 Nov 1993 22:08:12 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: hm@hcshh.hcs.de (Hellmuth Michaelis)
  12. Posting-number: Volume 40, Issue 72
  13. Archive-name: cwish/part05
  14. Environment: UNIX, ANSI-C, SYSV-CURSES
  15. Supersedes: cwish: Volume 39, Issue 97-100
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  MANIFEST ChangeLog complete.c config.h control.h fkeys.c
  22. #   patchlevel.h rcinit.h usage.c usrgrp.c
  23. # Wrapped by kent@sparky on Fri Oct 29 14:39:11 1993
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 5 (of 5)."'
  27. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  29. else
  30.   echo shar: Extracting \"'MANIFEST'\" \(1407 characters\)
  31.   sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  32. XFile Name            Description
  33. X-----------------------------------------------------------
  34. XCOPYING                GNU GENERAL PUBLIC LICENSE
  35. XChangeLog            Description of changes
  36. XMANIFEST            This shipping list
  37. XMakefile.386bsd            Makefile for 386BSD, NetBSD etc.
  38. XMakefile.aix            Makefile for RS/6000 AIX 3.2.4
  39. XMakefile.hpux            Makefile for HP-UX 8.0/9.0
  40. XMakefile.linux            Makefile for Linux (0.99.pl9-1)
  41. XMakefile.sunos            Makefile for SunOS 4.1.3
  42. XMakefile.ultrix            Makefile for Ultrix
  43. XREADME                Intro
  44. Xchdir.c                cd wildcard functions
  45. Xcommandline.c            commandline window handling
  46. Xcomplete.c            primitive filename completition
  47. Xconfig.c            runtime configuration menu
  48. Xconfig.h            header file for config.c
  49. Xcontrol.h            control character defines
  50. Xcursor.c            highlighting functions
  51. Xdot-cwishrc            sample .cwishrc file
  52. Xfiles.c                the directory scanner
  53. Xfkeys.c                function key label handling
  54. Xheader.c            header & attribute window misc
  55. Xhelp.c                help screen
  56. Xhistory.c            commandline history functions
  57. Xmovement.c            current file movement functions
  58. Xpaging.c            current directory linked list formatting
  59. Xpatchlevel.h            the current patchlevel
  60. Xrcinit.c            initialization file processing
  61. Xrcinit.h            defines for rcinit.c
  62. Xshowtime.c            signal handling for time display
  63. Xusage.c                usage and copyright information
  64. Xusrgrp.c            user and group name extraction & cacheing
  65. Xcwish.1                the manual page
  66. Xcwish.c                program startup and main loop
  67. Xcwish.h                the global header file
  68. X
  69. END_OF_FILE
  70.   if test 1407 -ne `wc -c <'MANIFEST'`; then
  71.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  72.   fi
  73.   # end of 'MANIFEST'
  74. fi
  75. if test -f 'ChangeLog' -a "${1}" != "-c" ; then 
  76.   echo shar: Will not clobber existing file \"'ChangeLog'\"
  77. else
  78.   echo shar: Extracting \"'ChangeLog'\" \(1289 characters\)
  79.   sed "s/^X//" >'ChangeLog' <<'END_OF_FILE'
  80. X
  81. XPATCHLEVEL 2.00
  82. X-------------------------------------------------------------------------------
  83. X
  84. X    - headerline terminal name field adjusted
  85. X    - makefile for Linux
  86. X    - added counter to keep track of the size of all tagged files
  87. X      (suggested by Jim Graham, jim@n5ial.mythical.com)
  88. X    - inode display in alternate attribute line
  89. X    - Makefile for AIX
  90. X    - soft/hard links confusion cleanup
  91. X    - alternate status line switchable by F7 / status line cleanup
  92. X    - rename wish to cwish, cleanup of all text and man page
  93. X    - intro of DATE_US and REREAD_AFTER_EDIT flag in Makefiles
  94. X    - malloced filename string in struct onefile to save runtime space
  95. X    - added variable opt_tagmove to select wether to move to the next
  96. X      file after tagging the current one or to stay on the current.
  97. X      (suggested by Jim Graham, jim@n5ial.mythical.com)
  98. X    - added conditional defines for S_ISLNK and S_ISSOCK in files.c
  99. X      (report by Thanh Ma, tma@encore.com)
  100. X    - SunOS 4.1.3 patch from Thomas E. Dickey, dickey@software.org
  101. X    - patch for hp-ux 8.0 from: Jean-Yves Kerjan, jyk@ratp.noisy.ratp.fr
  102. X    - ultrix patches from Gertjan van Oosten, gvoosten@isosa1.estec.esa.nl
  103. X
  104. X
  105. XPATCHLEVEL 1.00
  106. X-------------------------------------------------------------------------------
  107. X
  108. X    - first public release to comp.sources.misc in September 1993
  109. END_OF_FILE
  110.   if test 1289 -ne `wc -c <'ChangeLog'`; then
  111.     echo shar: \"'ChangeLog'\" unpacked with wrong size!
  112.   fi
  113.   # end of 'ChangeLog'
  114. fi
  115. if test -f 'complete.c' -a "${1}" != "-c" ; then 
  116.   echo shar: Will not clobber existing file \"'complete.c'\"
  117. else
  118.   echo shar: Extracting \"'complete.c'\" \(4028 characters\)
  119.   sed "s/^X//" >'complete.c' <<'END_OF_FILE'
  120. X/*---------------------------------------------------------------------------*
  121. X *
  122. X *                  cwish - windowing user friendly shell
  123. X *                  -------------------------------------
  124. X *
  125. X *              (c) Copyright Hellmuth Michaelis 1989 - 1993
  126. X *
  127. X *                  Eggerstedtstr. 28
  128. X *                  22765 Hamburg
  129. X *                  Germany
  130. X *
  131. X *                  Tel:    +49 / 40 / 384298    (private)
  132. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  133. X *                  e-mail: hm@hcshh.hcs.de
  134. X *
  135. X *           All rights are reserved except as explicitly granted
  136. X *                  by written permission of the author.
  137. X *
  138. X *             See the file COPYING, distributed with cwish, for
  139. X *                  restriction and warranty information
  140. X *
  141. X *---------------------------------------------------------------------------*
  142. X *
  143. X *    last edit-date: [Sun Oct 17 18:03:43 1993]
  144. X *
  145. X *    -hm    primitive filename completition
  146. X *
  147. X *----------------------------------------------------------------------------*/
  148. X
  149. X#include "cwish.h"        /* local includes */
  150. X
  151. Xstatic char *wild(char *path, char *wildname);
  152. X
  153. X/*---------------------------------------------------------------------------*
  154. X *    complete name to first matching filename
  155. X *----------------------------------------------------------------------------*/
  156. Xvoid complete(void)
  157. X{
  158. X        char *cptr;        /* ptr to start of line after prompt */
  159. X    char *cend;        /* ptr to end of commandline */
  160. X    char *p,*q;        /* gp ptr */
  161. X    char *csave;        /* filename start position */
  162. X    char path[MAXPATHLEN+1];/* path portion */
  163. X    char name[MAXPATHLEN+1];/* name portion */
  164. X    
  165. X    cptr = cbuff+3;            /* init start ptr */
  166. X    cend = cptr + strlen(cptr);    /* int end ptr */
  167. X
  168. X    while(cend > cptr)        /* end of commandline */
  169. X    {
  170. X        cend--;
  171. X        if(isspace(*cend))    /* start of filename ? */
  172. X            break;
  173. X    }
  174. X    if(cend <= cptr)        /* hmm ... */
  175. X        return;
  176. X
  177. X    cend++;                /* first char of filename */
  178. X    csave = cend;            /* save position for later compare */
  179. X    
  180. X    if((p = strrchr(cend, '/')) == NULL)
  181. X    {
  182. X        path[0] = '\0';        /* setup path part */
  183. X        strcpy(name, cend);    /* setup name part */
  184. X    }
  185. X    else
  186. X    {
  187. X        q = path;        /* setup path part */
  188. X        while(cend <= p)
  189. X            *q++ = *cend++;
  190. X        *q = '\0';
  191. X        
  192. X        q = name;        /* setup name part */
  193. X        while(*cend)
  194. X            *q++ = *cend++;
  195. X        *q = '\0';
  196. X    }        
  197. X    strcat(name, "*");            /* add wildcard char */
  198. X        
  199. X    if((q = wild(path, name)) == NULL)    /* resolve wildcards */
  200. X        return;                /* not found */
  201. X
  202. X    while(*csave && *q && (*csave++ == *q++))    /* skip same chars */
  203. X        ;
  204. X
  205. X    while(*q && (cmdline(*q++) == GOOD))    /* rest to commandline */
  206. X        ;
  207. X}
  208. X            
  209. X/*---------------------------------------------------------------------------*
  210. X *    check if "wildname" matches any name in directory "path"
  211. X *    return concatenated "path" and matched name from dir
  212. X *    if directory found, append a '/' to resulting name
  213. X *----------------------------------------------------------------------------*/
  214. Xstatic char *wild(char *path, char *wildname)
  215. X{
  216. X    register struct direct *dp;        /* dir access */
  217. X    register DIR *dirp;            /* dir access */
  218. X    struct stat fdbuffer;            /* stat buffer */
  219. X    static char wtry[MAXPATHLEN+1];        /* try buffer */
  220. X    char rpath[MAXPATHLEN+1];        /* resulting path */
  221. X    
  222. X    strcpy(rpath, path);            /* path -> result path */
  223. X    strcat(rpath, ".");            /* for readdir */
  224. X    
  225. X    if((dirp = opendir(rpath)) == NULL)
  226. X        return(NULL);            /* cannot open directory */
  227. X
  228. X    for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
  229. X    {
  230. X        if((!(strcmp(dp->d_name, "."))) || (!(strcmp(dp->d_name, ".."))))
  231. X            continue;
  232. X
  233. X        if(wildmat(dp->d_name, wildname) == TRUE) /* hit ? */
  234. X        {
  235. X            strcpy(wtry, path);        /* pathname */
  236. X            strcat(wtry, dp->d_name);    /* matchname */
  237. X            if(stat(wtry, &fdbuffer) < 0)
  238. X                continue;        /* not accessible */
  239. X            closedir(dirp);            /* close */
  240. X            if(S_ISDIR(fdbuffer.st_mode))    /* directory ? */
  241. X                strcat(wtry, "/");    /* yes, append / */
  242. X            return(wtry);            /* return result */
  243. X        }
  244. X    }
  245. X    closedir(dirp);        /* close */
  246. X    return(NULL);        /* failed */
  247. X}
  248. X
  249. X/*---------------------------------- EOF -------------------------------------*/
  250. END_OF_FILE
  251.   if test 4028 -ne `wc -c <'complete.c'`; then
  252.     echo shar: \"'complete.c'\" unpacked with wrong size!
  253.   fi
  254.   # end of 'complete.c'
  255. fi
  256. if test -f 'config.h' -a "${1}" != "-c" ; then 
  257.   echo shar: Will not clobber existing file \"'config.h'\"
  258. else
  259.   echo shar: Extracting \"'config.h'\" \(4734 characters\)
  260.   sed "s/^X//" >'config.h' <<'END_OF_FILE'
  261. X/*---------------------------------------------------------------------------*
  262. X *
  263. X *                  cwish - windowing user friendly shell
  264. X *                  -------------------------------------
  265. X *
  266. X *              (c) Copyright Hellmuth Michaelis 1989 - 1993
  267. X *
  268. X *                  Eggerstedtstr. 28
  269. X *                  22765 Hamburg 
  270. X *                  Germany
  271. X *
  272. X *                  Tel:    +49 / 40 / 384298    (private)
  273. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  274. X *                  e-mail: hm@hcshh.hcs.de
  275. X *
  276. X *           All rights are reserved except as explicitly granted
  277. X *                  by written permission of the author.
  278. X *
  279. X *             See the file COPYING, distributed with cwish, for
  280. X *                  restriction and warranty information
  281. X *
  282. X *---------------------------------------------------------------------------*
  283. X *
  284. X *    Last Edit-Date: [Sun Oct 17 18:17:40 1993]
  285. X *
  286. X *    -hm    initial creation
  287. X *    -hm    debug / streamline
  288. X *    -hm    wildcards
  289. X *    -hm    move after tagging
  290. X *
  291. X *----------------------------------------------------------------------------*/
  292. X
  293. Xstruct item {
  294. X    int row;        /* name row position */
  295. X    int col;        /* name column position */
  296. X    char *name;        /* field name */
  297. X    int nl;            /* name length */
  298. X    int type;        /* item type */
  299. X#define ITEM_ONOFF    0        /* YES / NO */
  300. X#define ITEM_STRING    1        /* a string */
  301. X#define ITEM_CHAR    2        /* a character */
  302. X#define ITEM_NOCHANGE    0x80        /* user cannot chage item at run-time */
  303. X    int *value;        /* pointer to variable [...hmmm] */
  304. X    char *help;        /* help/description string */
  305. X    struct item *next;    /* ptr to next item struct */
  306. X    struct item *prev;    /* ptr to previous item struct */    
  307. X};
  308. X
  309. Xstruct item i_ret, i_attr, i_pres, i_fkey, i_link, i_point, i_pager, i_editor,
  310. X        i_delim, i_wild, i_wldon, i_cdrom, i_cdnop, i_dotfn, i_tagmv;
  311. X
  312. X#define FIRST_I        (&i_ret)
  313. X
  314. X/* ----- changable ON/OFF ----- */
  315. X
  316. Xstruct item i_ret = {
  317. X    2, 0, "   Return: ", 11, ITEM_ONOFF, (int *)&opt_return,
  318. X    "Specify wait for RETURN/ENTER key after executing an external command",
  319. X    &i_pres, &i_delim
  320. X};
  321. X
  322. Xstruct item i_pres = {
  323. X    2, 26, " Preserve: ", 11, ITEM_ONOFF, (int *)&opt_preserve, 
  324. X    "Preserve current directory when moving up in directory tree",
  325. X    &i_link, &i_ret
  326. X};
  327. X
  328. Xstruct item i_link = {
  329. X    2, 52, "SoftLinks: ", 11, ITEM_ONOFF, (int *)&opt_links,    
  330. X    "Enable detection and display of Softlinks in the attribute window",
  331. X    &i_point, &i_pres
  332. X};
  333. X
  334. Xstruct item i_point = {
  335. X    4, 0, "      Dot: ", 11, ITEM_ONOFF, (int *)&opt_point, 
  336. X    "Enable to display the current directory as a dot",
  337. X    &i_tagmv, &i_link
  338. X};
  339. X
  340. Xstruct item i_tagmv = {
  341. X    4, 26, "  TagMove: ", 11, ITEM_ONOFF, (int *)&opt_tagmove,    
  342. X    "Move to next filename after tagging the current one",
  343. X    &i_delim, &i_point
  344. X};
  345. X
  346. Xstruct item i_delim = {
  347. X    4, 52, "Delimiter: ", 11, ITEM_CHAR, (int *)&opt_delimiter, 
  348. X    "Character to be used a a horizontal delimiter between windows",
  349. X    &i_cdrom, &i_tagmv
  350. X};
  351. X
  352. Xstruct item i_cdrom = {
  353. X    6, 0, "   CD-Rom: ", 11, ITEM_ONOFF, (int *)&opt_cdrom,
  354. X    "Do special filename processing for cdrom filenames containing ';'",
  355. X    &i_cdnop, &i_delim
  356. X};
  357. X
  358. Xstruct item i_cdnop = {
  359. X    6, 26, "CDNoProgs: ", 11, ITEM_ONOFF, (int *)&opt_cdnoprog,         
  360. X    "Take all executable programs on CDROM as data files for display",
  361. X    &i_dotfn, &i_cdrom
  362. X};
  363. X
  364. Xstruct item i_dotfn = {
  365. X    6, 52, " DotNames: ", 11, ITEM_ONOFF, (int *)&opt_dotnames,    
  366. X    "Display Filenames starting with a Dot",
  367. X    &i_wldon, &i_cdnop
  368. X};
  369. X
  370. Xstruct item i_wldon = {
  371. X    8, 0, "WildEnabl: ", 11, ITEM_ONOFF, (int *)&opt_wildon,     
  372. X    "Enable wildcard filename display filtering",
  373. X    &i_wild, &i_dotfn
  374. X};
  375. X
  376. X/* ----- changable STRING ----- */
  377. X
  378. Xstruct item i_wild = {
  379. X    8, 26, " Wildcard: ", 11, ITEM_STRING, (int *)&opt_wild[0], 
  380. X    "Wildcard string for files being displayed in the file window",
  381. X    &i_attr, &i_wldon
  382. X};
  383. X
  384. X
  385. X/* ----- NOT changeable ON/OFF ----- */
  386. X
  387. Xstruct item i_attr = {
  388. X    12, 0, "  Attribs: ", 11, ITEM_ONOFF | ITEM_NOCHANGE, (int *)&opt_attrib, 
  389. X    "Display the current file's attributes and Permissions (NOT CHANGEABLE)",
  390. X    &i_fkey, &i_wild
  391. X};
  392. X
  393. Xstruct item i_fkey = {
  394. X    12, 40, "    Fkeys: ", 11, ITEM_ONOFF | ITEM_NOCHANGE, (int *)&opt_labels, 
  395. X    "Display virtual function key labels at bottom of the screen (NOT CHANGEABLE)",
  396. X    &i_pager, &i_attr
  397. X};
  398. X
  399. X/*----------------------- string variables -------------------------------*/
  400. X
  401. Xstruct item i_pager = {
  402. X    14, 0, "    Pager: ", 11, ITEM_STRING | ITEM_NOCHANGE, (int *)&opt_more[0], 
  403. X    "External command for program to display text (NOT CHANGEABLE)",
  404. X    &i_editor, &i_fkey    
  405. X};
  406. X
  407. Xstruct item i_editor = {
  408. X    16, 0, "   Editor: ", 11, ITEM_STRING | ITEM_NOCHANGE, (int *)&opt_edit[0], 
  409. X    "External command for program to edit text (NOT CHANGEABLE)",
  410. X    &i_ret, &i_pager
  411. X};
  412. X
  413. X/*---------------------------------- EOF ------------------------------------*/
  414. END_OF_FILE
  415.   if test 4734 -ne `wc -c <'config.h'`; then
  416.     echo shar: \"'config.h'\" unpacked with wrong size!
  417.   fi
  418.   # end of 'config.h'
  419. fi
  420. if test -f 'control.h' -a "${1}" != "-c" ; then 
  421.   echo shar: Will not clobber existing file \"'control.h'\"
  422. else
  423.   echo shar: Extracting \"'control.h'\" \(1501 characters\)
  424.   sed "s/^X//" >'control.h' <<'END_OF_FILE'
  425. X/*---------------------------------------------------------------------------*
  426. X *
  427. X *                  cwish - windowing user friendly shell
  428. X *                  -------------------------------------
  429. X *
  430. X *              (c) Copyright Hellmuth Michaelis 1989 - 1993
  431. X *
  432. X *                  Eggerstedtstr. 28
  433. X *                  22765 Hamburg
  434. X *                  Germany
  435. X *
  436. X *                  Tel:    +49 / 40 / 384298    (private)
  437. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  438. X *                  e-mail: hm@hcshh.hcs.de
  439. X *
  440. X *           All rights are reserved except as explicitly granted
  441. X *                  by written permission of the author.
  442. X *
  443. X *             See the file COPYING, distributed with cwish, for
  444. X *                  restriction and warranty information
  445. X *
  446. X *---------------------------------------------------------------------------*/
  447. X
  448. X#define CNTRL_@    0x00
  449. X#define CNTRL_A    0x01
  450. X#define CNTRL_B    0x02
  451. X#define CNTRL_C    0x03
  452. X#define CNTRL_D    0x04
  453. X#define CNTRL_E    0x05
  454. X#define CNTRL_F    0x06
  455. X#define CNTRL_G    0x07
  456. X#define CNTRL_H    0x08
  457. X#define CNTRL_I    0x09
  458. X#define CNTRL_J    0x0A
  459. X#define CNTRL_K    0x0B 
  460. X#define CNTRL_L    0x0C
  461. X#define CNTRL_M    0x0D
  462. X#define CNTRL_N    0x0E
  463. X#define CNTRL_O    0x0F
  464. X#define CNTRL_P    0x10
  465. X#define CNTRL_Q    0x11
  466. X#define CNTRL_R    0x12
  467. X#define CNTRL_S    0x13
  468. X#define CNTRL_T    0x14
  469. X#define CNTRL_U    0x15
  470. X#define CNTRL_V    0x16
  471. X#define CNTRL_W    0x17
  472. X#define CNTRL_X    0x18
  473. X#define CNTRL_Y    0x19
  474. X#define CNTRL_Z    0x1A
  475. X
  476. X
  477. X/*--------------------------- EOF -----------------------------*/
  478. END_OF_FILE
  479.   if test 1501 -ne `wc -c <'control.h'`; then
  480.     echo shar: \"'control.h'\" unpacked with wrong size!
  481.   fi
  482.   # end of 'control.h'
  483. fi
  484. if test -f 'fkeys.c' -a "${1}" != "-c" ; then 
  485.   echo shar: Will not clobber existing file \"'fkeys.c'\"
  486. else
  487.   echo shar: Extracting \"'fkeys.c'\" \(3899 characters\)
  488.   sed "s/^X//" >'fkeys.c' <<'END_OF_FILE'
  489. X/*---------------------------------------------------------------------------*
  490. X *
  491. X *                  cwish - windowing user friendly shell
  492. X *                  -------------------------------------
  493. X *
  494. X *              (c) Copyright Hellmuth Michaelis 1989 - 1993
  495. X *
  496. X *                  Eggerstedtstr. 28
  497. X *                  22765 Hamburg
  498. X *                  Germany
  499. X *
  500. X *                  Tel:    +49 / 40 / 384298    (private)
  501. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  502. X *                  e-mail: hm@hcshh.hcs.de
  503. X *
  504. X *           All rights are reserved except as explicitly granted
  505. X *                  by written permission of the author.
  506. X *
  507. X *             See the file COPYING, distributed with cwish, for
  508. X *                  restriction and warranty information
  509. X *
  510. X *---------------------------------------------------------------------------*
  511. X *
  512. X *    last edit-date: [Wed Oct 20 16:52:06 1993]
  513. X *
  514. X *    -hm    modifying function key label layout
  515. X *    -hm    consistent fkey labels ( just 8 ! )
  516. X *    -hm    flabel.c -> fkeys.c
  517. X *    -hm    hpterm support
  518. X *    -hm    interactive configuration
  519. X *    -hm    fkey label structures
  520. X *    -hm    alternate attrib line
  521. X *
  522. X *----------------------------------------------------------------------------*/
  523. X
  524. X#include "cwish.h"
  525. X
  526. X/*---------------------------------------------------------------------------*
  527. X *    write string to function key label
  528. X *---------------------------------------------------------------------------*/
  529. Xvoid fnclabel(int n, char *string)
  530. X{
  531. X    char xmit[5];        /* transmitted string ( ESC 'p'...'w' ) */
  532. X    char result[50];    /* result buffer */
  533. X
  534. X    /* check if we are on an hp-terminal or lookalike */
  535. X
  536. X    if(termtype == TERM_HP || termtype == TERM_PCVT || termtype == TERM_HPX)
  537. X    {
  538. X        if(n < 1 || n > 8) /* and it must be a legal key number */
  539. X            return;
  540. X        if((strlen(string)) != 16)
  541. X            return;
  542. X            
  543. X        xmit[0] = ESC;
  544. X        xmit[1] = 'o' + n;
  545. X        xmit[2] = '\0';
  546. X        sprintf(result,"%c&f0a%dk16d2L%s%s",ESC,n,string,xmit);
  547. X        write(2,result,strlen(result));
  548. X        sprintf(result,"%c&jB",ESC);    /* display user function keys */
  549. X        write(2,result,strlen(result));
  550. X        return;
  551. X    }
  552. X    else if(opt_labels)    /* if virtual f-key labels .. */
  553. X    {
  554. X        if(n < 1 || n > 8) /* and it must be a legal key number */
  555. X            return;
  556. X
  557. X        if((strlen(string)) != 9)
  558. X            return;
  559. X
  560. X        wmove(flbl_w, 0, ((n-1)*10)); /* last line */
  561. X
  562. X        wattron(flbl_w, A_REVERSE);
  563. X        waddstr(flbl_w, string);
  564. X        wattroff(flbl_w, A_REVERSE);
  565. X        wrefresh(flbl_w);        
  566. X    }
  567. X}
  568. X
  569. X/*---------------------------------------------------------------------------*
  570. X *    function key labels initialization
  571. X *---------------------------------------------------------------------------*/
  572. Xvoid init_flabels(void)
  573. X{
  574. X    int i;
  575. X    for(i = 0; i < 8; i++)
  576. X    {
  577. X        if(termtype == TERM_HP || termtype == TERM_PCVT || termtype == TERM_HPX)
  578. X            fnclabel(i+1, (*cur_fktab)[i].label_16);
  579. X        else if(opt_labels)
  580. X            fnclabel(i+1, (*cur_fktab)[i].label_8);
  581. X        else
  582. X            break;
  583. X    }
  584. X}
  585. X
  586. X/*---------------------------------------------------------------------------*
  587. X *    restore function key labels
  588. X *---------------------------------------------------------------------------*/
  589. Xvoid fini_flabels(void)
  590. X{
  591. X    static char modes[] = { ESC, '&', 'j', 'A', '\0'};
  592. X
  593. X     /* check if we are on an hp-terminal */
  594. X    
  595. X    if(termtype == TERM_HP || termtype == TERM_PCVT || termtype == TERM_HPX)
  596. X        write(2,modes,strlen(modes));
  597. X}
  598. X
  599. X/*---------------------------------------------------------------------------*
  600. X *    system function keys table
  601. X *---------------------------------------------------------------------------*/
  602. X
  603. Xstruct fk_tab sys_keys[] = {
  604. X    {"  Edit    File  ", "Edit File"},
  605. X    {"  Echo  Filename", "Echo Name"},
  606. X    {"  Help  Commands", "Help Cmds"},
  607. X    {" Config  Screen ", "Conf Scrn"},
  608. X    {"  Mark  Filename", "Mark File"},
  609. X    {" Unmark allmarkd", "UnmarkAll"},
  610. X    {"AlternatAttrLine", "Alt AttLn"},
  611. X    {" Close   CurDir ", "Close Dir"}
  612. X};
  613. X    
  614. X/*---------------------------------- EOF -------------------------------------*/
  615. END_OF_FILE
  616.   if test 3899 -ne `wc -c <'fkeys.c'`; then
  617.     echo shar: \"'fkeys.c'\" unpacked with wrong size!
  618.   fi
  619.   # end of 'fkeys.c'
  620. fi
  621. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  622.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  623. else
  624.   echo shar: Extracting \"'patchlevel.h'\" \(1690 characters\)
  625.   sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  626. X/*---------------------------------------------------------------------------*
  627. X *
  628. X *                  cwish - windowing user friendly shell
  629. X *                  -------------------------------------
  630. X *
  631. X *               Copyright (c) 1988-1993 Hellmuth Michaelis
  632. X *
  633. X *                  Eggerstedtstr. 28
  634. X *                  22765 Hamburg
  635. X *                  Germany
  636. X *
  637. X *                  Tel:    +49 / 40 / 384298    (private)
  638. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  639. X *                  e-mail: hm@hcshh.hcs.de
  640. X *
  641. X *                          --------oOo--------
  642. X *
  643. X *   This program is free software; you can redistribute it and/or modify
  644. X *   it under the terms of the GNU General Public License as published by
  645. X *   the Free Software Foundation; either version 2 of the License, or
  646. X *   (at your option) any later version.
  647. X *
  648. X *   This program is distributed in the hope that it will be useful,
  649. X *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  650. X *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  651. X *   GNU General Public License for more details.
  652. X *
  653. X *   You should have received a copy of the GNU General Public License
  654. X *   along with this program; if not, write to the Free Software
  655. X *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  656. X *
  657. X *---------------------------------------------------------------------------*
  658. X *
  659. X *    Last Edit-Date: [Fri Oct 29 10:44:38 1993]
  660. X *
  661. X *    -hm    added patchlevel.h for submission to comp.sources.misc
  662. X *
  663. X *----------------------------------------------------------------------------*/
  664. X
  665. X#define PATCHLEVEL "2.00"
  666. X
  667. X/*--------------------------------- EOF -------------------------------------*/
  668. END_OF_FILE
  669.   if test 1690 -ne `wc -c <'patchlevel.h'`; then
  670.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  671.   fi
  672.   # end of 'patchlevel.h'
  673. fi
  674. if test -f 'rcinit.h' -a "${1}" != "-c" ; then 
  675.   echo shar: Will not clobber existing file \"'rcinit.h'\"
  676. else
  677.   echo shar: Extracting \"'rcinit.h'\" \(2314 characters\)
  678.   sed "s/^X//" >'rcinit.h' <<'END_OF_FILE'
  679. X/*---------------------------------------------------------------------------*
  680. X *
  681. X *                  cwish - windowing user friendly shell
  682. X *                  -------------------------------------
  683. X *
  684. X *               Copyright (c) 1988-1993 Hellmuth Michaelis
  685. X *
  686. X *                  Eggerstedtstr. 28
  687. X *                  22765 Hamburg
  688. X *                  Germany
  689. X *
  690. X *                  Tel:    +49 / 40 / 384298    (private)
  691. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  692. X *                  e-mail: hm@hcshh.hcs.de
  693. X *
  694. X *                          --------oOo--------
  695. X *
  696. X *   This program is free software; you can redistribute it and/or modify
  697. X *   it under the terms of the GNU General Public License as published by
  698. X *   the Free Software Foundation; either version 2 of the License, or
  699. X *   (at your option) any later version.
  700. X *
  701. X *   This program is distributed in the hope that it will be useful,
  702. X *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  703. X *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  704. X *   GNU General Public License for more details.
  705. X *
  706. X *   You should have received a copy of the GNU General Public License
  707. X *   along with this program; if not, write to the Free Software
  708. X *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  709. X *
  710. X *---------------------------------------------------------------------------*
  711. X *
  712. X *    Last Edit-Date: [Sun Oct 17 18:17:42 1993]
  713. X *
  714. X *    -hm    init file ".wishrc"
  715. X *    -hm    wildcards
  716. X *    -hm    cdrom processing for ';' chars
  717. X *    -hm    move after tag
  718. X *
  719. X *----------------------------------------------------------------------------*/
  720. X
  721. X#define CWISHRC        ".cwishrc"    /* our config file */
  722. X
  723. X#define    RC_ON        "on"
  724. X#define    RC_OFF        "off"
  725. X
  726. X/* booolean variables (on/off) */
  727. X
  728. X#define    RC_ATTR        "attributes"
  729. X#define    RC_PRESERVE    "preserve"
  730. X#define    RC_FKEYS    "fkeys"
  731. X#define    RC_LINKS    "links"
  732. X#define    RC_POINT    "point"
  733. X#define RC_RETURN    "return"
  734. X#define RC_WILDON    "wildenable"
  735. X#define RC_CDROM    "cdrom"
  736. X#define RC_CDNOPROG    "cdnoprog"
  737. X#define RC_DOTNAMES    "dotnames"
  738. X#define RC_TAGMOVE    "tagmove"
  739. X
  740. X/* string variables */
  741. X
  742. X#define    RC_PAGER    "pager"
  743. X#define    RC_EDITOR    "editor"
  744. X#define RC_WILDCARD    "wildcard"
  745. X
  746. X/* character variables */
  747. X
  748. X#define RC_DELIMITER    "delimiter"
  749. X
  750. X/*---------------------------------- EOF ------------------------------------*/
  751. END_OF_FILE
  752.   if test 2314 -ne `wc -c <'rcinit.h'`; then
  753.     echo shar: \"'rcinit.h'\" unpacked with wrong size!
  754.   fi
  755.   # end of 'rcinit.h'
  756. fi
  757. if test -f 'usage.c' -a "${1}" != "-c" ; then 
  758.   echo shar: Will not clobber existing file \"'usage.c'\"
  759. else
  760.   echo shar: Extracting \"'usage.c'\" \(4589 characters\)
  761.   sed "s/^X//" >'usage.c' <<'END_OF_FILE'
  762. X/*---------------------------------------------------------------------------*
  763. X *
  764. X *                  cwish - windowing user friendly shell
  765. X *                  -------------------------------------
  766. X *
  767. X *               Copyright (c) 1988-1993 Hellmuth Michaelis
  768. X *
  769. X *                  Eggerstedtstr. 28
  770. X *                  22765 Hamburg
  771. X *                  Germany
  772. X *
  773. X *                  Tel:    +49 / 40 / 384298    (private)
  774. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  775. X *                  e-mail: hm@hcshh.hcs.de
  776. X *
  777. X *                          --------oOo--------
  778. X *
  779. X *   This program is free software; you can redistribute it and/or modify
  780. X *   it under the terms of the GNU General Public License as published by
  781. X *   the Free Software Foundation; either version 2 of the License, or
  782. X *   (at your option) any later version.
  783. X *
  784. X *   This program is distributed in the hope that it will be useful,
  785. X *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  786. X *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  787. X *   GNU General Public License for more details.
  788. X *
  789. X *   You should have received a copy of the GNU General Public License
  790. X *   along with this program; if not, write to the Free Software
  791. X *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  792. X *
  793. X *---------------------------------------------------------------------------*
  794. X *
  795. X *    Last Edit-Date: [Fri Oct 29 11:27:16 1993]
  796. X *
  797. X *    -hm    adding compilation revision numbers
  798. X *    -hm    prototyping, updating, vt220 support
  799. X *    -hm    386bsd intro
  800. X *    -hm    hpterm, hpux 9.0
  801. X *    -hm    interactive configuration
  802. X *    -hm    altcharset in config.c on hpux
  803. X *    -hm    preserve bug fixed in hpux
  804. X *    -hm    multiple extension support in commandline.c
  805. X *    -hm    fkey label structures
  806. X *    -hm    wildcards
  807. X *    -hm    cdrom options
  808. X *    -hm    primitive filename completition
  809. X *    -hm    option display dot-filenames
  810. X *    -hm    option processing
  811. X *    -hm    added patchlevel.h for submission
  812. X *    -hm    released to comp.sources.misc
  813. X *    -hm    renamed to cwish
  814. X *
  815. X *----------------------------------------------------------------------------*/
  816. X
  817. X#include "cwish.h"
  818. X#include "patchlevel.h"
  819. X
  820. X/*---------------------------------------------------------------------------*
  821. X *    format the headerline
  822. X *---------------------------------------------------------------------------*/
  823. Xvoid init_header(void)
  824. X{
  825. X    sprintf(headerline, "cwish %s.%02d (c)Copyright 1988-1993 Hellmuth Michaelis, Hamburg [%7.7s]      ", 
  826. X    PATCHLEVEL,
  827. X#include "update.h"
  828. X    ,term_string);
  829. X}
  830. X
  831. X/*---------------------------------------------------------------------------*
  832. X *    format & print the usage display
  833. X *---------------------------------------------------------------------------*/
  834. Xvoid usage(void)
  835. X{
  836. X    fprintf(stderr,"\n   cwish - revision %s - compilation %02d - %s - %s\n",
  837. X    PATCHLEVEL,
  838. X#include "update.h"
  839. X    ,__DATE__,__TIME__);
  840. X    fprintf(stderr,"   Copyright (c) 1988 - 1993 by Hellmuth Michaelis, Hamburg, Germany\n\n");
  841. X    fprintf(stderr,"   Cwish comes with ABSOLUTELY NO WARRANTY; for details see the file\n");
  842. X    fprintf(stderr,"   COPYING, which should have come with the source for this program.\n");
  843. X    fprintf(stderr,"   This program is free software; you can redistribute it and/or modify\n");
  844. X    fprintf(stderr,"   it under the terms of the GNU General Public License as published by\n");
  845. X    fprintf(stderr,"   the Free Software Foundation; either version 2 of the License, or\n");
  846. X    fprintf(stderr,"   (at your option) any later version; see file COPYING for details.\n\n");
  847. X    fprintf(stderr,"     Usage:   cwish [[+ | -] [acCdflnprw]] | [-?]\n");
  848. X    fprintf(stderr,"   Options:   +/-a  file attributes display window on/off\n");
  849. X    fprintf(stderr,"              +/-c  enable special cdrom filename processing (\";\") on/off\n");
  850. X    fprintf(stderr,"              +/-C  on cdrom handle programs as data files on/off\n");
  851. X    fprintf(stderr,"              +/-d  preserve current directory when \"cd ..\" on/off\n");
  852. X    fprintf(stderr,"              +/-f  display virtual fkey labels window on/off\n");
  853. X    fprintf(stderr,"              +/-l  file link detection enable on/off\n");
  854. X    fprintf(stderr,"              +/-n  display filenames beginning with a dot (\".\") on/off\n");
  855. X    fprintf(stderr,"              +/-p  display the current directory (as a \".\") on/off\n");
  856. X    fprintf(stderr,"              +/-r  wait for return after external command on/off\n");
  857. X    fprintf(stderr,"              +/-w  enable wildcard filename processing on/off\n");    
  858. X    fprintf(stderr,"              -?    display this help text\n");
  859. X    exit(99);    
  860. X}
  861. X
  862. X/*---------------------------------- EOF -------------------------------------*/
  863. END_OF_FILE
  864.   if test 4589 -ne `wc -c <'usage.c'`; then
  865.     echo shar: \"'usage.c'\" unpacked with wrong size!
  866.   fi
  867.   # end of 'usage.c'
  868. fi
  869. if test -f 'usrgrp.c' -a "${1}" != "-c" ; then 
  870.   echo shar: Will not clobber existing file \"'usrgrp.c'\"
  871. else
  872.   echo shar: Extracting \"'usrgrp.c'\" \(4642 characters\)
  873.   sed "s/^X//" >'usrgrp.c' <<'END_OF_FILE'
  874. X/*---------------------------------------------------------------------------*
  875. X *
  876. X *                  cwish - windowing user friendly shell
  877. X *                  -------------------------------------
  878. X *
  879. X *               Copyright (c) 1988-1993 Hellmuth Michaelis
  880. X *
  881. X *                  Eggerstedtstr. 28
  882. X *                  22765 Hamburg
  883. X *                  Germany
  884. X *
  885. X *                  Tel:    +49 / 40 / 384298    (private)
  886. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  887. X *                  e-mail: hm@hcshh.hcs.de
  888. X *
  889. X *                          --------oOo--------
  890. X *
  891. X *   This program is free software; you can redistribute it and/or modify
  892. X *   it under the terms of the GNU General Public License as published by
  893. X *   the Free Software Foundation; either version 2 of the License, or
  894. X *   (at your option) any later version.
  895. X *
  896. X *   This program is distributed in the hope that it will be useful,
  897. X *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  898. X *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  899. X *   GNU General Public License for more details.
  900. X *
  901. X *   You should have received a copy of the GNU General Public License
  902. X *   along with this program; if not, write to the Free Software
  903. X *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  904. X *
  905. X *---------------------------------------------------------------------------*
  906. X *
  907. X * This is based on some file i got from some Berkley distribution years ago,
  908. X * i really forgot which one, and i forgot the name of the file this is from,
  909. X * so i just copied the copyright notice from some other file:
  910. X *
  911. X * Copyright (c) 1988 The Regents of the University of California.
  912. X * All rights reserved.
  913. X *
  914. X * Redistribution and use in source and binary forms are permitted
  915. X * provided that: (1) source distributions retain this entire copyright
  916. X * notice and comment, and (2) distributions including binaries display
  917. X * the following acknowledgement:  ``This product includes software
  918. X * developed by the University of California, Berkeley and its contributors''
  919. X * in the documentation or other materials provided with the distribution
  920. X * and in all advertising materials mentioning features or use of this
  921. X * software. Neither the name of the University nor the names of its
  922. X * contributors may be used to endorse or promote products derived
  923. X * from this software without specific prior written permission.
  924. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  925. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  926. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  927. X *
  928. X *---------------------------------------------------------------------------*
  929. X *
  930. X *    last edit-date: [Sun Oct 17 18:09:36 1993]
  931. X *
  932. X *    -hm    caching uid/gid entries
  933. X *    -hm    new calling sequence
  934. X *
  935. X *---------------------------------------------------------------------------*/ 
  936. X
  937. X#include "cwish.h"
  938. X
  939. X#ifndef min
  940. X#define min(x, y)    (((x) < (y)) ? (x) : (y))
  941. X#endif
  942. X
  943. X#define    NCACHE        256
  944. X#define    MASK        (NCACHE - 1)
  945. X#define NAMELENGTH    16
  946. X
  947. X/*---------------------------------------------------------------------------*
  948. X *    make a user id string from the numeric user id (and cache a bit)
  949. X *---------------------------------------------------------------------------*/
  950. Xchar *user_from_uid(uid_t uid, int size)
  951. X{
  952. X    static struct ncache
  953. X    {
  954. X        uid_t    uid;
  955. X        char    name[NAMELENGTH];
  956. X    } c_uid[NCACHE];
  957. X
  958. X    static char nbuf[15];
  959. X    register struct passwd *pw;
  960. X    register struct ncache *cp;
  961. X    int length = min(NAMELENGTH, size);
  962. X    
  963. X    cp = (c_uid + (uid & MASK));
  964. X
  965. X    if (cp->uid != uid || !*cp->name)
  966. X    {
  967. X        if (!(pw = getpwuid(uid)))
  968. X        {
  969. X            sprintf(nbuf, "%-*u", length, uid);
  970. X            return(nbuf);
  971. X        }
  972. X        cp->uid = uid;
  973. X        sprintf(cp->name, "%-*s", NAMELENGTH, pw->pw_name);
  974. X    }
  975. X    strncpy(nbuf, cp->name, length);
  976. X    return(nbuf);
  977. X}
  978. X
  979. X/*---------------------------------------------------------------------------*
  980. X *    make a group id string from the numeric group id (and cache a bit)
  981. X *---------------------------------------------------------------------------*/
  982. Xchar *group_from_gid(gid_t gid, int size)
  983. X{
  984. X    static struct ncache
  985. X    {
  986. X        gid_t    gid;
  987. X        char    name[NAMELENGTH];
  988. X    } c_gid[NCACHE];
  989. X
  990. X    static char nbuf[15];
  991. X    register struct group *gr;
  992. X    register struct ncache *cp;
  993. X    int length = min(NAMELENGTH, size);
  994. X    
  995. X    cp = c_gid + (gid & MASK);
  996. X    if (cp->gid != gid || !*cp->name)
  997. X    {
  998. X        if (!(gr = getgrgid(gid)))
  999. X        {
  1000. X            sprintf(nbuf, "%-*u", length, gid);
  1001. X            return(nbuf);
  1002. X        }
  1003. X        cp->gid = gid;
  1004. X        sprintf(cp->name, "%-*s", NAMELENGTH, gr->gr_name);
  1005. X    }
  1006. X
  1007. X    strncpy(nbuf, cp->name, length);
  1008. X    return(nbuf);
  1009. X}
  1010. X
  1011. X/*---------------------------------- EOF -------------------------------------*/
  1012. END_OF_FILE
  1013.   if test 4642 -ne `wc -c <'usrgrp.c'`; then
  1014.     echo shar: \"'usrgrp.c'\" unpacked with wrong size!
  1015.   fi
  1016.   # end of 'usrgrp.c'
  1017. fi
  1018. echo shar: End of archive 5 \(of 5\).
  1019. cp /dev/null ark5isdone
  1020. MISSING=""
  1021. for I in 1 2 3 4 5 ; do
  1022.     if test ! -f ark${I}isdone ; then
  1023.     MISSING="${MISSING} ${I}"
  1024.     fi
  1025. done
  1026. if test "${MISSING}" = "" ; then
  1027.     echo You have unpacked all 5 archives.
  1028.     rm -f ark[1-9]isdone
  1029. else
  1030.     echo You still must unpack the following archives:
  1031.     echo "        " ${MISSING}
  1032. fi
  1033. exit 0
  1034. exit 0 # Just in case...
  1035.