home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume39 / cwish / part03 < prev    next >
Encoding:
Text File  |  1993-09-22  |  59.2 KB  |  2,260 lines

  1. Newsgroups: comp.sources.misc
  2. From: hm@hcshh.hcs.de (Hellmuth Michaelis)
  3. Subject: v39i099:  cwish - Window Shell / Filemanager v1.00, Part03/04
  4. Message-ID: <1993Sep22.161633.26237@sparky.sterling.com>
  5. X-Md4-Signature: 899a797f0a6df39694639a57239a78ab
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Reply-To: hm@hcshh.hcs.de
  8. Organization: HCS Hanseatischer Computerservice GmbH
  9. Date: Wed, 22 Sep 1993 16:16:33 GMT
  10. Approved: kent@sparky.sterling.com
  11.  
  12. Submitted-by: hm@hcshh.hcs.de (Hellmuth Michaelis)
  13. Posting-number: Volume 39, Issue 99
  14. Archive-name: cwish/part03
  15. Environment: HP-UX, 386BSD, NETBSD, ANSI-C, SYSV-CURSES
  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:  config.c files.c movement.c paging.c rcinit.c wish.h
  22. # Wrapped by kent@sparky on Wed Sep 22 10:49:57 1993
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 3 (of 4)."'
  26. if test -f 'config.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'config.c'\"
  28. else
  29.   echo shar: Extracting \"'config.c'\" \(8688 characters\)
  30.   sed "s/^X//" >'config.c' <<'END_OF_FILE'
  31. X/*---------------------------------------------------------------------------*
  32. X *
  33. X *                  wish - windowing user friendly shell
  34. X *                 --------------------------------------
  35. X *
  36. X *              (c) Copyright Hellmuth Michaelis 1989 - 1993
  37. X *
  38. X *                  Eggerstedtstr. 28
  39. X *                  22765 Hamburg
  40. X *                  Germany
  41. X *
  42. X *                  Tel:    +49 / 40 / 384298    (private)
  43. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  44. X *                  e-mail: hm@hcshh.hcs.de
  45. X *
  46. X *           All rights are reserved except as explicitly granted
  47. X *                  by written permission of the author.
  48. X *
  49. X *             See the file COPYING, distributed with wish, for
  50. X *                  restriction and warranty information
  51. X *
  52. X *---------------------------------------------------------------------------*
  53. X *
  54. X *    Last Edit-Date: [Mon Aug 30 12:29:19 1993]
  55. X *
  56. X *    -hm    initial configuration menu design
  57. X *    -hm    altcharset debugging
  58. X *    -hm    fkey labels for config screen
  59. X *    -hm    enter wildcard string
  60. X *
  61. X *----------------------------------------------------------------------------*/
  62. X
  63. X#include "wish.h"
  64. X#include "config.h"
  65. X#include "control.h"
  66. X
  67. Xextern char *contin;        /* from help.c */
  68. X
  69. Xstatic char *help1 = "Use cursor keys to move to the items you wish change";
  70. Xstatic char *help2 = "SPACE toggles between YES and NO";
  71. Xstatic char *help3 = "CONTROL-D exits configuration menu";
  72. X
  73. Xstatic void separate(int);
  74. Xstatic char *enter_string(int row, int col, char *string, int length);
  75. X
  76. Xstatic char was_wildcard[OPTSLEN+1];
  77. Xstatic char was_wildon;
  78. Xstatic char was_cdrom;
  79. Xstatic char was_cdnoprog;
  80. X
  81. X/*---------------------------------------------------------------------------*
  82. X *    config function key labels
  83. X *---------------------------------------------------------------------------*/
  84. X
  85. Xstatic struct fk_tab conf_keys[] = {
  86. X    {"                ", "         "},
  87. X    {"                ", "         "},
  88. X    {"                ", "         "},
  89. X    {"                ", "         "},
  90. X    {"                ", "         "},
  91. X    {"                ", "         "},
  92. X    {"                ", "         "},
  93. X    {"  Exit   Config ", "         "}
  94. X};
  95. X
  96. X/*---------------------------------------------------------------------------*
  97. X *    run-time configuration menu
  98. X *---------------------------------------------------------------------------*/
  99. Xvoid config(void)
  100. X{
  101. X    struct item *ip;
  102. X    char *q;
  103. X    int c;
  104. X    int i;
  105. X    int dids = 0;
  106. X    int helpline = 0;
  107. X    
  108. X    suspend_time();        /* stop updating time */
  109. X
  110. X    cur_fktab = &conf_keys;    /* config screen fkey label table */
  111. X    init_flabels();
  112. X
  113. X    strcpy(was_wildcard, opt_wild);
  114. X    was_wildon = opt_wildon;
  115. X    was_cdrom = opt_cdrom;
  116. X    was_cdnoprog = opt_cdnoprog;
  117. X    
  118. X    wmove(stdscr, 0, 0);    /* first line */
  119. X    wclear(stdscr);        /* clear window */
  120. X    touchwin(stdscr);    /* touch it */
  121. X    wnoutrefresh(stdscr);    /* force refresh */
  122. X
  123. X    move(0, 0);        /* first line */
  124. X    attron(A_REVERSE);    /* highlight on */
  125. X    addstr(headerline);    /* program/copyright header */
  126. X    attroff(A_REVERSE);    /* highlight off */
  127. X
  128. X    ip = FIRST_I;
  129. X    
  130. X    /* display menu */
  131. X    
  132. X    do
  133. X    {
  134. X        if(!dids && ip->type & ITEM_NOCHANGE)
  135. X        {
  136. X            dids = 1;
  137. X            separate(ip->row - 2);
  138. X        }
  139. X            
  140. X        mvaddstr(ip->row, ip->col, ip->name);
  141. X        standout();
  142. X        switch(ip->type & ~ITEM_NOCHANGE)
  143. X        {
  144. X            case ITEM_ONOFF:
  145. X                if(*(ip->value))
  146. X                    addstr("YES");
  147. X                else
  148. X                    addstr(" NO");
  149. X                break;
  150. X            case ITEM_STRING:
  151. X                if(*((char *)ip->value))
  152. X                    addstr((char *)ip->value);
  153. X                else
  154. X                {
  155. X                    standend();
  156. X                    addstr("[Not set]");
  157. X                }
  158. X                break;
  159. X            case ITEM_CHAR:
  160. X                if((char)*(ip->value))
  161. X                    addch((char)*(ip->value));
  162. X                else
  163. X                {
  164. X                    standend();
  165. X                    addstr("[Not set]");
  166. X                }
  167. X                break;
  168. X        }
  169. X        standend();
  170. X        if(helpline < ip->row)
  171. X            helpline = ip->row;
  172. X    }
  173. X    while((ip = ip->next) != FIRST_I);
  174. X
  175. X    helpline += 3;
  176. X
  177. X    separate(helpline-1);
  178. X    
  179. X    move(helpline + 2, (COLS-strlen(help1))/2);
  180. X    addstr(help1);
  181. X
  182. X    move(helpline + 3, (COLS-strlen(help2))/2);
  183. X    addstr(help2);
  184. X
  185. X    move(helpline + 4, (COLS-strlen(help3))/2);
  186. X    addstr(help3);
  187. X    
  188. X    ip = FIRST_I;
  189. X
  190. X    /* cruise in menu */
  191. X
  192. X    i = 0;
  193. X    
  194. X    for(;;)
  195. X    {
  196. X        move(helpline, 0);
  197. X        clrtoeol();
  198. X        move(helpline, (COLS-strlen(ip->help))/2);
  199. X        addstr(ip->help);
  200. X
  201. X        move(ip->row, ((ip->col)+(ip->nl)));
  202. X        refresh();
  203. X
  204. X        c = getch();
  205. X
  206. X        switch(c)
  207. X        {
  208. X            case CR:
  209. X                if(ip->type != ITEM_STRING)
  210. X                    break;
  211. X
  212. X                if((q = enter_string(ip->row, ((ip->col)+(ip->nl)), (char *)ip->value , OPTSLEN)) != NULL)
  213. X                    strcpy((char *)ip->value, q);
  214. X
  215. X                mvaddstr(ip->row, ip->col, ip->name);
  216. X                if(*((char *)ip->value))
  217. X                {
  218. X                    standout();                
  219. X                    addstr((char *)ip->value);
  220. X                    standend();
  221. X                }
  222. X                else
  223. X                {
  224. X                    addstr("[Not set]");
  225. X                }
  226. X                break;
  227. X                
  228. X            case ' ':        /* nextopt */
  229. X                if(ip->type == ITEM_ONOFF)
  230. X                {
  231. X                    standout();
  232. X                    if(*(ip->value))
  233. X                    {
  234. X                        *(ip->value) = 0;
  235. X                        addstr(" NO");
  236. X                    }
  237. X                    else
  238. X                    {
  239. X                        *(ip->value) = 1;
  240. X                        addstr("YES");
  241. X                    }
  242. X                    standend();
  243. X                }                
  244. X                break;
  245. X
  246. X            case CNTRL_D:
  247. X                goto breakout;
  248. X
  249. X            case KEY_UP:        /* up item */
  250. X                i = ip->col;
  251. X                do
  252. X                    ip = ip->prev;
  253. X                while(ip->col != i);
  254. X                break;
  255. X
  256. X            case KEY_DOWN:        /* down item */
  257. X                i = ip->col;
  258. X                do
  259. X                    ip = ip->next;
  260. X                while(ip->col != i);
  261. X                break;
  262. X
  263. X            case KEY_LEFT:        /* left item */
  264. X            case KEY_BTAB:
  265. X                ip = ip->prev;
  266. X                break;
  267. X
  268. X            case KEY_RIGHT:        /* right item */
  269. X            case TAB:
  270. X                ip = ip->next;
  271. X                break;
  272. X
  273. X            case KEY_F(1):    /* function key 1 */
  274. X                break;
  275. X
  276. X            case KEY_F(2):    /* function key 2 */
  277. X                break;
  278. X            
  279. X            case KEY_F(3):    /* function key 3 */
  280. X                break;
  281. X                
  282. X            case KEY_F(4):    /* function key 4 */
  283. X                break;
  284. X                
  285. X            case KEY_F(5):    /* function key 5 */
  286. X                break;
  287. X
  288. X            case KEY_F(6):    /* function key 6 */
  289. X                break;
  290. X                
  291. X            case KEY_F(7):    /* function key 7 */
  292. X                break;
  293. X                
  294. X            case KEY_F(8):    /* function key 8 */
  295. X                goto breakout;
  296. X
  297. X            case CNTRL_L:    /* refresh */
  298. X                touchwin(curscr);
  299. X                wrefresh(curscr);
  300. X                break;
  301. X        }
  302. X    }
  303. X
  304. Xbreakout:
  305. X
  306. X    /* do we have to reread dir ? */
  307. X
  308. X    if((strcmp(opt_wild, was_wildcard)) || (opt_wildon != was_wildon) ||
  309. X       (was_cdrom != opt_cdrom) || (was_cdnoprog != opt_cdnoprog))
  310. X    {
  311. X        free_list();            /* free malloc'ed buffers */
  312. X        init_files(PRES_NORM, NULL);    /* yes, read current dir */
  313. X    }
  314. X
  315. X    wmove(stdscr, 0, 0);            /* first line */
  316. X    wclear(stdscr);                /* clear window */
  317. X    touchwin(stdscr);
  318. X    wnoutrefresh(stdscr);
  319. X
  320. X    touchwin(cmnd_w);
  321. X    touchwin(fst_w);
  322. X    touchwin(file_w);
  323. X    if(opt_attrib)
  324. X        touchwin(attr_w);
  325. X    if(opt_labels)
  326. X        touchwin(flbl_w);
  327. X    
  328. X    resume_time();        /* restart updating time */
  329. X
  330. X    header();        /* new header */
  331. X    dis_hist();        /* display current commandline */
  332. X    fresh_files();        /* refresh files */
  333. X    attribs(1);        /* new attributes */
  334. X    update_all();        /* update complete screen */
  335. X
  336. X    cur_fktab = &sys_keys;    /* system fkey label table */
  337. X    init_flabels();
  338. X}
  339. X
  340. X/*---------------------------------------------------------------------------*
  341. X *    print a horizontal line
  342. X *---------------------------------------------------------------------------*/
  343. Xstatic void separate(int row)
  344. X{
  345. X    int i = COLS;
  346. X    unsigned char delim;
  347. X    
  348. X    move(row, 0);
  349. X
  350. X    if(opt_delimiter)
  351. X    {
  352. X        delim = opt_delimiter;        
  353. X    }
  354. X    else if(enter_alt_charset_mode && exit_alt_charset_mode &&
  355. X            *enter_alt_charset_mode && *exit_alt_charset_mode)
  356. X    {
  357. X        attron(A_ALTCHARSET);
  358. X        switch(termtype)
  359. X        {
  360. X            case TERM_HP:    /* HEWLETT-PACKARD Terminals (2392,700/9x etc) */
  361. X                delim = ';';
  362. X                break;
  363. X    
  364. X            case TERM_VT2:    /* DEC VT220 / 320 */
  365. X            case TERM_VT3:
  366. X            case TERM_PCVT:
  367. X                delim = 'q';
  368. X                break;
  369. X    
  370. X            default:    /* everything else */
  371. X                delim = DEFDELIMCH;
  372. X                break;
  373. X        }
  374. X    }
  375. X    else
  376. X    {
  377. X        delim = DEFDELIMCH;
  378. X    }
  379. X        
  380. X    while(i--)
  381. X        addch(delim);
  382. X
  383. X    if(enter_alt_charset_mode && exit_alt_charset_mode &&
  384. X           *enter_alt_charset_mode && *exit_alt_charset_mode && !opt_delimiter)
  385. X        attroff(A_ALTCHARSET);
  386. X}    
  387. X
  388. X/*---------------------------------------------------------------------------*
  389. X *    enter a string into a string variable
  390. X *---------------------------------------------------------------------------*/
  391. Xstatic char *enter_string(int row, int col, char *string, int length)
  392. X{
  393. X    static char buffer[81];
  394. X    int ccol, c;
  395. X
  396. X    strcpy(buffer, string);
  397. X    ccol = strlen(buffer);
  398. X
  399. X    for(;;)
  400. X    {
  401. X        mvaddstr(row, col, buffer);
  402. X        clrtoeol();
  403. X        
  404. X        refresh();
  405. X
  406. X        c = getch();    
  407. X
  408. X        if(c == bschar)
  409. X        {
  410. X            if(ccol > 0)
  411. X            {
  412. X                ccol--;
  413. X                buffer[ccol] = '\0';
  414. X            }
  415. X            continue;
  416. X        }
  417. X
  418. X        switch(c)
  419. X        {
  420. X            case CR:
  421. X                return(buffer);
  422. X                
  423. X            case ESC:
  424. X                return(NULL);
  425. X                
  426. X            case CNTRL_L:    /* refresh */
  427. X                touchwin(curscr);
  428. X                wrefresh(curscr);
  429. X                break;
  430. X
  431. X            default:
  432. X                if(ccol < length)
  433. X                {
  434. X                    buffer[ccol++] = c;
  435. X                    buffer[ccol] = '\0';
  436. X                }
  437. X                else
  438. X                {
  439. X                    flash();
  440. X                }
  441. X                break;
  442. X        }
  443. X    }
  444. X}
  445. X
  446. X/*----------------------- E O F -------------------------------------------*/
  447. END_OF_FILE
  448.   if test 8688 -ne `wc -c <'config.c'`; then
  449.     echo shar: \"'config.c'\" unpacked with wrong size!
  450.   fi
  451.   # end of 'config.c'
  452. fi
  453. if test -f 'files.c' -a "${1}" != "-c" ; then 
  454.   echo shar: Will not clobber existing file \"'files.c'\"
  455. else
  456.   echo shar: Extracting \"'files.c'\" \(8501 characters\)
  457.   sed "s/^X//" >'files.c' <<'END_OF_FILE'
  458. X/*---------------------------------------------------------------------------*
  459. X *
  460. X *                  wish - windowing user friendly shell
  461. X *                 --------------------------------------
  462. X *
  463. X *              (c) Copyright Hellmuth Michaelis 1989 - 1993
  464. X *
  465. X *                  Eggerstedtstr. 28
  466. X *                  22765 Hamburg
  467. X *                  Germany
  468. X *
  469. X *                  Tel:    +49 / 40 / 384298    (private)
  470. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  471. X *                  e-mail: hm@hcshh.hcs.de
  472. X *
  473. X *           All rights are reserved except as explicitly granted
  474. X *                  by written permission of the author.
  475. X *
  476. X *             See the file COPYING, distributed with wish, for
  477. X *                  restriction and warranty information
  478. X *
  479. X *---------------------------------------------------------------------------*
  480. X *
  481. X *    Last Edit-Date: [Mon Aug 30 11:34:16 1993]
  482. X *
  483. X *    -hm    conversion to curses
  484. X *    -hm    new sorting order
  485. X *    -hm    displaying file count
  486. X *    -hm    optimizing .....
  487. X *    -hm    wildcard filenames
  488. X *    -hm    cdrom processing option
  489. X *    -hm    cdrom programs to files option
  490. X *
  491. X *----------------------------------------------------------------------------*/
  492. X
  493. X#include "wish.h"        /* global include file */
  494. X
  495. X#ifndef __386BSD__
  496. X#include <sys/vfs.h>
  497. X#endif
  498. X#include <sys/mount.h>
  499. X
  500. Xstatic int  pia[] = {S_IFDIR,S_IREAD,S_IWRITE,S_IEXEC,040,020,010,04,02,01};
  501. Xstatic char pca[] = "drwxrwxrwx";
  502. X
  503. X/*---------------------------------------------------------------------------*
  504. X *    create a doubly linked list in sorted order, return pointer to new
  505. X *    first element of list
  506. X *---------------------------------------------------------------------------*/
  507. Xstruct onefile *store
  508. X(register struct onefile *new,    /* new entry to store into list */
  509. X register struct onefile *top)    /* current first entry in list */
  510. X{
  511. X    register struct onefile *old,*p;
  512. X    
  513. X    if(last == NULL)    /* enter very first element ? */
  514. X    {
  515. X        new->next = NULL;
  516. X        new->prev = NULL;
  517. X        last = new;    /* init last */
  518. X        return(new);    /* return new first */
  519. X    }
  520. X    p = top;        /* p = old first element */
  521. X    old = NULL;
  522. X    while(p)
  523. X    {
  524. X        if((strcmp(p->onam,new->onam)) < 0)    /* current less new ? */
  525. X        {
  526. X            old = p;
  527. X            p = p->next;
  528. X        }
  529. X        else
  530. X        {    /* current >= new */
  531. X        
  532. X            if(p->prev)
  533. X            {
  534. X                p->prev->next = new;
  535. X                new->next = p;
  536. X                new->prev = p->prev;
  537. X                p->prev = new;
  538. X                return(top);
  539. X            }
  540. X            new->next = p;
  541. X            new->prev = NULL;
  542. X            p->prev = new;
  543. X            return(new);
  544. X        }
  545. X    }
  546. X    old->next = new;
  547. X    new->next = NULL;
  548. X    new->prev = old;
  549. X    last = new;
  550. X    return(first);
  551. X}
  552. X
  553. X/*---------------------------------------------------------------------------*
  554. X *    read current directory and build up a doubly linked sorted list
  555. X *---------------------------------------------------------------------------*/
  556. Xint fill_list(void)
  557. X{
  558. X    register struct direct *dp;
  559. X    register struct onefile *new_entry;
  560. X    register int j;
  561. X    register struct tm *tp;
  562. X    register DIR *dirp;
  563. X    
  564. X    static struct stat fdbuffer;
  565. X    static char templine[MAXPATHLEN+2];
  566. X
  567. X    int templeng;
  568. X    int flcnt = 0;
  569. X    int sret;
  570. X
  571. X    maxfnleng = 0;        /* init global variables */    
  572. X
  573. X    iscdfs = 0;        /* no cdrom filesys */
  574. X    
  575. X    if(opt_cdrom)
  576. X    {
  577. X        struct statfs statfsb;
  578. X#ifndef __386BSD__
  579. X    /* the 386BSD way, this also seems to work for SunOS 4.1.x */
  580. X        if((statfs(".", &statfsb)==0) && (statfsb.f_fsid[1]==MOUNT_CDFS))
  581. X#else
  582. X    /* the HPUX way ... */
  583. X        if((statfs(".", &statfsb)==0) && (statfsb.f_type==MOUNT_ISOFS))
  584. X#endif        
  585. X            iscdfs = 1;
  586. X    }
  587. X        
  588. X    if((dirp = opendir(".")) == NULL)
  589. X        return(-1);    /* cannot open directory */
  590. X
  591. X    for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
  592. X    {
  593. X          flcnt++;            /* increment file count */
  594. X
  595. X         if(!opt_point)            /* display dot ? */
  596. X         {
  597. X            if((*(dp->d_name) == '.') && (*(dp->d_name+1) == '\0'))
  598. X                continue;
  599. X        }
  600. X
  601. X        if(!opt_dotnames)        /* display dot-names ? */
  602. X        {
  603. X            if((*(dp->d_name) == '.') && (*(dp->d_name+1) != '.') && (*(dp->d_name+1) != '\0'))
  604. X                continue;
  605. X        }
  606. X        
  607. X        if((new_entry = (struct onefile *) malloc(sizeof(struct onefile))) == NULL)
  608. X        {
  609. X            closedir(dirp);        /* clean up */
  610. X            return(-2);        /* out of memory */
  611. X        }
  612. X
  613. X        new_entry->oislnk = 0;        /* no link yet */
  614. X        
  615. X        if(opt_links)            /* detect links ? */
  616. X        {
  617. X            sret = 0;        /* init return */
  618. X
  619. X            if((lstat(dp->d_name, &fdbuffer)) < 0)
  620. X            {
  621. X                free(new_entry);    /* lstat failed */
  622. X                continue;        /* next one .. */
  623. X            }
  624. X
  625. X            if(S_ISLNK(fdbuffer.st_mode))    /* have a link ? */
  626. X            {
  627. X                new_entry->oislnk = 1;    /* mark as link */
  628. X                sret = stat(dp->d_name, &fdbuffer); /* and get status */
  629. X            }
  630. X        }
  631. X        else
  632. X        {
  633. X            sret = stat(dp->d_name, &fdbuffer);    /* get status */
  634. X        }
  635. X
  636. X        if(sret < 0)            /* return from stat bad ? */
  637. X        {
  638. X            free(new_entry);    /* next entry ... */
  639. X            continue;
  640. X        }
  641. X        else    /* got status, fill in from stat buffer */
  642. X        {
  643. X            /* size, userid & groupid */
  644. X            
  645. X            new_entry->osiz = fdbuffer.st_size;
  646. X            new_entry->ousr = fdbuffer.st_uid;
  647. X            new_entry->ogrp = fdbuffer.st_gid;
  648. X
  649. X            /* permissions */
  650. X            
  651. X            for(j=0;j<10;j++)
  652. X            {
  653. X                if(fdbuffer.st_mode & pia[j])
  654. X                    new_entry->oprm[j] = pca[j];
  655. X                else
  656. X                    new_entry->oprm[j] = '-';
  657. X            }
  658. X            new_entry->oprm[j] = '\0';
  659. X            
  660. X            /* type of file -> templine[0] */
  661. X            
  662. X            if(S_ISREG(fdbuffer.st_mode))
  663. X            {
  664. X                if(opt_wildon && (wildmat(dp->d_name, opt_wild) != TRUE))
  665. X                {
  666. X                    free(new_entry);
  667. X                    continue;
  668. X                }
  669. X                new_entry->oprm[0] = '-';
  670. X                if((new_entry->oprm[3] == 'x') ||
  671. X                           (new_entry->oprm[6] == 'x') ||
  672. X                           (new_entry->oprm[9] == 'x'))
  673. X                        {
  674. X                            if(iscdfs && opt_cdnoprog)
  675. X                            {
  676. X                        new_entry->oprm[3] = '-';
  677. X                                new_entry->oprm[6] = '-';
  678. X                        new_entry->oprm[9] = '-';
  679. X                        templine[0] = ISDATA;
  680. X                    }
  681. X                    else
  682. X                    {
  683. X                                   templine[0] = ISPROG;
  684. X                            }
  685. X                        }
  686. X                else
  687. X                    templine[0] = ISDATA;
  688. X                if((fdbuffer.st_mode & S_IFMT) == S_ISUID)
  689. X                    new_entry->oprm[3] = 's';
  690. X                if((fdbuffer.st_mode & S_IFMT) == S_ISGID)
  691. X                    new_entry->oprm[6] = 's';
  692. X            }
  693. X            else if(S_ISDIR(fdbuffer.st_mode))
  694. X            {
  695. X                if(opt_wildon)
  696. X                {
  697. X                    flcnt--;
  698. X                }
  699. X                templine[0] = ISDIR;
  700. X                new_entry->oprm[0] = 'd';
  701. X            }
  702. X            else if(S_ISCHR(fdbuffer.st_mode))
  703. X            {            
  704. X                if(opt_wildon && (wildmat(dp->d_name, opt_wild) != TRUE))
  705. X                {
  706. X                    free(new_entry);
  707. X                    continue;
  708. X                }
  709. X                templine[0] = ISCHAR;
  710. X                new_entry->oprm[0] = 'c';
  711. X            }
  712. X            else if(S_ISBLK(fdbuffer.st_mode))
  713. X            {
  714. X                if(opt_wildon && (wildmat(dp->d_name, opt_wild) != TRUE))
  715. X                {
  716. X                    free(new_entry);
  717. X                    continue;
  718. X                }
  719. X                templine[0] = ISBLOCK;
  720. X                new_entry->oprm[0] = 'b';
  721. X            }
  722. X            else if(S_ISFIFO(fdbuffer.st_mode))
  723. X            {
  724. X                if(opt_wildon && (wildmat(dp->d_name, opt_wild) != TRUE))
  725. X                {
  726. X                    free(new_entry);
  727. X                    continue;
  728. X                }
  729. X                templine[0] = ISPIPE;
  730. X                new_entry->oprm[0] = 'p';
  731. X            }
  732. X            else if(S_ISSOCK(fdbuffer.st_mode))
  733. X            {
  734. X                if(opt_wildon && (wildmat(dp->d_name, opt_wild) != TRUE))
  735. X                {
  736. X                    free(new_entry);
  737. X                    continue;
  738. X                }
  739. X                templine[0] = ISSOCK;
  740. X                new_entry->oprm[0] = 'n';
  741. X            }
  742. X            else
  743. X            {
  744. X                if(opt_wildon && (wildmat(dp->d_name, opt_wild) != TRUE))
  745. X                {
  746. X                    free(new_entry);
  747. X                    continue;
  748. X                }
  749. X                templine[0] = ISUNKN; /* unknown */
  750. X                new_entry->oprm[0] = 'u';
  751. X            }
  752. X            templine[1] = '\0'; /* terminate templine */
  753. X
  754. X            /* file time */
  755. X            
  756. X            tp = localtime(&(fdbuffer.st_mtime));
  757. X            sprintf(new_entry->odat,"%02d-%02d-%02d %02d:%02d",
  758. X                tp->tm_mday,(tp->tm_mon)+1,tp->tm_year,
  759. X                tp->tm_hour,tp->tm_min);
  760. X            
  761. X            new_entry->tag = 0;    /* clear tag-field */
  762. X            new_entry->page = -1;    /* page # unknown */
  763. X
  764. X            /* new max filename length */
  765. X            
  766. X            templeng = strlen(dp->d_name);    /* get name length */
  767. X            if(templeng > maxfnleng)    /* new max filename length ? */
  768. X                maxfnleng = templeng;    /* yes */
  769. X
  770. X            /* cat templine + filename */
  771. X
  772. X            strcat(templine, dp->d_name);    /* file name */
  773. X
  774. X            strcpy(new_entry->onam, templine);    
  775. X
  776. X            /* sort entry into linked list */
  777. X            
  778. X            first = store(new_entry,first);
  779. X        }
  780. X    }
  781. X    closedir(dirp);                /* close current dir */
  782. X    sprintf(counter,"%4d",flcnt);        /* entries counter */
  783. X    return(0);                /* ok return */
  784. X}
  785. X
  786. X/*---------------------------------------------------------------------------*
  787. X *    free the current malloc'ed list
  788. X *---------------------------------------------------------------------------*/
  789. Xvoid free_list(void)
  790. X{
  791. X    struct onefile *dir;
  792. X    struct onefile *tmp;        
  793. X
  794. X    dir = first;
  795. X
  796. X    while(dir)
  797. X    {
  798. X
  799. X        tmp = dir->next;
  800. X        free(dir);
  801. X        dir = tmp;
  802. X    }
  803. X    first = NULL;
  804. X    last = NULL;
  805. X    maxfnleng = 0;
  806. X}
  807. X/*---------------------------------- EOF -------------------------------------*/
  808. END_OF_FILE
  809.   if test 8501 -ne `wc -c <'files.c'`; then
  810.     echo shar: \"'files.c'\" unpacked with wrong size!
  811.   fi
  812.   # end of 'files.c'
  813. fi
  814. if test -f 'movement.c' -a "${1}" != "-c" ; then 
  815.   echo shar: Will not clobber existing file \"'movement.c'\"
  816. else
  817.   echo shar: Extracting \"'movement.c'\" \(6360 characters\)
  818.   sed "s/^X//" >'movement.c' <<'END_OF_FILE'
  819. X/*---------------------------------------------------------------------------*
  820. X *
  821. X *                  wish - windowing user friendly shell
  822. X *                  ------------------------------------
  823. X *
  824. X *               Copyright (c) 1988-1993 Hellmuth Michaelis
  825. X *
  826. X *                  Eggerstedtstr. 28
  827. X *                  22765 Hamburg
  828. X *                  Germany
  829. X *
  830. X *                  Tel:    +49 / 40 / 384298    (private)
  831. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  832. X *                  e-mail: hm@hcshh.hcs.de
  833. X *
  834. X *                          --------oOo--------
  835. X *
  836. X *   This program is free software; you can redistribute it and/or modify
  837. X *   it under the terms of the GNU General Public License as published by
  838. X *   the Free Software Foundation; either version 2 of the License, or
  839. X *   (at your option) any later version.
  840. X *
  841. X *   This program is distributed in the hope that it will be useful,
  842. X *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  843. X *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  844. X *   GNU General Public License for more details.
  845. X *
  846. X *   You should have received a copy of the GNU General Public License
  847. X *   along with this program; if not, write to the Free Software
  848. X *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  849. X *
  850. X *---------------------------------------------------------------------------*
  851. X *
  852. X *    Last Edit-Date: [Mon Aug 30 19:51:19 1993]
  853. X *
  854. X *    -hm    conversion to curses
  855. X *    -hm    rewrite to not look at filetype anymore
  856. X *    -hm    consistent up/down and left/right moves
  857. X *
  858. X *----------------------------------------------------------------------------*/
  859. X
  860. X#include "wish.h"
  861. X
  862. Xstatic int iscurpag(void);
  863. X
  864. X/*---------------------------------------------------------------------------*
  865. X *    return true if filename is on current displayed page
  866. X *---------------------------------------------------------------------------*/
  867. Xstatic int iscurpag(void)
  868. X{
  869. X    return(((cur_file->page) & PAGEMASK) == cur_page );
  870. X}
  871. X
  872. X/*---------------------------------------------------------------------------*
  873. X *    move current file to first file on page
  874. X *---------------------------------------------------------------------------*/
  875. Xint firstfile(void)
  876. X{
  877. X    cur_file = scr_beg;
  878. X
  879. X    for(;;)
  880. X    {
  881. X        if(iscurpag())
  882. X            return(GOOD);
  883. X        else if(cur_file->next == NULL)
  884. X            return(BAD);
  885. X        else
  886. X            cur_file = cur_file->next;
  887. X    }
  888. X}
  889. X
  890. X/*---------------------------------------------------------------------------*
  891. X *    move current file to last file on page
  892. X *---------------------------------------------------------------------------*/
  893. Xint lastfile(void)
  894. X{
  895. X    cur_file = scr_beg;    /* start of screen */
  896. X    
  897. X    for(;;)
  898. X    {
  899. X        if(cur_file->next == NULL)
  900. X            break;
  901. X        if((cur_file->next->page) == ((cur_page + 1) | FIRST))
  902. X            break;
  903. X        cur_file = cur_file->next;
  904. X    }
  905. X    for(;;)
  906. X    {
  907. X        if(iscurpag())
  908. X            return(GOOD);
  909. X        else if(cur_file->prev == NULL)
  910. X            return(BAD);
  911. X        else
  912. X            cur_file = cur_file->prev;
  913. X    }
  914. X}
  915. X
  916. X/*---------------------------------------------------------------------------*
  917. X *    move current file to next file on page
  918. X *---------------------------------------------------------------------------*/
  919. Xint nextfile(void)
  920. X{
  921. X    for(;;)
  922. X    {
  923. X        if(cur_file->next == NULL)
  924. X            return(BAD);
  925. X        cur_file = cur_file->next;
  926. X        if(iscurpag())
  927. X            return(GOOD);
  928. X    }
  929. X}
  930. X        
  931. X/*---------------------------------------------------------------------------*
  932. X *    move current file to previous file on page
  933. X *---------------------------------------------------------------------------*/
  934. Xint prevfile(void)
  935. X{
  936. X    for(;;)
  937. X    {
  938. X        if(cur_file->prev == NULL)
  939. X            return(BAD);
  940. X        cur_file = cur_file->prev;
  941. X        if(iscurpag())
  942. X            return(GOOD);
  943. X    }
  944. X}
  945. X
  946. X/*---------------------------------------------------------------------------*
  947. X *    move highlighted file to first file on page
  948. X *---------------------------------------------------------------------------*/
  949. Xvoid move_home(void)
  950. X{
  951. X    cur_norm(cur_file);
  952. X    firstfile();
  953. X    cur_inv(cur_file);
  954. X}
  955. X
  956. X/*---------------------------------------------------------------------------*
  957. X *    move highlighted file to last file on page
  958. X *---------------------------------------------------------------------------*/
  959. Xvoid move_hmdn(void)
  960. X{
  961. X    cur_norm(cur_file);
  962. X    lastfile();
  963. X    cur_inv(cur_file);
  964. X}
  965. X
  966. X/*---------------------------------------------------------------------------*
  967. X *    move highlighted file one pos right, wrapping on end
  968. X *---------------------------------------------------------------------------*/
  969. Xvoid move_right(void)
  970. X{
  971. X    cur_norm(cur_file);
  972. X    if(nextfile() == BAD)
  973. X        firstfile();
  974. X    cur_inv(cur_file);
  975. X}
  976. X
  977. X/*---------------------------------------------------------------------------*
  978. X *    move highlighted file one pos left, wrapping on begin
  979. X *---------------------------------------------------------------------------*/
  980. Xvoid move_left(void)
  981. X{
  982. X    cur_norm(cur_file);
  983. X    if(prevfile() == BAD)
  984. X        lastfile();
  985. X    cur_inv(cur_file);
  986. X}
  987. X
  988. X/*---------------------------------------------------------------------------*
  989. X *    move highlighted file one pos up, wrapping on top
  990. X *---------------------------------------------------------------------------*/
  991. Xvoid move_up(void)
  992. X{
  993. X    struct onefile *save_cur;
  994. X    int upcol;
  995. X    
  996. X    save_cur = cur_file;    /* fail safe */
  997. X    
  998. X    upcol = cur_file->ocol;    /* current column */
  999. X    
  1000. X    if(first != NULL)
  1001. X    {
  1002. X        cur_norm(cur_file);
  1003. X
  1004. X        while(prevfile() != BAD)
  1005. X        {
  1006. X            if(cur_file->ocol == upcol)
  1007. X                goto upfound;
  1008. X        }
  1009. X        if(lastfile() != BAD)
  1010. X        {
  1011. X            do
  1012. X            {
  1013. X                if(cur_file->ocol == upcol)
  1014. X                    goto upfound;
  1015. X            }
  1016. X            while(prevfile() != BAD);
  1017. X        }
  1018. X    }
  1019. X    cur_file = save_cur;    /* not found, no change ! */
  1020. X
  1021. Xupfound:
  1022. X    cur_inv(cur_file);
  1023. X}
  1024. X
  1025. X/*---------------------------------------------------------------------------*
  1026. X *    move highlighted file one pos down, wrapping on bottom
  1027. X *---------------------------------------------------------------------------*/
  1028. Xvoid move_down(void)
  1029. X{
  1030. X    struct onefile *save_cur;
  1031. X    int downcol;
  1032. X    
  1033. X    save_cur = cur_file;    /* fail safe */
  1034. X    
  1035. X    downcol = cur_file->ocol;    /* current column */
  1036. X    
  1037. X    if(first != NULL)
  1038. X    {
  1039. X        cur_norm(cur_file);
  1040. X
  1041. X        while(nextfile() != BAD)
  1042. X        {
  1043. X            if(cur_file->ocol == downcol)
  1044. X                goto downfound;
  1045. X        }
  1046. X        if(firstfile() != BAD)
  1047. X        {
  1048. X            do
  1049. X            {
  1050. X                if(cur_file->ocol == downcol)
  1051. X                    goto downfound;
  1052. X            }
  1053. X            while(nextfile() != BAD);
  1054. X        }
  1055. X    }
  1056. X    cur_file = save_cur;    /* not found, no change ! */
  1057. X    
  1058. Xdownfound:
  1059. X    cur_inv(cur_file);
  1060. X}
  1061. X
  1062. X/*---------------------------------- EOF -------------------------------------*/
  1063. X
  1064. END_OF_FILE
  1065.   if test 6360 -ne `wc -c <'movement.c'`; then
  1066.     echo shar: \"'movement.c'\" unpacked with wrong size!
  1067.   fi
  1068.   # end of 'movement.c'
  1069. fi
  1070. if test -f 'paging.c' -a "${1}" != "-c" ; then 
  1071.   echo shar: Will not clobber existing file \"'paging.c'\"
  1072. else
  1073.   echo shar: Extracting \"'paging.c'\" \(14185 characters\)
  1074.   sed "s/^X//" >'paging.c' <<'END_OF_FILE'
  1075. X/*---------------------------------------------------------------------------*
  1076. X *
  1077. X *                  wish - windowing user friendly shell
  1078. X *                  ------------------------------------
  1079. X *
  1080. X *               Copyright (c) 1988-1993 Hellmuth Michaelis
  1081. X *
  1082. X *                  Eggerstedtstr. 28
  1083. X *                  22765 Hamburg
  1084. X *                  Germany
  1085. X *
  1086. X *                  Tel:    +49 / 40 / 384298    (private)
  1087. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  1088. X *                  e-mail: hm@hcshh.hcs.de
  1089. X *
  1090. X *                          --------oOo--------
  1091. X *
  1092. X *   This program is free software; you can redistribute it and/or modify
  1093. X *   it under the terms of the GNU General Public License as published by
  1094. X *   the Free Software Foundation; either version 2 of the License, or
  1095. X *   (at your option) any later version.
  1096. X *
  1097. X *   This program is distributed in the hope that it will be useful,
  1098. X *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1099. X *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1100. X *   GNU General Public License for more details.
  1101. X *
  1102. X *   You should have received a copy of the GNU General Public License
  1103. X *   along with this program; if not, write to the Free Software
  1104. X *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1105. X *
  1106. X *---------------------------------------------------------------------------*
  1107. X *
  1108. X *    Last Edit-Date: [Mon Aug 30 19:51:35 1993]
  1109. X *
  1110. X *    -hm    conversion to curses
  1111. X *    -hm    multiple windows
  1112. X *    -hm    debugging paging routines
  1113. X *    -hm    hpux 9.0 zero pointers ...
  1114. X *    -hm    housekeeping
  1115. X *
  1116. X *----------------------------------------------------------------------------*/
  1117. X
  1118. X#include "wish.h"
  1119. X
  1120. Xstatic char curpath[MAXPATHLEN+1];    /* current path buffer normalized for screen */
  1121. Xstatic int lastpage;            /* number of last page */
  1122. X
  1123. Xstatic void make_cpath();        /* get & format current directory */
  1124. Xstatic void dis_cpath(int init);    /* print current directory & entries */
  1125. Xstatic void new_stops();
  1126. Xstatic void dis_init(struct onefile *);
  1127. Xstatic void dis_play(struct onefile *);
  1128. Xstatic void show_blip(void);
  1129. X
  1130. X/*---------------------------------------------------------------------------*
  1131. X *    get & format current directory for display
  1132. X *---------------------------------------------------------------------------*/
  1133. Xstatic void make_cpath(void)
  1134. X{
  1135. X    int i,j,width;
  1136. X    
  1137. X    if((getcwd(curpath, MAXPATHLEN)) == NULL)
  1138. X    {
  1139. X        error("internal getwcd() error, chdir to HOME");
  1140. X        if((chdir(envhome)) == -1)
  1141. X            fatal("cannot chdir() to HOME");
  1142. X        if((getcwd(curpath, MAXPATHLEN)) == NULL)
  1143. X            fatal("twotimes internal getcwd() error");
  1144. X    }
  1145. X
  1146. X    strcpy(cur_path,curpath);    /* for program execution */
  1147. X    
  1148. X    width = COLS-CURDIRW-(ENTRYSW+ENTRYCW);
  1149. X    i = strlen(curpath);
  1150. X    if(i > width)
  1151. X    {
  1152. X        j = 0;
  1153. X        i = i - width + 4;
  1154. X        while(curpath[i++] != '/')
  1155. X            ;
  1156. X        curpath[j++] = '.';
  1157. X        curpath[j++] = '.';
  1158. X        curpath[j++] = '.';
  1159. X        curpath[j++] = ' ';
  1160. X        i--;
  1161. X        while(curpath[i])
  1162. X            curpath[j++] = curpath[i++];
  1163. X        curpath[j++] = '\0';
  1164. X    }
  1165. X}                
  1166. X
  1167. X/*---------------------------------------------------------------------------*
  1168. X *    print current directory & entries
  1169. X *---------------------------------------------------------------------------*/
  1170. Xstatic void dis_cpath(int init)
  1171. X{
  1172. X    static int p_init = 1;
  1173. X    int i;
  1174. X    
  1175. X    if(p_init || init)
  1176. X    {
  1177. X        wmove   (fst_w, 0, 0);        /* move to dir string */
  1178. X        wattron (fst_w, A_UNDERLINE);    /* underline on */
  1179. X        waddstr (fst_w, "Directory:");    /* description */
  1180. X        wattroff(fst_w, A_UNDERLINE);    /* end underline */
  1181. X    }
  1182. X    wmove   (fst_w, 0, CURDIRW);
  1183. X    waddstr (fst_w, curpath);        /* print current path */
  1184. X
  1185. X    i = CURDIRW + strlen(curpath);
  1186. X    
  1187. X    while(i++ < COLS-ENTRYSW-ENTRYCW)
  1188. X        waddch(fst_w, SPACE);
  1189. X
  1190. X    if(p_init || init)
  1191. X    {
  1192. X        wmove   (fst_w, 0, COLS-ENTRYSW-ENTRYCW); /* move to entries string */
  1193. X        wattron (fst_w, A_UNDERLINE);    /* underline on */
  1194. X        if(opt_wildon)
  1195. X            waddstr (fst_w, "Matches:");    /* description */
  1196. X        else
  1197. X            waddstr (fst_w, "Entries:");    /* description */
  1198. X        wattroff(fst_w, A_UNDERLINE);    /* underline off */
  1199. X        p_init = 0;
  1200. X    }
  1201. X
  1202. X    wmove   (fst_w, 0, COLS-ENTRYCW);    /* move to entries string */
  1203. X    waddstr (fst_w, counter);        /* print current path */
  1204. X}
  1205. X
  1206. X/*---------------------------------------------------------------------------*
  1207. X *    calculate new "tab" stops for filename display
  1208. X *---------------------------------------------------------------------------*/
  1209. Xstatic void new_stops(void)
  1210. X{
  1211. X    int j = STARTCOL;        /* start value */
  1212. X    int maxcol = 0;            /* global no of cols */
  1213. X    
  1214. X    while(maxcol < STOPS)
  1215. X    {
  1216. X        stops[maxcol++] = j;    /* set stop point */
  1217. X        j += MINSPACE;        /* add minimum space count between names */
  1218. X        j += maxfnleng;        /* and next filename's length */
  1219. X        if((j + MINSPACE + maxfnleng) > COLS)
  1220. X        {
  1221. X            stops[maxcol] = 0;    /* end marker */
  1222. X            break;            /* leave loop */
  1223. X        }
  1224. X    }
  1225. X}    
  1226. X
  1227. X/*---------------------------------------------------------------------------*
  1228. X *    display next file page (if any) in file window
  1229. X *---------------------------------------------------------------------------*/
  1230. Xvoid next_page(void)
  1231. X{
  1232. X    if(cur_page >= lastpage)    /* already on last page ? */
  1233. X        return;            /* yes, leave .. */
  1234. X        
  1235. X    wclear(file_w);            /* clear current window */
  1236. X    dis_cpath(0);            /* current path & entries */
  1237. X
  1238. X    for(;;)
  1239. X    {
  1240. X        if((cur_file->page & PAGEMASK) == ((cur_page+1) & PAGEMASK))
  1241. X            break;
  1242. X        if(cur_file->next != NULL)
  1243. X            cur_file = cur_file->next;    /* next entry */
  1244. X        else
  1245. X            break;
  1246. X    }
  1247. X
  1248. X    cur_page = cur_file->page & PAGEMASK;
  1249. X    
  1250. X    scr_beg = cur_file;
  1251. X    scr_end = cur_file;
  1252. X
  1253. X    dis_play(cur_file);        /* display directories */
  1254. X    show_blip();
  1255. X    cur_inv(cur_file);
  1256. X}
  1257. X
  1258. X/*---------------------------------------------------------------------------*
  1259. X *    display previous file page (if any) in file window
  1260. X *---------------------------------------------------------------------------*/
  1261. Xvoid prev_page(void)
  1262. X{
  1263. X    if(cur_page <= 0)        /* is there a previous page ? */
  1264. X        return;            /* no, return */
  1265. X
  1266. X    wclear(file_w);            /* clear current window */
  1267. X    dis_cpath(0);            /* display current path & entries */
  1268. X    
  1269. X    cur_file = first;
  1270. X
  1271. X    for(;;)    
  1272. X    {
  1273. X        if((cur_file->page & PAGEMASK) == ((cur_page-1) & PAGEMASK))
  1274. X            break;
  1275. X        if(cur_file->next != NULL)
  1276. X            cur_file = cur_file->next;    /* next entry */
  1277. X        else
  1278. X            break;
  1279. X    }
  1280. X
  1281. X    cur_page = cur_file->page & PAGEMASK;
  1282. X    
  1283. X    scr_beg = cur_file;
  1284. X    scr_end = cur_file;
  1285. X    
  1286. X    dis_play(cur_file);        /* display directories */
  1287. X    show_blip();
  1288. X    cur_inv(cur_file);
  1289. X}
  1290. X
  1291. X/*---------------------------------------------------------------------------*
  1292. X *    re-fill/refresh file window with data for current dir
  1293. X *---------------------------------------------------------------------------*/
  1294. Xvoid fresh_files(void) 
  1295. X{
  1296. X    scr_end = scr_beg;        /* init */
  1297. X    wclear(file_w);            /* clear current window */
  1298. X    dis_cpath(1);            /* display current path */
  1299. X    dis_play(scr_beg);        /* display directories */
  1300. X    show_blip();            /* show more indicator */
  1301. X    cur_inv(cur_file);        /* highlight old */
  1302. X}
  1303. X
  1304. X/*---------------------------------------------------------------------------*
  1305. X *    initialize the file diaply window
  1306. X *---------------------------------------------------------------------------*/
  1307. Xvoid init_files(int preserve, char *dirname)
  1308. X{
  1309. X    char filename[MAXPATHLEN];
  1310. X    int page;
  1311. X    int row;
  1312. X    int col;
  1313. X
  1314. X    if(cur_file != NULL)
  1315. X    {
  1316. X        cur_blink(cur_file);    /* blink current file while reading */
  1317. X        wrefresh(file_w);    /* update blinking */
  1318. X        page = cur_file->page & PAGEMASK;
  1319. X        row = cur_file->orow;
  1320. X        col = cur_file->ocol;
  1321. X    }
  1322. X    else
  1323. X    {
  1324. X        page = row = col = 0;
  1325. X    }
  1326. X    
  1327. X    if(preserve == PRES_NORM)
  1328. X    {
  1329. X        strcpy(filename, cur_file->onam);
  1330. X        page = cur_file->page & PAGEMASK;
  1331. X        row = cur_file->orow;
  1332. X        col = cur_file->ocol;
  1333. X    }
  1334. X    else if(preserve == PRES_DD)
  1335. X    {
  1336. X        if(dirname != NULL && *dirname && opt_preserve)
  1337. X        {
  1338. X            char *ptr;
  1339. X
  1340. X            if((ptr = (char *)rindex(dirname, '/')) == NULL)
  1341. X            {
  1342. X                preserve = PRES_NO;
  1343. X            }
  1344. X            else if(*dirname)
  1345. X            {
  1346. X                ptr++;
  1347. X                strcpy(filename, ptr);
  1348. X                page = 0;
  1349. X                row = 0;
  1350. X                col = 0;
  1351. X            }
  1352. X            else
  1353. X            {
  1354. X                preserve = PRES_NO;
  1355. X            }
  1356. X        }
  1357. X        else
  1358. X        {
  1359. X            preserve = PRES_NO;
  1360. X        }
  1361. X    }
  1362. X    
  1363. X    cur_page = 0;            /* file display page 0 */
  1364. X    make_cpath();            /* format current dir */
  1365. X    
  1366. X    if(fill_list() != 0)        /* get directory data into list */
  1367. X    {
  1368. X        if(first != NULL)    /* if any malloced space ... */
  1369. X            free_list();    /* FREE IT !!! */
  1370. X        return;            /* return with error */
  1371. X    }
  1372. X
  1373. X    dis_cpath(1);            /* display current path */
  1374. X    new_stops();            /* compute new stops-table */
  1375. X    cur_file = first;        /* current file is first */
  1376. X    scr_beg = first;        /* first filename on display */
  1377. X    scr_end = first;        /* last filename on display */
  1378. X    wclear(file_w);            /* clear current window */
  1379. X    
  1380. X    while(cur_file != NULL)        /* init whole list */
  1381. X    {
  1382. X        dis_init(cur_file);    /* page init directories */
  1383. X        cur_page++;        /* next page */
  1384. X        cur_file = scr_end->next;    /* new pointer */
  1385. X        scr_beg = cur_file;    /* new screen start */
  1386. X    }
  1387. X    lastpage = cur_page-1;        /* init last page no. */
  1388. X    cur_page = 0;            /* file display page 0 */
  1389. X    cur_file = first;        /* current file is first */
  1390. X    scr_beg = first;        /* first filename on display */
  1391. X    scr_end = first;        /* last filename on display */
  1392. X
  1393. X    if(preserve == PRES_NORM || preserve == PRES_DD)
  1394. X    {
  1395. X        int found = 0;
  1396. X        int length = strlen(filename);
  1397. X        struct onefile *last_file = cur_file;
  1398. X    
  1399. X        while(!found)
  1400. X        {
  1401. X            if(preserve == PRES_NORM)
  1402. X            {
  1403. X                if(!(strncmp(filename,last_file->onam,length)))
  1404. X                {
  1405. X                    found = 1;
  1406. X                    break;
  1407. X                }
  1408. X            }
  1409. X            else if(preserve == PRES_DD)
  1410. X            {
  1411. X                if(!(strncmp(filename,&(last_file->onam[1]),length)))
  1412. X                {
  1413. X                    found = 1;
  1414. X                    break;
  1415. X                }
  1416. X            }
  1417. X            
  1418. X            if(last_file->next)
  1419. X                last_file = last_file->next;
  1420. X            else
  1421. X                break;
  1422. X        }
  1423. X        if(found)
  1424. X        {
  1425. X            page = ((last_file->page) & PAGEMASK);
  1426. X            row = last_file->orow;
  1427. X            col = last_file->ocol;
  1428. X        }
  1429. X        if(page > lastpage)
  1430. X            page = lastpage;
  1431. X        
  1432. X        for(;;)
  1433. X        {
  1434. X            if((cur_file->page & PAGEMASK) == (page & PAGEMASK))
  1435. X                break;
  1436. X            if(cur_file->next != NULL)
  1437. X                cur_file = cur_file->next;
  1438. X            else    
  1439. X                break;
  1440. X        }
  1441. X        cur_page = cur_file->page & PAGEMASK;
  1442. X    
  1443. X        scr_beg = cur_file;
  1444. X        scr_end = cur_file;
  1445. X
  1446. X        if(found)
  1447. X            cur_file = last_file;
  1448. X        else
  1449. X        {
  1450. X            last_file = cur_file;
  1451. X
  1452. X            while((last_file->page & PAGEMASK) == (page & PAGEMASK))
  1453. X            {
  1454. X                if((last_file->orow == row) && (last_file->ocol == col))
  1455. X                {
  1456. X                    cur_file = last_file;
  1457. X                    break;
  1458. X                }
  1459. X                if(last_file->next != NULL)
  1460. X                    last_file = last_file->next;
  1461. X                else    
  1462. X                    break;
  1463. X            }
  1464. X        }
  1465. X    }
  1466. X    dis_play(scr_beg);        /* display directories */
  1467. X    show_blip();
  1468. X    cur_inv(cur_file);        /* handle current filename */
  1469. X}
  1470. X
  1471. X/*---------------------------------------------------------------------------*
  1472. X *    display file window
  1473. X *---------------------------------------------------------------------------*/
  1474. Xstatic void dis_play(register struct onefile *n_ptr)
  1475. X{
  1476. X    int displaytype = 1;        /* display file type */
  1477. X    int what = n_ptr->onam[0];    /* dirs, files, executables */
  1478. X    int curp = n_ptr->page & PAGEMASK;
  1479. X
  1480. X    while(n_ptr)
  1481. X    {
  1482. X        if(displaytype)        /* print description */
  1483. X        {
  1484. X            wmove(file_w, n_ptr->orow, 0);    /* move type pos. */
  1485. X            wattron(file_w, A_UNDERLINE);    /* underline */
  1486. X            switch(what)
  1487. X            {
  1488. X                case ISDIR:    /* directories */
  1489. X                    waddstr(file_w, "Dirs:");
  1490. X                    break;
  1491. X                    
  1492. X                case ISPROG:    /* executables */
  1493. X                    waddstr(file_w, "Progs:");
  1494. X                    break;
  1495. X                    
  1496. X                case ISDATA:    /* data */
  1497. X                    waddstr(file_w, "Files:");
  1498. X                    break;
  1499. X                    
  1500. X                case ISCHAR:    /* char devs */
  1501. X                    waddstr(file_w, "Cdevs:");
  1502. X                    break;
  1503. X                    
  1504. X                case ISBLOCK:    /* block devs */
  1505. X                    waddstr(file_w, "Bdevs:");
  1506. X                    break;
  1507. X                    
  1508. X                case ISPIPE:    /* pipes */
  1509. X                    waddstr(file_w, "Pipes:");
  1510. X                    break;
  1511. X                    
  1512. X                case ISSOCK:    /* sockets */
  1513. X                    waddstr(file_w, "Sockt:");
  1514. X                    break;
  1515. X                    
  1516. X                default:    /* data */
  1517. X                    waddstr(file_w, "Unkwn:");
  1518. X                    break;
  1519. X            }
  1520. X            wattroff(file_w, A_UNDERLINE);    /* end underline */
  1521. X            displaytype = 0;          /* reset displaytype */
  1522. X        }
  1523. X
  1524. X        is_tagged(n_ptr);    /* print it */
  1525. X
  1526. X        scr_end = n_ptr;    /* new last screen pos */
  1527. X
  1528. X        if(!n_ptr->next)    /* next entry valid ?? */
  1529. X            break;        /* no, current is last */
  1530. X            
  1531. X        n_ptr = n_ptr->next;    /* next entry */
  1532. X
  1533. X        if(n_ptr->page != curp)    /* if next page != current page ..*/
  1534. X            break;        /* ..exit */
  1535. X
  1536. X        if(n_ptr && (what != n_ptr->onam[0]))    /* new type ?? */
  1537. X        {
  1538. X            what = n_ptr->onam[0];        /* new type */
  1539. X            displaytype = 1;        /* display */
  1540. X        }
  1541. X    }
  1542. X}
  1543. X
  1544. X/*---------------------------------------------------------------------------*
  1545. X *    initialize file window display
  1546. X *---------------------------------------------------------------------------*/
  1547. Xstatic void dis_init(register struct onefile *n_ptr)
  1548. X{
  1549. X    int firstpage = 1;        /* mark first page flag */
  1550. X    int row = 0;            /* current row */
  1551. X    int what = n_ptr->onam[0];    /* dirs, files, executables */
  1552. X    int stop = 0;            /* first stop */
  1553. X    int col = stops[stop];        /* current column */
  1554. X
  1555. X    firstpage = 1;
  1556. X    
  1557. X    while(n_ptr && ( row < fileheight ))    /* while not at end of list */
  1558. X                        /*  and in file window .... */
  1559. X    {
  1560. X        if(firstpage)    /* mark first file first page */
  1561. X        {
  1562. X            n_ptr->page = (cur_page | FIRST);
  1563. X            firstpage = 0;
  1564. X        }
  1565. X        else        
  1566. X        {
  1567. X            n_ptr->page = cur_page;
  1568. X        }
  1569. X        
  1570. X        n_ptr->orow = row;    /* save current pos */
  1571. X        n_ptr->ocol = col;    /*  into list entry */
  1572. X
  1573. X        stop++;            /* next stop */
  1574. X        if(stops[stop] == 0)    /* last stop ? */
  1575. X        {
  1576. X            row++;        /* next row */
  1577. X            stop = 0;    /* new stop */
  1578. X        }
  1579. X        col = stops[stop];    /* new col */
  1580. X
  1581. X        scr_end = n_ptr;    /* new last screen pos */
  1582. X
  1583. X        n_ptr = n_ptr->next;    /* next entry */
  1584. X
  1585. X        if(n_ptr && (what != n_ptr->onam[0]))    /* new type ?? */
  1586. X        {
  1587. X            what = n_ptr->onam[0];    /* new type */
  1588. X
  1589. X            if(stop == 0)        /* compute vertical space */
  1590. X            {
  1591. X                row++;
  1592. X            }
  1593. X            else
  1594. X            {
  1595. X                row += 2;
  1596. X                stop = 0;
  1597. X            }
  1598. X            col = stops[stop];    /* new column */
  1599. X        }
  1600. X    }
  1601. X}
  1602. X
  1603. X/*---------------------------------------------------------------------------*
  1604. X *    show wether we have a previous(^), next(v) or just one(*) page
  1605. X *---------------------------------------------------------------------------*/
  1606. Xstatic void show_blip(void)
  1607. X{
  1608. X    if((!cur_page) && (!lastpage))        /* just one page */
  1609. X        return;
  1610. X        
  1611. X    wmove(file_w, fileheight-1 , COLS-1);
  1612. X
  1613. X    wattrset(file_w, A_REVERSE);
  1614. X    
  1615. X    if((!cur_page) && (lastpage))    /* first page */
  1616. X    {
  1617. X        waddch(file_w,'v');
  1618. X    }
  1619. X    else if(lastpage && (cur_page == lastpage)) /* last page */
  1620. X    {
  1621. X        waddch(file_w,'^');
  1622. X    }
  1623. X    else                    /* somewhere between */
  1624. X    {
  1625. X        waddch(file_w,'*');
  1626. X    }
  1627. X    wattrset(file_w, A_NORMAL);    
  1628. X}
  1629. X
  1630. X/*---------------------------------- EOF -------------------------------------*/
  1631. END_OF_FILE
  1632.   if test 14185 -ne `wc -c <'paging.c'`; then
  1633.     echo shar: \"'paging.c'\" unpacked with wrong size!
  1634.   fi
  1635.   # end of 'paging.c'
  1636. fi
  1637. if test -f 'rcinit.c' -a "${1}" != "-c" ; then 
  1638.   echo shar: Will not clobber existing file \"'rcinit.c'\"
  1639. else
  1640.   echo shar: Extracting \"'rcinit.c'\" \(5140 characters\)
  1641.   sed "s/^X//" >'rcinit.c' <<'END_OF_FILE'
  1642. X/*---------------------------------------------------------------------------*
  1643. X *
  1644. X *                  wish - windowing user friendly shell
  1645. X *                  ------------------------------------
  1646. X *
  1647. X *               Copyright (c) 1988-1993 Hellmuth Michaelis
  1648. X *
  1649. X *                  Eggerstedtstr. 28
  1650. X *                  22765 Hamburg
  1651. X *                  Germany
  1652. X *
  1653. X *                  Tel:    +49 / 40 / 384298    (private)
  1654. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  1655. X *                  e-mail: hm@hcshh.hcs.de
  1656. X *
  1657. X *                          --------oOo--------
  1658. X *
  1659. X *   This program is free software; you can redistribute it and/or modify
  1660. X *   it under the terms of the GNU General Public License as published by
  1661. X *   the Free Software Foundation; either version 2 of the License, or
  1662. X *   (at your option) any later version.
  1663. X *
  1664. X *   This program is distributed in the hope that it will be useful,
  1665. X *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1666. X *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1667. X *   GNU General Public License for more details.
  1668. X *
  1669. X *   You should have received a copy of the GNU General Public License
  1670. X *   along with this program; if not, write to the Free Software
  1671. X *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1672. X *
  1673. X *---------------------------------------------------------------------------*
  1674. X *
  1675. X *    Last Edit-Date: [Mon Aug 30 19:51:56 1993]
  1676. X *
  1677. X *    -hm    init file ".wishrc"
  1678. X *    -hm    wildcards
  1679. X *
  1680. X *----------------------------------------------------------------------------*/
  1681. X
  1682. X#include "wish.h"        /* everything we want */
  1683. X#include "control.h"        /* control-characters */
  1684. X#include "rcinit.h"        /* .wishrc definitions */
  1685. X
  1686. Xstatic void onoff(char *string, int *var);
  1687. Xstatic void optchar(char *string, unsigned char *var);
  1688. Xstatic void optstr(char *string, char dest[]);
  1689. X
  1690. X/*---------------------------------------------------------------------------*
  1691. X *    get user configuration from file "$HOME/.wishrc"
  1692. X *---------------------------------------------------------------------------*/
  1693. Xvoid readrc(void)
  1694. X{
  1695. X    char buffer[MAXPATHLEN+1];    /* gp buffer */
  1696. X    FILE *fp;
  1697. X    
  1698. X    sprintf(buffer, "%s/%s", envhome, WISHRC);
  1699. X
  1700. X    if((fp = fopen(buffer, "r")) == NULL)
  1701. X        return;
  1702. X
  1703. X    while((fgets(buffer, MAXPATHLEN, fp)) != NULL)
  1704. X    {
  1705. X
  1706. X/* comments */
  1707. X        if(buffer[0] == '#' || buffer[0] == ' ' || buffer[0] == '\t')
  1708. X        {
  1709. X            continue;
  1710. X        }
  1711. X/* booleans */
  1712. X        else if(!strncmp(buffer, RC_ATTR, strlen(RC_ATTR)))
  1713. X        {
  1714. X            onoff(buffer, &opt_attrib);
  1715. X        }
  1716. X        else if(!strncmp(buffer, RC_PRESERVE, strlen(RC_PRESERVE)))
  1717. X        {
  1718. X            onoff(buffer, &opt_preserve);
  1719. X        }
  1720. X        else if(!strncmp(buffer, RC_FKEYS, strlen(RC_FKEYS)))
  1721. X        {
  1722. X            onoff(buffer, &opt_labels);
  1723. X        }
  1724. X        else if(!strncmp(buffer, RC_LINKS, strlen(RC_LINKS)))
  1725. X        {
  1726. X            onoff(buffer, &opt_links);
  1727. X        }
  1728. X        else if(!strncmp(buffer, RC_POINT, strlen(RC_POINT)))
  1729. X        {
  1730. X            onoff(buffer, &opt_point);
  1731. X        }
  1732. X        else if(!strncmp(buffer, RC_RETURN, strlen(RC_RETURN)))
  1733. X        {
  1734. X            onoff(buffer, &opt_return);
  1735. X        }
  1736. X        else if(!strncmp(buffer, RC_WILDON, strlen(RC_WILDON)))
  1737. X        {
  1738. X            onoff(buffer, &opt_wildon);
  1739. X        }
  1740. X        else if(!strncmp(buffer, RC_CDROM, strlen(RC_CDROM)))
  1741. X        {
  1742. X            onoff(buffer, &opt_cdrom);
  1743. X        }
  1744. X        else if(!strncmp(buffer, RC_CDNOPROG, strlen(RC_CDNOPROG)))
  1745. X        {
  1746. X            onoff(buffer, &opt_cdnoprog);
  1747. X        }
  1748. X        else if(!strncmp(buffer, RC_DOTNAMES, strlen(RC_DOTNAMES)))
  1749. X        {
  1750. X            onoff(buffer, &opt_dotnames);
  1751. X        }
  1752. X/* strings */
  1753. X        else if(!strncmp(buffer, RC_PAGER, strlen(RC_PAGER)))
  1754. X        {
  1755. X            optstr(buffer, opt_more);            
  1756. X        }
  1757. X        else if(!strncmp(buffer, RC_EDITOR, strlen(RC_EDITOR)))
  1758. X        {
  1759. X            optstr(buffer, opt_edit);
  1760. X        }
  1761. X        else if(!strncmp(buffer, RC_WILDCARD, strlen(RC_WILDCARD)))
  1762. X        {
  1763. X            optstr(buffer, opt_wild);
  1764. X        }
  1765. X/* characters */
  1766. X        else if(!strncmp(buffer, RC_DELIMITER, strlen(RC_DELIMITER)))
  1767. X        {
  1768. X            optchar(buffer, &opt_delimiter);
  1769. X        }
  1770. X    }
  1771. X}
  1772. X
  1773. X/*---------------------------------------------------------------------------*
  1774. X *    process on/off strings
  1775. X *---------------------------------------------------------------------------*/
  1776. Xstatic void onoff(char *string, int *var)
  1777. X{
  1778. X    char *ptr;
  1779. X    
  1780. X    if((ptr = (char *)index(string, '=')) == NULL)
  1781. X        return;
  1782. X        
  1783. X    ptr++;
  1784. X
  1785. X    if(!strncmp(ptr, RC_ON, strlen(RC_ON)))
  1786. X    {
  1787. X        *var = 1;
  1788. X    }
  1789. X    else if(!strncmp(ptr, RC_OFF, strlen(RC_OFF)))
  1790. X    {
  1791. X        *var = 0;
  1792. X    }
  1793. X}
  1794. X
  1795. X/*---------------------------------------------------------------------------*
  1796. X *    process chars
  1797. X *---------------------------------------------------------------------------*/
  1798. Xstatic void optchar(char *string, unsigned char *var)
  1799. X{
  1800. X    unsigned char *ptr;
  1801. X    
  1802. X    if((ptr = (unsigned char *)index(string, '=')) == NULL)
  1803. X        return;
  1804. X        
  1805. X    ptr++;
  1806. X
  1807. X    if(isprint(*ptr))
  1808. X        *var = *ptr;        
  1809. X}
  1810. X
  1811. X/*---------------------------------------------------------------------------*
  1812. X *    process strings
  1813. X *---------------------------------------------------------------------------*/
  1814. Xstatic void optstr(char *string, char dest[])
  1815. X{
  1816. X    char *ptr, *bptr;
  1817. X    
  1818. X    if((ptr = (char *)index(string, '=')) == NULL)
  1819. X        return;
  1820. X        
  1821. X    ptr++;
  1822. X
  1823. X    bptr = dest;
  1824. X    
  1825. X    while(*ptr && (*ptr != '#') && (isprint(*ptr)) && (!isspace(*ptr)))
  1826. X        *bptr++ = *ptr++;
  1827. X
  1828. X    *bptr = '\0';
  1829. X}
  1830. X
  1831. X/*--------------------------------- EOF ------------------------------------*/
  1832. END_OF_FILE
  1833.   if test 5140 -ne `wc -c <'rcinit.c'`; then
  1834.     echo shar: \"'rcinit.c'\" unpacked with wrong size!
  1835.   fi
  1836.   # end of 'rcinit.c'
  1837. fi
  1838. if test -f 'wish.h' -a "${1}" != "-c" ; then 
  1839.   echo shar: Will not clobber existing file \"'wish.h'\"
  1840. else
  1841.   echo shar: Extracting \"'wish.h'\" \(11980 characters\)
  1842.   sed "s/^X//" >'wish.h' <<'END_OF_FILE'
  1843. X/*---------------------------------------------------------------------------*
  1844. X *
  1845. X *                  wish - windowing user friendly shell
  1846. X *                  ------------------------------------
  1847. X *
  1848. X *               Copyright (c) 1988-1993 Hellmuth Michaelis
  1849. X *
  1850. X *                  Eggerstedtstr. 28
  1851. X *                  22765 Hamburg
  1852. X *                  Germany
  1853. X *
  1854. X *                  Tel:    +49 / 40 / 384298    (private)
  1855. X *                  Tel:    +49 / 40 / 55903-170 (at work)
  1856. X *                  e-mail: hm@hcshh.hcs.de
  1857. X *
  1858. X *                          --------oOo--------
  1859. X *
  1860. X *   This program is free software; you can redistribute it and/or modify
  1861. X *   it under the terms of the GNU General Public License as published by
  1862. X *   the Free Software Foundation; either version 2 of the License, or
  1863. X *   (at your option) any later version.
  1864. X *
  1865. X *   This program is distributed in the hope that it will be useful,
  1866. X *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1867. X *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1868. X *   GNU General Public License for more details.
  1869. X *
  1870. X *   You should have received a copy of the GNU General Public License
  1871. X *   along with this program; if not, write to the Free Software
  1872. X *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1873. X *
  1874. X *---------------------------------------------------------------------------*
  1875. X *
  1876. X *    Last Edit-Date: [Mon Aug 30 19:55:44 1993]
  1877. X *
  1878. X *    -hm    conversion to curses
  1879. X *    -hm    conversion to multi-windows
  1880. X *    -hm    conversion to programs, files & directories
  1881. X *    -hm    adding history to commandline
  1882. X *    -hm    bsd porting
  1883. X *    -hm    preserve dir when cd ..
  1884. X *    -hm    stdlib inclusion for malloc()
  1885. X *    -hm    getcwd debugging
  1886. X *    -hm    fkey handling structures
  1887. X *    -hm    wildcard matching cd
  1888. X *
  1889. X *----------------------------------------------------------------------------*/
  1890. X
  1891. X#ifdef __386BSD__
  1892. X#include <ncurses.h>
  1893. X#else
  1894. X#include <curses.h>
  1895. X#endif
  1896. X
  1897. X#include <ctype.h>
  1898. X#include <errno.h>
  1899. X#include <fcntl.h>
  1900. X#include <grp.h>
  1901. X#include <pwd.h>
  1902. X#include <stdio.h>
  1903. X#include <stdlib.h>
  1904. X#include <string.h>
  1905. X#include <strings.h>
  1906. X#include <term.h>
  1907. X#include <time.h>
  1908. X#include <unistd.h>
  1909. X#include <utmp.h>
  1910. X#include <sys/dir.h>
  1911. X#include <sys/param.h>
  1912. X#include <sys/stat.h>
  1913. X#include <sys/types.h>
  1914. X
  1915. X#ifdef MAIN
  1916. X#define EXTERNAL
  1917. X#else
  1918. X#define EXTERNAL extern
  1919. X#endif
  1920. X
  1921. X#define EXPSEL    '%'    /* expand selection character in commandline */
  1922. X
  1923. X#define DEFDELIMCH '-'    /* default char used for horizontal delimiting lines */
  1924. X
  1925. X/* screen */
  1926. X
  1927. X#define C_HEAD     0    /* copyright header line */
  1928. X#define C_LINE     1    /* command entry line */
  1929. X#define C_SEP     2    /* separator line between command & file display */
  1930. X#define C_HEIGHT 3    /* commandline height in lines */
  1931. X
  1932. X#define F_BEG     0    /* first line of file window */
  1933. X
  1934. X#define A_SEP     0    /* separator line between file display & status line */
  1935. X#define A_LINE     1    /* attributes line */
  1936. X
  1937. X#define CURDIRW    11    /* F_CURDIR: current dir string width */
  1938. X#define ENTRYSW    9    /* F_CURDIR: entries string width */
  1939. X#define ENTRYCW    4    /* F_CURDIR: entries count width */
  1940. X
  1941. X/* attribute line */
  1942. X
  1943. X#define PP_PERM    0        /* position of permission string */
  1944. X
  1945. X#define PS_SIZE    11        /* position description string */
  1946. X#define ST_SIZE    "Size:"        /* description */
  1947. X#define PP_SIZE    PS_SIZE+6    /* position parameter string */
  1948. X
  1949. X#define PS_USER    27        /* position description string */
  1950. X#define ST_USER    "User:"        /* description */
  1951. X#define PP_USER    PS_USER+6    /* position parameter string */
  1952. X
  1953. X#define PS_GRUP    42        /* position description string */
  1954. X#define ST_GRUP    "Group:"    /* description */
  1955. X#define PP_GRUP    PS_GRUP+7    /* position parameter string */
  1956. X
  1957. X#define PS_DATE    58        /* position description string */
  1958. X#define ST_DATE    "Date:"        /* description */
  1959. X#define PP_DATE    PS_DATE+6    /* position parameter string */
  1960. X
  1961. X#define STOPS      30    /* # of positions for filename on screen */
  1962. X#define MINSPACE 2    /* minimum space between two filenames */
  1963. X#define STARTCOL 7    /* start column in a row */
  1964. X
  1965. X#ifndef TRUE
  1966. X#define TRUE    1    /* TRUE */
  1967. X#define FALSE    0    /* not TRUE */
  1968. X#endif
  1969. X
  1970. X#define ABORT    -1    /* wildmatch */
  1971. X#define GOOD    TRUE    /* good return */
  1972. X#define BAD      FALSE    /* bad return */
  1973. X
  1974. X#define FIRST    0x100    /* first entry of a file-page */
  1975. X#define PAGEMASK 0x0ff    /* for reading just the page */
  1976. X
  1977. X#define CR    0x0d    /* some characters */
  1978. X#define LF    0x0a
  1979. X#define TAB    0x09
  1980. X#define BS    0x08
  1981. X#define DEL    0x7f
  1982. X#define SPACE    0x20
  1983. X#define BEL    0x07
  1984. X#define ESC    0x1b
  1985. X
  1986. X/* keycodes for cursor motion */
  1987. X
  1988. X#define    K_UP    0x10    /* ^P */
  1989. X#define K_DOWN    0x0e    /* ^N */
  1990. X#define    K_LEFT    0x02    /* ^B */
  1991. X#define    K_RIGHT    0x06    /* ^F */
  1992. X
  1993. X#define K_TAB    0x09    /* tab */
  1994. X
  1995. X#define K_NEXT    0x16    /* ^V */
  1996. X#define K_PREV    0x1a    /* ^Z */
  1997. X
  1998. X#define K_QUIT    0x04    /* ^D */
  1999. X#define K_REF    0x0c    /* ^L */
  2000. X
  2001. X#define K_MARK    0x01    /* ^A */
  2002. X#define    K_ECHO    0x17    /* ^W */
  2003. X#define K_UMARK    0x15    /* ^U */
  2004. X
  2005. X#define HISLINES    32    /* no. of lines in history buffer */
  2006. X#define HISLNLEN    512    /* length of one history line */
  2007. X
  2008. X/* terminal types */
  2009. X
  2010. X#define TERM_DUMB        0    /* dumb whatsoever */
  2011. X#define TERM_HP            1    /* Hewlett Packard 2392 or 700/9x */
  2012. X#define TERM_VT1        2    /* DEC VT100 */
  2013. X#define TERM_VT2        3    /* DEC VT220 */
  2014. X#define TERM_VT3        4    /* DEC VT320 */
  2015. X#define TERM_PCVT        5    /* 386BSD pcvt driver */
  2016. X#define TERM_HPX        6    /* hpterm X11 terminal emulator */
  2017. X
  2018. X/* preserve options */
  2019. X
  2020. X#define PRES_NO        0        /* don't preserve anything */
  2021. X#define PRES_NORM    1        /* try "normal" position preserve */
  2022. X#define PRES_DD        2        /* jump to cur dir after cd .. */
  2023. X
  2024. X/* one file */
  2025. X
  2026. Xstruct onefile {        /* structure for one directory entry */
  2027. X    char onam[255];        /* filename */
  2028. X    unsigned int osiz;    /* size */
  2029. X    int ousr;        /* user */
  2030. X    int ogrp;        /* group */
  2031. X    char oislnk;        /* flag, is a link */
  2032. X    char oprm[16];        /* permissions */
  2033. X    char odat[15];        /* access date */
  2034. X    int orow;        /* relative row to display item */
  2035. X    int ocol;        /* relative column to display item */
  2036. X    int tag;        /* flag for tagging files */
  2037. X    int page;        /* page and number for display window */
  2038. X    struct onefile *next;    /* ptr to next entry */
  2039. X    struct onefile *prev;    /* prt to previous entry */
  2040. X};
  2041. X
  2042. X/* onam[0] contains the entry type, which can be:    */
  2043. X
  2044. X#define ISDIR    '1'
  2045. X#define    ISPROG    '2'
  2046. X#define    ISDATA    '3'
  2047. X#define    ISCHAR    '4'
  2048. X#define    ISBLOCK    '5'
  2049. X#define    ISPIPE    '6'
  2050. X#define ISSOCK    '7'
  2051. X#define ISUNKN    '8'
  2052. X
  2053. X#define OPTSLEN    60        /* option string length */
  2054. X
  2055. X#define WILDCHARS "\\?*["    /* special meaning chars */
  2056. X
  2057. X/* fkey labels */
  2058. X
  2059. Xstruct fk_tab {
  2060. X    char *label_16;        /* HP Terminal Labels */
  2061. X    char *label_8;        /* DEC (and others) Terminal Labels */
  2062. X};
  2063. X
  2064. Xextern struct fk_tab sys_keys[];
  2065. X
  2066. X#ifdef MAIN
  2067. X
  2068. Xchar *hislines[HISLINES];    /* array of history line pointers */
  2069. Xint  cur_his = 0;        /* current history line */
  2070. Xchar cbuff[HISLNLEN+16];    /* command buffer */
  2071. X
  2072. Xchar counter[5] = "\0";        /* entrycount as string */
  2073. Xchar cur_path[1024];        /* current path */
  2074. Xchar errorline[256];        /* error line if errorflag == 1 */
  2075. Xchar headerline[256];        /* headerline for copyright etc */
  2076. X
  2077. Xint stops[STOPS];        /* table of stop points on row */
  2078. X
  2079. Xstruct onefile *cur_file = NULL;/* the CURRENT highlighted filename */
  2080. Xstruct onefile *first = NULL;    /* init dir-list head-ptr */
  2081. Xstruct onefile *last = NULL;    /* init dir-list tail-ptr */
  2082. X
  2083. Xint maxfnleng = 0;        /* length of longest filename of this dir */
  2084. Xint opt_attrib = 1;        /* display attribute line */
  2085. Xint opt_labels = 0;        /* use virtual f-key labels in last line */
  2086. Xint opt_point  = 0;        /* display current dir in file window */
  2087. Xint opt_preserve = 0;        /* initially preserve dirs when cd .. */
  2088. Xint opt_links = 0;        /* initially show files not links */
  2089. Xint opt_return = 1;        /* press any key to continue */
  2090. Xunsigned char opt_delimiter = 0;/* window delimiter character */
  2091. Xint opt_wildon = 0;        /* no wildcarding yet */
  2092. Xchar opt_wild[OPTSLEN+1];    /* file window wildcard spec */
  2093. Xchar opt_edit[OPTSLEN+1];    /* user sepecified editor */
  2094. Xchar opt_more[OPTSLEN+1];    /* user sepecified pager */
  2095. Xint opt_cdrom = 0;        /* cdrom special filename processing */
  2096. Xint opt_cdnoprog = 0;        /* cdrom, convert executables to data */
  2097. Xint opt_dotnames = 1;        /* display filenames starting with dot */
  2098. X
  2099. X#else /* !MAIN */
  2100. X
  2101. Xextern char *hislines[];
  2102. Xextern int  cur_his;
  2103. X
  2104. Xextern char cbuff[];
  2105. X
  2106. Xextern char counter[];
  2107. Xextern char cur_path[];
  2108. Xextern char errorline[];
  2109. Xextern char headerline[];
  2110. X
  2111. Xextern int stops[];
  2112. X
  2113. Xextern struct onefile *cur_file;
  2114. Xextern struct onefile *first;
  2115. Xextern struct onefile *last;
  2116. X
  2117. Xextern int maxfnleng;
  2118. Xextern int opt_attrib;
  2119. Xextern int opt_labels;
  2120. Xextern int opt_point;
  2121. Xextern int opt_preserve;
  2122. Xextern int opt_links;
  2123. Xextern int opt_return;
  2124. Xextern unsigned char opt_delimiter;
  2125. Xextern opt_wildon;
  2126. Xextern char opt_wild[];
  2127. Xextern char opt_edit[];
  2128. Xextern char opt_more[];
  2129. Xextern int opt_cdrom;
  2130. Xextern int opt_cdnoprog;
  2131. Xextern int opt_dotnames;
  2132. X
  2133. X#endif /* MAIN */
  2134. X
  2135. XEXTERNAL char bschar;        /* backspace */
  2136. X
  2137. XEXTERNAL WINDOW *attr_w;    /* attributes display window (separation,attributes) */
  2138. XEXTERNAL WINDOW *cmnd_w;    /* command line window (copyright,command,separation) */
  2139. XEXTERNAL WINDOW *file_w;    /* files display window (file names) */
  2140. XEXTERNAL WINDOW *fst_w;        /* files status window (cur dir, entries) */
  2141. XEXTERNAL WINDOW *flbl_w;    /* function key labels */
  2142. X
  2143. XEXTERNAL char *envhome;        /* ptr to HOME - env var */
  2144. XEXTERNAL char *envmore;        /* ptr to PAGER - env var */
  2145. XEXTERNAL char *envedit;        /* ptr to EDITOR - env var */
  2146. XEXTERNAL char *term_string;    /* terminal type string from environment */
  2147. X
  2148. XEXTERNAL int termtype;        /* flag what terminal category we are on */
  2149. X
  2150. XEXTERNAL struct onefile *scr_beg;/* ptr to first filename on screen */
  2151. XEXTERNAL struct onefile *scr_end;/* ptr to last filename on screen */
  2152. X
  2153. XEXTERNAL int cur_page;        /* current file window page */
  2154. XEXTERNAL int errorflag;        /* if error string is in header line */
  2155. XEXTERNAL int fileheight;    /* height of filewindow */
  2156. XEXTERNAL struct fk_tab (*cur_fktab)[]; /* current fkey label table */
  2157. XEXTERNAL int iscdfs;        /* flag, true if we are on a cdrom filesys */
  2158. X
  2159. Xvoid attribs ( int flag );
  2160. Xvoid bol_line ( void );
  2161. Xint cd( char *string );
  2162. Xvoid clear_toeol ( void );
  2163. Xvoid close_cdir ( void );
  2164. Xvoid clrerror ( void );
  2165. Xint cmdline ( int c );
  2166. Xvoid complete ( void );
  2167. Xvoid config( void );
  2168. Xint cr_on_files ( void );
  2169. Xint curcol ( void );
  2170. Xvoid cur_blink ( struct onefile *current );
  2171. Xvoid cur_inv ( struct onefile *current );
  2172. Xvoid cur_norm ( struct onefile *current );
  2173. Xvoid del_char ( void );
  2174. Xvoid dis_hist ( void );
  2175. Xvoid edit_current ( void );
  2176. Xvoid eol_line ( void );
  2177. Xvoid error ( char *str );
  2178. Xvoid exec_command ( char *cline );
  2179. Xvoid expsel ( char *p );
  2180. Xvoid fatal ( char *str );
  2181. Xint fill_list ( void );
  2182. Xvoid fini_flabels ( void );
  2183. Xint firstfile ( void );
  2184. Xvoid fnclabel ( int n, char *string );
  2185. Xvoid free_list ( void );
  2186. Xvoid fresh_files ( void );
  2187. Xchar *group_from_gid ( gid_t gid, int size );
  2188. Xvoid handlebs ( void );
  2189. Xvoid handlecr ( void );
  2190. Xvoid header ( void );
  2191. Xvoid help ( void );
  2192. Xvoid h_files ( void );
  2193. Xvoid h_line ( void );
  2194. Xvoid init_files ( int preserve, char *dirname );
  2195. Xvoid init_flabels ( void );
  2196. Xvoid init_header ( void );
  2197. Xvoid init_history ( void );
  2198. Xvoid init_screen ( void );
  2199. Xvoid init_time ( void );
  2200. Xvoid is_tagged ( struct onefile *current );
  2201. Xint lastfile ( void );
  2202. Xvoid left_line ( void );
  2203. Xint main ( int argc, char *argv[] );
  2204. Xvoid move_down ( void );
  2205. Xvoid move_hmdn ( void );
  2206. Xvoid move_home ( void );
  2207. Xvoid move_left ( void );
  2208. Xvoid move_right ( void );
  2209. Xvoid move_up ( void );
  2210. Xvoid name_echo ( void );
  2211. Xint nextfile ( void );
  2212. Xvoid next_line ( void );
  2213. Xvoid next_page ( void );
  2214. Xint prevfile ( void );
  2215. Xvoid prev_line ( void );
  2216. Xvoid prev_page ( void );
  2217. Xvoid readrc ( void );
  2218. Xvoid resume_time ( void );
  2219. Xvoid right_line ( void );
  2220. Xvoid save_line ( void );
  2221. Xvoid sepaline ( struct _win_st *window );
  2222. Xvoid set_termtype ( void );
  2223. Xstruct onefile *store ( struct onefile *new, struct onefile *top );
  2224. Xvoid suspend_time ( void );
  2225. Xvoid tag_current ( struct onefile *current );
  2226. Xvoid timeout_hdlr ( int sig );
  2227. Xvoid untag_all ( void );
  2228. Xvoid update_all ( void );
  2229. Xvoid update_files ( void );
  2230. Xvoid usage ( void );
  2231. Xchar *user_from_uid ( uid_t uid, int size );
  2232. Xint wildmat( char *text, char *p );
  2233. Xvoid yank ( void );
  2234. X
  2235. X/*---------------------------------- EOF -------------------------------------*/
  2236. END_OF_FILE
  2237.   if test 11980 -ne `wc -c <'wish.h'`; then
  2238.     echo shar: \"'wish.h'\" unpacked with wrong size!
  2239.   fi
  2240.   # end of 'wish.h'
  2241. fi
  2242. echo shar: End of archive 3 \(of 4\).
  2243. cp /dev/null ark3isdone
  2244. MISSING=""
  2245. for I in 1 2 3 4 ; do
  2246.     if test ! -f ark${I}isdone ; then
  2247.     MISSING="${MISSING} ${I}"
  2248.     fi
  2249. done
  2250. if test "${MISSING}" = "" ; then
  2251.     echo You have unpacked all 4 archives.
  2252.     rm -f ark[1-9]isdone
  2253. else
  2254.     echo You still must unpack the following archives:
  2255.     echo "        " ${MISSING}
  2256. fi
  2257. exit 0
  2258. exit 0 # Just in case...
  2259.