|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 17398 (0x43f6) Types: TextFile Names: »mic_interface.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« └─⟦d846658bd⟧ └─⟦this⟧ »osimis/smap/mic_interface.c«
/* * Copyright (c) 1988 University College London * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the Department of Computer Science, University College London. * The name of the University may not be used to * endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* SunView osimic interface */ /* * Initially by Andrew Eliasz, modified by George Pavlou * October 1988 */ #include <stdio.h> #include <ctype.h> #include <signal.h> #include <suntool/sunview.h> #include <suntool/panel.h> #include <suntool/tty.h> #include <suntool/scrollbar.h> #include <suntool/seln.h> #include <suntool/textsw.h> #include "isode/rosap.h" #include "msap.h" #include "microscope.h" #include "config.h" #define BUFFERSIZE ((ATTRLEN+1) * 2) char *progname = "osimic"; int display_item_count; int chosen_one; int chosen_flag; char valbuf[32]; int valid_input; AttrPairs *result; Frame base_frame, schema_frame, edit_frame; Panel control_panel, edit_control_panel, edit_panel_win; Panel_item mic_message, mic_panel_win; Panel_item view_button, list_button, modify_button, up_button, down_button, schema_button, quit_button, mod_add_button, mod_remove_button, mod_replace_button, mod_quit_button; Panel_item pos_type_display, pos_value_display; Panel_item new_text_item, mic_panel_entry[100]; Textsw schema_text_win; int view_proc(), list_proc(), up_proc(), down_proc(), modify_proc(), schema_proc(), quit_proc(); int set_proc(), do_add(), do_remove(), do_replace(), do_abort(); AttrPairs *view_mobject(), *list_subords(), *modify_attribute(); Panel_setting do_validate_input(); int terminate(); /* signal handler */ PositionD position; Error error; char host[HOSTLEN+1]; /* local host name */ char *hosts[MAXHOSTS]; /* hosts where SMAs run */ int NofHosts; /* how many */ main (argc, argv) char **argv; int argc; { if (getconfig(hosts, &NofHosts) == NOTOK) advise(NULLCP, "Warning: failed to read configuration file"); if (parse_args (argc, argv) == NOTOK) { advise(NULLCP, "host %s not supported", host); exit(1); } if (init_position (&position, &error) == NOTOK) { advise(NULLCP, "%s", error.err_msg); exit(1); } signal (SIGHUP, terminate); signal (SIGINT, terminate); signal (SIGQUIT, terminate); signal (SIGTERM, terminate); chosen_flag = 1; base_frame = window_create (NULL, FRAME, FRAME_LABEL, "INCA Sunview Microscope Interface", 0); schema_frame = window_create (base_frame, FRAME, FRAME_LABEL, "Read Results", 0); init_control_panel (); init_main_panel (); window_fit (base_frame); init_schema_text_win (); window_fit (schema_frame); window_main_loop (base_frame); terminate (0); } static init_control_panel () { control_panel = window_create (base_frame, PANEL, WIN_ROWS, 8 , WIN_COLUMNS, 90, 0); mic_message = panel_create_item (control_panel , PANEL_TEXT, PANEL_ITEM_X, ATTR_COL(1), PANEL_ITEM_Y, ATTR_ROW(1), PANEL_LAYOUT, PANEL_HORIZONTAL, PANEL_LABEL_BOLD, TRUE, PANEL_LABEL_STRING, "Message : ", PANEL_VALUE, "", 0); view_button = panel_create_item (control_panel, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(1), PANEL_ITEM_Y, ATTR_ROW(3), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "VIEW", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC , view_proc, 0); list_button = panel_create_item (control_panel, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(15), PANEL_ITEM_Y, ATTR_ROW(3), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "LIST", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC , list_proc, 0); up_button = panel_create_item (control_panel, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(30), PANEL_ITEM_Y, ATTR_ROW(3), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "UP", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC , up_proc, 0); down_button = panel_create_item (control_panel, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(45), PANEL_ITEM_Y, ATTR_ROW(3), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "DOWN", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC , down_proc, 0); modify_button = panel_create_item (control_panel, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(60), PANEL_ITEM_Y, ATTR_ROW(3), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "MODIFY", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC , modify_proc, 0); quit_button = panel_create_item (control_panel, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(75), PANEL_ITEM_Y, ATTR_ROW(3), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "QUIT", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC , quit_proc, 0); pos_type_display = panel_create_item (control_panel , PANEL_TEXT, PANEL_ITEM_X, ATTR_COL(1), PANEL_ITEM_Y, ATTR_ROW(5), PANEL_LAYOUT, PANEL_HORIZONTAL, PANEL_LABEL_BOLD, TRUE, PANEL_LABEL_STRING, "Pos_type : ", PANEL_VALUE, position.pos_type, 0); pos_value_display = panel_create_item (control_panel , PANEL_TEXT, PANEL_ITEM_X, ATTR_COL(1), PANEL_ITEM_Y, ATTR_ROW(7), PANEL_LAYOUT, PANEL_HORIZONTAL, PANEL_LABEL_BOLD, TRUE, PANEL_LABEL_STRING, "Pos_value : ", PANEL_VALUE, position.pos_value, 0); } static init_main_panel () { int i; mic_panel_win = window_create (base_frame, PANEL, WIN_ROWS, 20, WIN_COLUMNS, 90, WIN_X, 0, WIN_BELOW, control_panel, WIN_VERTICAL_SCROLLBAR, scrollbar_create(0), 0); for (i = 0; i < 100; i++) mic_panel_entry [i] = (Panel_item ) NULL; display_item_count = 0; } static init_schema_text_win () { schema_text_win = window_create (schema_frame, TEXTSW, WIN_ROWS, 40, WIN_COLUMNS, 60, 0); } static view_proc () { chosen_flag = 1; panel_set (mic_message, PANEL_VALUE, " ", 0); free_attrpairs (result); if ((result = view_mobject (&position, &error)) == (AttrPairs *) NULL) { panel_set (mic_message, PANEL_VALUE, error.err_msg, 0); if (error.err_type == objectDoesNotExist ) { panel_set (pos_type_display, PANEL_VALUE, position.pos_type,0); panel_set (pos_value_display, PANEL_VALUE, position.pos_value, 0); clear_main_panel (); } } else { clear_main_panel (); display_view_results (); } } static list_proc () { panel_set (mic_message, PANEL_VALUE, " ", 0); free_attrpairs (result); if ((result = list_subords (&position, &error)) == (AttrPairs *) NULL) { panel_set (mic_message, PANEL_VALUE, error.err_msg,0); if (error.err_type == objectDoesNotExist ) { panel_set (pos_type_display, PANEL_VALUE, position.pos_type,0); panel_set (pos_value_display, PANEL_VALUE, position.pos_value,0); clear_main_panel (); } } else { clear_main_panel (); display_list_results (); } chosen_flag = 1; } static up_proc () { chosen_flag = 1; panel_set (mic_message, PANEL_VALUE, " ", 0); clear_main_panel (); if (mib_ascend (&position, &error) == NOTOK) panel_set (mic_message, PANEL_VALUE, error.err_msg,0); else { panel_set (pos_type_display, PANEL_VALUE, position.pos_type,0); panel_set (pos_value_display, PANEL_VALUE, position.pos_value,0); } } static down_proc () { panel_set (mic_message, PANEL_VALUE, " ", 0); if (chosen_flag == 0) { if (mib_descend (chosen_one, &position, &error) == NOTOK) panel_set (mic_message, PANEL_VALUE, error.err_msg, 0); else { panel_set (pos_type_display, PANEL_VALUE, position.pos_type, 0); panel_set (pos_value_display, PANEL_VALUE, position.pos_value,0); clear_main_panel (); } } else panel_set (mic_message, PANEL_VALUE, "Error: no currently chosen entry", 0); chosen_flag = 1; } static schema_proc () { char *schema, *create_schema(); schema = create_schema(); textsw_delete (schema_text_win, 0, window_get(schema_text_win, TEXTSW_LENGTH)); window_set(schema_frame, WIN_SHOW, TRUE, 0); textsw_insert(schema_text_win, schema, strlen(schema)); free(schema); } static quit_proc () { terminate(OK); } static modify_proc () { panel_set (mic_message, PANEL_VALUE, " ", 0); if (chosen_flag == 0) { if (check_attribute (chosen_one, &error) == NOTOK) panel_set (mic_message, PANEL_VALUE, error.err_msg, 0); else call_modify (); } else panel_set (mic_message, PANEL_VALUE, "Error: no currently chosen entry", 0); chosen_flag = 1; } static display_view_results () { int i,j; char panel_text_buf[BUFFERSIZE]; AttrPairs *ap_ptr; mic_panel_entry[0] = panel_create_item (mic_panel_win, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(0), PANEL_ITEM_Y, ATTR_ROW(0), PANEL_LABEL_STRING, "Attribute Type \ Attribute Value", PANEL_SHOW_ITEM, TRUE, 0); panel_set (mic_panel_entry[0], PANEL_PAINT, PANEL_CLEAR, 0); for (ap_ptr = result, i = 1; ap_ptr != (AttrPairs *) NULL; ap_ptr = ap_ptr->Next) { panel_text_buf[0] = '\0' ; strcat (panel_text_buf, ap_ptr->attr_type); strcat (panel_text_buf, ap_ptr->attr_value); mic_panel_entry[i] = panel_create_item (mic_panel_win, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(0), PANEL_ITEM_Y, ATTR_ROW(i), PANEL_LABEL_STRING, panel_text_buf, PANEL_CLIENT_DATA, (i - 1), PANEL_NOTIFY_PROC, set_proc, PANEL_SHOW_ITEM, TRUE, 0); panel_set (mic_panel_entry[i++], PANEL_PAINT, PANEL_CLEAR, 0); } display_item_count = i; panel_update_scrolling_size (mic_panel_win); } static display_list_results () { int i,j; char panel_text_buf[BUFFERSIZE]; AttrPairs *ap_ptr; mic_panel_entry[0] = panel_create_item (mic_panel_win, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(0), PANEL_ITEM_Y, ATTR_ROW(0), PANEL_LABEL_STRING, "Subordinate Type \ Subordinate Value", PANEL_SHOW_ITEM, TRUE, 0); panel_set (mic_panel_entry[0], PANEL_PAINT, PANEL_CLEAR, 0); for (ap_ptr = result, i = 1; ap_ptr != (AttrPairs *) NULL; ap_ptr = ap_ptr->Next) { panel_text_buf[0] = '\0'; strcat (panel_text_buf, ap_ptr->attr_type); strcat (panel_text_buf, ap_ptr->attr_value); mic_panel_entry[i] = panel_create_item (mic_panel_win, PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(0), PANEL_ITEM_Y, ATTR_ROW(i), PANEL_LABEL_STRING, panel_text_buf, PANEL_CLIENT_DATA, (i - 1), PANEL_NOTIFY_PROC, set_proc, PANEL_SHOW_ITEM, TRUE, 0); panel_set (mic_panel_entry[i++], PANEL_PAINT, PANEL_CLEAR, 0); } display_item_count = i; panel_update_scrolling_size (mic_panel_win); } static set_proc (item, event) Panel_item item; Event *event; { chosen_one = (int ) panel_get (item, PANEL_CLIENT_DATA); chosen_flag = 0; } static clear_main_panel () { int i; if (display_item_count != 0) { for ( i = 0; i < display_item_count; i++ ) { panel_set (mic_panel_entry[i], PANEL_SHOW_ITEM, FALSE, 0); panel_destroy_item (mic_panel_entry[i]); mic_panel_entry[i] = (Panel_item ) NULL; } panel_update_scrolling_size (mic_panel_win); } display_item_count = 0; } static call_modify () { Frame edit_frame, init_edit_frame(); edit_frame = init_edit_frame (); panel_set (mic_message, PANEL_VALUE, "hit RETURN after you enter value", 0); window_loop (edit_frame); window_set (edit_frame , FRAME_NO_CONFIRM, TRUE, 0); panel_set (mic_message, PANEL_VALUE, " ", 0); window_destroy (edit_frame); clear_main_panel(); display_view_results (); } Frame init_edit_frame () { Frame get_arg_frame; Panel panel; Panel_item message_item, arg_text, yes_button, no_button; int left, top, width, height, i = chosen_one; AttrPairs *attr = result; Rect *r; edit_frame = window_create (0, FRAME, FRAME_SHOW_LABEL, FALSE, 0); edit_control_panel = window_create (edit_frame, PANEL, WIN_ROWS, 3, WIN_COLUMNS, 60, 0); mod_replace_button = panel_create_item (edit_control_panel , PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(1), PANEL_ITEM_Y, ATTR_ROW(1), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "ADD", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC, do_add, 0); mod_add_button = panel_create_item (edit_control_panel , PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(15), PANEL_ITEM_Y, ATTR_ROW(1), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "REMOVE", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC, do_remove, 0); mod_remove_button = panel_create_item (edit_control_panel , PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(30), PANEL_ITEM_Y, ATTR_ROW(1), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "REPLACE", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC, do_replace, 0); mod_quit_button = panel_create_item (edit_control_panel , PANEL_BUTTON, PANEL_ITEM_X, ATTR_COL(45), PANEL_ITEM_Y, ATTR_ROW(1), PANEL_LABEL_IMAGE, panel_button_image(control_panel, "ABORT", 10 , NULL), PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC, do_abort, 0); while (i--) attr = attr->Next; new_text_item = panel_create_item (edit_control_panel , PANEL_TEXT, PANEL_ITEM_X, ATTR_COL(1), PANEL_ITEM_Y, ATTR_ROW(3), PANEL_LABEL_STRING, attr->attr_type, PANEL_VALUE, attr->attr_value, PANEL_SHOW_ITEM, TRUE, PANEL_NOTIFY_PROC, do_validate_input, 0); edit_panel_win = window_create (edit_frame, PANEL, WIN_ROWS,3, WIN_COLUMNS, 60, WIN_X, 0, WIN_BELOW, edit_control_panel, 0); window_fit (edit_control_panel); window_fit (edit_panel_win); window_fit (edit_frame); r = (Rect *) window_get (edit_frame, WIN_SCREEN_RECT ); /* center edit_frame on the screen */ width = (int) window_get ( edit_frame, WIN_WIDTH ); height = (int) window_get ( edit_frame, WIN_HEIGHT ); left = (r->r_width - width) / 2; top = (r->r_height - height) / 2; if (left < 0) left = 0; if (top < 0) top = 0; window_set (edit_frame, WIN_X, left, WIN_Y, top, 0); return edit_frame; } Panel_setting do_validate_input (item, event) Panel_item item; Event *event; { strcpy(valbuf, panel_get_value(item)); if (validate_input(valbuf) == NOTOK) panel_set (mic_message, PANEL_VALUE, "Error: invalid input", 0); else valid_input = TRUE; return (panel_text_notify(item, event)); } static do_add () { AttrPairs *tmpres; panel_set (mic_message, PANEL_VALUE, " ", 0); if (!valid_input) return; if ((tmpres = modify_attribute(chosen_one, m_addValue, valbuf, &position, &error)) == (AttrPairs *) NULL) { panel_set (mic_message, PANEL_VALUE, error.err_msg, 0); if (error.err_type == objectDoesNotExist) { panel_set (pos_type_display, PANEL_VALUE, position.pos_type, 0); panel_set (pos_value_display, PANEL_VALUE, position.pos_value, 0); } if (error.err_type != illegalOperation) { free_attrpairs (result); result = (AttrPairs *) NULL; window_return(); } } else { free_attrpairs (result); result = tmpres; window_set(edit_frame, FRAME_NO_CONFIRM, TRUE, 0); window_return(); } } static do_remove () { AttrPairs *tmpres; panel_set (mic_message, PANEL_VALUE, " ", 0); if (!valid_input) return; if ((tmpres = modify_attribute(chosen_one, m_removeValue, valbuf, &position, &error)) == (AttrPairs *) NULL) { panel_set (mic_message, PANEL_VALUE, error.err_msg, 0); if (error.err_type == objectDoesNotExist) { panel_set (pos_type_display, PANEL_VALUE, position.pos_type, 0); panel_set (pos_value_display, PANEL_VALUE, position.pos_value, 0); } if (error.err_type != illegalOperation) { free_attrpairs (result); result = (AttrPairs *) NULL; window_return(); } } else { free_attrpairs (result); result = tmpres; window_set(edit_frame, FRAME_NO_CONFIRM, TRUE, 0); window_return(); } } static do_replace () { AttrPairs *tmpres; panel_set (mic_message, PANEL_VALUE, " ", 0); if (!valid_input) return; if ((tmpres = modify_attribute(chosen_one, m_replace, valbuf, &position, &error)) == (AttrPairs *) NULL) { panel_set (mic_message, PANEL_VALUE, error.err_msg, 0); if (error.err_type == objectDoesNotExist) { panel_set (pos_type_display, PANEL_VALUE, position.pos_type, 0); panel_set (pos_value_display, PANEL_VALUE, position.pos_value, 0); } if (error.err_type != illegalOperation) { free_attrpairs (result); result = (AttrPairs *) NULL; window_return(); } } else { free_attrpairs (result); result = tmpres; window_set(edit_frame, FRAME_NO_CONFIRM, TRUE, 0); window_return(); } } static do_abort (item, event) Panel_item item; Event *event; { panel_set (mic_message, PANEL_VALUE, " ", 0); window_return (); }