1 /* ***********************************************************
  2    *                                                         *
  3    * Copyright, (C) Honeywell Bull Inc., 1987                *
  4    *                                                         *
  5    * Copyright, (C) Honeywell Information Systems Inc., 1986 *
  6    *                                                         *
  7    *********************************************************** */
  8 
  9 /* HISTORY COMMENTS:
 10   1) change(86-09-26,Lee), approve(87-07-13,MCR7580), audit(87-07-13,Leskiw),
 11      install(87-08-07,MR12.1-1072):
 12      Routines extracted from proc_op.c,
 13       now used by in proc_op.c and dbprocop.c
 14                                                    END HISTORY COMMENTS */
 15 
 16 /* : PROCEDURE FUNCTION (freeze)
 17 
 18 loop until any keyboard character is hit
 19 */
 20 
 21 #include <ctype.h>
 22 #include <ws.h>
 23 #include <ws_dcls.h>
 24 #include <wsmincap.h>
 25 #include <keydefs.h>
 26 #include <emulator.h>
 27 
 28 #if EM_DEBUG                           /* Do NOT compile if !EM_DEBUG */
 29 
 30 extern int em_tab_size;
 31 extern int bg_sender_in;
 32 extern int bg_sender_out;
 33 extern int bg_sender_buff[];
 34 extern char *buff;
 35 
 36 freeze()
 37 {
 38 int i;
 39 int ch;
 40 
 41 /* : if no key was pressed, loop for a while to give clock interrupts a
 42      chance */
 43 
 44    while (!get_kb_key(&ch))
 45       for (i = 0; i < 100; i++);
 46 
 47 }
 48 
 49 /* : PROCEDURE FUNCTION (menu)
 50 
 51 print a summary of the emulator functions
 52 */
 53 
 54 menu()
 55 {
 56 int ch;
 57 
 58    printf ("----------------------------------------------------------\n");
 59    printf ("  * Background messages preceeded by ^\n");
 60    printf ("  * Preceed input with ^ to write to background\n\n");
 61    printf ("\n");
 62    printf ("F1 - Freeze display          F2 - Select display mode\n");
 63    printf ("F3 - Help menu               F4 - Toggle local edit\n");
 64    printf ("F5 - Toggle term data only   F6 - Show query status\n");
 65    printf ("F7 - Set tab size            F8 - Execute DOS command\n");
 66    printf ("F9 - send BREAK              F10 - Exit Emulator\n");
 67    printf ("\n");
 68    printf ("ALT F1 - Toggle Show Packets\n");
 69    printf ("ALT F2 - Toggle Diagnose Rejects\n");
 70    printf ("ALT F3 - Toggle Extra RCV Chars\n");
 71    printf ("----------------------------------------------------------\n");
 72 }
 73 
 74 /* : PROCEDURE FUNCTION (set_tab_size)
 75 
 76 set a new tab size; if the tab size entered by the user is invalid, do not
 77 change existing tab size
 78 */
 79 
 80 set_tab_size()
 81 {
 82 int size;
 83 
 84 /* : prompt for a new tab size and read in user's response */
 85 
 86    printf("$$ Enter new tab size: ");
 87    gets(buff);
 88 
 89 /* : check that only a signle number is entered; the size must be at least one
 90      and less than the width of the screen */
 91 
 92    if (sscanf(buff,"%d%s",&size) != 1 || size < 1 || size > get_screen_width())
 93       printf("$$ -- Invalid tab size, tab size is now %d -- $$\n", em_tab_size);
 94    else {
 95       em_tab_size = size;
 96       printf("$$ New tab size = %d $$\n", em_tab_size);
 97    }
 98 }
 99 
100 /* : PROCEDURE FUNCTION (execute_dos_cmd)
101 
102 get and execute a command for the command interpreter
103 */
104 
105 execute_dos_cmd()
106 {
107 
108 /* : prompt and get user's command for command interpreter */
109 
110    printf ("$$ Enter DOS command: ");
111    gets(buff);
112 
113 /* : execute it and return to the emulator */
114 
115    system(buff);
116    printf ("$$ Returning to normal emulation $$\n");
117 }
118 
119 /* : PROCEDURE FUNCTION (send_query_status)
120 
121 display the contents of the background query queue
122 */
123 
124 sender_query_status()
125 {
126 int pending;
127 int sys;
128 int major;
129 int i;
130 int index;
131 
132 /* : check to see if the queue is empty */
133 
134    if (bg_sender_in == bg_sender_out)
135       printf ("$$ No background queries pending $$\n");
136 
137 /* : get count of queries pending in the queue */
138 
139    else {
140       if (bg_sender_in > bg_sender_out)
141          pending = bg_sender_in - bg_sender_out;
142       else
143          pending = bg_sender_in - bg_sender_out + BG_SENDBUFF_SIZE;
144 
145 /* : display the system id and major capability number of all query senders
146      in the queue */
147 
148       printf ("$$ %d queries pending:\n", pending);
149       for (i = 0; i < pending; i++) {
150          index = (bg_sender_out + i) % BG_SENDBUFF_SIZE;
151          c_unpack(&sys,&major,bg_sender_buff[index]);
152          printf ("  Query %2d>  system = %4d  major = %d\n", i, sys, major);
153       }
154       printf ("$$ Returning to normal emulation $$\n");
155    }
156 }
157 
158 /* : PROCEDURE FUNCTION (reply_to_query)
159 
160 check the background query queue and if not empty, reply to first pending
161 message in queue with message from user.
162 */
163 
164 reply_to_query()
165 {
166 
167 /* : if background query queue is empty */
168 
169    if (bg_sender_in == bg_sender_out)
170       printf ("$$ No background queries pending $$\n");
171 
172 /* : else background query queue not empty */
173 
174    else {
175       printf ("$$ Enter reply message: ");
176       gets(buff);
177       sendqrep(buff,bg_sender_buff[bg_sender_out]);
178 
179 /* : reply made, remove query sender from queue */
180 
181       bg_sender_out = (bg_sender_out+1) % BG_SENDBUFF_SIZE;
182    }
183 }
184 #else
185 freeze ()
186 {}
187 menu ()
188 {}
189 set_tab_size ()
190 {}
191 execute_dos_cmd ()
192 {}
193 sender_query_status ()
194 {}
195 reply_to_query ()
196 {}
197 #endif
198 ^Z