home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / contol3a / part05 < prev    next >
Encoding:
Text File  |  1992-03-04  |  45.1 KB  |  1,447 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!dcmartin
  3. From: Chuck Musciano <chuck@trantor.harris-atd.com>
  4. Subject: v16i104: contool 3.2A (Final Release), Part05/07
  5. Message-ID: <1992Mar5.214823.9656@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-16i100-contool-3.2a@uunet.UU.NET>
  10. Date: Thu, 5 Mar 1992 21:48:23 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: Chuck Musciano <chuck@trantor.harris-atd.com>
  14. Posting-number: Volume 16, Issue 104
  15. Archive-name: contool-3.2a/part05
  16.  
  17. # this is Part.05 (part 5 of a multipart archive)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file logging.c continued
  20. #
  21. if test ! -r _shar_seq_.tmp; then
  22.     echo 'Please unpack part 1 first!'
  23.     exit 1
  24. fi
  25. (read Scheck
  26.  if test "$Scheck" != 5; then
  27.     echo Please unpack part "$Scheck" next!
  28.     exit 1
  29.  else
  30.     exit 0
  31.  fi
  32. ) < _shar_seq_.tmp || exit 1
  33. if test ! -f _shar_wnt_.tmp; then
  34.     echo 'x - still skipping logging.c'
  35. else
  36. echo 'x - continuing file logging.c'
  37. sed 's/^X//' << 'SHAR_EOF' >> 'logging.c' &&
  38. X       }
  39. }
  40. X
  41. /************************************************************************/
  42. EXPORT    Menu_item    start_logging(item, op)
  43. X
  44. Menu_item    item;
  45. Menu_generate    op;
  46. X
  47. {    contool_base_objects    *ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  48. X
  49. X    if (op == MENU_DISPLAY)
  50. X       xv_set(item, MENU_INACTIVE, logging, NULL);
  51. X    else if (op == MENU_NOTIFY)
  52. X       enable_logging();
  53. X    return item;
  54. }
  55. X
  56. /************************************************************************/
  57. EXPORT    Menu_item    stop_logging(item, op)
  58. X
  59. Menu_item    item;
  60. Menu_generate    op;
  61. X
  62. {    contool_base_objects    *ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  63. X    
  64. X    if (op == MENU_DISPLAY)
  65. X       xv_set(item, MENU_INACTIVE, !logging, NULL);
  66. X    else if (op == MENU_NOTIFY)
  67. X       disable_logging();
  68. X    return item;
  69. }
  70. X
  71. /************************************************************************/
  72. EXPORT    update_logging()
  73. X
  74. {
  75. X    if (logging) {
  76. X       disable_logging();
  77. X       enable_logging();
  78. X       }
  79. }
  80. X
  81. /************************************************************************/
  82. EXPORT    write_log(s)
  83. X
  84. char    *s;
  85. X
  86. {    int    t;
  87. X    static    char    hostname[100] = "";
  88. X
  89. X    if (logging) {
  90. X       if (*hostname == NULL) 
  91. X          if (gethostname(hostname, 99) != 0)
  92. X             strcpy(hostname, "(unknown)");
  93. X       t = time(0);
  94. X       fseek(logfile, 0L, 2);
  95. X       fprintf(logfile, "%s\t%.16s\t%s", hostname, ctime(&t) + 4, s);
  96. X       fflush(logfile);
  97. X       }
  98. }
  99. SHAR_EOF
  100. echo 'File logging.c is complete' &&
  101. chmod 0644 logging.c ||
  102. echo 'restore of logging.c failed'
  103. Wc_c="`wc -c < 'logging.c'`"
  104. test 4060 -eq "$Wc_c" ||
  105.     echo 'logging.c: original size 4060, current size' "$Wc_c"
  106. rm -f _shar_wnt_.tmp
  107. fi
  108. # ============= misc.c ==============
  109. if test -f 'misc.c' -a X"$1" != X"-c"; then
  110.     echo 'x - skipping misc.c (File already exists)'
  111.     rm -f _shar_wnt_.tmp
  112. else
  113. > _shar_wnt_.tmp
  114. echo 'x - extracting misc.c (Text)'
  115. sed 's/^X//' << 'SHAR_EOF' > 'misc.c' &&
  116. /************************************************************************/
  117. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  118. /*                                    */
  119. /*    Full ownership of this software, and all rights pertaining to     */
  120. /*    the for-profit distribution of this software, are retained by     */
  121. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  122. /*    use this software without fee.  This software is provided "as     */
  123. /*    is" without express or implied warranty.  You may redistribute     */
  124. /*    this software, provided that this copyright notice is retained,    */
  125. /*    and that the software is not distributed for profit.  If you     */
  126. /*    wish to use this software in a profit-making venture, you must     */
  127. /*    first license this code and its underlying technology from     */
  128. /*    Harris Corporation.                         */
  129. /*                                    */
  130. /*    Bottom line: you can have this software, you can use it, you     */
  131. /*    can give it away.  You just can't sell any or all parts of it     */
  132. /*    without prior permission from Harris Corporation.         */
  133. /************************************************************************/
  134. X
  135. #include    <stdio.h>
  136. #include    <ctype.h>
  137. #include    <pwd.h>
  138. X
  139. #include    "manifest.h"
  140. #include    "contool.h"
  141. X
  142. PUBLIC    char    *index();
  143. X
  144. /************************************************************************/
  145. EXPORT    int    getline(stream, string, max)
  146. X
  147. FILE    *stream;
  148. char    *string;
  149. int    max;
  150. X
  151. {    register    int    i, j;
  152. X
  153. X    i = (int) fgets(string, max, stream);
  154. X    if (i == NULL)
  155. X       return(EOF);
  156. X    j = strlen(string);
  157. X    if (j > 0 && string[j - 1] == '\n')
  158. X       string[--j] = '\0';
  159. X    return(j);
  160. }
  161. X
  162. /************************************************************************/
  163. EXPORT    int    verify(source, valid)
  164. X
  165. char    *source;
  166. char    *valid;
  167. X
  168. {    register    char    *s;
  169. X
  170. X    for ( ; *source; source++) {
  171. X       for (s = valid; *s && *s != *source; s++)
  172. X          ;
  173. X       if (*s == '\0')
  174. X          return(0);
  175. X       }
  176. X    return(1);
  177. }
  178. X
  179. /************************************************************************/
  180. EXPORT    char    **saveargs(argc, argv)
  181. X
  182. int    argc;
  183. char    **argv;
  184. X
  185. {    int    i;
  186. X    char    **copy;
  187. X
  188. X    copy = (char **) malloc((argc + 1) * sizeof(char *));
  189. X    for (i = 0; i < argc; i++)
  190. X       strcpy(copy[i] = (char *) malloc(strlen(argv[i]) + 1), argv[i]);
  191. X    copy[i] = (char *) 0;
  192. X    return(copy);
  193. }
  194. X
  195. #define        SIZE_INCREMENT        8
  196. X
  197. /************************************************************************/
  198. EXPORT    char    **tokenize(line, argc)
  199. X
  200. char    *line;
  201. int    *argc;
  202. X
  203. {    char    match, **argv, *buf, *p;
  204. X    int    limit;
  205. X
  206. X    buf = (char *) malloc(strlen(line) + 1);
  207. X    *argc = 0;
  208. X    argv = (char **) malloc((limit = SIZE_INCREMENT) * sizeof(char *));
  209. X    while (*line) {
  210. X       while (isspace(*line))
  211. X          line++;
  212. X       switch (*line) {
  213. X          case '"'  :
  214. X          case '\'' : match = *line++; /* remove the quote mark */
  215. X                    for (p = buf; *line && (*line != match); ) {
  216. X                       if (*line == '\\')
  217. X                          line++;
  218. X                       if (*line)
  219. X                          *p++ = *line++;
  220. X                       }
  221. X                    if (*line)
  222. X                       line++; /* wipe out quote mark */
  223. X                    break;
  224. X          default   : for (p = buf; *line && !isspace(*line) && (*line != '"') && (*line != '\''); )
  225. X                       *p++ = *line++;
  226. X                    break;
  227. X          }
  228. X       *p = '\0';
  229. X       if (*buf) {
  230. X          argv[(*argc)++] = strsave(buf);
  231. X          if (*argc == limit)
  232. X             argv = (char **) realloc(argv, (limit += SIZE_INCREMENT) * sizeof(char *));
  233. X          }
  234. X       }
  235. X    free(buf);
  236. X    argv[*argc] = (char *) 0;
  237. X    return(argv);
  238. }
  239. X
  240. #define        P_POS        5
  241. #define        L_POS        8
  242. #define        D_POS        9
  243. X
  244. #define        PATH        "/dev/ptyp0"
  245. #define        LETTERS        "pqr"
  246. #define        DIGITS        "0123456789abcdef"
  247. X
  248. PRIVATE    char    path[12];
  249. X
  250. /************************************************************************/
  251. EXPORT    char    *open_psuedo_tty(master, m_mode, slave, s_mode)
  252. X
  253. FILE    **master;
  254. char    *m_mode;
  255. FILE    **slave;
  256. char    *s_mode;
  257. X
  258. {    char    *s, *t;
  259. X
  260. X    strcpy(path, PATH);
  261. X    for (s = LETTERS; *s && *master == NULL; s++) {
  262. X       path[L_POS] = *s;
  263. X       for (t = DIGITS; *t && *master == NULL; t++) {
  264. X          path[D_POS] = *t;
  265. X          *master = fopen(path, m_mode);
  266. X          }
  267. X       }
  268. X    if (*master != NULL) {
  269. X       path[P_POS] = 't';
  270. X       *slave = fopen(path, s_mode);
  271. X       path[P_POS] = 'p';
  272. X       }
  273. X    return(path);
  274. }
  275. X
  276. /************************************************************************/
  277. EXPORT    char    *expand_tilde(path)
  278. X
  279. char    *path;
  280. X
  281. {    char    s[1024], *p;
  282. X    struct    passwd    *pw;
  283. X
  284. X    if (*path == '~') {
  285. X       if (path[1] == '/' || path[1] == '\0') {
  286. X          strcpy(s, getenv("HOME"));
  287. X          strcat(s, path + 1);
  288. X          }
  289. X       else {
  290. X          if ((p = index(path, '/')) != NULL)
  291. X             *p = '\0';
  292. X          if ((pw = getpwnam(path + 1)) != NULL) {
  293. X             strcpy(s, pw->pw_dir);
  294. X             if (p != NULL) {
  295. X                strcat(s, "/");
  296. X                strcat(s, p + 1);
  297. X                }
  298. X             }
  299. X          else {
  300. X             if (p != NULL)
  301. X                *p = '/';
  302. X             strcpy(s, path);
  303. X             }
  304. X          }
  305. X       return(strsave(s));
  306. X       }
  307. X    else
  308. X       return(strsave(path));
  309. }
  310. X
  311. /************************************************************************/
  312. EXPORT    int    is_empty(s)
  313. X
  314. char    *s;
  315. X
  316. {
  317. X    if (s == NULL)
  318. X       return(TRUE);
  319. X    for (; *s; s++)
  320. X       if (!isspace(*s))
  321. X          return(FALSE); 
  322. X    return(TRUE);
  323. }
  324. X
  325. /************************************************************************/
  326. EXPORT    char    *check_escapes(s)
  327. X
  328. char    *s;
  329. X
  330. {    static    char    buf[1024];
  331. X    char    *p;
  332. X
  333. X    for (p = buf; *s; s++, p++)
  334. X       if (*s == '"') {
  335. X          *p++ = '"';
  336. X          *p = *s;
  337. X          }
  338. X       else
  339. X          *p = *s;
  340. X    *p = '\0';
  341. X    return(buf);
  342. }
  343. SHAR_EOF
  344. chmod 0644 misc.c ||
  345. echo 'restore of misc.c failed'
  346. Wc_c="`wc -c < 'misc.c'`"
  347. test 5391 -eq "$Wc_c" ||
  348.     echo 'misc.c: original size 5391, current size' "$Wc_c"
  349. rm -f _shar_wnt_.tmp
  350. fi
  351. # ============= pinned_menu_notify.c ==============
  352. if test -f 'pinned_menu_notify.c' -a X"$1" != X"-c"; then
  353.     echo 'x - skipping pinned_menu_notify.c (File already exists)'
  354.     rm -f _shar_wnt_.tmp
  355. else
  356. > _shar_wnt_.tmp
  357. echo 'x - extracting pinned_menu_notify.c (Text)'
  358. sed 's/^X//' << 'SHAR_EOF' > 'pinned_menu_notify.c' &&
  359. /************************************************************************/
  360. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  361. /*                                    */
  362. /*    Full ownership of this software, and all rights pertaining to     */
  363. /*    the for-profit distribution of this software, are retained by     */
  364. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  365. /*    use this software without fee.  This software is provided "as     */
  366. /*    is" without express or implied warranty.  You may redistribute     */
  367. /*    this software, provided that this copyright notice is retained,    */
  368. /*    and that the software is not distributed for profit.  If you     */
  369. /*    wish to use this software in a profit-making venture, you must     */
  370. /*    first license this code and its underlying technology from     */
  371. /*    Harris Corporation.                         */
  372. /*                                    */
  373. /*    Bottom line: you can have this software, you can use it, you     */
  374. /*    can give it away.  You just can't sell any or all parts of it     */
  375. /*    without prior permission from Harris Corporation.         */
  376. /************************************************************************/
  377. X
  378. /************************************************************************/
  379. /*                                    */
  380. /*    pinned_menu_notify.c    GUIDE callback for pinned menus        */
  381. /*                                    */
  382. /************************************************************************/
  383. X
  384. #include    <stdio.h>
  385. #include    <sys/param.h>
  386. #include    <sys/types.h>
  387. #include    <xview/xview.h>
  388. X
  389. #include    "manifest.h"
  390. X
  391. /************************************************************************/
  392. EXPORT    void    pinned_menu_notify(menu, item)
  393. X
  394. Menu        menu;
  395. Menu_item    item;
  396. X
  397. {    Xv_opaque    pin_window     = (Xv_opaque) xv_get(menu, MENU_PIN_WINDOW);
  398. X    void        (*menu_notify)() = (void (*)()) xv_get(menu, MENU_GEN_PROC);
  399. X    void        (*item_notify)() = (void (*)()) xv_get(item, MENU_GEN_PROC);
  400. X    
  401. X    if (pin_window && xv_get(pin_window, XV_SHOW)) {
  402. X       if (menu_notify)
  403. X          (*menu_notify)(menu, MENU_NOTIFY);
  404. X       if (item_notify)
  405. X          (*item_notify)(item, MENU_NOTIFY);
  406. X       if (item_notify)
  407. X          (*item_notify)(item, MENU_NOTIFY_DONE);
  408. X       if (menu_notify)
  409. X          (*menu_notify)(menu, MENU_NOTIFY_DONE);
  410. X    }
  411. }
  412. SHAR_EOF
  413. chmod 0644 pinned_menu_notify.c ||
  414. echo 'restore of pinned_menu_notify.c failed'
  415. Wc_c="`wc -c < 'pinned_menu_notify.c'`"
  416. test 2118 -eq "$Wc_c" ||
  417.     echo 'pinned_menu_notify.c: original size 2118, current size' "$Wc_c"
  418. rm -f _shar_wnt_.tmp
  419. fi
  420. # ============= place_dialog.c ==============
  421. if test -f 'place_dialog.c' -a X"$1" != X"-c"; then
  422.     echo 'x - skipping place_dialog.c (File already exists)'
  423.     rm -f _shar_wnt_.tmp
  424. else
  425. > _shar_wnt_.tmp
  426. echo 'x - extracting place_dialog.c (Text)'
  427. sed 's/^X//' << 'SHAR_EOF' > 'place_dialog.c' &&
  428. /************************************************************************/
  429. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  430. /*                                    */
  431. /*    Full ownership of this software, and all rights pertaining to     */
  432. /*    the for-profit distribution of this software, are retained by     */
  433. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  434. /*    use this software without fee.  This software is provided "as     */
  435. /*    is" without express or implied warranty.  You may redistribute     */
  436. /*    this software, provided that this copyright notice is retained,    */
  437. /*    and that the software is not distributed for profit.  If you     */
  438. /*    wish to use this software in a profit-making venture, you must     */
  439. /*    first license this code and its underlying technology from     */
  440. /*    Harris Corporation.                         */
  441. /*                                    */
  442. /*    Bottom line: you can have this software, you can use it, you     */
  443. /*    can give it away.  You just can't sell any or all parts of it     */
  444. /*    without prior permission from Harris Corporation.         */
  445. /************************************************************************/
  446. X
  447. /************************************************************************/
  448. /*                                    */
  449. /*    place_dialog.c    position a dialog box at the right place    */
  450. /*                                    */
  451. /************************************************************************/
  452. X
  453. #include    <stdio.h>
  454. #include    <sys/param.h>
  455. #include    <sys/types.h>
  456. #include    <xview/xview.h>
  457. #include    <X11/Xutil.h>
  458. X
  459. #include    "manifest.h"
  460. X
  461. /************************************************************************/
  462. EXPORT    void    place_dialog(base, dialog)
  463. X
  464. XXv_opaque    base;
  465. XXv_opaque    dialog;
  466. X
  467. {    Rect        br, dr, sr;
  468. X    XWMHints    *hints;
  469. X
  470. X    sr = *((Rect *) xv_get(base, WIN_SCREEN_RECT));
  471. X    frame_get_rect(base, &br);
  472. X    frame_get_rect(dialog, &dr);
  473. X    if (rect_right(&br) + dr.r_width < sr.r_width) {
  474. X       dr.r_left = rect_right(&br);
  475. X       dr.r_top = br.r_top;
  476. X       }
  477. X    else if (dr.r_width <= br.r_left) {
  478. X       dr.r_left = br.r_left - dr.r_width;
  479. X       dr.r_top = br.r_top;
  480. X       }
  481. X    else {
  482. X       dr.r_left = br.r_left + 32;
  483. X       dr.r_top = br.r_top + 32;
  484. X       }
  485. X    if (dr.r_top + dr.r_height > sr.r_height)
  486. X       dr.r_top = sr.r_height - dr.r_height;
  487. X    if (dr.r_top < 0)
  488. X       dr.r_top = 0;
  489. X    if (rect_right(&dr) > sr.r_width)
  490. X       dr.r_left = sr.r_width - dr.r_width;
  491. X    if (dr.r_left < 0)
  492. X       dr.r_left = 0;
  493. X    frame_set_rect(dialog, &dr);
  494. X
  495. X    hints = XGetWMHints(xv_get(dialog, XV_DISPLAY), xv_get(dialog, XV_XID));
  496. X    hints->flags |= StateHint;
  497. X    hints->initial_state = NormalState;
  498. X    XSetWMHints(xv_get(dialog, XV_DISPLAY), xv_get(dialog, XV_XID), hints);
  499. X    XFree(hints);
  500. }
  501. X
  502. SHAR_EOF
  503. chmod 0644 place_dialog.c ||
  504. echo 'restore of place_dialog.c failed'
  505. Wc_c="`wc -c < 'place_dialog.c'`"
  506. test 2563 -eq "$Wc_c" ||
  507.     echo 'place_dialog.c: original size 2563, current size' "$Wc_c"
  508. rm -f _shar_wnt_.tmp
  509. fi
  510. # ============= props.c ==============
  511. if test -f 'props.c' -a X"$1" != X"-c"; then
  512.     echo 'x - skipping props.c (File already exists)'
  513.     rm -f _shar_wnt_.tmp
  514. else
  515. > _shar_wnt_.tmp
  516. echo 'x - extracting props.c (Text)'
  517. sed 's/^X//' << 'SHAR_EOF' > 'props.c' &&
  518. /************************************************************************/
  519. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  520. /*                                    */
  521. /*    Full ownership of this software, and all rights pertaining to     */
  522. /*    the for-profit distribution of this software, are retained by     */
  523. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  524. /*    use this software without fee.  This software is provided "as     */
  525. /*    is" without express or implied warranty.  You may redistribute     */
  526. /*    this software, provided that this copyright notice is retained,    */
  527. /*    and that the software is not distributed for profit.  If you     */
  528. /*    wish to use this software in a profit-making venture, you must     */
  529. /*    first license this code and its underlying technology from     */
  530. /*    Harris Corporation.                         */
  531. /*                                    */
  532. /*    Bottom line: you can have this software, you can use it, you     */
  533. /*    can give it away.  You just can't sell any or all parts of it     */
  534. /*    without prior permission from Harris Corporation.         */
  535. /************************************************************************/
  536. X
  537. /************************************************************************/
  538. /*                                    */
  539. /*    props.c        contool properties dialog manager        */
  540. /*                                    */
  541. /************************************************************************/
  542. X
  543. #include    <stdio.h>
  544. #include    <sys/param.h>
  545. #include    <sys/types.h>
  546. #include    <xview/xview.h>
  547. #include    <xview/panel.h>
  548. #include    <xview/rect.h>
  549. #include    <xview/screen.h>
  550. X
  551. #include    "manifest.h"
  552. #include    "contool.h"
  553. #include    "contool_ui.h"
  554. X
  555. EXPORT    Props    defaults = {3,            /* beeps             */
  556. X                TRUE,        /* flash the icon         */
  557. X                TRUE,        /* write the message to the log     */
  558. X                FALSE,        /* don't pop the window         */
  559. X                TRUE,        /* timestamp the message     */
  560. X                NULL,        /* no command to run         */
  561. X                NULL,        /* default good icon         */
  562. X                NULL,        /* default bad icon         */
  563. X                NULL,        /* default flash icon         */
  564. X                "lpr",        /* default print filter         */
  565. X                NULL,        /* no log file             */
  566. X                TRUE,        /* log after filtering         */
  567. X                ARCHIVE_MANUALLY,    /* archive only at user request  */
  568. X                60,            /* timestamp every 60 seconds     */
  569. X                32768,        /* save 32K of messages         */
  570. X                1024        /* remove 1K when we get full     */
  571. X               };
  572. X
  573. PRIVATE    contool_props_objects    *contool_props = NULL;
  574. X
  575. /************************************************************************/
  576. PRIVATE    init_props(ip)
  577. X
  578. contool_props_objects    *ip;
  579. X
  580. {    int    val;
  581. X
  582. X    val = 0;
  583. X    if (defaults.beep > 0)
  584. X       val |= BEEP_BIT;
  585. X    if (defaults.command != NULL)
  586. X       val |= COMMAND_BIT;
  587. X    if (defaults.flash)
  588. X       val |= FLASH_BIT;
  589. X    if (defaults.log)
  590. X       val |= LOG_BIT;
  591. X    if (defaults.open)
  592. X       val |= OPEN_BIT;
  593. X    if (defaults.stamp > 0)
  594. X       val |= STAMP_BIT;
  595. X    xv_set(ip->default_action,     PANEL_VALUE,    val,                       NULL);
  596. X    xv_set(ip->default_beep_count, PANEL_VALUE,    defaults.beep,
  597. X                       PANEL_INACTIVE, defaults.beep == 0,        NULL);
  598. X    xv_set(ip->default_beep_times, PANEL_INACTIVE, defaults.beep == 0,        NULL);
  599. X    xv_set(ip->default_command,    PANEL_VALUE,    is_null(defaults.command),
  600. X                       PANEL_INACTIVE, defaults.command == NULL,  NULL);
  601. X    xv_set(ip->log_file,           PANEL_VALUE,    defaults.log_file,         NULL);
  602. X    xv_set(ip->log_style,          PANEL_VALUE,    defaults.log_after,        NULL);
  603. X    xv_set(ip->archive_style,      PANEL_VALUE,    defaults.archive_style,    NULL);
  604. X    xv_set(ip->good_icon,          PANEL_VALUE,    defaults.good_icon,        NULL);
  605. X    xv_set(ip->bad_icon,           PANEL_VALUE,    defaults.bad_icon,         NULL);
  606. X    xv_set(ip->flash_icon,         PANEL_VALUE,    defaults.flash_icon,       NULL);
  607. X    xv_set(ip->print_filter,       PANEL_VALUE,    defaults.print_filter,     NULL);
  608. X    xv_set(ip->max_message,        PANEL_VALUE,    defaults.max_size,         NULL);
  609. X    xv_set(ip->stamp_resolution,   PANEL_VALUE,    defaults.stamp_resolution, NULL);
  610. X    xv_set(ip->delete_amount,      PANEL_VALUE,    defaults.delete_amount,    NULL);
  611. }
  612. X
  613. /************************************************************************/
  614. EXPORT    Menu_item    edit_properties(item, op)
  615. X
  616. Menu_item    item;
  617. Menu_generate    op;
  618. X
  619. {    contool_base_objects    *ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  620. X
  621. X    if (op == MENU_NOTIFY) {
  622. X       xv_set(ip->base, FRAME_BUSY, TRUE, NULL);
  623. X       if (contool_props == NULL) {
  624. X          contool_props = contool_props_objects_initialize(NULL, ip->base);
  625. X          xv_set(contool_props->log_file,
  626. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  627. X                      PANEL_NOTIFY_STRING, "\n\r\t ",
  628. X                   NULL);
  629. X          xv_set(contool_props->good_icon,
  630. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  631. X                      PANEL_NOTIFY_STRING, "\n\r\t ",
  632. X                   NULL);
  633. X          xv_set(contool_props->bad_icon,
  634. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  635. X                      PANEL_NOTIFY_STRING, "\n\r\t ",
  636. X                   NULL);
  637. X          xv_set(contool_props->flash_icon,
  638. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  639. X                      PANEL_NOTIFY_STRING, "\n\r\t ",
  640. X                   NULL);
  641. X          place_dialog(ip->base, contool_props->props);
  642. X          }
  643. X       init_props(contool_props);
  644. X       xv_set(contool_props->props, XV_SHOW, TRUE, NULL);
  645. X       xv_set(ip->base, FRAME_BUSY, FALSE, NULL);
  646. X       }
  647. X    return item;
  648. }
  649. X
  650. /************************************************************************/
  651. EXPORT    void    default_action(item, value, event)
  652. X
  653. Panel_item    item;
  654. unsigned int    value;
  655. Event        *event;
  656. X
  657. {    contool_props_objects    *ip = (contool_props_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  658. X    
  659. X    xv_set(ip->default_beep_count, PANEL_INACTIVE, !(value & BEEP_BIT), NULL);
  660. X    xv_set(ip->default_beep_times, PANEL_INACTIVE, !(value & BEEP_BIT), NULL);
  661. X    xv_set(ip->default_command,    PANEL_INACTIVE, !(value & COMMAND_BIT), NULL);
  662. }
  663. X
  664. /************************************************************************/
  665. EXPORT    void    accept_properties(item, event)
  666. X
  667. Panel_item    item;
  668. Event        *event;
  669. X
  670. {    contool_props_objects    *ip = (contool_props_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  671. X    Props    new;
  672. X    int    val;
  673. X    Server_image    icon = NULL, load_icon();
  674. X    char    msg[1024];
  675. X
  676. X    val = (int) xv_get(ip->default_action, PANEL_VALUE);
  677. X
  678. X    if (val & BEEP_BIT)
  679. X       new.beep = (int) xv_get(ip->default_beep_count, PANEL_VALUE);
  680. X    else
  681. X       new.beep = 0;
  682. X
  683. X    if (val & COMMAND_BIT) {
  684. X       new.command = (char *) xv_get(ip->default_command, PANEL_VALUE);
  685. X       if (is_empty(new.command)) {
  686. X          error("You must specify a command to be executed");
  687. X          xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  688. X          return;
  689. X          }
  690. X       }
  691. X    else
  692. X       new.command = NULL;
  693. X
  694. X    new.flash            = (val & FLASH_BIT)? TRUE : FALSE;
  695. X    new.log              = (val & LOG_BIT)? TRUE : FALSE;
  696. X    new.open             = (val & OPEN_BIT)? TRUE : FALSE;
  697. X    new.stamp            = (val & STAMP_BIT)? TRUE : FALSE;
  698. X    new.log_file         = (char *) xv_get(ip->log_file,         PANEL_VALUE);
  699. X    new.log_after        = (int)    xv_get(ip->log_style,        PANEL_VALUE);
  700. X    new.archive_style    = (int)    xv_get(ip->archive_style,    PANEL_VALUE);
  701. X    new.good_icon        = (char *) xv_get(ip->good_icon,        PANEL_VALUE);
  702. X    new.bad_icon         = (char *) xv_get(ip->bad_icon,         PANEL_VALUE);
  703. X    new.flash_icon       = (char *) xv_get(ip->flash_icon,       PANEL_VALUE);
  704. X    new.print_filter     = (char *) xv_get(ip->print_filter,     PANEL_VALUE);
  705. X    new.max_size         = (int)    xv_get(ip->max_message,      PANEL_VALUE);
  706. X    new.stamp_resolution = (int)    xv_get(ip->stamp_resolution, PANEL_VALUE);
  707. X    new.delete_amount    = (int)    xv_get(ip->delete_amount,    PANEL_VALUE);
  708. X
  709. X    new.good_icon = is_empty(new.good_icon)? NULL : expand_tilde(new.good_icon);
  710. X    new.bad_icon = is_empty(new.bad_icon)? NULL : expand_tilde(new.bad_icon);
  711. X    new.flash_icon = is_empty(new.flash_icon)? NULL : expand_tilde(new.flash_icon);
  712. X
  713. X    if (new.good_icon && (icon = load_icon(new.good_icon, msg)) == NULL) {
  714. X       error("Invalid \"All is well\" icon: %s", msg);
  715. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  716. X       return;
  717. X       }
  718. X    if (icon)
  719. X       xv_destroy(icon);
  720. X    if (new.bad_icon && (icon = load_icon(new.bad_icon, msg)) == NULL) {
  721. X       error("Invalid \"Check console\" icon: %s", msg);
  722. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  723. X       return;
  724. X       }
  725. X    if (icon)
  726. X       xv_destroy(icon);
  727. X    if (new.flash_icon && (icon = load_icon(new.flash_icon, msg)) == NULL) {
  728. X       error("Invalid \"Flash\" icon: %s", msg);
  729. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  730. X       return;
  731. X       }
  732. X    if (icon)
  733. X       xv_destroy(icon);
  734. X
  735. X    new.log_file = is_empty(new.log_file)? NULL : expand_tilde(new.log_file);
  736. X    new.print_filter = strsave(new.print_filter);
  737. X    new.command = strsave(new.command);
  738. X    defaults = new;
  739. X
  740. X    adjust_window_limit();
  741. X    update_icons();
  742. X    update_logging();
  743. }
  744. X
  745. /************************************************************************/
  746. EXPORT    void    reset_properties(item, event)
  747. X
  748. Panel_item    item;
  749. Event        *event;
  750. X
  751. {    contool_props_objects    *ip = (contool_props_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  752. X    
  753. X    init_props(ip);
  754. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  755. }
  756. SHAR_EOF
  757. chmod 0644 props.c ||
  758. echo 'restore of props.c failed'
  759. Wc_c="`wc -c < 'props.c'`"
  760. test 9038 -eq "$Wc_c" ||
  761.     echo 'props.c: original size 9038, current size' "$Wc_c"
  762. rm -f _shar_wnt_.tmp
  763. fi
  764. # ============= regexp.c ==============
  765. if test -f 'regexp.c' -a X"$1" != X"-c"; then
  766.     echo 'x - skipping regexp.c (File already exists)'
  767.     rm -f _shar_wnt_.tmp
  768. else
  769. > _shar_wnt_.tmp
  770. echo 'x - extracting regexp.c (Text)'
  771. sed 's/^X//' << 'SHAR_EOF' > 'regexp.c' &&
  772. /************************************************************************/
  773. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  774. /*                                    */
  775. /*    Full ownership of this software, and all rights pertaining to     */
  776. /*    the for-profit distribution of this software, are retained by     */
  777. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  778. /*    use this software without fee.  This software is provided "as     */
  779. /*    is" without express or implied warranty.  You may redistribute     */
  780. /*    this software, provided that this copyright notice is retained,    */
  781. /*    and that the software is not distributed for profit.  If you     */
  782. /*    wish to use this software in a profit-making venture, you must     */
  783. /*    first license this code and its underlying technology from     */
  784. /*    Harris Corporation.                         */
  785. /*                                    */
  786. /*    Bottom line: you can have this software, you can use it, you     */
  787. /*    can give it away.  You just can't sell any or all parts of it     */
  788. /*    without prior permission from Harris Corporation.         */
  789. /************************************************************************/
  790. X
  791. #include    <stdio.h>
  792. X
  793. #include    "manifest.h"
  794. #include    "contool.h"
  795. X
  796. PRIVATE    regexp_error();
  797. X
  798. #define        INIT            register char *expbuf = ep, *sp = instring;
  799. #define        GETC()            (*sp++)
  800. #define        PEEKC()            (*sp)
  801. #define        UNGETC(c)        (--sp)
  802. #define        RETURN(p)        {bcopy(expbuf, sp = (char *) malloc(p - expbuf), p - expbuf); return(sp);}
  803. #define        ERROR(val)        {regexp_error(val, instring); return(NULL);}
  804. X
  805. #include    <regexp.h>
  806. X
  807. PRIVATE    char    error_message[512];
  808. X
  809. /************************************************************************/
  810. EXPORT    int    match_exp(exp, circ, str)
  811. X
  812. char    *exp;
  813. int    circ;
  814. char    *str;
  815. X
  816. {    char    *p;
  817. X    int    result;
  818. X
  819. X    p = str + strlen(str) - 1;
  820. X    if (p >= str && *p == '\n')
  821. X       *p = '\0';
  822. X    circf = circ;
  823. X    result = step(str, exp);
  824. X    if (p >= str && *p == '\0')
  825. X       *p = '\n';
  826. X    return(result);
  827. }
  828. X
  829. /************************************************************************/
  830. PRIVATE    regexp_error(val, string)
  831. X
  832. int    val;
  833. char    *string;
  834. X
  835. {    char    *msg;
  836. X
  837. X    switch (val) {
  838. X       case 11 : msg = "range endpoint too large";
  839. X       case 16 : msg = "bad number";
  840. X       case 25 : msg = "\"\\digit\" out of range";
  841. X       case 36 : msg = "illegal or missing delimiter";
  842. X       case 41 : msg = "no remembered search string";
  843. X       case 42 : msg = "\\(\\) imbalance";
  844. X       case 43 : msg = "too many \\(";
  845. X       case 44 : msg = "more than 2 numbers given in \\{\\}";
  846. X       case 45 : msg = "} expected after \\";
  847. X       case 46 : msg = "first number exceeds second in \\{\\}";
  848. X       case 49 : msg = "[] imbalance";
  849. X       case 50 : msg = "regular expression overflow";
  850. X       default : msg = "regular expression error";
  851. X       }
  852. X    sprintf(error_message, "%s in %s", msg, string);
  853. }
  854. X
  855. /************************************************************************/
  856. PRIVATE    char    *fix_control_chars(s)
  857. X
  858. char    *s;
  859. X
  860. {    static    char    buf[2048];
  861. X    char    *p;
  862. X
  863. X    for (p = buf; *s; s++, p++)
  864. X       if (*s == '\\' && *(s + 1) >= '0' && *(s + 1) <= '7') {
  865. X          for (*p = 0, s++; *s && *s >= '0' && *s <= '7'; s++)
  866. X             *p = (*p << 3) + *s - '0';
  867. X          s--;
  868. X          }
  869. X       else
  870. X          *p = *s;
  871. X    *p = '\0';
  872. X    return(buf);
  873. }
  874. X
  875. /************************************************************************/
  876. EXPORT    char    *compile_exp(filter, start, stop)
  877. X
  878. Filter    *filter;
  879. char    *start;
  880. char    *stop;
  881. X
  882. {    char    rbuf[1024], *sre, *ere;
  883. X    int    sc, ec;
  884. X
  885. X    sre = ere = NULL;
  886. X    if (start) {
  887. X       if ((sre = compile(fix_control_chars(start), rbuf, rbuf+1024, '\0')) == NULL)
  888. X          return(error_message);
  889. X       sc = circf;
  890. X       }
  891. X    if (stop) {
  892. X       if ((ere = compile(fix_control_chars(stop), rbuf, rbuf+1024, '\0')) == NULL) {
  893. X          cond_free(sre);
  894. X          return(error_message);
  895. X          }
  896. X       ec = circf;
  897. X       }
  898. X    if (filter) {
  899. X       filter->start = start;
  900. X       filter->stop = stop;
  901. X       filter->start_re = sre;
  902. X       filter->stop_re = ere;
  903. X       filter->start_circf = sc;
  904. X       filter->stop_circf = ec;
  905. X       }
  906. X    else {
  907. X       cond_free(sre);
  908. X       if (ere)
  909. X          cond_free(ere);
  910. X       }
  911. X    return(NULL);
  912. }
  913. SHAR_EOF
  914. chmod 0644 regexp.c ||
  915. echo 'restore of regexp.c failed'
  916. Wc_c="`wc -c < 'regexp.c'`"
  917. test 3963 -eq "$Wc_c" ||
  918.     echo 'regexp.c: original size 3963, current size' "$Wc_c"
  919. rm -f _shar_wnt_.tmp
  920. fi
  921. # ============= send_mail.c ==============
  922. if test -f 'send_mail.c' -a X"$1" != X"-c"; then
  923.     echo 'x - skipping send_mail.c (File already exists)'
  924.     rm -f _shar_wnt_.tmp
  925. else
  926. > _shar_wnt_.tmp
  927. echo 'x - extracting send_mail.c (Text)'
  928. sed 's/^X//' << 'SHAR_EOF' > 'send_mail.c' &&
  929. /************************************************************************/
  930. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  931. /*                                    */
  932. /*    Full ownership of this software, and all rights pertaining to     */
  933. /*    the for-profit distribution of this software, are retained by     */
  934. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  935. /*    use this software without fee.  This software is provided "as     */
  936. /*    is" without express or implied warranty.  You may redistribute     */
  937. /*    this software, provided that this copyright notice is retained,    */
  938. /*    and that the software is not distributed for profit.  If you     */
  939. /*    wish to use this software in a profit-making venture, you must     */
  940. /*    first license this code and its underlying technology from     */
  941. /*    Harris Corporation.                         */
  942. /*                                    */
  943. /*    Bottom line: you can have this software, you can use it, you     */
  944. /*    can give it away.  You just can't sell any or all parts of it     */
  945. /*    without prior permission from Harris Corporation.         */
  946. /************************************************************************/
  947. X
  948. /************************************************************************/
  949. /*                                    */
  950. /*    send_mail.c    display a little information window        */
  951. /*                                    */
  952. /************************************************************************/
  953. X
  954. #include    <stdio.h>
  955. #include    <sys/param.h>
  956. #include    <sys/types.h>
  957. #include    <xview/xview.h>
  958. #include    <xview/panel.h>
  959. #include    <xview/textsw.h>
  960. #include    "contool_ui.h"
  961. X
  962. #include    "manifest.h"
  963. X
  964. #define        VERSION            "3.2a"
  965. X
  966. PUBLIC    contool_base_objects    *contool_base;
  967. X
  968. PRIVATE    contool_mail_objects    *dialog = NULL;
  969. X
  970. /************************************************************************/
  971. EXPORT    popup_send_mail(item, event)
  972. X
  973. Panel_item    item;
  974. Event        *event;
  975. X
  976. {
  977. X    if (dialog == NULL) {
  978. X       dialog = contool_mail_objects_initialize(NULL, contool_base->base);
  979. X       place_dialog(contool_base->base, dialog->mail);
  980. X       xv_set(dialog->other_address, WIN_SHOW, FALSE, NULL);
  981. X       }
  982. X    xv_set(dialog->mail, XV_SHOW, TRUE, NULL);
  983. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
  984. }
  985. X
  986. /************************************************************************/
  987. EXPORT    Menu    handle_address(menu, op)
  988. X
  989. Menu_item    menu;
  990. Menu_generate    op;
  991. X
  992. {    char    *addr;
  993. X
  994. X    if (op == MENU_NOTIFY) {
  995. X       addr = (char *) xv_get(menu, MENU_STRING);
  996. X       xv_set(dialog->other_address, WIN_SHOW, strcmp(addr, "Other:") == 0, NULL);
  997. X       xv_set(dialog->fixed_address, PANEL_LABEL_STRING, addr, NULL);
  998. X       panel_paint(dialog->other_address, PANEL_CLEAR);
  999. X       panel_paint(dialog->fixed_address, PANEL_CLEAR);
  1000. X       }
  1001. X    xv_set(menu, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  1002. X    xv_set(xv_get(menu, MENU_PARENT), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  1003. X    return(menu);
  1004. }
  1005. X
  1006. /************************************************************************/
  1007. EXPORT    void    done_mail(frame)
  1008. X
  1009. Frame        frame;
  1010. X
  1011. {
  1012. X    textsw_reset(dialog->message, 0, 0);
  1013. X    xv_set(frame, XV_SHOW, FALSE, 0);
  1014. }
  1015. X
  1016. /************************************************************************/
  1017. EXPORT    void    send_mail(item, event)
  1018. X
  1019. Panel_item    item;
  1020. Event        *event;
  1021. X
  1022. {    char    cmd[1024], *buf;
  1023. X    int    val, size;
  1024. X    FILE    *pipe;
  1025. X
  1026. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, 0);
  1027. X    buf = (char *) xv_get(dialog->fixed_address, PANEL_LABEL_STRING);
  1028. X    if (strcmp(buf, "Other:") != 0)
  1029. X       sprintf(cmd, "%s %s", MAILER, buf);
  1030. X    else {
  1031. X       buf = (char *) xv_get(dialog->other_address, PANEL_VALUE);
  1032. X       if (is_empty(buf)) {
  1033. X          error("You must specify an alternate address before sending your message");
  1034. X          return;
  1035. X          }
  1036. X       else
  1037. X          sprintf(cmd, "%s %s", MAILER, buf);
  1038. X       }
  1039. X    size = (int) xv_get(dialog->message, TEXTSW_LENGTH);
  1040. X    if (size == 0) {
  1041. X       error("Please type a message before sending the mail");
  1042. X       return;
  1043. X       }
  1044. X    if ((pipe = popen(cmd, "w")) == NULL) {
  1045. X       error("Could not invoke \"%s\" to send mail", cmd);
  1046. X       return;
  1047. X       }
  1048. X    lets_get_busy(contool_base->base, TRUE, NULL);
  1049. X    buf = (char *) malloc(size);
  1050. X    xv_get(dialog->message, TEXTSW_CONTENTS, 0, buf, size);
  1051. X    fprintf(pipe, "Subject: Contool %s comment\n\n", VERSION);
  1052. X    if (fwrite(buf, 1, size, pipe) != size) {
  1053. X       error("Could not write message to the mailer");
  1054. X       free(buf);
  1055. X       return;
  1056. X       }
  1057. X    pclose(pipe);
  1058. X    free(buf);
  1059. X    textsw_reset(dialog->message, 0, 0);
  1060. X    lets_get_busy(contool_base->base, FALSE, NULL);
  1061. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
  1062. }
  1063. SHAR_EOF
  1064. chmod 0644 send_mail.c ||
  1065. echo 'restore of send_mail.c failed'
  1066. Wc_c="`wc -c < 'send_mail.c'`"
  1067. test 4316 -eq "$Wc_c" ||
  1068.     echo 'send_mail.c: original size 4316, current size' "$Wc_c"
  1069. rm -f _shar_wnt_.tmp
  1070. fi
  1071. # ============= store.c ==============
  1072. if test -f 'store.c' -a X"$1" != X"-c"; then
  1073.     echo 'x - skipping store.c (File already exists)'
  1074.     rm -f _shar_wnt_.tmp
  1075. else
  1076. > _shar_wnt_.tmp
  1077. echo 'x - extracting store.c (Text)'
  1078. sed 's/^X//' << 'SHAR_EOF' > 'store.c' &&
  1079. /************************************************************************/
  1080. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  1081. /*                                    */
  1082. /*    Full ownership of this software, and all rights pertaining to     */
  1083. /*    the for-profit distribution of this software, are retained by     */
  1084. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1085. /*    use this software without fee.  This software is provided "as     */
  1086. /*    is" without express or implied warranty.  You may redistribute     */
  1087. /*    this software, provided that this copyright notice is retained,    */
  1088. /*    and that the software is not distributed for profit.  If you     */
  1089. /*    wish to use this software in a profit-making venture, you must     */
  1090. /*    first license this code and its underlying technology from     */
  1091. /*    Harris Corporation.                         */
  1092. /*                                    */
  1093. /*    Bottom line: you can have this software, you can use it, you     */
  1094. /*    can give it away.  You just can't sell any or all parts of it     */
  1095. /*    without prior permission from Harris Corporation.         */
  1096. /************************************************************************/
  1097. X
  1098. /************************************************************************/
  1099. /*                                    */
  1100. /*    store.c        contool store dialog manager            */
  1101. /*                                    */
  1102. /************************************************************************/
  1103. X
  1104. #include    <stdio.h>
  1105. #include    <ctype.h>
  1106. #include    <sys/param.h>
  1107. #include    <sys/types.h>
  1108. #include    <sys/file.h>
  1109. #include    <xview/xview.h>
  1110. #include    <xview/panel.h>
  1111. #include    <xview/notice.h>
  1112. #include    <xview/xv_xrect.h>
  1113. X
  1114. #include    "manifest.h"
  1115. #include    "contool.h"
  1116. #include    "contool_ui.h"
  1117. X
  1118. #define        yes_no(x)        ((x)? "yes" : "no")
  1119. X
  1120. #define        FILTER_VERSION        320
  1121. X
  1122. PUBLIC    contool_base_objects    *contool_base;
  1123. X
  1124. PRIVATE    contool_store_objects    *contool_store = NULL;
  1125. X
  1126. /************************************************************************/
  1127. EXPORT    Menu_item    popup_save_config(item, op)
  1128. X
  1129. Menu_item    item;
  1130. Menu_generate    op;
  1131. X
  1132. {    contool_base_objects * ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1133. X
  1134. X    if (op == MENU_NOTIFY) {
  1135. X       if (contool_store == NULL) {
  1136. X          contool_store = contool_store_objects_initialize(NULL, ip->base);
  1137. X          xv_set(contool_store->store_file,
  1138. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  1139. X                      PANEL_NOTIFY_STRING, "\n\r ",
  1140. X                   NULL);
  1141. X          xv_set(contool_store->store_type, PANEL_VALUE, 3, NULL);
  1142. X          place_dialog(ip->base, contool_store->store);
  1143. X          }
  1144. X       xv_set(contool_store->store_file, PANEL_VALUE, filter_file, NULL);
  1145. X       xv_set(contool_store->store, XV_SHOW, TRUE, NULL);
  1146. X       }
  1147. X    return item;
  1148. }
  1149. X
  1150. /************************************************************************/
  1151. EXPORT    int    store_filters_to_file(path, save_filters, save_props)
  1152. X
  1153. char        *path;
  1154. int        save_filters;
  1155. int        save_props;
  1156. X
  1157. {    char    buf[1024];
  1158. X    int    answer;
  1159. X    FILE    *f;
  1160. X    Filter    *filt;
  1161. X
  1162. X    if (access(path, W_OK) == 0) {
  1163. X       sprintf(buf, "File \"%s\" exists.  You can:", path);
  1164. X       answer = notice_prompt(contool_base->base, NULL,
  1165. X                        NOTICE_MESSAGE_STRINGS, buf, NULL,
  1166. X                        NOTICE_BUTTON_YES, "Overwrite",
  1167. X                        NOTICE_BUTTON_NO, "Cancel",
  1168. X                     NULL);
  1169. X       if (answer == 0)
  1170. X          return(FALSE);
  1171. X       }
  1172. X    if ((f = fopen(path, "w")) == NULL) {
  1173. X       error("Cannot write to %s: %s", path, sys_errlist[errno]);
  1174. X       return(FALSE);
  1175. X       }
  1176. X    fprintf(f, "version %d\n", FILTER_VERSION);
  1177. X    if (save_props) {
  1178. X       fprintf(f, "defaults {\n");
  1179. X       fprintf(f, "   beep                 %d\n", defaults.beep);
  1180. X       fprintf(f, "   command              \"%s\"\n", check_escapes(is_null(defaults.command)));
  1181. X       fprintf(f, "   flash                %s\n", yes_no(defaults.flash));
  1182. X       fprintf(f, "   log                  %s\n", yes_no(defaults.log));
  1183. X       fprintf(f, "   open                 %s\n", yes_no(defaults.open));
  1184. X       fprintf(f, "   stamp                %s\n", yes_no(defaults.stamp));
  1185. X       fprintf(f, "   archive              %d\n", defaults.archive_style);
  1186. X       fprintf(f, "   good_icon            \"%s\"\n", is_null(defaults.good_icon));
  1187. X       fprintf(f, "   check_icon           \"%s\"\n", is_null(defaults.bad_icon));
  1188. X       fprintf(f, "   flash_icon           \"%s\"\n", is_null(defaults.flash_icon));
  1189. X       fprintf(f, "   print                \"%s\"\n", defaults.print_filter);
  1190. X       fprintf(f, "   log_file             \"%s\"\n", is_null(defaults.log_file));
  1191. X       fprintf(f, "   log_before_filtering %s\n", yes_no(!defaults.log_after));
  1192. X       fprintf(f, "   timestamp            %d\n", defaults.stamp_resolution);
  1193. X       fprintf(f, "   display              %d\n", defaults.max_size);
  1194. X       fprintf(f, "   delete               %d\n", defaults.delete_amount);
  1195. X       fprintf(f, "}\n");
  1196. X       }
  1197. X    if (save_filters) {
  1198. X       fprintf(f, "filters {\n");
  1199. X       for (filt = filters; filt; filt = filt->next) {
  1200. X          fprintf(f, "   {\n");
  1201. X          fprintf(f, "      match   \"%s\"\n", check_escapes(filt->start));
  1202. X          if (filt->stop) {
  1203. X             fprintf(f, "      to      \"%s\"\n", check_escapes(filt->stop));
  1204. X             fprintf(f, "      timeout %d\n", filt->timeout);
  1205. X             }
  1206. X          if (filt->comment)
  1207. X             fprintf(f, "      comment \"%s\"\n", check_escapes(filt->comment));
  1208. X          if (filt->save) {
  1209. X             fprintf(f, "      ignore  no\n");
  1210. X             fprintf(f, "      beep    %d\n", filt->beep);
  1211. X             fprintf(f, "      command \"%s\"\n", check_escapes(is_null(filt->command)));
  1212. X             fprintf(f, "      flash   %s\n", yes_no(filt->flash));
  1213. X             fprintf(f, "      log     %s\n", yes_no(filt->log));
  1214. X             fprintf(f, "      open    %s\n", yes_no(filt->open));
  1215. X             fprintf(f, "      stamp   %s\n", yes_no(filt->stamp));
  1216. X             }
  1217. X          else
  1218. X             fprintf(f, "      ignore  yes\n");
  1219. X          fprintf(f, "   }\n");
  1220. X          }
  1221. X       fprintf(f, "}\n");
  1222. X       }
  1223. X    fclose(f);
  1224. X    return(TRUE);
  1225. }
  1226. X
  1227. /************************************************************************/
  1228. EXPORT    void    store_filters(item, event)
  1229. X
  1230. Panel_item    item;
  1231. Event        *event;
  1232. X
  1233. {    contool_store_objects    *ip = (contool_store_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1234. X    char    *path;
  1235. X    int    kind;
  1236. X
  1237. X    path = expand_tilde(xv_get(ip->store_file, PANEL_VALUE));
  1238. X    kind = (int) xv_get(ip->store_type, PANEL_VALUE);
  1239. X    if (store_filters_to_file(path, kind & 2, kind & 1)) {
  1240. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, NULL);
  1241. X       filter_file = path;
  1242. X       }
  1243. X    else {
  1244. X       free(path);
  1245. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1246. X       }
  1247. }
  1248. SHAR_EOF
  1249. chmod 0644 store.c ||
  1250. echo 'restore of store.c failed'
  1251. Wc_c="`wc -c < 'store.c'`"
  1252. test 6340 -eq "$Wc_c" ||
  1253.     echo 'store.c: original size 6340, current size' "$Wc_c"
  1254. rm -f _shar_wnt_.tmp
  1255. fi
  1256. # ============= contool.h ==============
  1257. if test -f 'contool.h' -a X"$1" != X"-c"; then
  1258.     echo 'x - skipping contool.h (File already exists)'
  1259.     rm -f _shar_wnt_.tmp
  1260. else
  1261. > _shar_wnt_.tmp
  1262. echo 'x - extracting contool.h (Text)'
  1263. sed 's/^X//' << 'SHAR_EOF' > 'contool.h' &&
  1264. /************************************************************************/
  1265. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  1266. /*                                    */
  1267. /*    Full ownership of this software, and all rights pertaining to     */
  1268. /*    the for-profit distribution of this software, are retained by     */
  1269. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1270. /*    use this software without fee.  This software is provided "as     */
  1271. /*    is" without express or implied warranty.  You may redistribute     */
  1272. /*    this software, provided that this copyright notice is retained,    */
  1273. /*    and that the software is not distributed for profit.  If you     */
  1274. /*    wish to use this software in a profit-making venture, you must     */
  1275. /*    first license this code and its underlying technology from     */
  1276. /*    Harris Corporation.                         */
  1277. /*                                    */
  1278. /*    Bottom line: you can have this software, you can use it, you     */
  1279. /*    can give it away.  You just can't sell any or all parts of it     */
  1280. /*    without prior permission from Harris Corporation.         */
  1281. /************************************************************************/
  1282. X
  1283. /************************************************************************/
  1284. /*                                    */
  1285. /*    contool.h    internal contool data structures        */
  1286. /*                                    */
  1287. /************************************************************************/
  1288. X
  1289. #define        is_null(x)        ((x)? x : "")
  1290. X
  1291. #define        BEEP_BIT        0x01
  1292. #define        COMMAND_BIT        0x02
  1293. #define        FLASH_BIT        0x04
  1294. #define        LOG_BIT            0x08
  1295. #define        OPEN_BIT        0x10
  1296. #define        STAMP_BIT        0x20
  1297. X
  1298. #define        ARCHIVE_MANUALLY    0
  1299. #define        ARCHIVE_ON_CLOSE    1
  1300. X
  1301. typedef    struct    filter    Filter;
  1302. typedef    struct    props    Props;
  1303. X
  1304. struct    filter    {char    *start;
  1305. X         char    *start_re;
  1306. X         int    start_circf;
  1307. X         char    *stop;
  1308. X         char    *stop_re;
  1309. X         int    stop_circf;
  1310. X         char    *comment;
  1311. X         int    save;
  1312. X         int    beep;
  1313. X         int    flash;
  1314. X         int    log;
  1315. X         int    open;
  1316. X         int    stamp;
  1317. X         int    timeout;
  1318. X         char    *command;
  1319. X         Filter    *next;
  1320. X        };
  1321. X
  1322. struct    props    {int    beep;
  1323. X         int    flash;
  1324. X         int    log;
  1325. X         int    open;
  1326. X         int    stamp;
  1327. X         char    *command;
  1328. X         char    *good_icon;
  1329. X         char    *bad_icon;
  1330. X         char    *flash_icon;
  1331. X         char    *print_filter;
  1332. X         char    *log_file;
  1333. X         int    log_after;
  1334. X         int    archive_style;
  1335. X         int    stamp_resolution;
  1336. X         int    max_size;
  1337. X         int    delete_amount;
  1338. X        };
  1339. X
  1340. PUBLIC    char    *compile_exp();
  1341. PUBLIC    char    *expand_tilde();
  1342. X
  1343. PUBLIC    Props    defaults;
  1344. PUBLIC    Props    *parsed_defaults;
  1345. PUBLIC    Filter    *parsed_filters;
  1346. PUBLIC    Filter    *filters;
  1347. PUBLIC    int    parse_errors_occured;
  1348. PUBLIC    char    *filter_file;
  1349. PUBLIC    int    filter_version;
  1350. SHAR_EOF
  1351. chmod 0644 contool.h ||
  1352. echo 'restore of contool.h failed'
  1353. Wc_c="`wc -c < 'contool.h'`"
  1354. test 2457 -eq "$Wc_c" ||
  1355.     echo 'contool.h: original size 2457, current size' "$Wc_c"
  1356. rm -f _shar_wnt_.tmp
  1357. fi
  1358. # ============= contool_ui.h ==============
  1359. if test -f 'contool_ui.h' -a X"$1" != X"-c"; then
  1360.     echo 'x - skipping contool_ui.h (File already exists)'
  1361.     rm -f _shar_wnt_.tmp
  1362. else
  1363. > _shar_wnt_.tmp
  1364. echo 'x - extracting contool_ui.h (Text)'
  1365. sed 's/^X//' << 'SHAR_EOF' > 'contool_ui.h' &&
  1366. #ifndef    contool_HEADER
  1367. #define    contool_HEADER
  1368. X
  1369. /*
  1370. X * contool_ui.h - User interface object and function declarations.
  1371. X * This file was generated by `gxv' from `contool.G'.
  1372. X * DO NOT EDIT BY HAND.
  1373. X */
  1374. X
  1375. extern Attr_attribute    INSTANCE;
  1376. X
  1377. extern Xv_opaque    contool_file_menu_create();
  1378. extern Xv_opaque    contool_view_menu_create();
  1379. extern Xv_opaque    contool_edit_menu_create();
  1380. extern Xv_opaque    contool_filter_insert_menu_create();
  1381. extern Xv_opaque    contool_filter_paste_menu_create();
  1382. extern Xv_opaque    contool_filter_edit_menu_create();
  1383. extern Xv_opaque    contool_address_menu_create();
  1384. X
  1385. typedef struct {
  1386. X    Xv_opaque    base;
  1387. X    Xv_opaque    contool_controls;
  1388. X    Xv_opaque    file;
  1389. X    Xv_opaque    view;
  1390. X    Xv_opaque    edit;
  1391. X    Xv_opaque    display;
  1392. } contool_base_objects;
  1393. X
  1394. extern contool_base_objects    *contool_base_objects_initialize();
  1395. X
  1396. extern Xv_opaque    contool_base_base_create();
  1397. extern Xv_opaque    contool_base_contool_controls_create();
  1398. extern Xv_opaque    contool_base_file_create();
  1399. extern Xv_opaque    contool_base_view_create();
  1400. extern Xv_opaque    contool_base_edit_create();
  1401. extern Xv_opaque    contool_base_display_create();
  1402. X
  1403. typedef struct {
  1404. X    Xv_opaque    props;
  1405. X    Xv_opaque    prop_controls;
  1406. X    Xv_opaque    default_action;
  1407. X    Xv_opaque    default_beep_count;
  1408. X    Xv_opaque    default_beep_times;
  1409. X    Xv_opaque    default_command;
  1410. X    Xv_opaque    log_file;
  1411. X    Xv_opaque    log_style;
  1412. X    Xv_opaque    archive_style;
  1413. X    Xv_opaque    print_filter;
  1414. X    Xv_opaque    good_icon;
  1415. X    Xv_opaque    bad_icon;
  1416. X    Xv_opaque    flash_icon;
  1417. X    Xv_opaque    stamp_resolution;
  1418. X    Xv_opaque    message2;
  1419. X    Xv_opaque    max_message;
  1420. X    Xv_opaque    message3;
  1421. X    Xv_opaque    delete_amount;
  1422. X    Xv_opaque    message4;
  1423. X    Xv_opaque    props_apply;
  1424. X    Xv_opaque    props_reset;
  1425. } contool_props_objects;
  1426. X
  1427. extern contool_props_objects    *contool_props_objects_initialize();
  1428. X
  1429. extern Xv_opaque    contool_props_props_create();
  1430. extern Xv_opaque    contool_props_prop_controls_create();
  1431. extern Xv_opaque    contool_props_default_action_create();
  1432. extern Xv_opaque    contool_props_default_beep_count_create();
  1433. extern Xv_opaque    contool_props_default_beep_times_create();
  1434. extern Xv_opaque    contool_props_default_command_create();
  1435. SHAR_EOF
  1436. true || echo 'restore of contool_ui.h failed'
  1437. fi
  1438. echo 'End of  part 5'
  1439. echo 'File contool_ui.h is continued in part 6'
  1440. echo 6 > _shar_seq_.tmp
  1441. exit 0
  1442. -- 
  1443. --
  1444. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1445. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1446. Sunnyvale, California 94086            at&t: 408/522-9236
  1447.