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-11,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 When called with a status_reply, place message 16 into status list. 17 END HISTORY COMMENTS */ 18 19 /* : PROCEDURE FUNCTION (i_putbgm) 20 21 Places a message on the background message queue for subsequent retrieval by 22 a foreground program. In addition to placing the message on the queue, a 23 count of the number of messages on the queue is incremented. 24 */ 25 26 #include <dos.h> 27 #include <alloc.h> 28 #include <cat.h> 29 #include <ws_dcls.h> 30 #include <ws_error.h> 31 #include <ws_msg.h> 32 #include <ws_fgb.h> 33 #include <wsmincap.h> 34 35 #define NULL 0 36 37 extern struct fgbstr *bgbfptr; /* first buffer on linked list */ 38 extern struct fgbstr *bgblptr; /* last buffer on linked list */ 39 extern struct fgbstr *sgbfptr; /* first buffer on Status linked list */ 40 extern struct fgbstr *sgblptr; /* last buffer on Status linked list */ 41 extern struct allocstr *bgaptr; /* allocation data for linked list*/ 42 extern int bgcount; /* count of bg messages in linked list */ 43 44 i_putbgm (p_param) 45 46 struct putbg_struc *p_param; 47 { 48 int i; /* copy counter */ 49 char *s1; /* pointer to source for copy */ 50 char *d1; /* pointer to destination of copy */ 51 struct fgbstr *bufp; /* pointer to current message structure */ 52 struct fgbstr *fgbp1; /* temporary pointer to message structure */ 53 struct query_msg *qrp; /* definition of query/reply message */ 54 int sysid; /* system id extracted from sender major */ 55 int cap_num; /* capability number extracted from sender major */ 56 57 /* : Allocate a buffer and place it on the linked list, 1 extra for message type */ 58 59 bufp = (struct fgbstr *) wsalloc (bgaptr,p_param -> length + 1 + sizeof(struct fgbstr)); 60 61 /* : if allocation successful 62 - copy to background message buffer */ 63 64 if (bufp != NULL) { 65 d1 = &bufp -> fgb_minor; 66 *d1++ = (char) p_param -> type; 67 c_unpack (&sysid, &cap_num, p_param -> sender_major); 68 *d1++ = (char) sysid; 69 *d1++ = (char) cap_num; 70 s1 = p_param -> bgmsg; 71 for (i = 0;i < p_param -> length;i++) { 72 *d1++ = *s1++; 73 } 74 bufp -> fgb_length = p_param -> length + 2; /* add in sysid, cap_num */ 75 76 /* : - link to previous status buffers OR background buffers */ 77 78 bufp -> fgb_next = NULL; 79 80 if (p_param -> type == STATUS_REPLY) 81 { if (sgbfptr == NULL) { 82 sgbfptr = bufp; 83 sgblptr = bufp; 84 } 85 else { 86 fgbp1 = bgblptr; 87 fgbp1 -> fgb_next = bufp; 88 sgblptr = bufp; 89 } 90 } 91 else 92 { if (bgbfptr == NULL) { 93 bgbfptr = bufp; 94 bgblptr = bufp; 95 bgcount = 1; 96 } 97 else { 98 fgbp1 = bgblptr; 99 fgbp1 -> fgb_next = bufp; 100 bgblptr = bufp; 101 bgcount++; 102 } 103 } 104 } 105 106 /* : return parameter structure to caller */ 107 108 return(0); 109 } 110 ^Z