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-07-12,Westcott), approve(87-07-13,MCR7580), 11 audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072): 12 Created. 13 2) change(86-12-10,Flegel), approve(87-07-13,MCR7580), 14 audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072): 15 Numerous minor changes to get it to work. 16 END HISTORY COMMENTS */ 17 18 /* : PROCEDURE FUNCTION (getstat) 19 20 Sends a message to the specified background application requesting status. 21 */ 22 23 /* : NOTES 24 25 This routine will loop while waiting for a reply and can therefore only be 26 called by a foreground application. 27 */ 28 29 #include <dos.h> 30 #include <ws.h> 31 #include <ws_msg.h> 32 #include <ws_dcls.h> 33 #include <ws_func.h> 34 #include <ws_error.h> 35 #include <wsmincap.h> 36 37 #define POLL_TIMER 4000 38 39 getstat (p_major_num, p_status_request, p_status_reply) 40 41 int p_major_num; /* Capability number to get status from */ 42 char *p_status_request; /* Request string */ 43 char *p_status_reply; /* Reply string */ 44 { 45 int code; /* return code */ 46 int i; /* loop counter*/ 47 int system; /* System of destination */ 48 int major; /* Major index of destination */ 49 int msg_len; /* Length of status request */ 50 char *s1; /* pointer to source string for copy */ 51 char *d1; /* pointer to destination string for copy */ 52 struct packet_msg msg; /* structure for message */ 53 struct gbgmsg_struc smsg; /* status reply structure */ 54 55 /* : copy reply string to mowse buffer and extract destination system and cap */ 56 57 msg_len = stccpy (msg.msg_data, p_status_request, WSPAKSIZ); 58 c_unpack (&system, &major, p_major_num); 59 60 msg.system = (char)(system); 61 msg.major = (char)(major); 62 msg.minor = GET_STATUS; 63 msg.source_system = WSIBMPC; 64 msg.source_major = WSMAJCAP; 65 66 /* : call user_interrupt to send data afet getting the length of the message 67 (128 is the number of chars in the data field, 2 removes the address 68 overhead) */ 69 70 msg_len = msg_len + sizeof (struct packet_msg) - 128 - 2; 71 if (code = call_mowse_int (I$SENDBG, &msg , msg_len)) 72 return (code); 73 74 /* : Now ask MOWSE to give us the status message when it arrives. This involves 75 looping in a request loop for status. In order to allow MOWSE interrupts, 76 there is a "do nothing" loop. */ 77 78 smsg.bg_type = STATUS_REPLY; 79 code = WSNOMESS; 80 while (code == WSNOMESS) { 81 for (i = 0; i < POLL_TIMER; i++); 82 code = call_mowse_int (I$GETBGMES, &smsg , sizeof (struct gbgmsg_struc)); 83 } 84 85 /* : Copy reply status back to caller's buffer */ 86 87 s1 = smsg.bgmsg; 88 d1 = p_status_reply; 89 for (i= 0; i < smsg.length; i++) 90 *d1++ = *s1++; 91 92 *d1++ = 0; 93 94 return(0); 95 }