From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 25-SEP-1990 15:05:19.60
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	RE: Request /Reply question

Received:  by crdgw1.ge.com (5.57/GE 1.73)
	 id AA26343; Tue, 25 Sep 90 14:50:04 EDT
Received: From CRDGW1.GE.COM by CRVAX.SRI.COM with TCP; Tue, 25 SEP 90 10:39:17 PDT
Received:  by crdgw1.ge.com (5.57/GE 1.73)
	 id AA23343; Tue, 25 Sep 90 13:30:20 EDT
Date:  Tue, 25 Sep 90 13:30:20 EDT
Message-Id:  <9009251730.AA23343@crdgw1.ge.com>
From: sessions%sparev.DECNET@crdgw1 (Zack Sessions 8*292-5517)
To: info-vax@sparev.DECNET
Subject: RE: Request /Reply question

Carlos Alberto Fonseca Brefe <subrefe@venus.cpqd.ansp.br> asks:
>        Are there any easy way to receive the reply of an operator?
>        I'll explain:
> 
>        user : $ reque /repl/to=oper1 "Please mount tape and type tape number."
>        oper1: $ repl /to=n "#tape_number"
> 
>        How can the user ``read'' the returned value ?

The value is displayed to the user's SYS$OUTPUT. I suppose the user could
re-direct SYS$OUTPUT to a file and parse the file. _OR_ you could supply
a custom program designed to return the value in some other way. What
follows is a sample C program (released to the public domain) which
demonstrates this functionality:

/*
	rrequest.c

	by Zack Sessions

	demonstrate operator request which gets a value back
*/
#include <stdio.h>
#include <stdlib.h>
#include <ssdef.h>
#include <string.h>
#include <descrip.h>
#include <opcdef.h>
#include <iodef.h>
#include <quidef.h>

typedef struct {
	variant_union udef {
		variant_struct entrydef {
			short	buflen;
			short	itmcod;
			char	*bufadr;
			char	*retadr;
		} entry;
		int	end_list;
	} uent;
} LIST;
struct iosbdef {
	variant_union udef {
		int l_iosb[2];
		variant_struct mbdef {
			short	s1_iosb[2];
			int	s2_iosb;
		} s;
	} u;
} iosb;

LIST qlist[4];
LIST jlist[6];
int qlen;
int jlen;
int ulen;
char queue_name[32];
char job_name[40];
char username[13];
char sname[32];
int search_flags;
int job_size;
int job_status;
int status_q;
int status_j;
int status_f;
short mbxchan;
int rstat;
FILE *fp, *fopen();
struct OPC rqst;
struct dsc$descriptor_s rqstbuff;

request(msg,chan,opreply,size)
 char *msg;
 short chan;
 char *opreply;
 short *size;
{
	char reply[161];
	int i;
	rqst.opc$b_ms_type = OPC$_RQ_RQST;
	rqst.opc$b_ms_target = OPC$M_NM_CENTRL | OPC$M_NM_CLUSTER | OPC$M_NM_SECURITY;
	rqst.opc$l_ms_rqstid = 1;
	strcpy(&rqst.opc$l_ms_text,msg);
	rqstbuff.dsc$b_dtype = DSC$K_DTYPE_T;
	rqstbuff.dsc$b_class = DSC$K_CLASS_S;
	rqstbuff.dsc$a_pointer = &rqst;
	rqstbuff.dsc$w_length = 8 + strlen(msg);
	rstat = sys$sndopr(&rqstbuff,chan);
	if(rstat != SS$_NORMAL)
		sys$exit(rstat);
	if(chan != 0) {
		rstat = sys$qiow(0,mbxchan,IO$_READVBLK,&iosb,0,0,reply,160,0,0,0,0);
		if(rstat != SS$_NORMAL)
			sys$exit(rstat);
		if(iosb.s1_iosb[0] == SS$_NORMAL) {
			for(i=8; reply[i] != 0x0D; ++i) ;
			reply[i] = '\0';
			strcpy(opreply,&reply[8]);
			*size = strlen(opreply);
		}
	}
}
main()
{
	int i;
	char q_name[32];
	char j_name[40];
	char user[13];
	char msg[160];
	char reply[81];
	short rlen = 80;
	rstat = sys$crembx(0,&mbxchan,0,0,0,0,0);
	if(rstat != SS$_NORMAL)
		sys$exit(rstat);
	request("Starting request/reply test",0,NULL,NULL);
	printf("Issuing request with reply\n");
	request("Enter something, dummy",mbxchan,reply,&rlen);
	printf("Received message %s\n",reply);
}

Hope this helps someone!

Zack C. Sessions
Sessions@Sparev.dnet.ge.com (Internet)
Sessions%Sparev.dnet.ge.com@crdgw1.ge.com (Alternate Internet)
...!uflorida!ki4pv!macs!stetson!rewop!sencland!sessions (UUCP at home)

