home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / contol3a / part04 < prev    next >
Encoding:
Text File  |  1992-03-04  |  45.1 KB  |  1,454 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: v16i103: contool 3.2A (Final Release), Part04/07
  5. Message-ID: <1992Mar5.214807.9597@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:07 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: Chuck Musciano <chuck@trantor.harris-atd.com>
  14. Posting-number: Volume 16, Issue 103
  15. Archive-name: contool-3.2a/part04
  16.  
  17. # this is Part.04 (part 4 of a multipart archive)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file filters.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" != 4; 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 filters.c'
  35. else
  36. echo 'x - continuing file filters.c'
  37. sed 's/^X//' << 'SHAR_EOF' >> 'filters.c' &&
  38. PRIVATE    free_filter(f)
  39. X
  40. Filter    *f;
  41. X
  42. {
  43. X    cond_free(f->start);
  44. X    cond_free(f->start_re);
  45. X    cond_free(f->stop);
  46. X    cond_free(f->stop_re);
  47. X    cond_free(f->command);
  48. X    cond_free(f->comment);
  49. X    free(f);
  50. }
  51. X
  52. /************************************************************************/
  53. EXPORT    free_list(list)
  54. X
  55. Filter    *list;
  56. X
  57. {    Filter    *next;
  58. X
  59. X    for ( ; list; list = next) {
  60. X       next = list->next;
  61. X       free_filter(list);
  62. X       }
  63. }
  64. X
  65. /************************************************************************/
  66. PRIVATE    update_controls()
  67. X
  68. {    Filter    *f;
  69. X    int    i;
  70. X
  71. X    if (selection_count() == 1) {
  72. X       for (f = edit_set, i = 0; f; f = f->next, i++)
  73. X          if (xv_get(contool_filters->filter_list, PANEL_LIST_SELECTED, i))
  74. X             break;
  75. X       if (f == NULL) {
  76. X          error("Internal error: filters do not match scrolling list!");
  77. X          return;
  78. X          }
  79. X       xv_set(contool_filters->filter_update, PANEL_INACTIVE, FALSE, NULL);
  80. X       xv_set(contool_filters->filter_type, PANEL_INACTIVE, FALSE, PANEL_VALUE, f->stop? 1 : 0, NULL);
  81. X       xv_set(contool_filters->start, PANEL_INACTIVE, FALSE, PANEL_VALUE, is_null(f->start), NULL);
  82. X       xv_set(contool_filters->stop, PANEL_INACTIVE, f->stop == NULL, PANEL_VALUE, is_null(f->stop), NULL);
  83. X       xv_set(contool_filters->filter_timeout, PANEL_INACTIVE, f->stop == NULL, PANEL_VALUE, f->timeout, NULL);
  84. X       xv_set(contool_filters->filter_timeout_units, PANEL_INACTIVE, f->stop == NULL, NULL);
  85. X       xv_set(contool_filters->comment, PANEL_INACTIVE, FALSE, PANEL_VALUE, is_null(f->comment), NULL);
  86. X       xv_set(contool_filters->ignore, PANEL_INACTIVE, FALSE, PANEL_VALUE, f->save? 0 : 1, NULL);
  87. X       if (f->save) {
  88. X          i = 0;
  89. X          if (f->beep) {
  90. X             i |= BEEP_BIT;
  91. X             xv_set(contool_filters->filter_beep_count, PANEL_INACTIVE, FALSE, PANEL_VALUE, f->beep, NULL);
  92. X             xv_set(contool_filters->filter_beep_times, PANEL_INACTIVE, FALSE, NULL);
  93. X             }
  94. X          else {
  95. X             xv_set(contool_filters->filter_beep_count, PANEL_INACTIVE, TRUE, NULL);
  96. X             xv_set(contool_filters->filter_beep_times, PANEL_INACTIVE, TRUE, NULL);
  97. X             }
  98. X          if (f->command) {
  99. X             i |= COMMAND_BIT;
  100. X             xv_set(contool_filters->filter_command, PANEL_INACTIVE, FALSE, PANEL_VALUE, f->command, NULL);
  101. X             xv_set(contool_filters->filter_beep_times, PANEL_INACTIVE, FALSE, NULL);
  102. X             }
  103. X          else
  104. X             xv_set(contool_filters->filter_command, PANEL_INACTIVE, TRUE, NULL);
  105. X          if (f->flash)
  106. X             i |= FLASH_BIT;
  107. X          if (f->log)
  108. X             i |= LOG_BIT;
  109. X          if (f->open)
  110. X             i |= OPEN_BIT;
  111. X          if (f->stamp)
  112. X             i |= STAMP_BIT;
  113. X          xv_set(contool_filters->action, PANEL_INACTIVE, FALSE, PANEL_VALUE, i, NULL);
  114. X          }
  115. X       else {
  116. X          xv_set(contool_filters->action, PANEL_INACTIVE, TRUE, NULL);
  117. X          xv_set(contool_filters->filter_beep_count, PANEL_INACTIVE, TRUE, NULL);
  118. X          xv_set(contool_filters->filter_beep_times, PANEL_INACTIVE, TRUE, NULL);
  119. X          xv_set(contool_filters->filter_command, PANEL_INACTIVE, TRUE, NULL);
  120. X          }
  121. X       }
  122. X    else {
  123. X       xv_set(contool_filters->filter_update,        PANEL_INACTIVE, TRUE, NULL);
  124. X       xv_set(contool_filters->filter_type,          PANEL_INACTIVE, TRUE, NULL);
  125. X       xv_set(contool_filters->filter_timeout,       PANEL_INACTIVE, TRUE, NULL);
  126. X       xv_set(contool_filters->filter_timeout_units, PANEL_INACTIVE, TRUE, NULL);
  127. X       xv_set(contool_filters->start,                PANEL_INACTIVE, TRUE, NULL);
  128. X       xv_set(contool_filters->stop,                 PANEL_INACTIVE, TRUE, NULL);
  129. X       xv_set(contool_filters->comment,              PANEL_INACTIVE, TRUE, NULL);
  130. X       xv_set(contool_filters->ignore,               PANEL_INACTIVE, TRUE, NULL);
  131. X       xv_set(contool_filters->action,               PANEL_INACTIVE, TRUE, NULL);
  132. X       xv_set(contool_filters->filter_beep_count,    PANEL_INACTIVE, TRUE, NULL);
  133. X       xv_set(contool_filters->filter_beep_times,    PANEL_INACTIVE, TRUE, NULL);
  134. X       xv_set(contool_filters->filter_command,       PANEL_INACTIVE, TRUE, NULL);
  135. X       }
  136. }
  137. X
  138. /************************************************************************/
  139. PRIVATE    init_filters()
  140. X
  141. {    Filter    *f;
  142. X    int    i, total;
  143. X
  144. X    xv_set(contool_filters->filter_list, PANEL_PAINT, PANEL_NO_CLEAR, NULL);
  145. X    for (total = (int) xv_get(contool_filters->filter_list, PANEL_LIST_NROWS); total > 0; total--)
  146. X       xv_set(contool_filters->filter_list, PANEL_LIST_DELETE, total - 1, NULL);
  147. X    xv_set(contool_filters->filter_list, PANEL_PAINT, PANEL_CLEAR, NULL);
  148. X    free_list(edit_set);
  149. X    edit_set = duplicate_list(filters);
  150. X    for (i = 0, f = edit_set; f; f = f->next, i++)
  151. X       xv_set(contool_filters->filter_list,
  152. X                PANEL_LIST_INSERT, i,
  153. X                PANEL_LIST_GLYPH,  i, f->stop? range : single,
  154. X                PANEL_LIST_STRING, i, f->start,
  155. X             NULL);
  156. X    update_controls();
  157. }
  158. X
  159. /************************************************************************/
  160. PRIVATE    insert_item(pos)
  161. X
  162. int    pos;
  163. X
  164. {    int    i, total;
  165. X    Filter    *f, *t;
  166. X
  167. X    total = (int) xv_get(contool_filters->filter_list, PANEL_LIST_NROWS);
  168. X    for (i = 0; i < total; i++)
  169. X       if (xv_get(contool_filters->filter_list, PANEL_LIST_SELECTED, i))
  170. X          xv_set(contool_filters->filter_list, PANEL_LIST_SELECT, i, FALSE, NULL);
  171. X    xv_set(contool_filters->filter_list, PANEL_LIST_INSERT, pos, NULL);
  172. X    xv_set(contool_filters->filter_list, PANEL_LIST_GLYPH, pos, empty, NULL);
  173. X    xv_set(contool_filters->filter_list, PANEL_LIST_SELECT, pos, TRUE, NULL);
  174. X    if (pos == 0) {
  175. X       f = (Filter *) malloc(sizeof(Filter));
  176. X       f->next = edit_set;
  177. X       edit_set = f;
  178. X       }
  179. X    else {
  180. X       for (i = 1, f = edit_set; i < pos; i++, f = f->next)
  181. X          ;
  182. X       t = f->next;
  183. X       f->next = (Filter *) malloc(sizeof(Filter));
  184. X       f = f->next;
  185. X       f->next = t;
  186. X       }
  187. X    f->start = f->stop = f->comment = NULL;
  188. X    f->beep = defaults.beep;
  189. X    f->command = strsave(defaults.command);
  190. X    f->flash = defaults.flash;
  191. X    f->log = defaults.log;
  192. X    f->open = defaults.open;
  193. X    f->stamp = defaults.stamp;
  194. X    f->timeout = 0;
  195. X    f->save = TRUE;
  196. X    update_controls();
  197. /* update the scrolling view */
  198. }
  199. X
  200. /************************************************************************/
  201. PRIVATE    paste_items(pos)
  202. X
  203. int    pos;
  204. X
  205. {    int    i;
  206. X    Filter    *new, *tail, *f;
  207. X
  208. X    new = duplicate_list(clipboard);
  209. X    for (f = new, i = 0; f; f = f->next, i++) {
  210. X       xv_set(contool_filters->filter_list, PANEL_LIST_INSERT, pos + i, 0);
  211. X       xv_set(contool_filters->filter_list,
  212. X                PANEL_LIST_STRING, pos + i, f->start,
  213. X                PANEL_LIST_GLYPH,  pos + i, f->stop? range : single,
  214. X             NULL);
  215. X       tail = f;
  216. X       }
  217. X    if (pos == 0) {
  218. X       tail->next = edit_set;
  219. X       edit_set = new;
  220. X       }
  221. X    else {
  222. X       for (i = 1, f = edit_set; i < pos; i++, f = f->next)
  223. X          ;
  224. X       tail->next = f->next;
  225. X       f->next = new;
  226. X       }
  227. X    update_controls();
  228. }
  229. X
  230. /************************************************************************/
  231. PRIVATE    int    update_values(f, flag)
  232. X
  233. Filter    *f;
  234. int    flag;
  235. X
  236. {    char    *start, *stop, *msg;
  237. X    int    i;
  238. X
  239. X    start = (char *) xv_get(contool_filters->start, PANEL_VALUE);
  240. X    if (is_empty(start)) {
  241. X       if (flag)
  242. X          error("You must specify a starting message pattern");
  243. X       return(FALSE);
  244. X       }
  245. X    if (xv_get(contool_filters->filter_type, PANEL_VALUE) == 1) {
  246. X       stop = (char *) xv_get(contool_filters->stop, PANEL_VALUE);
  247. X       if (is_empty(stop)) {
  248. X          if (flag)
  249. X             error("You must specify an ending message pattern");
  250. X          return(FALSE);
  251. X          }
  252. X       }
  253. X    else
  254. X       stop = NULL;
  255. X    if (msg = compile_exp(f, start, stop)) {
  256. X       if (flag)
  257. X          error(msg);
  258. X       return(FALSE);
  259. X       }
  260. X    if ((int) xv_get(contool_filters->ignore, PANEL_VALUE) == 0) {
  261. X       i = (int) xv_get(contool_filters->action, PANEL_VALUE);
  262. X       if (i & COMMAND_BIT)
  263. X          if (msg = (char *) xv_get(contool_filters->filter_command, PANEL_VALUE))
  264. X             f->command = strsave(msg);
  265. X          else {
  266. X             if (flag)
  267. X                error("You must specify a command for this filter");
  268. X             return(FALSE);
  269. X             }
  270. X       else
  271. X          f->command = NULL;
  272. X       if (i & BEEP_BIT)
  273. X          f->beep = (int) xv_get(contool_filters->filter_beep_count, PANEL_VALUE);
  274. X       else
  275. X          f->beep = 0;
  276. X       f->flash = (i & FLASH_BIT)? TRUE : FALSE;
  277. X       f->log = (i & LOG_BIT)? TRUE : FALSE;
  278. X       f->open = (i & OPEN_BIT)? TRUE : FALSE;
  279. X       f->stamp = (i & STAMP_BIT)? TRUE : FALSE;
  280. X       f->save = TRUE;
  281. X       }
  282. X    else
  283. X       f->save = FALSE;
  284. X    f->timeout = (stop == NULL)? 0 : (int) xv_get(contool_filters->filter_timeout, PANEL_VALUE);
  285. X    f->start = strsave(start);
  286. X    f->stop = strsave(stop);
  287. X    f->comment = strsave((char *) xv_get(contool_filters->comment, PANEL_VALUE));
  288. X    return(TRUE);
  289. }
  290. X
  291. /************************************************************************/
  292. EXPORT    Menu_item    edit_filters(item, op)
  293. X
  294. Menu_item    item;
  295. Menu_generate    op;
  296. X
  297. {    Filter    *f, *curr;
  298. X
  299. X    if (op == MENU_NOTIFY) {
  300. X       xv_set(contool_base->base, FRAME_BUSY, TRUE, NULL);
  301. X       if (contool_filters == NULL) {
  302. X          contool_filters = contool_filters_objects_initialize(NULL, contool_base->base);
  303. X          place_dialog(contool_base->base, contool_filters->filters);
  304. X          xv_set(contool_filters->filter_list, PANEL_LIST_ROW_HEIGHT, 16, NULL);
  305. X          single = (Server_image) xv_create(NULL, SERVER_IMAGE,
  306. X                                 XV_WIDTH, 16,
  307. X                                 XV_HEIGHT, 16,
  308. X                                 SERVER_IMAGE_BITS, single_bits,
  309. X                              0);
  310. X          range  = (Server_image) xv_create(NULL, SERVER_IMAGE,
  311. X                                 XV_WIDTH, 16,
  312. X                                 XV_HEIGHT, 16,
  313. X                                 SERVER_IMAGE_BITS, range_bits,
  314. X                              0);
  315. X          empty  = (Server_image) xv_create(NULL, SERVER_IMAGE,
  316. X                                 XV_WIDTH, 16,
  317. X                                 XV_HEIGHT, 16,
  318. X                                 SERVER_IMAGE_BITS, empty_bits,
  319. X                              0);
  320. X          }
  321. X       if (xv_get(contool_filters->filters, XV_SHOW) == FALSE) {
  322. X          edit_set = duplicate_list(filters);
  323. X          free_list(clipboard);
  324. X          clipboard = NULL;
  325. X          init_filters();
  326. X          }
  327. X       xv_set(contool_filters->filters, XV_SHOW, TRUE, NULL);
  328. X       xv_set(contool_base->base, FRAME_BUSY, FALSE, NULL);
  329. X       }
  330. X    return item;
  331. }
  332. X
  333. /************************************************************************/
  334. EXPORT    int    filter_notify(item, string, client_data, op, event)
  335. X
  336. Panel_item    item;
  337. char        *string;
  338. XXv_opaque    client_data;
  339. Panel_list_op    op;
  340. Event        *event;
  341. X
  342. {    
  343. X    if (op == PANEL_LIST_OP_DESELECT || op == PANEL_LIST_OP_SELECT)
  344. X       update_controls();
  345. X    return XV_OK;
  346. }
  347. X
  348. /************************************************************************/
  349. EXPORT    Menu    filter_insert_handler(menu, op)
  350. X
  351. Menu        menu;
  352. Menu_generate    op;
  353. X
  354. {
  355. X    xv_set(menu, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  356. X    xv_set(contool_filters->filter_insert, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  357. X    return menu;
  358. }
  359. X
  360. /************************************************************************/
  361. EXPORT    Menu_item    insert_at_top(item, op)
  362. X
  363. Menu_item    item;
  364. Menu_generate    op;
  365. X
  366. {
  367. X    xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  368. X    xv_set(contool_filters->filter_insert, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  369. X    if (op == MENU_NOTIFY)
  370. X       insert_item(0);
  371. X    return item;
  372. }
  373. X
  374. /************************************************************************/
  375. EXPORT    Menu_item    insert_above(item, op)
  376. X
  377. Menu_item    item;
  378. Menu_generate    op;
  379. X
  380. {
  381. X    xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  382. X    xv_set(contool_filters->filter_insert, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  383. X    if (op == MENU_DISPLAY)
  384. X       xv_set(item, MENU_INACTIVE, selection_count() != 1, NULL);
  385. X    else if (op == MENU_NOTIFY)
  386. X       insert_item(curr_selection());
  387. X    return item;
  388. }
  389. X
  390. /************************************************************************/
  391. EXPORT    Menu_item    insert_below(item, op)
  392. X
  393. Menu_item    item;
  394. Menu_generate    op;
  395. X
  396. {
  397. X    xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  398. X    xv_set(contool_filters->filter_insert, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  399. X    if (op == MENU_DISPLAY)
  400. X       xv_set(item, MENU_INACTIVE, selection_count() != 1, NULL);
  401. X    else if (op == MENU_NOTIFY)
  402. X       insert_item(curr_selection() + 1);
  403. X    return item;
  404. }
  405. X
  406. /************************************************************************/
  407. EXPORT    Menu_item    insert_at_bottom(item, op)
  408. X
  409. Menu_item    item;
  410. Menu_generate    op;
  411. X
  412. {
  413. X    xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  414. X    xv_set(contool_filters->filter_insert, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  415. X    if (op == MENU_NOTIFY)
  416. X       insert_item(xv_get(contool_filters->filter_list, PANEL_LIST_NROWS));
  417. X    return item;
  418. }
  419. X
  420. /************************************************************************/
  421. EXPORT    Menu    filter_edit_handler(menu, op)
  422. X
  423. Menu        menu;
  424. Menu_generate    op;
  425. X
  426. {
  427. X    xv_set(menu, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  428. X    xv_set(contool_filters->filter_insert, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  429. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  430. X    return menu;
  431. }
  432. X
  433. /************************************************************************/
  434. EXPORT    Menu_item    filter_cut(item, op)
  435. X
  436. Menu_item    item;
  437. Menu_generate    op;
  438. X
  439. {    int    i, total;
  440. X    Filter    *f, *prev, *curr = NULL;
  441. X
  442. X    xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  443. X    xv_set(contool_filters->filter_edit, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  444. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  445. X    if (op == MENU_DISPLAY)
  446. X       xv_set(item, MENU_INACTIVE, selection_count() == 0, NULL);
  447. X    else if (op == MENU_NOTIFY) {
  448. X       free_list(clipboard);
  449. X       clipboard = NULL;
  450. X       total = (int) xv_get(contool_filters->filter_list, PANEL_LIST_NROWS);
  451. X       for (prev = NULL, f = edit_set, i = 0; i < total; i++, f = f->next)
  452. X          if (xv_get(contool_filters->filter_list, PANEL_LIST_SELECTED, i)) {
  453. X             if (clipboard == NULL)
  454. X                clipboard = curr = f;
  455. X             else {
  456. X                curr->next = f;
  457. X                curr = curr->next;
  458. X                }
  459. X             if (prev == NULL)
  460. X                edit_set = f->next;
  461. X             else
  462. X                prev->next = f->next;
  463. X             xv_set(contool_filters->filter_list, PANEL_LIST_DELETE, i, NULL);
  464. X             i--;
  465. X             total--;
  466. X             }
  467. X          else
  468. X             prev = f;
  469. X       if (curr)
  470. X          curr->next = NULL;
  471. X       update_controls();
  472. X       xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  473. X       }
  474. X    return item;
  475. }
  476. X
  477. /************************************************************************/
  478. EXPORT    Menu_item    filter_copy(item, op)
  479. X
  480. Menu_item    item;
  481. Menu_generate    op;
  482. X
  483. {    int    i, total;
  484. X    Filter    *f, *curr;
  485. X
  486. X    xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  487. X    xv_set(contool_filters->filter_edit, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  488. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  489. X    if (op == MENU_DISPLAY)
  490. X       xv_set(item, MENU_INACTIVE, selection_count() == 0, NULL);
  491. X    else if (op == MENU_NOTIFY) {
  492. X       free_list(clipboard);
  493. X       clipboard = NULL;
  494. X       total = (int) xv_get(contool_filters->filter_list, PANEL_LIST_NROWS);
  495. X       for (f = edit_set, i = 0; i < total; i++, f = f->next)
  496. X          if (xv_get(contool_filters->filter_list, PANEL_LIST_SELECTED, i))
  497. X             if (clipboard == NULL)
  498. X                clipboard = curr = duplicate_filter(f);
  499. X             else {
  500. X                curr->next = duplicate_filter(f);
  501. X                curr = curr->next;
  502. X                }
  503. X       curr->next = NULL;
  504. X       xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  505. X       }
  506. X    return item;
  507. }
  508. X
  509. /************************************************************************/
  510. EXPORT    Menu_item    filter_delete(item, op)
  511. X
  512. Menu_item    item;
  513. Menu_generate    op;
  514. X
  515. {    int    i, total;
  516. X    Filter    *f, *prev, *temp = NULL, *curr;
  517. X
  518. X    xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  519. X    xv_set(contool_filters->filter_edit, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  520. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  521. X    if (op == MENU_DISPLAY)
  522. X       xv_set(item, MENU_INACTIVE, selection_count() == 0, NULL);
  523. X    else if (op == MENU_NOTIFY) {
  524. X       total = (int) xv_get(contool_filters->filter_list, PANEL_LIST_NROWS);
  525. X       for (prev = NULL, f = edit_set, i = 0; i < total; i++, f = f->next)
  526. X          if (xv_get(contool_filters->filter_list, PANEL_LIST_SELECTED, i)) {
  527. X             if (temp == NULL)
  528. X                temp = curr = f;
  529. X             else {
  530. X                curr->next = f;
  531. X                curr = curr->next;
  532. X                }
  533. X             if (prev == NULL)
  534. X                edit_set = f->next;
  535. X             else
  536. X                prev->next = f->next;
  537. X             xv_set(contool_filters->filter_list, PANEL_LIST_DELETE, i, NULL);
  538. X             i--;
  539. X             total--;
  540. X             }
  541. X          else
  542. X             prev = f;
  543. X       if (curr)
  544. X          curr->next = NULL;
  545. X       free_list(temp);
  546. X       update_controls();
  547. X       xv_set(item, MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  548. X       }
  549. X    return item;
  550. }
  551. X
  552. /************************************************************************/
  553. EXPORT    Menu_item    filter_paste(item, op)
  554. X
  555. Menu_item    item;
  556. Menu_generate    op;
  557. X
  558. {
  559. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  560. X    if (op == MENU_DISPLAY)
  561. X       xv_set(item, MENU_INACTIVE, clipboard == NULL, NULL);
  562. X    return item;
  563. }
  564. X
  565. /************************************************************************/
  566. EXPORT    Menu_item    paste_at_top(item, op)
  567. X
  568. Menu_item    item;
  569. Menu_generate    op;
  570. X
  571. {
  572. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  573. X    if (op == MENU_NOTIFY)
  574. X       paste_items(0);
  575. X    return item;
  576. }
  577. X
  578. /************************************************************************/
  579. EXPORT    Menu_item    paste_above(item, op)
  580. X
  581. Menu_item    item;
  582. Menu_generate    op;
  583. X
  584. {
  585. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  586. X    if (op == MENU_DISPLAY)
  587. X       xv_set(item, MENU_INACTIVE, selection_count() != 1, NULL);
  588. X    else if (op == MENU_NOTIFY)
  589. X       paste_items(curr_selection());
  590. X    return item;
  591. }
  592. X
  593. /************************************************************************/
  594. EXPORT    Menu_item    paste_below(item, op)
  595. X
  596. Menu_item    item;
  597. Menu_generate    op;
  598. X
  599. {
  600. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  601. X    if (op == MENU_DISPLAY)
  602. X       xv_set(item, MENU_INACTIVE, selection_count() != 1, NULL);
  603. X    else if (op == MENU_NOTIFY)
  604. X       paste_items(curr_selection() + 1);
  605. X    return item;
  606. }
  607. X
  608. /************************************************************************/
  609. EXPORT    Menu_item    paste_at_bottom(item, op)
  610. X
  611. Menu_item    item;
  612. Menu_generate    op;
  613. X
  614. {
  615. X    xv_set(xv_get(contool_filters->filter_edit, PANEL_ITEM_MENU), MENU_NOTIFY_STATUS, XV_ERROR, NULL);
  616. X    if (op == MENU_NOTIFY)
  617. X       paste_items((int) xv_get(contool_filters->filter_list, PANEL_LIST_NROWS));
  618. X    return item;
  619. }
  620. X
  621. /************************************************************************/
  622. EXPORT    void    filter_update(item, event)
  623. X
  624. Panel_item    item;
  625. Event        *event;
  626. X
  627. {    int    i, curr;
  628. X    Filter    *f;
  629. X
  630. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  631. X
  632. X    curr = curr_selection();
  633. X    for (i = 0, f = edit_set; i < curr; i++, f = f->next)
  634. X       ;
  635. X    if (update_values(f, TRUE))
  636. X       xv_set(contool_filters->filter_list,
  637. X             PANEL_LIST_STRING, curr, f->start,
  638. X             PANEL_LIST_GLYPH,  curr, f->stop? range : single,
  639. X              NULL);
  640. }
  641. X
  642. /************************************************************************/
  643. EXPORT    void    set_filter_type(item, value, event)
  644. X
  645. Panel_item    item;
  646. int        value;
  647. Event        *event;
  648. X
  649. {
  650. X    xv_set(contool_filters->stop, PANEL_INACTIVE, value == 0, NULL);
  651. X    xv_set(contool_filters->filter_timeout, PANEL_INACTIVE, value == 0, NULL);
  652. X    xv_set(contool_filters->filter_timeout_units, PANEL_INACTIVE, value == 0, NULL);
  653. }
  654. X
  655. /************************************************************************/
  656. EXPORT    void    set_filter_action(item, value, event)
  657. X
  658. Panel_item    item;
  659. int        value;
  660. Event        *event;
  661. X
  662. {    contool_filters_objects    *ip = (contool_filters_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  663. X
  664. X    if (value == 0) { /* save this message */
  665. X       xv_set(ip->action,            PANEL_INACTIVE, FALSE, NULL);
  666. X       xv_set(ip->filter_beep_count, PANEL_INACTIVE, !((int) xv_get(ip->action, PANEL_VALUE) & BEEP_BIT), NULL);
  667. X       xv_set(ip->filter_beep_times, PANEL_INACTIVE, !((int) xv_get(ip->action, PANEL_VALUE) & BEEP_BIT), NULL);
  668. X       xv_set(ip->filter_command,    PANEL_INACTIVE, !((int) xv_get(ip->action, PANEL_VALUE) & COMMAND_BIT), NULL);
  669. X       }
  670. X    else { /* ignore this message */
  671. X       xv_set(ip->action,            PANEL_INACTIVE, TRUE, NULL);
  672. X       xv_set(ip->filter_beep_count, PANEL_INACTIVE, TRUE, NULL);
  673. X       xv_set(ip->filter_beep_times, PANEL_INACTIVE, TRUE, NULL);
  674. X       xv_set(ip->filter_command,    PANEL_INACTIVE, TRUE, NULL);
  675. X       }
  676. }
  677. X
  678. /************************************************************************/
  679. EXPORT    void    set_match_action(item, value, event)
  680. X
  681. Panel_item    item;
  682. unsigned int    value;
  683. Event        *event;
  684. X
  685. {    contool_filters_objects    *ip = (contool_filters_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  686. X    
  687. X    xv_set(ip->filter_beep_count, PANEL_INACTIVE, !(value & BEEP_BIT), NULL);
  688. X    xv_set(ip->filter_beep_times, PANEL_INACTIVE, !(value & BEEP_BIT), NULL);
  689. X    xv_set(ip->filter_command,    PANEL_INACTIVE, !(value & COMMAND_BIT), NULL);
  690. }
  691. X
  692. /************************************************************************/
  693. EXPORT    void    filter_done(frame)
  694. X
  695. Frame        frame;
  696. X
  697. {
  698. X    free_list(edit_set);
  699. X    edit_set = NULL;
  700. X    free_list(clipboard);
  701. X    clipboard = NULL;
  702. X    xv_set(frame, XV_SHOW, FALSE, 0);
  703. }
  704. X
  705. /************************************************************************/
  706. PRIVATE    int    check_for_update()
  707. X
  708. {    int    i, result, curr, diff = FALSE;
  709. X    Filter    *f, new;
  710. X
  711. X    if (selection_count() != 1)
  712. X       return(TRUE);
  713. X    curr = curr_selection();
  714. X    for (i = 0, f = edit_set; i < curr; i++, f = f->next)
  715. X       ;
  716. X    new = *f;
  717. X    if (update_values(&new, FALSE) == FALSE)
  718. X       diff = TRUE;
  719. X    else if ((f->start != NULL && new.start == NULL) || (f->start == NULL && new.start != NULL))
  720. X       diff = TRUE;
  721. X    else if ((f->stop != NULL && new.stop == NULL) || (f->stop == NULL && new.stop != NULL))
  722. X       diff = TRUE;
  723. X    else if ((f->comment != NULL && new.comment == NULL) || (f->comment == NULL && new.comment != NULL))
  724. X       diff = TRUE;
  725. X    else if ((f->command != NULL && new.command == NULL) || (f->command == NULL && new.command != NULL))
  726. X       diff = TRUE;
  727. X    else if (new.stop && f->timeout != new.timeout)
  728. X       diff = TRUE;
  729. X    else if (f->save != new.save || f->beep != new.beep || f->flash != new.flash || f->log != new.log || f->open != new.open || f->stamp != new.stamp)
  730. X       diff = TRUE;
  731. X    else if (f->start && strcmp(f->start, new.start) != 0)
  732. X       diff = TRUE;
  733. X    else if (f->stop && strcmp(f->stop, new.stop) != 0)
  734. X       diff = TRUE;
  735. X    else if (f->comment && strcmp(f->comment, new.comment) != 0)
  736. X       diff = TRUE;
  737. X    else if (f->command && strcmp(f->command, new.command) != 0)
  738. X       diff = TRUE;
  739. X    if (diff) {
  740. X       result = notice_prompt(contool_base->base, NULL,
  741. X                        NOTICE_MESSAGE_STRINGS,
  742. X                           "You have modified the attributes of the selected filter.",
  743. X                           " ",
  744. X                           "Do you wish to perform an Update before doing an Apply?",
  745. X                           NULL,
  746. X                        NOTICE_BUTTON_YES, "Update, then Apply",
  747. X                        NOTICE_BUTTON_NO, "Apply",
  748. X                        NOTICE_BUTTON, "Cancel", 101,
  749. X                     NULL);
  750. X       if (result == NOTICE_YES)
  751. X          filter_update(contool_filters->filters, NULL);
  752. X       return(result != 101);
  753. X       }
  754. X    return(TRUE);
  755. }
  756. X
  757. /************************************************************************/
  758. EXPORT    void    accept_filters(item, event)
  759. X
  760. Panel_item    item;
  761. Event        *event;
  762. X
  763. {    Filter    *f;
  764. X    int    i, total;
  765. X    char    *msg = NULL;
  766. X
  767. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  768. X
  769. X    if (!check_for_update())
  770. X       return;
  771. X
  772. X    total = (int) xv_get(contool_filters->filter_list, PANEL_LIST_NROWS);
  773. X    for (i = 0; i < total; i++)
  774. X       if (xv_get(contool_filters->filter_list, PANEL_LIST_SELECTED, i))
  775. X          xv_set(contool_filters->filter_list, PANEL_LIST_SELECT, i, FALSE, NULL);
  776. X    for (f = edit_set, i = 0; f; f = f->next, i++)
  777. X       if (is_empty(f->start) || (msg = compile_exp(f, f->start, f->stop))) {
  778. X          xv_set(contool_filters->filter_list, PANEL_LIST_SELECT, i, TRUE, NULL);
  779. X          update_controls();
  780. X          error(msg? msg : "No pattern is specified for the indicated filter");
  781. X          return;
  782. X          }
  783. X    free_list(filters);
  784. X    filters = edit_set;
  785. X    if (xv_get(contool_filters->filters, FRAME_CMD_PUSHPIN_IN))
  786. X       edit_set = duplicate_list(filters);
  787. X    else {
  788. X       edit_set = NULL;
  789. X       free_list(clipboard);
  790. X       clipboard = NULL;
  791. X       }
  792. X    filters_changed();
  793. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, NULL);
  794. }
  795. X
  796. /************************************************************************/
  797. EXPORT    void    accept_and_save_filters(item, event)
  798. X
  799. Panel_item    item;
  800. Event        *event;
  801. X
  802. {
  803. X    accept_filters(item, event);
  804. X    if (xv_get(item, PANEL_NOTIFY_STATUS) == XV_OK)
  805. X       if (!store_filters_to_file(filter_file, TRUE, TRUE))
  806. X          xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  807. }
  808. X
  809. /************************************************************************/
  810. EXPORT    void    reset_filters(item, event)
  811. X
  812. Panel_item    item;
  813. Event        *event;
  814. X
  815. {
  816. X    init_filters();
  817. X    xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  818. }
  819. SHAR_EOF
  820. echo 'File filters.c is complete' &&
  821. chmod 0644 filters.c ||
  822. echo 'restore of filters.c failed'
  823. Wc_c="`wc -c < 'filters.c'`"
  824. test 28125 -eq "$Wc_c" ||
  825.     echo 'filters.c: original size 28125, current size' "$Wc_c"
  826. rm -f _shar_wnt_.tmp
  827. fi
  828. # ============= getopt.c ==============
  829. if test -f 'getopt.c' -a X"$1" != X"-c"; then
  830.     echo 'x - skipping getopt.c (File already exists)'
  831.     rm -f _shar_wnt_.tmp
  832. else
  833. > _shar_wnt_.tmp
  834. echo 'x - extracting getopt.c (Text)'
  835. sed 's/^X//' << 'SHAR_EOF' > 'getopt.c' &&
  836. /************************************************************************/
  837. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  838. /*                                    */
  839. /*    Full ownership of this software, and all rights pertaining to     */
  840. /*    the for-profit distribution of this software, are retained by     */
  841. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  842. /*    use this software without fee.  This software is provided "as     */
  843. /*    is" without express or implied warranty.  You may redistribute     */
  844. /*    this software, provided that this copyright notice is retained,    */
  845. /*    and that the software is not distributed for profit.  If you     */
  846. /*    wish to use this software in a profit-making venture, you must     */
  847. /*    first license this code and its underlying technology from     */
  848. /*    Harris Corporation.                         */
  849. /*                                    */
  850. /*    Bottom line: you can have this software, you can use it, you     */
  851. /*    can give it away.  You just can't sell any or all parts of it     */
  852. /*    without prior permission from Harris Corporation.         */
  853. /************************************************************************/
  854. X
  855. #include    <stdio.h>
  856. X
  857. #include    "manifest.h"
  858. X
  859. /************************************************************************/
  860. PRIVATE    delarg(argc, argv)
  861. X
  862. int    *argc;
  863. char    **argv;
  864. X
  865. {    char    *p;
  866. X
  867. X    while (*argv = *(argv+1))
  868. X       argv++;
  869. X    (*argc)--;
  870. }
  871. X
  872. /************************************************************************/
  873. EXPORT    char    getopt(argc, argv, opts, parm)
  874. X
  875. int    *argc;
  876. char    **argv;
  877. char    *opts;
  878. char    **parm;
  879. X
  880. {    char    c, *p, *strcpy(), *index();
  881. X    int    killed;
  882. X
  883. X    *parm = NULL;
  884. X    while (*argv && ((**argv != '-') || (*(*argv+1) == '\0')))
  885. X       argv++;
  886. X    if (*argv == NULL)
  887. X       return(EOF);
  888. X    c = *(*argv+1);
  889. X    *++(*argv) = '-';
  890. X    if (killed = (*(*argv+1) == '\0'))
  891. X       delarg(argc, argv);
  892. X    if ((p = index(opts, c)) == NULL)
  893. X       c = '\0';
  894. X    else if (*(p+1) == ':') {
  895. X       *parm = killed ? *argv : *argv+1;
  896. X       delarg(argc, argv);
  897. X       }
  898. X    return(c);
  899. }
  900. SHAR_EOF
  901. chmod 0644 getopt.c ||
  902. echo 'restore of getopt.c failed'
  903. Wc_c="`wc -c < 'getopt.c'`"
  904. test 1926 -eq "$Wc_c" ||
  905.     echo 'getopt.c: original size 1926, current size' "$Wc_c"
  906. rm -f _shar_wnt_.tmp
  907. fi
  908. # ============= lex.c ==============
  909. if test -f 'lex.c' -a X"$1" != X"-c"; then
  910.     echo 'x - skipping lex.c (File already exists)'
  911.     rm -f _shar_wnt_.tmp
  912. else
  913. > _shar_wnt_.tmp
  914. echo 'x - extracting lex.c (Text)'
  915. sed 's/^X//' << 'SHAR_EOF' > 'lex.c' &&
  916. /************************************************************************/
  917. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  918. /*                                    */
  919. /*    Full ownership of this software, and all rights pertaining to     */
  920. /*    the for-profit distribution of this software, are retained by     */
  921. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  922. /*    use this software without fee.  This software is provided "as     */
  923. /*    is" without express or implied warranty.  You may redistribute     */
  924. /*    this software, provided that this copyright notice is retained,    */
  925. /*    and that the software is not distributed for profit.  If you     */
  926. /*    wish to use this software in a profit-making venture, you must     */
  927. /*    first license this code and its underlying technology from     */
  928. /*    Harris Corporation.                         */
  929. /*                                    */
  930. /*    Bottom line: you can have this software, you can use it, you     */
  931. /*    can give it away.  You just can't sell any or all parts of it     */
  932. /*    without prior permission from Harris Corporation.         */
  933. /************************************************************************/
  934. X
  935. #define        RETURN(x)        return(last_token = (x))
  936. X
  937. #define        FIRST_KEYWORD        ARCHIVE
  938. #define        LAST_KEYWORD        YES
  939. #define        NUM_KEYWORDS        (LAST_KEYWORD - FIRST_KEYWORD + 1)
  940. X
  941. PRIVATE    FILE    *f = NULL;
  942. PRIVATE    int    last_token = -1;
  943. PRIVATE    char    buf[1024];
  944. X
  945. PRIVATE    struct    {char    *name;
  946. X         int    value;
  947. X        } token[] = {{"archive",              ARCHIVE},
  948. X                 {"beep",                 BEEP},
  949. X                 {"check_icon",           CHECK_ICON},
  950. X                 {"command",              COMMAND},
  951. X                 {"comment",              COMMENT},
  952. X                 {"defaults",             DEFAULTS},
  953. X                 {"delete",               DELETE},
  954. X                 {"display",              DISPLAY},
  955. X                 {"filters",              FILTERS},
  956. X                 {"flash",                FLASH},
  957. X                 {"flash_icon",           FLASH_ICON},
  958. X                 {"good_icon",            GOOD_ICON},
  959. X                 {"ignore",               IGNORE},
  960. X                 {"log",                  LOG},
  961. X                 {"log_before_filtering", LOG_BEFORE_FILTERING},
  962. X                 {"log_file",             LOG_FILE},
  963. X                 {"match",                MATCH},
  964. X                 {"no"     ,              NO},
  965. X                 {"noflash",              NOFLASH},
  966. X                 {"noopen",               NOOPEN},
  967. X                 {"nostamp",              NOSTAMP},
  968. X                 {"open",                 OPEN},
  969. X                 {"print",                PRINT},
  970. X                 {"quiet",                QUIET},
  971. X                 {"save",                 SAVE},
  972. X                 {"stamp",                STAMP},
  973. X                 {"timeout",              TIMEOUT},
  974. X                 {"timestamp",            TIMESTAMP},
  975. X                 {"to",                   TO},
  976. X                 {"version",              VERSION},
  977. X                 {"yes",                  YES}};
  978. X
  979. PRIVATE    struct    {char    first;
  980. X         char    next;
  981. X         int    name;
  982. X        } punc[] = {{'{',  '\0', LBRACE},
  983. X                {'}',  '\0', RBRACE},
  984. X                {'\0', '\0', -1}};
  985. X
  986. /************************************************************************/
  987. EXPORT    int    lex_init(path)
  988. X
  989. char    *path;
  990. X
  991. {
  992. X    if (f)
  993. X       fclose(f);
  994. X    if (f = fopen(path, "r")) {
  995. X       curr_file = strsave(path);
  996. X       line_count = 1;
  997. X       ungetc = -1;
  998. X       parse_errors_occured = 0;
  999. X       return(TRUE);
  1000. X       }
  1001. X    else
  1002. X       return(FALSE);
  1003. }
  1004. X
  1005. /************************************************************************/
  1006. PRIVATE    char    getch()
  1007. X
  1008. {    register    char    c;
  1009. X    static        int    first = TRUE;
  1010. X
  1011. X    if (ungetc != -1)
  1012. X       c = ungetc, ungetc = -1;
  1013. X    else {
  1014. X       c = getc(f);
  1015. X       if (c == '\n')
  1016. X          line_count++;
  1017. X       }
  1018. X    return(c);
  1019. }
  1020. X
  1021. /************************************************************************/
  1022. PRIVATE    int    is_keyword(s)
  1023. X
  1024. char    *s;
  1025. X
  1026. {    register    int    cmp, high, low, pos;
  1027. X
  1028. X    for (low = 0, high = NUM_KEYWORDS - 1; low <= high; )
  1029. X       if ((cmp = strcmp(s, token[pos = (high - low) / 2 + low].name)) == 0)
  1030. X          return(token[pos].value);
  1031. X       else if (cmp < 0)
  1032. X          high = pos - 1;
  1033. X       else
  1034. X          low = pos + 1;
  1035. X    return(NULL);
  1036. }
  1037. X
  1038. /************************************************************************/
  1039. PRIVATE    int    yylex()
  1040. X
  1041. {    register    char    c, c1, *p;
  1042. X    register    int    i, j, val;
  1043. X    char            *index();
  1044. X    double            atof();
  1045. X
  1046. X    c = getch();
  1047. X    while (isspace(c))
  1048. X       c = getch();
  1049. X    if (isalpha(c)) {
  1050. X       p = buf;
  1051. X       *p++ = c;
  1052. X       while (isalnum(c = getch()) || c == '_')
  1053. X          *p++ = c;
  1054. X       ungetc = c;
  1055. X       *p = '\0';
  1056. X       for (p = buf; *p; p++)
  1057. X          if (isupper(*p))
  1058. X             *p = tolower(*p);
  1059. X       if (i = is_keyword(buf))
  1060. X          RETURN(i);
  1061. X       else {
  1062. X          yyerror("unexpected keyword: %s", buf);
  1063. X          fclose(f);
  1064. X          f = NULL;
  1065. X          RETURN(EOF);
  1066. X          }
  1067. X       }
  1068. X    else if (c == '"' || c == '\'') {
  1069. X       for (p = buf; TRUE; p++)
  1070. X          if ((*p = getch()) == c) {
  1071. X             if ((c1 = getch()) != c) {
  1072. X                ungetc = c1;
  1073. X                break;
  1074. X                }
  1075. X             }
  1076. X          else if (*p == '\\' && filter_version < 310)
  1077. X             *p = getch();
  1078. X          else if (*p == '\n' || *p == '\r') {
  1079. X             yyerror("Newline in string not allowed");
  1080. X             break;
  1081. X             }
  1082. X       *p = '\0';
  1083. X       yylval.cpval = strsave(buf);
  1084. X       RETURN(STRING);
  1085. X       }
  1086. X    else if (isdigit(c)) {
  1087. X       p = buf;
  1088. X       *p++ = c;
  1089. X       while (isdigit(c = getch()))
  1090. X          *p++ = c;
  1091. X       *p = '\0';
  1092. X       ungetc = c;
  1093. X       yylval.ival = atoi(buf);
  1094. X       RETURN(INTEGER);
  1095. X       }
  1096. X    else if (c == '#') {
  1097. X       while ((c = getch()) != '\n' && c != EOF)
  1098. X          ;
  1099. X       if (c == EOF) {
  1100. X          fclose(f);
  1101. X          f = NULL;
  1102. X          RETURN(EOF);
  1103. X          }
  1104. X       else
  1105. X          RETURN(yylex());
  1106. X       }
  1107. X    else if (c == EOF) {
  1108. X       fclose(f);
  1109. X       f = NULL;
  1110. X       RETURN(EOF);
  1111. X       }
  1112. X    else {
  1113. X       for (i = 0; punc[i].first; i++)
  1114. X          if (c == punc[i].first) {
  1115. X             for (c1 = getch(), j = 1; punc[i + j].first == c; j++)
  1116. X                if (c1 == punc[i + j].next)
  1117. X                   RETURN(punc[i + j].name);
  1118. X             ungetc = c1;
  1119. X             RETURN(punc[i].name);
  1120. X             }
  1121. X       yyerror("Invalid character in source file: %c (0x%02x)", c, c);
  1122. X       }
  1123. X    RETURN(yylex());
  1124. }
  1125. X
  1126. /************************************************************************/
  1127. PRIVATE    char    *get_last_token()
  1128. X
  1129. {    int    i;
  1130. X    static    char    msg[512];
  1131. X
  1132. X    if (last_token == INTEGER || last_token == STRING)
  1133. X       sprintf(msg, "\"%s\"", buf);
  1134. X    else if (last_token >= LBRACE && last_token <= RBRACE) {
  1135. X       for (i = 0; punc[i].first; i++)
  1136. X          if (punc[i].name == last_token) {
  1137. X             sprintf(msg, "\"%c\"", punc[i].first);
  1138. X             if (punc[i].next)
  1139. X                sprintf(msg + 2, "%c\"", punc[i].next);
  1140. X             break;
  1141. X             }
  1142. X       if (punc[i].first == '\0')
  1143. X          sprintf(msg, "!!Geez!  Some punctuation, I don't know!!");
  1144. X       }
  1145. X    else if (last_token >= FIRST_KEYWORD && last_token <= LAST_KEYWORD)
  1146. X       sprintf(msg, "\"%s\"", token[last_token - FIRST_KEYWORD].name);
  1147. X    else if (last_token == EOF)
  1148. X       sprintf(msg, "End Of File");
  1149. X    else
  1150. X       sprintf(msg, "!!Geez!  Some keyword, I don't know!!");
  1151. X    return(msg);
  1152. }
  1153. SHAR_EOF
  1154. chmod 0644 lex.c ||
  1155. echo 'restore of lex.c failed'
  1156. Wc_c="`wc -c < 'lex.c'`"
  1157. test 6716 -eq "$Wc_c" ||
  1158.     echo 'lex.c: original size 6716, current size' "$Wc_c"
  1159. rm -f _shar_wnt_.tmp
  1160. fi
  1161. # ============= load.c ==============
  1162. if test -f 'load.c' -a X"$1" != X"-c"; then
  1163.     echo 'x - skipping load.c (File already exists)'
  1164.     rm -f _shar_wnt_.tmp
  1165. else
  1166. > _shar_wnt_.tmp
  1167. echo 'x - extracting load.c (Text)'
  1168. sed 's/^X//' << 'SHAR_EOF' > 'load.c' &&
  1169. /************************************************************************/
  1170. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  1171. /*                                    */
  1172. /*    Full ownership of this software, and all rights pertaining to     */
  1173. /*    the for-profit distribution of this software, are retained by     */
  1174. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1175. /*    use this software without fee.  This software is provided "as     */
  1176. /*    is" without express or implied warranty.  You may redistribute     */
  1177. /*    this software, provided that this copyright notice is retained,    */
  1178. /*    and that the software is not distributed for profit.  If you     */
  1179. /*    wish to use this software in a profit-making venture, you must     */
  1180. /*    first license this code and its underlying technology from     */
  1181. /*    Harris Corporation.                         */
  1182. /*                                    */
  1183. /*    Bottom line: you can have this software, you can use it, you     */
  1184. /*    can give it away.  You just can't sell any or all parts of it     */
  1185. /*    without prior permission from Harris Corporation.         */
  1186. /************************************************************************/
  1187. X
  1188. /************************************************************************/
  1189. /*                                    */
  1190. /*    load.c        contool load dialog manager            */
  1191. /*                                    */
  1192. /************************************************************************/
  1193. X
  1194. #include    <stdio.h>
  1195. #include    <sys/param.h>
  1196. #include    <sys/types.h>
  1197. #include    <xview/xview.h>
  1198. #include    <xview/panel.h>
  1199. #include    <xview/xv_xrect.h>
  1200. X
  1201. #include    "manifest.h"
  1202. #include    "contool.h"
  1203. #include    "contool_ui.h"
  1204. X
  1205. PRIVATE    contool_load_objects    *contool_load = NULL;
  1206. X
  1207. /************************************************************************/
  1208. EXPORT    Menu_item    popup_load_config(item, op)
  1209. X
  1210. Menu_item    item;
  1211. Menu_generate    op;
  1212. X
  1213. {    contool_base_objects * ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1214. X
  1215. X    if (op == MENU_NOTIFY) {
  1216. X       if (contool_load == NULL) {
  1217. X          contool_load = contool_load_objects_initialize(NULL, ip->base);
  1218. X          xv_set(contool_load->load_file,
  1219. X                      PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  1220. X                      PANEL_NOTIFY_STRING, "\n\r ",
  1221. X                   NULL);
  1222. X          xv_set(contool_load->load_type, PANEL_VALUE, 3, NULL);
  1223. X          place_dialog(ip->base, contool_load->load);
  1224. X          }
  1225. X       xv_set(contool_load->load_file, PANEL_VALUE, filter_file, NULL);
  1226. X       xv_set(contool_load->load, XV_SHOW, TRUE, NULL);
  1227. X       }
  1228. X    return item;
  1229. }
  1230. X
  1231. /************************************************************************/
  1232. EXPORT    void    load_filters(item, event)
  1233. X
  1234. Panel_item    item;
  1235. Event        *event;
  1236. X
  1237. {    contool_load_objects    *ip = (contool_load_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  1238. X    int    kind;
  1239. X    char    *path;
  1240. X
  1241. X    path = expand_tilde(xv_get(ip->load_file, PANEL_VALUE));
  1242. X    if (lex_init(path)) {
  1243. X       yyparse();
  1244. X       if (parse_errors_occured) {
  1245. X          error("Error in configuration file.  Configuration not loaded");
  1246. X          xv_set(ip->accept_load, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1247. X          }
  1248. X       else {
  1249. X          kind = (int) xv_get(ip->load_type, PANEL_VALUE);
  1250. X          if (kind & 1 && parsed_defaults) {
  1251. X             defaults = *parsed_defaults;
  1252. X             adjust_window_limit();
  1253. X             }
  1254. X          if (kind & 2)
  1255. X             filters = parsed_filters;
  1256. X          free(parsed_defaults);
  1257. X          filter_file = path;
  1258. X          }
  1259. X       }
  1260. X    else {
  1261. X       error("Unable to read configuration file");
  1262. X       xv_set(ip->accept_load, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  1263. X       free(path);
  1264. X       }
  1265. }
  1266. SHAR_EOF
  1267. chmod 0644 load.c ||
  1268. echo 'restore of load.c failed'
  1269. Wc_c="`wc -c < 'load.c'`"
  1270. test 3392 -eq "$Wc_c" ||
  1271.     echo 'load.c: original size 3392, current size' "$Wc_c"
  1272. rm -f _shar_wnt_.tmp
  1273. fi
  1274. # ============= load_icon.c ==============
  1275. if test -f 'load_icon.c' -a X"$1" != X"-c"; then
  1276.     echo 'x - skipping load_icon.c (File already exists)'
  1277.     rm -f _shar_wnt_.tmp
  1278. else
  1279. > _shar_wnt_.tmp
  1280. echo 'x - extracting load_icon.c (Text)'
  1281. sed 's/^X//' << 'SHAR_EOF' > 'load_icon.c' &&
  1282. /************************************************************************/
  1283. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  1284. /*                                    */
  1285. /*    Full ownership of this software, and all rights pertaining to     */
  1286. /*    the for-profit distribution of this software, are retained by     */
  1287. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1288. /*    use this software without fee.  This software is provided "as     */
  1289. /*    is" without express or implied warranty.  You may redistribute     */
  1290. /*    this software, provided that this copyright notice is retained,    */
  1291. /*    and that the software is not distributed for profit.  If you     */
  1292. /*    wish to use this software in a profit-making venture, you must     */
  1293. /*    first license this code and its underlying technology from     */
  1294. /*    Harris Corporation.                         */
  1295. /*                                    */
  1296. /*    Bottom line: you can have this software, you can use it, you     */
  1297. /*    can give it away.  You just can't sell any or all parts of it     */
  1298. /*    without prior permission from Harris Corporation.         */
  1299. /************************************************************************/
  1300. X
  1301. #include    <stdio.h>
  1302. #include    <sys/file.h>
  1303. X
  1304. #include    <xview/xview.h>
  1305. #include    <xview/icon_load.h>
  1306. X
  1307. #include    "manifest.h"
  1308. X
  1309. #if !defined(ICON_PATH)
  1310. #define        ICON_PATH        ".:./icons:/usr/local/images:/usr/include/images"
  1311. #endif
  1312. X
  1313. PUBLIC    char    *getenv(), *index();
  1314. X
  1315. /************************************************************************/
  1316. EXPORT    Server_image    load_icon(path, message)
  1317. X
  1318. char    *path;
  1319. char    *message;
  1320. X
  1321. {    char    *icon_path, new_path[1024], *p, *q;
  1322. X
  1323. X    if (*path == '/')
  1324. X       return(icon_load_svrim(path, message));
  1325. X    else {
  1326. X       if ((p = getenv("ICON_PATH")) != NULL)
  1327. X          icon_path = strsave(p);
  1328. X       else
  1329. X          icon_path = strsave(ICON_PATH);
  1330. X       for (p = icon_path; *p; ) {
  1331. X          if (q = index(p, ':'))
  1332. X             *q = '\0';
  1333. X          strcpy(new_path, p);
  1334. X          strcat(new_path, "/");
  1335. X          strcat(new_path, path);
  1336. X          if (access(new_path, R_OK) == 0) {
  1337. X             free(icon_path);
  1338. X             return(icon_load_svrim(new_path, message));
  1339. X             }
  1340. X          else if (q != NULL)
  1341. X             p = q + 1;
  1342. X          else
  1343. X             break;
  1344. X          }
  1345. X       free(icon_path);
  1346. X       return(icon_load_svrim(path, message));
  1347. X       }
  1348. }
  1349. SHAR_EOF
  1350. chmod 0644 load_icon.c ||
  1351. echo 'restore of load_icon.c failed'
  1352. Wc_c="`wc -c < 'load_icon.c'`"
  1353. test 2201 -eq "$Wc_c" ||
  1354.     echo 'load_icon.c: original size 2201, current size' "$Wc_c"
  1355. rm -f _shar_wnt_.tmp
  1356. fi
  1357. # ============= logging.c ==============
  1358. if test -f 'logging.c' -a X"$1" != X"-c"; then
  1359.     echo 'x - skipping logging.c (File already exists)'
  1360.     rm -f _shar_wnt_.tmp
  1361. else
  1362. > _shar_wnt_.tmp
  1363. echo 'x - extracting logging.c (Text)'
  1364. sed 's/^X//' << 'SHAR_EOF' > 'logging.c' &&
  1365. /************************************************************************/
  1366. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  1367. /*                                    */
  1368. /*    Full ownership of this software, and all rights pertaining to     */
  1369. /*    the for-profit distribution of this software, are retained by     */
  1370. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1371. /*    use this software without fee.  This software is provided "as     */
  1372. /*    is" without express or implied warranty.  You may redistribute     */
  1373. /*    this software, provided that this copyright notice is retained,    */
  1374. /*    and that the software is not distributed for profit.  If you     */
  1375. /*    wish to use this software in a profit-making venture, you must     */
  1376. /*    first license this code and its underlying technology from     */
  1377. /*    Harris Corporation.                         */
  1378. /*                                    */
  1379. /*    Bottom line: you can have this software, you can use it, you     */
  1380. /*    can give it away.  You just can't sell any or all parts of it     */
  1381. /*    without prior permission from Harris Corporation.         */
  1382. /************************************************************************/
  1383. X
  1384. /************************************************************************/
  1385. /*                                    */
  1386. /*    logging.c    message log management                */
  1387. /*                                    */
  1388. /************************************************************************/
  1389. X
  1390. #include    <stdio.h>
  1391. #include    <sys/param.h>
  1392. #include    <sys/types.h>
  1393. #include    <xview/xview.h>
  1394. #include    <xview/panel.h>
  1395. #include    <xview/xv_xrect.h>
  1396. X
  1397. #include    "manifest.h"
  1398. #include    "contool.h"
  1399. #include    "contool_ui.h"
  1400. X
  1401. PUBLIC    Menu_item    start_logging();
  1402. PUBLIC    Menu_item    stop_logging();
  1403. X
  1404. PUBLIC    contool_base_objects    *contool_base;
  1405. X
  1406. PRIVATE    int    logging = FALSE;
  1407. PRIVATE    FILE    *logfile = NULL;
  1408. PRIVATE    char    *log_path = NULL;
  1409. X
  1410. /************************************************************************/
  1411. EXPORT    void    disable_logging()
  1412. X
  1413. {
  1414. X    if (logging) {
  1415. X       fclose(logfile);
  1416. X       cond_free(log_path);
  1417. X       log_path = NULL;
  1418. X       logging = FALSE;
  1419. X       }
  1420. X    xv_set(contool_base->base, FRAME_RIGHT_FOOTER, "", NULL);
  1421. }
  1422. X
  1423. /************************************************************************/
  1424. EXPORT    void    enable_logging()
  1425. X
  1426. {    char    buf[1024];
  1427. X
  1428. X    if (logging) {
  1429. X       if (log_path && strcmp(log_path, defaults.log_file) == 0)
  1430. X          return;
  1431. X       disable_logging();
  1432. X       }
  1433. X    if (is_empty(defaults.log_file))
  1434. X       error("You must specify a log file in the Properties dialog");
  1435. X    else if ((logfile = fopen(defaults.log_file, "a")) == NULL)
  1436. X       error("Cannot open log file %s : %s", defaults.log_file, sys_errlist[errno]);
  1437. X    else {
  1438. X       logging = TRUE;
  1439. X       log_path = strsave(defaults.log_file);
  1440. X       sprintf(buf, "Logging to %s...", defaults.log_file);
  1441. X       xv_set(contool_base->base, FRAME_RIGHT_FOOTER, buf, NULL);
  1442. SHAR_EOF
  1443. true || echo 'restore of logging.c failed'
  1444. fi
  1445. echo 'End of  part 4'
  1446. echo 'File logging.c is continued in part 5'
  1447. echo 5 > _shar_seq_.tmp
  1448. exit 0
  1449. -- 
  1450. --
  1451. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1452. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1453. Sunnyvale, California 94086            at&t: 408/522-9236
  1454.