/* fortytwo.x Example Sun RPC interface. Marvin Theimer, Xerox PARC March, 1992 $Id: fortytwo.x,v 1.2 1992/04/01 02:15:53 nichols Exp theimer $ */ /* Copyright (c) 1992 Xerox Corporation. All rights reserved. Use and copying of this software and preparation of derivative works based upon this software are permitted. Any distribution of this software or derivative works must comply with all applicable United States export control laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. */ /* * fortytwo RPC server. */ #if RPC←HDR %#ifndef fourtwo←h %#define fourtwo←h %#include "fourtwo.h" %#endif fourtwo←h %#ifndef fortyone←h %#define fortyone←h %#include "fortyone.h" %#endif fortyone←h #endif RPC←HDR #if RPC←HDR %#define ServiceName "fortytwo" #endif rpc←HDR enum QuestionType { boring = 123, cosmic = 456, universal, stupid = 789, silly }; enum Question1Type { boooring, cooosmic, univeeersal, stuuupid, sillly }; typedef struct answerRec answerRecType; union TheANSWER switch (QuestionType truthType) { case boring: opaque b[13]; case cosmic: int c; case stupid: void; default: struct answerRec *d; }; union YetAnotherAnswer switch (int responseType) { case 0: enum QuestionType answer; case 1: int a; default: void; }; struct trueAnswerRec { bool tellingTheTruth; int theTruth[TRUTH←SIZE]; TheANSWER theTRUTH; }; struct trueQuestionRec { QuestionType questionType; int randomNumbers<>; }; typedef trueQuestionRec QuestionRec; typedef trueAnswerRec AnswerRec; typedef QuestionRec *QuestionRecPtr; typedef QuestionRec QuestionRecArray<>; typedef QuestionRec QuestionRecArray1[13]; struct tuple { int x; int y; }; struct randomTypes { float a; double b; char c; short d; int e; long f; unsigned char g; unsigned short h; unsigned int i; unsigned long j; tuple k<>; opaque l[3]; unsigned char m<13>; }; /*** Additional types used for testing stub generator correctness. ***/ typedef int FooBar; union fortytwo←foo switch (unsigned int desc) { case 1: unsigned int a; case 2: unsigned long b<>; case 3: unsigned char c[42]; case 4: unsigned long d<43>; default: unsigned char e; }; struct barr { unsigned short a; unsigned int b<>; unsigned char c[13]; unsigned int *d; }; typedef unsigned long ULONG; typedef unsigned int foobar<>; typedef unsigned char foobaz[137]; typedef unsigned int *foobarrr; union fortytwo←bar switch (bool desc) { case TRUE: int a; case FALSE: char b; }; enum TestNamesArray { a = 1, b = 2 }; program FORTY←TWO←PROG { version FORTY←TWO←VERS←1 { answerRec GET←ANSWER(questionRec) = 1; trueAnswerRec GET←TRUE←ANSWER(trueQuestionRec) = 2; int GET←BOGUS←ANSWER(void) = 3; void DONT←ANSWER(int) = 4; } = 1; version FORTY←TWO←VERS←2 { AnswerRec GET←THE←ANSWER(QuestionRec) = 1; } = 2; } = 0x20000000; program TEST←TYPES←PROG { version TEST←TYPES←3 { randomTypes DO←TEST(randomTypes) = 13; } = 3; } = 40400001;