2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * generator.c -- phase 2 of the generator.
13 * takes a file, which has a list of signature as input,
14 * and outputs the client, server, .xg, and makefiles
15 * This file is normally created by running tableGen.c,
16 * but theoretically could be generated by a human.
18 * Format of the signatures : no_of_args list_of_arg_signs
19 * arg_sign : (dir type)
22 * This program is used to generate client/server pairs that
23 * make and verify random rpcs. It can be used to generate
24 * both pthread and lwp versions of the client and server.
25 * It was designed to verify that the new pthread rx library
26 * was functioning correctly.
28 * The key to understanding how this program works is to realize
29 * that all the data necessary to generate the client/server
30 * code is generated first, in char string format.
31 * For example, if you are generating 10 rpc's, the input and
32 * output values of all the parameters are generated - and
33 * stored as strings. This allows you to write out the values
34 * as the client and server are created without having to worry
35 * about data type conversion.
37 * In addition, these strings (along with other information) are
38 * stored in a structure that is iterated over many times during
39 * the construction of the client and server.
41 * Often this iteration takes the form of:
42 * for (i=0; i < argsP->argCount; i++)
44 * It may be possible to eliminate some of these iterations for
45 * efficiency sake, but this was not done - allowing an easier
48 * The bulk of this code was lifted from the delight project.
59 #include "generator.h"
61 static char *unix_symbols[] = {
63 "include ../../../config/Makefile.$(SYS_NAME)\n",
66 "#include <netdb.h>\n",
70 "LIBS = $(DESTDIR)lib/libafsrpc.so \\\n"
71 "\t$(DESTDIR)lib/afs/libcmd.a \\\n"
72 "\t$(DESTDIR)lib/afs/libcom_err.a \\\n"
73 "\t$(DESTDIR)lib/afs/util.a \n",
76 "LIBS = $(DESTDIR)lib/librxkad.a \\\n"
77 "\t$(DESTDIR)lib/libdes.a \\\n"
78 "\t$(DESTDIR)lib/librx.a \\\n"
79 "\t$(DESTDIR)lib/liblwp.a \\\n"
80 "\t$(DESTDIR)lib/afs/libcmd.a \\\n"
81 "\t$(DESTDIR)lib/afs/libcom_err.a \\\n"
82 "\t$(DESTDIR)lib/afs/util.a \\\n"
83 "\t/usr/ucblib/libucb.a \n",
86 "\t@if [ ! -r DEST ] ; \\\n"
88 "\t\techo \"Must create DEST link by hand before building tests\"; \\\n"
93 static char *nt_symbols[] = {
95 "!INCLUDE ../../../config/NTMakefile.$(SYS_NAME)\n",
98 "#include <windows.h>\n",
102 "LIBS = $(DESTDIR)/lib/afsrpc.lib \\\n"
103 "\t$(DESTDIR)/lib/afs/afscmd.lib \\\n"
104 "\t$(DESTDIR)/lib/afs/afscom_err.lib \\\n"
105 "\t$(DESTDIR)/lib/afs/afsutil.lib \\\n"
106 "\t$(DESTDIR)/lib/pthread.lib \\\n"
107 "\t$(DESTDIR)/lib/afsreg.lib \\\n"
111 "LIBS = $(DESTDIR)/lib/afsrxkad.lib \\\n"
112 "\t$(DESTDIR)/lib/afsdes.lib \\\n"
113 "\t$(DESTDIR)/lib/afsrx.lib \\\n"
114 "\t$(DESTDIR)/lib/afslwp.lib \\\n"
115 "\t$(DESTDIR)/lib/afs/afscmd.lib \\\n"
116 "\t$(DESTDIR)/lib/afs/afscom_err.lib \\\n"
117 "\t$(DESTDIR)/lib/afs/afsutil.lib \\\n"
118 "\t$(DESTDIR)/lib/afsreg.lib \n",
121 "!\tIF (!EXIST(DEST))\n"
122 "!\t\tERROR Must create DEST link by hand before building tests\n"
126 static char **platform = nt_symbols;
129 #define strdup(x) _strdup(x)
133 * 31 bit random number generator, we don't really care how random
134 * these numbers are, it is more important that identical rx files
135 * are generated no matter what platform the generator runs on
137 static unsigned long randVal = 0x330E16;
144 static threadModel_t threadModel = PTHREADS;
146 PRIVATE double drand32(void)
148 randVal = ((randVal * 0xEECE66D) + 0xB) & 0xFFFFFFFF;
149 return ((double)(randVal) / 4294967296.0);
153 * GetDescription writes a one line comment describing the parameters
154 * used in an rpc in the client program
156 PRIVATE char *GetDescription(rpcArgs *argsP)
161 bufP2 = (char *) calloc((MAX_TYP_STR+MAX_DIR_STR+ATTRIB_LEN*ATTRIB_NO)
162 *argsP->argCount+3, sizeof(char));
163 MEM_CHK(bufP2, "GetDescription: out of mem bufP2\n");
165 for (i=0; i < argsP->argCount; i++) {
166 strcat(bufP2, argsP->argDescr[i].direction);
167 strcat(bufP2, argsP->argDescr[i].type);
173 * GetName -- get the name of the current server/instance
175 PRIVATE char *GetName(char *serverName, int sign_no)
177 /* itl file name 8.3 format*/
180 bufP = (char *) malloc(32 * sizeof(char));
181 MEM_CHK(bufP, "GetName: bufP out of mem\n");
183 sprintf(bufP, "%s%d", serverName, sign_no);
188 * OpenOutFile -- open a file in the output directory
190 PRIVATE FILE *OpenOutFile(char *outDir, char *fileName, char *tailStr)
196 bufP = (char *) malloc(sizeof(char)*(strlen(fileName)+
197 strlen(tailStr)+strlen(outDir)+2));
198 MEM_CHK(bufP, "OpenOutFile : Out of mem -- bufP\n");
199 sprintf(bufP, "%s/%s%s", outDir, fileName, tailStr);
201 bufP = (char *) malloc(sizeof(char)*(strlen(fileName)+
203 MEM_CHK(bufP, "OpenOutFile : Out of mem -- bufP\n");
204 sprintf(bufP, "%s%s", fileName, tailStr);
206 fP = fopen(bufP, "w");
207 MEM_CHK(fP, "main: Unable to open output file\n");
213 * WriteXGDecl -- write the declaration for a parameter
215 PRIVATE void WriteXGDecl(arg_tuple *arg, FILE *xg_h, int i,
216 int structFlag, int lastFlag)
219 if (!strcmp(arg->type, "varString")) {
220 fprintf(xg_h, "\tchar a%d[STR_MAX];\n", i);
223 fprintf(xg_h, "\tdrpc_%s_t a%d;\n", arg->type, i);
226 if (!strncmp(arg->type, "ar_", 2)) {
227 fprintf(xg_h, "\t%s drpc_out_%s_t *a%d",
228 arg->direction, arg->type, i);
230 else if (!strcmp(arg->type, "varString")) {
231 fprintf(xg_h, "\t%s string a%d<STR_MAX>",
234 else if (!strcmp(arg->direction, "IN")) {
235 fprintf(xg_h, "\t%s drpc_%s_t a%d",
236 arg->direction, arg->type, i);
238 fprintf(xg_h, "\t%s drpc_%s_t *a%d",
239 arg->direction, arg->type, i);
250 * WriteXG -- write the body of the xg interface
252 PRIVATE void WriteXG(rpcArgs *argsP, FILE *xg_h, char *serverName, int sign_no)
255 char *name = GetName(serverName, sign_no);
258 * CASE 1: all arguments passed as parameters
261 fprintf(xg_h, "\nproc %s(\n", name);
263 /* declare each arg */
264 for (i=0; i < argsP->argCount; i++) {
265 WriteXGDecl(&argsP->argDescr[i], xg_h, i, FALSE,
266 (i==argsP->argCount-1));
269 /* Now pass the paramaters inside a structure */
270 fprintf(xg_h, "\nstruct %s_t {\n", name);
271 for (i=0; i < argsP->argCount; i++) {
272 WriteXGDecl(&argsP->argDescr[i], xg_h, i, TRUE,
273 (i==argsP->argCount-1));
275 fprintf(xg_h, "} ;\n");
276 fprintf(xg_h, "\nproc %s_s(\n", name);
277 fprintf(xg_h, "\tINOUT struct %s_t *s);\n", name);
283 * GetRandStr -- get a random string
285 PRIVATE void GetRandStr(int strLen, char **ret, int *rP)
293 randI = 'A' + ('Z' - 'A')*drand32();
294 sprintf(buf, "%c", randI);
303 * GetRandP -- sets a string to a random value of the data type
304 * inthe case of a char type, ret holds "%c" and ret2 holds '%c'
306 PRIVATE void GetRandP(char *typ, char **ret, char **ret2)
313 *ret = (char *) calloc(MAX_RAND_LENGTH+1, sizeof(char));
314 *ret2 = (char *) calloc(MAX_RAND_LENGTH+1, sizeof(char));
316 if (strstr(typ, "char")) {
317 GetRandStr(1, ret2, &randI);
319 strcpy(*ret2, "'\\\\'");
320 else if(randI == '\'')
321 strcpy(*ret2, "'\\''");
323 sprintf(*ret, "'%c'", randI);
325 } else if (strstr(typ, "short")) {
326 shI = SHRT_MIN + (SHRT_MAX - SHRT_MIN) * drand32();
327 sprintf(*ret, "%d", shI);
329 } else if (strstr(typ, "afs_int32")) {
330 randI = INT_MIN + UINT_MAX * drand32();
331 if (randI < INT_MIN || randI > INT_MAX) {
332 fprintf(stderr, "GetRandP: afs_int32 %d out of bounds\n", randI);
335 sprintf(*ret, "%d", randI);
337 } else if (strstr(typ, "float")) {
340 sprintf(*ret, "%2.8e", f);
343 } else if (strstr(typ, "double")) {
345 sprintf(*ret, "%2.16e", d1);
348 } else if (strstr(typ, "String")) {
349 strLen = (MAX_RAND_LENGTH-2)*drand32();
350 GetRandStr(strLen, ret, &randI);
357 * GenParamValues -- generate the parameter values for an rpc
359 PRIVATE void GenParamValues(rpcArgs *argsP)
364 /* generate random values for each argument */
365 for (i=0; i < argsP->argCount; i++) {
367 argsP->argDescr[i].vc_low = 0;
368 argsP->argDescr[i].vc_max = IDL_FIX_ARRAY_SIZE-1;
369 argsP->argDescr[i].vc_high = IDL_FIX_ARRAY_SIZE-1;
370 argsP->argDescr[i].ovc_low = 0;
371 argsP->argDescr[i].ovc_high = IDL_FIX_ARRAY_SIZE-1;
373 if (!strncmp(argsP->argDescr[i].type, "ar_", 3)) {
374 typ = argsP->argDescr[i].type + 3;
375 for (j = 0 ; j < IDL_FIX_ARRAY_SIZE ; j++) {
376 GetRandP(typ, &argsP->argDescr[i].inValue[j],
377 &argsP->argDescr[i].inValue2[j]);
378 GetRandP(typ, &argsP->argDescr[i].outValue[j],
379 &argsP->argDescr[i].outValue2[j]);
382 GetRandP(argsP->argDescr[i].type,
383 &argsP->argDescr[i].inValue[0],
384 &argsP->argDescr[i].inValue2[0]);
385 GetRandP(argsP->argDescr[i].type,
386 &argsP->argDescr[i].outValue[0],
387 &argsP->argDescr[i].outValue2[0]);
393 * WriteServC -- write the rpcs in the server file
395 PRIVATE void WriteServC(rpcArgs *argsP, FILE *srv_h, char *serverName, int sign_no)
400 name = GetName(serverName, sign_no);
401 fprintf(srv_h, "\nint A%s(struct rx_call *c,\n", name);
403 /* declare each arg */
404 for (i=0; i < argsP->argCount; i++) {
406 if (!strcmp(argsP->argDescr[i].type, "varString")) {
407 if (!strcmp(argsP->argDescr[i].direction, "IN")) {
408 fprintf(srv_h, "\tchar *a%d", i);
411 fprintf(srv_h, "\tchar **a%d", i);
414 else if (strncmp(argsP->argDescr[i].type, "ar_", 3) &&
415 (!strcmp(argsP->argDescr[i].direction, "IN"))) {
416 fprintf(srv_h, "\tdrpc_%s_t a%d", argsP->argDescr[i].type, i);
418 if (!strncmp(argsP->argDescr[i].type, "ar_", 3)) {
419 fprintf(srv_h, "\tdrpc_out_%s_t *a%d", argsP->argDescr[i].type, i);
422 fprintf(srv_h, "\tdrpc_%s_t *a%d", argsP->argDescr[i].type, i);
425 if(i < (argsP->argCount - 1)) {
426 fprintf(srv_h, ",\n");
429 fputs(")\n{\n", srv_h); /* balance the } */
430 fputs("\tint errFlag = 0;", srv_h);
433 * check the in and inout parameters
435 for (i=0; i < argsP->argCount; i++) {
437 if (!strcmp(argsP->argDescr[i].direction, "IN") ||
438 (!strcmp(argsP->argDescr[i].direction, "INOUT") &&
439 !strcmp(argsP->argDescr[i].type, "varString"))) {
441 typ = argsP->argDescr[i].type;
443 if (strstr(typ, "String")) {
444 if(!strcmp(argsP->argDescr[i].direction, "INOUT")) {
445 fprintf(srv_h, "\n\tCHECK%s((char *)*a%d, %s, \"%s\");",
446 typ, i, argsP->argDescr[i].inValue[0], name);
448 fprintf(srv_h, "\n\tCHECK%s((char *)a%d, %s, \"%s\");",
449 typ, i, argsP->argDescr[i].inValue[0], name);
451 } else if (!strcmp(typ, "afs_int32")) {
452 fprintf(srv_h, "\n\tCHECK%s(a%d, %sL, \"%s\");",
453 typ, i, argsP->argDescr[i].inValue[0], name);
455 if(!strncmp(typ, "ar_", 3)) {
456 for(j=0;j<IDL_FIX_ARRAY_SIZE;j++)
457 fprintf(srv_h, "\n\tCHECK%s(a%d->drpc_out_%s_t_val[%d], %s, \"%s\");",
458 (typ+3), i, typ, j, argsP->argDescr[i].inValue[j],
462 fprintf(srv_h, "\n\tCHECK%s(a%d, %s, \"%s\");",
463 typ, i, argsP->argDescr[i].inValue[0], name);
466 } else if (!strcmp(argsP->argDescr[i].direction, "INOUT")) {
468 typ = argsP->argDescr[i].type;
470 if (strstr(typ, "String")) {
471 fprintf(srv_h, "\n\tCHECK%s((char *)*a%d, %s, \"%s\");",
472 typ, i, argsP->argDescr[i].inValue[0], name);
473 } else if (!strcmp(typ, "afs_int32")) {
474 fprintf(srv_h, "\n\tCHECK%s(*a%d, %sL, \"%s\");",
475 typ, i, argsP->argDescr[i].inValue[0], name);
477 if(!strncmp(typ, "ar_", 3)) {
478 for(j=0;j<IDL_FIX_ARRAY_SIZE;j++)
479 fprintf(srv_h, "\n\tCHECK%s(a%d->drpc_out_%s_t_val[%d], %s, \"%s\");",
480 (typ+3), i, typ, j, argsP->argDescr[i].inValue[j],
484 fprintf(srv_h, "\n\tCHECK%s(*a%d, %s, \"%s\");",
485 typ, i, argsP->argDescr[i].inValue[0], name);
492 * free up memory for dynamic input args
494 for (i=0; i < argsP->argCount; i++) {
495 if (!strncmp(argsP->argDescr[i].type, "ar_", 3)) {
496 typ = argsP->argDescr[i].type;
497 if(!strcmp(argsP->argDescr[i].direction, "INOUT")) {
498 fprintf(srv_h, "\n\tif (a%d->drpc_out_%s_t_val) "
499 "free(a%d->drpc_out_%s_t_val);", i, typ, i, typ);
501 if(!strcmp(argsP->argDescr[i].direction, "INOUT") ||
502 !strcmp(argsP->argDescr[i].direction, "OUT")) {
503 fprintf(srv_h, "\n\ta%d->drpc_out_%s_t_val = (%s *) "
504 "malloc(FIX_ARRAY_SIZE * sizeof(%s));",
505 i, typ, (typ+3), (typ+3));
506 fprintf(srv_h, "\n\ta%d->drpc_out_%s_t_len = FIX_ARRAY_SIZE;",
513 * set the inout and out parameters
515 for (i=0; i < argsP->argCount; i++) {
517 if (!strcmp(argsP->argDescr[i].direction, "INOUT") ||
518 !strcmp(argsP->argDescr[i].direction, "OUT")) {
520 typ = argsP->argDescr[i].type;
522 if (!strncmp(typ, "ar_", 3)) {
523 for(j=0;j<IDL_FIX_ARRAY_SIZE;j++)
524 fprintf(srv_h, "\n\ta%d->drpc_out_%s_t_val[%d] = %s;",
525 i, typ, j, argsP->argDescr[i].outValue[j]);
526 } else if (!strcmp(typ, "afs_int32")) {
527 fprintf(srv_h, "\n\t*a%d = %sL;",
528 i, argsP->argDescr[i].outValue[0]);
529 } else if (!strcmp(typ, "varString")) {
530 if(!strcmp(argsP->argDescr[i].direction, "OUT")) {
531 fprintf(srv_h, "\n\t*a%d = (char *) malloc(STR_MAX);", i);
533 fprintf(srv_h, "\n\tstrcpy((char *)*a%d, %s);",
534 i, argsP->argDescr[i].outValue[0]);
535 } else if (strstr(typ, "String")) {
537 "\n\t*a%d = (drpc_%s_t)rpc_ss_allocate(%d);",
538 i, typ, strlen(argsP->argDescr[i].outValue[0])-1);
539 fprintf(srv_h, "\n\tstrcpy((char *)*a%d, %s);",
540 i, argsP->argDescr[i].outValue[0]);
542 fprintf(srv_h, "\n\t*a%d = %s;",
543 i, argsP->argDescr[i].outValue[0]);
550 "\n\t\tprintf(\"%s: failed\\n\");"
551 "\n\t\tfflush(stdout);"
553 "\n\treturn errFlag;\n}\n",
557 * second routine with arguments inside a structure
559 fprintf(srv_h, "\nint A%s_s(struct rx_call *c,\n\t%s_t *s)\n{"
560 "\n\tint errFlag = 0;", name, name);
563 * check the in and inout parameters
565 for (i=0; i < argsP->argCount; i++) {
567 if (!strcmp(argsP->argDescr[i].direction, "IN") ||
568 (!strstr(argsP->argDescr[i].type, "String") &&
569 !strcmp(argsP->argDescr[i].direction, "INOUT"))) {
571 typ = argsP->argDescr[i].type;
573 if(!strncmp(typ, "ar_", 3)) {
574 for(j=0;j<IDL_FIX_ARRAY_SIZE;j++)
575 fprintf(srv_h, "\n\tCHECK%s(s->a%d[%d], %s, \"%s_s\");",
576 (typ+3), i, j, argsP->argDescr[i].inValue[j],
579 else if (strstr(typ, "String")) {
580 fprintf(srv_h, "\n\tCHECK%s((char *)s->a%d, %s, \"%s_s\");",
581 typ, i, argsP->argDescr[i].inValue[0], name);
582 } else if (!strcmp(typ, "afs_int32")) {
583 fprintf(srv_h, "\n\tCHECK%s(s->a%d, %sL, \"%s_s\");",
584 typ, i, argsP->argDescr[i].inValue[0], name);
586 fprintf(srv_h, "\n\tCHECK%s(s->a%d, %s, \"%s_s\");",
587 typ, i, argsP->argDescr[i].inValue[0], name);
593 * set the inout and out parameters
595 for (i=0; i < argsP->argCount; i++) {
597 if (!strcmp(argsP->argDescr[i].direction, "INOUT") ||
598 !strcmp(argsP->argDescr[i].direction, "OUT")) {
600 typ = argsP->argDescr[i].type;
602 if(!strncmp(typ, "ar_", 3)) {
603 for(j=0;j<IDL_FIX_ARRAY_SIZE;j++)
604 fprintf(srv_h, "\n\ts->a%d[%d]= %s;",
605 i, j, argsP->argDescr[i].outValue[j]);
607 else if (!strcmp(typ, "afs_int32")) {
608 fprintf(srv_h, "\n\ts->a%d = %sL;",
609 i, argsP->argDescr[i].outValue[0]);
610 } else if (!strcmp(typ, "varString")) {
611 fprintf(srv_h, "\n\tstrcpy((char *)s->a%d, %s);",
612 i, argsP->argDescr[i].outValue[0]);
613 } else if (strstr(typ, "String")) {
614 fprintf(srv_h, "\n\ts->a%d = rpc_ss_allocate(%d);",
615 i, strlen(argsP->argDescr[i].outValue[0])-1);
616 fprintf(srv_h, "\n\tstrcpy((char *)s->a%d, %s);",
617 i, argsP->argDescr[i].outValue[0]);
619 fprintf(srv_h, "\n\ts->a%d = %s;",
620 i, argsP->argDescr[i].outValue[0]);
627 "\n\t\tprintf(\"%s_s: failed\\n\");"
629 "\n\tfflush(stdout);"
630 "\n\treturn errFlag;\n}\n",
638 * WriteMake - write the makefile for a particular client/server pair
640 PRIVATE void WriteMake(char *serverName, int srv_no, FILE *mak_h)
643 char *obj=platform[2];
645 sprintf(p,"%s%d", serverName, srv_no);
646 fprintf(mak_h, "%s", platform[1]);
647 if (threadModel == PTHREADS) {
649 "CFLAGS = -KPIC -g -mt -I$(DESTDIR)include\n"
655 "CFLAGS = -g -I$(DESTDIR)include\n"
661 "\n\ntest: all\ntests: all\nall: %sClt %sSrv\n\n"
662 "%sClt: %s.cs.%s %s.xdr.%s %sClt.%s $(LIBS)\n",
663 p,p,p,p,obj,p,obj,p,obj
665 if(platform == nt_symbols) {
666 fprintf(mak_h, "\t$(EXECONLINK)\n\n");
669 "\t$(CC) $(CFLAGS) -o $@ %sClt.%s %s.cs.%s %s.xdr.%s "
670 "$(LIBS) $(XLIBS)\n\n",
675 "%s.xdr.c: %s.xg\n\n"
676 "%s.h %s.cs.c %s.ss.c: %s.xg\n"
680 p,p,p,p,p,p,p,platform[3],p,platform[3],p);
682 "%sSrv: %s.ss.%s %s.xdr.%s %sSrv.%s $(LIBS)\n",
683 p,p,obj,p,obj,p,obj);
685 if(platform == nt_symbols) {
686 fprintf(mak_h, "\t$(EXECONLINK)\n\n");
689 "\t$(CC) $(CFLAGS) -o $@ %sSrv.o %s.ss.o %s.xdr.o "
690 "$(LIBS) $(XLIBS)\n\n",
695 if(platform == unix_symbols) {
698 "\t/bin/rm -f %sClt %s.h %s.cs.c %s.ss.c core "
700 "\t%sClt.o %s.cs.o %s.ss.o %s.xdr.c %s.xdr.o\n",
701 p,p,p,p,p,p,p,p,p,p,p);
707 * WriteCltTrailer - finish writing client source
709 PRIVATE void WriteCltTrailer(char *serverName, int first, int last, FILE *itl_h)
714 * Write out 1 function that calls all the manager functions
716 if (threadModel == PTHREADS) {
717 fprintf(itl_h, "\n\nvoid *threadFunc(void *arg) {\n");
719 fprintf(itl_h, "\n\nint threadFunc(int *arg) {\n");
723 "\tstruct rx_connection *conn;\n"
725 "\tint i = (int) arg;\n\n"
728 fprintf(itl_h, "\tconn = rx_GetCachedConnection(serverAddr,serverPort,4,secClass,secIndex);\n");
730 fprintf(itl_h, "\twhile(i--) {\n");
732 if (first == 0) first = 1;
733 for(i=first;i<last;i++) {
734 fprintf(itl_h, "\t\tC_%s%d(conn);\n",serverName, i);
735 fprintf(itl_h, "\t\tC_%s%d_s(conn);\n",serverName, i);
737 fprintf(itl_h, "\t}\n");
739 fprintf(itl_h, "\trx_ReleaseCachedConnection(conn);\n");
741 if (threadModel == PTHREADS) {
742 fprintf(itl_h, "\treturn (void *) 0;\n");
745 "\tLWP_CALL(LWP_SignalProcess,(&done));\n"
750 fprintf(itl_h, "}\n");
753 "\n\nstatic void DoRun(struct cmd_syndesc *as, char *arock) {\n"
756 if (threadModel == PTHREADS) {
757 fprintf(itl_h, "\tpthread_t *tid;\n");
759 fprintf(itl_h, "\tPROCESS *tid;\n");
764 "\tunsigned int numThreads=0,numIterations=0;\n"
766 "\tstruct hostent *host=NULL;\n\n"
767 "\tnumThreads = atoi(as->parms[0].items->data);\n"
768 "\tnumIterations = atoi(as->parms[1].items->data);\n"
769 "\tsecType = atoi(as->parms[2].items->data);\n"
770 "\tencLevel = atoi(as->parms[3].items->data);\n"
771 "\tserverPort = htons(atoi(as->parms[4].items->data));\n"
772 "\tif ((host = hostutil_GetHostByName(as->parms[5].items->data))==0) {\n"
776 "\t\tmemcpy((void *) &serverAddr, (const void *)host->h_addr, sizeof(serverAddr));\n"
778 "\tif ((secType<1) || (secType>2)) errflg++;\n"
779 "\tif ((encLevel<0) || (encLevel>2)) errflg++;\n"
780 "\tif ((serverPort == 0) ||(numThreads == 0) ||(numIterations == 0)) errflg++;\n"
782 "\t\tprintf(\"invalid argument\\n\");\n"
785 "\tif(rx_Init(htons(0)) < 0) {\n"
788 "\tswitch(secType) {\n"
790 "\t\t\tsecIndex = 0;\n"
791 "\t\t\tsecClass = rxnull_NewClientSecurityObject();\n"
794 "\t\t\tif (GetTicket (&kvno, &Ksession, &ticketLen, ticket) == 0) {\n"
795 "\t\t\t\tsecIndex = 2;\n"
796 "\t\t\t\tsecClass = rxkad_NewClientSecurityObject(encLevel,\n"
797 "\t\t\t\t&Ksession, kvno, ticketLen, ticket);\n"
803 "\tassert(secClass);\n\n"
805 if (threadModel == PTHREADS) {
808 "\tthr_setconcurrency(numThreads);\n"
810 "\ttid = (pthread_t *) "
811 "malloc(numThreads*(sizeof(pthread_t)));\n"
815 "\ttid = (PROCESS *) malloc(numThreads*(sizeof(PROCESS *)));\n"
821 "\tfor(j=0;j<numThreads;j++) {\n"
823 if (threadModel == PTHREADS) {
825 "\t\ti = pthread_create(&tid[j], (const pthread_attr_t *) 0,\n"
826 "\t\tthreadFunc, (void *) numIterations);\n"
827 "\t\tassert(i==0);\n"
831 "\t\tLWP_CALL(LWP_CreateProcess,(threadFunc, 10*4096, LWP_NORMAL_PRIORITY, numIterations, \"foo\", &tid[j]));\n"
837 "\tfor(j=0;j<numThreads;j++) {\n"
839 if (threadModel == PTHREADS) {
841 "\t\ti = pthread_join(tid[j], (void **) 0);\n"
842 "\t\tassert(i==0);\n"
845 fprintf(itl_h, "\t\tLWP_CALL(LWP_WaitProcess,(&done));\n");
855 * Write command syntax function
859 "static void SetupRunCmd(void) {\n"
860 "\tstruct cmd_syndesc *ts;\n"
861 "\tts = cmd_CreateSyntax((char *) 0,DoRun, 0, \"run the test client program\");\n"
862 "\tcmd_AddParm(ts, \"-threadCount\", CMD_SINGLE, CMD_REQUIRED, \"number of threads to spawn\");\n"
863 "\tcmd_AddParm(ts, \"-iterationCount\", CMD_SINGLE, CMD_REQUIRED, \"number of iterations to make over entire interface for each thread\");\n"
864 "\tcmd_AddParm(ts, \"-secType\", CMD_SINGLE, CMD_REQUIRED, \"security level to use (1 -> unauthenticated, 2 -> authenticated)\");\n"
865 "\tcmd_AddParm(ts, \"-encLevel\", CMD_SINGLE, CMD_REQUIRED, \"encryption level to use, (0-> rxkad_clear, 1 -> rxkad_auth, 2 -> rxkad_crypt)\");\n"
866 "\tcmd_AddParm(ts, \"-serverPort\", CMD_SINGLE, CMD_REQUIRED, \"port that server is using\");\n"
867 "\tcmd_AddParm(ts, \"-serverHost\", CMD_SINGLE, CMD_REQUIRED, \"host where server is running\");\n"
876 "int main (int argc, char *argv[]) {\n"
878 "\tinitialize_cmd_error_table();\n"
880 "\tcode = cmd_Dispatch(argc, argv);\n\n"
888 * Create macros useful for checking input/output parameters
891 PRIVATE void WriteTestMacros(FILE *f) {
893 "\n#define CHECKchar(x,y,z) if ((x)!=(y)) { printf(\"%%s: Got '%%c',"
894 "expected '%%c'\\n\", z, (char)x, (char)(y)); fflush(stdout); "
896 "\n#define CHECKshort(x,y,z) if ((x)!=(y)) "
897 "{ printf(\"%%s: Got 0x%%04x, "
898 "expected 0x%%04x\\n\", z, x, y); fflush(stdout); "
900 "\n#define CHECKint32(x,y,z) if ((x)!=(y)) "
901 "{ printf(\"%%s: Got 0x%%08x, "
902 "expected 0x%%08x\\n\", z, x, y); fflush(stdout); "
904 "\n#define CHECKfloat(x,y,z) if (((x)/(y)<.999999) "
905 "|| ((x)/(y)>1.000001)) "
906 "{ printf(\"%%s: Got %%2.8e, expected %%2.8e\\n\", z, x, y); "
909 "\n#define CHECKdouble(x,y,z) if (((x)/(y)<.999999999999999) || "
910 "((x)/(y)>1.000000000000001)) { printf(\"%%s: Got %%2.16e, "
911 "expected %%2.16e\\n\", z, x, y); fflush(stdout); errFlag = 1; }"
912 "\n#define CHECKvarString(x,y,z) if (strcmp((x),(y))) { printf(\"%%s: "
913 "Got \\\"%%s\\\", expected \\\"%%s\\\"\\n\", z, x, y); fflush(stdout); "
914 "errFlag = 1; } \n");
918 * WriteCltHeader - write the begining of the client code.
920 PRIVATE void WriteCltHeader(char *serverName, int srv_no, FILE *itl_h)
922 fprintf(itl_h, "#include <stdio.h>\n");
923 if (threadModel == PTHREADS) {
924 fprintf(itl_h,"#include <pthread.h>\n");
928 "#include <assert.h>\n"
929 "#include <rx/rx.h>\n"
930 "#include <rx/rx_null.h>\n"
931 "#include <rx/rxkad.h>\n"
932 "#include <afs/cmd.h>\n"
933 "#include \"%s%d.h\"\n"
935 platform[4], serverName, srv_no);
936 if (threadModel == LWPS) {
938 "\n\n#define LWP_CALL(fnName, params) \\\n"
941 "\trc = fnName params; \\\n"
942 "\tif (rc != LWP_SUCCESS) { \\\n"
943 "\t\tprintf(\"call to %%s failed with %%d\\n\", # fnName, rc); \\\n"
951 "struct ktc_encryptionKey serviceKey =\n"
952 "\t{0x45, 0xe3, 0x3d, 0x16, 0x29, 0x64, 0x8a, 0x8f};\n"
953 "long serviceKeyVersion = 7;\n"
954 "\nextern struct hostent *hostutil_GetHostByName();\n\n"
955 "static long GetTicket (long *versionP,\n"
956 "\tstruct ktc_encryptionKey *session,\n"
957 "\tint * ticketLenP, char *ticket)\n"
960 "\tdes_init_random_number_generator (&serviceKey);\n"
961 "\tcode = des_random_key (session);\n"
962 "\tif (code) return code;\n"
963 "\t*ticketLenP = 0;\n"
964 "\tcode = tkt_MakeTicket(ticket, ticketLenP, &serviceKey,\n"
965 "\t\t\"tclnt\", \"\", \"\",\n"
966 "\t\t0, 0xffffffff, session, 0,\n"
967 "\t\t\"tsrvr\", \"\");\n"
968 "\tif (code) return code;\n"
969 "\t*versionP = serviceKeyVersion;\n"
972 "static int secType,encLevel,serverPort,serverAddr;\n"
973 "struct rx_securityClass *secClass;\n"
976 "char ticket[MAXKTCTICKETLEN];\n"
978 "struct ktc_encryptionKey Ksession;\n\n"
980 WriteTestMacros(itl_h);
985 * WriteCltInit -- write the initialization for each param
987 PRIVATE void WriteCltInit(arg_tuple *arg, FILE *itl_h, int i,
991 char *s = (structFlag) ? "s." : "";
993 if ((!strncmp(arg->direction, "IN", 2) || structFlag)) {
994 if (!strncmp(arg->type, "varString", 9)) {
995 fprintf(itl_h, "\tstrcpy(%sa%d, %s);\n", s, i, arg->inValue[0]);
997 else if (!strncmp(arg->type, "ar_", 3)) {
999 fprintf(itl_h, "\t%sa%d.drpc_out_%s_t_len = FIX_ARRAY_SIZE;\n",
1002 "\t%sa%d.drpc_out_%s_t_val = "
1003 "(%s *) malloc(FIX_ARRAY_SIZE * sizeof(%s));\n",
1004 s, i, arg->type, (arg->type + 3), (arg->type + 3));
1006 for(j=0;j<IDL_FIX_ARRAY_SIZE;j++) {
1009 "\t%sa%d[%d] = %s;\n",
1010 s, i, j,arg->inValue[j]);
1014 "\t%sa%d.drpc_out_%s_t_val[%d] = %s;\n",
1015 s, i, arg->type,j,arg->inValue[j]);
1020 fprintf(itl_h, "\t%sa%d = %s;\n", s, i, arg->inValue[0]);
1026 * WriteCltCall -- write each parameter for a call
1028 PRIVATE void WriteCltCall(arg_tuple *arg, FILE *itl_h, int i) {
1030 if (!strncmp(arg->type, "varString", 9)) {
1031 if ((!strncmp(arg->direction, "OUT", 3)) ||
1032 (!strncmp(arg->direction, "INOUT", 5))) {
1033 fprintf(itl_h, "&a%d_p", i);
1036 fprintf(itl_h, "a%d_p", i);
1040 if ((!strncmp(arg->direction, "OUT", 3)) ||
1041 (!strncmp(arg->direction, "INOUT", 5)) ||
1042 (!strncmp(arg->type, "ar_", 3))) {
1043 fprintf(itl_h, "&a%d", i);
1046 fprintf(itl_h, "a%d", i);
1052 * WriteCltDecl -- write the declaration for a parameter
1054 PRIVATE void WriteCltDecl(arg_tuple *arg, FILE *itl_h, int i) {
1056 if (!strncmp(arg->type, "ar_", 3)) {
1057 if (!strncmp(arg->direction, "OUT", 3)) {
1058 fprintf(itl_h, "\tdrpc_out_%s_t a%d = {0,0};\n", arg->type, i);
1061 fprintf(itl_h, "\tdrpc_out_%s_t a%d;\n", arg->type, i);
1064 else if (!strncmp(arg->type, "varString", 9)) {
1065 fprintf(itl_h, "\tchar a%d[STR_MAX];\n", i);
1066 fprintf(itl_h, "\tchar *a%d_p = a%d;\n", i, i);
1069 fprintf(itl_h, "\t%s a%d;\n", arg->type, i);
1075 * WriteClt -- write the rpcs in the client
1077 PRIVATE void WriteClt(rpcArgs *argsP, char *serverName, int sign_no, FILE *itl_h)
1079 char *name, *name2, *typ;
1082 name = GetName(serverName, sign_no);
1083 name2 = GetDescription(argsP);
1085 fprintf(itl_h, "\n/* %s */\n\n", name2);
1087 fprintf(itl_h, "\nvoid C_%s(struct rx_connection *conn) {\n", name);
1089 /* declare each arg */
1090 for (i=0; i < argsP->argCount; i++) {
1091 WriteCltDecl(&argsP->argDescr[i], itl_h, i);
1093 fprintf(itl_h, "\tint error;\n\tint errFlag;\n\n");
1095 /* initialize IN/INOUT args */
1096 for (i=0; i < argsP->argCount; i++) {
1097 WriteCltInit(&argsP->argDescr[i], itl_h, i, FALSE);
1100 /* call the server */
1101 fprintf(itl_h, "\terror = A%s(conn, ", name);
1104 for (i=0; i < argsP->argCount; i++) {
1105 WriteCltCall(&argsP->argDescr[i], itl_h, i);
1106 fprintf(itl_h, ((i < (argsP->argCount -1))) ? "," : ");\n");
1110 "\tif (error != 0) {\n"
1111 "\t\tprintf(\"C_%s failed %%d\\n\", error);\n"
1112 "\t\tfflush(stdout);\n"
1118 * check the in and inout parameters
1120 for (i=0; i < argsP->argCount; i++) {
1122 if ((!strcmp(argsP->argDescr[i].direction, "OUT")) ||
1123 (!strcmp(argsP->argDescr[i].direction, "INOUT"))) {
1125 typ = argsP->argDescr[i].type;
1127 if(!strncmp(typ, "ar_", 3)) {
1128 for(j=0;j<IDL_FIX_ARRAY_SIZE;j++)
1129 fprintf(itl_h, "\n\tCHECK%s(a%d.drpc_out_%s_t_val[%d], %s, \"C_%s_s\");",
1130 (typ+3), i, typ, j, argsP->argDescr[i].outValue[j],
1133 else if (strstr(typ, "String")) {
1134 fprintf(itl_h, "\n\tCHECK%s((char *)a%d, %s, \"C_%s_s\");",
1135 typ, i, argsP->argDescr[i].outValue[0], name);
1136 } else if (!strcmp(typ, "afs_int32")) {
1137 fprintf(itl_h, "\n\tCHECK%s(a%d, %sL, \"C_%s_s\");",
1138 typ, i, argsP->argDescr[i].outValue[0], name);
1140 fprintf(itl_h, "\n\tCHECK%s(a%d, %s, \"C_%s_s\");",
1141 typ, i, argsP->argDescr[i].outValue[0], name);
1147 * free up memory for dynamic input args
1149 for (i=0; i < argsP->argCount; i++) {
1150 if (!strncmp(argsP->argDescr[i].type, "ar_", 3)) {
1151 typ = argsP->argDescr[i].type;
1152 fprintf(itl_h, "\n\tif (a%d.drpc_out_%s_t_val) "
1153 "free(a%d.drpc_out_%s_t_val);", i, typ, i, typ);
1158 fprintf(itl_h, "\n}\n");
1161 * Call the structure oriented rpc interface
1164 fprintf(itl_h, "\nvoid C_%s_s(struct rx_connection *conn) {\n", name);
1165 fprintf(itl_h, "\tstruct %s_t s;\n", name);
1166 fprintf(itl_h, "\tint error;\n\tint errFlag;\n\n");
1168 /* initialize IN/INOUT args */
1169 for (i=0; i < argsP->argCount; i++) {
1170 WriteCltInit(&argsP->argDescr[i], itl_h, i, TRUE);
1173 /* call the server */
1174 fprintf(itl_h, "\terror = A%s_s(conn, &s);\n", name);
1177 "\tif (error != 0) {\n"
1178 "\t\tprintf(\"C_%s_s failed %%d\\n\", error);\n"
1179 "\t\tfflush(stdout);\n"
1185 * check the in and inout parameters
1187 for (i=0; i < argsP->argCount; i++) {
1189 if ((!strcmp(argsP->argDescr[i].direction, "OUT")) ||
1190 (!strcmp(argsP->argDescr[i].direction, "INOUT"))) {
1192 typ = argsP->argDescr[i].type;
1194 if(!strncmp(typ, "ar_", 3)) {
1195 for(j=0;j<IDL_FIX_ARRAY_SIZE;j++)
1196 fprintf(itl_h, "\n\tCHECK%s(s.a%d[%d], %s, \"C_%s_s\");",
1197 (typ+3), i, j, argsP->argDescr[i].outValue[j],
1200 else if (strstr(typ, "String")) {
1201 fprintf(itl_h, "\n\tCHECK%s((char *)s.a%d, %s, \"C_%s_s\");",
1202 typ, i, argsP->argDescr[i].outValue[0], name);
1203 } else if (!strcmp(typ, "afs_int32")) {
1204 fprintf(itl_h, "\n\tCHECK%s(s.a%d, %sL, \"C_%s_s\");",
1205 typ, i, argsP->argDescr[i].outValue[0], name);
1207 fprintf(itl_h, "\n\tCHECK%s(s.a%d, %s, \"C_%s_s\");",
1208 typ, i, argsP->argDescr[i].outValue[0], name);
1214 fprintf(itl_h, "\n}\n");
1221 * WriteXGHeader -- fill in Header info in the xg file
1223 PRIVATE void WriteXGHeader(char *serverName, FILE *xg_h, int srv_no)
1226 /* create the interface header */
1229 "\n/* Do not edit this file -- it was created by a generator */\n"
1231 "const STR_MAX = %d; \n"
1232 "const FIX_ARRAY_SIZE = %d; \n"
1233 "typedef char drpc_char_t; \n"
1234 "typedef short drpc_short_t; \n"
1235 "typedef long drpc_int32_t; \n"
1236 "typedef string drpc_varString_t<STR_MAX>; \n"
1237 "typedef drpc_char_t drpc_ar_char_t[FIX_ARRAY_SIZE]; \n"
1238 "typedef drpc_char_t drpc_out_ar_char_t<FIX_ARRAY_SIZE>; \n"
1239 "typedef drpc_short_t drpc_ar_short_t[FIX_ARRAY_SIZE]; \n"
1240 "typedef drpc_short_t drpc_out_ar_short_t<FIX_ARRAY_SIZE>; \n"
1241 "typedef drpc_int32_t drpc_ar_int32_t[FIX_ARRAY_SIZE]; \n"
1242 "typedef drpc_int32_t drpc_out_ar_int32_t<FIX_ARRAY_SIZE>; \n"
1244 IDL_STR_MAX, IDL_FIX_ARRAY_SIZE);
1248 * WriteServHeader -- fill in the Header info in the server file
1250 PRIVATE void WriteServHeader(FILE *srv_h, char *serverName, int srv_no)
1254 name = GetName(serverName, srv_no);
1257 "\n/* Do not edit this file -- it's been created by a generator */\n\n"
1259 "#include <stdio.h>\n"
1260 "#include <string.h>\n"
1261 "#include <stdlib.h>\n"
1262 "#include <rx/rx.h>\n"
1263 "#include <rx/rx_null.h>\n"
1264 "#include <rx/rxkad.h>\n"
1265 "#include <afs/cmd.h>\n"
1266 "#include \"%s.h\"\n\n"
1267 "struct ktc_encryptionKey serviceKey =\n"
1268 "\t{0x45, 0xe3, 0x3d, 0x16, 0x29, 0x64, 0x8a, 0x8f};\n"
1269 "long serviceKeyVersion = 7;\n\n"
1270 "extern int AExecuteRequest();\n"
1271 "extern char *optarg;\n"
1272 "extern int optind, opterr, optopt;\n\n"
1273 "#define VERIFY(x,y) if (!(x)) { printf y ; exit(1); }\n"
1274 "#define CHECK(x) ASSERT(x)\n"
1278 WriteTestMacros(srv_h);
1283 * WriteServTrailer -- finish up the server file
1285 PRIVATE void WriteServTrailer(FILE *srv_h) {
1288 "\nstatic long GetKey (char *rock, long kvno, struct ktc_encryptionKey *key) {\n"
1289 "\tmemcpy ((void *) key, (void *) &serviceKey, sizeof(*key));\n"
1293 "static void DoRun(struct cmd_syndesc *as, char *arock) {\n"
1294 "\tstruct rx_service *serv;\n"
1295 "\tstruct rx_securityClass *sc[3];\n\n"
1296 "\tint port=0, errflg=0;\n"
1298 "\tint lowThreads=4, highThreads=8;\n"
1299 "\tlowThreads = atoi(as->parms[0].items->data);\n"
1300 "\thighThreads = atoi(as->parms[1].items->data);\n"
1301 "\tport = atoi(as->parms[2].items->data);\n"
1303 "\tif (port == 0) errflg++;\n"
1306 "\t\tprintf(\"invalid argument\\n\");\n"
1310 "\trx_Init(htons(port));\n"
1311 "\tsc[0] = rxnull_NewServerSecurityObject();\n"
1313 "\tsc[2] = rxkad_NewServerSecurityObject (rxkad_clear, 0, GetKey, 0);\n"
1314 "\tif (serv = rx_NewService(0,4,\"foo\",sc,3,AExecuteRequest)) {\n"
1315 "\t\trx_SetMinProcs(serv,lowThreads);\n"
1316 "\t\trx_SetMaxProcs(serv,highThreads);\n"
1317 "\t\trx_StartServer(1);\n"
1322 "static void SetupRunCmd(void) {\n"
1323 "\tstruct cmd_syndesc *ts;\n"
1324 "\tts = cmd_CreateSyntax((char *) 0,DoRun, 0, \"run the test server program\");\n"
1325 "\tcmd_AddParm(ts, \"-lowThreadCount\", CMD_SINGLE, CMD_REQUIRED, \"minimum number of threads to spawn\");\n"
1326 "\tcmd_AddParm(ts, \"-highThreadCount\", CMD_SINGLE, CMD_REQUIRED, \"maximum number of threads to spawn\");\n"
1327 "\tcmd_AddParm(ts, \"-serverPort\", CMD_SINGLE, CMD_REQUIRED, \"port that server is using\");\n"
1330 "int main(int argc, char **argv) {\n"
1332 "\tinitialize_cmd_error_table();\n"
1333 "\tSetupRunCmd();\n"
1334 "\tcode = cmd_Dispatch(argc, argv);\n"
1341 * ProcessCmdLine -- processes the command line args
1343 PRIVATE void ProcessCmdLine(int argc, char **argv, char **serverName,
1344 char **ipFileName, char **outputDir)
1350 /* command line processing */
1351 while (--argc > 0) {
1352 if ((*++argv)[0] == '-') {
1353 switch ((*argv)[1]) {
1356 case 'F': /* input table file */
1357 *ipFileName = *++argv;
1360 case 'h': /* display help */
1366 case 'L': /* use LWP threads */
1370 case 'S': /* serverName */
1371 *serverName = *++argv;
1372 /* need 8 char file name, and so truncate the server name*/
1373 if ((int)strlen(*serverName) > MAX_SERV_NAME)
1374 *(*serverName+MAX_SERV_NAME) = '\0';
1379 *outputDir = *++argv;
1384 if(strcmp(*++argv,"NT")) platform = unix_symbols;
1398 FATAL("Please set server name using -s switch\n");
1402 void main(int argc, char **argv)
1404 FILE *table_h, *srv_h, *xg_h, *clt_h, *mak_h;
1407 char *name, *ifName;
1408 char *serverName = NULL;
1409 char *ipFileName = NULL;
1410 char *outputDir = NULL;
1411 int sign_no=0, start_no, srv_no;
1413 ProcessCmdLine(argc, argv, &serverName, &ipFileName, &outputDir);
1415 /* open input file */
1416 table_h = fopen(ipFileName, "r");
1417 MEM_CHK(table_h, "main: Unable to open input file\n");
1423 * open the first set of output files
1426 name = GetName(serverName, srv_no);
1428 srv_h = OpenOutFile(outputDir, name, "Srv.c");
1429 xg_h = OpenOutFile(outputDir, name, ".xg");
1430 clt_h = OpenOutFile(outputDir, name, "Clt.c");
1431 mak_h = OpenOutFile(outputDir, name, ".mak");
1433 WriteXGHeader(serverName, xg_h, srv_no);
1434 WriteServHeader(srv_h, serverName, srv_no);
1435 WriteCltHeader(serverName, srv_no, clt_h);
1436 WriteMake(serverName, srv_no, mak_h);
1440 /* read the table */
1441 while (fscanf(table_h, "%d", &(args.argCount)) != EOF) {
1443 /* increment signature number 8.3 format-- only 10^7 dif sign */
1445 if (sign_no > 1.0e+7)
1446 FATAL("Max no: of signatures overflow\n");
1448 /* allocate for the arg struct */
1449 args.argDescr = (arg_tuple *)calloc(args.argCount, sizeof(arg_tuple));
1450 MEM_CHK(args.argDescr, "main: Out of memory -- args.argDescr\n");
1452 /* pick out the dirs and the types */
1453 for (i=0; i < args.argCount; i++) {
1454 if(!fscanf(table_h, " ( %s %s )", args.argDescr[i].direction,
1455 args.argDescr[i].type)) {
1456 FATAL("main: Incorrect input file format\n");
1461 * switch files when we hit TESTS_PER_FILE
1463 if (sign_no - start_no >= TESTS_PER_FILE) {
1465 * Finish up the current files
1467 WriteServTrailer(srv_h);
1468 WriteCltTrailer(serverName, start_no, sign_no, clt_h);
1475 * Open the next set of output files
1480 name = GetName(serverName, srv_no);
1482 srv_h = OpenOutFile(outputDir, name, "Srv.c");
1483 xg_h = OpenOutFile(outputDir, name, ".xg");
1484 clt_h = OpenOutFile(outputDir, name, "Clt.c");
1485 mak_h = OpenOutFile(outputDir, name, ".mak");
1486 WriteXGHeader(serverName, xg_h, srv_no);
1487 WriteServHeader(srv_h, serverName, srv_no);
1488 WriteCltHeader(serverName, srv_no, clt_h);
1489 WriteMake(serverName, srv_no, mak_h);
1495 /* initialize parameter values */
1496 for (i=0; i<args.argCount; i++) {
1497 for (j = 0 ; j < IDL_FIX_ARRAY_SIZE ; j++) {
1498 args.argDescr[i].inValue[j] = NULL;
1499 args.argDescr[i].inValue2[j] = NULL;
1500 args.argDescr[i].outValue[j] = NULL;
1501 args.argDescr[i].outValue2[j] = NULL;
1504 GenParamValues(&args);
1506 /* write rpc desc into body of the interface */
1507 WriteXG(&args, xg_h, serverName, sign_no);
1509 /* write the rpc into the manager file */
1510 WriteServC(&args, srv_h, serverName, sign_no);
1512 /* write out ITL test */
1513 WriteClt(&args, serverName, sign_no, clt_h);
1515 /* free saved values */
1516 for (i=0; i<args.argCount; i++) {
1517 for (j = 0 ; j < IDL_FIX_ARRAY_SIZE ; j++) {
1518 if (args.argDescr[i].inValue[j])
1519 free(args.argDescr[i].inValue[j]);
1520 if (args.argDescr[i].inValue2[j])
1521 free(args.argDescr[i].inValue2[j]);
1522 if (args.argDescr[i].outValue[j])
1523 free(args.argDescr[i].outValue[j]);
1524 if (args.argDescr[i].outValue2[j])
1525 free(args.argDescr[i].outValue2[j]);
1528 free(args.argDescr);
1531 WriteServTrailer(srv_h);
1532 WriteCltTrailer(serverName, start_no, (sign_no +1), clt_h);
1542 * create 1 makefile that drives all the rest
1545 mak_h = OpenOutFile(outputDir, "Makefile", "");
1546 fprintf(mak_h, "\ntest:all\ntests:all\nall:\n");
1547 fprintf(mak_h, "%s", platform[8]);
1548 for(i=1;i<=srv_no;i++)
1549 fprintf(mak_h, "\t%s %s%d.mak %s\n",
1550 platform[0], serverName, i, platform[5]);
1551 fprintf(mak_h, "\nclean:\n");
1552 for(i=1;i<=srv_no;i++)
1553 fprintf(mak_h, "\t%s %s%d.mak clean\n", platform[0], serverName, i);