[comp.protocols.misc] RPCGEN and array of strings

jwright@cfht.hawaii.edu (Jim Wright) (07/19/90)

In an RPC call, part of the structure I'm passing is an array of strings.
All is OK on the server before returning, but the client only sees garbage.
The samples below have lots removed, but I hope they get the idea across.
Specifically, I don't have any lack of error checking in the real code.
Are there any special tricks involved in passing an array of strings?  Any
help is greatly appreciated.

=================
from rpcgen file:
=================
const NUMERRSTR = 4;
typedef string ErrorStr<>;
union ErrorStrs switch (int errno) {
	case 0:
		ErrorStr str[NUMERRSTR];
	default:
		void;
};
=====================
from the server side:
=====================
ErrorStrs errorstrs;

ErrorStrs *logger_geterr_1(device)
char **device;
{
	for (n=0 ; n<NUMERRSTR ; n++) {
		HPIB_WRITE (hh_id, "ERRSTR?");
		HPIB_READ (hh_id, buffer, 255);
		errorstrs.ErrorStrs_u.str[n] = strtok(buffer, "\n\r");
		fprintf (stderr, "%s\n", errorstrs.ErrorStrs_u.str[n]);
	}
	errorstrs.errno = 0;
	return (&errorstrs);
}
=====================
from the client side:
=====================

        errorstrs = logger_geterr_1(&device, cl);
	for (n=0 ; n<NUMERRSTR ; n++) {
		printf ("%d - %s\n", n, errorstrs->ErrorStrs_u.str[n]);
	}

--
Jim Wright
jwright@quonset.cfht.hawaii.edu
Canada-France-Hawaii Telescope Corp.