🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.protocols.misc
Article #212

RPCGEN and array of strings

#212
From: Jim Wright
Date: Wed, 18 Jul 1990 20:53
48 lines
1711 bytes
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.
Technical Details
Message-ID: <jwright.648334423@quonset>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!pacbell.com!ames!uhccux!quonset!jwright

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!pacbell.com!ames!uhccux!quonset!jwright
From: jwright@cfht.hawaii.edu (Jim Wright)
Newsgroups: comp.protocols.misc
Subject: RPCGEN and array of strings
Message-ID: <jwright.648334423@quonset>
Date: 18 Jul 90 20:53:43 GMT
Sender: news@uhccux.uhcc.Hawaii.Edu
Distribution: comp
Lines: 48