home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume18 / ftptool-4.3 / part03 < prev    next >
Text File  |  1992-08-18  |  51KB  |  2,237 lines

  1. Path: uunet!sun-barr!ames!elroy.jpl.nasa.gov!swrinde!mips!msi!dcmartin
  2. From: Mike.Sullivan@EBay.Sun.COM (Mike Sullivan {AKA Simon BarSinister})
  3. Newsgroups: comp.sources.x
  4. Subject: v18i085: Ftptool 4.3 (XVIEW), Part03/12
  5. Message-ID: <1992Aug18.153554.28670@msi.com>
  6. Date: 18 Aug 92 15:35:54 GMT
  7. References: <csx-18i083-ftptool-4.3@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 2223
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: Mike.Sullivan@EBay.Sun.COM (Mike Sullivan {AKA Simon BarSinister})
  15. Posting-number: Volume 18, Issue 85
  16. Archive-name: ftptool-4.3/part03
  17.  
  18. #!/bin/sh
  19. # this is part.03 (part 3 of a multipart archive)
  20. # do not concatenate these parts, unpack them in order with /bin/sh
  21. # file ftptool.h continued
  22. #
  23. if test ! -r _shar_seq_.tmp; then
  24.     echo 'Please unpack part 1 first!'
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 3; then
  29.     echo Please unpack part "$Scheck" next!
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < _shar_seq_.tmp || exit 1
  35. if test ! -f _shar_wnt_.tmp; then
  36.     echo 'x - still skipping ftptool.h'
  37. else
  38. echo 'x - continuing file ftptool.h'
  39. sed 's/^X//' << 'SHAR_EOF' >> 'ftptool.h' &&
  40. X    Panel_item user_perms;
  41. X    Panel_item group_perms;
  42. X    Panel_item other_perms;
  43. X    Panel_item dismiss;    /* for non-OPEN LOOK window managers */
  44. };
  45. X
  46. EXTERN struct file_property_window local_file_properties, remote_file_properties;
  47. X
  48. struct about_window {
  49. X    Frame    frame;
  50. X    Panel    panel;
  51. X    Textsw    message;
  52. X    Panel_item    bottom_panel;
  53. X    Panel_item    mail;
  54. X    Panel_item    dismiss;    /* for non-OPEN LOOK window managers */
  55. X    char    geometry[MAXGEOMETRYSIZE];
  56. };
  57. X
  58. EXTERN struct about_window about_window;
  59. X
  60. struct feedback_window {
  61. X    Frame    frame;
  62. X    Panel    panel;
  63. X    Panel_item    which;
  64. X    Panel_item    other;
  65. X    Textsw    feedback;
  66. X    Panel_item    bottom_panel;
  67. X    Panel_item    send;
  68. X    Panel_item    cancel;
  69. };
  70. X
  71. EXTERN struct feedback_window feedback_window;
  72. X
  73. struct schedule_window {
  74. X    Frame    frame;
  75. X    Panel    panel;
  76. X    Panel_item    current_time;
  77. X    Panel_item    process;
  78. X    Panel_item    hosts;
  79. X    Panel_item    options;
  80. X    Panel_item    direction;
  81. X    Panel_item    menu_name;
  82. X    Panel_item    hour;
  83. X    Panel_item    minute;
  84. X    Panel_item    month;
  85. X    Panel_item    day;
  86. X    Panel_item    year;
  87. X    Panel_item    send_list;
  88. X    Panel_item    receive_list;
  89. X    Panel_item    dismiss;    /* for non-OPEN LOOK window managers */
  90. X    Frame    lsframe;
  91. X    Panel_item    filename;
  92. X    Panel_item    lsbutton;
  93. X    int        visible;
  94. X    char    geometry[MAXGEOMETRYSIZE];
  95. };
  96. X
  97. EXTERN struct schedule_window schedule_window;
  98. X
  99. EXTERN Frame    tar_frame;
  100. EXTERN Panel_item    tar_text;
  101. EXTERN Panel_item    tar_button;
  102. EXTERN Panel_item    tar_quit_button;    /* for non-OPEN LOOK window managers */
  103. X
  104. EXTERN Xv_font    list_font;
  105. EXTERN Xv_font    bold_list_font;
  106. X
  107. EXTERN Xv_Cursor    busy_cursor;
  108. EXTERN Xv_Cursor    normal_cursor;
  109. X
  110. EXTERN char *program_name;
  111. EXTERN char *header_name;
  112. EXTERN char *list_label;
  113. X
  114. #define MAXLINE 1024
  115. X
  116. EXTERN char    response_line[MAXLINE];
  117. X
  118. EXTERN char    scratch[MAXPATHLEN + MAXNAMLEN + 10];
  119. EXTERN char    myhostname[MAXHOSTNAMELEN + 1];
  120. X
  121. EXTERN int connected;
  122. EXTERN char icon_label[9];
  123. EXTERN int dowhat;
  124. X
  125. EXTERN int local_list_nfiles;
  126. EXTERN int local_list_ndirs;
  127. EXTERN int local_list_nothers;
  128. EXTERN int remote_list_nfiles;
  129. EXTERN int remote_list_ndirs;
  130. EXTERN int remote_list_nothers;
  131. X
  132. EXTERN int        timedout;
  133. EXTERN int        list_changed;
  134. EXTERN int        timestamped;
  135. EXTERN int        nhostlist_items;
  136. EXTERN int        nsenditems;
  137. EXTERN int        nreceiveitems;
  138. EXTERN int        current_year;
  139. EXTERN int        current_month;
  140. X
  141. /* Properties */
  142. EXTERN int        logging;
  143. EXTERN int        keepalive;
  144. EXTERN int        ignore_case;
  145. EXTERN int        unique_local_names;
  146. EXTERN int        unique_remote_names;
  147. EXTERN int        remote_showdotfiles;
  148. EXTERN int        local_showdotfiles;
  149. EXTERN int        confirmdeletes;
  150. EXTERN int        remote_sort_mode;
  151. EXTERN int        remote_sort_direction;
  152. EXTERN int        group_remote_files;
  153. EXTERN int        local_sort_mode;
  154. EXTERN int        local_sort_direction;
  155. EXTERN int        group_local_files;
  156. EXTERN char        *default_viewer;
  157. EXTERN char        *archive_viewer;
  158. EXTERN char        *postscript_viewer;
  159. X
  160. EXTERN double        click_timeout;
  161. EXTERN int nbusyicons;
  162. EXTERN Server_image busy_glyphs[];
  163. EXTERN Server_image busy_glyphs[];
  164. X
  165. EXTERN Server_image directory_glyph;
  166. EXTERN Server_image file_glyph;
  167. EXTERN Server_image dotdot_glyph;
  168. EXTERN Server_image unknown_glyph;
  169. X
  170. EXTERN unsigned short icon_array[];
  171. X
  172. EXTERN Server_image ftptool_glyph;
  173. X
  174. EXTERN struct hostlist *hostlist_head;
  175. X
  176. EXTERN FILE    *commandfp;
  177. EXTERN FILE    *responsefp;
  178. X
  179. EXTERN char    *anonftp_password;
  180. EXTERN char    *login_name;
  181. X
  182. EXTERN int    ftp_port;
  183. EXTERN int    ftp_passthru_port;
  184. EXTERN int    try_proxy;
  185. EXTERN int    auto_connect;
  186. X
  187. EXTERN int    abort_transfer;
  188. X
  189. EXTERN int openlook_mode;
  190. EXTERN int show_status;
  191. X
  192. EXTERN int non_unix;
  193. X
  194. EXTERN char *netrc_filename;
  195. X
  196. EXTERN char *dir_pattern;
  197. X
  198. /*
  199. X FTP externs
  200. X */
  201. EXTERN int code;
  202. X
  203. EXTERN struct    sockaddr_in hisctladdr;
  204. EXTERN struct    sockaddr_in data_addr;
  205. EXTERN int    data;
  206. EXTERN int    abrtflag;
  207. EXTERN int    ptflag;
  208. EXTERN int    verbose;
  209. EXTERN int    debug;
  210. EXTERN int    code;
  211. EXTERN int    cpend;
  212. EXTERN int    curtype;
  213. EXTERN int    crflag;
  214. EXTERN int    runique;
  215. EXTERN int    sendport;
  216. EXTERN struct sockaddr_in myctladdr;
  217. EXTERN off_t    restart_point;
  218. X
  219. SHAR_EOF
  220. echo 'File ftptool.h is complete' &&
  221. chmod 0644 ftptool.h ||
  222. echo 'restore of ftptool.h failed'
  223. Wc_c="`wc -c < 'ftptool.h'`"
  224. test 9377 -eq "$Wc_c" ||
  225.     echo 'ftptool.h: original size 9377, current size' "$Wc_c"
  226. rm -f _shar_wnt_.tmp
  227. fi
  228. # ============= tar_view.c ==============
  229. if test -f 'tar_view.c' -a X"$1" != X"-c"; then
  230.     echo 'x - skipping tar_view.c (File already exists)'
  231.     rm -f _shar_wnt_.tmp
  232. else
  233. > _shar_wnt_.tmp
  234. echo 'x - extracting tar_view.c (Text)'
  235. sed 's/^X//' << 'SHAR_EOF' > 'tar_view.c' &&
  236. #include "ftptool.h"
  237. X
  238. static Panel_button_item    list_button;
  239. static Panel_button_item    extract_button;
  240. static Textsw    tar_output;
  241. static Frame    cd_frame;
  242. static Panel    cd_panel;
  243. static Panel    cd_text;
  244. X
  245. static char *tarfile;
  246. X
  247. static int insert_error;
  248. X
  249. static unsigned short tar_icon_array[] = {
  250. #include "./tar.viewer.icon"
  251. };
  252. X
  253. #ifdef USE_PROTOTYPES
  254. void handle_tarfile(char *filename)
  255. #else
  256. void handle_tarfile(filename)
  257. char    *filename;
  258. #endif
  259. {
  260. X    char    dir[MAXPATHLEN + 2];
  261. X    Panel_button_item ex_button;
  262. X    Rect    *butrect;
  263. X    Icon    frame_icon;
  264. X    Server_image tar_glyph;
  265. X    void    tar_quit_proc();
  266. X
  267. X    if (getcwd(dir, sizeof(dir)) == NULL) {
  268. X        fprintf(stderr, "getwd: %s\n", dir);
  269. X        exit(1);
  270. X    }
  271. X
  272. X    if (filename[0] != '/') {
  273. X        /* should be in current directory. */
  274. X        tarfile = (char *)malloc((unsigned int)(strlen(dir)+1+strlen(filename)+1));
  275. X        if (tarfile == NULL) {
  276. X            fprintf(stderr, "malloc failed\n");
  277. X            exit(1);
  278. X        }
  279. X        sprintf(tarfile, "%s/%s", dir, filename);
  280. X    } else
  281. X        tarfile = strdup(filename);
  282. X
  283. X    sprintf(scratch, "Tar File Viewer - %s", filename);
  284. X
  285. X    base_window.frame = xv_create(XV_NULL, FRAME,
  286. X        XV_LABEL, scratch,
  287. X        XV_WIDTH, 430,
  288. X        NULL);
  289. X
  290. X    tar_glyph = (Server_image )xv_create(XV_NULL,SERVER_IMAGE,
  291. X        XV_WIDTH, 64,
  292. X        XV_HEIGHT,64,
  293. X        SERVER_IMAGE_DEPTH, 1,
  294. X        SERVER_IMAGE_BITS,tar_icon_array,
  295. X        NULL);
  296. X
  297. X    frame_icon = (Icon)xv_get(base_window.frame, FRAME_ICON);
  298. X
  299. X    xv_set(frame_icon, 
  300. X        ICON_IMAGE, tar_glyph, 
  301. X        ICON_TRANSPARENT, TRUE,
  302. X        NULL);
  303. X
  304. X
  305. X    base_window.panel = xv_create(base_window.frame, PANEL,
  306. X        PANEL_LAYOUT, PANEL_HORIZONTAL,
  307. X        XV_HELP_DATA, "ftptool:TarFileViewer",
  308. X        NULL);
  309. X    
  310. X    list_button = xv_create(base_window.panel, PANEL_BUTTON,
  311. X        PANEL_LABEL_STRING, "List Contents",
  312. X        PANEL_NOTIFY_PROC, list_proc,
  313. X        XV_HELP_DATA, "ftptool:TarFileListContents",
  314. X        NULL);
  315. X
  316. X    extract_button = xv_create(base_window.panel, PANEL_BUTTON,
  317. X        PANEL_LABEL_STRING, "Extract Files",
  318. X        PANEL_NOTIFY_PROC, tar_extract_proc,
  319. X        XV_HELP_DATA, "ftptool:TarFileExtractFiles",
  320. X        NULL);
  321. X
  322. X    openlook_mode = defaults_get_boolean(
  323. X        "ftptool.OpenLookMode", "Ftptool.OpenLookMode", TRUE);
  324. X
  325. X    if (!openlook_mode) {
  326. X        tar_quit_button = xv_create(base_window.panel, PANEL_BUTTON,
  327. X            PANEL_LABEL_STRING, "Quit",
  328. X            PANEL_NOTIFY_PROC, tar_quit_proc,
  329. X            XV_HELP_DATA, "ftptool:TarQuitButton",
  330. X            NULL);
  331. X    }
  332. X
  333. X    xv_set(base_window.panel, PANEL_LAYOUT, PANEL_HORIZONTAL, NULL);
  334. X    window_fit_height(base_window.panel);
  335. X
  336. X    tar_output = xv_create(base_window.frame, TEXTSW,
  337. X        XV_LABEL, "Tar Output",
  338. X        XV_HEIGHT, 100,
  339. X        NULL);
  340. X    
  341. X    window_fit(base_window.frame);
  342. X
  343. X    xv_set(base_window.frame, XV_SHOW, TRUE, NULL);
  344. X
  345. X    cd_frame = xv_create(base_window.frame, FRAME_CMD,
  346. X        XV_LABEL, "Extract Directory",
  347. X        NULL);
  348. X
  349. X    dpy = (Display *)xv_get(base_window.frame, XV_DISPLAY);
  350. X    cd_panel = xv_get(cd_frame, FRAME_CMD_PANEL);
  351. X
  352. X    xv_set(cd_panel, 
  353. X        PANEL_LAYOUT, PANEL_VERTICAL, 
  354. X        NULL);
  355. X
  356. X    cd_text = xv_create(cd_panel, PANEL_TEXT,
  357. X        PANEL_VALUE_DISPLAY_LENGTH, 40,
  358. X        PANEL_VALUE_STORED_LENGTH, MAXPATHLEN + 1,
  359. X        PANEL_LABEL_STRING, "Directory: ",
  360. X        PANEL_LAYOUT, PANEL_HORIZONTAL,
  361. X        PANEL_VALUE,dir,
  362. X        XV_HELP_DATA, "ftptool:TarFileNameText",
  363. X        NULL);
  364. X
  365. X    ex_button = xv_create(cd_panel, PANEL_BUTTON,
  366. X        PANEL_NOTIFY_PROC, doextract_proc,
  367. X        PANEL_LABEL_STRING, "Extract",
  368. X        XV_HELP_DATA, "ftptool:TarFileNameButton",
  369. X        NULL);
  370. X    
  371. X    xv_set(cd_panel, 
  372. X        PANEL_DEFAULT_ITEM, ex_button, 
  373. X        NULL);
  374. X
  375. X    window_fit(cd_panel);
  376. X    window_fit(cd_frame);
  377. X
  378. X    butrect = (Rect *)xv_get(ex_button, XV_RECT);
  379. X    xv_set(ex_button, 
  380. X        XV_X, (int)xv_get(cd_panel, XV_WIDTH)/2 - butrect->r_width, 
  381. X        NULL);
  382. X
  383. X    notify_interpose_destroy_func(base_window.frame, tar_destroy_func);
  384. X    XFlush(dpy);
  385. X    notify_start();
  386. X
  387. X    exit(0);
  388. }
  389. X
  390. #ifdef USE_PROTOTYPES
  391. void list_proc(void)
  392. #else
  393. void list_proc()
  394. #endif
  395. {
  396. X    xv_set(base_window.frame, 
  397. X        FRAME_BUSY, TRUE, 
  398. X        NULL);
  399. X    start_tar("tf", tarfile);
  400. }
  401. X
  402. #ifdef USE_PROTOTYPES
  403. void doextract_proc(void)
  404. #else
  405. void doextract_proc()
  406. #endif
  407. {
  408. X    char    *dir;
  409. X    extern char *sys_errlist[];
  410. X    int        rval;
  411. X
  412. X    xv_set(base_window.frame, 
  413. X        FRAME_BUSY, TRUE, 
  414. X        NULL);
  415. X    dir = (char *)xv_get(cd_text, PANEL_VALUE);
  416. X    if (dir[0] == '\0') {
  417. X        footer_message("Please type in a directory name", (char *)NULL);
  418. X        xv_set(base_window.frame, 
  419. X            FRAME_BUSY, FALSE, 
  420. X            NULL);
  421. X        return;
  422. X    }
  423. X    dir = expand_dirname(dir);
  424. X    if (dir == NULL) {
  425. X        fprintf(stderr, "Out of memory.\n");
  426. X        xv_set(base_window.frame, 
  427. X            FRAME_BUSY, FALSE, 
  428. X            NULL);
  429. X        return;
  430. X    }
  431. X    if (chdir(dir) == -1) {
  432. X        if (errno == ENOENT) {
  433. X            if (rval = ask_make_dir(dir)) {
  434. X                if (rval != -1) {
  435. X                    footer_message("Could not make directory. Reason: %s",
  436. X                        sys_errlist[rval], (char *)NULL);
  437. X                }
  438. X                xv_set(base_window.frame, 
  439. X                    FRAME_BUSY, FALSE, 
  440. X                    NULL);
  441. X                return;
  442. X            }
  443. X            if (chdir(dir) == -1) {
  444. X                perror("chdir");
  445. X                exit(1);
  446. X            }
  447. X        } else {
  448. X            footer_message("Could not make directory. Reason: %s",
  449. X                    sys_errlist[errno], (char *)NULL);
  450. X            xv_set(base_window.frame, 
  451. X                FRAME_BUSY, FALSE, 
  452. X                NULL);
  453. X            return;
  454. X        }
  455. X    }
  456. X    free(dir);
  457. X    start_tar("xvf", tarfile);
  458. }
  459. X
  460. #ifdef USE_PROTOTYPES
  461. void tar_extract_proc(void)
  462. #else
  463. void tar_extract_proc()
  464. #endif
  465. {
  466. X    int    x = xv_get(base_window.frame, XV_X) - 5;
  467. X    int y = xv_get(base_window.frame, XV_Y);
  468. X    int height = xv_get(cd_frame, XV_HEIGHT)  * 2;
  469. X
  470. X    y -= height;
  471. X    if (x < 0 || x >= display_width)
  472. X        x = 0;
  473. X    if (y < 0 || y >= display_height)
  474. X        y = 0;
  475. X    xv_set(cd_frame, 
  476. X        XV_X, x, 
  477. X        XV_Y, y, 
  478. X        XV_SHOW, TRUE, 
  479. X        NULL);
  480. }
  481. X
  482. #ifdef USE_PROTOTYPES
  483. void start_tar(char *options, char *filename)
  484. #else
  485. void start_tar(options, filename)
  486. char    *options;
  487. char    *filename;
  488. #endif
  489. {
  490. X    int        pipe_fds[2];
  491. X    int        pid;
  492. X
  493. X    textsw_erase(tar_output, 0, TEXTSW_INFINITY);
  494. X    if (pipe(pipe_fds) == -1) {
  495. X        perror("pipe");
  496. X        exit(1);
  497. X    }
  498. X    insert_error = 0;
  499. X    switch(pid = fork()) {
  500. X    case -1:
  501. X        perror("fork");
  502. X        exit(1);
  503. X        break;
  504. X    case 0: /* child */
  505. X        /* dup standard out to pipe */
  506. X        dup2(pipe_fds[1], 1);
  507. X        dup2(pipe_fds[1], 2);
  508. X        close(pipe_fds[0]);
  509. X        close(pipe_fds[1]);
  510. X        execlp("tar", "tar", options, filename, (char *)NULL);
  511. X        perror("can not start viewer");
  512. X        exit(1);
  513. X    default:/* parent */
  514. X        close(pipe_fds[1]);
  515. X        notify_set_wait3_func(base_window.frame, notify_default_wait3, pid);
  516. X
  517. X        break;
  518. X    }
  519. X
  520. X    notify_set_input_func(base_window.frame, input_func, pipe_fds[0]);
  521. X    notify_set_wait3_func(base_window.frame, notify_default_wait3, pid);
  522. }
  523. X
  524. #ifdef USE_PROTOTYPES
  525. Notify_value input_func(Notify_client client, int fd)
  526. #else
  527. Notify_value input_func(client, fd)
  528. Notify_client    client;
  529. int    fd;
  530. #endif
  531. {
  532. X    char    buf[80];
  533. X    int        nread;
  534. X
  535. X    for (;;) {
  536. X        nread = read(fd, buf, sizeof(buf));
  537. X        if (nread == 0) {
  538. X            notify_set_input_func(client, NOTIFY_FUNC_NULL, fd);
  539. X            close(fd);
  540. X            xv_set(base_window.frame, FRAME_BUSY, FALSE, NULL);
  541. X            break;
  542. X        }
  543. X        if (nread == -1)
  544. X            if (errno == EWOULDBLOCK) 
  545. X                break;
  546. X            else {
  547. X                perror("read");
  548. X                exit(1);
  549. X            }
  550. X        if (!insert_error && textsw_insert(tar_output,buf, nread) != nread)
  551. X            insert_error = 1;
  552. X        XFlush(dpy);
  553. X    } 
  554. X
  555. X    return NOTIFY_DONE;
  556. }
  557. X
  558. #ifdef USE_PROTOTYPES
  559. Notify_value tar_destroy_func(Notify_client client, Destroy_status status)
  560. #else
  561. Notify_value tar_destroy_func(client, status)
  562. Notify_client   client;
  563. Destroy_status  status;
  564. #endif
  565. {
  566. X    switch(status) {
  567. X    case DESTROY_CHECKING:
  568. X        break;
  569. X    case DESTROY_CLEANUP:
  570. X        return notify_next_destroy_func(client, status);
  571. X        break;
  572. X    case DESTROY_SAVE_YOURSELF:
  573. X        break;
  574. X    case DESTROY_PROCESS_DEATH:
  575. X        break;
  576. X    }
  577. X    return NOTIFY_DONE;
  578. }
  579. X
  580. X
  581. #ifdef USE_PROTOTYPES
  582. void    tar_quit_proc(void)
  583. #else
  584. void    tar_quit_proc()
  585. #endif
  586. {
  587. X    exit(0);
  588. }
  589. SHAR_EOF
  590. chmod 0644 tar_view.c ||
  591. echo 'restore of tar_view.c failed'
  592. Wc_c="`wc -c < 'tar_view.c'`"
  593. test 7548 -eq "$Wc_c" ||
  594.     echo 'tar_view.c: original size 7548, current size' "$Wc_c"
  595. rm -f _shar_wnt_.tmp
  596. fi
  597. # ============= view_file.c ==============
  598. if test -f 'view_file.c' -a X"$1" != X"-c"; then
  599.     echo 'x - skipping view_file.c (File already exists)'
  600.     rm -f _shar_wnt_.tmp
  601. else
  602. > _shar_wnt_.tmp
  603. echo 'x - extracting view_file.c (Text)'
  604. sed 's/^X//' << 'SHAR_EOF' > 'view_file.c' &&
  605. #include "ftptool.h"
  606. X
  607. #ifdef USE_PROTOTYPES
  608. int start_viewer(char *filename, int isremote)
  609. #else
  610. int start_viewer(filename, isremote)
  611. char    *filename;
  612. int        isremote;
  613. #endif
  614. {
  615. X    int        which;
  616. X
  617. X    which = file_type(filename);
  618. X
  619. X    switch(which) {
  620. X    case COMPRESSED:
  621. X        /* uncompress file */
  622. X        if (isremote)
  623. X            footer_message("Uncompressing %s\n", filename, (char *)NULL);
  624. X        else
  625. X            local_footer_message("Uncompressing %s\n", filename, (char *)NULL);
  626. X        uncompress_file(filename, "-vf");
  627. X        break;
  628. X    case POSTSCRIPT:
  629. X        if (isremote) {
  630. X            footer_message("Starting PostScript viewer %s", 
  631. X                postscript_viewer, (char *)NULL);
  632. X        } else {
  633. X            local_footer_message("Starting PostScript viewer %s", 
  634. X                postscript_viewer, (char *)NULL);
  635. X        }
  636. X        fork_viewer(postscript_viewer, filename);
  637. X        break;
  638. X    case TARFILE:
  639. X        if (isremote)
  640. X            footer_message("Starting tar viewer", (char *)NULL);
  641. X        else
  642. X            local_footer_message("Starting tar viewer", (char *)NULL);
  643. X        fork_viewer(archive_viewer, filename);
  644. X        break;
  645. X    default:
  646. X        if (isremote) {
  647. X            footer_message("Starting default viewer %s", 
  648. X                default_viewer, (char *)NULL);
  649. X        } else {
  650. X            local_footer_message("Starting default viewer %s", 
  651. X                default_viewer, (char *)NULL);
  652. X        }
  653. X        fork_viewer(default_viewer, filename);
  654. X        break;
  655. X    }
  656. X    return which;
  657. }
  658. X
  659. #ifdef USE_PROTOTYPES
  660. void fork_viewer(char *program, char *filename)
  661. #else
  662. void fork_viewer(program, filename)
  663. char    *program;
  664. char    *filename;
  665. #endif
  666. {
  667. X    int    pid;
  668. X    char    **argv;
  669. X    int        argc;
  670. X    char    *arg;
  671. X    int        percentf=0;
  672. X
  673. X    switch(pid = fork()) {
  674. X    case -1:   
  675. X        perror("fork");
  676. X        break; 
  677. X    case 0: /* child */
  678. X        /* count number of words */
  679. X        argc = 0;
  680. X        arg = program;
  681. X        while (*arg && isspace(*arg))
  682. X            arg++;
  683. X        while (*arg) {
  684. X            /* found an arg */
  685. X            argc++;
  686. X            /* skip arg */
  687. X            while (*arg && !isspace(*arg))    
  688. X                arg++;
  689. X            /* skip WS */
  690. X            while (*arg && isspace(*arg))
  691. X                arg++;
  692. X        }
  693. X        if (argc == 0) {
  694. X            fprintf(stderr, "Null viewer.\n");
  695. X            exit(1);
  696. X        }
  697. X        /* allocate argv[]  (extra entry in case no %f specified) */
  698. X        argv = (char **)malloc((argc+2) * sizeof(char *));
  699. X        if (argv == NULL) {
  700. X            fprintf(stderr, "No memory. Cannot start viewer '%s'.\n",
  701. X                program);
  702. X            exit(1);
  703. X        }
  704. X        /* can munge program here, since it's in the child */
  705. X        argc = 0;
  706. X        arg = strtok(program, " \t\n");
  707. X        while (arg) {
  708. X            if (!strcmp(arg, "%f")) {
  709. X                percentf++;
  710. X                argv[argc] = filename;
  711. X            } else {
  712. X                argv[argc] = arg;
  713. X            }
  714. X            argc++;
  715. X            arg = strtok((char *)NULL, " \t\n");
  716. X        }
  717. X        if (!percentf) {
  718. X            argv[argc] = filename;
  719. X            argc++;
  720. X        }
  721. X        argv[argc] = NULL;
  722. X        /* %f means program name */
  723. X        execvp(argv[0], argv);
  724. X        fprintf(stderr, "viewer '%s' failed:", program);
  725. X        perror("");
  726. X        exit(1);
  727. X    default:/* parent */
  728. X        notify_set_wait3_func(base_window.frame, notify_default_wait3, pid);                    
  729. X        break;                                  
  730. X    }
  731. }
  732. X
  733. #ifdef USE_PROTOTYPES
  734. int file_type(char *filename)
  735. #else
  736. int file_type(filename)
  737. char    *filename;
  738. #endif
  739. {
  740. X    int        fd;
  741. X    char    buf[10];
  742. X    int        nread;
  743. X    char    *ext;
  744. X
  745. X    if ((fd = open(filename, O_RDONLY)) == -1) {
  746. X        goto out;
  747. X    }
  748. X    notify_do_dispatch();
  749. X    nread = read(fd, buf, sizeof(buf));
  750. X    notify_no_dispatch();
  751. X    if (nread == -1) {
  752. X        goto out;
  753. X    }
  754. X    close(fd);
  755. X    /* check for compressed file. '.Z' and magic value from /etc/magic */
  756. X    /*
  757. X     0       string          \037\235        compressed data
  758. X     */
  759. X    if (strlen(filename) > (unsigned int)2) {
  760. X        ext = filename + (strlen(filename) - 2);
  761. X        if (!strcmp(ext, ".Z") && (buf[0] == '\037') && (buf[1] == '\235')) {
  762. X                return COMPRESSED;
  763. X        }
  764. X    }
  765. X    /* check for postscript. */
  766. X    /*
  767. X     0       string          %!              PostScript document
  768. X     */
  769. X    if ((buf[0] == '%') && (buf[1] == '!')) {
  770. X        return POSTSCRIPT;
  771. X    }
  772. X    if (strlen(filename) > (unsigned int)3) {
  773. X        ext = filename + (strlen(filename) - 3);
  774. X        if (!strcmp(ext, ".ps"))
  775. X                return POSTSCRIPT;
  776. X    }
  777. X    /* try .tar */
  778. X    if (strlen(filename) > (unsigned int)4)  {
  779. X        ext = filename + (strlen(filename) - 4);
  780. X        if (!strcmp(ext, ".tar")) {
  781. X            return TARFILE;
  782. X        }
  783. X    }
  784. out:
  785. X    return UNKNOWN;
  786. }
  787. X
  788. #ifdef USE_PROTOTYPES
  789. void uncompress_file(char *filename, char *options)
  790. #else
  791. void uncompress_file(filename, options)
  792. char    *filename;
  793. char    *options;
  794. #endif
  795. {
  796. X    static char *argv[] = {
  797. X        "uncompress",
  798. X        "-vf",
  799. X        0,
  800. X        NULL,
  801. X    };
  802. X
  803. X    argv[1] = options;
  804. X    argv[2] = filename;
  805. X    pipe_program(argv);
  806. X
  807. }
  808. X
  809. #ifdef USE_PROTOTYPES
  810. void compress_file(char *filename, char *options)
  811. #else
  812. void compress_file(filename, options)
  813. char    *filename;
  814. char    *options;
  815. #endif
  816. {
  817. X    static char *argv[] = {
  818. X        "compress",
  819. X        "-vf",
  820. X        0,
  821. X        NULL,
  822. X    };
  823. X
  824. X    argv[1] = options;
  825. X    argv[2] = filename;
  826. X    pipe_program(argv);
  827. X
  828. }
  829. X
  830. #ifdef USE_PROTOTYPES
  831. void pipe_program(char *argv[])
  832. #else
  833. void pipe_program(argv)
  834. char    *argv[];
  835. #endif
  836. {
  837. X    int    pid;
  838. X    int pipe_fds[2];
  839. X    char scratch[100];
  840. X    FILE    *fp;
  841. X
  842. X    if (pipe(pipe_fds) == -1) {
  843. X        perror("ftptool:pipe");
  844. X        return;
  845. X    }
  846. X
  847. X    switch(pid = fork()) {
  848. X    case -1:   
  849. X        perror("fork");
  850. X        break; 
  851. X    case 0: /* child */
  852. X        dup2(pipe_fds[1], 1);
  853. X        dup2(pipe_fds[1], 2);
  854. X        close(pipe_fds[0]);
  855. X        close(pipe_fds[1]);
  856. X        execvp(argv[0], argv);
  857. X        perror("can not start program");
  858. X        exit(1);
  859. X    default:/* parent */
  860. X        notify_set_wait3_func(base_window.frame, notify_default_wait3, pid);
  861. X        close(pipe_fds[1]);
  862. X        break;                                  
  863. X    }
  864. X    fp = fdopen(pipe_fds[0], "r");
  865. X    if (fp == NULL) {
  866. X        perror("fopen");
  867. X        close(pipe_fds[0]);
  868. X        return;
  869. X    }
  870. X    notify_do_dispatch();
  871. X    while (fgets(scratch, sizeof(scratch), fp) != NULL) {
  872. X        notify_no_dispatch();
  873. X        log_message(scratch);
  874. X        notify_do_dispatch();
  875. X    }
  876. X    notify_no_dispatch();
  877. X    fclose(fp);
  878. }
  879. X
  880. #ifdef USE_PROTOTYPES
  881. int view_local_file(char *name, int which, int *dirchanged)
  882. #else
  883. int view_local_file(name, which, dirchanged)
  884. char    *name;
  885. int        which;
  886. int        *dirchanged;
  887. #endif
  888. {
  889. X    char *dot;
  890. X    struct stat buf;
  891. X
  892. X    if (stat(name, &buf) == -1) {
  893. X        local_footer_message("%s: %s.", name, sys_errlist[errno]);
  894. X        return 1;
  895. X    }   
  896. X    if (!S_ISREG(buf.st_mode)) {
  897. X        local_footer_message("%s is not a regular file.", name);
  898. X        return 1;
  899. X    }
  900. X    if (start_viewer(name,which==DOREMOTEVIEW) == COMPRESSED) {
  901. X        dot = rindex(name, '.');
  902. X        if (dot) {
  903. X            *dot = '\0';
  904. X            if (which == DOLOCALVIEW && dirchanged != NULL)
  905. X                *dirchanged = 1;
  906. X            start_viewer(name, which == DOREMOTEVIEW);
  907. X        }
  908. X    }
  909. X    return 0;
  910. }
  911. X
  912. char *newname;
  913. X
  914. #ifdef USE_PROTOTYPES
  915. int view_remote_file(char *name, size_t size)
  916. #else
  917. int view_remote_file(name, size)
  918. char    *name;
  919. size_t    size;
  920. #endif
  921. {
  922. X    static char *tmpname;
  923. X
  924. X    if (tmpname == NULL || (access(tmpname, F_OK) == -1 && errno == ENOENT)) {
  925. X        tmpname = tempnam("/var/tmp", "ftptl");
  926. X        if (tmpname == NULL || (mkdir(tmpname, 0777) == -1)) {
  927. X            footer_message("Can't create temporary directory.", (char *)NULL);
  928. X            return 1;
  929. X        }
  930. X    }
  931. X    sprintf(scratch, "%s/%s", tmpname, name);
  932. X    /* newname will be set if a unique local name is generated */
  933. X    newname = NULL;
  934. X    if (get_file(name, scratch, size)) {
  935. X        return 1;
  936. X    }
  937. X
  938. X    if (newname)
  939. X        strcpy(scratch, newname);
  940. X    
  941. X    return view_local_file(scratch, DOREMOTEVIEW, (int *)NULL);
  942. }
  943. SHAR_EOF
  944. chmod 0644 view_file.c ||
  945. echo 'restore of view_file.c failed'
  946. Wc_c="`wc -c < 'view_file.c'`"
  947. test 6916 -eq "$Wc_c" ||
  948.     echo 'view_file.c: original size 6916, current size' "$Wc_c"
  949. rm -f _shar_wnt_.tmp
  950. fi
  951. # ============= Makefile ==============
  952. if test -f 'Makefile' -a X"$1" != X"-c"; then
  953.     echo 'x - skipping Makefile (File already exists)'
  954.     rm -f _shar_wnt_.tmp
  955. else
  956. > _shar_wnt_.tmp
  957. echo 'x - extracting Makefile (Text)'
  958. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  959. # Makefile generated by imake - do not edit!
  960. # $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  961. #
  962. # The cpp used on this machine replaces all newlines and multiple tabs and
  963. # spaces in a macro expansion with a single space.  Imake tries to compensate
  964. # for this, but is not always successful.
  965. #
  966. X
  967. # -------------------------------------------------------------------------
  968. # Makefile generated from "Imake.tmpl" and </tmp/IIf.a13102>
  969. # $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  970. #
  971. # Platform-specific parameters may be set in the appropriate <vendor>.cf
  972. # configuration files.  Site-specific parameters should be set in the file
  973. # site.def.  Full rebuilds are recommended if any parameters are changed.
  974. #
  975. # If your C preprocessor does not define any unique symbols, you will need
  976. # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  977. # "make World" the first time).
  978. #
  979. X
  980. # -------------------------------------------------------------------------
  981. # site-specific configuration parameters that need to come before
  982. # the platform-specific parameters - edit site.def to change
  983. X
  984. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  985. X
  986. # -------------------------------------------------------------------------
  987. # platform-specific configuration parameters - edit sun.cf to change
  988. X
  989. # platform:  $XConsortium: sun.cf,v 1.72.1.1 92/03/18 13:13:37 rws Exp $
  990. X
  991. # operating system:  SunOS 4.1.1
  992. X
  993. # $XConsortium: sunLib.rules,v 1.7 91/12/20 11:19:47 rws Exp $
  994. X
  995. .c.o:
  996. X    $(CC) -c $(CFLAGS) $*.c
  997. X
  998. # -------------------------------------------------------------------------
  999. # site-specific configuration parameters that go after
  1000. # the platform-specific parameters - edit site.def to change
  1001. X
  1002. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  1003. X
  1004. X            SHELL = /bin/sh
  1005. X
  1006. X              TOP = .
  1007. X      CURRENT_DIR = .
  1008. X
  1009. X               AR = ar clq
  1010. X  BOOTSTRAPCFLAGS =
  1011. X               CC = gcc -fstrength-reduce -fpcc-struct-return
  1012. X               AS = as
  1013. X
  1014. X         COMPRESS = compress
  1015. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  1016. X    PREPROCESSCMD = gcc -fstrength-reduce -fpcc-struct-return -E $(STD_CPP_DEFINES)
  1017. X          INSTALL = install
  1018. X               LD = ld
  1019. X             LINT = lint
  1020. X      LINTLIBFLAG = -C
  1021. X         LINTOPTS = -axz
  1022. X               LN = ln -s
  1023. X             MAKE = make
  1024. X               MV = mv
  1025. X               CP = cp
  1026. X
  1027. X           RANLIB = ranlib
  1028. X  RANLIBINSTFLAGS =
  1029. X
  1030. X               RM = rm -f
  1031. X            TROFF = psroff
  1032. X         MSMACROS = -ms
  1033. X              TBL = tbl
  1034. X              EQN = eqn
  1035. X     STD_INCLUDES =
  1036. X  STD_CPP_DEFINES =
  1037. X      STD_DEFINES =
  1038. X EXTRA_LOAD_FLAGS = -B/usr/bin/
  1039. X  EXTRA_LIBRARIES =
  1040. X             TAGS = ctags
  1041. X
  1042. X    SHAREDCODEDEF = -DSHAREDCODE
  1043. X         SHLIBDEF = -DSUNSHLIB
  1044. X
  1045. X    PROTO_DEFINES =
  1046. X
  1047. X     INSTPGMFLAGS =
  1048. X
  1049. X     INSTBINFLAGS = -m 0755
  1050. X     INSTUIDFLAGS = -m 4755
  1051. X     INSTLIBFLAGS = -m 0644
  1052. X     INSTINCFLAGS = -m 0444
  1053. X     INSTMANFLAGS = -m 0444
  1054. X     INSTDATFLAGS = -m 0444
  1055. X    INSTKMEMFLAGS = -g kmem -m 2755
  1056. X
  1057. X      PROJECTROOT = /usr/X11/R5
  1058. X
  1059. X     TOP_INCLUDES = -I$(INCROOT)
  1060. X
  1061. X      CDEBUGFLAGS = -O2
  1062. X        CCOPTIONS =
  1063. X
  1064. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  1065. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  1066. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  1067. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  1068. X
  1069. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  1070. X
  1071. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  1072. X
  1073. X   LDCOMBINEFLAGS = -X -r
  1074. X      DEPENDFLAGS =
  1075. X
  1076. X        MACROFILE = sun.cf
  1077. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  1078. X
  1079. X    IMAKE_DEFINES =
  1080. X
  1081. X         IRULESRC = $(CONFIGDIR)
  1082. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  1083. X
  1084. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  1085. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  1086. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  1087. X
  1088. # -------------------------------------------------------------------------
  1089. # X Window System Build Parameters
  1090. # $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  1091. X
  1092. # -------------------------------------------------------------------------
  1093. # X Window System make variables; this need to be coordinated with rules
  1094. X
  1095. X          PATHSEP = /
  1096. X        USRLIBDIR = /usr/X11/R5/lib
  1097. X           BINDIR = /usr/X11/R5/bin
  1098. X          INCROOT = /usr/X11/R5/include
  1099. X     BUILDINCROOT = $(TOP)
  1100. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  1101. X      BUILDINCTOP = ..
  1102. X           INCDIR = $(INCROOT)/X11
  1103. X           ADMDIR = /usr/adm
  1104. X           LIBDIR = $(USRLIBDIR)/X11
  1105. X        CONFIGDIR = $(LIBDIR)/config
  1106. X       LINTLIBDIR = $(USRLIBDIR)/lint
  1107. X
  1108. X          FONTDIR = $(LIBDIR)/fonts
  1109. X         XINITDIR = $(LIBDIR)/xinit
  1110. X           XDMDIR = $(LIBDIR)/xdm
  1111. X           TWMDIR = $(LIBDIR)/twm
  1112. X          MANPATH = /usr/X11/R5/man
  1113. X    MANSOURCEPATH = $(MANPATH)/man
  1114. X        MANSUFFIX = n
  1115. X     LIBMANSUFFIX = 3
  1116. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  1117. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  1118. X           NLSDIR = $(LIBDIR)/nls
  1119. X        PEXAPIDIR = $(LIBDIR)/PEX
  1120. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  1121. X       FONTCFLAGS = -t
  1122. X
  1123. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  1124. X
  1125. X            IMAKE = imake
  1126. X           DEPEND = makedepend
  1127. X              RGB = rgb
  1128. X
  1129. X            FONTC = bdftopcf
  1130. X
  1131. X        MKFONTDIR = mkfontdir
  1132. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  1133. X
  1134. X        CONFIGSRC = $(TOP)/config
  1135. X       DOCUTILSRC = $(TOP)/doc/util
  1136. X        CLIENTSRC = $(TOP)/clients
  1137. X          DEMOSRC = $(TOP)/demos
  1138. X           LIBSRC = $(TOP)/lib
  1139. X          FONTSRC = $(TOP)/fonts
  1140. X       INCLUDESRC = $(TOP)/X11
  1141. X        SERVERSRC = $(TOP)/server
  1142. X          UTILSRC = $(TOP)/util
  1143. X        SCRIPTSRC = $(UTILSRC)/scripts
  1144. X       EXAMPLESRC = $(TOP)/examples
  1145. X       CONTRIBSRC = $(TOP)/../contrib
  1146. X           DOCSRC = $(TOP)/doc
  1147. X           RGBSRC = $(TOP)/rgb
  1148. X        DEPENDSRC = $(UTILSRC)/makedepend
  1149. X         IMAKESRC = $(CONFIGSRC)
  1150. X         XAUTHSRC = $(LIBSRC)/Xau
  1151. X          XLIBSRC = $(LIBSRC)/X
  1152. X           XMUSRC = $(LIBSRC)/Xmu
  1153. X       TOOLKITSRC = $(LIBSRC)/Xt
  1154. X       AWIDGETSRC = $(LIBSRC)/Xaw
  1155. X       OLDXLIBSRC = $(LIBSRC)/oldX
  1156. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  1157. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  1158. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  1159. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  1160. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  1161. X         FSLIBSRC = $(FONTSRC)/lib/fs
  1162. X    FONTSERVERSRC = $(FONTSRC)/server
  1163. X     EXTENSIONSRC = $(TOP)/extensions
  1164. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  1165. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  1166. X
  1167. # $XConsortium: sunLib.tmpl,v 1.14.1.1 92/03/17 14:58:46 rws Exp $
  1168. X
  1169. SHLIBLDFLAGS = -assert pure-text
  1170. PICFLAGS = -pic
  1171. X
  1172. X  DEPEXTENSIONLIB =
  1173. X     EXTENSIONLIB = -lXext
  1174. X
  1175. X          DEPXLIB = $(DEPEXTENSIONLIB)
  1176. X             XLIB = $(EXTENSIONLIB) -lX11
  1177. X
  1178. X        DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
  1179. X       XMULIBONLY = -lXmu
  1180. X           XMULIB = -lXmu
  1181. X
  1182. X       DEPOLDXLIB =
  1183. X          OLDXLIB = -loldX
  1184. X
  1185. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
  1186. X         XTOOLLIB = -lXt
  1187. X
  1188. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
  1189. X           XAWLIB = -lXaw
  1190. X
  1191. X        DEPXILIB =
  1192. X           XILIB = -lXi
  1193. X
  1194. X        SOXLIBREV = 4.10
  1195. X          SOXTREV = 4.10
  1196. X         SOXAWREV = 5.0
  1197. X        SOOLDXREV = 4.10
  1198. X         SOXMUREV = 4.10
  1199. X        SOXEXTREV = 4.10
  1200. X      SOXINPUTREV = 4.10
  1201. X
  1202. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  1203. X         XAUTHLIB =  -lXau
  1204. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  1205. X         XDMCPLIB =  -lXdmcp
  1206. X
  1207. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  1208. X           PHIGSLIB =  -lphigs
  1209. X
  1210. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  1211. X          XBSDLIB =  -lXbsd
  1212. X
  1213. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  1214. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  1215. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  1216. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  1217. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  1218. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  1219. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  1220. X
  1221. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  1222. X
  1223. X         DEPLIBS1 = $(DEPLIBS)
  1224. X         DEPLIBS2 = $(DEPLIBS)
  1225. X         DEPLIBS3 = $(DEPLIBS)
  1226. X
  1227. # -------------------------------------------------------------------------
  1228. # Imake rules for building libraries, programs, scripts, and data files
  1229. # rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  1230. X
  1231. # -------------------------------------------------------------------------
  1232. # start of Imakefile
  1233. X
  1234. #OPENWINHOME = /usr/local/OW3
  1235. X
  1236. #Uncomment the appropriate one if necessary. You should not need
  1237. #either, as it should be determined by the program.
  1238. #XVIEW= -DXVIEW3
  1239. #XVIEW= -DXVIEW2
  1240. X
  1241. #Uncomment the following line for SunOS 4.X
  1242. DEFINES= $(XVIEW)
  1243. X
  1244. #Uncomment the following lines for SunOS 5.0.
  1245. #DEFINES= -DSYSV -DSVR4
  1246. #LIBSUNOS5= -R /usr/openwin/lib:/opt/openwin/lib:/usr/opt/openwin/lib \
  1247. #    -lsocket -lnsl
  1248. X
  1249. #Uncomment the following line for 386 SVR4.
  1250. #DEFINES= -DSYSV386 -DSYSV -DSVR4
  1251. X
  1252. SYS_LIBRARIES     = -lm
  1253. LOCAL_LIBRARIES = -lxview -lolgx $(XLIB) $(LIBSUNOS5)
  1254. LDOPTIONS         = -L$(OPENWINHOME)/lib
  1255. INCLUDES         = -I$(OPENWINHOME)/include
  1256. X
  1257. HELPDIR            = $(OPENWINHOME)/lib/help
  1258. X
  1259. ICONS = busy1.ftptool.icon busy2.ftptool.icon busy3.ftptool.icon \
  1260. X    busy4.ftptool.icon ftptool.icon tar.viewer.icon
  1261. X
  1262. HEADERS = ftptool.h
  1263. X
  1264. SUBHEADERS= batch.h batch_struct.h button_funcs.h change_dir.h config.h \
  1265. X    create_main.h create_other.h dircache.h dircache_struct.h dirlist.h \
  1266. X    dirlist_struct.h dofuncs.h event.h ftp_var.h host_list.h \
  1267. X    host_list_struct.h main.h menu_funcs.h misc.h patchlevel.h readdir.h \
  1268. X    schedule.h schedule_struct.h tar_view.h transfer.h view_file.h
  1269. X
  1270. INFOFILES = ftptool.info
  1271. X
  1272. MANPAGES = ftptool.man
  1273. X
  1274. SRCS = batch.c button_funcs.c change_dir.c create_main.c create_other.c \
  1275. X    dircache.c dirlist.c dofuncs.c event.c ftp.c host_list.c lex.l main.c \
  1276. X    menu_funcs.c misc.c readdir.c schedule.c tar_view.c transfer.c view_file.c
  1277. X
  1278. OBJS = batch.o button_funcs.o change_dir.o create_main.o create_other.o \
  1279. X    dircache.o dirlist.o dofuncs.o event.o ftp.o host_list.o lex.o main.o \
  1280. X    menu_funcs.o misc.o readdir.o schedule.o tar_view.o transfer.o view_file.o
  1281. X
  1282. ALLFILES = ${HEADERS} ${INFOFILES} ${MANPAGES} ${ICONS} ${SRCS}
  1283. X
  1284. all:: ftptool
  1285. X
  1286. $(OBJS): $(HEADERS) $(SUBHEADERS)
  1287. X
  1288. X PROGRAM = ftptool
  1289. X
  1290. all:: ftptool
  1291. X
  1292. ftptool: $(OBJS) $(DEPLIBS)
  1293. X    $(RM) $@
  1294. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  1295. X
  1296. install:: ftptool
  1297. X    @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  1298. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  1299. X    $(INSTALL) -c $(INSTPGMFLAGS)  ftptool $(DESTDIR)$(BINDIR)
  1300. X
  1301. install.man:: ftptool.man
  1302. X    @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  1303. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  1304. X    $(INSTALL) -c $(INSTMANFLAGS) ftptool.man $(DESTDIR)$(MANDIR)/ftptool.$(MANSUFFIX)
  1305. X
  1306. depend::
  1307. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  1308. X
  1309. lint:
  1310. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  1311. lint1:
  1312. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  1313. X
  1314. clean::
  1315. X    $(RM) $(PROGRAM)
  1316. X
  1317. install::
  1318. X    $(INSTALL) -c $(INSTMANFLAGS) ftptool.info $(HELPDIR)/ftptool.info
  1319. X
  1320. # -------------------------------------------------------------------------
  1321. # common rules for all Makefiles - do not edit
  1322. X
  1323. emptyrule::
  1324. X
  1325. clean::
  1326. X    $(RM_CMD) "#"*
  1327. X
  1328. Makefile::
  1329. X    -@if [ -f Makefile ]; then set -x; \
  1330. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  1331. X    else exit 0; fi
  1332. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  1333. X
  1334. tags::
  1335. X    $(TAGS) -w *.[ch]
  1336. X    $(TAGS) -xw *.[ch] > TAGS
  1337. X
  1338. # -------------------------------------------------------------------------
  1339. # empty rules for directories that do not have SUBDIRS - do not edit
  1340. X
  1341. install::
  1342. X    @echo "install in $(CURRENT_DIR) done"
  1343. X
  1344. install.man::
  1345. X    @echo "install.man in $(CURRENT_DIR) done"
  1346. X
  1347. Makefiles::
  1348. X
  1349. includes::
  1350. X
  1351. # -------------------------------------------------------------------------
  1352. # dependencies generated by makedepend
  1353. X
  1354. SHAR_EOF
  1355. chmod 0644 Makefile ||
  1356. echo 'restore of Makefile failed'
  1357. Wc_c="`wc -c < 'Makefile'`"
  1358. test 11937 -eq "$Wc_c" ||
  1359.     echo 'Makefile: original size 11937, current size' "$Wc_c"
  1360. rm -f _shar_wnt_.tmp
  1361. fi
  1362. # ============= dirlist.c ==============
  1363. if test -f 'dirlist.c' -a X"$1" != X"-c"; then
  1364.     echo 'x - skipping dirlist.c (File already exists)'
  1365.     rm -f _shar_wnt_.tmp
  1366. else
  1367. > _shar_wnt_.tmp
  1368. echo 'x - extracting dirlist.c (Text)'
  1369. sed 's/^X//' << 'SHAR_EOF' > 'dirlist.c' &&
  1370. #include "ftptool.h"
  1371. X
  1372. #ifdef USE_PROTOTYPES
  1373. struct dirlist *new_dirlist(char *name, char *date, char *owner, 
  1374. X    char *group, mode_t mode, size_t size)
  1375. #else
  1376. struct dirlist *new_dirlist(name, date, owner, group, mode, size)
  1377. char    *name;
  1378. char    *date;
  1379. char    *owner;
  1380. char    *group;
  1381. mode_t    mode;
  1382. size_t    size;
  1383. #endif
  1384. {
  1385. X    struct dirlist *tmp;
  1386. X
  1387. X    tmp = (struct dirlist *)malloc(sizeof(struct dirlist));
  1388. X    if (tmp == NULL)
  1389. X        return NULL;
  1390. X    bzero((char *)tmp, sizeof(struct dirlist));
  1391. X    tmp->name = (char *)malloc((unsigned int)(strlen(name) + 1));
  1392. X    if (tmp->name == NULL) {
  1393. X        free_dirlist(tmp);
  1394. X        return NULL;
  1395. X    }
  1396. X
  1397. X    tmp->date = (char *)malloc((unsigned int)(strlen(date) + 1));
  1398. X    if (tmp->date == NULL) {
  1399. X        free_dirlist(tmp);
  1400. X        return NULL;
  1401. X    }
  1402. X
  1403. X    tmp->owner = (char *)malloc((unsigned int)(strlen(owner) + 1));
  1404. X    if (tmp->owner == NULL) {
  1405. X        free_dirlist(tmp);
  1406. X        return NULL;
  1407. X    }
  1408. X
  1409. X    tmp->group = (char *)malloc((unsigned int)(strlen(group) + 1));
  1410. X    if (tmp->group == NULL) {
  1411. X        free_dirlist(tmp);
  1412. X        return NULL;
  1413. X    }
  1414. X
  1415. X    strcpy(tmp->name, name);
  1416. X    strcpy(tmp->date, date);
  1417. X    strcpy(tmp->owner, owner);
  1418. X    strcpy(tmp->group, group);
  1419. X    tmp->mode = mode;
  1420. X    tmp->size = size;
  1421. X    tmp->next = NULL;
  1422. X    return tmp;
  1423. }
  1424. X
  1425. #ifdef USE_PROTOTYPES
  1426. struct dirlist *add_dirname(struct dirlist *head, char *name, char *date, 
  1427. X    char *owner, char *group, mode_t mode, size_t size, int sort_mode, 
  1428. X    int sort_direction)
  1429. #else
  1430. struct dirlist *add_dirname(head, name, date, owner, group, mode, 
  1431. X    size, sort_mode, sort_direction)
  1432. struct dirlist *head;
  1433. char    *name;
  1434. char    *date;
  1435. char    *owner;
  1436. char    *group;
  1437. mode_t    mode;
  1438. size_t    size;
  1439. int sort_mode;
  1440. int    sort_direction;
  1441. #endif
  1442. {
  1443. X    struct dirlist *tmp;
  1444. X    struct dirlist *oldnext = NULL;
  1445. X
  1446. X    if (non_unix)
  1447. X        sort_mode = SORTBYNAME;
  1448. X    switch(sort_mode) {
  1449. X    default:
  1450. X        fprintf(stderr, "Unknown sort mode in add_dirname.\n");
  1451. X        /* Fall through */
  1452. X    case SORTBYNAME:
  1453. X        if (sort_direction == ASCENDING)
  1454. X            tmp = sortupbyname(head, name);
  1455. X        else
  1456. X            tmp = sortdownbyname(head, name);
  1457. X        break;
  1458. X    case SORTBYDATE:
  1459. X        if (sort_direction == ASCENDING)
  1460. X            tmp = sortupbydate(head, date);
  1461. X        else
  1462. X            tmp = sortdownbydate(head, date);
  1463. X        break;
  1464. X    case SORTBYSIZE:
  1465. X        if (sort_direction == ASCENDING)
  1466. X            tmp = sortupbysize(head, size);
  1467. X        else
  1468. X            tmp = sortdownbysize(head, size);
  1469. X        break;
  1470. X    }
  1471. X    oldnext = tmp->next;
  1472. X    tmp->next = new_dirlist(name, date, owner, group, mode, size);
  1473. X    if (tmp->next == NULL) {
  1474. X        tmp->next = oldnext;
  1475. X        return NULL;
  1476. X    }
  1477. X
  1478. X    tmp->next->next = oldnext;
  1479. X    return head;
  1480. }
  1481. X
  1482. #ifdef USE_PROTOTYPES
  1483. struct dirlist *add_dirlist_struct(struct dirlist *head, 
  1484. X    struct dirlist *dlist, int sort_mode, int sort_direction)
  1485. #else
  1486. struct dirlist *add_dirlist_struct(head, dlist, sort_mode, sort_direction)
  1487. struct dirlist *head;
  1488. struct dirlist *dlist;
  1489. int sort_mode;
  1490. int    sort_direction;
  1491. #endif
  1492. {
  1493. X    struct dirlist *tmp;
  1494. X
  1495. X    if (non_unix)
  1496. X        sort_mode = SORTBYNAME;
  1497. X    switch(sort_mode) {
  1498. X    default:
  1499. X        fprintf(stderr, "Unknown sort mode in add_dirlist_struct.\n");
  1500. X        /* Fall through */
  1501. X    case SORTBYNAME:
  1502. X        if (sort_direction == ASCENDING)
  1503. X            tmp = sortupbyname(head, dlist->name);
  1504. X        else
  1505. X            tmp = sortdownbyname(head, dlist->name);
  1506. X        break;
  1507. X    case SORTBYDATE:
  1508. X        if (sort_direction == ASCENDING)
  1509. X            tmp = sortupbydate(head, dlist->date);
  1510. X        else
  1511. X            tmp = sortdownbydate(head, dlist->date);
  1512. X        break;
  1513. X    case SORTBYSIZE:
  1514. X        if (sort_direction == ASCENDING)
  1515. X            tmp = sortupbysize(head, dlist->size);
  1516. X        else
  1517. X            tmp = sortdownbysize(head, dlist->size);
  1518. X        break;
  1519. X    }
  1520. X    dlist->next = tmp->next;
  1521. X    tmp->next = dlist;
  1522. X    return head;
  1523. }
  1524. X
  1525. #ifdef USE_PROTOTYPES
  1526. void free_dirlist(struct dirlist *head)
  1527. #else
  1528. void free_dirlist(head)
  1529. struct dirlist *head;
  1530. #endif
  1531. {
  1532. X    struct dirlist *tmp;
  1533. X
  1534. X    while (head) {
  1535. X        tmp = head->next;
  1536. X        if (head->name)
  1537. X            free(head->name);
  1538. X        if (head->date)
  1539. X            free(head->date);
  1540. X        if (head->owner)
  1541. X            free(head->owner);
  1542. X        if (head->group)
  1543. X            free(head->group);
  1544. X        free((char *)head);
  1545. X        head = tmp;
  1546. X    }
  1547. }
  1548. X
  1549. /* alphabetical order */
  1550. #ifdef USE_PROTOTYPES
  1551. struct dirlist *sortupbyname(struct dirlist *head, char *name)
  1552. #else
  1553. struct dirlist *sortupbyname(head, name)
  1554. struct dirlist *head;
  1555. char    *name;
  1556. #endif
  1557. {
  1558. X    struct dirlist *tmp;
  1559. X    int        rval;
  1560. X
  1561. X    for (tmp = head; tmp->next != NULL; tmp = tmp->next) {
  1562. X        if (ignore_case)
  1563. X            rval = strcasecmp(name, tmp->next->name);
  1564. X        else
  1565. X            rval = strcmp(name, tmp->next->name);
  1566. X        if (rval < 0)
  1567. X            break; /* need to go before next entry. */
  1568. X    }
  1569. X    return tmp;
  1570. }
  1571. X
  1572. /* least recently modified */
  1573. #ifdef USE_PROTOTYPES
  1574. struct dirlist *sortupbydate(struct dirlist *head, char *date)
  1575. #else
  1576. struct dirlist *sortupbydate(head, date)
  1577. struct dirlist *head;
  1578. char    *date;
  1579. #endif
  1580. {
  1581. X    struct dirlist *tmp;
  1582. X
  1583. X    for (tmp = head; tmp->next != NULL; tmp = tmp->next) {
  1584. X        if (isearlier(date, tmp->next->date)) 
  1585. X            break; /* need to go before next entry. */
  1586. X    }
  1587. X    return tmp;
  1588. }
  1589. X
  1590. /* smallest to largest */
  1591. #ifdef USE_PROTOTYPES
  1592. struct dirlist *sortupbysize(struct dirlist *head, size_t size)
  1593. #else
  1594. struct dirlist *sortupbysize(head, size)
  1595. struct dirlist *head;
  1596. size_t    size;
  1597. #endif
  1598. {
  1599. X    struct dirlist *tmp;
  1600. X
  1601. X    for (tmp = head; tmp->next != NULL; tmp = tmp->next)
  1602. X        if (size <= tmp->next->size) 
  1603. X            break; /* need to go before next entry. */
  1604. X    return tmp;
  1605. }
  1606. X
  1607. static int cummonthdays[] = {
  1608. X    0,
  1609. X    31,
  1610. X    59,
  1611. X    90,
  1612. X    120,
  1613. X    151,
  1614. X    181,
  1615. X    212,
  1616. X    243,
  1617. X    273,
  1618. X    304,
  1619. X    334
  1620. };
  1621. X
  1622. #ifdef USE_PROTOTYPES
  1623. long    datetotime(char *date)
  1624. #else
  1625. long    datetotime(date)
  1626. char    *date;
  1627. #endif
  1628. {
  1629. X    struct tm tm;
  1630. X
  1631. X    /* "Aug 19 19:47" */
  1632. X    /* "Jan 10  1990" */
  1633. X
  1634. X    if (index(date, ':')) {
  1635. X        hour_time(date, &tm);
  1636. X        if (tm.tm_mon > current_month) 
  1637. X            tm.tm_year = current_year - 1;
  1638. X        else
  1639. X            tm.tm_year = current_year;
  1640. X    } else {
  1641. X        year_time(date, &tm);
  1642. X        tm.tm_hour = 0;
  1643. X        tm.tm_min = 0;
  1644. X    }
  1645. X    return (tm.tm_min + tm.tm_hour * 60
  1646. X        + (tm.tm_year * 365 + tm.tm_mday + cummonthdays[tm.tm_mon]) * 1440);
  1647. }
  1648. X
  1649. #ifdef USE_PROTOTYPES
  1650. int isearlier(char *date1, char *date2)
  1651. #else
  1652. int isearlier(date1, date2)
  1653. char    *date1, *date2;
  1654. #endif
  1655. {
  1656. X    long    time1;
  1657. X    long    time2;
  1658. X
  1659. X
  1660. X    time1 = datetotime(date1);
  1661. X    time2 = datetotime(date2);
  1662. X
  1663. X    if (time1 < time2)
  1664. X        return 1;
  1665. X    return 0;
  1666. }
  1667. X
  1668. /* reverse alphabetical order */
  1669. #ifdef USE_PROTOTYPES
  1670. struct dirlist *sortdownbyname(struct dirlist *head, char *name)
  1671. #else
  1672. struct dirlist *sortdownbyname(head, name)
  1673. struct dirlist *head;
  1674. char    *name;
  1675. #endif
  1676. {
  1677. X    struct dirlist *tmp;
  1678. X    int        rval;
  1679. X
  1680. X    for (tmp = head; tmp->next != NULL; tmp = tmp->next) {
  1681. X        if (ignore_case)
  1682. X            rval = strcasecmp(name, tmp->next->name);
  1683. X        else
  1684. X            rval = strcmp(name, tmp->next->name);
  1685. X        if (rval > 0)
  1686. X            break; /* need to go before next entry. */
  1687. X    }
  1688. X    return tmp;
  1689. }
  1690. X
  1691. /* most recently modified */
  1692. #ifdef USE_PROTOTYPES
  1693. struct dirlist *sortdownbydate(struct dirlist *head, char *date)
  1694. #else
  1695. struct dirlist *sortdownbydate(head, date)
  1696. struct dirlist *head;
  1697. char    *date;
  1698. #endif
  1699. {
  1700. X    struct dirlist *tmp;
  1701. X
  1702. X    for (tmp = head; tmp->next != NULL; tmp = tmp->next) {
  1703. X        if (!isearlier(date, tmp->next->date)) {
  1704. X            break; /* need to go before next entry. */
  1705. X        }
  1706. X    }
  1707. X    return tmp;
  1708. }
  1709. X
  1710. /* largest to smallest */
  1711. #ifdef USE_PROTOTYPES
  1712. struct dirlist *sortdownbysize(struct dirlist *head, size_t size)
  1713. #else
  1714. struct dirlist *sortdownbysize(head, size)
  1715. struct dirlist *head;
  1716. size_t    size;
  1717. #endif
  1718. {
  1719. X    struct dirlist *tmp;
  1720. X
  1721. X    for (tmp = head; tmp->next != NULL; tmp = tmp->next)
  1722. X        if (size >= tmp->next->size) 
  1723. X            break; /* need to go before next entry. */
  1724. X    return tmp;
  1725. }
  1726. X
  1727. #ifdef USE_PROTOTYPES
  1728. void clear_slist(Panel panel_list)
  1729. #else
  1730. void clear_slist(panel_list)
  1731. Panel panel_list;
  1732. #endif
  1733. {
  1734. X    int        nitems, row;
  1735. X    struct dirlist *dotdot;
  1736. X
  1737. X    nitems = xv_get(panel_list, PANEL_LIST_NROWS);
  1738. X    if (nitems && (dotdot = (struct dirlist *)xv_get(panel_list, 
  1739. X        PANEL_LIST_CLIENT_DATA, 0))) {
  1740. X        dotdot->next = NULL;
  1741. X        free_dirlist(dotdot);
  1742. X    }
  1743. X    for (row = nitems - 1; row >= 0; row--) {
  1744. X        xv_set(panel_list,
  1745. X            PANEL_LIST_DELETE, row,
  1746. X            PANEL_PAINT, PANEL_NONE,
  1747. X            NULL);
  1748. X    }
  1749. X    panel_paint(panel_list, PANEL_CLEAR);
  1750. }
  1751. X
  1752. #ifdef USE_PROTOTYPES
  1753. void actual_dirlist_to_slist(Panel panel_list, struct dirlist *head, 
  1754. X    mode_t type, int showdotfiles)
  1755. #else
  1756. void actual_dirlist_to_slist(panel_list, head, type, showdotfiles)
  1757. Panel    panel_list;
  1758. struct dirlist *head;
  1759. mode_t    type;
  1760. int        showdotfiles;
  1761. #endif
  1762. {
  1763. X    struct dirlist *tmp;
  1764. X    int    row;
  1765. X    Xv_font    entry_font;
  1766. X    char *d;
  1767. X    Server_image entry_glyph;
  1768. X
  1769. X    row = 0;
  1770. X    for (tmp = head->next; tmp != NULL; tmp = tmp->next) {
  1771. X        if (type && ((type & S_IFMT) != (tmp->mode & S_IFMT)))
  1772. X            continue;
  1773. X        if ((tmp != head->next) && (tmp->name[0] == '.' && !showdotfiles))
  1774. X            continue;
  1775. X        d = tmp->date;
  1776. X        if (!strcmp(tmp->date, "unknown"))
  1777. X            d = "";
  1778. X        if (tmp->size == -1)
  1779. X            sprintf(scratch, "  %12s  %10s  %s", d, "", tmp->name);
  1780. X        else
  1781. X            sprintf(scratch, "  %12s  %10d  %s", d, tmp->size, tmp->name);
  1782. X
  1783. X        if (S_ISDIR(tmp->mode)) {
  1784. X            entry_font = bold_list_font;
  1785. X            if (row != 0)
  1786. X                entry_glyph = directory_glyph;
  1787. X            else
  1788. X                entry_glyph = dotdot_glyph;
  1789. X            strcat(scratch, "/");
  1790. X        } else if (S_ISREG(tmp->mode)) {
  1791. X            entry_font = list_font;
  1792. X            entry_glyph = file_glyph;
  1793. X        } else {
  1794. X            entry_font = list_font;
  1795. X            entry_glyph = unknown_glyph;
  1796. X        }
  1797. X        xv_set(panel_list,
  1798. X            PANEL_LIST_INSERT, row,
  1799. X            PANEL_LIST_STRING, row, scratch,
  1800. X            PANEL_LIST_FONT, row, entry_font,
  1801. X            PANEL_LIST_GLYPH, row, entry_glyph,
  1802. X            PANEL_LIST_CLIENT_DATA, row, tmp,
  1803. X            PANEL_PAINT, PANEL_NONE,
  1804. X            NULL);
  1805. X        row++;
  1806. X    } 
  1807. X
  1808. }
  1809. X
  1810. #ifdef USE_PROTOTYPES
  1811. void dirlist_to_slist(Panel panel_list, struct dirlist *head)
  1812. #else
  1813. void dirlist_to_slist(panel_list, head)
  1814. Panel    panel_list;
  1815. struct dirlist *head;
  1816. #endif
  1817. {
  1818. X    struct dirlist *tmp;
  1819. X    int    dotypesort = 0;
  1820. X    int    showdotfiles = 0;
  1821. X
  1822. X    add_dotdot(head);
  1823. X
  1824. X    if (panel_list == local_window.list) {
  1825. X        showdotfiles = local_showdotfiles;
  1826. X        if (group_local_files)
  1827. X            dotypesort = 1;
  1828. X    } else {
  1829. X        /* panel_list == base_window.list */
  1830. X        showdotfiles = remote_showdotfiles;
  1831. X        if (group_remote_files)
  1832. X            dotypesort = 1;
  1833. X    }
  1834. X            
  1835. X    if (dotypesort) {
  1836. X        /* have to insert backwards, since the routine inserts at 0 */
  1837. #ifdef S_IFIFO
  1838. X        actual_dirlist_to_slist(panel_list, head, S_IFIFO, showdotfiles);
  1839. #endif
  1840. #ifdef S_IFSOCK
  1841. X        actual_dirlist_to_slist(panel_list, head, S_IFSOCK, showdotfiles);
  1842. #endif
  1843. X        actual_dirlist_to_slist(panel_list, head, S_IFBLK, showdotfiles);
  1844. X        actual_dirlist_to_slist(panel_list, head, S_IFCHR, showdotfiles);
  1845. X        actual_dirlist_to_slist(panel_list, head, S_IFLNK, showdotfiles);
  1846. X        actual_dirlist_to_slist(panel_list, head, S_IFREG, showdotfiles);
  1847. X        actual_dirlist_to_slist(panel_list, head, S_IFDIR, showdotfiles);
  1848. X    } else {
  1849. X        actual_dirlist_to_slist(panel_list, head, 0, showdotfiles);
  1850. X    }
  1851. X
  1852. X    /* now remove '..' from list */
  1853. X    tmp = head->next;
  1854. X    head->next = head->next->next;
  1855. X    tmp->next = NULL;
  1856. X
  1857. X    /* all entries attached as client_data */
  1858. X    xv_set(panel_list, 
  1859. X        XV_SHOW, TRUE, 
  1860. X        NULL);
  1861. }
  1862. X
  1863. #ifdef USE_PROTOTYPES
  1864. void add_dotdot(struct dirlist *head)
  1865. #else
  1866. void add_dotdot(head)
  1867. struct dirlist *head;
  1868. #endif
  1869. {
  1870. X    struct dirlist *tmp;
  1871. X
  1872. X    tmp = new_dirlist("..", "unknown", "", "", S_IFDIR, (size_t)-1);
  1873. X    if (tmp == NULL)
  1874. X        return;
  1875. X
  1876. X    tmp->next = head->next;
  1877. X    head->next = tmp;
  1878. }
  1879. X
  1880. #ifdef USE_PROTOTYPES
  1881. struct dirlist *sort_dirlist(struct dirlist *head, int sort_mode, 
  1882. X    int sort_direction)
  1883. #else
  1884. struct dirlist *sort_dirlist(head, sort_mode, sort_direction)
  1885. struct dirlist *head;
  1886. int    sort_mode;
  1887. int    sort_direction;
  1888. #endif
  1889. {
  1890. X    struct dirlist *tmp;
  1891. X    struct dirlist *next;
  1892. X
  1893. X    if (head == NULL)
  1894. X        return NULL;
  1895. X    /* sort current list into new one */
  1896. X    tmp = head->next;
  1897. X    head->next = NULL;
  1898. X    while (tmp) {
  1899. X        next = tmp->next;
  1900. X        tmp->next = NULL;
  1901. X        add_dirlist_struct(head, tmp, sort_mode, sort_direction);
  1902. X        tmp = next;
  1903. X    }
  1904. X    return head;
  1905. }
  1906. X
  1907. static char *abbrev_month[] = {
  1908. X    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  1909. X    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
  1910. };
  1911. X
  1912. #ifdef USE_PROTOTYPES
  1913. void hour_time(char *date, struct tm *tm)
  1914. #else
  1915. void hour_time(date, tm)
  1916. char    *date;
  1917. struct tm *tm;
  1918. #endif
  1919. {
  1920. X    char    month[10];
  1921. X    int        i;
  1922. X
  1923. X    bzero((char *)tm, sizeof(struct tm));
  1924. X    sscanf(date, "%s%d%d:%d", month, &tm->tm_mday, 
  1925. X        &tm->tm_hour, &tm->tm_min);
  1926. X    for (i = 0; i < 12; i++)
  1927. X        if (!strncmp(month, abbrev_month[i], 3))
  1928. X            break;
  1929. X    if (i != 12)
  1930. X        tm->tm_mon = i;
  1931. }
  1932. X
  1933. #ifdef USE_PROTOTYPES
  1934. void year_time(char *date, struct tm *tm)
  1935. #else
  1936. void year_time(date, tm)
  1937. char    *date;
  1938. struct tm *tm;
  1939. #endif
  1940. {
  1941. X    char    month[10];
  1942. X    int        i;
  1943. X
  1944. X    bzero((char *)tm, sizeof(struct tm));
  1945. X    sscanf(date, "%s%d%d", month, &tm->tm_mday, &tm->tm_year);
  1946. X    for (i = 0; i < 12; i++)
  1947. X        if (!strncmp(month, abbrev_month[i], 3))
  1948. X            break;
  1949. X    if (i != 12)
  1950. X        tm->tm_mon = i;
  1951. X    if (tm->tm_year > 1900)
  1952. X        tm->tm_year -= 1900;
  1953. }
  1954. SHAR_EOF
  1955. chmod 0644 dirlist.c ||
  1956. echo 'restore of dirlist.c failed'
  1957. Wc_c="`wc -c < 'dirlist.c'`"
  1958. test 12320 -eq "$Wc_c" ||
  1959.     echo 'dirlist.c: original size 12320, current size' "$Wc_c"
  1960. rm -f _shar_wnt_.tmp
  1961. fi
  1962. # ============= lex.c ==============
  1963. if test -f 'lex.c' -a X"$1" != X"-c"; then
  1964.     echo 'x - skipping lex.c (File already exists)'
  1965.     rm -f _shar_wnt_.tmp
  1966. else
  1967. > _shar_wnt_.tmp
  1968. echo 'x - extracting lex.c (Text)'
  1969. sed 's/^X//' << 'SHAR_EOF' > 'lex.c' &&
  1970. # include <stdio.h>
  1971. # define U(x) x
  1972. # define NLSTATE yyprevious=YYNEWLINE
  1973. # define BEGIN yybgin = yysvec + 1 +
  1974. # define INITIAL 0
  1975. # define YYLERR yysvec
  1976. # define YYSTATE (yyestate-yysvec-1)
  1977. # define YYOPTIM 1
  1978. # define YYLMAX 200
  1979. # define output(c) (void)putc(c,yyout)
  1980. #if defined(__cplusplus) || defined(__STDC__)
  1981. X    int yyback(int *, int);
  1982. X    int yyinput(void);
  1983. X    int yylook(void);
  1984. X    void yyoutput(int);
  1985. X    int yyracc(int);
  1986. X    int yyreject(void);
  1987. X    void yyunput(int);
  1988. X
  1989. #ifndef __STDC__
  1990. #ifndef yyless
  1991. X    void yyless(int);
  1992. #endif
  1993. #ifndef yywrap
  1994. X    int yywrap(void);
  1995. #endif
  1996. #endif
  1997. X
  1998. #endif
  1999. # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
  2000. # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
  2001. # define yymore() (yymorfg=1)
  2002. # define ECHO (void)fprintf(yyout, "%s",yytext)
  2003. # define REJECT { nstr = yyreject(); goto yyfussy;}
  2004. int yyleng; extern char yytext[];
  2005. int yymorfg;
  2006. extern char *yysptr, yysbuf[];
  2007. int yytchar;
  2008. FILE *yyin = {stdin}, *yyout = {stdout};
  2009. extern int yylineno;
  2010. struct yysvf { 
  2011. X    struct yywork *yystoff;
  2012. X    struct yysvf *yyother;
  2013. X    int *yystops;};
  2014. struct yysvf *yyestate;
  2015. extern struct yysvf yysvec[], *yybgin;
  2016. #undef ECHO
  2017. #include "ftptool.h"
  2018. X
  2019. #undef input
  2020. extern char *lex_string;
  2021. # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):*lex_string++)==10?(yylineno++,yytchar):yytchar)==0?0:yytchar)
  2022. # define YYNEWLINE 10
  2023. yylex(){
  2024. int nstr; extern int yyprevious;
  2025. while((nstr = yylook()) >= 0)
  2026. yyfussy: switch(nstr){
  2027. case 0:
  2028. if(yywrap()) return(0); break;
  2029. case 1:
  2030. X
  2031. # line 10 "lex.l"
  2032. {return(' ');}
  2033. break;
  2034. case 2:
  2035. X
  2036. # line 11 "lex.l"
  2037. X    {return(PERMS);}
  2038. break;
  2039. case 3:
  2040. X
  2041. # line 12 "lex.l"
  2042. X    {return(LINKS);}
  2043. break;
  2044. case 4:
  2045. X
  2046. # line 13 "lex.l"
  2047. X    {return(USER);}
  2048. break;
  2049. case 5:
  2050. X
  2051. # line 14 "lex.l"
  2052. X    {return(GROUP);}
  2053. break;
  2054. case 6:
  2055. X
  2056. # line 15 "lex.l"
  2057. X    {return(SIZE);}
  2058. break;
  2059. case 7:
  2060. X
  2061. # line 16 "lex.l"
  2062. X    {return(MONTH);}
  2063. break;
  2064. case 8:
  2065. X
  2066. # line 17 "lex.l"
  2067. X        {return(DAY);}
  2068. break;
  2069. case 9:
  2070. X
  2071. # line 18 "lex.l"
  2072. X    {return(TIME);}
  2073. break;
  2074. case 10:
  2075. X
  2076. # line 19 "lex.l"
  2077. X    {return(NAME);}
  2078. break;
  2079. case 11:
  2080. X
  2081. # line 20 "lex.l"
  2082. X    {return(SKIP);}
  2083. break;
  2084. case 12:
  2085. X
  2086. # line 21 "lex.l"
  2087. X    {return(NONUNIX);}
  2088. break;
  2089. case 13:
  2090. X
  2091. # line 22 "lex.l"
  2092. X    {return(LOWERNAME);}
  2093. break;
  2094. case 14:
  2095. X
  2096. # line 23 "lex.l"
  2097. X        {return(yytext[0]);}
  2098. break;
  2099. case -1:
  2100. break;
  2101. default:
  2102. (void)fprintf(yyout,"bad switch yylook %d",nstr);
  2103. } return(0); }
  2104. /* end of yylex */
  2105. X
  2106. yywrap()
  2107. {
  2108. X    return 1;
  2109. }
  2110. int yyvstop[] = {
  2111. 0,
  2112. X
  2113. 14,
  2114. 0,
  2115. X
  2116. 1,
  2117. 14,
  2118. 0,
  2119. X
  2120. 1,
  2121. 0,
  2122. X
  2123. 14,
  2124. 0,
  2125. X
  2126. 14,
  2127. 0,
  2128. X
  2129. 14,
  2130. 0,
  2131. X
  2132. 14,
  2133. 0,
  2134. X
  2135. 14,
  2136. 0,
  2137. X
  2138. 14,
  2139. 0,
  2140. X
  2141. 14,
  2142. 0,
  2143. X
  2144. 14,
  2145. 0,
  2146. X
  2147. 14,
  2148. 0,
  2149. X
  2150. 14,
  2151. 0,
  2152. X
  2153. 8,
  2154. 0,
  2155. X
  2156. 10,
  2157. 0,
  2158. X
  2159. 6,
  2160. 0,
  2161. X
  2162. 11,
  2163. 0,
  2164. X
  2165. 9,
  2166. 0,
  2167. X
  2168. 4,
  2169. 0,
  2170. X
  2171. 5,
  2172. 0,
  2173. X
  2174. 3,
  2175. 0,
  2176. X
  2177. 7,
  2178. 0,
  2179. X
  2180. 2,
  2181. 0,
  2182. X
  2183. 13,
  2184. 0,
  2185. X
  2186. 12,
  2187. 0,
  2188. 0};
  2189. # define YYTYPE unsigned char
  2190. struct yywork { YYTYPE verify, advance; } yycrank[] = {
  2191. 0,0,    0,0,    1,3,    0,0,    
  2192. 0,0,    0,0,    0,0,    0,0,    
  2193. 0,0,    0,0,    1,4,    1,5,    
  2194. 4,5,    4,5,    0,0,    0,0,    
  2195. 0,0,    0,0,    0,0,    0,0,    
  2196. 0,0,    0,0,    0,0,    0,0,    
  2197. 0,0,    0,0,    0,0,    0,0,    
  2198. 0,0,    0,0,    0,0,    0,0,    
  2199. 0,0,    0,0,    0,0,    4,5,    
  2200. 0,0,    0,0,    0,0,    0,0,    
  2201. 0,0,    0,0,    0,0,    0,0,    
  2202. 0,0,    0,0,    0,0,    0,0,    
  2203. 0,0,    0,0,    0,0,    0,0,    
  2204. 0,0,    0,0,    0,0,    0,0,    
  2205. 0,0,    0,0,    0,0,    0,0,    
  2206. 0,0,    1,6,    0,0,    51,57,    
  2207. 0,0,    0,0,    7,17,    16,28,    
  2208. 0,0,    1,7,    12,23,    27,39,    
  2209. 1,8,    33,44,    9,19,    11,21,    
  2210. 14,26,    1,9,    1,10,    1,11,    
  2211. 2,6,    1,12,    6,16,    8,18,    
  2212. 1,13,    1,14,    1,15,    10,20,    
  2213. 2,7,    11,22,    13,24,    2,8,    
  2214. 13,25,    15,27,    17,29,    18,30,    
  2215. 2,9,    2,10,    2,11,    19,31,    
  2216. 2,12,    20,32,    21,33,    2,13,    
  2217. 2,14,    2,15,    22,34,    23,35,    
  2218. 24,36,    25,37,    26,38,    28,40,    
  2219. 30,41,    31,42,    32,43,    34,45,    
  2220. 35,46,    36,47,    37,48,    38,49,    
  2221. 39,50,    40,51,    41,52,    42,53,    
  2222. 43,54,    45,55,    46,56,    55,58,    
  2223. 58,59,    0,0,    0,0,    0,0,    
  2224. 0,0};
  2225. SHAR_EOF
  2226. true || echo 'restore of lex.c failed'
  2227. fi
  2228. echo 'End of  part 3'
  2229. echo 'File lex.c is continued in part 4'
  2230. echo 4 > _shar_seq_.tmp
  2231. exit 0
  2232. -- 
  2233. Senior Systems Scientist        mail: dcmartin@msi.com
  2234. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  2235. 796 North Pastoria Avenue        at&t: 408/522-9236
  2236. Sunnyvale, California 94086        fax: 408/732-0831
  2237.