mcgrew@aramis.rutgers.edu (Charles Mcgrew) (09/26/90)
Submitted-by: chuck@trantor.harris-atd.com (Chuck Musciano) Posting-number: Volume 2, Issue 21 Archive-name: contool3.0/part02 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 2 (of 6)." # Contents: contool_ui.h lex.c logging.c misc.c parse.y regexp.c # store.c # Wrapped by chuck@melmac on Fri Aug 17 10:00:51 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'contool_ui.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'contool_ui.h'\" else echo shar: Extracting \"'contool_ui.h'\" \(5115 characters\) sed "s/^X//" >'contool_ui.h' <<'END_OF_FILE' X#ifndef contool_HEADER X#define contool_HEADER X X/* X * contool_ui.h - User interface object and function declarations. X * This file was generated by `gxv' from `contool.G'. X * DO NOT EDIT BY HAND. X */ X Xextern Attr_attribute INSTANCE; X Xextern Xv_opaque contool_file_menu_create(); Xextern Xv_opaque contool_view_menu_create(); Xextern Xv_opaque contool_edit_menu_create(); Xextern Xv_opaque contool_filter_insert_menu_create(); Xextern Xv_opaque contool_filter_edit_menu_create(); Xextern Xv_opaque contool_filter_paste_menu_create(); X Xtypedef struct { X Xv_opaque base; X Xv_opaque contool_controls; X Xv_opaque file; X Xv_opaque view; X Xv_opaque edit; X Xv_opaque display; X} contool_base_objects; X Xextern contool_base_objects *contool_base_objects_initialize(); X Xextern Xv_opaque contool_base_base_create(); Xextern Xv_opaque contool_base_contool_controls_create(); Xextern Xv_opaque contool_base_file_create(); Xextern Xv_opaque contool_base_view_create(); Xextern Xv_opaque contool_base_edit_create(); Xextern Xv_opaque contool_base_display_create(); X Xtypedef struct { X Xv_opaque props; X Xv_opaque prop_controls; X Xv_opaque default_action; X Xv_opaque default_beep_count; X Xv_opaque default_beep_times; X Xv_opaque default_command; X Xv_opaque log_file; X Xv_opaque log_style; X Xv_opaque print_filter; X Xv_opaque good_icon; X Xv_opaque bad_icon; X Xv_opaque flash_icon; X Xv_opaque stamp_resolution; X Xv_opaque message2; X Xv_opaque max_message; X Xv_opaque message3; X Xv_opaque delete_amount; X Xv_opaque message4; X Xv_opaque props_apply; X Xv_opaque props_reset; X} contool_props_objects; X Xextern contool_props_objects *contool_props_objects_initialize(); X Xextern Xv_opaque contool_props_props_create(); Xextern Xv_opaque contool_props_prop_controls_create(); Xextern Xv_opaque contool_props_default_action_create(); Xextern Xv_opaque contool_props_default_beep_count_create(); Xextern Xv_opaque contool_props_default_beep_times_create(); Xextern Xv_opaque contool_props_default_command_create(); Xextern Xv_opaque contool_props_log_file_create(); Xextern Xv_opaque contool_props_log_style_create(); Xextern Xv_opaque contool_props_print_filter_create(); Xextern Xv_opaque contool_props_good_icon_create(); Xextern Xv_opaque contool_props_bad_icon_create(); Xextern Xv_opaque contool_props_flash_icon_create(); Xextern Xv_opaque contool_props_stamp_resolution_create(); Xextern Xv_opaque contool_props_message2_create(); Xextern Xv_opaque contool_props_max_message_create(); Xextern Xv_opaque contool_props_message3_create(); Xextern Xv_opaque contool_props_delete_amount_create(); Xextern Xv_opaque contool_props_message4_create(); Xextern Xv_opaque contool_props_props_apply_create(); Xextern Xv_opaque contool_props_props_reset_create(); X Xtypedef struct { X Xv_opaque filters; X Xv_opaque filter_controls; X Xv_opaque filter_list; X Xv_opaque filter_insert; X Xv_opaque filter_edit; X Xv_opaque filter_update; X Xv_opaque filter_type; X Xv_opaque start; X Xv_opaque stop; X Xv_opaque comment; X Xv_opaque ignore; X Xv_opaque action; X Xv_opaque filter_beep_count; X Xv_opaque filter_beep_times; X Xv_opaque filter_command; X Xv_opaque filters_apply; X Xv_opaque filters_reset; X} contool_filters_objects; X Xextern contool_filters_objects *contool_filters_objects_initialize(); X Xextern Xv_opaque contool_filters_filters_create(); Xextern Xv_opaque contool_filters_filter_controls_create(); Xextern Xv_opaque contool_filters_filter_list_create(); Xextern Xv_opaque contool_filters_filter_insert_create(); Xextern Xv_opaque contool_filters_filter_edit_create(); Xextern Xv_opaque contool_filters_filter_update_create(); Xextern Xv_opaque contool_filters_filter_type_create(); Xextern Xv_opaque contool_filters_start_create(); Xextern Xv_opaque contool_filters_stop_create(); Xextern Xv_opaque contool_filters_comment_create(); Xextern Xv_opaque contool_filters_ignore_create(); Xextern Xv_opaque contool_filters_action_create(); Xextern Xv_opaque contool_filters_filter_beep_count_create(); Xextern Xv_opaque contool_filters_filter_beep_times_create(); Xextern Xv_opaque contool_filters_filter_command_create(); Xextern Xv_opaque contool_filters_filters_apply_create(); Xextern Xv_opaque contool_filters_filters_reset_create(); X Xtypedef struct { X Xv_opaque load; X Xv_opaque load_controls; X Xv_opaque load_type; X Xv_opaque load_file; X Xv_opaque accept_load; X} contool_load_objects; X Xextern contool_load_objects *contool_load_objects_initialize(); X Xextern Xv_opaque contool_load_load_create(); Xextern Xv_opaque contool_load_load_controls_create(); Xextern Xv_opaque contool_load_load_type_create(); Xextern Xv_opaque contool_load_load_file_create(); Xextern Xv_opaque contool_load_accept_load_create(); X Xtypedef struct { X Xv_opaque store; X Xv_opaque store_controls; X Xv_opaque store_type; X Xv_opaque store_file; X Xv_opaque accept_store; X} contool_store_objects; X Xextern contool_store_objects *contool_store_objects_initialize(); X Xextern Xv_opaque contool_store_store_create(); Xextern Xv_opaque contool_store_store_controls_create(); Xextern Xv_opaque contool_store_store_type_create(); Xextern Xv_opaque contool_store_store_file_create(); Xextern Xv_opaque contool_store_accept_store_create(); X#endif END_OF_FILE if test 5115 -ne `wc -c <'contool_ui.h'`; then echo shar: \"'contool_ui.h'\" unpacked with wrong size! fi # end of 'contool_ui.h' fi if test -f 'lex.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'lex.c'\" else echo shar: Extracting \"'lex.c'\" \(6635 characters\) sed "s/^X//" >'lex.c' <<'END_OF_FILE' X/************************************************************************/ X/* Copyright 1988-1990 by Chuck Musciano and Harris Corporation */ X/* */ X/* Permission to use, copy, modify, and distribute this software */ X/* and its documentation for any purpose and without fee is */ X/* hereby granted, provided that the above copyright notice */ X/* appear in all copies and that both that copyright notice and */ X/* this permission notice appear in supporting documentation, and */ X/* that the name of Chuck Musciano and Harris Corporation not be */ X/* used in advertising or publicity pertaining to distribution */ X/* of the software without specific, written prior permission. */ X/* Chuck Musciano and Harris Corporation make no representations */ X/* about the suitability of this software for any purpose. It is */ X/* provided "as is" without express or implied warranty. This */ X/* software may not be sold without the prior explicit permission */ X/* of Harris Corporation. */ X/************************************************************************/ X X#define RETURN(x) return(last_token = (x)) X X#define FIRST_KEYWORD BEEP X#define LAST_KEYWORD YES X#define NUM_KEYWORDS (LAST_KEYWORD - FIRST_KEYWORD + 1) X XPRIVATE FILE *f = NULL; XPRIVATE int last_token = -1; XPRIVATE char buf[1024]; X XPRIVATE struct {char *name; X int value; X } token[] = {{"beep", BEEP}, X {"check_icon", CHECK_ICON}, X {"command", COMMAND}, X {"comment", COMMENT}, X {"defaults", DEFAULTS}, X {"delete", DELETE}, X {"display", DISPLAY}, X {"filters", FILTERS}, X {"flash", FLASH}, X {"flash_icon", FLASH_ICON}, X {"good_icon", GOOD_ICON}, X {"ignore", IGNORE}, X {"log_before_filtering", LOG_BEFORE_FILTERING}, X {"log_file", LOG_FILE}, X {"match", MATCH}, X {"no" , NO}, X {"noflash", NOFLASH}, X {"noopen", NOOPEN}, X {"nostamp", NOSTAMP}, X {"open", OPEN}, X {"print", PRINT}, X {"save", SAVE}, X {"stamp", STAMP}, X {"timestamp", TIMESTAMP}, X {"to", TO}, X {"yes", YES}}; X XPRIVATE struct {char first; X char next; X int name; X } punc[] = {{'{', '\0', LBRACE}, X {'}', '\0', RBRACE}, X {'\0', '\0', -1}}; X X/************************************************************************/ XEXPORT int lex_init(path) X Xchar *path; X X{ X if (f) X fclose(f); X if (f = fopen(path, "r")) { X curr_file = strsave(path); X line_count = 1; X ungetc = -1; X parse_errors_occured = 0; X return(TRUE); X } X else X return(FALSE); X} X X/************************************************************************/ XPRIVATE char getch() X X{ register char c; X static int first = TRUE; X X if (ungetc != -1) X c = ungetc, ungetc = -1; X else { X c = getc(f); X if (c == '\n') X line_count++; X } X return(c); X} X X/************************************************************************/ XPRIVATE fix_escapes(buf) X Xchar *buf; X X{ char *q; X int i; X X for (q = buf; *buf; buf++, q++) X if (*buf == '\\') X *q = *++buf; X else X *q = *buf; X *q = '\0'; X} X X/************************************************************************/ XPRIVATE int is_keyword(s) X Xchar *s; X X{ register int cmp, high, low, pos; X X for (low = 0, high = NUM_KEYWORDS - 1; low <= high; ) X if ((cmp = strcmp(s, token[pos = (high - low) / 2 + low].name)) == 0) X return(token[pos].value); X else if (cmp < 0) X high = pos - 1; X else X low = pos + 1; X return(NULL); X} X X/************************************************************************/ XPRIVATE int yylex() X X{ register char c, c1, *p; X register int i, j, val; X char *index(); X double atof(); X X c = getch(); X while (isspace(c)) X c = getch(); X if (isalpha(c)) { X p = buf; X *p++ = c; X while (isalnum(c = getch()) || c == '_') X *p++ = c; X ungetc = c; X *p = '\0'; X for (p = buf; *p; p++) X if (isupper(*p)) X *p = tolower(*p); X if (i = is_keyword(buf)) X RETURN(i); X else { X yyerror("unexpected keyword: %s", buf); X fclose(f); X f = NULL; X RETURN(EOF); X } X } X else if (c == '"' || c == '\'') { X for (p = buf; TRUE; p++) X if ((*p = getch()) == c) X break; X else if (*p == '\\') X *++p = getch(); X else if (*p == '\n' || *p == '\r') { X yyerror("Newline in string not allowed"); X break; X } X *p = '\0'; X fix_escapes(buf); X yylval.cpval = strsave(buf); X RETURN(STRING); X } X else if (isdigit(c)) { X p = buf; X *p++ = c; X while (isdigit(c = getch())) X *p++ = c; X *p = '\0'; X ungetc = c; X yylval.ival = atoi(buf); X RETURN(INTEGER); X } X else if (c == '#') { X while ((c = getch()) != '\n' && c != EOF) X ; X if (c == EOF) { X fclose(f); X f = NULL; X RETURN(EOF); X } X else X RETURN(yylex()); X } X else if (c == EOF) { X fclose(f); X f = NULL; X RETURN(EOF); X } X else { X for (i = 0; punc[i].first; i++) X if (c == punc[i].first) { X for (c1 = getch(), j = 1; punc[i + j].first == c; j++) X if (c1 == punc[i + j].next) X RETURN(punc[i + j].name); X ungetc = c1; X RETURN(punc[i].name); X } X yyerror("Invalid character in source file: %c (0x%02x)", c, c); X } X RETURN(yylex()); X} X X/************************************************************************/ XPRIVATE char *get_last_token() X X{ int i; X static char msg[512]; X X if (last_token == INTEGER || last_token == STRING) X sprintf(msg, "\"%s\"", buf); X else if (last_token >= LBRACE && last_token <= RBRACE) { X for (i = 0; punc[i].first; i++) X if (punc[i].name == last_token) { X sprintf(msg, "\"%c\"", punc[i].first); X if (punc[i].next) X sprintf(msg + 2, "%c\"", punc[i].next); X break; X } X if (punc[i].first == '\0') X sprintf(msg, "!!Geez! Some punctuation, I don't know!!"); X } X else if (last_token >= FIRST_KEYWORD && last_token <= LAST_KEYWORD) X sprintf(msg, "\"%s\"", token[last_token - FIRST_KEYWORD].name); X else if (last_token == EOF) X sprintf(msg, "End Of File"); X else X sprintf(msg, "!!Geez! Some keyword, I don't know!!"); X return(msg); X} END_OF_FILE if test 6635 -ne `wc -c <'lex.c'`; then echo shar: \"'lex.c'\" unpacked with wrong size! fi # end of 'lex.c' fi if test -f 'logging.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'logging.c'\" else echo shar: Extracting \"'logging.c'\" \(4036 characters\) sed "s/^X//" >'logging.c' <<'END_OF_FILE' X/************************************************************************/ X/* Copyright 1988-1990 by Chuck Musciano and Harris Corporation */ X/* */ X/* Permission to use, copy, modify, and distribute this software */ X/* and its documentation for any purpose and without fee is */ X/* hereby granted, provided that the above copyright notice */ X/* appear in all copies and that both that copyright notice and */ X/* this permission notice appear in supporting documentation, and */ X/* that the name of Chuck Musciano and Harris Corporation not be */ X/* used in advertising or publicity pertaining to distribution */ X/* of the software without specific, written prior permission. */ X/* Chuck Musciano and Harris Corporation make no representations */ X/* about the suitability of this software for any purpose. It is */ X/* provided "as is" without express or implied warranty. This */ X/* software may not be sold without the prior explicit permission */ X/* of Harris Corporation. */ X/************************************************************************/ X X/************************************************************************/ X/* */ X/* logging.c message log management */ X/* */ X/************************************************************************/ X X#include <stdio.h> X#include <sys/param.h> X#include <sys/types.h> X#include <xview/xview.h> X#include <xview/panel.h> X#include <xview/xv_xrect.h> X X#include "manifest.h" X#include "contool.h" X#include "contool_ui.h" X XPUBLIC Menu_item start_logging(); XPUBLIC Menu_item stop_logging(); X XPUBLIC contool_base_objects *contool_base; X XPRIVATE int logging = FALSE; XPRIVATE FILE *logfile = NULL; XPRIVATE char *log_path = NULL; X X/************************************************************************/ XEXPORT void disable_logging() X X{ X if (logging) { X fclose(logfile); X cond_free(log_path); X log_path = NULL; X logging = FALSE; X } X xv_set(contool_base->base, FRAME_RIGHT_FOOTER, "", NULL); X} X X/************************************************************************/ XEXPORT void enable_logging() X X{ char buf[1024]; X X if (logging) { X if (log_path && strcmp(log_path, defaults.log_file) == 0) X return; X disable_logging(); X } X if (is_empty(defaults.log_file)) X error("You must specify a log file in the Properties dialog"); X else if ((logfile = fopen(defaults.log_file, "a")) == NULL) X error("Cannot open log file %s : %s", defaults.log_file, sys_errlist[errno]); X else { X logging = TRUE; X log_path = strsave(defaults.log_file); X sprintf(buf, "Logging to %s...", defaults.log_file); X xv_set(contool_base->base, FRAME_RIGHT_FOOTER, buf, NULL); X } X} X X/************************************************************************/ XEXPORT Menu_item start_logging(item, op) X XMenu_item item; XMenu_generate op; X X{ contool_base_objects *ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); X X if (op == MENU_DISPLAY) X xv_set(item, MENU_INACTIVE, logging, NULL); X else if (op == MENU_NOTIFY) X enable_logging(); X return item; X} X X/************************************************************************/ XEXPORT Menu_item stop_logging(item, op) X XMenu_item item; XMenu_generate op; X X{ contool_base_objects *ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); X X if (op == MENU_DISPLAY) X xv_set(item, MENU_INACTIVE, !logging, NULL); X else if (op == MENU_NOTIFY) X disable_logging(); X return item; X} X X/************************************************************************/ XEXPORT update_logging() X X{ X if (logging) { X disable_logging(); X enable_logging(); X } X} X X/************************************************************************/ XEXPORT write_log(s) X Xchar *s; X X{ int t; X static char hostname[100] = ""; X X if (logging) { X if (*hostname == NULL) X if (gethostname(hostname, 99) != 0) X strcpy(hostname, "(unknown)"); X t = time(0); X fseek(logfile, 0L, 2); X fprintf(logfile, "%s\t%.16s\t%s", hostname, ctime(&t) + 4, s); X fflush(logfile); X } X} END_OF_FILE if test 4036 -ne `wc -c <'logging.c'`; then echo shar: \"'logging.c'\" unpacked with wrong size! fi # end of 'logging.c' fi if test -f 'misc.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'misc.c'\" else echo shar: Extracting \"'misc.c'\" \(6150 characters\) sed "s/^X//" >'misc.c' <<'END_OF_FILE' X/************************************************************************/ X/* Copyright 1988-1990 by Chuck Musciano and Harris Corporation */ X/* */ X/* Permission to use, copy, modify, and distribute this software */ X/* and its documentation for any purpose and without fee is */ X/* hereby granted, provided that the above copyright notice */ X/* appear in all copies and that both that copyright notice and */ X/* this permission notice appear in supporting documentation, and */ X/* that the name of Chuck Musciano and Harris Corporation not be */ X/* used in advertising or publicity pertaining to distribution */ X/* of the software without specific, written prior permission. */ X/* Chuck Musciano and Harris Corporation make no representations */ X/* about the suitability of this software for any purpose. It is */ X/* provided "as is" without express or implied warranty. This */ X/* software may not be sold without the prior explicit permission */ X/* of Harris Corporation. */ X/************************************************************************/ X X#include <stdio.h> X#include <ctype.h> X#include <pwd.h> X X#include "manifest.h" X#include "contool.h" X X/************************************************************************/ XEXPORT int getline(stream, string, max) X XFILE *stream; Xchar *string; Xint max; X X{ register int i, j; X X i = (int) fgets(string, max, stream); X if (i == NULL) X return(EOF); X j = strlen(string); X if (j > 0 && string[j - 1] == '\n') X string[--j] = '\0'; X return(j); X} X X/************************************************************************/ XPRIVATE delarg(argc, argv) X Xint *argc; Xchar **argv; X X{ char *p; X X while (*argv = *(argv+1)) X argv++; X (*argc)--; X} X X/************************************************************************/ XEXPORT char getopt(argc, argv, opts, parm) X Xint *argc; Xchar **argv; Xchar *opts; Xchar **parm; X X{ char c, *p, *strcpy(), *index(); X int killed; X X *parm = NULL; X while (*argv && ((**argv != '-') || (*(*argv+1) == '\0'))) X argv++; X if (*argv == NULL) X return(EOF); X c = *(*argv+1); X *++(*argv) = '-'; X if (killed = (*(*argv+1) == '\0')) X delarg(argc, argv); X if ((p = index(opts, c)) == NULL) X c = '\0'; X else if (*(p+1) == ':') { X *parm = killed ? *argv : *argv+1; X delarg(argc, argv); X } X return(c); X} X X/************************************************************************/ XEXPORT int verify(source, valid) X Xchar *source; Xchar *valid; X X{ register char *s; X X for ( ; *source; source++) { X for (s = valid; *s && *s != *source; s++) X ; X if (*s == '\0') X return(0); X } X return(1); X} X X/************************************************************************/ XEXPORT char **saveargs(argc, argv) X Xint argc; Xchar **argv; X X{ int i; X char **copy; X X copy = (char **) malloc((argc + 1) * sizeof(char *)); X for (i = 0; i < argc; i++) X strcpy(copy[i] = (char *) malloc(strlen(argv[i]) + 1), argv[i]); X copy[i] = (char *) 0; X return(copy); X} X X#define SIZE_INCREMENT 8 X X/************************************************************************/ XEXPORT char **tokenize(line, argc) X Xchar *line; Xint *argc; X X{ char match, **argv, *buf, *p; X int limit; X X buf = (char *) malloc(strlen(line) + 1); X *argc = 0; X argv = (char **) malloc((limit = SIZE_INCREMENT) * sizeof(char *)); X while (*line) { X while (isspace(*line)) X line++; X switch (*line) { X case '"' : X case '\'' : match = *line++; /* remove the quote mark */ X for (p = buf; *line && (*line != match); ) { X if (*line == '\\') X line++; X if (*line) X *p++ = *line++; X } X if (*line) X line++; /* wipe out quote mark */ X break; X default : for (p = buf; *line && !isspace(*line) && (*line != '"') && (*line != '\''); ) X *p++ = *line++; X break; X } X *p = '\0'; X if (*buf) { X argv[(*argc)++] = strsave(buf); X if (*argc == limit) X argv = (char **) realloc(argv, (limit += SIZE_INCREMENT) * sizeof(char *)); X } X } X free(buf); X argv[*argc] = (char *) 0; X return(argv); X} X X#define P_POS 5 X#define L_POS 8 X#define D_POS 9 X X#define PATH "/dev/ptyp0" X#define LETTERS "pqr" X#define DIGITS "0123456789abcdef" X XPRIVATE char path[12]; X X/************************************************************************/ XEXPORT char *open_psuedo_tty(master, m_mode, slave, s_mode) X XFILE **master; Xchar *m_mode; XFILE **slave; Xchar *s_mode; X X{ char *s, *t; X X strcpy(path, PATH); X for (s = LETTERS; *s && *master == NULL; s++) { X path[L_POS] = *s; X for (t = DIGITS; *t && *master == NULL; t++) { X path[D_POS] = *t; X *master = fopen(path, m_mode); X } X } X if (*master != NULL) { X path[P_POS] = 't'; X *slave = fopen(path, s_mode); X path[P_POS] = 'p'; X } X return(path); X} X X/************************************************************************/ XEXPORT char *expand_tilde(path) X Xchar *path; X X{ char s[1024], *p; X struct passwd *pw; X X if (*path == '~') { X if (path[1] == '/' || path[1] == '\0') { X strcpy(s, getenv("HOME")); X strcat(s, path + 1); X } X else { X if ((p = index(path, '/')) != NULL) X *p = '\0'; X if ((pw = getpwnam(path + 1)) != NULL) { X strcpy(s, pw->pw_dir); X if (p != NULL) { X strcat(s, "/"); X strcat(s, p + 1); X } X } X else { X if (p != NULL) X *p = '/'; X strcpy(s, path); X } X } X return(strsave(s)); X } X else X return(strsave(path)); X} X X/************************************************************************/ XEXPORT int is_empty(s) X Xchar *s; X X{ X if (s == NULL) X return(TRUE); X for (; *s; s++) X if (!isspace(*s)) X return(FALSE); X return(TRUE); X} X X/************************************************************************/ XEXPORT char *check_escapes(s) X Xchar *s; X X{ static char buf[1024]; X char *p; X X for (p = buf; *s; s++, p++) X if (*s == '\\' || *s == '"') { X *p++ = '\\'; X *p = *s; X } X else X *p = *s; X *p = '\0'; X return(buf); X} END_OF_FILE if test 6150 -ne `wc -c <'misc.c'`; then echo shar: \"'misc.c'\" unpacked with wrong size! fi # end of 'misc.c' fi if test -f 'parse.y' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'parse.y'\" else echo shar: Extracting \"'parse.y'\" \(6942 characters\) sed "s/^X//" >'parse.y' <<'END_OF_FILE' X/************************************************************************/ X/* Copyright 1988-1990 by Chuck Musciano and Harris Corporation */ X/* */ X/* Permission to use, copy, modify, and distribute this software */ X/* and its documentation for any purpose and without fee is */ X/* hereby granted, provided that the above copyright notice */ X/* appear in all copies and that both that copyright notice and */ X/* this permission notice appear in supporting documentation, and */ X/* that the name of Chuck Musciano and Harris Corporation not be */ X/* used in advertising or publicity pertaining to distribution */ X/* of the software without specific, written prior permission. */ X/* Chuck Musciano and Harris Corporation make no representations */ X/* about the suitability of this software for any purpose. It is */ X/* provided "as is" without express or implied warranty. This */ X/* software may not be sold without the prior explicit permission */ X/* of Harris Corporation. */ X/************************************************************************/ X X%{ X X#include <stdio.h> X#include <ctype.h> X X#include "manifest.h" X#include "contool.h" X XEXPORT Props *parsed_defaults; XEXPORT Filter *parsed_filters; X XEXPORT int parse_errors_occured; X XPRIVATE char *get_last_token(); X XPRIVATE Filter *curr; XPRIVATE char *curr_file; XPRIVATE int line_count = 1; XPRIVATE char ungetc = -1; X X%} X X%start configuration X X%union {char *cpval; X int ival; X Filter *fval; X Props *pval; X } X X%token <cpval> STRING X%token <ival> INTEGER X X%token LBRACE RBRACE X X%token BEEP CHECK_ICON COMMAND COMMENT DEFAULTS DELETE DISPLAY FILTERS X FLASH FLASH_ICON GOOD_ICON IGNORE LOG_BEFORE_FILTERING LOG_FILE X MATCH NO NOFLASH NOOPEN NOSTAMP OPEN PRINT SAVE STAMP TIMESTAMP TO YES X X%type <ival> beep flash old_flash old_open old_stamp open stamp yes_no X%type <cpval> command old_end_string string X%type <fval> filter filter_list old_filter old_filter_list old_ignore old_save X X%% X Xconfiguration : empty X | old_style X | new_style X ; X Xold_style : old_filter_list X { parsed_defaults = NULL; X parsed_filters = $1; X } X ; X Xold_filter_list : old_filter X { $$ = $1; } X | old_filter_list old_filter X { Filter *f; X X for (f = $1; f->next; f = f->next) X ; X f->next = $2; X $$ = $1; X } X ; X Xold_filter : old_save X | old_ignore X ; X Xold_save : SAVE beep old_flash old_open old_stamp STRING old_end_string X { Filter *f; X char *msg; X X f = (Filter *) malloc(sizeof(Filter)); X f->save = TRUE; X f->beep = $2; X f->flash = $3; X f->open = $4; X f->stamp = $5; X f->start = $6; X f->stop = $7; X f->start_re = NULL; X f->stop_re = NULL; X f->command = NULL; X f->comment = NULL; X f->next = NULL; X if (msg = compile_exp(f, f->start, f->stop)) X yyerror(msg); X $$ = f; X } X ; X Xold_ignore : IGNORE STRING old_end_string X { Filter *f; X char *msg; X X f = (Filter *) malloc(sizeof(Filter)); X f->save = FALSE; X f->beep = 0; X f->flash = FALSE; X f->open = FALSE; X f->stamp = FALSE; X f->start = $2; X f->stop = $3; X f->start_re = NULL; X f->stop_re = NULL; X f->command = NULL; X f->comment = NULL; X f->next = NULL; X if (msg = compile_exp(f, f->start, f->stop)) X yyerror(msg); X $$ = f; X } X ; X Xold_flash : FLASH X { $$ = TRUE; } X | NOFLASH X { $$ = FALSE; } X ; X Xold_open : OPEN X { $$ = TRUE; } X | NOOPEN X { $$ = FALSE; } X ; X Xold_stamp : STAMP X { $$ = TRUE; } X | NOSTAMP X { $$ = FALSE; } X ; X Xold_end_string : empty X { $$ = NULL; } X | TO STRING X { $$ = $2; } X ; X Xnew_style : defaults X | filters X | defaults filters X ; X Xdefaults : DEFAULTS X { parsed_defaults = (Props *) malloc(sizeof(Props)); X *parsed_defaults = defaults; X } X LBRACE default_list RBRACE X ; X Xfilters : FILTERS LBRACE filter_list RBRACE X { parsed_filters = $3; } X ; X Xdefault_list : empty X | default_list default X ; X Xdefault : beep X { parsed_defaults->beep = $1; } X | command X { parsed_defaults->command = $1; } X | flash X { parsed_defaults->flash = $1; } X | open X { parsed_defaults->open = $1; } X | stamp X { parsed_defaults->stamp = $1; } X | CHECK_ICON string X { parsed_defaults->bad_icon = $2; } X | DELETE INTEGER X { parsed_defaults->delete_amount = $2; } X | DISPLAY INTEGER X { parsed_defaults->max_size = $2; } X | FLASH_ICON string X { parsed_defaults->flash_icon = $2; } X | GOOD_ICON string X { parsed_defaults->good_icon = $2; } X | LOG_BEFORE_FILTERING yes_no X { parsed_defaults->log_after = !$2; } X | LOG_FILE string X { parsed_defaults->log_file = $2; } X | PRINT STRING X { parsed_defaults->print_filter = $2; } X | TIMESTAMP INTEGER X { parsed_defaults->stamp_resolution = $2; } X ; X Xfilter_list : empty X { $$ = NULL; } X | filter_list filter X { Filter *f; X X if ($1 == NULL) X $$ = $2; X else { X for (f = $1; f->next; f = f->next) X ; X f->next = $2; X $$ = $1; X } X } X ; X Xfilter : LBRACE X { curr = (Filter *) malloc(sizeof(Filter)); X bzero(curr, sizeof(Filter)); X } X filter_attr_list RBRACE X { char *msg; X X if (curr->start == NULL) X yyerror("no filter pattern specified"); X if (msg = compile_exp(curr, curr->start, curr->stop)) X yyerror(msg); X $$ = curr; X } X ; X Xfilter_attr_list: empty X | filter_attr_list filter_attr X ; X Xfilter_attr : beep X { curr->beep = $1; } X | command X { curr->command = $1; } X | flash X { curr->flash = $1; } X | open X { curr->open = $1; } X | stamp X { curr->stamp = $1; } X | COMMENT string X { curr->comment = $2; } X | IGNORE yes_no X { curr->save = !$2; } X | MATCH string X { curr->start = $2; } X | TO string X { curr->stop = $2; } X ; X Xbeep : BEEP INTEGER X { $$ = $2; } X ; X Xcommand : COMMAND string X { $$ = $2; } X ; Xflash : FLASH yes_no X { $$ = $2; } X ; X Xopen : OPEN yes_no X { $$ = $2; } X ; X Xstamp : STAMP yes_no X { $$ = $2; } X ; X Xyes_no : YES X { $$ = TRUE; } X | NO X { $$ = FALSE; } X ; X Xstring : STRING X { $$ = (*$1 == '\0')? NULL : $1; } X ; X Xempty : ; X X%% X X/************************************************************************/ XPRIVATE yyerror(s1, s2, s3, s4, s5, s6, s7) X Xchar *s1, *s2, *s3, *s4, *s5, *s6, *s7; X X{ char buf1[1024], buf2[1024]; X X sprintf(buf1, "%s: line %d: ", curr_file, line_count - ((ungetc == '\n')? 1 : 0)); X sprintf(buf2, s1, s2, s3, s4, s5, s6, s7); X strcat(buf1, buf2); X if (strcmp(s1, "syntax error") == 0) { X strcat(buf1, " at or near "); X strcat(buf1, get_last_token()); X } X error(buf1); X yyclearin; X parse_errors_occured++; X} X X#include "lex.c" END_OF_FILE if test 6942 -ne `wc -c <'parse.y'`; then echo shar: \"'parse.y'\" unpacked with wrong size! fi # end of 'parse.y' fi if test -f 'regexp.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'regexp.c'\" else echo shar: Extracting \"'regexp.c'\" \(3483 characters\) sed "s/^X//" >'regexp.c' <<'END_OF_FILE' X/************************************************************************/ X/* Copyright 1988-1990 by Chuck Musciano and Harris Corporation */ X/* */ X/* Permission to use, copy, modify, and distribute this software */ X/* and its documentation for any purpose and without fee is */ X/* hereby granted, provided that the above copyright notice */ X/* appear in all copies and that both that copyright notice and */ X/* this permission notice appear in supporting documentation, and */ X/* that the name of Chuck Musciano and Harris Corporation not be */ X/* used in advertising or publicity pertaining to distribution */ X/* of the software without specific, written prior permission. */ X/* Chuck Musciano and Harris Corporation make no representations */ X/* about the suitability of this software for any purpose. It is */ X/* provided "as is" without express or implied warranty. This */ X/* software may not be sold without the prior explicit permission */ X/* of Harris Corporation. */ X/************************************************************************/ X X#include <stdio.h> X X#include "manifest.h" X#include "contool.h" X XPRIVATE regexp_error(); X X#define INIT register char *expbuf = ep, *sp = instring; X#define GETC() (*sp++) X#define PEEKC() (*sp) X#define UNGETC(c) (--sp) X#define RETURN(p) {bcopy(expbuf, sp = (char *) malloc(p - expbuf), p - expbuf); return(sp);} X#define ERROR(val) {regexp_error(val, instring); return(NULL);} X X#include <regexp.h> X XPRIVATE char error_message[512]; X X/************************************************************************/ XEXPORT int match_exp(exp, circ, str) X Xchar *exp; Xint circ; Xchar *str; X X{ char *p; X int result; X X p = str + strlen(str) - 1; X if (p >= str && *p == '\n') X *p = '\0'; X circf = circ; X result = step(str, exp); X if (p >= str && *p == '\0') X *p = '\n'; X return(result); X} X X/************************************************************************/ XPRIVATE regexp_error(val, string) X Xint val; Xchar *string; X X{ char *msg; X X switch (val) { X case 11 : msg = "range endpoint too large"; X case 16 : msg = "bad number"; X case 25 : msg = "\"\\digit\" out of range"; X case 36 : msg = "illegal or missing delimiter"; X case 41 : msg = "no remembered search string"; X case 42 : msg = "\\(\\) imbalance"; X case 43 : msg = "too many \\("; X case 44 : msg = "more than 2 numbers given in \\{\\}"; X case 45 : msg = "} expected after \\"; X case 46 : msg = "first number exceeds second in \\{\\}"; X case 49 : msg = "[] imbalance"; X case 50 : msg = "regular expression overflow"; X default : msg = "regular expression error"; X } X sprintf(error_message, "%s in %s", msg, string); X} X X/************************************************************************/ XEXPORT char *compile_exp(filter, start, stop) X XFilter *filter; Xchar *start; Xchar *stop; X X{ char rbuf[1024], *sre, *ere; X int sc, ec; X X sre = ere = NULL; X if (start) { X if ((sre = compile(start, rbuf, rbuf+1024, '\0')) == NULL) X return(error_message); X sc = circf; X } X if (stop) { X if ((ere = compile(stop, rbuf, rbuf+1024, '\0')) == NULL) { X cond_free(sre); X return(error_message); X } X ec = circf; X } X if (filter) { X filter->start = start; X filter->stop = stop; X filter->start_re = sre; X filter->stop_re = ere; X filter->start_circf = sc; X filter->stop_circf = ec; X } X else { X cond_free(sre); X if (ere) X cond_free(ere); X } X return(NULL); X} END_OF_FILE if test 3483 -ne `wc -c <'regexp.c'`; then echo shar: \"'regexp.c'\" unpacked with wrong size! fi # end of 'regexp.c' fi if test -f 'store.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'store.c'\" else echo shar: Extracting \"'store.c'\" \(5792 characters\) sed "s/^X//" >'store.c' <<'END_OF_FILE' X/************************************************************************/ X/* Copyright 1988-1990 by Chuck Musciano and Harris Corporation */ X/* */ X/* Permission to use, copy, modify, and distribute this software */ X/* and its documentation for any purpose and without fee is */ X/* hereby granted, provided that the above copyright notice */ X/* appear in all copies and that both that copyright notice and */ X/* this permission notice appear in supporting documentation, and */ X/* that the name of Chuck Musciano and Harris Corporation not be */ X/* used in advertising or publicity pertaining to distribution */ X/* of the software without specific, written prior permission. */ X/* Chuck Musciano and Harris Corporation make no representations */ X/* about the suitability of this software for any purpose. It is */ X/* provided "as is" without express or implied warranty. This */ X/* software may not be sold without the prior explicit permission */ X/* of Harris Corporation. */ X/************************************************************************/ X X/************************************************************************/ X/* */ X/* store.c contool store dialog manager */ X/* */ X/************************************************************************/ X X#include <stdio.h> X#include <ctype.h> X#include <sys/param.h> X#include <sys/types.h> X#include <sys/file.h> X#include <xview/xview.h> X#include <xview/panel.h> X#include <xview/notice.h> X#include <xview/xv_xrect.h> X X#include "manifest.h" X#include "contool.h" X#include "contool_ui.h" X X#define yes_no(x) ((x)? "yes" : "no") X XPUBLIC contool_base_objects *contool_base; X XPRIVATE contool_store_objects *contool_store = NULL; X X/************************************************************************/ XEXPORT Menu_item popup_save_config(item, op) X XMenu_item item; XMenu_generate op; X X{ contool_base_objects * ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); X X if (op == MENU_NOTIFY) { X if (contool_store == NULL) { X contool_store = contool_store_objects_initialize(NULL, ip->base); X xv_set(contool_store->store_file, X PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED, X PANEL_NOTIFY_STRING, "\n\r ", X NULL); X xv_set(contool_store->store_type, PANEL_VALUE, 3, NULL); X place_dialog(ip->base, contool_store->store); X } X xv_set(contool_store->store_file, PANEL_VALUE, filter_file, NULL); X xv_set(contool_store->store, XV_SHOW, TRUE, NULL); X } X return item; X} X X/************************************************************************/ XEXPORT void store_filters(item, event) X XPanel_item item; XEvent *event; X X{ contool_store_objects *ip = (contool_store_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); X char *path, buf[1024]; X FILE *f; X int kind; X Filter *filt; X X path = expand_tilde(xv_get(ip->store_file, PANEL_VALUE)); X if (access(path, W_OK) == 0) { X sprintf(buf, "File \"%s\" exists. You can:", path); X kind = notice_prompt(contool_base->base, NULL, X NOTICE_MESSAGE_STRINGS, buf, NULL, X NOTICE_BUTTON_YES, "Overwrite", X NOTICE_BUTTON_NO, "Cancel", X NULL); X if (kind == 0) { X xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL); X free(path); X return; X } X } X if ((f = fopen(path, "w")) == NULL) { X error("Cannot write to %s: %s", path, sys_errlist[errno]); X xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, NULL); X free(path); X } X else { X kind = (int) xv_get(ip->store_type, PANEL_VALUE); X if (kind & 1) { X fprintf(f, "defaults {\n"); X fprintf(f, " beep %d\n", defaults.beep); X fprintf(f, " command \"%s\"\n", check_escapes(is_null(defaults.command))); X fprintf(f, " flash %s\n", yes_no(defaults.flash)); X fprintf(f, " open %s\n", yes_no(defaults.open)); X fprintf(f, " stamp %s\n", yes_no(defaults.stamp)); X fprintf(f, " good_icon \"%s\"\n", is_null(defaults.good_icon)); X fprintf(f, " check_icon \"%s\"\n", is_null(defaults.bad_icon)); X fprintf(f, " flash_icon \"%s\"\n", is_null(defaults.flash_icon)); X fprintf(f, " print \"%s\"\n", defaults.print_filter); X fprintf(f, " log_file \"%s\"\n", is_null(defaults.log_file)); X fprintf(f, " log_before_filtering %s\n", yes_no(!defaults.log_after)); X fprintf(f, " timestamp %d\n", defaults.stamp_resolution); X fprintf(f, " display %d\n", defaults.max_size); X fprintf(f, " delete %d\n", defaults.delete_amount); X fprintf(f, "}\n"); X } X if (kind & 2) { X fprintf(f, "filters {\n"); X for (filt = filters; filt; filt = filt->next) { X fprintf(f, " {\n"); X fprintf(f, " match \"%s\"\n", check_escapes(filt->start)); X if (filt->stop) X fprintf(f, " to \"%s\"\n", check_escapes(filt->stop)); X if (filt->comment) X fprintf(f, " comment \"%s\"\n", check_escapes(filt->comment)); X if (filt->save) { X fprintf(f, " ignore no\n"); X fprintf(f, " beep %d\n", filt->beep); X fprintf(f, " command \"%s\"\n", check_escapes(is_null(filt->command))); X fprintf(f, " flash %s\n", yes_no(filt->flash)); X fprintf(f, " open %s\n", yes_no(filt->open)); X fprintf(f, " stamp %s\n", yes_no(filt->stamp)); X } X else X fprintf(f, " ignore yes\n"); X fprintf(f, " }\n"); X } X fprintf(f, "}\n"); X } X fclose(f); X filter_file = path; X } X} END_OF_FILE if test 5792 -ne `wc -c <'store.c'`; then echo shar: \"'store.c'\" unpacked with wrong size! fi # end of 'store.c' fi echo shar: End of archive 2 \(of 6\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 Chuck Musciano ARPA : chuck@trantor.harris-atd.com Harris Corporation Usenet: ...!uunet!x102a!trantor!chuck PO Box 37, MS 3A/1912 AT&T : (407) 727-6131 Melbourne, FL 32902 FAX : (407) 727-{5118,5227,4004} I'm glad you asked, son. Being popular is the most important thing in the world. -- Homer Simpson