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-06,Westcott), approve(87-07-13,MCR7580),
 11 ;     audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 12 ;     Created.
 13 ;                                                      END HISTORY COMMENTS
 14 
 15 ;/* : PROCEDURE FUNCTION (putbgmes)
 16 ;
 17 ;Sends a message from a background application to the foreground message
 18 ;handler. These messages will be queued by MOWSE until they are retrieved
 19 ;via a getbgmes call from a foreground program.
 20 ;*/
 21 
 22 ;/* : NOTES
 23 ;
 24 ;Syntax:
 25 ;    code = putbgmes(mcb_ptr,code,caller,control,arg1,..argN)
 26 ;    mcb *mcb_ptr;
 27 ;    int code;
 28 ;    char *caller;
 29 ;    char *control;
 30 ;
 31 ;Arguments:
 32 ;    mcb_ptr - the pointer to the application's MOWSE control block.
 33 ;    code    - determines the type of message if 0, the message will
 34 ;              consist only of the contents of the control string if WSQUERY,
 35 ;              the control string will be used to prompt the user for a
 36 ;              response.
 37 ;    caller  - the name of the background machine that is making this call.
 38 ;    control - a "printf" control string
 39 ;    Arg1..ArgN
 40 ;            - printf arguments to be substituted into the control argument.
 41 ;              These arguments are optional. They are only used if required
 42 ;              by the control argument.
 43 ;
 44 ;Returns:
 45 ;    WSINVBUF, if the resulting message is longer than WSPAKSIZ
 46 ;*/
 47 
 48 include dos.mac
 49 include ws.mac
 50 include ws_dcls.mac
 51 include ws_mcb.mac
 52 include ws_func.mac
 53 
 54 ;----------- WORKING STORAGE FOR PUTBGMES
 55 
 56 dseg
 57 
 58 sv_bp   dw      ?       ; caller's BP save space
 59 sv_retn dw      ?       ; return address from call
 60 sv_mcb  dw      ?       ; pointer to caller's mcb
 61 sv_code dw      ?       ; code
 62 work    putbgstr <0,0,0>
 63 string  db      "%d",0  ; control string to sprintf for code expansion
 64 
 65 endds
 66 
 67 pseg
 68 ;----------- PUBLICS
 69 
 70 public putbgmes
 71 
 72 ;----------- EXTERNALS
 73 
 74 extrn  call_mowse_int:near
 75 extrn  sprintf:near
 76 
 77 ;----------- DYNAMIC STORAGE FOR PUTBGMES
 78 
 79 dyns    struc
 80 old_bp  dw      ?       ; caller's BP save
 81 retn    dw      ?       ; return address from call
 82 mcb_ptr dw      ?       ; pointer to caller's mcb
 83 code    dw      ?       ; code
 84 caller  dw      ?       ; address of caller string
 85 control dw      ?       ; address of control string
 86 dyns    ends
 87 
 88 putbgmes proc near
 89         push    bp
 90         mov     bp,sp
 91 
 92 ;/* : cleanup stack so that a call to sprintf can be made */
 93 
 94         pop     ax
 95         mov     sv_bp,ax
 96         pop     ax
 97         mov     sv_retn,ax
 98         pop     ax
 99         mov     sv_mcb,ax
100         pop     ax
101         mov     sv_code,ax
102 
103 ;/* : insert the caller's name at the beginning of the string */
104 
105         pop     si
106         lea     di,work.pbgmsg
107         xor     cx,cx
108 
109 pl1:
110         lodsb
111         or      al,al
112         jz      pl2    ; if end of caller's name
113         stosb
114         inc     cx
115         jmp     pl1
116 
117 pl2:
118         mov     al,':'
119         stosb
120         mov     al,' '
121         stosb
122         add     cx,2
123         mov     work.plength,cx
124 
125 ;/* : Copy in the code value if it is not 0 and not WSQUERY */
126 
127         mov     ax, sv_code
128         cmp     ax, WSQUERY
129         jne     no_query
130         mov     work.ptype, ax
131         jmp     no_code
132 
133 no_query:
134         mov     work.ptype, WSINFO     ; Info type
135         or      ax, ax                 ; Is the code 0?
136         je      no_code
137 
138         push    di                     ; save message position
139         mov     bp, sp
140         push    ax                     ; ax is code
141         lea     si, string             ; string is control string
142         push    si
143         push    di                     ; di is current position in message
144         call    sprintf
145         mov     sp, bp
146         add     work.plength, ax       ; save the length of the string
147         pop     di
148         add     di, ax                 ; increment position in message
149 
150         mov     al,'.'                 ; terminate the code with some chars
151         stosb
152         mov     al,' '
153         stosb
154         add     work.plength,2
155 
156 ;/* : since control string and arguments are already in the stack, all we
157 ;     have to do is push the address of the buffer and set the stack pointer. */
158 
159 no_code:
160         mov     bp,sp
161         push    di
162         call    sprintf
163         mov     sp,bp
164 
165         add     work.plength,ax        ; save length of string
166 
167         mov     bx,sv_mcb
168         mov     ah,system_id[bx]
169         mov     al,major_capability[bx]
170         mov     work.psender_major,ax
171 
172         mov     ax,work.plength        ; make sure message is less than WSPAKSIZ
173         cmp     ax,WSPAKSIZ
174         jle     no_overflow
175         mov     work.plength,WSPAKSIZ
176 
177 no_overflow:
178         mov     bp,sp
179         mov     cx,type work
180         push    cx
181         lea     bx,work
182         push    bx
183         mov     ax,I$PUTBGMES
184         push    ax
185         call    call_mowse_int
186         mov     sp,bp
187         mov     bp,sv_bp
188         push    sv_retn
189         ret
190 
191 putbgmes endp
192 endps
193         end
194 
195 ^Z