home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2558 < prev    next >
Encoding:
Text File  |  1992-11-18  |  50.1 KB  |  2,233 lines

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!manuel.anu.edu.au!csc.canberra.edu.au!pandonia!jan
  3. From: jan@pandonia.canberra.edu.au (Jan Newmarch)
  4. Subject: X11/Motif file manager - part 02 of 17
  5. Message-ID: <1992Nov19.052155.25516@csc.canberra.edu.au>
  6. Sender: news@csc.canberra.edu.au
  7. Organization: University of Canberra
  8. Date: Thu, 19 Nov 92 05:21:55 GMT
  9. Lines: 2222
  10.  
  11.  
  12.  
  13. #!/bin/sh
  14. # this is part.02 (part 2 of a multipart archive)
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file xmfm/xmfm.man continued
  17. #
  18. if test ! -r _shar_seq_.tmp; then
  19.     echo 'Please unpack part 1 first!'
  20.     exit 1
  21. fi
  22. (read Scheck
  23.  if test "$Scheck" != 2; then
  24.     echo Please unpack part "$Scheck" next!
  25.     exit 1
  26.  else
  27.     exit 0
  28.  fi
  29. ) < _shar_seq_.tmp || exit 1
  30. if test ! -f _shar_wnt_.tmp; then
  31.     echo 'x - still skipping xmfm/xmfm.man'
  32. else
  33. echo 'x - continuing file xmfm/xmfm.man'
  34. sed 's/^X//' << 'SHAR_EOF' >> 'xmfm/xmfm.man' &&
  35. X
  36. .ta 8,12,16,20,24,28,32,36,40
  37. .na
  38. .nf
  39. X    TopLevelShell xmfm
  40. X        MainWindow main
  41. X            Form form
  42. X                Label directory_label
  43. X                RowColumn files_toolbar
  44. X                    PushButton file_button
  45. X                RowColumn dirs_toolbar
  46. X                    PushButton dir_button
  47. X                PanedWindow pane
  48. X                    PanedWindow rc1
  49. X                        Label executable_filter_label
  50. X                        ScrolledWindow sw1
  51. X                            RowColumn executables_pane
  52. X                                DrawnButton ?
  53. X                    PanedWindow rc2
  54. X                        Label file_filter_label
  55. X                        ScrolledWindow sw2
  56. X                            RowColumn files_pane
  57. X                                DrawnButton ?
  58. X                    PanedWindow rc3
  59. X                        Label dir_filter_label
  60. X                        ScrolledWindow sw3
  61. X                            RowColumn dirs_pane
  62. X                                DrawnButton ?
  63. .fi
  64. .ad
  65. .SH BUGS
  66. .PP
  67. If 
  68. .I xmfm
  69. uses a display other than that in the environment variable
  70. $DISPLAY, 
  71. .IR xterm 's
  72. invoked from within
  73. .I xmfm
  74. will appear on the wrong display, the one in $DISPLAY.
  75. Some parts of 
  76. .I xmfm
  77. do not perform ~ substitution or environment variable
  78. expansion.
  79. .SH "SEE ALSO"
  80. .PP
  81. XX(1),
  82. .I "Motif Style Guide.
  83. Any good Motif book, such as J.D Newmarch,
  84. .I "The X Window System and Motif - A Fast Track Approach
  85. .SH AUTHOR
  86. .PP
  87. Jan Newmarch, University of Canberra
  88. .br
  89. (jan@ise.canberra.edu.au)
  90. SHAR_EOF
  91. echo 'File xmfm/xmfm.man is complete' &&
  92. chmod 0644 xmfm/xmfm.man ||
  93. echo 'restore of xmfm/xmfm.man failed'
  94. Wc_c="`wc -c < 'xmfm/xmfm.man'`"
  95. test 4181 -eq "$Wc_c" ||
  96.     echo 'xmfm/xmfm.man: original size 4181, current size' "$Wc_c"
  97. rm -f _shar_wnt_.tmp
  98. fi
  99. # ============= xmfm/xmfmrc ==============
  100. if test -f 'xmfm/xmfmrc' -a X"$1" != X"-c"; then
  101.     echo 'x - skipping xmfm/xmfmrc (File already exists)'
  102.     rm -f _shar_wnt_.tmp
  103. else
  104. > _shar_wnt_.tmp
  105. echo 'x - extracting xmfm/xmfmrc (Text)'
  106. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/xmfmrc' &&
  107. {    type    f
  108. X      pattern    [mM]akefile
  109. X    pixmap    makefile.xbm
  110. X        description Makefile
  111. X    {
  112. X        label    make
  113. X        run_in_xterm
  114. X        pause_after_exec
  115. X        action    "make -f $0"
  116. X    }
  117. X    {
  118. X        label    make...
  119. X        run_in_xterm
  120. X        pause_after_exec
  121. X        prompt "Make what file?"
  122. X        action    "make -f $0 $*"
  123. X    }
  124. X    {
  125. X        label    edit
  126. X        action    "vi $0"
  127. X    }
  128. X        {       label    print
  129. X                action   "lpr $0"
  130. X        }
  131. }
  132. X
  133. {    type    f
  134. X    pattern    *.c
  135. X    pixmap    ccode.xbm
  136. X        description "C source code"
  137. X    {
  138. X        label    edit
  139. X        action    "vi $0"
  140. X    }
  141. X    {
  142. X        label    more
  143. X        run_in_xterm
  144. X        pause_after_exec
  145. X        action    "more $0"
  146. X    }
  147. X    {
  148. X        label    "to
  149. object"
  150. X        run_in_xterm
  151. X        pause_after_exec
  152. X        action    "gcc -c $0"
  153. X    }
  154. X    {
  155. X        label    "to
  156. executable"
  157. X        run_in_xterm
  158. X        pause_after_exec
  159. X        action    "gcc -o ${0%.c} $0"
  160. X    }
  161. X        {       label    print
  162. X                action   "lpr $0"
  163. X        }
  164. }
  165. X
  166. {    type    f
  167. X    pattern    *.tar
  168. X    pixmap    file.xbm
  169. X        description "tar archive"
  170. X    {
  171. X        label    "tar x"
  172. X        action    "tar xf $0"
  173. X    }
  174. X    {
  175. X        label    "tar t"
  176. X        run_in_xterm
  177. X        pause_after_exec
  178. X        action    "tar tf $0"
  179. X    }
  180. X    {
  181. X        label    "tar xv"
  182. X        run_in_xterm
  183. X        pause_after_exec
  184. X        action    "tar xvf $0"
  185. X    }
  186. }
  187. X
  188. {    type    f
  189. X    pattern    *.o
  190. X    pixmap    ocode.xbm
  191. X        description "object module"
  192. X    {
  193. X        label    "to
  194. executable"
  195. X        run_in_xterm
  196. X        pause_after_exec
  197. X        action    "gcc -o ${0%.o} $0"
  198. X    }
  199. }
  200. X
  201. {    type    f
  202. X    pattern    *.Z
  203. X    pixmap    z.xbm
  204. X        description "compressed file"
  205. X    {
  206. X        label    uncompress
  207. X        action    "uncompress $0"
  208. X    }
  209. X    {
  210. X        label    more
  211. X        run_in_xterm
  212. X        pause_after_exec
  213. X        action    "zcat $0 | more"
  214. X    }
  215. }
  216. X
  217. {    type    f
  218. X    pattern    core
  219. X    pixmap    core.xbm
  220. X        description "core dump"
  221. X    {
  222. X        label    remove
  223. X        action    "rm $0"
  224. X    }
  225. X    {
  226. X        label    debug
  227. X        prompt    "file to debug"
  228. X        action    "x11ups $1 $0"
  229. X    }
  230. }
  231. X
  232. {    type    f
  233. X    pattern    *.xbm
  234. X    pixmap    bitmap.xbm
  235. X        description "X bitmap"
  236. X    {
  237. X        label    edit
  238. X        action    "bitmap $0"
  239. X    }
  240. }
  241. X
  242. {    type    f
  243. X    pattern    *.gif
  244. X    pixmap    bitmap.xbm
  245. X        description "GIFF image"
  246. X    {
  247. X        label    edit
  248. X        action    "xli $0"
  249. X    }
  250. }
  251. X
  252. {    type    f
  253. X    pattern    *.jpg
  254. X    pixmap    bitmap.xbm
  255. X        description "JPEG image"
  256. X    {
  257. X        label    "view (xv)"
  258. X        action    "xv $0"
  259. X    }
  260. X        {
  261. X                label "view (xli)"
  262. X                action "xli $0"
  263. X        }
  264. }
  265. X
  266. {    type    f
  267. X    pattern    *
  268. X    pixmap    file.xbm
  269. X    {
  270. X        label    edit
  271. X        action    "vi $0"
  272. X    }
  273. X    {
  274. X        label    more
  275. X        run_in_xterm
  276. X        pause_after_exec
  277. X        action    "more $0"
  278. X    }
  279. X        {       label    print
  280. X                action   "lpr $0"
  281. X        }
  282. }
  283. X
  284. {    type    x
  285. X    pattern    x*
  286. X    pixmap    xlogo32
  287. X        description "X program"
  288. X    {
  289. X        label    execute
  290. X        action    "$0"
  291. X    }
  292. X    {
  293. X        label    execute...
  294. X        prompt    "Enter the command line arguments:"
  295. X        action    "$0 $*"
  296. X    }
  297. X    {
  298. X        label    debug
  299. X        action    "x11ups $0"
  300. X    }
  301. }
  302. X
  303. {    type    x
  304. X    pattern    *
  305. X    pixmap    prog.xbm
  306. X        description program
  307. X    {
  308. X        label    execute
  309. X        run_in_xterm
  310. X        pause_after_exec
  311. X        action    "$0"
  312. X    }
  313. X    {
  314. X        label    execute...
  315. X        run_in_xterm
  316. X        pause_after_exec
  317. X        prompt    "Enter the command line arguments:"
  318. X        action    "$0 $*"
  319. X    }
  320. X    {
  321. X        label    debug
  322. X        action    "x11ups $0"
  323. X    }
  324. }
  325. X
  326. {    type    d
  327. X    pattern    .
  328. X    pixmap    herefolder.xbm
  329. X        description "current directory"
  330. X    {
  331. X        label    refresh
  332. X        action    "$cd $0"
  333. X    }
  334. X    {
  335. X        label    open
  336. X        action    "$opendir $0"
  337. X    }
  338. }
  339. X
  340. {    type    d
  341. X    pattern    ..
  342. X    pixmap    dotdot.xbm
  343. X        description "parent directory"
  344. X    {
  345. X        label    chdir
  346. X        action    "$cd $0"
  347. X    }
  348. X    {
  349. X        label    open
  350. X        action    "$opendir $0"
  351. X    }
  352. }
  353. X
  354. {    type    d
  355. X    pattern    *
  356. X    pixmap    folder.xbm
  357. X    {
  358. X        label    chdir
  359. X        action    "$cd $0"
  360. X    }
  361. X    {
  362. X        label    open
  363. X        action    "$opendir $0"
  364. X    }
  365. }
  366. X
  367. {    type    p
  368. X    pattern    *
  369. X    pixmap    ""
  370. X    {
  371. X        label    make
  372. X        run_in_xterm
  373. X        pause_after_exec
  374. X        action    make
  375. X    }
  376. X    {
  377. X        label    information
  378. X        run_in_xterm
  379. X        pause_after_exec
  380. X        action    "$information $0"
  381. X    }
  382. X    {
  383. X        label    remove
  384. X        action    "rm -ir $0"
  385. X        run_in_xterm
  386. X    }
  387. X    {
  388. X        label    "refresh
  389. dir"
  390. X        action    "$cd ."
  391. X    }
  392. }
  393. SHAR_EOF
  394. chmod 0644 xmfm/xmfmrc ||
  395. echo 'restore of xmfm/xmfmrc failed'
  396. Wc_c="`wc -c < 'xmfm/xmfmrc'`"
  397. test 3594 -eq "$Wc_c" ||
  398.     echo 'xmfm/xmfmrc: original size 3594, current size' "$Wc_c"
  399. rm -f _shar_wnt_.tmp
  400. fi
  401. # ============= xmfm/DirMgr.h ==============
  402. if test -f 'xmfm/DirMgr.h' -a X"$1" != X"-c"; then
  403.     echo 'x - skipping xmfm/DirMgr.h (File already exists)'
  404.     rm -f _shar_wnt_.tmp
  405. else
  406. > _shar_wnt_.tmp
  407. echo 'x - extracting xmfm/DirMgr.h (Text)'
  408. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/DirMgr.h' &&
  409. /****************************************************************************
  410. X
  411. X    DirMgr.h
  412. X
  413. X    This file contains the C declarations and definitions for the
  414. X    DirectoryMgr system.
  415. X
  416. X    This system is intended to managed filtered and sorted directory
  417. X    lists.
  418. X
  419. X ****************************************************************************/
  420. X
  421. #ifndef _DIRECTORY_MGR_H_
  422. #define    _DIRECTORY_MGR_H_
  423. X
  424. #include "Directory.h"
  425. X
  426. /*---------------------------------------------------------------------------*
  427. X
  428. X        Simple DirectoryMgr Interface
  429. X
  430. X        DirectoryMgrSimpleOpen();
  431. X        DirectoryMgrSimpleRefilter();
  432. X        DirectoryMgrSimpleResort();
  433. X
  434. X    Standard DirectoryMgr Interface
  435. X
  436. X        DirectoryMgrOpen();
  437. X        DirectoryMgrClose();
  438. X        DirectoryMgrRefilter();
  439. X        DirectoryMgrRefresh();
  440. X        DirectoryMgrResort();
  441. X
  442. X    Moving Around Items
  443. X
  444. X        DirectoryMgrGotoItem();
  445. X        DirectoryMgrGotoNamedItem();
  446. X        DirectoryMgrRestart();
  447. X        DirectoryMgrGetIndex();
  448. X        DirectoryMgrCurrentEntry();
  449. X        DirectoryMgrNextEntry();
  450. X        DirectoryMgrPrevEntry();
  451. X
  452. X    Utility Functions
  453. X
  454. X        DirectoryMgrSimpleFilterFunc();
  455. X        DirectoryMgrSimpleSortingFunc();
  456. X
  457. X    Comparison Functions
  458. X
  459. X        DirectoryMgrCompareName();
  460. X        DirectoryMgrCompareSizeAscending();
  461. X        DirectoryMgrCompareSizeDescending();
  462. X
  463. X    Macros
  464. X
  465. X        DirectoryMgrDir();
  466. X        DirectoryMgrData();
  467. X        DirectoryMgrSortedPtrs();
  468. X        DirectoryMgrFilterFunc();
  469. X        DirectoryMgrCompFunc();
  470. X        DirectoryMgrFilterData();
  471. X        DirectoryMgrFreeFilterData();
  472. X        DirectoryMgrTotalCount();
  473. X        DirectoryMgrFilteredCount();
  474. X        DirectoryMgrCurrentIndex();
  475. X
  476. X
  477. X *---------------------------------------------------------------------------*/
  478. X
  479. #ifndef PFI
  480. typedef int (*PFI)();
  481. #endif
  482. X
  483. typedef struct entry_cons
  484. {
  485. X    DIR_ENTRY dir_entry;
  486. X    struct entry_cons *next;
  487. } DIR_ENTRY_CONS;
  488. X
  489. typedef    DIR_ENTRY_CONS DirEntryCons;
  490. X
  491. typedef struct
  492. {
  493. X    DIRECTORY dir;
  494. X    DIR_ENTRY *data;
  495. X    DIR_ENTRY **sorted_ptrs;
  496. X    int total_count;
  497. X    int filtered_count;
  498. X    PFI filter_func;
  499. X    char *filter_data;
  500. X    int free_filter_data;
  501. X    PFI comp_func;
  502. X    int current_index;
  503. } DIRECTORY_MGR;
  504. X
  505. typedef    DIRECTORY_MGR DirectoryMgr;
  506. X
  507. #define    DIR_MGR_SORT_NONE            0
  508. #define    DIR_MGR_SORT_NAME            1
  509. #define    DIR_MGR_SORT_NAME_DIRS_FIRST        2
  510. #define DIR_MGR_SORT_SIZE_ASCENDING        3
  511. #define DIR_MGR_SORT_SIZE_DESCENDING        4
  512. #define    DIR_MGR_SORT_ACCESS_ASCENDING        5
  513. #define    DIR_MGR_SORT_ACCESS_DESCENDING        6
  514. X
  515. #define    DirectoryMgrDir(dm)        (&((dm)->dir))
  516. #define    DirectoryMgrData(dm)        ((dm)->data)
  517. #define    DirectoryMgrSortedPtrs(dm)    ((dm)->sorted_ptrs)
  518. #define    DirectoryMgrFilterFunc(dm)    ((dm)->filter_func)
  519. #define    DirectoryMgrCompFunc(dm)    ((dm)->comp_func)
  520. #define    DirectoryMgrFilterData(dm)    ((dm)->filter_data)
  521. #define    DirectoryMgrFreeFilterData(dm)    ((dm)->free_filter_data)
  522. #define    DirectoryMgrTotalCount(dm)    ((dm)->total_count)
  523. #define    DirectoryMgrFilteredCount(dm)    ((dm)->filtered_count)
  524. #define    DirectoryMgrCurrentIndex(dm)    ((dm)->current_index)
  525. X
  526. #ifndef __cplusplus
  527. X
  528. DirectoryMgr        *DirectoryMgrSimpleOpen();
  529. int            DirectoryMgrSimpleRefilter();
  530. int            DirectoryMgrSimpleResort();
  531. X
  532. DirectoryMgr        *DirectoryMgrOpen();
  533. void            DirectoryMgrClose();
  534. int            DirectoryMgrRefilter();
  535. int            DirectoryMgrRefresh();
  536. void            DirectoryMgrResort();
  537. X
  538. int            DirectoryMgrGotoItem();
  539. int            DirectoryMgrGotoNamedItem();
  540. void            DirectoryMgrRestart();
  541. int            DirectoryMgrGetIndex();
  542. DirEntry        *DirectoryMgrCurrentEntry();
  543. DirEntry        *DirectoryMgrNextEntry();
  544. DirEntry        *DirectoryMgrPrevEntry();
  545. X
  546. int            DirectoryMgrSimpleFilterFunc();
  547. int            DirectoryMgrSimpleSortingFunc();
  548. X
  549. int            DirectoryMgrCompareName();
  550. int            DirectoryMgrCompareNameDirsFirst();
  551. int            DirectoryMgrCompareSizeAscending();
  552. int            DirectoryMgrCompareSizeDescending();
  553. int            DirectoryMgrCompareLastAccessAscending();
  554. int            DirectoryMgrCompareLastAccessDescending();
  555. X
  556. int            DirectoryMgrFilterName();
  557. X
  558. #endif
  559. X
  560. #endif
  561. SHAR_EOF
  562. chmod 0644 xmfm/DirMgr.h ||
  563. echo 'restore of xmfm/DirMgr.h failed'
  564. Wc_c="`wc -c < 'xmfm/DirMgr.h'`"
  565. test 3729 -eq "$Wc_c" ||
  566.     echo 'xmfm/DirMgr.h: original size 3729, current size' "$Wc_c"
  567. rm -f _shar_wnt_.tmp
  568. fi
  569. # ============= xmfm/Directory.h ==============
  570. if test -f 'xmfm/Directory.h' -a X"$1" != X"-c"; then
  571.     echo 'x - skipping xmfm/Directory.h (File already exists)'
  572.     rm -f _shar_wnt_.tmp
  573. else
  574. > _shar_wnt_.tmp
  575. echo 'x - extracting xmfm/Directory.h (Text)'
  576. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/Directory.h' &&
  577. /****************************************************************************
  578. X
  579. X    Directory.h
  580. X
  581. X    This file contains the C definitions and declarations for the
  582. X    Directory.c directory iteration code.
  583. X
  584. X    This code is intended to be used as a convenient, machine
  585. X    independent interface to iterate through the contents of a
  586. X    directory.
  587. X
  588. X ****************************************************************************/
  589. X
  590. #ifndef _DIRECTORY_H_
  591. #define _DIRECTORY_H_
  592. X
  593. #include <stdio.h>
  594. #include <sys/param.h>
  595. #include <sys/types.h>
  596. #include <sys/stat.h>
  597. X
  598. #ifndef    NO_DIRENT
  599. #include <dirent.h>
  600. #else
  601. #include <sys/dir.h>
  602. #define    dirent direct
  603. #endif
  604. X
  605. #ifndef _SYS_NAME_MAX
  606. #ifndef MAXNAMLEN
  607. ERROR, ONE OF THESE MUST BE DEFINED
  608. #else
  609. #define    MAX_NAME_LENGTH    MAXNAMLEN
  610. #endif
  611. #else
  612. #define    MAX_NAME_LENGTH    _SYS_NAME_MAX
  613. #endif
  614. X
  615. #ifndef TRUE
  616. #define TRUE                1
  617. #endif
  618. X
  619. #ifndef FALSE
  620. #define    FALSE                0
  621. #endif
  622. X
  623. #define    PERM_READ            4
  624. #define    PERM_WRITE            2    
  625. #define    PERM_EXECUTE            1
  626. X
  627. #define    F_TYPE_DIR            1
  628. #define    F_TYPE_FILE            2
  629. #define    F_TYPE_CHAR_SPECIAL        3
  630. #define    F_TYPE_BLOCK_SPECIAL        4
  631. #define    F_TYPE_SYM_LINK            5
  632. #define    F_TYPE_SOCKET            6
  633. #define    F_TYPE_FIFO            7
  634. X
  635. /*--------------------------------------------------------------------------*
  636. X
  637. X            D A T A    T Y P E    A C C E S S    M A C R O S
  638. X
  639. X *--------------------------------------------------------------------------*/
  640. X
  641. X    /* Directory: Directory Iterator */
  642. X
  643. #define    DirectoryDir(dp)        ((dp)->filep)
  644. #define    DirectoryPath(dp)        ((dp)->path)
  645. X
  646. X    /* FileInfo: Information About A File Or Link */
  647. X
  648. #define    FileInfoProt(fi)        ((fi)->protections)
  649. #define FileInfoOrigMode(fi)        ((fi)->orig_mode)
  650. #define    FileInfoUserID(fi)        ((fi)->user_id)
  651. #define    FileInfoGroupID(fi)        ((fi)->group_id)
  652. #define    FileInfoFileSize(fi)        ((fi)->size)
  653. #define    FileInfoLastAccess(fi)        ((fi)->last_access)
  654. #define    FileInfoLastModify(fi)        ((fi)->last_modify)
  655. #define    FileInfoLastStatusChange(fi)    ((fi)->last_status_change)
  656. X
  657. #define    FIProt(fi)            FileInfoProt(fi)
  658. #define FIOrigMode(fi)            FileInfoOrigMode(fi)
  659. #define    FIUserID(fi)            FileInfoUserID(fi)
  660. #define    FIGroupID(fi)            FileInfoGroupID(fi)
  661. #define    FIFileSize(fi)            FileInfoFileSize(fi)
  662. #define    FILastAccess(fi)        FileInfoLastAccess(fi)
  663. #define    FILastModify(fi)        FileInfoLastModify(fi)
  664. #define    FILastStatusChange(fi)        FileInfoLastStatusChange(fi)
  665. X
  666. X    /* FType: File Type Macros */
  667. X
  668. #define    FTypeIsDir(ft)            ((ft) == F_TYPE_DIR)
  669. #define    FTypeIsFile(ft)            ((ft) == F_TYPE_FILE)
  670. #define    FTypeIsCharSpecial(ft)        ((ft) == F_TYPE_CHAR_SPECIAL)
  671. #define    FTypeIsBlockSpecial(ft)        ((ft) == F_TYPE_BLOCK_SPECIAL)
  672. #define    FTypeIsSymLink(ft)        ((ft) == F_TYPE_SYM_LINK)
  673. #define    FTypeIsSocket(ft)        ((ft) == F_TYPE_SOCKET)
  674. #define    FTypeIsFifo(ft)            ((ft) == F_TYPE_FIFO)
  675. X
  676. X    /* DirEntry: Information About A Item In A Directory */
  677. X
  678. #define    DirEntryFileName(fi)        ((fi)->filename)
  679. #define    DirEntryType(fi)        ((fi)->file_type)
  680. #define    DirEntrySelfInfo(fi)        (&((fi)->self_info))
  681. #define    DirEntryActualInfo(fi)        (&((fi)->actual_info))
  682. X
  683. #define    DirEntryIsBrokenLink(fi)    ((fi)->broken_link)
  684. #define    DirEntryIsDirectoryLink(fi)    ((fi)->directory_link)
  685. #define    DirEntryIsDir(fi)        (FTypeIsDir(DirEntryType(fi)))
  686. #define    DirEntryIsFile(fi)        (FTypeIsFile(DirEntryType(fi)))
  687. #define    DirEntryIsCharSpecial(fi)    (FTypeIsCharSpecial(DirEntryType(fi)))
  688. #define    DirEntryIsBlockSpecial(fi)    (FTypeIsBlockSpecial(DirEntryType(fi)))
  689. #define    DirEntryIsSymLink(fi)        (FTypeIsSymLink(DirEntryType(fi)))
  690. #define    DirEntryIsSocket(fi)        (FTypeIsSocket(DirEntryType(fi)))
  691. #define    DirEntryIsFifo(fi)        (FTypeIsFifo(DirEntryType(fi)))
  692. #define    DirEntryLeadsToDir(fi)        (DirEntryIsDir(fi) ||        \
  693. X                     DirEntryIsDirectoryLink(fi))
  694. X
  695. #define    DirEntryProt(d)            FIProt(DirEntrySelfInfo(d))
  696. #define DirEntryOrigMode(d)        FIOrigMode(DirEntrySelfInfo(d))
  697. #define    DirEntryUserID(d)        FIUserID(DirEntrySelfInfo(d))
  698. #define    DirEntryGroupID(d)        FIGroupID(DirEntrySelfInfo(d))
  699. #define    DirEntryFileSize(d)        FIFileSize(DirEntrySelfInfo(d))
  700. #define    DirEntryLastAccess(d)        FILastAccess(DirEntrySelfInfo(d))
  701. #define    DirEntryLastModify(d)        FILastModify(DirEntrySelfInfo(d))
  702. #define    DirEntryLastStatusChange(d)    FILastStatusChange(DirEntrySelfInfo(d))
  703. X
  704. /*--------------------------------------------------------------------------*
  705. X
  706. X             D A T A    T Y P E    D E F I N I T I O N S
  707. X
  708. X *--------------------------------------------------------------------------*/
  709. X
  710. X    /* Directory: Directory Iterator */
  711. X
  712. typedef struct
  713. {
  714. X    DIR *filep;
  715. X    char path[MAXPATHLEN + 2];
  716. } DIRECTORY;
  717. X
  718. typedef DIRECTORY Directory;
  719. X
  720. X    /* FileInfo: Information About A File Or Link */
  721. X
  722. typedef struct
  723. {
  724. X    short protections;
  725. X    short orig_mode;
  726. X    short user_id;
  727. X    short group_id;
  728. X    long size;
  729. X    time_t last_access;
  730. X    time_t last_modify;
  731. X    time_t last_status_change;
  732. } FILE_INFO;
  733. X
  734. typedef    FILE_INFO FileInfo;
  735. X
  736. X    /* DirEntry: Information About A Item In A Directory */
  737. X
  738. typedef struct
  739. {
  740. X    char filename[MAX_NAME_LENGTH + 1];
  741. X    short file_type;
  742. X    short broken_link;
  743. X    short directory_link;
  744. X    FileInfo self_info;
  745. X    FileInfo actual_info;
  746. } DIR_ENTRY;
  747. X
  748. typedef DIR_ENTRY DirEntry;
  749. X
  750. /*--------------------------------------------------------------------------*
  751. X
  752. X        L O W    L E V E L    D I R E C T O R Y    I N T E R F A C E
  753. X
  754. X *--------------------------------------------------------------------------*/
  755. X
  756. int        DirectoryOpen();
  757. void        DirectoryRestart();
  758. void        DirectoryClose();
  759. long        DirectoryTellPosition();
  760. void        DirectorySetPosition();
  761. int        DirectoryReadNextEntry();
  762. char        *DirectoryPathExpand();
  763. void        DirEntryDump();
  764. X
  765. #endif
  766. X
  767. X
  768. SHAR_EOF
  769. chmod 0644 xmfm/Directory.h ||
  770. echo 'restore of xmfm/Directory.h failed'
  771. Wc_c="`wc -c < 'xmfm/Directory.h'`"
  772. test 5473 -eq "$Wc_c" ||
  773.     echo 'xmfm/Directory.h: original size 5473, current size' "$Wc_c"
  774. rm -f _shar_wnt_.tmp
  775. fi
  776. # ============= xmfm/RegExp.h ==============
  777. if test -f 'xmfm/RegExp.h' -a X"$1" != X"-c"; then
  778.     echo 'x - skipping xmfm/RegExp.h (File already exists)'
  779.     rm -f _shar_wnt_.tmp
  780. else
  781. > _shar_wnt_.tmp
  782. echo 'x - extracting xmfm/RegExp.h (Text)'
  783. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/RegExp.h' &&
  784. /****************************************************************************
  785. X
  786. X    RegExp.h
  787. X
  788. X    This file contains the C definitions and declarations for
  789. X    the regular expression matching code.
  790. X
  791. X    The routines supported act as a more friendly, user level
  792. X    interface to the regexp regular expression matching system.
  793. X
  794. X ****************************************************************************/
  795. X
  796. #ifndef _REGEXP_H_
  797. #define    _REGEXP_H_
  798. X
  799. #include <stdio.h>
  800. X
  801. void        RegExpCompile();
  802. int        RegExpMatch();
  803. void        _RegExpError();
  804. void        RegExpPatternToRegExp();
  805. X
  806. #ifndef TRUE
  807. #define TRUE                1
  808. #endif
  809. X
  810. #ifndef FALSE
  811. #define    FALSE                0
  812. #endif
  813. X
  814. #define    INIT        register char *sp = instring;
  815. #define    GETC()        (*sp++)
  816. #define    PEEKC()        (*sp)
  817. #define    UNGETC(c)    -- sp
  818. #define    RETURN(ptr)    return;
  819. #define    ERROR(val)    _RegExpError(val)
  820. X
  821. #endif
  822. SHAR_EOF
  823. chmod 0644 xmfm/RegExp.h ||
  824. echo 'restore of xmfm/RegExp.h failed'
  825. Wc_c="`wc -c < 'xmfm/RegExp.h'`"
  826. test 814 -eq "$Wc_c" ||
  827.     echo 'xmfm/RegExp.h: original size 814, current size' "$Wc_c"
  828. rm -f _shar_wnt_.tmp
  829. fi
  830. # ============= xmfm/const.h ==============
  831. if test -f 'xmfm/const.h' -a X"$1" != X"-c"; then
  832.     echo 'x - skipping xmfm/const.h (File already exists)'
  833.     rm -f _shar_wnt_.tmp
  834. else
  835. > _shar_wnt_.tmp
  836. echo 'x - extracting xmfm/const.h (Text)'
  837. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/const.h' &&
  838. X
  839. #include "copyright.h"
  840. X
  841. #ifndef _XMFM_CONST_H
  842. #define _XMFM_CONST_H
  843. X
  844. /* let editres work on this application under R5 */
  845. /* #define ALLOW_EDITRES */
  846. X
  847. /* max number of args to a widget set/get */
  848. #define MAX_ARGS    20
  849. X
  850. /* returns from modal dialogs */
  851. #define OK_ANSWER 0
  852. #define CANCEL_ANSWER 1
  853. X
  854. /* client data in file menu callbacks to tell where
  855. ** it came from
  856. */
  857. #define EXIT_DIALOG 0
  858. #define LOAD_DIALOG 1 
  859. #define SAVE_DIALOG 2 
  860. #define NEW_DIALOG 3 
  861. #define PRINT_DIALOG 4 
  862. X
  863. #define DIRS_TOOLBAR_SIZE 6
  864. #define FILES_TOOLBAR_SIZE 6
  865. X
  866. #define FILE_TYPE 'f'
  867. #define DIR_TYPE  'd'
  868. #define EXECUTABLE_TYPE 'x'
  869. #define PANE_TYPE 'p'
  870. X
  871. #define CHDIR_COMMAND "cd"
  872. #define LEN_CHDIR_COMMAND 2
  873. X
  874. #define OPENDIR_COMMAND "opendir"
  875. #define LEN_OPENDIR_COMMAND 7
  876. X
  877. #define INFO_COMMAND "information"
  878. #define LEN_INFO_COMMAND 11
  879. X
  880. #include <sys/stat.h>
  881. #ifndef S_IXUSR
  882. /* Apollo eg has none of this stuff */
  883. #define S_IRUSR 0400
  884. #define S_IWUSR 0200
  885. #define S_IXUSR 0100
  886. #define S_IRGRP 0040
  887. #define S_IWGRP 0020
  888. #define S_IXGRP 0010
  889. #define S_IROTH 0004
  890. #define S_IWOTH 0002
  891. #define S_IXOTH 0001
  892. #endif
  893. X
  894. #endif /* _XMFM_CONST_H */
  895. SHAR_EOF
  896. chmod 0644 xmfm/const.h ||
  897. echo 'restore of xmfm/const.h failed'
  898. Wc_c="`wc -c < 'xmfm/const.h'`"
  899. test 1120 -eq "$Wc_c" ||
  900.     echo 'xmfm/const.h: original size 1120, current size' "$Wc_c"
  901. rm -f _shar_wnt_.tmp
  902. fi
  903. # ============= xmfm/copyright.h ==============
  904. if test -f 'xmfm/copyright.h' -a X"$1" != X"-c"; then
  905.     echo 'x - skipping xmfm/copyright.h (File already exists)'
  906.     rm -f _shar_wnt_.tmp
  907. else
  908. > _shar_wnt_.tmp
  909. echo 'x - extracting xmfm/copyright.h (Text)'
  910. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/copyright.h' &&
  911. #ifndef _XMFM_COPYRIGHT
  912. #define _XMFM_COPYRIGHT
  913. X
  914. /*********************************************************************
  915. Copyright (C) 1992 Jan Newmarch
  916. X
  917. Faculty of Information Sciences and Engineering
  918. University of Canberra
  919. PO Box 1, Belconnen 2614
  920. ACT, Australia
  921. X
  922. email: jan@ise.canberra.edu.au
  923. X
  924. X    This program is free software; you can redistribute it and/or modify
  925. X    it under the terms of the GNU General Public License as published by
  926. X    the Free Software Foundation; either version 2 of the License, or
  927. X    (at your option) any later version.
  928. X
  929. X    This program is distributed in the hope that it will be useful,
  930. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  931. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  932. X    GNU General Public License for more details.
  933. X
  934. X    You should have received a copy of the GNU General Public License
  935. X    along with this program; if not, write to the Free Software
  936. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  937. X
  938. *********************************************************************/
  939. X
  940. #endif /* _XMFM_COPYRIGHT */
  941. SHAR_EOF
  942. chmod 0644 xmfm/copyright.h ||
  943. echo 'restore of xmfm/copyright.h failed'
  944. Wc_c="`wc -c < 'xmfm/copyright.h'`"
  945. test 1103 -eq "$Wc_c" ||
  946.     echo 'xmfm/copyright.h: original size 1103, current size' "$Wc_c"
  947. rm -f _shar_wnt_.tmp
  948. fi
  949. # ============= xmfm/filecb.h ==============
  950. if test -f 'xmfm/filecb.h' -a X"$1" != X"-c"; then
  951.     echo 'x - skipping xmfm/filecb.h (File already exists)'
  952.     rm -f _shar_wnt_.tmp
  953. else
  954. > _shar_wnt_.tmp
  955. echo 'x - extracting xmfm/filecb.h (Text)'
  956. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/filecb.h' &&
  957. X
  958. #include "copyright.h"
  959. X
  960. #ifndef _XMFM_FILECB_H
  961. #define _XMFM_FILECB_H
  962. X
  963. /* client data in file menu callbacks to tell where
  964. ** it came from
  965. */
  966. #define EXIT_DIALOG 0
  967. #define LOAD_DIALOG 1 
  968. #define SAVE_DIALOG 2 
  969. #define NEW_DIALOG 3 
  970. #define PRINT_DIALOG 4 
  971. X
  972. #endif /* _XMFM_FILECB_H */
  973. SHAR_EOF
  974. chmod 0644 xmfm/filecb.h ||
  975. echo 'restore of xmfm/filecb.h failed'
  976. Wc_c="`wc -c < 'xmfm/filecb.h'`"
  977. test 286 -eq "$Wc_c" ||
  978.     echo 'xmfm/filecb.h: original size 286, current size' "$Wc_c"
  979. rm -f _shar_wnt_.tmp
  980. fi
  981. # ============= xmfm/macros.h ==============
  982. if test -f 'xmfm/macros.h' -a X"$1" != X"-c"; then
  983.     echo 'x - skipping xmfm/macros.h (File already exists)'
  984.     rm -f _shar_wnt_.tmp
  985. else
  986. > _shar_wnt_.tmp
  987. echo 'x - extracting xmfm/macros.h (Text)'
  988. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/macros.h' &&
  989. X
  990. #include "copyright.h"
  991. X
  992. /* return an index 'a' -> 0, 'z' -> 25, 'A' -> 26, 'Z' -> 51
  993. */
  994. #define ALPHINDEX(ch)     ((ch) >= 'a' && (ch) <= 'z' ? ((ch) - 'a') : \
  995. X             (ch) >= 'A' && (ch) <= 'Z' ? ((ch) - 'A' + 26) : \
  996. X                 fatal("alpha out of range"))
  997. X
  998. /* return an index into the list of words, based on the
  999. ** length of a word. Asumes the following pattern:
  1000. **    all words less than a min length are stored in one list
  1001. **    all words greater than a max length are stored in max list
  1002. **    all other words are stored in list of same length as word
  1003. */
  1004. #define LISTINDEX(i)    ((i) <= ListLowerIndex ? ListLowerIndex : \
  1005. X             (i) >= ListUpperIndex ? ListUpperIndex : \
  1006. X                           (i))
  1007. X
  1008. extern int ListLowerIndex;
  1009. extern int ListUpperIndex;
  1010. X
  1011. /* fix a clash between Motif traversal and Xt by faking our
  1012. ** own routine, to change on Motif 1.1
  1013. */
  1014. #define XmSetKeyboardFocus(x, y) _XmGrabTheFocus(y)
  1015. X
  1016. #define max(x,y)    ((x) > (y) ? (x) : (y))
  1017. SHAR_EOF
  1018. chmod 0644 xmfm/macros.h ||
  1019. echo 'restore of xmfm/macros.h failed'
  1020. Wc_c="`wc -c < 'xmfm/macros.h'`"
  1021. test 922 -eq "$Wc_c" ||
  1022.     echo 'xmfm/macros.h: original size 922, current size' "$Wc_c"
  1023. rm -f _shar_wnt_.tmp
  1024. fi
  1025. # ============= xmfm/rdd.h ==============
  1026. if test -f 'xmfm/rdd.h' -a X"$1" != X"-c"; then
  1027.     echo 'x - skipping xmfm/rdd.h (File already exists)'
  1028.     rm -f _shar_wnt_.tmp
  1029. else
  1030. > _shar_wnt_.tmp
  1031. echo 'x - extracting xmfm/rdd.h (Text)'
  1032. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/rdd.h' &&
  1033. /*                               -*- Mode: C -*- 
  1034. X * rdd.h
  1035. X * 
  1036. X * Description     : Header file for rdd, plus a few other things
  1037. X *                      that rdd needs declared.
  1038. X * 
  1039. X * Author          : Roger Reynolds
  1040. X * Created On      : Wed Jun 17 12:05:55 1992
  1041. X * 
  1042. X * Configuration Management
  1043. X * 
  1044. X * @(#)rdd.h    1.7    10/5/92
  1045. X * 
  1046. X * VERSION   SPR   MODIFIER   DATE AND TIME
  1047. X * 1.7       0     rogerr     Mon Oct  5 14:34:36 1992
  1048. X *           more gcc stuff. 
  1049. X * 1.6       0     rogerr     Tue Sep 29 11:41:27 1992
  1050. X *           GCC2.2.2 clean up. Can now be cleanly compiled without 
  1051. X *           -traditional. 
  1052. X * 1.5       0     rogerr     Thu Aug 27 15:20:08 1992
  1053. X *           clean up for C++ part 1 
  1054. X * 1.4       0     rogerr     Wed Jul 15 14:49:27 1992
  1055. X *           send keymask in RddCallbackStruct so dropee knows what was 
  1056. X *           going on 
  1057. X * 1.3       0     rogerr     Tue Jun 23 17:08:58 1992
  1058. X *           now dragging pixmaps around 
  1059. X * 
  1060. X */
  1061. X
  1062. #ifndef RDD_LIB_H
  1063. #define RDD_LIB_H
  1064. X
  1065. #include <stdio.h>
  1066. #include <errno.h>
  1067. X
  1068. /*
  1069. X * The only thing that needs Xm is rddDragCallback, you can lose or modify
  1070. X * it if you are not using Motif.
  1071. X */
  1072. #include <Xm/Xm.h>
  1073. X
  1074. #undef _PROTO_ARGS_
  1075. #undef const
  1076. #if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus)
  1077. #   define _PROTO_ARGS_(x)    x
  1078. #   define CONST const
  1079. #   ifdef __cplusplus
  1080. #       define VARARGS (...)
  1081. #   else
  1082. #       define VARARGS ()
  1083. #   endif
  1084. #else
  1085. #   define _PROTO_ARGS_(x)    ()
  1086. #   define CONST
  1087. #endif
  1088. X
  1089. #ifdef __cplusplus
  1090. #   define EXTERN extern "C"
  1091. #else
  1092. #   define EXTERN extern
  1093. #endif
  1094. X
  1095. X
  1096. /*
  1097. X *  Execute the code in the DEBUGRDD macro if defined 
  1098. X */
  1099. X
  1100. #ifdef DEBUGRDD_ON
  1101. #define DEBUGRDD(x) {x}
  1102. #else
  1103. #define DEBUGRDD(x)
  1104. #endif
  1105. X
  1106. /*
  1107. X *  Print the (string) message given, along with file and line number 
  1108. X */
  1109. #ifdef TRACE_ON
  1110. #define TRACE(x) fprintf(stderr, "TRACE %s %s,%d\n", (x), __FILE__, __LINE__)
  1111. #else
  1112. #define TRACE(x)
  1113. #endif
  1114. X
  1115. /*
  1116. X * This will make free go alot slower, but should trap cases where 
  1117. X * the pointer being deallocated is not within the allocated memory area,
  1118. X * like if it was the address of a variable on the stack.
  1119. X */
  1120. #ifdef DEBUGRDD_FREE_ON
  1121. #define XtFree(x) \
  1122. X    (((unsigned long)x == 0) ? fprintf(stderr, "Attempt to free NULL at %s %d\n", __FILE__, __LINE__) : \
  1123. X     (((unsigned long)x > sbrk(0)) ? fprintf(stderr, "Attempt to free non allocated address at %s %d\n", __FILE__, __LINE__) : free(x)))
  1124. X
  1125. #endif
  1126. X
  1127. /* A few predefined data types */
  1128. #define RDD_NO_DATA_TYPE    0        /* unspecified drop data type        */
  1129. #define RDD_FILENAME_TYPE    1        /* filename in drop data            */
  1130. X
  1131. typedef struct _rddCallbackStruct
  1132. {
  1133. X    caddr_t data;                        /* pointer to dropped data    */
  1134. X    int  len;                            /* length of data            */
  1135. X    int  type;                            /* type of data dropped        */
  1136. X    Window from;                        /* Window message is from    */
  1137. X    u_int keymask;                        /* keybord modifier mask    */
  1138. X    XClientMessageEvent *event;            /* the ClientMessage event    */
  1139. } RddCallbackStruct;    
  1140. X
  1141. EXTERN    void    rddInit     
  1142. X    _PROTO_ARGS_((Widget shell, XtAppContext appContext));
  1143. X
  1144. EXTERN    void    rddAppMainLoop 
  1145. X    _PROTO_ARGS_((XtAppContext appContext));
  1146. X
  1147. EXTERN    void    rddAddDropHandler
  1148. X    _PROTO_ARGS_((Widget w, XtCallbackProc proc, caddr_t call));
  1149. X
  1150. EXTERN    void    rddSendDropEvent
  1151. X    _PROTO_ARGS_((Widget w, XEvent *event));
  1152. X
  1153. EXTERN    void     rddSetDropData
  1154. X    _PROTO_ARGS_((caddr_t data, int size));
  1155. X
  1156. EXTERN    void     rddStartAction
  1157. X    _PROTO_ARGS_((Widget w, XButtonEvent *event, String *args, int *nargs));
  1158. X
  1159. EXTERN    void     rddDragAction
  1160. X    _PROTO_ARGS_((Widget w, XButtonEvent *event, String *args, int *nargs));
  1161. X
  1162. EXTERN    void     rddDropAction
  1163. X    _PROTO_ARGS_((Widget w, XButtonEvent *event, String *args, int *nargs));
  1164. X
  1165. EXTERN    void     rddDragCallback
  1166. X    _PROTO_ARGS_((Widget w, XtPointer call, XmAnyCallbackStruct *cbs));
  1167. X
  1168. #endif /*RDD_LIB_H*/
  1169. X
  1170. X
  1171. SHAR_EOF
  1172. chmod 0644 xmfm/rdd.h ||
  1173. echo 'restore of xmfm/rdd.h failed'
  1174. Wc_c="`wc -c < 'xmfm/rdd.h'`"
  1175. test 3744 -eq "$Wc_c" ||
  1176.     echo 'xmfm/rdd.h: original size 3744, current size' "$Wc_c"
  1177. rm -f _shar_wnt_.tmp
  1178. fi
  1179. # ============= xmfm/types.h ==============
  1180. if test -f 'xmfm/types.h' -a X"$1" != X"-c"; then
  1181.     echo 'x - skipping xmfm/types.h (File already exists)'
  1182.     rm -f _shar_wnt_.tmp
  1183. else
  1184. > _shar_wnt_.tmp
  1185. echo 'x - extracting xmfm/types.h (Text)'
  1186. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/types.h' &&
  1187. /*************************************************************************
  1188. X * File: $Source: /usr/usrs/xsource/xmfm/RCS/types.h,v $
  1189. X * Author: Jan Newmarch
  1190. X * Last modified: $Date: 1992/11/17 00:35:57 $
  1191. X * Version: $Revision: 1.6 $
  1192. X * Purpose:
  1193. X *
  1194. X * Revision history:
  1195. X *    11 Aug 92    added description field to file_action
  1196. X *      22 Ayg 92       added run_dialog and info_dialog as per pane stuff
  1197. X ************************************************************************/ 
  1198. X
  1199. #include "copyright.h"
  1200. X
  1201. #ifndef _XMFM_TYPES_H
  1202. #define _XMFM_TYPES_H
  1203. X
  1204. #include <Xm/Xm.h>
  1205. X
  1206. #include "DirMgr.h"
  1207. X
  1208. #define FSM_LENGTH 1024
  1209. X
  1210. /*****************************************************************
  1211. X * Data type:
  1212. X * Used by:
  1213. X * Purpose:
  1214. X * Description:
  1215. X *****************************************************************/
  1216. X
  1217. /*****************************************************************
  1218. X * Data type: action_pair
  1219. X * Used by: do_command(), FileToolbarButtonPressed()
  1220. X * Purpose: define a possible action that can be taken on a file
  1221. X * Description: It contains a label to be displayed in an action button,
  1222. X *        the action itself,
  1223. X *        Booleans to control the exection environment of the command,
  1224. X *        and a pointer to another action_pair record
  1225. X *****************************************************************/
  1226. typedef struct action_pair
  1227. {
  1228. X    char            *action_label;
  1229. X    char            *action;
  1230. X    char            *prompt;
  1231. X    Bool            run_in_xterm;
  1232. X    Bool            pause_after_exec;
  1233. X    Bool            has_prompt;
  1234. X    struct action_pair    *next;
  1235. }    action_pair;
  1236. X
  1237. X
  1238. typedef struct file_action
  1239. {
  1240. X    char            file_type;
  1241. X    char            *name_pattern;
  1242. X    char            fsm_ptr[FSM_LENGTH];
  1243. X    char            *pixmap;
  1244. X    char            *description;
  1245. X    action_pair        *actions;
  1246. X    struct file_action    *next;
  1247. }    file_action;
  1248. X
  1249. typedef struct aWidgetList
  1250. {
  1251. X    Widget            widget;
  1252. X    struct aWidgetList    *next;
  1253. }    aWidgetList;
  1254. X
  1255. typedef struct info_dialog_widgets
  1256. {  Widget    form,
  1257. X                filename_label,
  1258. X        filename,
  1259. X                separator,
  1260. X        size_label,
  1261. X        size,
  1262. X        owner_label,
  1263. X        owner,
  1264. X        description_label,
  1265. X        description,
  1266. X        perms_label,
  1267. X        perms_rowcol,
  1268. X        empty_label,
  1269. X        read_label,
  1270. X        write_label,
  1271. X                exec_label,
  1272. X        user_label,
  1273. X        group_label,
  1274. X        other_label,
  1275. X        ur_toggle,
  1276. X        uw_toggle,
  1277. X        ux_toggle,
  1278. X        gr_toggle,
  1279. X        gw_toggle,
  1280. X        gx_toggle,
  1281. X        or_toggle,
  1282. X        ow_toggle,
  1283. X        ox_toggle;
  1284. }      info_dialog_widgets;
  1285. X
  1286. X
  1287. /*****************************************************************
  1288. X * Data type: dir_pane-info
  1289. X * Used by: almost everything.
  1290. X * Purpose: it carries around "global" data to all callbacks that need
  1291. X *    it.  It is placed in the user data of most widgets (except file
  1292. X *    buttons, which use pane_button_info, and toolbar buttons which
  1293. X *    use tool_button_info). Most callbacks get this structure from
  1294. X *    their userData first off. There is one of these per directory
  1295. X *    showing.
  1296. X * Description:
  1297. X *****************************************************************/
  1298. typedef struct dir_pane_info
  1299. {    
  1300. X    /* label at top showing current dir */
  1301. X    Widget        directory_label;
  1302. X
  1303. X    /* two sets of toolbar buttons */
  1304. X    Widget        *files_toolbar;
  1305. X    Widget        *dirs_toolbar;
  1306. X
  1307. X    /* three lists of file/dir/exec buttons in the panes */
  1308. X    aWidgetList    *files_buttons;
  1309. X    aWidgetList    *executables_buttons;
  1310. X    aWidgetList    *dirs_buttons;
  1311. X
  1312. X    /* and the panes they are in */
  1313. X    Widget        files_pane;
  1314. X    Widget        dirs_pane;
  1315. X    Widget        executables_pane;
  1316. X
  1317. X    /* list of all files in current dir matching selection pattern */
  1318. X    DirectoryMgr    *directory_manager;
  1319. X
  1320. X    /* currently selected file/dir/exec button */
  1321. X    char        *file_selected;        /* name */
  1322. X    Widget        file_button_selected;    /* widget button */
  1323. X    char        *description;        /* what sort of file */
  1324. X
  1325. X    char        *executable_selected;    /* unused */
  1326. X    char        *dir_selected;        /* unused */
  1327. X
  1328. X    /* top of this widget tree */
  1329. X    Widget        toplevel;
  1330. X
  1331. X    /* filters used in file matching */
  1332. X    char        *file_filter;
  1333. X    char        file_filter_regexp[FSM_LENGTH];
  1334. X    char        *dir_filter;
  1335. X    char        dir_filter_regexp[FSM_LENGTH];
  1336. X    char        *executable_filter;
  1337. X    char        executable_filter_regexp[FSM_LENGTH];
  1338. X    char        all_filter;
  1339. X
  1340. X    /* widgets showing the filter info */
  1341. X    Widget        file_filter_label;
  1342. X    Widget        dir_filter_label;
  1343. X    Widget        executable_filter_label;
  1344. X
  1345. X        /* dialogs that are non-transient, must be kept on a per pane basis */
  1346. X        Widget          run_dialog;
  1347. X        Widget          info_dialog;
  1348. X        info_dialog_widgets *idw;
  1349. }    dir_pane_info;
  1350. X
  1351. typedef struct pane_button_info
  1352. {    char        *name;
  1353. X    char        file_type;
  1354. X    dir_pane_info    *dpi;
  1355. X    Pixmap        pixmap;
  1356. X    Pixmap        pixmap_reversed;
  1357. X    GC        gc;
  1358. X    GC        gc_reversed;
  1359. }    pane_button_info;
  1360. X
  1361. typedef struct tool_button_info
  1362. {    char        *action;
  1363. X    dir_pane_info    *dpi;
  1364. X    Bool        run_in_xterm;
  1365. X    Bool        pause_after_exec;
  1366. X        Bool            has_prompt;
  1367. X        char            *prompt;
  1368. }    tool_button_info;
  1369. X
  1370. #ifndef S_ISDIR
  1371. #define S_ISDIR(m)    ((m) & S_IFDIR)
  1372. #endif
  1373. X
  1374. #endif /* _XMFM_TYPES_H */
  1375. SHAR_EOF
  1376. chmod 0644 xmfm/types.h ||
  1377. echo 'restore of xmfm/types.h failed'
  1378. Wc_c="`wc -c < 'xmfm/types.h'`"
  1379. test 4730 -eq "$Wc_c" ||
  1380.     echo 'xmfm/types.h: original size 4730, current size' "$Wc_c"
  1381. rm -f _shar_wnt_.tmp
  1382. fi
  1383. # ============= xmfm/xmvararg.h ==============
  1384. if test -f 'xmfm/xmvararg.h' -a X"$1" != X"-c"; then
  1385.     echo 'x - skipping xmfm/xmvararg.h (File already exists)'
  1386.     rm -f _shar_wnt_.tmp
  1387. else
  1388. > _shar_wnt_.tmp
  1389. echo 'x - extracting xmfm/xmvararg.h (Text)'
  1390. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/xmvararg.h' &&
  1391. X
  1392. #include "copyright.h"
  1393. X
  1394. /*    xmvarargs.h
  1395. **    External definitions of varargs funcs
  1396. */
  1397. X
  1398. /* 
  1399. **    need Xm.h to find the current version number
  1400. */
  1401. #ifndef _XMVARARGS_H
  1402. #define _XMVARARGS_H
  1403. X
  1404. #include <Xm/Xm.h>
  1405. X
  1406. /*
  1407. **    varargs interface for Xt not defined for Motif 1.0
  1408. **    because it is based on X11 R3. In this case, define
  1409. **    equivalents to the Xt functions
  1410. */
  1411. #if XmVersion == 1000
  1412. extern Widget     XtVaCreateManagedWidget();
  1413. extern void    XtVaSetValues();
  1414. extern void    XtVaGetValues();
  1415. #endif
  1416. X
  1417. /* 
  1418. ** widgets
  1419. */
  1420. extern Widget    XmVaCreateArrowButton(
  1421. #ifdef UseFunctionPrototypes
  1422. X    ...
  1423. #endif
  1424. );
  1425. extern Widget    XmVaCreateBulletinBoard(
  1426. #ifdef UseFunctionPrototypes
  1427. X    ...
  1428. #endif
  1429. );
  1430. extern Widget    XmVaCreateCascadeButton(
  1431. #ifdef UseFunctionPrototypes
  1432. X    ...
  1433. #endif
  1434. );
  1435. extern Widget    XmVaCreateCommand(
  1436. #ifdef UseFunctionPrototypes
  1437. X    ...
  1438. #endif
  1439. );
  1440. extern Widget    XmVaCreateDialogShell(
  1441. #ifdef UseFunctionPrototypes
  1442. X    ...
  1443. #endif
  1444. );
  1445. extern Widget    XmVaCreateDrawingArea(
  1446. #ifdef UseFunctionPrototypes
  1447. X    ...
  1448. #endif
  1449. );
  1450. extern Widget    XmVaCreateDrawnButton(
  1451. #ifdef UseFunctionPrototypes
  1452. X    ...
  1453. #endif
  1454. );
  1455. extern Widget    XmVaCreateFileSelectionBox(
  1456. #ifdef UseFunctionPrototypes
  1457. X    ...
  1458. #endif
  1459. );
  1460. extern Widget    XmVaCreateForm(
  1461. #ifdef UseFunctionPrototypes
  1462. X    ...
  1463. #endif
  1464. );
  1465. extern Widget    XmVaCreateFrame(
  1466. #ifdef UseFunctionPrototypes
  1467. X    ...
  1468. #endif
  1469. );
  1470. extern Widget    XmVaCreateLabel(
  1471. #ifdef UseFunctionPrototypes
  1472. X    ...
  1473. #endif
  1474. );
  1475. extern Widget    XmVaCreateList(
  1476. #ifdef UseFunctionPrototypes
  1477. X    ...
  1478. #endif
  1479. );
  1480. extern Widget    XmVaCreateMainWindow(
  1481. #ifdef UseFunctionPrototypes
  1482. X    ...
  1483. #endif
  1484. );
  1485. extern Widget    XmVaCreateMessageBox(
  1486. #ifdef UseFunctionPrototypes
  1487. X    ...
  1488. #endif
  1489. );
  1490. extern Widget    XmVaCreatePanedWindow(
  1491. #ifdef UseFunctionPrototypes
  1492. X    ...
  1493. #endif
  1494. );
  1495. extern Widget    XmVaCreatePushButton(
  1496. #ifdef UseFunctionPrototypes
  1497. X    ...
  1498. #endif
  1499. );
  1500. extern Widget    XmVaCreateRowColumn(
  1501. #ifdef UseFunctionPrototypes
  1502. X    ...
  1503. #endif
  1504. );
  1505. extern Widget    XmVaCreateScale(
  1506. #ifdef UseFunctionPrototypes
  1507. X    ...
  1508. #endif
  1509. );
  1510. extern Widget    XmVaCreateScrollBar(
  1511. #ifdef UseFunctionPrototypes
  1512. X    ...
  1513. #endif
  1514. );
  1515. extern Widget    XmVaCreateSelectionBox(
  1516. #ifdef UseFunctionPrototypes
  1517. X    ...
  1518. #endif
  1519. );
  1520. extern Widget    XmVaCreateSeparator(
  1521. #ifdef UseFunctionPrototypes
  1522. X    ...
  1523. #endif
  1524. );
  1525. extern Widget    XmVaCreateText(
  1526. #ifdef UseFunctionPrototypes
  1527. X    ...
  1528. #endif
  1529. );
  1530. extern Widget    XmVaCreateToggleButton(
  1531. #ifdef UseFunctionPrototypes
  1532. X    ...
  1533. #endif
  1534. );
  1535. X
  1536. /*
  1537. ** dialogs
  1538. */
  1539. extern Widget    XmVaCreateErrorDialog(
  1540. #ifdef UseFunctionPrototypes
  1541. X    ...
  1542. #endif
  1543. );
  1544. extern Widget    XmVaCreateFileSelectionDialog(
  1545. #ifdef UseFunctionPrototypes
  1546. X    ...
  1547. #endif
  1548. );
  1549. extern Widget    XmVaCreateFormDialog(
  1550. #ifdef UseFunctionPrototypes
  1551. X    ...
  1552. #endif
  1553. );
  1554. extern Widget    XmVaCreateInformationDialog(
  1555. #ifdef UseFunctionPrototypes
  1556. X    ...
  1557. #endif
  1558. );
  1559. extern Widget    XmVaCreateMessageDialog(
  1560. #ifdef UseFunctionPrototypes
  1561. X    ...
  1562. #endif
  1563. );
  1564. extern Widget    XmVaCreatePromptDialog(
  1565. #ifdef UseFunctionPrototypes
  1566. X    ...
  1567. #endif
  1568. );
  1569. extern Widget    XmVaCreateQuestionDialog(
  1570. #ifdef UseFunctionPrototypes
  1571. X    ...
  1572. #endif
  1573. );
  1574. extern Widget    XmVaCreateSelectionDialog(
  1575. #ifdef UseFunctionPrototypes
  1576. X    ...
  1577. #endif
  1578. );
  1579. extern Widget    XmVaCreateWarningDialog(
  1580. #ifdef UseFunctionPrototypes
  1581. X    ...
  1582. #endif
  1583. );
  1584. extern Widget    XmVaCreateWorkingDialog(
  1585. #ifdef UseFunctionPrototypes
  1586. X    ...
  1587. #endif
  1588. );
  1589. X
  1590. /*
  1591. ** rowcolumn convenience routines
  1592. */
  1593. extern Widget    XmVaCreateMenuBar(
  1594. #ifdef UseFunctionPrototypes
  1595. X    ...
  1596. #endif
  1597. );
  1598. extern Widget    XmVaCreateOptionMenu(
  1599. #ifdef UseFunctionPrototypes
  1600. X    ...
  1601. #endif
  1602. );
  1603. extern Widget    XmVaCreatePopupMenu(
  1604. #ifdef UseFunctionPrototypes
  1605. X    ...
  1606. #endif
  1607. );
  1608. extern Widget    XmVaCreatePulldownMenu(
  1609. #ifdef UseFunctionPrototypes
  1610. X    ...
  1611. #endif
  1612. );
  1613. extern Widget    XmVaCreateRadioBox(
  1614. #ifdef UseFunctionPrototypes
  1615. X    ...
  1616. #endif
  1617. );
  1618. X
  1619. /*
  1620. ** scrollbar convenience routines
  1621. */
  1622. extern Widget    XmVaCreateScrolledList(
  1623. #ifdef UseFunctionPrototypes
  1624. X    ...
  1625. #endif
  1626. );
  1627. extern Widget    XmVaCreateScrolledText(
  1628. #ifdef UseFunctionPrototypes
  1629. X    ...
  1630. #endif
  1631. );
  1632. extern Widget    XmVaCreateScrolledWindow(
  1633. #ifdef UseFunctionPrototypes
  1634. X    ...
  1635. #endif
  1636. );
  1637. X
  1638. X
  1639. #endif /* _XMVARARGS_H */
  1640. SHAR_EOF
  1641. chmod 0644 xmfm/xmvararg.h ||
  1642. echo 'restore of xmfm/xmvararg.h failed'
  1643. Wc_c="`wc -c < 'xmfm/xmvararg.h'`"
  1644. test 3932 -eq "$Wc_c" ||
  1645.     echo 'xmfm/xmvararg.h: original size 3932, current size' "$Wc_c"
  1646. rm -f _shar_wnt_.tmp
  1647. fi
  1648. # ============= xmfm/DirMgr.c ==============
  1649. if test -f 'xmfm/DirMgr.c' -a X"$1" != X"-c"; then
  1650.     echo 'x - skipping xmfm/DirMgr.c (File already exists)'
  1651.     rm -f _shar_wnt_.tmp
  1652. else
  1653. > _shar_wnt_.tmp
  1654. echo 'x - extracting xmfm/DirMgr.c (Text)'
  1655. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/DirMgr.c' &&
  1656. /****************************************************************************
  1657. X
  1658. X    DirMgr.c
  1659. X
  1660. X    This file contains the C code to implement the DirectoryMgr system.
  1661. X
  1662. X    This system is intended to manage filtered and sorted directory
  1663. X    lists.
  1664. X
  1665. X ****************************************************************************/
  1666. X
  1667. #include "DirMgr.h"
  1668. X
  1669. #define    DIR_MGR_FSM_SIZE 1024
  1670. X
  1671. /*---------------------------------------------------------------------------*
  1672. X
  1673. X                   S I M P L E    I N T E R F A C E
  1674. X
  1675. X *---------------------------------------------------------------------------*/
  1676. X
  1677. DirectoryMgr *DirectoryMgrSimpleOpen
  1678. #ifdef UseFunctionPrototypes
  1679. X    (char *path, int sort_type, char *pattern)
  1680. #else
  1681. X    (path,sort_type,pattern)
  1682. char *path;
  1683. int sort_type;
  1684. char *pattern;
  1685. X
  1686. #endif
  1687. {
  1688. X    DirectoryMgr *dm;
  1689. X    PFI f_func,s_func;
  1690. X    char *f_data;
  1691. X
  1692. X    if (pattern == NULL) pattern = "*";
  1693. X    if (!DirectoryMgrSimpleFilterFunc(pattern,&f_func,&f_data))
  1694. X    {
  1695. X        return(NULL);
  1696. X    }
  1697. X    if (!DirectoryMgrSimpleSortingFunc(sort_type,&s_func))
  1698. X    {
  1699. X        free(f_data);
  1700. X        return(NULL);
  1701. X    }
  1702. X    dm = DirectoryMgrOpen(path,s_func,f_func,f_data,TRUE);
  1703. X    return(dm);
  1704. } /* End DirectoryMgrSimpleOpen */
  1705. X
  1706. X
  1707. int DirectoryMgrSimpleRefilter
  1708. #ifdef UseFunctionPrototypes
  1709. X    (DirectoryMgr *dm, char *pattern)
  1710. #else
  1711. X    (dm,pattern)
  1712. DirectoryMgr *dm;
  1713. char *pattern;
  1714. X
  1715. #endif
  1716. {
  1717. X    PFI f_func;
  1718. X    char *f_data;
  1719. X
  1720. X    if (!DirectoryMgrSimpleFilterFunc(pattern,&f_func,&f_data))
  1721. X    {
  1722. X        return(FALSE);
  1723. X    }
  1724. X    DirectoryMgrRefilter(dm,f_func,f_data,TRUE);
  1725. X    return(TRUE);
  1726. } /* End DirectoryMgrSimpleRefilter */
  1727. X
  1728. X
  1729. int DirectoryMgrSimpleResort
  1730. #ifdef UseFunctionPrototypes
  1731. X    (DirectoryMgr *dm, int sort_type)
  1732. #else
  1733. X    (dm,sort_type)
  1734. DirectoryMgr *dm;
  1735. int sort_type;
  1736. X
  1737. #endif
  1738. {
  1739. X    PFI c_func;
  1740. X
  1741. X    if (!DirectoryMgrSimpleSortingFunc(sort_type,&c_func))
  1742. X    {
  1743. X        return(FALSE);
  1744. X    }
  1745. X    DirectoryMgrResort(dm,c_func);
  1746. X    return(TRUE);
  1747. } /* End DirectoryMgrSimpleResort */
  1748. X
  1749. X
  1750. /*---------------------------------------------------------------------------*
  1751. X
  1752. X                    N O R M A L    I N T E R F A C E
  1753. X
  1754. X *---------------------------------------------------------------------------*/
  1755. X
  1756. DirectoryMgr *DirectoryMgrOpen
  1757. #ifdef UseFunctionPrototypes
  1758. X    (char *path, PFI c_func, PFI f_func, char *f_data, int free_data)
  1759. #else
  1760. X    (path,c_func,f_func,f_data,free_data)
  1761. char *path;
  1762. PFI c_func,f_func;
  1763. char *f_data;
  1764. int free_data;
  1765. X
  1766. #endif
  1767. {
  1768. X    DirectoryMgr *dm;
  1769. X
  1770. X    dm = (DirectoryMgr *)calloc(1,sizeof(DirectoryMgr));
  1771. X    if (dm == NULL)
  1772. X    {
  1773. X        if (free_data && f_data) free(f_data);
  1774. X        return(NULL);
  1775. X    }
  1776. X    if (DirectoryOpen(path,DirectoryMgrDir(dm)) == FALSE)
  1777. X    {
  1778. X        free(dm);
  1779. X        if (free_data && f_data) free(f_data);
  1780. X        return(NULL);
  1781. X    }
  1782. X    DirectoryMgrCompFunc(dm) = c_func;
  1783. X    DirectoryMgrRefilter(dm,f_func,f_data,free_data);
  1784. X    return(dm);
  1785. } /* End DirectoryMgrOpen */
  1786. X
  1787. X
  1788. void DirectoryMgrClose
  1789. #ifdef UseFunctionPrototypes
  1790. X    (DirectoryMgr *dm)
  1791. #else
  1792. X    (dm)
  1793. DirectoryMgr *dm;
  1794. X
  1795. #endif
  1796. {
  1797. X    free(DirectoryMgrData(dm));
  1798. X    free(DirectoryMgrSortedPtrs(dm));
  1799. X    if (DirectoryMgrFilterData(dm) && DirectoryMgrFreeFilterData(dm))
  1800. X    {
  1801. X        free(DirectoryMgrFilterData(dm));
  1802. X    }
  1803. X    DirectoryClose(DirectoryMgrDir(dm));
  1804. X    free(dm);
  1805. } /* End DirectoryMgrClose */
  1806. X
  1807. X
  1808. int DirectoryMgrRefilter
  1809. #ifdef UseFunctionPrototypes
  1810. X    (DirectoryMgr *dm, PFI f_func, char *f_data, int f_free)
  1811. #else
  1812. X    (dm,f_func,f_data,f_free)
  1813. DirectoryMgr *dm;
  1814. PFI f_func;
  1815. char *f_data;
  1816. int f_free;
  1817. X
  1818. #endif
  1819. {
  1820. X    if (DirectoryMgrFilterData(dm) && DirectoryMgrFreeFilterData(dm))
  1821. X    {
  1822. X        free(DirectoryMgrFilterData(dm));
  1823. X    }
  1824. X    DirectoryMgrFilterFunc(dm) = f_func;
  1825. X    DirectoryMgrFilterData(dm) = f_data;
  1826. X    DirectoryMgrFreeFilterData(dm) = f_free;
  1827. X    DirectoryMgrRefresh(dm);
  1828. } /* End DirectoryMgrRefilter */
  1829. X
  1830. X
  1831. int DirectoryMgrRefresh
  1832. #ifdef UseFunctionPrototypes
  1833. X    (DirectoryMgr *dm)
  1834. #else
  1835. X    (dm)
  1836. DirectoryMgr *dm;
  1837. X
  1838. #endif
  1839. {
  1840. X    int err,data_size,ptrs_size,i;
  1841. X    DirEntryCons *head,*tail,*cons;
  1842. X    DirEntry *dm_data,**dm_ptrs;
  1843. X    PFI f_func;
  1844. X    char *f_data;
  1845. X
  1846. X    DirectoryMgrTotalCount(dm) = 0;
  1847. X    DirectoryMgrFilteredCount(dm) = 0;
  1848. X    DirectoryRestart(DirectoryMgrDir(dm));
  1849. X    if (DirectoryMgrData(dm)) free(DirectoryMgrData(dm));
  1850. X    if (DirectoryMgrSortedPtrs(dm)) free(DirectoryMgrSortedPtrs(dm));
  1851. X    head = NULL;
  1852. X    f_func = DirectoryMgrFilterFunc(dm);
  1853. X    f_data = DirectoryMgrFilterData(dm);
  1854. X    while (1)
  1855. X    {
  1856. X        cons = (DirEntryCons *)malloc(sizeof(DirEntryCons));
  1857. X        if (cons == NULL)
  1858. X        {
  1859. X            fprintf(stderr,
  1860. X                "DirectoryMgrRefresh: Can't Alloc Cons\n");
  1861. X            exit(-1);
  1862. X        }
  1863. X        err = DirectoryReadNextEntry(DirectoryMgrDir(dm),
  1864. X                         &(cons->dir_entry));
  1865. X        if (err == FALSE)
  1866. X        {
  1867. X            free(cons);
  1868. X            break;
  1869. X        }
  1870. X        ++ DirectoryMgrTotalCount(dm);
  1871. X        if ((f_func == NULL) ||
  1872. X            (f_func && f_func(&(cons->dir_entry),f_data)))
  1873. X        {
  1874. X            cons->next = NULL;
  1875. X            if (head == NULL)
  1876. X                head = cons;
  1877. X                else
  1878. X                tail->next = cons;
  1879. X            tail = cons;
  1880. X            ++ DirectoryMgrFilteredCount(dm);
  1881. X        }
  1882. X            else            /* Filter Failed */
  1883. X        {
  1884. X            free(cons);
  1885. X        }
  1886. X    }
  1887. X
  1888. X    data_size = sizeof(DirEntry) * DirectoryMgrFilteredCount(dm);
  1889. X    ptrs_size = sizeof(DirEntry *) * DirectoryMgrFilteredCount(dm);
  1890. X    dm_data = (DirEntry *)malloc(data_size);
  1891. X    dm_ptrs = (DirEntry **)malloc(ptrs_size);
  1892. X    if ((dm_data == NULL) || (dm_ptrs == NULL))
  1893. X    {
  1894. X        fprintf(stderr,"DirectoryMgrRefresh: Out of memory\n");
  1895. X        exit(1);
  1896. X    }
  1897. X    DirectoryMgrData(dm) = dm_data;
  1898. X    DirectoryMgrSortedPtrs(dm) = dm_ptrs;
  1899. X
  1900. X    for (i = 0; i < DirectoryMgrFilteredCount(dm); i++)
  1901. X    {
  1902. X        DirectoryMgrData(dm)[i] = head->dir_entry;
  1903. X        DirectoryMgrSortedPtrs(dm)[i] = &(DirectoryMgrData(dm)[i]);
  1904. X        cons = head->next;
  1905. X        free(head);
  1906. X        head = cons;
  1907. X    }
  1908. X
  1909. X    DirectoryMgrResort(dm,DirectoryMgrCompFunc(dm));
  1910. X    DirectoryMgrRestart(dm);
  1911. X    return(TRUE);
  1912. } /* End DirectoryMgrRefresh */
  1913. X
  1914. X
  1915. void DirectoryMgrResort
  1916. #ifdef UseFunctionPrototypes
  1917. X    (DirectoryMgr *dm, PFI c_func)
  1918. #else
  1919. X    (dm,c_func)
  1920. DirectoryMgr *dm;
  1921. PFI c_func;
  1922. X
  1923. #endif
  1924. {
  1925. X    DirectoryMgrCompFunc(dm) = c_func;
  1926. X    if (c_func != NULL)
  1927. X    {
  1928. X        qsort(DirectoryMgrSortedPtrs(dm),DirectoryMgrFilteredCount(dm),
  1929. X              sizeof(DirEntry *),DirectoryMgrCompFunc(dm));
  1930. X    }
  1931. X    DirectoryMgrRestart(dm);
  1932. } /* End DirectoryMgrResort */
  1933. X
  1934. /*---------------------------------------------------------------------------*
  1935. X
  1936. X                  I T E R A T I O N    C O M M A N D S
  1937. X
  1938. X *---------------------------------------------------------------------------*/
  1939. X
  1940. int DirectoryMgrGotoItem
  1941. #ifdef UseFunctionPrototypes
  1942. X    (DirectoryMgr *dm, int i)
  1943. #else
  1944. X    (dm,i)
  1945. DirectoryMgr *dm;
  1946. int i;
  1947. X
  1948. #endif
  1949. {
  1950. X    if (i < 0 || i >= DirectoryMgrFilteredCount(dm)) return(FALSE);
  1951. X    DirectoryMgrCurrentIndex(dm) = i;
  1952. X    return(TRUE);
  1953. } /* End DirectoryMgrGotoItem */
  1954. X
  1955. X
  1956. int DirectoryMgrGotoNamedItem
  1957. #ifdef UseFunctionPrototypes
  1958. X    (DirectoryMgr *dm, char *name)
  1959. #else
  1960. X    (dm,name)
  1961. DirectoryMgr *dm;
  1962. char *name;
  1963. X
  1964. #endif
  1965. {
  1966. X    int i;
  1967. X    DirEntry *entry;
  1968. X
  1969. X    for (i = 0; i < DirectoryMgrFilteredCount(dm); i++)
  1970. X    {
  1971. X        entry = DirectoryMgrSortedPtrs(dm)[i];
  1972. X        if (strcmp(DirEntryFileName(entry),name) == 0)
  1973. X        {
  1974. X            DirectoryMgrCurrentIndex(dm) = i;
  1975. X            return(TRUE);
  1976. X        }
  1977. X    }
  1978. X    return(FALSE);
  1979. } /* End DirectoryMgrGotoNamedItem */
  1980. X
  1981. X
  1982. void DirectoryMgrRestart
  1983. #ifdef UseFunctionPrototypes
  1984. X    (DirectoryMgr *dm)
  1985. #else
  1986. X    (dm)
  1987. DirectoryMgr *dm;
  1988. X
  1989. #endif
  1990. {
  1991. X    DirectoryMgrCurrentIndex(dm) = 0;
  1992. } /* End DirectoryMgrRestart */
  1993. X
  1994. X
  1995. DirEntry *DirectoryMgrCurrentEntry
  1996. #ifdef UseFunctionPrototypes
  1997. X    (DirectoryMgr *dm)
  1998. #else
  1999. X    (dm)
  2000. DirectoryMgr *dm;
  2001. X
  2002. #endif
  2003. {
  2004. X    int index;
  2005. X
  2006. X    index = DirectoryMgrCurrentIndex(dm);
  2007. X    if (index < 0 || index >= DirectoryMgrFilteredCount(dm)) return(NULL);
  2008. X    return(DirectoryMgrSortedPtrs(dm)[index]);
  2009. } /* End DirectoryMgrCurrentEntry */
  2010. X
  2011. X
  2012. DirEntry *DirectoryMgrNextEntry
  2013. #ifdef UseFunctionPrototypes
  2014. X    (DirectoryMgr *dm)
  2015. #else
  2016. X    (dm)
  2017. DirectoryMgr *dm;
  2018. X
  2019. #endif
  2020. {
  2021. X    int index;
  2022. X
  2023. X    index = DirectoryMgrCurrentIndex(dm);
  2024. X    if (index >= DirectoryMgrFilteredCount(dm)) return(NULL);
  2025. X    ++ DirectoryMgrCurrentIndex(dm);
  2026. X    return(DirectoryMgrSortedPtrs(dm)[index]);
  2027. } /* End DirectoryMgrNextEntry */
  2028. X
  2029. X
  2030. DirEntry *DirectoryMgrPrevEntry
  2031. #ifdef UseFunctionPrototypes
  2032. X    (DirectoryMgr *dm)
  2033. #else
  2034. X    (dm)
  2035. DirectoryMgr *dm;
  2036. X
  2037. #endif
  2038. {
  2039. X    int index;
  2040. X
  2041. X    index = DirectoryMgrCurrentIndex(dm) - 1;
  2042. X    if (index < 0) return(NULL);
  2043. X    -- DirectoryMgrCurrentIndex(dm);
  2044. X    return(DirectoryMgrSortedPtrs(dm)[index]);
  2045. } /* End DirectoryMgrPrevEntry */
  2046. X
  2047. /*---------------------------------------------------------------------------*
  2048. X
  2049. X                   U T I L I T Y    F U N C T I O N S
  2050. X
  2051. X *---------------------------------------------------------------------------*/
  2052. X
  2053. int DirectoryMgrSimpleFilterFunc
  2054. #ifdef UseFunctionPrototypes
  2055. X    (char *pattern, PFI *ff_ptr, char **fd_ptr)
  2056. #else
  2057. X    (pattern,ff_ptr,fd_ptr)
  2058. char *pattern;
  2059. PFI *ff_ptr;
  2060. char **fd_ptr;
  2061. X
  2062. #endif
  2063. {
  2064. #ifndef    NO_REGEXP
  2065. X    char regexp[2048];
  2066. X
  2067. X    *ff_ptr = DirectoryMgrFilterName;
  2068. X    *fd_ptr = (char *)malloc(sizeof(char) * DIR_MGR_FSM_SIZE);
  2069. X    if (*fd_ptr == NULL) return(FALSE);
  2070. X    RegExpPatternToRegExp(pattern,regexp);
  2071. X    RegExpCompile(regexp,*fd_ptr,DIR_MGR_FSM_SIZE);
  2072. #endif
  2073. X    return(TRUE);
  2074. } /* End DirectoryMgrSimpleFilterFunc */
  2075. X
  2076. X
  2077. int DirectoryMgrSimpleSortingFunc
  2078. #ifdef UseFunctionPrototypes
  2079. X    (int sort_type, PFI *sf_ptr)
  2080. #else
  2081. X    (sort_type,sf_ptr)
  2082. int sort_type;
  2083. PFI *sf_ptr;
  2084. X
  2085. #endif
  2086. {
  2087. X    *sf_ptr = NULL;
  2088. X    switch (sort_type)
  2089. X    {
  2090. X        case DIR_MGR_SORT_NONE:
  2091. X        break;
  2092. X        case DIR_MGR_SORT_NAME:
  2093. X        *sf_ptr = DirectoryMgrCompareName;
  2094. X        break;
  2095. X        case DIR_MGR_SORT_SIZE_ASCENDING:
  2096. X        *sf_ptr = DirectoryMgrCompareSizeAscending;
  2097. X        break;
  2098. X        case DIR_MGR_SORT_SIZE_DESCENDING:
  2099. X        *sf_ptr = DirectoryMgrCompareSizeDescending;
  2100. X        break;
  2101. X        case DIR_MGR_SORT_NAME_DIRS_FIRST:
  2102. X        *sf_ptr = DirectoryMgrCompareNameDirsFirst;
  2103. X        break;
  2104. X        case DIR_MGR_SORT_ACCESS_ASCENDING:
  2105. X        *sf_ptr = DirectoryMgrCompareLastAccessAscending;
  2106. X        break;
  2107. X        case DIR_MGR_SORT_ACCESS_DESCENDING:
  2108. X        *sf_ptr = DirectoryMgrCompareLastAccessDescending;
  2109. X        break;
  2110. X        default:
  2111. X        fprintf(stderr,"Bad sort type %d\n",sort_type);
  2112. X        return(FALSE);
  2113. X    }
  2114. X    return(TRUE);
  2115. } /* End DirectoryMgrSimpleSortingFunc */
  2116. X
  2117. /*---------------------------------------------------------------------------*
  2118. X
  2119. X                    S O R T I N G    R O U T I N E S
  2120. X
  2121. X *---------------------------------------------------------------------------*/
  2122. X
  2123. int DirectoryMgrCompareName
  2124. #ifdef UseFunctionPrototypes
  2125. X    (DirEntry **e1p, DirEntry **e2p)
  2126. #else
  2127. X    (e1p,e2p)
  2128. DirEntry **e1p,**e2p;
  2129. X
  2130. #endif
  2131. {
  2132. X    return(strcmp(DirEntryFileName(*e1p),DirEntryFileName(*e2p)));
  2133. } /* End DirectoryMgrCompareName */
  2134. X
  2135. X
  2136. int DirectoryMgrCompareNameDirsFirst
  2137. #ifdef UseFunctionPrototypes
  2138. X    (DirEntry **e1p, DirEntry **e2p)
  2139. #else
  2140. X    (e1p,e2p)
  2141. DirEntry **e1p,**e2p;
  2142. X
  2143. #endif
  2144. {
  2145. X    if (DirEntryLeadsToDir(*e1p))
  2146. X    {
  2147. X        if (!DirEntryLeadsToDir(*e2p)) return(-1);
  2148. X    }
  2149. X        else if (DirEntryLeadsToDir(*e2p))
  2150. X    {
  2151. X        return(1);
  2152. X    }
  2153. X    return(strcmp(DirEntryFileName(*e1p),DirEntryFileName(*e2p)));
  2154. } /* End DirectoryMgrCompareNameDirsFirst */
  2155. X
  2156. X
  2157. int DirectoryMgrCompareSizeAscending
  2158. #ifdef UseFunctionPrototypes
  2159. X    (DirEntry **e1p, DirEntry **e2p)
  2160. #else
  2161. X    (e1p,e2p)
  2162. DirEntry **e1p,**e2p;
  2163. X
  2164. #endif
  2165. {
  2166. X    if (DirEntryFileSize(*e1p) < DirEntryFileSize(*e2p))
  2167. X        return (-1);
  2168. X        else if (DirEntryFileSize(*e1p) == DirEntryFileSize(*e2p))
  2169. X        return (0);
  2170. X        else
  2171. X        return (1);
  2172. } /* End DirectoryMgrCompareSizeAscending */
  2173. X
  2174. X
  2175. int DirectoryMgrCompareSizeDescending
  2176. #ifdef UseFunctionPrototypes
  2177. X    (DirEntry **e1p, DirEntry **e2p)
  2178. #else
  2179. X    (e1p,e2p)
  2180. DirEntry **e1p,**e2p;
  2181. X
  2182. #endif
  2183. {
  2184. X    if (DirEntryFileSize(*e1p) > DirEntryFileSize(*e2p))
  2185. X        return (-1);
  2186. X        else if (DirEntryFileSize(*e1p) == DirEntryFileSize(*e2p))
  2187. X        return (0);
  2188. X        else
  2189. X        return (1);
  2190. } /* End DirectoryMgrCompareSizeDescending */
  2191. X
  2192. X
  2193. int DirectoryMgrCompareLastAccessAscending
  2194. #ifdef UseFunctionPrototypes
  2195. X    (DirEntry **e1p, DirEntry **e2p)
  2196. #else
  2197. X    (e1p,e2p)
  2198. DirEntry **e1p,**e2p;
  2199. X
  2200. #endif
  2201. {
  2202. X    return((long)DirEntryLastAccess(*e1p) >
  2203. X           (long)DirEntryLastAccess(*e2p));
  2204. } /* End DirectoryMgrCompareLastAccessAscending */
  2205. X
  2206. X
  2207. int DirectoryMgrCompareLastAccessDescending
  2208. #ifdef UseFunctionPrototypes
  2209. X    (DirEntry **e1p, DirEntry **e2p)
  2210. #else
  2211. X    (e1p,e2p)
  2212. DirEntry **e1p,**e2p;
  2213. X
  2214. #endif
  2215. {
  2216. X    return((long)DirEntryLastAccess(*e1p) <
  2217. X           (long)DirEntryLastAccess(*e2p));
  2218. } /* End DirectoryMgrCompareLastAccessDescending */
  2219. X
  2220. /*---------------------------------------------------------------------------*
  2221. SHAR_EOF
  2222. true || echo 'restore of xmfm/DirMgr.c failed'
  2223. fi
  2224. echo 'End of  part 2'
  2225. echo 'File xmfm/DirMgr.c is continued in part 3'
  2226. echo 3 > _shar_seq_.tmp
  2227. exit 0
  2228. --
  2229. +----------------------+---+
  2230.   Jan Newmarch, Information Science and Engineering,
  2231.   University of Canberra, PO Box 1, Belconnen, Act 2616
  2232.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  2233.