home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / x / volume16 / contool-3.2 / part04 < prev    next >
Encoding:
Text File  |  1992-03-05  |  55.1 KB  |  1,777 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!news
  3. From: chuck@trantor.harris-atd.com (Chuck Musciano)
  4. Subject: v16i089: Contool 3.2, Part04/05
  5. Message-ID: <1992Mar5.190333.2611@msi.com>
  6. Originator: news@sun4
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-16i086-contool-3.2@uunet.UU.NET>
  10. Date: Thu, 5 Mar 1992 19:03:33 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: chuck@trantor.harris-atd.com (Chuck Musciano)
  14. Posting-number: Volume 16, Issue 89
  15. Archive-name: contool-3.2/part04
  16.  
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  21. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  22. # If this archive is complete, you will see the following message at the end:
  23. #        "End of archive 4 (of 5)."
  24. # Contents:  archive.c contool_ui.h load.c misc.c parse.y props.c
  25. #   send_mail.c store.c
  26. # Wrapped by dcmartin@fascet on Sat Feb 22 10:11:10 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'archive.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'archive.c'\"
  30. else
  31. echo shar: Extracting \"'archive.c'\" \(5379 characters\)
  32. sed "s/^X//" >'archive.c' <<'END_OF_FILE'
  33. X/************************************************************************/
  34. X/*    Copyright 1987-1991 by Chuck Musciano and Harris Corporation     */
  35. X/*                                    */
  36. X/*    Full ownership of this software, and all rights pertaining to     */
  37. X/*    the for-profit distribution of this software, are retained by     */
  38. X/*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  39. X/*    use this software without fee.  This software is provided "as     */
  40. X/*    is" without express or implied warranty.  You may redistribute     */
  41. X/*    this software, provided that this copyright notice is retained,    */
  42. X/*    and that the software is not distributed for profit.  If you     */
  43. X/*    wish to use this software in a profit-making venture, you must     */
  44. X/*    first license this code and its underlying technology from     */
  45. X/*    Harris Corporation.                         */
  46. X/*                                    */
  47. X/*    Bottom line: you can have this software, you can use it, you     */
  48. X/*    can give it away.  You just can't sell any or all parts of it     */
  49. X/*    without prior permission from Harris Corporation.         */
  50. X/************************************************************************/
  51. X
  52. X/************************************************************************/
  53. X/*                                    */
  54. X/*    archive.c    contool message archive manager            */
  55. X/*                                    */
  56. X/************************************************************************/
  57. X
  58. X#include    <stdio.h>
  59. X#include    <sys/param.h>
  60. X#include    <sys/types.h>
  61. X#include    <xview/xview.h>
  62. X#include    <xview/panel.h>
  63. X#include    <xview/textsw.h>
  64. X
  65. X#include    "manifest.h"
  66. X#include    "contool.h"
  67. X#include    "contool_ui.h"
  68. X
  69. XPUBLIC    contool_base_objects    *contool_base;
  70. X
  71. XPRIVATE    contool_message_archive_objects    *dialog = NULL;
  72. X
  73. X/************************************************************************/
  74. XPRIVATE    void    stamp_archive(s)
  75. X
  76. Xchar    *s;
  77. X
  78. X{    int    t;
  79. X    char    msg[128];
  80. X
  81. X    t = time(0);
  82. X    sprintf(msg, "%s %.25s", s, ctime(&t));
  83. X    xv_set(dialog->message_archive, FRAME_LEFT_FOOTER, msg, NULL);
  84. X}
  85. X
  86. X/************************************************************************/
  87. XEXPORT    void    reset_archive_size()
  88. X
  89. X{    int    sw_len;
  90. X    char    *temp;
  91. X
  92. X    if (dialog) {
  93. X       sw_len = (int) xv_get(dialog->archive, TEXTSW_LENGTH);
  94. X       temp = (char *) malloc((unsigned) sw_len);
  95. X       xv_get(dialog->archive, TEXTSW_CONTENTS, 0, temp, sw_len);
  96. X       xv_set(dialog->archive, TEXTSW_MEMORY_MAXIMUM, defaults.max_size * 11, NULL);
  97. X       textsw_reset(dialog->archive, 0, 0);
  98. X       if (sw_len > defaults.max_size * 10)
  99. X          textsw_insert(dialog->archive, temp + sw_len - defaults.max_size * 10, defaults.max_size * 10);
  100. X       else
  101. X          textsw_insert(dialog->archive, temp, sw_len);
  102. X       free(temp);
  103. X       }
  104. X}
  105. X
  106. X/************************************************************************/
  107. XEXPORT    void    create_archive()
  108. X
  109. X{
  110. X    if (dialog == NULL) {
  111. X       dialog = contool_message_archive_objects_initialize(NULL, contool_base->base);
  112. X       place_dialog(contool_base->base, dialog->message_archive);
  113. X       reset_archive_size();
  114. X       }
  115. X}
  116. X
  117. X/************************************************************************/
  118. XEXPORT    Menu_item    popup_archive(item, op)
  119. X
  120. XMenu_item    item;
  121. XMenu_generate    op;
  122. X
  123. X{
  124. X    if (op == MENU_NOTIFY) {
  125. X       create_archive();
  126. X       xv_set(dialog->message_archive, XV_SHOW, TRUE, NULL);
  127. X       }
  128. X    return(item);
  129. X}
  130. X
  131. X/************************************************************************/
  132. XEXPORT    void    clear_archive()
  133. X
  134. X{
  135. X    textsw_reset(dialog->archive, 0, 0);
  136. X    stamp_archive("Archive cleared");
  137. X}
  138. X
  139. X/************************************************************************/
  140. XEXPORT    void    print_archive()
  141. X
  142. X{    int    size;
  143. X    char    *buf;
  144. X    FILE    *cmd;
  145. X
  146. X    if (is_empty(defaults.print_filter))
  147. X       error("You must specify a printer command in the Properties dialog");
  148. X    else if ((cmd = popen(defaults.print_filter, "w")) == NULL)
  149. X       error("Could not execute %s", defaults.print_filter);
  150. X    else {
  151. X       lets_get_busy(contool_base->base, TRUE, NULL);
  152. X       size = (int) xv_get(dialog->archive, TEXTSW_LENGTH);
  153. X       buf = (char *) malloc(size);
  154. X       xv_get(dialog->archive, TEXTSW_CONTENTS, 0, buf, size);
  155. X       if (fwrite(buf, 1, size, cmd) != size)
  156. X          error("Could not write console contents to printer");
  157. X       pclose(cmd);
  158. X       free(buf);
  159. X       lets_get_busy(contool_base->base, FALSE, NULL);
  160. X       }
  161. X}
  162. X
  163. X/************************************************************************/
  164. XEXPORT    void    archive_messages()
  165. X
  166. X{    int    size, first, last, sw_len;
  167. X    char    *temp, *buf;
  168. X
  169. X    create_archive();
  170. X    size = (int) xv_get(contool_base->display, TEXTSW_LENGTH);
  171. X    buf = (char *) malloc(size);
  172. X    xv_get(contool_base->display, TEXTSW_CONTENTS, 0, buf, size);
  173. X    while ((int) xv_get(dialog->archive, TEXTSW_LENGTH) + size > defaults.max_size * 10) {
  174. X       sw_len = (int) xv_get(dialog->archive, TEXTSW_LENGTH);
  175. X       first = 1;
  176. X       last = TEXTSW_INFINITY;
  177. X       if (textsw_find_bytes(dialog->archive, &first, &last, "\n<<<", 4, 0) == -1 || first == 0)
  178. X          if (textsw_find_bytes(dialog->archive, &first, &last, "\n", 1, 0) == -1 || first == 0)
  179. X             first = (defaults.delete_amount < sw_len)? defaults.delete_amount : sw_len;
  180. X       temp = (char *) malloc((unsigned) sw_len);
  181. X       xv_get(dialog->archive, TEXTSW_CONTENTS, 0, temp, sw_len);
  182. X       textsw_reset(dialog->archive, 0, 0);
  183. X       textsw_insert(dialog->archive, temp + first, sw_len - first);
  184. X       free(temp);
  185. X       }
  186. X    xv_set(dialog->archive, TEXTSW_INSERTION_POINT, TEXTSW_INFINITY, NULL);
  187. X    textsw_insert(dialog->archive, buf, size);
  188. X    free(buf);
  189. X    stamp_archive("Messages last archived");
  190. X    textsw_reset(contool_base->display, 0, 0);
  191. X}
  192. END_OF_FILE
  193. if test 5379 -ne `wc -c <'archive.c'`; then
  194.     echo shar: \"'archive.c'\" unpacked with wrong size!
  195. fi
  196. # end of 'archive.c'
  197. fi
  198. if test -f 'contool_ui.h' -a "${1}" != "-c" ; then 
  199.   echo shar: Will not clobber existing file \"'contool_ui.h'\"
  200. else
  201. echo shar: Extracting \"'contool_ui.h'\" \(8425 characters\)
  202. sed "s/^X//" >'contool_ui.h' <<'END_OF_FILE'
  203. X#ifndef    contool_HEADER
  204. X#define    contool_HEADER
  205. X
  206. X/*
  207. X * contool_ui.h - User interface object and function declarations.
  208. X * This file was generated by `gxv' from `contool.G'.
  209. X * DO NOT EDIT BY HAND.
  210. X */
  211. X
  212. Xextern Attr_attribute    INSTANCE;
  213. X
  214. Xextern Xv_opaque    contool_file_menu_create();
  215. Xextern Xv_opaque    contool_view_menu_create();
  216. Xextern Xv_opaque    contool_edit_menu_create();
  217. Xextern Xv_opaque    contool_filter_insert_menu_create();
  218. Xextern Xv_opaque    contool_filter_paste_menu_create();
  219. Xextern Xv_opaque    contool_filter_edit_menu_create();
  220. Xextern Xv_opaque    contool_address_menu_create();
  221. X
  222. Xtypedef struct {
  223. X    Xv_opaque    base;
  224. X    Xv_opaque    contool_controls;
  225. X    Xv_opaque    file;
  226. X    Xv_opaque    view;
  227. X    Xv_opaque    edit;
  228. X    Xv_opaque    display;
  229. X} contool_base_objects;
  230. X
  231. Xextern contool_base_objects    *contool_base_objects_initialize();
  232. X
  233. Xextern Xv_opaque    contool_base_base_create();
  234. Xextern Xv_opaque    contool_base_contool_controls_create();
  235. Xextern Xv_opaque    contool_base_file_create();
  236. Xextern Xv_opaque    contool_base_view_create();
  237. Xextern Xv_opaque    contool_base_edit_create();
  238. Xextern Xv_opaque    contool_base_display_create();
  239. X
  240. Xtypedef struct {
  241. X    Xv_opaque    props;
  242. X    Xv_opaque    prop_controls;
  243. X    Xv_opaque    default_action;
  244. X    Xv_opaque    default_beep_count;
  245. X    Xv_opaque    default_beep_times;
  246. X    Xv_opaque    default_command;
  247. X    Xv_opaque    log_file;
  248. X    Xv_opaque    log_style;
  249. X    Xv_opaque    archive_style;
  250. X    Xv_opaque    print_filter;
  251. X    Xv_opaque    good_icon;
  252. X    Xv_opaque    bad_icon;
  253. X    Xv_opaque    flash_icon;
  254. X    Xv_opaque    stamp_resolution;
  255. X    Xv_opaque    message2;
  256. X    Xv_opaque    max_message;
  257. X    Xv_opaque    message3;
  258. X    Xv_opaque    delete_amount;
  259. X    Xv_opaque    message4;
  260. X    Xv_opaque    props_apply;
  261. X    Xv_opaque    props_reset;
  262. X} contool_props_objects;
  263. X
  264. Xextern contool_props_objects    *contool_props_objects_initialize();
  265. X
  266. Xextern Xv_opaque    contool_props_props_create();
  267. Xextern Xv_opaque    contool_props_prop_controls_create();
  268. Xextern Xv_opaque    contool_props_default_action_create();
  269. Xextern Xv_opaque    contool_props_default_beep_count_create();
  270. Xextern Xv_opaque    contool_props_default_beep_times_create();
  271. Xextern Xv_opaque    contool_props_default_command_create();
  272. Xextern Xv_opaque    contool_props_log_file_create();
  273. Xextern Xv_opaque    contool_props_log_style_create();
  274. Xextern Xv_opaque    contool_props_archive_style_create();
  275. Xextern Xv_opaque    contool_props_print_filter_create();
  276. Xextern Xv_opaque    contool_props_good_icon_create();
  277. Xextern Xv_opaque    contool_props_bad_icon_create();
  278. Xextern Xv_opaque    contool_props_flash_icon_create();
  279. Xextern Xv_opaque    contool_props_stamp_resolution_create();
  280. Xextern Xv_opaque    contool_props_message2_create();
  281. Xextern Xv_opaque    contool_props_max_message_create();
  282. Xextern Xv_opaque    contool_props_message3_create();
  283. Xextern Xv_opaque    contool_props_delete_amount_create();
  284. Xextern Xv_opaque    contool_props_message4_create();
  285. Xextern Xv_opaque    contool_props_props_apply_create();
  286. Xextern Xv_opaque    contool_props_props_reset_create();
  287. X
  288. Xtypedef struct {
  289. X    Xv_opaque    filters;
  290. X    Xv_opaque    filter_controls;
  291. X    Xv_opaque    filter_list;
  292. X    Xv_opaque    filter_insert;
  293. X    Xv_opaque    filter_edit;
  294. X    Xv_opaque    filter_update;
  295. X    Xv_opaque    filter_type;
  296. X    Xv_opaque    start;
  297. X    Xv_opaque    stop;
  298. X    Xv_opaque    filter_timeout;
  299. X    Xv_opaque    filter_timeout_units;
  300. X    Xv_opaque    comment;
  301. X    Xv_opaque    ignore;
  302. X    Xv_opaque    action;
  303. X    Xv_opaque    filter_beep_count;
  304. X    Xv_opaque    filter_beep_times;
  305. X    Xv_opaque    filter_command;
  306. X    Xv_opaque    filters_apply;
  307. X    Xv_opaque    filters_apply_and_save;
  308. X    Xv_opaque    filters_reset;
  309. X} contool_filters_objects;
  310. X
  311. Xextern contool_filters_objects    *contool_filters_objects_initialize();
  312. X
  313. Xextern Xv_opaque    contool_filters_filters_create();
  314. Xextern Xv_opaque    contool_filters_filter_controls_create();
  315. Xextern Xv_opaque    contool_filters_filter_list_create();
  316. Xextern Xv_opaque    contool_filters_filter_insert_create();
  317. Xextern Xv_opaque    contool_filters_filter_edit_create();
  318. Xextern Xv_opaque    contool_filters_filter_update_create();
  319. Xextern Xv_opaque    contool_filters_filter_type_create();
  320. Xextern Xv_opaque    contool_filters_start_create();
  321. Xextern Xv_opaque    contool_filters_stop_create();
  322. Xextern Xv_opaque    contool_filters_filter_timeout_create();
  323. Xextern Xv_opaque    contool_filters_filter_timeout_units_create();
  324. Xextern Xv_opaque    contool_filters_comment_create();
  325. Xextern Xv_opaque    contool_filters_ignore_create();
  326. Xextern Xv_opaque    contool_filters_action_create();
  327. Xextern Xv_opaque    contool_filters_filter_beep_count_create();
  328. Xextern Xv_opaque    contool_filters_filter_beep_times_create();
  329. Xextern Xv_opaque    contool_filters_filter_command_create();
  330. Xextern Xv_opaque    contool_filters_filters_apply_create();
  331. Xextern Xv_opaque    contool_filters_filters_apply_and_save_create();
  332. Xextern Xv_opaque    contool_filters_filters_reset_create();
  333. X
  334. Xtypedef struct {
  335. X    Xv_opaque    load;
  336. X    Xv_opaque    load_controls;
  337. X    Xv_opaque    load_type;
  338. X    Xv_opaque    load_file;
  339. X    Xv_opaque    accept_load;
  340. X} contool_load_objects;
  341. X
  342. Xextern contool_load_objects    *contool_load_objects_initialize();
  343. X
  344. Xextern Xv_opaque    contool_load_load_create();
  345. Xextern Xv_opaque    contool_load_load_controls_create();
  346. Xextern Xv_opaque    contool_load_load_type_create();
  347. Xextern Xv_opaque    contool_load_load_file_create();
  348. Xextern Xv_opaque    contool_load_accept_load_create();
  349. X
  350. Xtypedef struct {
  351. X    Xv_opaque    store;
  352. X    Xv_opaque    store_controls;
  353. X    Xv_opaque    store_type;
  354. X    Xv_opaque    store_file;
  355. X    Xv_opaque    accept_store;
  356. X} contool_store_objects;
  357. X
  358. Xextern contool_store_objects    *contool_store_objects_initialize();
  359. X
  360. Xextern Xv_opaque    contool_store_store_create();
  361. Xextern Xv_opaque    contool_store_store_controls_create();
  362. Xextern Xv_opaque    contool_store_store_type_create();
  363. Xextern Xv_opaque    contool_store_store_file_create();
  364. Xextern Xv_opaque    contool_store_accept_store_create();
  365. X
  366. Xtypedef struct {
  367. X    Xv_opaque    about;
  368. X    Xv_opaque    about_controls;
  369. X    Xv_opaque    message1;
  370. X    Xv_opaque    message5;
  371. X    Xv_opaque    message6;
  372. X    Xv_opaque    message7;
  373. X    Xv_opaque    message8;
  374. X    Xv_opaque    message9;
  375. X    Xv_opaque    message10;
  376. X    Xv_opaque    message11;
  377. X    Xv_opaque    message12;
  378. X    Xv_opaque    message13;
  379. X    Xv_opaque    message14;
  380. X    Xv_opaque    message16;
  381. X    Xv_opaque    message17;
  382. X    Xv_opaque    message18;
  383. X    Xv_opaque    message19;
  384. X    Xv_opaque    message20;
  385. X    Xv_opaque    send_mail;
  386. X} contool_about_objects;
  387. X
  388. Xextern contool_about_objects    *contool_about_objects_initialize();
  389. X
  390. Xextern Xv_opaque    contool_about_about_create();
  391. Xextern Xv_opaque    contool_about_about_controls_create();
  392. Xextern Xv_opaque    contool_about_message1_create();
  393. Xextern Xv_opaque    contool_about_message5_create();
  394. Xextern Xv_opaque    contool_about_message6_create();
  395. Xextern Xv_opaque    contool_about_message7_create();
  396. Xextern Xv_opaque    contool_about_message8_create();
  397. Xextern Xv_opaque    contool_about_message9_create();
  398. Xextern Xv_opaque    contool_about_message10_create();
  399. Xextern Xv_opaque    contool_about_message11_create();
  400. Xextern Xv_opaque    contool_about_message12_create();
  401. Xextern Xv_opaque    contool_about_message13_create();
  402. Xextern Xv_opaque    contool_about_message14_create();
  403. Xextern Xv_opaque    contool_about_message16_create();
  404. Xextern Xv_opaque    contool_about_message17_create();
  405. Xextern Xv_opaque    contool_about_message18_create();
  406. Xextern Xv_opaque    contool_about_message19_create();
  407. Xextern Xv_opaque    contool_about_message20_create();
  408. Xextern Xv_opaque    contool_about_send_mail_create();
  409. X
  410. Xtypedef struct {
  411. X    Xv_opaque    mail;
  412. X    Xv_opaque    mail_controls;
  413. X    Xv_opaque    message21;
  414. X    Xv_opaque    message22;
  415. X    Xv_opaque    address;
  416. X    Xv_opaque    fixed_address;
  417. X    Xv_opaque    other_address;
  418. X    Xv_opaque    message;
  419. X    Xv_opaque    mail_controls1;
  420. X    Xv_opaque    accept_send;
  421. X} contool_mail_objects;
  422. X
  423. Xextern contool_mail_objects    *contool_mail_objects_initialize();
  424. X
  425. Xextern Xv_opaque    contool_mail_mail_create();
  426. Xextern Xv_opaque    contool_mail_mail_controls_create();
  427. Xextern Xv_opaque    contool_mail_message21_create();
  428. Xextern Xv_opaque    contool_mail_message22_create();
  429. Xextern Xv_opaque    contool_mail_address_create();
  430. Xextern Xv_opaque    contool_mail_fixed_address_create();
  431. Xextern Xv_opaque    contool_mail_other_address_create();
  432. Xextern Xv_opaque    contool_mail_message_create();
  433. Xextern Xv_opaque    contool_mail_mail_controls1_create();
  434. Xextern Xv_opaque    contool_mail_accept_send_create();
  435. X
  436. Xtypedef struct {
  437. X    Xv_opaque    message_archive;
  438. X    Xv_opaque    archive_controls;
  439. X    Xv_opaque    clear;
  440. X    Xv_opaque    print;
  441. X    Xv_opaque    archive;
  442. X} contool_message_archive_objects;
  443. X
  444. Xextern contool_message_archive_objects    *contool_message_archive_objects_initialize();
  445. X
  446. Xextern Xv_opaque    contool_message_archive_message_archive_create();
  447. Xextern Xv_opaque    contool_message_archive_archive_controls_create();
  448. Xextern Xv_opaque    contool_message_archive_clear_create();
  449. Xextern Xv_opaque    contool_message_archive_print_create();
  450. Xextern Xv_opaque    contool_message_archive_archive_create();
  451. X#endif
  452. END_OF_FILE
  453. if test 8425 -ne `wc -c <'contool_ui.h'`; then
  454.     echo shar: \"'contool_ui.h'\" unpacked with wrong size!
  455. fi
  456. # end of 'contool_ui.h'
  457. fi
  458. if test -f 'load.c' -a "${1}" != "-c" ; then 
  459.   echo shar: Will not clobber existing file \"'load.c'\"
  460. else
  461. echo shar: Extracting \"'load.c'\" \(3392 characters\)
  462. sed "s/^X//" >'load.c' <<'END_OF_FILE'
  463. X/************************************************************************/
  464. X/*    Copyright 1987-1991 by Chuck Musciano and Harris Corporation     */
  465. X/*                                    */
  466. X/*    Full ownership of this software, and all rights pertaining to     */
  467. X/*    the for-profit distribution of this software, are retained by     */
  468. X/*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  469. X/*    use this software without fee.  This software is provided "as     */
  470. X/*    is" without express or implied warranty.  You may redistribute     */
  471. X/*    this software, provided that this copyright notice is retained,    */
  472. X/*    and that the software is not distributed for profit.  If you     */
  473. X/*    wish to use this software in a profit-making venture, you must     */
  474. X/*    first license this code and its underlying technology from     */
  475. X/*    Harris Corporation.                         */
  476. X/*                                    */
  477. X/*    Bottom line: you can have this software, you can use it, you     */
  478. X/*    can give it away.  You just can't sell any or all parts of it     */
  479. X/*    without prior permission from Harris Corporation.         */
  480. X/************************************************************************/
  481. X
  482. X/************************************************************************/
  483. X/*                                    */
  484. X/*    load.c        contool load dialog manager            */
  485. X/*                                    */
  486. X/************************************************************************/
  487. X
  488. X#include    <stdio.h>
  489. X#include    <sys/param.h>
  490. X#include    <sys/types.h>
  491. X#include    <xview/xview.h>
  492. X#include    <xview/panel.h>
  493. X#include    <xview/xv_xrect.h>
  494. X
  495. X#include    "manifest.h"
  496. X#include    "contool.h"
  497. X#include    "contool_ui.h"
  498. X
  499. XPRIVATE    contool_load_objects    *contool_load = NULL;
  500. X
  501. X/************************************************************************/
  502. XEXPORT    Menu_item    popup_load_config(item, op)
  503. X
  504. XMenu_item    item;
  505. XMenu_generate    op;
  506. X
  507. X{    contool_base_objects * ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  508. X
  509. X    if (op == MENU_NOTIFY) {
  510. X       if (contool_load == NULL) {
  511. X          contool_load = contool_load_objects_initialize(NULL, ip->base);
  512. X          xv_set(contool_load->load_file,
  513. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  514. X                      PANEL_NOTIFY_STRING, "\n\r ",
  515. X                   NULL);
  516. X          xv_set(contool_load->load_type, PANEL_VALUE, 3, NULL);
  517. X          place_dialog(ip->base, contool_load->load);
  518. X          }
  519. X       xv_set(contool_load->load_file, PANEL_VALUE, filter_file, NULL);
  520. X       xv_set(contool_load->load, XV_SHOW, TRUE, NULL);
  521. X       }
  522. X    return item;
  523. X}
  524. X
  525. X/************************************************************************/
  526. XEXPORT    void    load_filters(item, event)
  527. X
  528. XPanel_item    item;
  529. XEvent        *event;
  530. X
  531. X{    contool_load_objects    *ip = (contool_load_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  532. X    int    kind;
  533. X    char    *path;
  534. X
  535. X    path = expand_tilde(xv_get(ip->load_file, PANEL_VALUE));
  536. X    if (lex_init(path)) {
  537. X       yyparse();
  538. X       if (parse_errors_occured) {
  539. X          error("Error in configuration file.  Configuration not loaded");
  540. X          xv_set(ip->accept_load, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  541. X          }
  542. X       else {
  543. X          kind = (int) xv_get(ip->load_type, PANEL_VALUE);
  544. X          if (kind & 1 && parsed_defaults) {
  545. X             defaults = *parsed_defaults;
  546. X             adjust_window_limit();
  547. X             }
  548. X          if (kind & 2)
  549. X             filters = parsed_filters;
  550. X          free(parsed_defaults);
  551. X          filter_file = path;
  552. X          }
  553. X       }
  554. X    else {
  555. X       error("Unable to read configuration file");
  556. X       xv_set(ip->accept_load, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  557. X       free(path);
  558. X       }
  559. X}
  560. END_OF_FILE
  561. if test 3392 -ne `wc -c <'load.c'`; then
  562.     echo shar: \"'load.c'\" unpacked with wrong size!
  563. fi
  564. # end of 'load.c'
  565. fi
  566. if test -f 'misc.c' -a "${1}" != "-c" ; then 
  567.   echo shar: Will not clobber existing file \"'misc.c'\"
  568. else
  569. echo shar: Extracting \"'misc.c'\" \(5391 characters\)
  570. sed "s/^X//" >'misc.c' <<'END_OF_FILE'
  571. X/************************************************************************/
  572. X/*    Copyright 1987-1991 by Chuck Musciano and Harris Corporation     */
  573. X/*                                    */
  574. X/*    Full ownership of this software, and all rights pertaining to     */
  575. X/*    the for-profit distribution of this software, are retained by     */
  576. X/*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  577. X/*    use this software without fee.  This software is provided "as     */
  578. X/*    is" without express or implied warranty.  You may redistribute     */
  579. X/*    this software, provided that this copyright notice is retained,    */
  580. X/*    and that the software is not distributed for profit.  If you     */
  581. X/*    wish to use this software in a profit-making venture, you must     */
  582. X/*    first license this code and its underlying technology from     */
  583. X/*    Harris Corporation.                         */
  584. X/*                                    */
  585. X/*    Bottom line: you can have this software, you can use it, you     */
  586. X/*    can give it away.  You just can't sell any or all parts of it     */
  587. X/*    without prior permission from Harris Corporation.         */
  588. X/************************************************************************/
  589. X
  590. X#include    <stdio.h>
  591. X#include    <ctype.h>
  592. X#include    <pwd.h>
  593. X
  594. X#include    "manifest.h"
  595. X#include    "contool.h"
  596. X
  597. XPUBLIC    char    *index();
  598. X
  599. X/************************************************************************/
  600. XEXPORT    int    getline(stream, string, max)
  601. X
  602. XFILE    *stream;
  603. Xchar    *string;
  604. Xint    max;
  605. X
  606. X{    register    int    i, j;
  607. X
  608. X    i = (int) fgets(string, max, stream);
  609. X    if (i == NULL)
  610. X       return(EOF);
  611. X    j = strlen(string);
  612. X    if (j > 0 && string[j - 1] == '\n')
  613. X       string[--j] = '\0';
  614. X    return(j);
  615. X}
  616. X
  617. X/************************************************************************/
  618. XEXPORT    int    verify(source, valid)
  619. X
  620. Xchar    *source;
  621. Xchar    *valid;
  622. X
  623. X{    register    char    *s;
  624. X
  625. X    for ( ; *source; source++) {
  626. X       for (s = valid; *s && *s != *source; s++)
  627. X          ;
  628. X       if (*s == '\0')
  629. X          return(0);
  630. X       }
  631. X    return(1);
  632. X}
  633. X
  634. X/************************************************************************/
  635. XEXPORT    char    **saveargs(argc, argv)
  636. X
  637. Xint    argc;
  638. Xchar    **argv;
  639. X
  640. X{    int    i;
  641. X    char    **copy;
  642. X
  643. X    copy = (char **) malloc((argc + 1) * sizeof(char *));
  644. X    for (i = 0; i < argc; i++)
  645. X       strcpy(copy[i] = (char *) malloc(strlen(argv[i]) + 1), argv[i]);
  646. X    copy[i] = (char *) 0;
  647. X    return(copy);
  648. X}
  649. X
  650. X#define        SIZE_INCREMENT        8
  651. X
  652. X/************************************************************************/
  653. XEXPORT    char    **tokenize(line, argc)
  654. X
  655. Xchar    *line;
  656. Xint    *argc;
  657. X
  658. X{    char    match, **argv, *buf, *p;
  659. X    int    limit;
  660. X
  661. X    buf = (char *) malloc(strlen(line) + 1);
  662. X    *argc = 0;
  663. X    argv = (char **) malloc((limit = SIZE_INCREMENT) * sizeof(char *));
  664. X    while (*line) {
  665. X       while (isspace(*line))
  666. X          line++;
  667. X       switch (*line) {
  668. X          case '"'  :
  669. X          case '\'' : match = *line++; /* remove the quote mark */
  670. X                    for (p = buf; *line && (*line != match); ) {
  671. X                       if (*line == '\\')
  672. X                          line++;
  673. X                       if (*line)
  674. X                          *p++ = *line++;
  675. X                       }
  676. X                    if (*line)
  677. X                       line++; /* wipe out quote mark */
  678. X                    break;
  679. X          default   : for (p = buf; *line && !isspace(*line) && (*line != '"') && (*line != '\''); )
  680. X                       *p++ = *line++;
  681. X                    break;
  682. X          }
  683. X       *p = '\0';
  684. X       if (*buf) {
  685. X          argv[(*argc)++] = strsave(buf);
  686. X          if (*argc == limit)
  687. X             argv = (char **) realloc(argv, (limit += SIZE_INCREMENT) * sizeof(char *));
  688. X          }
  689. X       }
  690. X    free(buf);
  691. X    argv[*argc] = (char *) 0;
  692. X    return(argv);
  693. X}
  694. X
  695. X#define        P_POS        5
  696. X#define        L_POS        8
  697. X#define        D_POS        9
  698. X
  699. X#define        PATH        "/dev/ptyp0"
  700. X#define        LETTERS        "pqr"
  701. X#define        DIGITS        "0123456789abcdef"
  702. X
  703. XPRIVATE    char    path[12];
  704. X
  705. X/************************************************************************/
  706. XEXPORT    char    *open_psuedo_tty(master, m_mode, slave, s_mode)
  707. X
  708. XFILE    **master;
  709. Xchar    *m_mode;
  710. XFILE    **slave;
  711. Xchar    *s_mode;
  712. X
  713. X{    char    *s, *t;
  714. X
  715. X    strcpy(path, PATH);
  716. X    for (s = LETTERS; *s && *master == NULL; s++) {
  717. X       path[L_POS] = *s;
  718. X       for (t = DIGITS; *t && *master == NULL; t++) {
  719. X          path[D_POS] = *t;
  720. X          *master = fopen(path, m_mode);
  721. X          }
  722. X       }
  723. X    if (*master != NULL) {
  724. X       path[P_POS] = 't';
  725. X       *slave = fopen(path, s_mode);
  726. X       path[P_POS] = 'p';
  727. X       }
  728. X    return(path);
  729. X}
  730. X
  731. X/************************************************************************/
  732. XEXPORT    char    *expand_tilde(path)
  733. X
  734. Xchar    *path;
  735. X
  736. X{    char    s[1024], *p;
  737. X    struct    passwd    *pw;
  738. X
  739. X    if (*path == '~') {
  740. X       if (path[1] == '/' || path[1] == '\0') {
  741. X          strcpy(s, getenv("HOME"));
  742. X          strcat(s, path + 1);
  743. X          }
  744. X       else {
  745. X          if ((p = index(path, '/')) != NULL)
  746. X             *p = '\0';
  747. X          if ((pw = getpwnam(path + 1)) != NULL) {
  748. X             strcpy(s, pw->pw_dir);
  749. X             if (p != NULL) {
  750. X                strcat(s, "/");
  751. X                strcat(s, p + 1);
  752. X                }
  753. X             }
  754. X          else {
  755. X             if (p != NULL)
  756. X                *p = '/';
  757. X             strcpy(s, path);
  758. X             }
  759. X          }
  760. X       return(strsave(s));
  761. X       }
  762. X    else
  763. X       return(strsave(path));
  764. X}
  765. X
  766. X/************************************************************************/
  767. XEXPORT    int    is_empty(s)
  768. X
  769. Xchar    *s;
  770. X
  771. X{
  772. X    if (s == NULL)
  773. X       return(TRUE);
  774. X    for (; *s; s++)
  775. X       if (!isspace(*s))
  776. X          return(FALSE); 
  777. X    return(TRUE);
  778. X}
  779. X
  780. X/************************************************************************/
  781. XEXPORT    char    *check_escapes(s)
  782. X
  783. Xchar    *s;
  784. X
  785. X{    static    char    buf[1024];
  786. X    char    *p;
  787. X
  788. X    for (p = buf; *s; s++, p++)
  789. X       if (*s == '"') {
  790. X          *p++ = '"';
  791. X          *p = *s;
  792. X          }
  793. X       else
  794. X          *p = *s;
  795. X    *p = '\0';
  796. X    return(buf);
  797. X}
  798. END_OF_FILE
  799. if test 5391 -ne `wc -c <'misc.c'`; then
  800.     echo shar: \"'misc.c'\" unpacked with wrong size!
  801. fi
  802. # end of 'misc.c'
  803. fi
  804. if test -f 'parse.y' -a "${1}" != "-c" ; then 
  805.   echo shar: Will not clobber existing file \"'parse.y'\"
  806. else
  807. echo shar: Extracting \"'parse.y'\" \(8184 characters\)
  808. sed "s/^X//" >'parse.y' <<'END_OF_FILE'
  809. X/************************************************************************/
  810. X/*    Copyright 1987-1991 by Chuck Musciano and Harris Corporation     */
  811. X/*                                    */
  812. X/*    Full ownership of this software, and all rights pertaining to     */
  813. X/*    the for-profit distribution of this software, are retained by     */
  814. X/*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  815. X/*    use this software without fee.  This software is provided "as     */
  816. X/*    is" without express or implied warranty.  You may redistribute     */
  817. X/*    this software, provided that this copyright notice is retained,    */
  818. X/*    and that the software is not distributed for profit.  If you     */
  819. X/*    wish to use this software in a profit-making venture, you must     */
  820. X/*    first license this code and its underlying technology from     */
  821. X/*    Harris Corporation.                         */
  822. X/*                                    */
  823. X/*    Bottom line: you can have this software, you can use it, you     */
  824. X/*    can give it away.  You just can't sell any or all parts of it     */
  825. X/*    without prior permission from Harris Corporation.         */
  826. X/************************************************************************/
  827. X
  828. X%{
  829. X
  830. X#include    <stdio.h>
  831. X#include    <ctype.h>
  832. X
  833. X#include    "manifest.h"
  834. X#include    "contool.h"
  835. X
  836. XEXPORT    Props    *parsed_defaults;
  837. XEXPORT    Filter    *parsed_filters;
  838. XEXPORT    int    filter_version = 0;
  839. X
  840. XEXPORT    int    parse_errors_occured;
  841. X
  842. XPRIVATE    char    *get_last_token();
  843. X
  844. XPRIVATE    Filter    *curr;
  845. XPRIVATE    char    *curr_file;
  846. XPRIVATE    int    line_count = 1;
  847. XPRIVATE    char    ungetc = -1;
  848. X
  849. X%}
  850. X
  851. X%start    configuration
  852. X
  853. X%union    {char    *cpval;
  854. X     int    ival;
  855. X     Filter    *fval;
  856. X     Props    *pval;
  857. X    }
  858. X
  859. X%token    <cpval>    STRING
  860. X%token    <ival>    INTEGER
  861. X
  862. X%token        LBRACE RBRACE
  863. X
  864. X%token        ARCHIVE BEEP CHECK_ICON COMMAND COMMENT DEFAULTS DELETE DISPLAY FILTERS
  865. X        FLASH FLASH_ICON GOOD_ICON IGNORE LOG LOG_BEFORE_FILTERING LOG_FILE
  866. X        MATCH NO NOFLASH NOOPEN NOSTAMP OPEN PRINT QUIET SAVE STAMP TIMEOUT
  867. X        TIMESTAMP TO VERSION YES
  868. X
  869. X%type    <ival>    beep flash log old_flash old_open old_stamp open stamp yes_no
  870. X%type    <cpval>    command old_end_string string
  871. X%type    <fval>    filter filter_list old_filter old_filter_list old_ignore old_quiet old_save
  872. X
  873. X%%
  874. X
  875. Xconfiguration    :    empty
  876. X        |    old_style
  877. X        |    new_style
  878. X        ;
  879. X
  880. Xold_style    :    old_filter_list
  881. X                    { parsed_defaults = NULL;
  882. X                      parsed_filters = $1;
  883. X                    }
  884. X        ;
  885. X
  886. Xold_filter_list    :    old_filter
  887. X                    { $$ = $1; }
  888. X        |    old_filter_list old_filter
  889. X                    { Filter    *f;
  890. X                    
  891. X                      for (f = $1; f->next; f = f->next)
  892. X                         ;
  893. X                      f->next = $2;
  894. X                      $$ = $1;
  895. X                    }
  896. X        ;
  897. X
  898. Xold_filter    :    old_save
  899. X        |    old_ignore
  900. X        |    old_quiet
  901. X        ;
  902. X
  903. Xold_save    :    SAVE beep old_flash old_open old_stamp STRING old_end_string
  904. X                    { Filter    *f;
  905. X                      char        *msg;
  906. X
  907. X                      f = (Filter *) malloc(sizeof(Filter));
  908. X                      f->save     = TRUE;
  909. X                      f->beep     = $2;
  910. X                      f->flash    = $3;
  911. X                      f->open     = $4;
  912. X                      f->stamp    = $5;
  913. X                      f->timeout  = 0;
  914. X                      f->log      = TRUE;
  915. X                      f->start    = $6;
  916. X                      f->stop     = $7;
  917. X                      f->start_re = NULL;
  918. X                      f->stop_re  = NULL;
  919. X                      f->command  = NULL;
  920. X                      f->comment  = NULL;
  921. X                      f->next     = NULL;
  922. X                      if (msg = compile_exp(f, f->start, f->stop))
  923. X                         yyerror(msg);
  924. X                      $$ = f;
  925. X                    }
  926. X        ;
  927. X
  928. Xold_ignore    :    IGNORE STRING old_end_string
  929. X                    { Filter    *f;
  930. X                      char        *msg;
  931. X                    
  932. X                      f = (Filter *) malloc(sizeof(Filter));
  933. X                      f->save     = FALSE;
  934. X                      f->beep     = 0;
  935. X                      f->flash    = FALSE;
  936. X                      f->open     = FALSE;
  937. X                      f->stamp    = FALSE;
  938. X                      f->timeout  = 0;
  939. X                      f->log      = TRUE;
  940. X                      f->start    = $2;
  941. X                      f->stop     = $3;
  942. X                      f->start_re = NULL;
  943. X                      f->stop_re  = NULL;
  944. X                      f->command  = NULL;
  945. X                      f->comment  = NULL;
  946. X                      f->next     = NULL;
  947. X                      if (msg = compile_exp(f, f->start, f->stop))
  948. X                         yyerror(msg);
  949. X                      $$ = f;
  950. X                    }
  951. X        ;
  952. X
  953. Xold_quiet    :    QUIET STRING old_end_string
  954. X                    { Filter    *f;
  955. X                      char        *msg;
  956. X                    
  957. X                      f = (Filter *) malloc(sizeof(Filter));
  958. X                      f->save     = TRUE;
  959. X                      f->beep     = 0;
  960. X                      f->flash    = FALSE;
  961. X                      f->open     = FALSE;
  962. X                      f->stamp    = TRUE;
  963. X                      f->timeout  = 0;
  964. X                      f->log      = TRUE;
  965. X                      f->start    = $2;
  966. X                      f->stop     = $3;
  967. X                      f->start_re = NULL;
  968. X                      f->stop_re  = NULL;
  969. X                      f->command  = NULL;
  970. X                      f->comment  = NULL;
  971. X                      f->next     = NULL;
  972. X                      if (msg = compile_exp(f, f->start, f->stop))
  973. X                         yyerror(msg);
  974. X                      $$ = f;
  975. X                    }
  976. X        ;
  977. X
  978. Xold_flash    :    FLASH
  979. X                    { $$ = TRUE; }
  980. X        |    NOFLASH
  981. X                    { $$ = FALSE; }
  982. X        ;
  983. X
  984. Xold_open    :    OPEN
  985. X                    { $$ = TRUE; }
  986. X        |    NOOPEN
  987. X                    { $$ = FALSE; }
  988. X        ;
  989. X
  990. Xold_stamp    :    STAMP
  991. X                    { $$ = TRUE; }
  992. X        |    NOSTAMP
  993. X                    { $$ = FALSE; }
  994. X        ;
  995. X
  996. Xold_end_string    :    empty
  997. X                    { $$ = NULL; }
  998. X        |    TO STRING
  999. X                    { $$ = $2; }
  1000. X        ;
  1001. X
  1002. Xnew_style    :    version defaults
  1003. X        |    version filters
  1004. X        |    version defaults filters
  1005. X        ;
  1006. X
  1007. Xversion        :    empty
  1008. X                    { filter_version = 0; }
  1009. X        |    VERSION INTEGER
  1010. X                    { filter_version = $2; }
  1011. X        ;
  1012. X
  1013. Xdefaults    :    DEFAULTS
  1014. X                    { parsed_defaults = (Props *) malloc(sizeof(Props));
  1015. X                      *parsed_defaults = defaults;
  1016. X                    }
  1017. X            LBRACE default_list RBRACE
  1018. X        ;
  1019. X
  1020. Xfilters        :    FILTERS LBRACE filter_list RBRACE
  1021. X                    { parsed_filters = $3; }
  1022. X        ;
  1023. X
  1024. Xdefault_list    :    empty
  1025. X        |    default_list default
  1026. X        ;
  1027. X
  1028. Xdefault        :    beep
  1029. X                    { parsed_defaults->beep = $1; }
  1030. X        |    command
  1031. X                    { parsed_defaults->command = $1; }
  1032. X        |    flash
  1033. X                    { parsed_defaults->flash = $1; }
  1034. X        |    log
  1035. X                    { parsed_defaults->log = $1; }
  1036. X        |    open
  1037. X                    { parsed_defaults->open = $1; }
  1038. X        |    stamp
  1039. X                    { parsed_defaults->stamp = $1; }
  1040. X        |    ARCHIVE INTEGER
  1041. X                    { parsed_defaults->archive_style = $2; }
  1042. X        |    CHECK_ICON string
  1043. X                    { parsed_defaults->bad_icon = $2; }
  1044. X        |    DELETE INTEGER
  1045. X                    { parsed_defaults->delete_amount = $2; }
  1046. X        |    DISPLAY INTEGER
  1047. X                    { parsed_defaults->max_size = $2; }
  1048. X        |    FLASH_ICON string
  1049. X                    { parsed_defaults->flash_icon = $2; }
  1050. X        |    GOOD_ICON string
  1051. X                    { parsed_defaults->good_icon = $2; }
  1052. X        |    LOG_BEFORE_FILTERING yes_no
  1053. X                    { parsed_defaults->log_after = !$2; }
  1054. X        |    LOG_FILE string
  1055. X                    { parsed_defaults->log_file = $2; }
  1056. X        |    PRINT STRING
  1057. X                    { parsed_defaults->print_filter = $2; }
  1058. X        |    TIMESTAMP INTEGER
  1059. X                    { parsed_defaults->stamp_resolution = $2; }
  1060. X        ;
  1061. X
  1062. Xfilter_list    :    empty
  1063. X                    { $$ = NULL; }
  1064. X        |    filter_list filter
  1065. X                    { Filter    *f;
  1066. X                    
  1067. X                      if ($1 == NULL)
  1068. X                         $$ = $2;
  1069. X                      else {
  1070. X                         for (f = $1; f->next; f = f->next)
  1071. X                            ;
  1072. X                         f->next = $2;
  1073. X                         $$ = $1;
  1074. X                         }
  1075. X                    }
  1076. X        ;
  1077. X
  1078. Xfilter        :    LBRACE
  1079. X                    { curr = (Filter *) malloc(sizeof(Filter));
  1080. X                      bzero(curr, sizeof(Filter));
  1081. X                      if (filter_version < 310)
  1082. X                         curr->log = TRUE;
  1083. X                    }
  1084. X            filter_attr_list RBRACE
  1085. X                    { char    *msg;
  1086. X                    
  1087. X                      if (curr->start == NULL)
  1088. X                         yyerror("no filter pattern specified");
  1089. X                      if (msg = compile_exp(curr, curr->start, curr->stop))
  1090. X                         yyerror(msg);
  1091. X                      $$ = curr;
  1092. X                    }
  1093. X        ;
  1094. X
  1095. Xfilter_attr_list:    empty
  1096. X        |    filter_attr_list filter_attr
  1097. X        ;
  1098. X
  1099. Xfilter_attr    :    beep
  1100. X                    { curr->beep = $1; }
  1101. X        |    command
  1102. X                    { curr->command = $1; }
  1103. X        |    flash
  1104. X                    { curr->flash = $1; }
  1105. X        |    log
  1106. X                    { curr->log = $1; }
  1107. X        |    open
  1108. X                    { curr->open = $1; }
  1109. X        |    stamp
  1110. X                    { curr->stamp = $1; }
  1111. X        |    COMMENT string
  1112. X                    { curr->comment = $2; }
  1113. X        |    IGNORE yes_no
  1114. X                    { curr->save = !$2; }
  1115. X        |    MATCH string
  1116. X                    { curr->start = $2; }
  1117. X        |    TIMEOUT INTEGER
  1118. X                    { curr->timeout = $2; }
  1119. X        |    TO string
  1120. X                    { curr->stop = $2; }
  1121. X        ;
  1122. X
  1123. Xbeep        :    BEEP INTEGER
  1124. X                    { $$ = $2; }
  1125. X        ;
  1126. X
  1127. Xcommand        :    COMMAND string
  1128. X                    { $$ = $2; }
  1129. X        ;
  1130. Xflash        :    FLASH yes_no
  1131. X                    { $$ = $2; }
  1132. X        ;
  1133. X
  1134. Xlog        :    LOG yes_no
  1135. X                    { $$ = $2; }
  1136. X        ;
  1137. X
  1138. Xopen        :    OPEN yes_no
  1139. X                    { $$ = $2; }
  1140. X        ;
  1141. X
  1142. Xstamp        :    STAMP yes_no
  1143. X                    { $$ = $2; }
  1144. X        ;
  1145. X
  1146. Xyes_no        :    YES
  1147. X                    { $$ = TRUE; }
  1148. X        |    NO
  1149. X                    { $$ = FALSE; }
  1150. X        ;
  1151. X
  1152. Xstring        :    STRING
  1153. X                    { $$ = (*$1 == '\0')? NULL : $1; }
  1154. X        ;
  1155. X
  1156. Xempty        : ;
  1157. X
  1158. X%%
  1159. X
  1160. X/************************************************************************/
  1161. XPRIVATE    yyerror(s1, s2, s3, s4, s5, s6, s7)
  1162. X
  1163. Xchar    *s1, *s2, *s3, *s4, *s5, *s6, *s7;
  1164. X
  1165. X{    char    buf1[1024], buf2[1024];
  1166. X
  1167. X    sprintf(buf1, "%s: line %d: ", curr_file, line_count - ((ungetc == '\n')? 1 : 0));
  1168. X    sprintf(buf2, s1, s2, s3, s4, s5, s6, s7);
  1169. X    strcat(buf1, buf2);
  1170. X    if (strcmp(s1, "syntax error") == 0) {
  1171. X       strcat(buf1, " at or near ");
  1172. X       strcat(buf1, get_last_token());
  1173. X       }
  1174. X    error(buf1);
  1175. X    yyclearin;
  1176. X    parse_errors_occured++;
  1177. X}
  1178. X
  1179. X#include "lex.c"
  1180. END_OF_FILE
  1181. if test 8184 -ne `wc -c <'parse.y'`; then
  1182.     echo shar: \"'parse.y'\" unpacked with wrong size!
  1183. fi
  1184. # end of 'parse.y'
  1185. fi
  1186. if test -f 'props.c' -a "${1}" != "-c" ; then 
  1187.   echo shar: Will not clobber existing file \"'props.c'\"
  1188. else
  1189. echo shar: Extracting \"'props.c'\" \(9038 characters\)
  1190. sed "s/^X//" >'props.c' <<'END_OF_FILE'
  1191. X/************************************************************************/
  1192. X/*    Copyright 1987-1991 by Chuck Musciano and Harris Corporation     */
  1193. X/*                                    */
  1194. X/*    Full ownership of this software, and all rights pertaining to     */
  1195. X/*    the for-profit distribution of this software, are retained by     */
  1196. X/*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1197. X/*    use this software without fee.  This software is provided "as     */
  1198. X/*    is" without express or implied warranty.  You may redistribute     */
  1199. X/*    this software, provided that this copyright notice is retained,    */
  1200. X/*    and that the software is not distributed for profit.  If you     */
  1201. X/*    wish to use this software in a profit-making venture, you must     */
  1202. X/*    first license this code and its underlying technology from     */
  1203. X/*    Harris Corporation.                         */
  1204. X/*                                    */
  1205. X/*    Bottom line: you can have this software, you can use it, you     */
  1206. X/*    can give it away.  You just can't sell any or all parts of it     */
  1207. X/*    without prior permission from Harris Corporation.         */
  1208. X/************************************************************************/
  1209. X
  1210. X/************************************************************************/
  1211. X/*                                    */
  1212. X/*    props.c        contool properties dialog manager        */
  1213. X/*                                    */
  1214. X/************************************************************************/
  1215. X
  1216. X#include    <stdio.h>
  1217. X#include    <sys/param.h>
  1218. X#include    <sys/types.h>
  1219. X#include    <xview/xview.h>
  1220. X#include    <xview/panel.h>
  1221. X#include    <xview/rect.h>
  1222. X#include    <xview/screen.h>
  1223. X
  1224. X#include    "manifest.h"
  1225. X#include    "contool.h"
  1226. X#include    "contool_ui.h"
  1227. X
  1228. XEXPORT    Props    defaults = {3,            /* beeps             */
  1229. X                TRUE,        /* flash the icon         */
  1230. X                TRUE,        /* write the message to the log     */
  1231. X                FALSE,        /* don't pop the window         */
  1232. X                TRUE,        /* timestamp the message     */
  1233. X                NULL,        /* no command to run         */
  1234. X                NULL,        /* default good icon         */
  1235. X                NULL,        /* default bad icon         */
  1236. X                NULL,        /* default flash icon         */
  1237. X                "lpr",        /* default print filter         */
  1238. X                NULL,        /* no log file             */
  1239. X                TRUE,        /* log after filtering         */
  1240. X                ARCHIVE_MANUALLY,    /* archive only at user request  */
  1241. X                60,            /* timestamp every 60 seconds     */
  1242. X                32768,        /* save 32K of messages         */
  1243. X                1024        /* remove 1K when we get full     */
  1244. X               };
  1245. X
  1246. XPRIVATE    contool_props_objects    *contool_props = NULL;
  1247. X
  1248. X/************************************************************************/
  1249. XPRIVATE    init_props(ip)
  1250. X
  1251. Xcontool_props_objects    *ip;
  1252. X
  1253. X{    int    val;
  1254. X
  1255. X    val = 0;
  1256. X    if (defaults.beep > 0)
  1257. X       val |= BEEP_BIT;
  1258. X    if (defaults.command != NULL)
  1259. X       val |= COMMAND_BIT;
  1260. X    if (defaults.flash)
  1261. X       val |= FLASH_BIT;
  1262. X    if (defaults.log)
  1263. X       val |= LOG_BIT;
  1264. X    if (defaults.open)
  1265. X       val |= OPEN_BIT;
  1266. X    if (defaults.stamp > 0)
  1267. X       val |= STAMP_BIT;
  1268. X    xv_set(ip->default_action,     PANEL_VALUE,    val,                       NULL);
  1269. X    xv_set(ip->default_beep_count, PANEL_VALUE,    defaults.beep,
  1270. X                       PANEL_INACTIVE, defaults.beep == 0,        NULL);
  1271. X    xv_set(ip->default_beep_times, PANEL_INACTIVE, defaults.beep == 0,        NULL);
  1272. X    xv_set(ip->default_command,    PANEL_VALUE,    is_null(defaults.command),
  1273. X                       PANEL_INACTIVE, defaults.command == NULL,  NULL);
  1274. X    xv_set(ip->log_file,           PANEL_VALUE,    defaults.log_file,         NULL);
  1275. X    xv_set(ip->log_style,          PANEL_VALUE,    defaults.log_after,        NULL);
  1276. X    xv_set(ip->archive_style,      PANEL_VALUE,    defaults.archive_style,    NULL);
  1277. X    xv_set(ip->good_icon,          PANEL_VALUE,    defaults.good_icon,        NULL);
  1278. X    xv_set(ip->bad_icon,           PANEL_VALUE,    defaults.bad_icon,         NULL);
  1279. X    xv_set(ip->flash_icon,         PANEL_VALUE,    defaults.flash_icon,       NULL);
  1280. X    xv_set(ip->print_filter,       PANEL_VALUE,    defaults.print_filter,     NULL);
  1281. X    xv_set(ip->max_message,        PANEL_VALUE,    defaults.max_size,         NULL);
  1282. X    xv_set(ip->stamp_resolution,   PANEL_VALUE,    defaults.stamp_resolution, NULL);
  1283. X    xv_set(ip->delete_amount,      PANEL_VALUE,    defaults.delete_amount,    NULL);
  1284. X}
  1285. X
  1286. X/************************************************************************/
  1287. XEXPORT    Menu_item    edit_properties(item, op)
  1288. X
  1289. XMenu_item    item;
  1290. XMenu_generate    op;
  1291. X
  1292. X{    contool_base_objects    *ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1293. X
  1294. X    if (op == MENU_NOTIFY) {
  1295. X       xv_set(ip->base, FRAME_BUSY, TRUE, NULL);
  1296. X       if (contool_props == NULL) {
  1297. X          contool_props = contool_props_objects_initialize(NULL, ip->base);
  1298. X          xv_set(contool_props->log_file,
  1299. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  1300. X                      PANEL_NOTIFY_STRING, "\n\r\t ",
  1301. X                   NULL);
  1302. X          xv_set(contool_props->good_icon,
  1303. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  1304. X                      PANEL_NOTIFY_STRING, "\n\r\t ",
  1305. X                   NULL);
  1306. X          xv_set(contool_props->bad_icon,
  1307. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  1308. X                      PANEL_NOTIFY_STRING, "\n\r\t ",
  1309. X                   NULL);
  1310. X          xv_set(contool_props->flash_icon,
  1311. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  1312. X                      PANEL_NOTIFY_STRING, "\n\r\t ",
  1313. X                   NULL);
  1314. X          place_dialog(ip->base, contool_props->props);
  1315. X          }
  1316. X       init_props(contool_props);
  1317. X       xv_set(contool_props->props, XV_SHOW, TRUE, NULL);
  1318. X       xv_set(ip->base, FRAME_BUSY, FALSE, NULL);
  1319. X       }
  1320. X    return item;
  1321. X}
  1322. X
  1323. X/************************************************************************/
  1324. XEXPORT    void    default_action(item, value, event)
  1325. X
  1326. XPanel_item    item;
  1327. Xunsigned int    value;
  1328. XEvent        *event;
  1329. X
  1330. X{    contool_props_objects    *ip = (contool_props_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1331. X    
  1332. X    xv_set(ip->default_beep_count, PANEL_INACTIVE, !(value & BEEP_BIT), NULL);
  1333. X    xv_set(ip->default_beep_times, PANEL_INACTIVE, !(value & BEEP_BIT), NULL);
  1334. X    xv_set(ip->default_command,    PANEL_INACTIVE, !(value & COMMAND_BIT), NULL);
  1335. X}
  1336. X
  1337. X/************************************************************************/
  1338. XEXPORT    void    accept_properties(item, event)
  1339. X
  1340. XPanel_item    item;
  1341. XEvent        *event;
  1342. X
  1343. X{    contool_props_objects    *ip = (contool_props_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1344. X    Props    new;
  1345. X    int    val;
  1346. X    Server_image    icon = NULL, load_icon();
  1347. X    char    msg[1024];
  1348. X
  1349. X    val = (int) xv_get(ip->default_action, PANEL_VALUE);
  1350. X
  1351. X    if (val & BEEP_BIT)
  1352. X       new.beep = (int) xv_get(ip->default_beep_count, PANEL_VALUE);
  1353. X    else
  1354. X       new.beep = 0;
  1355. X
  1356. X    if (val & COMMAND_BIT) {
  1357. X       new.command = (char *) xv_get(ip->default_command, PANEL_VALUE);
  1358. X       if (is_empty(new.command)) {
  1359. X          error("You must specify a command to be executed");
  1360. X          xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1361. X          return;
  1362. X          }
  1363. X       }
  1364. X    else
  1365. X       new.command = NULL;
  1366. X
  1367. X    new.flash            = (val & FLASH_BIT)? TRUE : FALSE;
  1368. X    new.log              = (val & LOG_BIT)? TRUE : FALSE;
  1369. X    new.open             = (val & OPEN_BIT)? TRUE : FALSE;
  1370. X    new.stamp            = (val & STAMP_BIT)? TRUE : FALSE;
  1371. X    new.log_file         = (char *) xv_get(ip->log_file,         PANEL_VALUE);
  1372. X    new.log_after        = (int)    xv_get(ip->log_style,        PANEL_VALUE);
  1373. X    new.archive_style    = (int)    xv_get(ip->archive_style,    PANEL_VALUE);
  1374. X    new.good_icon        = (char *) xv_get(ip->good_icon,        PANEL_VALUE);
  1375. X    new.bad_icon         = (char *) xv_get(ip->bad_icon,         PANEL_VALUE);
  1376. X    new.flash_icon       = (char *) xv_get(ip->flash_icon,       PANEL_VALUE);
  1377. X    new.print_filter     = (char *) xv_get(ip->print_filter,     PANEL_VALUE);
  1378. X    new.max_size         = (int)    xv_get(ip->max_message,      PANEL_VALUE);
  1379. X    new.stamp_resolution = (int)    xv_get(ip->stamp_resolution, PANEL_VALUE);
  1380. X    new.delete_amount    = (int)    xv_get(ip->delete_amount,    PANEL_VALUE);
  1381. X
  1382. X    new.good_icon = is_empty(new.good_icon)? NULL : expand_tilde(new.good_icon);
  1383. X    new.bad_icon = is_empty(new.bad_icon)? NULL : expand_tilde(new.bad_icon);
  1384. X    new.flash_icon = is_empty(new.flash_icon)? NULL : expand_tilde(new.flash_icon);
  1385. X
  1386. X    if (new.good_icon && (icon = load_icon(new.good_icon, msg)) == NULL) {
  1387. X       error("Invalid \"All is well\" icon: %s", msg);
  1388. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1389. X       return;
  1390. X       }
  1391. X    if (icon)
  1392. X       xv_destroy(icon);
  1393. X    if (new.bad_icon && (icon = load_icon(new.bad_icon, msg)) == NULL) {
  1394. X       error("Invalid \"Check console\" icon: %s", msg);
  1395. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1396. X       return;
  1397. X       }
  1398. X    if (icon)
  1399. X       xv_destroy(icon);
  1400. X    if (new.flash_icon && (icon = load_icon(new.flash_icon, msg)) == NULL) {
  1401. X       error("Invalid \"Flash\" icon: %s", msg);
  1402. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1403. X       return;
  1404. X       }
  1405. X    if (icon)
  1406. X       xv_destroy(icon);
  1407. X
  1408. X    new.log_file = is_empty(new.log_file)? NULL : expand_tilde(new.log_file);
  1409. X    new.print_filter = strsave(new.print_filter);
  1410. X    new.command = strsave(new.command);
  1411. X    defaults = new;
  1412. X
  1413. X    adjust_window_limit();
  1414. X    update_icons();
  1415. X    update_logging();
  1416. X}
  1417. X
  1418. X/************************************************************************/
  1419. XEXPORT    void    reset_properties(item, event)
  1420. X
  1421. XPanel_item    item;
  1422. XEvent        *event;
  1423. X
  1424. X{    contool_props_objects    *ip = (contool_props_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1425. X    
  1426. X    init_props(ip);
  1427. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1428. X}
  1429. END_OF_FILE
  1430. if test 9038 -ne `wc -c <'props.c'`; then
  1431.     echo shar: \"'props.c'\" unpacked with wrong size!
  1432. fi
  1433. # end of 'props.c'
  1434. fi
  1435. if test -f 'send_mail.c' -a "${1}" != "-c" ; then 
  1436.   echo shar: Will not clobber existing file \"'send_mail.c'\"
  1437. else
  1438. echo shar: Extracting \"'send_mail.c'\" \(4315 characters\)
  1439. sed "s/^X//" >'send_mail.c' <<'END_OF_FILE'
  1440. X/************************************************************************/
  1441. X/*    Copyright 1987-1991 by Chuck Musciano and Harris Corporation     */
  1442. X/*                                    */
  1443. X/*    Full ownership of this software, and all rights pertaining to     */
  1444. X/*    the for-profit distribution of this software, are retained by     */
  1445. X/*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1446. X/*    use this software without fee.  This software is provided "as     */
  1447. X/*    is" without express or implied warranty.  You may redistribute     */
  1448. X/*    this software, provided that this copyright notice is retained,    */
  1449. X/*    and that the software is not distributed for profit.  If you     */
  1450. X/*    wish to use this software in a profit-making venture, you must     */
  1451. X/*    first license this code and its underlying technology from     */
  1452. X/*    Harris Corporation.                         */
  1453. X/*                                    */
  1454. X/*    Bottom line: you can have this software, you can use it, you     */
  1455. X/*    can give it away.  You just can't sell any or all parts of it     */
  1456. X/*    without prior permission from Harris Corporation.         */
  1457. X/************************************************************************/
  1458. X
  1459. X/************************************************************************/
  1460. X/*                                    */
  1461. X/*    send_mail.c    display a little information window        */
  1462. X/*                                    */
  1463. X/************************************************************************/
  1464. X
  1465. X#include    <stdio.h>
  1466. X#include    <sys/param.h>
  1467. X#include    <sys/types.h>
  1468. X#include    <xview/xview.h>
  1469. X#include    <xview/panel.h>
  1470. X#include    <xview/textsw.h>
  1471. X#include    "contool_ui.h"
  1472. X
  1473. X#include    "manifest.h"
  1474. X
  1475. X#define        VERSION            "3.2"
  1476. X
  1477. XPUBLIC    contool_base_objects    *contool_base;
  1478. X
  1479. XPRIVATE    contool_mail_objects    *dialog = NULL;
  1480. X
  1481. X/************************************************************************/
  1482. XEXPORT    popup_send_mail(item, event)
  1483. X
  1484. XPanel_item    item;
  1485. XEvent        *event;
  1486. X
  1487. X{
  1488. X    if (dialog == NULL) {
  1489. X       dialog = contool_mail_objects_initialize(NULL, contool_base->base);
  1490. X       place_dialog(contool_base->base, dialog->mail);
  1491. X       xv_set(dialog->other_address, WIN_SHOW, FALSE, NULL);
  1492. X       }
  1493. X    xv_set(dialog->mail, XV_SHOW, TRUE, NULL);
  1494. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
  1495. X}
  1496. X
  1497. X/************************************************************************/
  1498. XEXPORT    Menu    handle_address(menu, op)
  1499. X
  1500. XMenu_item    menu;
  1501. XMenu_generate    op;
  1502. X
  1503. X{    char    *addr;
  1504. X
  1505. X    if (op == MENU_NOTIFY) {
  1506. X       addr = (char *) xv_get(menu, MENU_STRING);
  1507. X       xv_set(dialog->other_address, WIN_SHOW, strcmp(addr, "Other:") == 0, NULL);
  1508. X       xv_set(dialog->fixed_address, PANEL_LABEL_STRING, addr, NULL);
  1509. X       panel_paint(dialog->other_address, PANEL_CLEAR);
  1510. X       panel_paint(dialog->fixed_address, PANEL_CLEAR);
  1511. X       }
  1512. X    xv_set(menu, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  1513. X    xv_set(xv_get(menu, MENU_PARENT), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  1514. X    return(menu);
  1515. X}
  1516. X
  1517. X/************************************************************************/
  1518. XEXPORT    void    done_mail(frame)
  1519. X
  1520. XFrame        frame;
  1521. X
  1522. X{
  1523. X    textsw_reset(dialog->message, 0, 0);
  1524. X    xv_set(frame, XV_SHOW, FALSE, 0);
  1525. X}
  1526. X
  1527. X/************************************************************************/
  1528. XEXPORT    void    send_mail(item, event)
  1529. X
  1530. XPanel_item    item;
  1531. XEvent        *event;
  1532. X
  1533. X{    char    cmd[1024], *buf;
  1534. X    int    val, size;
  1535. X    FILE    *pipe;
  1536. X
  1537. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, 0);
  1538. X    buf = (char *) xv_get(dialog->fixed_address, PANEL_LABEL_STRING);
  1539. X    if (strcmp(buf, "Other:") != 0)
  1540. X       sprintf(cmd, "%s %s", MAILER, buf);
  1541. X    else {
  1542. X       buf = (char *) xv_get(dialog->other_address, PANEL_VALUE);
  1543. X       if (is_empty(buf)) {
  1544. X          error("You must specify an alternate address before sending your message");
  1545. X          return;
  1546. X          }
  1547. X       else
  1548. X          sprintf(cmd, "%s %s", MAILER, buf);
  1549. X       }
  1550. X    size = (int) xv_get(dialog->message, TEXTSW_LENGTH);
  1551. X    if (size == 0) {
  1552. X       error("Please type a message before sending the mail");
  1553. X       return;
  1554. X       }
  1555. X    if ((pipe = popen(cmd, "w")) == NULL) {
  1556. X       error("Could not invoke \"%s\" to send mail", cmd);
  1557. X       return;
  1558. X       }
  1559. X    lets_get_busy(contool_base->base, TRUE, NULL);
  1560. X    buf = (char *) malloc(size);
  1561. X    xv_get(dialog->message, TEXTSW_CONTENTS, 0, buf, size);
  1562. X    fprintf(pipe, "Subject: Contool %s comment\n\n", VERSION);
  1563. X    if (fwrite(buf, 1, size, pipe) != size) {
  1564. X       error("Could not write message to the mailer");
  1565. X       free(buf);
  1566. X       return;
  1567. X       }
  1568. X    pclose(pipe);
  1569. X    free(buf);
  1570. X    textsw_reset(dialog->message, 0, 0);
  1571. X    lets_get_busy(contool_base->base, FALSE, NULL);
  1572. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
  1573. X}
  1574. END_OF_FILE
  1575. if test 4315 -ne `wc -c <'send_mail.c'`; then
  1576.     echo shar: \"'send_mail.c'\" unpacked with wrong size!
  1577. fi
  1578. # end of 'send_mail.c'
  1579. fi
  1580. if test -f 'store.c' -a "${1}" != "-c" ; then 
  1581.   echo shar: Will not clobber existing file \"'store.c'\"
  1582. else
  1583. echo shar: Extracting \"'store.c'\" \(6340 characters\)
  1584. sed "s/^X//" >'store.c' <<'END_OF_FILE'
  1585. X/************************************************************************/
  1586. X/*    Copyright 1987-1991 by Chuck Musciano and Harris Corporation     */
  1587. X/*                                    */
  1588. X/*    Full ownership of this software, and all rights pertaining to     */
  1589. X/*    the for-profit distribution of this software, are retained by     */
  1590. X/*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1591. X/*    use this software without fee.  This software is provided "as     */
  1592. X/*    is" without express or implied warranty.  You may redistribute     */
  1593. X/*    this software, provided that this copyright notice is retained,    */
  1594. X/*    and that the software is not distributed for profit.  If you     */
  1595. X/*    wish to use this software in a profit-making venture, you must     */
  1596. X/*    first license this code and its underlying technology from     */
  1597. X/*    Harris Corporation.                         */
  1598. X/*                                    */
  1599. X/*    Bottom line: you can have this software, you can use it, you     */
  1600. X/*    can give it away.  You just can't sell any or all parts of it     */
  1601. X/*    without prior permission from Harris Corporation.         */
  1602. X/************************************************************************/
  1603. X
  1604. X/************************************************************************/
  1605. X/*                                    */
  1606. X/*    store.c        contool store dialog manager            */
  1607. X/*                                    */
  1608. X/************************************************************************/
  1609. X
  1610. X#include    <stdio.h>
  1611. X#include    <ctype.h>
  1612. X#include    <sys/param.h>
  1613. X#include    <sys/types.h>
  1614. X#include    <sys/file.h>
  1615. X#include    <xview/xview.h>
  1616. X#include    <xview/panel.h>
  1617. X#include    <xview/notice.h>
  1618. X#include    <xview/xv_xrect.h>
  1619. X
  1620. X#include    "manifest.h"
  1621. X#include    "contool.h"
  1622. X#include    "contool_ui.h"
  1623. X
  1624. X#define        yes_no(x)        ((x)? "yes" : "no")
  1625. X
  1626. X#define        FILTER_VERSION        320
  1627. X
  1628. XPUBLIC    contool_base_objects    *contool_base;
  1629. X
  1630. XPRIVATE    contool_store_objects    *contool_store = NULL;
  1631. X
  1632. X/************************************************************************/
  1633. XEXPORT    Menu_item    popup_save_config(item, op)
  1634. X
  1635. XMenu_item    item;
  1636. XMenu_generate    op;
  1637. X
  1638. X{    contool_base_objects * ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1639. X
  1640. X    if (op == MENU_NOTIFY) {
  1641. X       if (contool_store == NULL) {
  1642. X          contool_store = contool_store_objects_initialize(NULL, ip->base);
  1643. X          xv_set(contool_store->store_file,
  1644. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  1645. X                      PANEL_NOTIFY_STRING, "\n\r ",
  1646. X                   NULL);
  1647. X          xv_set(contool_store->store_type, PANEL_VALUE, 3, NULL);
  1648. X          place_dialog(ip->base, contool_store->store);
  1649. X          }
  1650. X       xv_set(contool_store->store_file, PANEL_VALUE, filter_file, NULL);
  1651. X       xv_set(contool_store->store, XV_SHOW, TRUE, NULL);
  1652. X       }
  1653. X    return item;
  1654. X}
  1655. X
  1656. X/************************************************************************/
  1657. XEXPORT    int    store_filters_to_file(path, save_filters, save_props)
  1658. X
  1659. Xchar        *path;
  1660. Xint        save_filters;
  1661. Xint        save_props;
  1662. X
  1663. X{    char    buf[1024];
  1664. X    int    answer;
  1665. X    FILE    *f;
  1666. X    Filter    *filt;
  1667. X
  1668. X    if (access(path, W_OK) == 0) {
  1669. X       sprintf(buf, "File \"%s\" exists.  You can:", path);
  1670. X       answer = notice_prompt(contool_base->base, NULL,
  1671. X                        NOTICE_MESSAGE_STRINGS, buf, NULL,
  1672. X                        NOTICE_BUTTON_YES, "Overwrite",
  1673. X                        NOTICE_BUTTON_NO, "Cancel",
  1674. X                     NULL);
  1675. X       if (answer == 0)
  1676. X          return(FALSE);
  1677. X       }
  1678. X    if ((f = fopen(path, "w")) == NULL) {
  1679. X       error("Cannot write to %s: %s", path, sys_errlist[errno]);
  1680. X       return(FALSE);
  1681. X       }
  1682. X    fprintf(f, "version %d\n", FILTER_VERSION);
  1683. X    if (save_props) {
  1684. X       fprintf(f, "defaults {\n");
  1685. X       fprintf(f, "   beep                 %d\n", defaults.beep);
  1686. X       fprintf(f, "   command              \"%s\"\n", check_escapes(is_null(defaults.command)));
  1687. X       fprintf(f, "   flash                %s\n", yes_no(defaults.flash));
  1688. X       fprintf(f, "   log                  %s\n", yes_no(defaults.log));
  1689. X       fprintf(f, "   open                 %s\n", yes_no(defaults.open));
  1690. X       fprintf(f, "   stamp                %s\n", yes_no(defaults.stamp));
  1691. X       fprintf(f, "   archive              %d\n", defaults.archive_style);
  1692. X       fprintf(f, "   good_icon            \"%s\"\n", is_null(defaults.good_icon));
  1693. X       fprintf(f, "   check_icon           \"%s\"\n", is_null(defaults.bad_icon));
  1694. X       fprintf(f, "   flash_icon           \"%s\"\n", is_null(defaults.flash_icon));
  1695. X       fprintf(f, "   print                \"%s\"\n", defaults.print_filter);
  1696. X       fprintf(f, "   log_file             \"%s\"\n", is_null(defaults.log_file));
  1697. X       fprintf(f, "   log_before_filtering %s\n", yes_no(!defaults.log_after));
  1698. X       fprintf(f, "   timestamp            %d\n", defaults.stamp_resolution);
  1699. X       fprintf(f, "   display              %d\n", defaults.max_size);
  1700. X       fprintf(f, "   delete               %d\n", defaults.delete_amount);
  1701. X       fprintf(f, "}\n");
  1702. X       }
  1703. X    if (save_filters) {
  1704. X       fprintf(f, "filters {\n");
  1705. X       for (filt = filters; filt; filt = filt->next) {
  1706. X          fprintf(f, "   {\n");
  1707. X          fprintf(f, "      match   \"%s\"\n", check_escapes(filt->start));
  1708. X          if (filt->stop) {
  1709. X             fprintf(f, "      to      \"%s\"\n", check_escapes(filt->stop));
  1710. X             fprintf(f, "      timeout %d\n", filt->timeout);
  1711. X             }
  1712. X          if (filt->comment)
  1713. X             fprintf(f, "      comment \"%s\"\n", check_escapes(filt->comment));
  1714. X          if (filt->save) {
  1715. X             fprintf(f, "      ignore  no\n");
  1716. X             fprintf(f, "      beep    %d\n", filt->beep);
  1717. X             fprintf(f, "      command \"%s\"\n", check_escapes(is_null(filt->command)));
  1718. X             fprintf(f, "      flash   %s\n", yes_no(filt->flash));
  1719. X             fprintf(f, "      log     %s\n", yes_no(filt->log));
  1720. X             fprintf(f, "      open    %s\n", yes_no(filt->open));
  1721. X             fprintf(f, "      stamp   %s\n", yes_no(filt->stamp));
  1722. X             }
  1723. X          else
  1724. X             fprintf(f, "      ignore  yes\n");
  1725. X          fprintf(f, "   }\n");
  1726. X          }
  1727. X       fprintf(f, "}\n");
  1728. X       }
  1729. X    fclose(f);
  1730. X    return(TRUE);
  1731. X}
  1732. X
  1733. X/************************************************************************/
  1734. XEXPORT    void    store_filters(item, event)
  1735. X
  1736. XPanel_item    item;
  1737. XEvent        *event;
  1738. X
  1739. X{    contool_store_objects    *ip = (contool_store_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1740. X    char    *path;
  1741. X    int    kind;
  1742. X
  1743. X    path = expand_tilde(xv_get(ip->store_file, PANEL_VALUE));
  1744. X    kind = (int) xv_get(ip->store_type, PANEL_VALUE);
  1745. X    if (store_filters_to_file(path, kind & 2, kind & 1)) {
  1746. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, NULL);
  1747. X       filter_file = path;
  1748. X       }
  1749. X    else {
  1750. X       free(path);
  1751. X       xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1752. X       }
  1753. X}
  1754. END_OF_FILE
  1755. if test 6340 -ne `wc -c <'store.c'`; then
  1756.     echo shar: \"'store.c'\" unpacked with wrong size!
  1757. fi
  1758. # end of 'store.c'
  1759. fi
  1760. echo shar: End of archive 4 \(of 5\).
  1761. cp /dev/null ark4isdone
  1762. MISSING=""
  1763. for I in 1 2 3 4 5 ; do
  1764.     if test ! -f ark${I}isdone ; then
  1765.     MISSING="${MISSING} ${I}"
  1766.     fi
  1767. done
  1768. if test "${MISSING}" = "" ; then
  1769.     echo You have unpacked all 5 archives.
  1770.     rm -f ark[1-9]isdone
  1771. else
  1772.     echo You still need to unpack the following archives:
  1773.     echo "        " ${MISSING}
  1774. fi
  1775. ##  End of shell archive.
  1776. exit 0
  1777.