1 /* @(#)rpc_parse.c 1.1 87/11/04 3.9 RPCSRC */
3 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4 * unrestricted use provided that this legend is included on all tape
5 * media and as a part of the software program in whole or part. Users
6 * may copy or modify Sun RPC without charge, but are not authorized
7 * to license or distribute it to anyone else except as part of a product or
8 * program developed by the user.
10 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 * Sun RPC is provided with no support and without any obligation on the
15 * part of Sun Microsystems, Inc. to assist in its use, correction,
16 * modification or enhancement.
18 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20 * OR ANY PART THEREOF.
22 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23 * or profits or other special, indirect and consequential damages, even if
24 * Sun has been advised of the possibility of such damages.
26 * Sun Microsystems, Inc.
28 * Mountain View, California 94043
32 * rpc_parse.c, Parser for the RPC protocol compiler
33 * Copyright (C) 1987 Sun Microsystems, Inc.
35 #include <afsconfig.h>
36 #include <afs/param.h>
43 #include "rpc_parse.h"
46 list *proc_defined[MAX_PACKAGES], *special_defined, *typedef_defined,
47 *uniondef_defined, *complex_defined;
48 char *SplitStart = NULL;
49 char *SplitEnd = NULL;
50 char *MasterPrefix = NULL;
51 char *ServerPrefix = "";
52 char *PackagePrefix[MAX_PACKAGES];
53 char *PackageStatIndex[MAX_PACKAGES];
54 int no_of_stat_funcs = 0; /*
55 * current function number in client interface
58 int no_of_stat_funcs_header[MAX_PACKAGES]; /*
59 * Total number of functions in client
62 int no_of_opcodes[MAX_PACKAGES], master_no_of_opcodes = 0;
63 int lowest_opcode[MAX_PACKAGES], master_lowest_opcode = 99999;
64 int highest_opcode[MAX_PACKAGES], master_highest_opcode = 0;
65 int master_opcodenumber = 99999;
66 int opcodesnotallowed[MAX_PACKAGES];
67 int combinepackages = 0;
68 int PackageIndex = -1;
69 int PerProcCounter = 0;
74 * Character arrays to keep list of function names as we process the file
77 char function_list[MAX_PACKAGES]
78 [MAX_FUNCTIONS_PER_PACKAGE]
79 [MAX_FUNCTION_NAME_LEN];
80 int function_list_index;
82 /* static prototypes */
83 static void isdefined(definition * defp);
84 static void def_struct(definition * defp);
85 static void def_enum(definition * defp);
86 static void def_const(definition * defp);
87 static void def_union(definition * defp);
88 static void def_typedef(definition * defp);
89 static void get_declaration(declaration * dec, defkind dkind);
90 static void get_type(char **prefixp, char **typep, defkind dkind);
91 static void unsigned_dec(char **typep);
92 static void def_package(definition * defp);
93 static void def_prefix(definition * defp);
94 static void def_statindex(definition * defp);
95 static void def_startingopcode(definition * defp);
96 static void def_split(definition * defp);
97 static void customize_struct(definition * defp);
98 static char *structname(char *name);
99 static void def_special(declaration * dec, definition * defp);
100 static void check_proc(definition * defp, token * tokp, int noname);
101 static int InvalidConstant(char *name);
102 static int opcodenum_is_defined(int opcode_num);
103 static void analyze_ProcParams(definition * defp, token * tokp);
104 static void generate_code(definition * defp, int proc_split_flag,
106 static void handle_split_proc(definition * defp, int multi_flag);
107 static void do_split(definition * defp, int direction, int *numofparams,
108 defkind param_kind, int restore_flag);
109 static void hdle_param_tok(definition * defp, declaration * dec, token * tokp,
111 static void get1_param_type(definition * defp, declaration * dec,
113 static void get_param_type(definition * defp, declaration * dec,
114 char **param_type, char **typename);
116 static void hndle_param_tail(definition * defp, declaration * dec,
117 token * tokp, char *typename);
119 static void cs_Proc_CodeGeneration(definition * defp, int split_flag,
121 static void cs_ProcName_setup(definition * defp, char *procheader,
123 static void cs_ProcParams_setup(definition * defp, int split_flag);
124 static void cs_ProcMarshallInParams_setup(definition * defp, int split_flag);
125 static void cs_ProcSendPacket_setup(definition * defp, int split_flag);
126 static void cs_ProcUnmarshallOutParams_setup(definition * defp);
127 static void cs_ProcTail_setup(definition * defp, int split_flag);
128 static void ucs_ProcName_setup(definition * defp, char *procheader,
130 static void ucs_ProcParams_setup(definition * defp, int split_flag);
131 static void ucs_ProcTail_setup(definition * defp, int split_flag);
132 static void ss_Proc_CodeGeneration(definition * defp);
133 static void ss_ProcName_setup(definition * defp);
134 static void ss_ProcParams_setup(definition * defp);
135 static void ss_ProcSpecial_setup(definition * defp);
136 static void ss_ProcUnmarshallInParams_setup(definition * defp);
137 static void ss_ProcCallRealProc_setup(definition * defp);
138 static void ss_ProcMarshallOutParams_setup(definition * defp);
139 static void ss_ProcTail_setup(definition * defp);
140 static int opcode_holes_exist(void);
141 static void er_ProcDeclExterns_setup(void);
142 static void er_ProcProcsArray_setup(void);
143 static void er_ProcMainBody_setup(void);
144 static void er_HeadofOldStyleProc_setup(void);
145 static void er_HeadofOldStyleProc_setup2(void);
146 static void er_BodyofOldStyleProc_setup(void);
147 static void er_BodyofOldStyleProc_setup2(void);
148 static void proc_er_case(definition * defp);
149 static void er_TailofOldStyleProc_setup(void);
150 static void er_TailofOldStyleProc_setup2(void);
155 * return the next definition you see
163 defp = ALLOC(definition);
164 memset(defp, 0, sizeof(definition));
197 def_special(&dec, defp);
200 case TOK_STARTINGOPCODE:
201 def_startingopcode(defp);
206 customize_struct(defp);
208 case TOK_SPLITPREFIX:
213 if (tok.kind == TOK_LPAREN) {
215 check_proc(defp, &tok, 1);
217 check_proc(defp, &tok, 0);
220 check_proc(defp, &tok, 0);
224 check_proc(defp, &tok, 1);
227 error("definition keyword expected");
229 if (!IsRxgenToken(&tok)) {
230 scan(TOK_SEMICOLON, &tok);
238 isdefined(definition * defp)
240 STOREVAL(&defined, defp);
245 def_struct(definition * defp)
253 defp->def_kind = DEF_STRUCT;
255 scan(TOK_IDENT, &tok);
256 defp->def_name = tok.str;
257 scan(TOK_LBRACE, &tok);
258 tailp = &defp->def.st.decls;
260 get_declaration(&dec, DEF_STRUCT);
261 /* If a structure contains an array, then we're going
262 * to need to be clever about freeing it */
263 if (dec.rel == REL_ARRAY) {
266 decls = ALLOC(decl_list);
269 tailp = &decls->next;
270 scan(TOK_SEMICOLON, &tok);
272 } while (tok.kind != TOK_RBRACE);
277 STOREVAL(&complex_defined, defp);
281 def_enum(definition * defp)
285 enumval_list **tailp;
287 defp->def_kind = DEF_ENUM;
288 scan(TOK_IDENT, &tok);
289 defp->def_name = tok.str;
290 scan(TOK_LBRACE, &tok);
291 tailp = &defp->def.en.vals;
293 scan(TOK_IDENT, &tok);
294 elist = ALLOC(enumval_list);
295 elist->name = tok.str;
296 elist->assignment = NULL;
297 scan3(TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok);
298 if (tok.kind == TOK_EQUAL) {
300 elist->assignment = tok.str;
301 scan2(TOK_COMMA, TOK_RBRACE, &tok);
304 tailp = &elist->next;
305 } while (tok.kind != TOK_RBRACE);
310 def_const(definition * defp)
314 defp->def_kind = DEF_CONST;
315 scan(TOK_IDENT, &tok);
316 defp->def_name = tok.str;
317 scan(TOK_EQUAL, &tok);
318 scan2(TOK_IDENT, TOK_STRCONST, &tok);
319 defp->def.co = tok.str;
323 def_union(definition * defp)
330 defp->def_kind = DEF_UNION;
331 scan(TOK_IDENT, &tok);
332 defp->def_name = tok.str;
333 scan(TOK_SWITCH, &tok);
334 scan(TOK_LPAREN, &tok);
335 get_declaration(&dec, DEF_UNION);
336 defp->def.un.enum_decl = dec;
337 tailp = &defp->def.un.cases;
338 scan(TOK_RPAREN, &tok);
339 scan(TOK_LBRACE, &tok);
340 scan(TOK_CASE, &tok);
341 while (tok.kind == TOK_CASE) {
342 scan(TOK_IDENT, &tok);
343 cases = ALLOC(case_list);
344 cases->case_name = tok.str;
345 scan(TOK_COLON, &tok);
346 get_declaration(&dec, DEF_UNION);
347 cases->case_decl = dec;
349 tailp = &cases->next;
350 scan(TOK_SEMICOLON, &tok);
351 scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
354 if (tok.kind == TOK_DEFAULT) {
355 scan(TOK_COLON, &tok);
356 get_declaration(&dec, DEF_UNION);
357 defp->def.un.default_decl = ALLOC(declaration);
358 *defp->def.un.default_decl = dec;
359 scan(TOK_SEMICOLON, &tok);
360 scan(TOK_RBRACE, &tok);
362 defp->def.un.default_decl = NULL;
368 def_typedef(definition * defp)
372 memset(&dec, 0, sizeof(dec));
374 defp->def_kind = DEF_TYPEDEF;
375 get_declaration(&dec, DEF_TYPEDEF);
376 defp->def_name = dec.name;
377 defp->def.ty.old_prefix = dec.prefix;
378 defp->def.ty.old_type = dec.type;
379 defp->def.ty.rel = dec.rel;
380 defp->def.ty.array_max = dec.array_max;
385 get_declaration(declaration * dec, defkind dkind)
389 get_type(&dec->prefix, &dec->type, dkind);
390 dec->rel = REL_ALIAS;
391 if (streq(dec->type, "void")) {
394 scan2(TOK_STAR, TOK_IDENT, &tok);
395 if (tok.kind == TOK_STAR) {
396 dec->rel = REL_POINTER;
397 scan(TOK_IDENT, &tok);
400 if (peekscan(TOK_LBRACKET, &tok)) {
401 if (dec->rel == REL_POINTER) {
402 error("no array-of-pointer declarations -- use typedef");
404 dec->rel = REL_VECTOR;
406 dec->array_max = tok.str;
407 scan(TOK_RBRACKET, &tok);
408 } else if (peekscan(TOK_LANGLE, &tok)) {
409 if (dec->rel == REL_POINTER) {
410 error("no array-of-pointer declarations -- use typedef");
412 dec->rel = REL_ARRAY;
413 if (peekscan(TOK_RANGLE, &tok)) {
414 dec->array_max = "~0u"; /* unspecified size, use max */
417 dec->array_max = tok.str;
418 scan(TOK_RANGLE, &tok);
421 if (streq(dec->type, "opaque")) {
422 if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
423 error("array declaration expected");
425 } else if (streq(dec->type, "string")) {
426 if (dec->rel != REL_ARRAY) {
427 error(" variable-length array declaration expected");
434 get_type(char **prefixp, char **typep, defkind dkind)
448 scan(TOK_IDENT, &tok);
456 (void)peekscan(TOK_INT, &tok);
459 *typep = "afs_int32";
460 (void)peekscan(TOK_INT, &tok);
463 if (dkind != DEF_UNION) {
464 error("voids allowed only inside union definitions");
479 error("expected type specifier");
485 unsigned_dec(char **typep)
498 (void)peekscan(TOK_INT, &tok);
502 *typep = "afs_uint32";
503 (void)peekscan(TOK_INT, &tok);
517 def_package(definition * defp)
521 defp->def_kind = DEF_PACKAGE;
522 scan(TOK_IDENT, &tok);
523 defp->def_name = tok.str;
524 no_of_stat_funcs = 0;
527 if (PackageIndex >= MAX_PACKAGES)
528 error("Exceeded upper limit of package statements\n");
530 function_list_index = 0;
531 PackagePrefix[PackageIndex] = tok.str;
532 if (MasterPrefix == NULL)
533 MasterPrefix = tok.str;
534 no_of_opcodes[PackageIndex] = highest_opcode[PackageIndex] =
535 opcodesnotallowed[PackageIndex] = 0;
536 lowest_opcode[PackageIndex] = 99999;
537 proc_defined[PackageIndex] = NULL;
538 PackageStatIndex[PackageIndex] = NULL;
542 def_prefix(definition * defp)
546 defp->def_kind = DEF_PREFIX;
547 scan(TOK_IDENT, &tok);
548 defp->def_name = tok.str;
549 ServerPrefix = tok.str;
553 def_statindex(definition * defp)
558 defp->def_kind = DEF_CONST;
560 if (PackageIndex < 0)
561 error("'statindex' command must follow 'package' command!\n");
562 if (PackageStatIndex[PackageIndex])
563 error("Cannot have more then one 'statindex' per package!\n");
564 if (InvalidConstant(tok.str))
565 error("Index in 'statindex' command must be a constant!");
567 alloc(strlen(PackagePrefix[PackageIndex]) + strlen("STATINDEX") + 1);
568 strcpy(name, PackagePrefix[PackageIndex]);
569 strcat(name, "STATINDEX");
570 defp->def_name = name;
571 defp->def.co = tok.str;
572 PackageStatIndex[PackageIndex] = name;
573 StatIndex = atoi(tok.str);
577 def_startingopcode(definition * defp)
581 defp->def_kind = DEF_STARTINGOPCODE;
582 scan(TOK_IDENT, &tok);
583 defp->def_name = tok.str;
584 if (InvalidConstant(defp->def_name))
585 error("Opcode in 'startingopcode' command must be a constant!");
586 lowest_opcode[PackageIndex] = master_lowest_opcode = atoi(tok.str);
587 if (lowest_opcode[PackageIndex] < 0
588 || lowest_opcode[PackageIndex] > 99999)
590 ("startingopcode number is out of bounds (must be >= 0 < 100000)");
591 master_opcodenumber = lowest_opcode[PackageIndex];
592 opcodesnotallowed[PackageIndex] = 1;
596 def_split(definition * defp)
600 defp->def_kind = DEF_SPLITPREFIX;
605 scan(TOK_EQUAL, &tok);
606 scan(TOK_IDENT, &tok);
607 SplitStart = tok.str;
610 scan(TOK_EQUAL, &tok);
611 scan(TOK_IDENT, &tok);
617 error("syntax error in the 'splitprefix' line");
619 } while (tok.kind != TOK_SEMICOLON);
620 if (!SplitStart && !SplitEnd)
621 error("At least one param should be passed to 'splitprefix' cmd");
626 customize_struct(definition * defp)
630 definition *defp1 = ALLOC(definition);
631 spec_list *specs, **tailp;
633 defp->def_kind = DEF_CUSTOMIZED;
634 defp1->def_kind = DEF_SPECIAL;
635 tailp = &defp1->def.sd.specs;
636 for (listp = defp->def.st.decls; listp; listp = listp->next) {
638 if (streq(dec->type, "string") || (dec->rel == REL_POINTER)) {
639 specs = ALLOC(spec_list);
640 specs->sdef.string_name = dec->name;
641 specs->sdef.string_value = defp->def_name;
643 tailp = &specs->next;
647 STOREVAL(&special_defined, defp1);
651 structname(char *name)
653 static char namecontents[150];
656 strcpy(namecontents, name);
658 if (!strncmp(pnt, "struct", 6))
660 while (isspace(*pnt))
663 while (*pnt != ' ' && *pnt != '\0')
671 def_special(declaration * dec, definition * defp)
674 spec_list *specs, **tailp;
677 defp->def_kind = DEF_SPECIAL;
678 get_type(&dec->prefix, &dec->type, DEF_SPECIAL);
679 dec->rel = REL_POINTER;
680 scan(TOK_IDENT, &tok);
681 tailp = &defp->def.sd.specs;
683 specs = ALLOC(spec_list);
684 specs->sdef.string_name = tok.str;
685 get_param_type(defp, dec, &specs->sdef.string_value, &typename);
687 tailp = &specs->next;
688 scan2(TOK_COMMA, TOK_SEMICOLON, &tok);
689 if (tok.kind == TOK_SEMICOLON)
692 } while (tok.kind == TOK_IDENT);
694 STOREVAL(&special_defined, defp);
698 proc1_list *Proc_list, **Proc_listp;
701 check_proc(definition * defp, token * tokp, int noname)
707 if (PackageIndex < 0)
708 error("Procedure must be in a package!\n");
710 tokp->kind = TOK_PROC;
711 defp->def_kind = DEF_PROC;
713 defp->pc.proc_name = "";
715 defp->pc.proc_name = tokp->str;
717 defp->pc.proc_prefix = alloc(strlen(PackagePrefix[PackageIndex]) + 1);
718 strcpy(defp->pc.proc_prefix, PackagePrefix[PackageIndex]);
719 scan2(TOK_LPAREN, TOK_IDENT, &tok);
720 defp->pc.proc_serverstub = NULL;
721 if (tok.kind == TOK_IDENT) {
722 defp->pc.proc_serverstub = tok.str;
723 scan(TOK_LPAREN, &tok);
725 analyze_ProcParams(defp, &tok);
726 defp->pc.proc_opcodenum = -1;
727 scan4(TOK_SPLIT, TOK_MULTI, TOK_EQUAL, TOK_SEMICOLON, &tok);
728 if (tok.kind == TOK_MULTI) {
730 defp->pc.multi_flag = 1;
731 scan2(TOK_EQUAL, TOK_SEMICOLON, &tok);
733 defp->pc.multi_flag = 0;
735 if (tok.kind == TOK_SPLIT) {
737 defp->pc.split_flag = 1;
738 scan2(TOK_EQUAL, TOK_SEMICOLON, &tok);
740 defp->pc.split_flag = 0;
742 if (tok.kind == TOK_EQUAL) {
743 if (opcodesnotallowed[PackageIndex])
744 error("Opcode assignment isn't allowed here!");
746 if (InvalidConstant(tok.str))
747 error("Illegal Opcode assignment (Must be a constant opcode!)");
748 if (opcodenum_is_defined(atoi(tok.str)))
749 error("The opcode number is already used by a previous proc");
750 defp->pc.proc_opcodename = tok.str;
751 defp->pc.proc_opcodenum = atoi(tok.str);
752 if (defp->pc.proc_opcodenum < lowest_opcode[PackageIndex])
753 lowest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
754 if (defp->pc.proc_opcodenum < master_lowest_opcode)
755 master_lowest_opcode = defp->pc.proc_opcodenum;
756 if (defp->pc.proc_opcodenum > highest_opcode[PackageIndex])
757 highest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
758 if (defp->pc.proc_opcodenum > master_highest_opcode)
759 master_highest_opcode = defp->pc.proc_opcodenum;
760 scan(TOK_SEMICOLON, &tok);
762 if (master_opcodenumber == 99999)
763 master_opcodenumber = 0;
764 defp->pc.proc_opcodenum = master_opcodenumber++;
765 if (defp->pc.proc_opcodenum < lowest_opcode[PackageIndex])
766 lowest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
767 if (defp->pc.proc_opcodenum > highest_opcode[PackageIndex])
768 highest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
769 if (defp->pc.proc_opcodenum > master_highest_opcode)
770 master_highest_opcode = defp->pc.proc_opcodenum;
771 opcodesnotallowed[PackageIndex] = 1; /* force it */
773 no_of_opcodes[PackageIndex]++, master_no_of_opcodes++;
775 generate_code(defp, 0, 1);
776 if (Cflag || cflag) {
777 generate_code(defp, 1, 1);
779 generate_multi_macros(defp);
781 generate_code(defp, proc_split, 0);
784 if (function_list_index >= MAX_FUNCTIONS_PER_INTERFACE) {
785 error("too many functions in interface, "
786 "increase MAX_FUNCTIONS_PER_INTERFACE");
788 sprintf(function_list[PackageIndex][function_list_index], "%s%s%s",
789 prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
791 function_list_index++;
792 defp->statindex = no_of_stat_funcs;
793 no_of_stat_funcs_header[PackageIndex]++;
799 #define LEGALNUMS "0123456789"
801 InvalidConstant(char *name)
807 slen = (int)strlen(name);
808 return (slen != strspn(name, map));
812 opcodenum_is_defined(int opcode_num)
817 for (listp = proc_defined[PackageIndex]; listp != NULL;
818 listp = listp->next) {
819 defp = (definition *) listp->val;
820 if (opcode_num == defp->pc.proc_opcodenum)
828 analyze_ProcParams(definition * defp, token * tokp)
831 decl_list *decls, **tailp;
833 Proc_listp = &defp->pc.plists;
834 tailp = &defp->def.st.decls;
837 Proc_list = ALLOC(proc1_list);
838 memset(Proc_list, 0, sizeof(proc1_list));
839 Proc_list->pl.param_flag = 0;
840 switch (tokp->kind) {
842 hdle_param_tok(defp, &dec, tokp, DEF_INPARAM);
845 hdle_param_tok(defp, &dec, tokp, DEF_OUTPARAM);
848 hdle_param_tok(defp, &dec, tokp, DEF_INOUTPARAM);
854 hdle_param_tok(defp, &dec, tokp, DEF_NULL);
857 *Proc_listp = Proc_list;
858 Proc_listp = &Proc_list->next;
859 decls = ALLOC(decl_list);
860 memset(decls, 0, sizeof(decl_list));
861 if (tokp->kind != TOK_RPAREN)
864 tailp = &decls->next;
865 } while (tokp->kind != TOK_RPAREN);
871 generate_code(definition * defp, int proc_split_flag, int multi_flag)
874 handle_split_proc(defp, multi_flag);
876 if (Cflag || cflag) {
877 cs_Proc_CodeGeneration(defp, 0, "");
880 ss_Proc_CodeGeneration(defp);
882 if (Sflag || (cflag && xflag && !proc_split_flag) || hflag)
883 STOREVAL(&proc_defined[PackageIndex], defp);
888 handle_split_proc(definition * defp, int multi_flag)
890 char *startname = SplitStart, *endname = SplitEnd;
897 if (Cflag || cflag) {
899 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 0);
901 cs_Proc_CodeGeneration(defp, 1, startname);
903 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 1);
904 do_split(defp, IN, &numofparams, DEF_INPARAM, 0);
906 cs_Proc_CodeGeneration(defp, (multi_flag ? 3 : 2), endname);
908 do_split(defp, IN, &numofparams, DEF_INPARAM, 1);
912 ss_Proc_CodeGeneration(defp);
917 do_split(definition * defp, int direction, int *numofparams,
918 defkind param_kind, int restore_flag)
923 defp->pc.paramtypes[direction] = *numofparams;
924 for (plist = defp->pc.plists; plist; plist = plist->next) {
925 if (plist->component_kind == DEF_NULL
926 && plist->pl.param_kind == param_kind)
927 plist->component_kind = DEF_PARAM;
930 *numofparams = defp->pc.paramtypes[direction];
931 defp->pc.paramtypes[direction] = 0;
932 for (plist = defp->pc.plists; plist; plist = plist->next) {
933 if (plist->component_kind == DEF_PARAM
934 && plist->pl.param_kind == param_kind)
935 plist->component_kind = DEF_NULL;
942 hdle_param_tok(definition * defp, declaration * dec, token * tokp,
945 static defkind last_param_kind = DEF_NULL;
947 if (par_kind == DEF_NULL)
948 Proc_list->pl.param_kind = last_param_kind;
950 Proc_list->pl.param_kind = par_kind;
951 last_param_kind = Proc_list->pl.param_kind;
952 defp->pc.paramtypes[(int)last_param_kind]++;
953 Proc_list->component_kind = DEF_PARAM;
954 Proc_list->code = alloc(250);
955 Proc_list->scode = alloc(250);
956 get_declaration(dec, DEF_PARAM);
957 Proc_list->pl.param_name = dec->name;
958 get1_param_type(defp, dec, &Proc_list->pl.param_type);
960 scan2(TOK_COMMA, TOK_RPAREN, tokp);
961 if (tokp->kind == TOK_COMMA)
967 get1_param_type(definition * defp, declaration * dec, char **param_type)
969 char typecontents[100];
971 if (streq(dec->type, "string")) {
972 *param_type = "char *";
975 strcpy(typecontents, dec->prefix);
976 strcat(typecontents, " ");
977 strcat(typecontents, dec->type);
978 strcat(typecontents, " *");
979 } else if (dec->rel == REL_POINTER) {
980 strcpy(typecontents, dec->type);
981 strcat(typecontents, " *");
983 strcpy(typecontents, dec->type);
984 *param_type = alloc(100);
985 strcpy(*param_type, typecontents);
991 get_param_type(definition * defp, declaration * dec, char **param_type,
994 char typecontents[100];
996 if (streq(dec->type, "string")) {
997 *typename = "wrapstring";
998 *param_type = "char *";
1000 *typename = dec->type;
1002 strcpy(typecontents, dec->prefix);
1003 strcat(typecontents, " ");
1004 strcat(typecontents, dec->type);
1005 strcat(typecontents, " *");
1006 dec->rel = REL_POINTER;
1007 } else if (dec->rel == REL_POINTER) {
1008 strcpy(typecontents, dec->type);
1009 strcat(typecontents, " *");
1011 strcpy(typecontents, dec->type);
1012 *param_type = alloc(100);
1013 strcpy(*param_type, typecontents);
1020 hndle_param_tail(definition * defp, declaration * dec, token * tokp,
1025 if (dec->rel == REL_POINTER)
1026 Proc_list->pl.param_flag |= INDIRECT_PARAM;
1028 Proc_list->pl.param_flag &= ~INDIRECT_PARAM;
1030 if (!(Proc_list->pl.param_flag & INDIRECT_PARAM))
1033 sprintf(Proc_list->code, "xdr_%s(&z_xdrs, %s%s)", typename, amp,
1034 Proc_list->pl.param_name);
1035 sprintf(Proc_list->scode, "xdr_%s(z_xdrs, &%s)", typename,
1036 Proc_list->pl.param_name);
1037 scan2(TOK_COMMA, TOK_RPAREN, tokp);
1038 if (tokp->kind == TOK_COMMA)
1045 cs_Proc_CodeGeneration(definition * defp, int split_flag, char *procheader)
1048 cs_ProcName_setup(defp, procheader, split_flag);
1050 cs_ProcParams_setup(defp, split_flag);
1051 cs_ProcMarshallInParams_setup(defp, split_flag);
1052 if (split_flag != 1) {
1053 cs_ProcSendPacket_setup(defp, split_flag);
1054 cs_ProcUnmarshallOutParams_setup(defp);
1056 cs_ProcTail_setup(defp, split_flag);
1059 if (!kflag && !split_flag && uflag) {
1060 ucs_ProcName_setup(defp, "ubik_", split_flag);
1062 ucs_ProcParams_setup(defp, split_flag);
1063 ucs_ProcTail_setup(defp, split_flag);
1069 cs_ProcName_setup(definition * defp, char *procheader, int split_flag)
1076 first_arg = "struct rx_call *z_call";
1078 first_arg = "struct rx_connection *z_conn";
1082 first_arg = "z_call";
1084 first_arg = "z_conn";
1089 f_print(fout, "int %s%s%s%s(%s", procheader, prefix,
1090 PackagePrefix[PackageIndex], defp->pc.proc_name, first_arg);
1092 if ((strlen(procheader) + strlen(prefix) +
1093 strlen(PackagePrefix[PackageIndex]) + strlen(defp->pc.proc_name)) >=
1094 MAX_FUNCTION_NAME_LEN) {
1095 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1098 for (plist = defp->pc.plists; plist; plist = plist->next) {
1099 if (plist->component_kind == DEF_PARAM) {
1102 if (plist->pl.param_kind == DEF_INPARAM &&
1103 strcmp(plist->pl.param_type, "char *") == 0) {
1104 f_print(fout, "const ");
1106 if (plist->pl.param_flag & OUT_STRING) {
1107 f_print(fout, "%s *%s", plist->pl.param_type,
1108 plist->pl.param_name);
1110 f_print(fout, "%s %s", plist->pl.param_type,
1111 plist->pl.param_name);
1114 f_print(fout, " %s", plist->pl.param_name);
1115 plist->pl.param_flag &= ~PROCESSED_PARAM;
1119 f_print(fout, ")\n");
1124 cs_ProcParams_setup(definition * defp, int split_flag)
1126 proc1_list *plist, *plist1;
1132 f_print(fout, "\tstruct rx_connection *z_conn;\n");
1134 f_print(fout, "\tstruct rx_call *z_call;\n");
1136 for (plist = defp->pc.plists; plist; plist = plist->next) {
1137 if (plist->component_kind == DEF_PARAM
1138 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1139 if (plist->pl.param_flag & OUT_STRING) {
1140 f_print(fout, "\t%s *%s", plist->pl.param_type,
1141 plist->pl.param_name);
1143 f_print(fout, "\t%s %s", plist->pl.param_type,
1144 plist->pl.param_name);
1146 plist->pl.param_flag |= PROCESSED_PARAM;
1147 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1148 if ((plist1->component_kind == DEF_PARAM)
1149 && streq(plist->pl.param_type, plist1->pl.param_type)
1150 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1152 char *pntr = strchr(plist1->pl.param_type, '*');
1155 if (plist1->pl.param_flag & OUT_STRING) {
1156 f_print(fout, ", *%s%s", star, plist1->pl.param_name);
1158 f_print(fout, ", %s%s", star, plist1->pl.param_name);
1160 plist1->pl.param_flag |= PROCESSED_PARAM;
1163 f_print(fout, ";\n");
1170 cs_ProcMarshallInParams_setup(definition * defp, int split_flag)
1172 int noofparams, i = 0;
1176 defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT] +
1177 defp->pc.paramtypes[OUT];
1179 f_print(fout, "{\n");
1181 f_print(fout, "\tstruct rx_call *z_call = rx_NewCall(z_conn);\n");
1182 if ((!split_flag) || (split_flag == 1)) {
1183 if (opcodesnotallowed[PackageIndex]) {
1184 f_print(fout, "\tstatic int z_op = %d;\n",
1185 defp->pc.proc_opcodenum);
1187 f_print(fout, "\tstatic int z_op = %s;\n",
1188 defp->pc.proc_opcodename);
1191 f_print(fout, "\tint z_result;\n");
1192 if (!(split_flag > 1) || (noofallparams != 0)) {
1193 f_print(fout, "\tXDR z_xdrs;\n");
1196 if ((!split_flag) || (split_flag == 1)) {
1197 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_ENCODE);\n");
1198 f_print(fout, "\n\t/* Marshal the arguments */\n");
1199 f_print(fout, "\tif ((!xdr_int(&z_xdrs, &z_op))");
1200 noofparams = defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT];
1201 for (plist = defp->pc.plists, dl = defp->def.st.decls; plist;
1202 plist = plist->next, dl = dl->next) {
1203 if (plist->component_kind == DEF_PARAM
1204 && (plist->pl.param_kind == DEF_INPARAM
1205 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1206 f_print(fout, "\n\t || (!%s)", plist->code);
1207 if (++i == noofparams) {
1209 ") {\n\t\tz_result = RXGEN_CC_MARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1216 ") {\n\t\tz_result = RXGEN_CC_MARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1224 cs_ProcSendPacket_setup(definition * defp, int split_flag)
1226 int noofoutparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1228 if (noofoutparams) {
1229 f_print(fout, "\t/* Un-marshal the reply arguments */\n");
1231 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
1233 f_print(fout, "\tz_xdrs.x_op = XDR_DECODE;\n");
1240 cs_ProcUnmarshallOutParams_setup(definition * defp)
1246 noofparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1248 for (plist = defp->pc.plists, dl = defp->def.st.decls, i = 0; plist;
1249 plist = plist->next, dl = dl->next) {
1250 if (plist->component_kind == DEF_PARAM
1251 && (plist->pl.param_kind == DEF_OUTPARAM
1252 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1254 f_print(fout, "\tif ((!%s)", plist->code);
1256 f_print(fout, "\n\t || (!%s)", plist->code);
1258 if (++i == noofparams) {
1260 ") {\n\t\tz_result = RXGEN_CC_UNMARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1269 cs_ProcTail_setup(definition * defp, int split_flag)
1271 f_print(fout, "\tz_result = RXGEN_SUCCESS;\n");
1272 if (defp->can_fail) {
1273 f_print(fout, "fail:\n");
1276 f_print(fout, "\tz_result = rx_EndCall(z_call, z_result);\n");
1278 if (xflag && split_flag != 1) {
1279 f_print(fout, "\tif (rx_enable_stats) {\n");
1280 if (PackageStatIndex[PackageIndex]) {
1282 "\t rx_RecordCallStatistics(z_call, %s,\n",
1283 PackageStatIndex[PackageIndex]);
1286 "\t rx_RecordCallStatistics(z_call, \n"
1287 "\t\t(((afs_uint32)(ntohs(rx_ServiceIdOf(rx_ConnectionOf(z_call))) << 16)) |\n"
1288 "\t\t((afs_uint32)ntohs(rx_PortOf(rx_PeerOf(rx_ConnectionOf(z_call)))))),\n");
1290 f_print(fout, "\t\t%d, %sNO_OF_STAT_FUNCS, 1);\n",
1291 no_of_stat_funcs, PackagePrefix[PackageIndex]);
1292 f_print(fout, "\t}\n\n");
1294 f_print(fout, "\treturn z_result;\n}\n\n");
1299 ss_Proc_CodeGeneration(definition * defp)
1302 ss_ProcName_setup(defp);
1304 ss_ProcParams_setup(defp);
1305 ss_ProcSpecial_setup(defp);
1306 ss_ProcUnmarshallInParams_setup(defp);
1307 ss_ProcCallRealProc_setup(defp);
1308 ss_ProcMarshallOutParams_setup(defp);
1309 ss_ProcTail_setup(defp);
1315 ss_ProcName_setup(definition * defp)
1319 if ((strlen(prefix) + strlen(PackagePrefix[PackageIndex]) +
1320 strlen(defp->pc.proc_name)) >= MAX_FUNCTION_NAME_LEN) {
1321 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1325 f_print(fout, "static afs_int32 _%s%s%s(", prefix,
1326 PackagePrefix[PackageIndex], defp->pc.proc_name);
1327 f_print(fout, "struct rx_call *z_call, XDR *z_xdrs)\n{\n");
1328 f_print(fout, "\t" "afs_int32 z_result;\n");
1330 for (plist = defp->pc.plists; plist; plist = plist->next)
1331 if (plist->component_kind == DEF_PARAM) {
1332 plist->pl.param_flag &= ~(PROCESSED_PARAM);
1333 plist->pl.string_name = NULL;
1340 ss_ProcParams_setup(definition * defp)
1342 proc1_list *plist, *plist1;
1346 for (plist = defp->pc.plists; plist; plist = plist->next) {
1347 if ((plist->component_kind == DEF_PARAM)
1348 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1349 if (plist->pl.param_flag & INDIRECT_PARAM) {
1350 char pres = '\0', *pntr = strchr(plist->pl.param_type, '*');
1356 f_print(fout, "\t%s %s", plist->pl.param_type,
1357 plist->pl.param_name);
1360 } else if (strchr(plist->pl.param_type, '*') == 0) {
1361 f_print(fout, "\t%s %s", plist->pl.param_type,
1362 plist->pl.param_name);
1364 plist->pl.param_flag |= FREETHIS_PARAM;
1365 f_print(fout, "\t%s %s=(%s)0", plist->pl.param_type,
1366 plist->pl.param_name, plist->pl.param_type);
1368 plist->pl.param_flag |= PROCESSED_PARAM;
1369 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1370 if ((plist1->component_kind == DEF_PARAM)
1371 && streq(plist->pl.param_type, plist1->pl.param_type)
1372 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1373 if (plist1->pl.param_flag & INDIRECT_PARAM) {
1374 f_print(fout, ", %s", plist1->pl.param_name);
1375 } else if (strchr(plist1->pl.param_type, '*') == 0) {
1376 f_print(fout, ", %s", plist1->pl.param_name);
1378 plist1->pl.param_flag |= FREETHIS_PARAM;
1379 f_print(fout, ", *%s=(%s)0", plist1->pl.param_name,
1380 plist1->pl.param_type);
1382 plist1->pl.param_flag |= PROCESSED_PARAM;
1385 f_print(fout, ";\n");
1388 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1389 defp1 = (definition *) listp->val;
1390 for (plist = defp->pc.plists; plist; plist = plist->next) {
1391 if (plist->component_kind == DEF_PARAM
1392 && (plist->pl.param_kind == DEF_OUTPARAM
1393 || plist->pl.param_kind == DEF_INOUTPARAM)
1394 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1395 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1396 switch (defp1->pc.rel) {
1406 fprintf(fout, "\n");
1411 ss_ProcSpecial_setup(definition * defp)
1417 for (listp = special_defined; listp != NULL; listp = listp->next) {
1418 defp1 = (definition *) listp->val;
1420 for (plist = defp->pc.plists; plist; plist = plist->next) {
1421 if (plist->component_kind == DEF_PARAM
1422 && (plist->pl.param_kind == DEF_INPARAM
1423 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1424 spec_list *spec = defp1->def.sd.specs;
1426 strcpy(string, structname(spec->sdef.string_value));
1427 if (streq(string, structname(plist->pl.param_type))) {
1428 plist->pl.string_name = spec->sdef.string_name;
1429 plist->pl.param_flag |= FREETHIS_PARAM;
1430 fprintf(fout, "\n\t%s.%s = 0;", plist->pl.param_name,
1431 spec->sdef.string_name);
1436 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1437 defp1 = (definition *) listp->val;
1438 for (plist = defp->pc.plists; plist; plist = plist->next) {
1439 if (plist->component_kind == DEF_PARAM) {
1440 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1441 plist->pl.param_flag |= FREETHIS_PARAM;
1442 switch (defp1->pc.rel) {
1444 plist->pl.string_name = alloc(40);
1446 f_print(fout, "\n\t%s.val = 0;",
1447 plist->pl.param_name);
1448 f_print(fout, "\n\t%s.len = 0;",
1449 plist->pl.param_name);
1450 s_print(plist->pl.string_name, "val");
1452 f_print(fout, "\n\t%s.%s_val = 0;",
1453 plist->pl.param_name, defp1->def_name);
1454 f_print(fout, "\n\t%s.%s_len = 0;",
1455 plist->pl.param_name, defp1->def_name);
1456 s_print(plist->pl.string_name, "%s_val",
1461 f_print(fout, "\n\t%s = 0;", plist->pl.param_name);
1462 plist->pl.string_name = NULL;
1471 for (listp = complex_defined; listp != NULL; listp = listp->next) {
1472 defp1 = (definition *) listp->val;
1473 for (plist = defp->pc.plists; plist; plist = plist->next) {
1474 if (plist->component_kind == DEF_PARAM) {
1475 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1476 plist->pl.param_flag |= FREETHIS_PARAM;
1477 fprintf(fout, "\n\tmemset(&%s, 0, sizeof(%s));",
1478 plist->pl.param_name, defp1->def_name);
1484 f_print(fout, "\n");
1489 ss_ProcUnmarshallInParams_setup(definition * defp)
1491 int noofparams, noofoutparams, i;
1494 noofparams = defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT];
1495 noofoutparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1496 for (plist = defp->pc.plists, i = 0; plist; plist = plist->next) {
1497 if (plist->component_kind == DEF_PARAM
1498 && (plist->pl.param_kind == DEF_INPARAM
1499 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1501 f_print(fout, "\n\tif ((!%s)",
1502 (plist->scode ? plist->scode : plist->code));
1504 f_print(fout, "\n\t || (!%s)",
1505 (plist->scode ? plist->scode : plist->code));
1507 if (++i == noofparams) {
1508 if (!noofoutparams) {
1509 f_print(fout, ") {\n");
1511 f_print(fout, ") {\n");
1514 "\t\tz_result = RXGEN_SS_UNMARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1523 ss_ProcCallRealProc_setup(definition * defp)
1528 f_print(fout, "\tz_result = %s%s%s%s(z_call", prefix, ServerPrefix,
1529 PackagePrefix[PackageIndex], defp->pc.proc_name);
1530 for (plist = defp->pc.plists; plist; plist = plist->next) {
1531 if (plist->component_kind == DEF_PARAM) {
1532 if (plist->pl.param_flag & INDIRECT_PARAM) {
1533 f_print(fout, ", &%s", plist->pl.param_name);
1535 if (plist->pl.param_flag & OUT_STRING) {
1536 f_print(fout, ", &%s", plist->pl.param_name);
1538 f_print(fout, ", %s", plist->pl.param_name);
1543 f_print(fout, ");\n");
1545 f_print(fout, "\tif (z_result)\n\t\treturn z_result;\n");
1551 ss_ProcMarshallOutParams_setup(definition * defp)
1556 noofparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1558 f_print(fout, "\tz_xdrs->x_op = XDR_ENCODE;\n");
1560 for (plist = defp->pc.plists, i = 0; plist; plist = plist->next) {
1561 if (plist->component_kind == DEF_PARAM
1562 && (plist->pl.param_kind == DEF_OUTPARAM
1563 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1565 f_print(fout, "\tif ((!%s)",
1566 (plist->scode ? plist->scode : plist->code));
1568 f_print(fout, "\n\t || (!%s)",
1569 (plist->scode ? plist->scode : plist->code));
1571 if (++i == noofparams) {
1572 f_print(fout, ")\n\t\tz_result = RXGEN_SS_MARSHAL;\n");
1580 ss_ProcTail_frees(char *xdrfunc, int *somefrees) {
1582 f_print(fout, "\tz_xdrs->x_op = XDR_FREE;\n");
1583 f_print(fout, "\tif ((!%s)", xdrfunc);
1586 f_print(fout, "\n\t || (!%s)", xdrfunc);
1592 ss_ProcTail_setup(definition * defp)
1599 if (defp->can_fail) {
1600 f_print(fout, "fail:\n");
1603 for (plist = defp->pc.plists; plist; plist = plist->next) {
1604 if (plist->component_kind == DEF_PARAM
1605 && (plist->pl.param_flag & FREETHIS_PARAM))
1606 ss_ProcTail_frees(plist->scode, &somefrees);
1609 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1610 defp1 = (definition *) listp->val;
1611 for (plist = defp->pc.plists; plist; plist = plist->next) {
1612 if (plist->component_kind == DEF_PARAM
1613 && (plist->pl.param_kind == DEF_OUTPARAM
1614 || plist->pl.param_kind == DEF_INOUTPARAM)
1615 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1616 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1617 switch (defp1->pc.rel) {
1620 ss_ProcTail_frees(plist->scode, &somefrees);
1630 for (listp = uniondef_defined; listp != NULL; listp = listp->next) {
1631 defp1 = (definition *) listp->val;
1632 for (plist = defp->pc.plists; plist; plist = plist->next) {
1633 if (plist->component_kind == DEF_PARAM
1634 && (plist->pl.param_kind == DEF_OUTPARAM
1635 || plist->pl.param_kind == DEF_INOUTPARAM)
1636 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1637 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1638 if (plist->pl.param_flag & INDIRECT_PARAM) {
1639 ss_ProcTail_frees(plist->scode, &somefrees);
1647 f_print(fout, ")\n");
1648 f_print(fout, "\t\tz_result = RXGEN_SS_XDRFREE;\n\n");
1652 f_print(fout, "\tif (rx_enable_stats) {\n");
1653 f_print(fout, "\t rx_RecordCallStatistics(z_call,");
1654 if (PackageStatIndex[PackageIndex]) {
1655 f_print(fout, " %s,\n", PackageStatIndex[PackageIndex]);
1658 "\n\t\t(((afs_uint32)(ntohs(rx_ServiceIdOf(rx_ConnectionOf(z_call))) << 16)) |\n"
1659 "\t\t((afs_uint32)ntohs(rx_ServiceOf(rx_ConnectionOf(z_call))->servicePort))),\n");
1661 f_print(fout, "\t\t%d, %sNO_OF_STAT_FUNCS, 0);\n",
1662 no_of_stat_funcs, PackagePrefix[PackageIndex]);
1663 f_print(fout, "\t}\n\n");
1666 f_print(fout, "\treturn z_result;\n");
1667 f_print(fout, "}\n\n");
1672 ucs_ProcName_setup(definition * defp, char *procheader, int split_flag)
1678 f_print(fout, "int %s%s%s%s(struct ubik_client *aclient, afs_int32 aflags",
1679 procheader, prefix, PackagePrefix[PackageIndex],
1680 defp->pc.proc_name);
1682 f_print(fout, "int %s%s%s%s(aclient, aflags", procheader, prefix,
1683 PackagePrefix[PackageIndex], defp->pc.proc_name);
1686 if ((strlen(procheader) + strlen(prefix) +
1687 strlen(PackagePrefix[PackageIndex]) + strlen(defp->pc.proc_name)) >=
1688 MAX_FUNCTION_NAME_LEN) {
1689 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1692 for (plist = defp->pc.plists; plist; plist = plist->next) {
1693 if (plist->component_kind == DEF_PARAM) {
1696 if (plist->pl.param_kind == DEF_INPARAM &&
1697 strcmp(plist->pl.param_type, "char *") == 0) {
1698 f_print(fout, "const ");
1700 if (plist->pl.param_flag & OUT_STRING) {
1701 f_print(fout, "%s *%s", plist->pl.param_type,
1702 plist->pl.param_name);
1704 f_print(fout, "%s %s", plist->pl.param_type,
1705 plist->pl.param_name);
1708 plist->pl.param_flag &= ~PROCESSED_PARAM;
1709 f_print(fout, " %s", plist->pl.param_name);
1713 f_print(fout, ")\n");
1719 ucs_ProcParams_setup(definition * defp, int split_flag)
1721 proc1_list *plist, *plist1;
1726 f_print(fout, "\tstruct ubik_client *aclient;\n\tafs_int32 aflags;\n");
1727 for (plist = defp->pc.plists; plist; plist = plist->next) {
1728 if (plist->component_kind == DEF_PARAM
1729 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1730 if (plist->pl.param_flag & OUT_STRING) {
1731 f_print(fout, "\t%s *%s", plist->pl.param_type,
1732 plist->pl.param_name);
1734 f_print(fout, "\t%s %s", plist->pl.param_type,
1735 plist->pl.param_name);
1737 plist->pl.param_flag |= PROCESSED_PARAM;
1738 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1739 if ((plist1->component_kind == DEF_PARAM)
1740 && streq(plist->pl.param_type, plist1->pl.param_type)
1741 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1743 char *pntr = strchr(plist1->pl.param_type, '*');
1746 if (plist1->pl.param_flag & OUT_STRING) {
1747 f_print(fout, ", *%s%s", star, plist1->pl.param_name);
1749 f_print(fout, ", %s%s", star, plist1->pl.param_name);
1751 plist1->pl.param_flag |= PROCESSED_PARAM;
1754 f_print(fout, ";\n");
1760 ucs_ProcTail_setup(definition * defp, int split_flag)
1764 f_print(fout, "{\tafs_int32 rcode, code, newHost, thisHost, i, _ucount;\n");
1765 f_print(fout, "\tint chaseCount, pass, needsync;\n");
1766 #if 0 /* goes with block below */
1767 f_print(fout, "\tint j, inlist;\n");
1769 f_print(fout, "\tstruct rx_connection *tc;\n");
1770 f_print(fout, "\tstruct rx_peer *rxp;\n");
1771 f_print(fout, "\tshort origLevel;\n\n");
1772 f_print(fout, "\tif (!aclient)\n");
1773 f_print(fout, "\t\treturn UNOENT;\n");
1774 f_print(fout, "\tLOCK_UBIK_CLIENT(aclient);\n\n");
1775 f_print(fout, "\t restart:\n");
1776 f_print(fout, "\torigLevel = aclient->initializationState;\n");
1777 f_print(fout, "\trcode = UNOSERVERS;\n");
1778 f_print(fout, "\tchaseCount = needsync = 0;\n\n");
1779 #if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
1780 f_print(fout, "\tinlist = 0;\n");
1781 f_print(fout, "\tLOCK_UCLNT_CACHE;\n");
1782 f_print(fout, "\tfor (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {\n");
1783 f_print(fout, "\t\tif (calls_needsync[j] == (int *)%s%s%s) {\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1784 f_print(fout, "\t\t\tinlist = needsync = 1;\n");
1785 f_print(fout, "\t\t\tbreak;\n");
1786 f_print(fout, "\t\t}\n");
1787 f_print(fout, "\t}\n");
1788 f_print(fout, "\tUNLOCK_UCLNT_CACHE;\n");
1790 f_print(fout, "\t/* \n\t* First pass, we try all servers that are up.\n\t* Second pass, we try all servers.\n\t*/\n");
1791 f_print(fout, "\tfor (pass = 0; pass < 2; pass++) { /*p */\n");
1792 f_print(fout, "\t\t/* For each entry in our servers list */\n");
1793 f_print(fout, "\t\tfor (_ucount = 0;; _ucount++) { /*s */\n\n");
1794 f_print(fout, "\t\tif (needsync) {\n");
1795 f_print(fout, "\t\t\t/* Need a sync site. Lets try to quickly find it */\n");
1796 f_print(fout, "\t\t\tif (aclient->syncSite) {\n");
1797 f_print(fout, "\t\t\t\tnewHost = aclient->syncSite; /* already in network order */\n");
1798 f_print(fout, "\t\t\t\taclient->syncSite = 0; /* Will reset if it works */\n");
1799 f_print(fout, "\t\t\t} else if (aclient->conns[3]) {\n");
1800 f_print(fout, "\t\t\t\t/* If there are fewer than four db servers in a cell,\n");
1801 f_print(fout, "\t\t\t\t* there's no point in making the GetSyncSite call.\n");
1802 f_print(fout, "\t\t\t\t* At best, it's a wash. At worst, it results in more\n");
1803 f_print(fout, "\t\t\t\t* RPCs than you would otherwise make.\n");
1804 f_print(fout, "\t\t\t\t*/\n");
1805 f_print(fout, "\t\t\t\ttc = aclient->conns[_ucount];\n");
1806 f_print(fout, "\t\t\t\tif (tc && rx_ConnError(tc)) {\n");
1807 f_print(fout, "\t\t\t\t\taclient->conns[_ucount] = tc = ubik_RefreshConn(tc);\n");
1808 f_print(fout, "\t\t\t\t}\n");
1809 f_print(fout, "\t\t\t\tif (!tc)\n");
1810 f_print(fout, "\t\t\t\t\tbreak;\n");
1811 f_print(fout, "\t\t\t\tcode = VOTE_GetSyncSite(tc, &newHost);\n");
1812 f_print(fout, "\t\t\t\tif (aclient->initializationState != origLevel)\n");
1813 f_print(fout, "\t\t\t\t\tgoto restart; /* somebody did a ubik_ClientInit */\n");
1814 f_print(fout, "\t\t\t\tif (code)\n");
1815 f_print(fout, "\t\t\t\t\tnewHost = 0;\n");
1816 f_print(fout, "\t\t\t\tnewHost = htonl(newHost); /* convert to network order */\n");
1817 f_print(fout, "\t\t\t} else {\n");
1818 f_print(fout, "\t\t\t\tnewHost = 0;\n");
1819 f_print(fout, "\t\t\t}\n");
1820 f_print(fout, "\t\t\tif (newHost) {\n");
1821 f_print(fout, "\t\t\t\t/* position count at the appropriate slot in the client\n");
1822 f_print(fout, "\t\t\t\t* structure and retry. If we can't find in slot, we'll\n");
1823 f_print(fout, "\t\t\t\t* just continue through the whole list \n");
1824 f_print(fout, "\t\t\t\t*/\n");
1825 f_print(fout, "\t\t\t\tfor (i = 0; i < MAXSERVERS && aclient->conns[i]; i++) {\n");
1826 f_print(fout, "\t\t\t\t\trxp = rx_PeerOf(aclient->conns[i]);\n");
1827 f_print(fout, "\t\t\t\t\tthisHost = rx_HostOf(rxp);\n");
1828 f_print(fout, "\t\t\t\t\tif (!thisHost)\n");
1829 f_print(fout, "\t\t\t\t\t\tbreak;\n");
1830 f_print(fout, "\t\t\t\t\tif (thisHost == newHost) {\n");
1831 f_print(fout, "\t\t\t\t\t\tif (chaseCount++ > 2)\n");
1832 f_print(fout, "\t\t\t\t\t\t\tbreak; /* avoid loop asking */\n");
1833 f_print(fout, "\t\t\t\t\t\t_ucount = i; /* this index is the sync site */\n");
1834 f_print(fout, "\t\t\t\t\t\tbreak;\n");
1835 f_print(fout, "\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n");
1836 f_print(fout, "\t\t/*needsync */\n");
1837 f_print(fout, "\t\ttc = aclient->conns[_ucount];\n");
1838 f_print(fout, "\t\tif (tc && rx_ConnError(tc)) {\n");
1839 f_print(fout, "\t\t\taclient->conns[_ucount] = tc = ubik_RefreshConn(tc);\n");
1840 f_print(fout, "\t\t}\n");
1841 f_print(fout, "\t\tif (!tc)\n");
1842 f_print(fout, "\t\t\tbreak;\n\n");
1843 f_print(fout, "\t\tif ((pass == 0) && (aclient->states[_ucount] & CFLastFailed)) {\n");
1844 f_print(fout, "\t\t\tcontinue; /* this guy's down */\n");
1845 f_print(fout, "\t\t}\n");
1847 f_print(fout, "\t\trcode = %s%s%s(tc\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1848 for (plist = defp->pc.plists; plist; plist = plist->next) {
1849 if (plist->component_kind == DEF_PARAM) {
1850 plist->pl.param_flag &= ~PROCESSED_PARAM;
1851 f_print(fout, ", %s", plist->pl.param_name);
1854 f_print(fout, ");\n");
1855 f_print(fout, "\t\tif (aclient->initializationState != origLevel) {\n");
1856 f_print(fout, "\t\t\t/* somebody did a ubik_ClientInit */\n");
1857 f_print(fout, "\t\t\tif (rcode)\n");
1858 f_print(fout, "\t\t\t\tgoto restart; /* call failed */\n");
1859 f_print(fout, "\t\t\telse\n");
1860 f_print(fout, "\t\t\t\tgoto done; /* call suceeded */\n");
1861 f_print(fout, "\t\t}\n");
1862 f_print(fout, "\t\tif (rcode < 0) { /* network errors */\n");
1863 f_print(fout, "\t\t\taclient->states[_ucount] |= CFLastFailed; /* Mark server down */\n");
1864 f_print(fout, "\t\t} else if (rcode == UNOTSYNC) {\n");
1865 f_print(fout, "\t\t\tneedsync = 1;\n");
1866 f_print(fout, "\t\t} else if (rcode != UNOQUORUM) {\n");
1867 f_print(fout, "\t\t\t/* either misc ubik code, or misc appl code, or success. */\n");
1868 f_print(fout, "\t\t\taclient->states[_ucount] &= ~CFLastFailed; /* mark server up*/\n");
1869 f_print(fout, "\t\t\tgoto done; /* all done */\n");
1870 f_print(fout, "\t\t}\n");
1871 f_print(fout, "\t\t} /*s */\n");
1872 f_print(fout, "\t} /*p */\n\n");
1873 f_print(fout, "\tdone:\n");
1874 f_print(fout, "\tif (needsync) {\n");
1876 #if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
1877 f_print(fout, "\t\tif (!inlist) { /* Remember proc call that needs sync site */\n");
1878 f_print(fout, "\t\t\tLOCK_UCLNT_CACHE;\n");
1879 f_print(fout, "\t\t\tcalls_needsync[synccount % SYNCCOUNT] = (int *)%s%s%s;\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1880 f_print(fout, "\t\t\tsynccount++;\n");
1881 f_print(fout, "\t\t\tUNLOCK_UCLNT_CACHE;\n");
1882 f_print(fout, "\t\t\tinlist = 1;\n");
1883 f_print(fout, "\t\t}\n");
1885 f_print(fout, "\t\tif (!rcode) { /* Remember the sync site - cmd successful */\n");
1886 f_print(fout, "\t\t\trxp = rx_PeerOf(aclient->conns[_ucount]);\n");
1887 f_print(fout, "\t\t\taclient->syncSite = rx_HostOf(rxp);\n");
1888 f_print(fout, "\t\t}\n");
1889 f_print(fout, "\t}\n");
1890 f_print(fout, "\tUNLOCK_UBIK_CLIENT(aclient);\n");
1891 f_print(fout, "\treturn rcode;\n}\n\n");
1896 opcode_holes_exist(void)
1900 for (i = lowest_opcode[PackageIndex]; i < highest_opcode[PackageIndex];
1902 if (!opcodenum_is_defined(i))
1910 er_Proc_CodeGeneration(void)
1914 temp = PackageIndex;
1915 if (!combinepackages)
1917 for (; PackageIndex <= temp; PackageIndex++) {
1918 if (proc_defined[PackageIndex] == NULL)
1920 if (combinepackages || opcode_holes_exist()) {
1921 er_HeadofOldStyleProc_setup();
1922 er_BodyofOldStyleProc_setup();
1923 er_TailofOldStyleProc_setup();
1924 er_HeadofOldStyleProc_setup2();
1925 er_BodyofOldStyleProc_setup2();
1926 er_TailofOldStyleProc_setup2();
1928 er_ProcDeclExterns_setup();
1929 er_ProcProcsArray_setup();
1930 er_ProcMainBody_setup();
1933 PackageIndex = temp;
1938 er_ProcDeclExterns_setup(void)
1946 f_print(fout, "\n");
1947 for (listp = proc_defined[PackageIndex]; listp != NULL;
1948 listp = listp->next) {
1949 defp = (definition *) listp->val;
1950 if (defp->pc.proc_serverstub) {
1951 f_print(fout, "afs_int32 %s();\n", defp->pc.proc_serverstub);
1958 er_ProcProcsArray_setup(void)
1963 if ((listp = proc_defined[PackageIndex])) {
1964 defp = (definition *) listp->val;
1966 f_print(fout, "\nstatic char *opnames%d[] = {\"%s%s\"",
1967 PackageIndex, defp->pc.proc_prefix, defp->pc.proc_name);
1970 if (defp->pc.proc_serverstub) {
1971 f_print(fout, "\nstatic afs_int32 (*StubProcsArray%d[])() = {%s",
1972 PackageIndex, defp->pc.proc_serverstub);
1975 "\nstatic afs_int32 (*StubProcsArray%d[])(struct rx_call *z_call, XDR *z_xdrs) = {_%s%s%s",
1976 PackageIndex, prefix, defp->pc.proc_prefix,
1977 ((definition *) listp->val)->pc.proc_name);
1980 listp = listp->next;
1982 for (; listp != NULL; listp = listp->next) {
1983 defp = (definition *) listp->val;
1985 f_print(fout, ", \"%s%s\"",defp->pc.proc_prefix,defp->pc.proc_name);
1988 if (defp->pc.proc_serverstub) {
1989 f_print(fout, ",%s", defp->pc.proc_serverstub);
1991 f_print(fout, ", _%s%s%s", prefix, defp->pc.proc_prefix,
1992 defp->pc.proc_name);
1996 f_print(fout, "};\n\n");
2001 er_ProcMainBody_setup(void)
2004 f_print(fout, "char *%sTranslateOpCode(int op)\n{\n",
2005 PackagePrefix[PackageIndex]);
2006 f_print(fout, "\tif (op < %sLOWEST_OPCODE || op > %sHIGHEST_OPCODE)\n\t\treturn NULL;\n",
2007 PackagePrefix[PackageIndex], PackagePrefix[PackageIndex]);
2008 f_print(fout, "\treturn opnames%d[op - %sLOWEST_OPCODE];\n}\n",
2009 PackageIndex, PackagePrefix[PackageIndex]);
2010 f_print(fout, "struct %sstats *%sOpCodeStats(int op)\n{\n",
2011 PackagePrefix[PackageIndex], PackagePrefix[PackageIndex]);
2012 f_print(fout, "\tif (op < %sLOWEST_OPCODE || op > %sHIGHEST_OPCODE)\n\t\treturn NULL;\n",
2013 PackagePrefix[PackageIndex], PackagePrefix[PackageIndex]);
2014 f_print(fout, "\treturn NULL;/*%d %s*/\n}\n",
2015 PackageIndex, PackagePrefix[PackageIndex]);
2019 f_print(fout, "int %s%sExecuteRequest(struct rx_call *z_call)\n",
2020 prefix, PackagePrefix[PackageIndex]);
2021 f_print(fout, "{\n\tint op;\n");
2022 f_print(fout, "\tXDR z_xdrs;\n");
2023 f_print(fout, "\t" "afs_int32 z_result;\n\n");
2024 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
2026 "\tif (!xdr_int(&z_xdrs, &op))\n\t\tz_result = RXGEN_DECODE;\n");
2028 "\telse if (op < %sLOWEST_OPCODE || op > %sHIGHEST_OPCODE)\n\t\tz_result = RXGEN_OPCODE;\n",
2029 PackagePrefix[PackageIndex], PackagePrefix[PackageIndex]);
2031 "\telse\n\t\tz_result = (*StubProcsArray%d[op - %sLOWEST_OPCODE])(z_call, &z_xdrs);\n",
2032 PackageIndex, PackagePrefix[PackageIndex]);
2033 f_print(fout, "\treturn hton_syserr_conv(z_result);\n}\n");
2037 er_HeadofOldStyleProc_setup2(void)
2040 f_print(fout, "int %sOpCodeIndex(int op)\n{\n", (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
2041 f_print(fout, "\tswitch (op) {\n");
2046 er_HeadofOldStyleProc_setup(void)
2049 f_print(fout, "char *%sTranslateOpCode(int op)\n{\n",
2050 (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
2054 "\nint %s%sExecuteRequest (struct rx_call *z_call)\n",
2056 (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
2057 f_print(fout, "{\n");
2058 f_print(fout, "\tint op;\n");
2059 f_print(fout, "\tXDR z_xdrs;\n");
2060 f_print(fout, "\t" "afs_int32 z_result;\n\n");
2061 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
2062 f_print(fout, "\tz_result = RXGEN_DECODE;\n");
2063 f_print(fout, "\tif (!xdr_int(&z_xdrs, &op)) goto fail;\n");
2065 f_print(fout, "\tswitch (op) {\n");
2069 er_BodyofOldStyleProc_setup(void)
2073 if (combinepackages) {
2074 int temp = PackageIndex;
2075 for (PackageIndex = 0; PackageIndex <= temp; PackageIndex++) {
2076 for (listp = proc_defined[PackageIndex]; listp != NULL;
2077 listp = listp->next)
2078 proc_er_case((definition *) listp->val);
2080 PackageIndex = temp;
2082 for (listp = proc_defined[PackageIndex]; listp != NULL;
2083 listp = listp->next)
2084 proc_er_case((definition *) listp->val);
2090 proc_er_case(definition * defp)
2093 f_print(fout, "\t\tcase %d:", defp->pc.proc_opcodenum);
2094 f_print(fout, "\treturn \"%s%s\";\n",
2095 defp->pc.proc_prefix, defp->pc.proc_name);
2098 if (opcodesnotallowed[PackageIndex]) {
2099 f_print(fout, "\t\tcase %d:\n", defp->pc.proc_opcodenum);
2101 f_print(fout, "\t\tcase %s:\n", defp->pc.proc_opcodename);
2103 if (defp->pc.proc_serverstub) {
2104 f_print(fout, "\t\t\tz_result = %s(z_call, &z_xdrs);\n",
2105 defp->pc.proc_serverstub);
2107 f_print(fout, "\t\t\tz_result = _%s%s%s(z_call, &z_xdrs);\n", prefix,
2108 defp->pc.proc_prefix, defp->pc.proc_name);
2110 f_print(fout, "\t\t\tbreak;\n");
2114 proc_op_case(definition * defp)
2116 f_print(fout, "\t\tcase %d:", defp->pc.proc_opcodenum);
2117 f_print(fout, "\treturn %d;\n",
2122 er_BodyofOldStyleProc_setup2(void)
2128 if (combinepackages) {
2129 int temp = PackageIndex;
2130 for (PackageIndex = 0; PackageIndex <= temp; PackageIndex++) {
2131 for (listp = proc_defined[PackageIndex]; listp != NULL;
2132 listp = listp->next)
2133 proc_op_case((definition *) listp->val);
2135 PackageIndex = temp;
2137 for (listp = proc_defined[PackageIndex]; listp != NULL;
2138 listp = listp->next)
2139 proc_op_case((definition *) listp->val);
2144 er_TailofOldStyleProc_setup2(void)
2147 f_print(fout, "\t\tdefault:\n");
2148 f_print(fout, "\t\t\treturn -1;\n\t}\n}\n");
2153 er_TailofOldStyleProc_setup(void)
2155 f_print(fout, "\t\tdefault:\n");
2157 f_print(fout, "\t\t\treturn NULL;\n\t}\n}\n");
2160 f_print(fout, "\t\t\tz_result = RXGEN_OPCODE;\n");
2161 f_print(fout, "\t\t\tbreak;\n\t}\n");
2162 f_print(fout, "fail:\n");
2163 f_print(fout, "\treturn z_result;\n}\n");
2167 h_ProcMainBody_setup(void)
2169 f_print(fout,"\nextern int %s%sExecuteRequest(struct rx_call *);\n",
2170 prefix, PackagePrefix[PackageIndex]);
2174 h_HeadofOldStyleProc_setup(void)
2176 char *pprefix = (combinepackages ? MasterPrefix :
2177 PackagePrefix[PackageIndex]);
2178 f_print(fout,"\nstruct %sstats{\n\tint statsver;\n};", pprefix);
2179 f_print(fout,"\nextern int %s%sExecuteRequest(struct rx_call *);\n",
2181 f_print(fout,"\nextern int %sOpCodeIndex(int op);\n", PackagePrefix[PackageIndex]);
2185 h_Proc_CodeGeneration(void)
2189 temp = PackageIndex;
2190 if (!combinepackages)
2192 for (; PackageIndex <= temp; PackageIndex++) {
2193 if (combinepackages || opcode_holes_exist()) {
2194 h_HeadofOldStyleProc_setup();
2196 h_ProcMainBody_setup();
2199 PackageIndex = temp;
2203 proc_h_case(definition * defp)
2205 f_print(fout, "#define opcode_%s%s \t((afs_uint64)((%uLL << 32) + %sOpCodeIndex(%u)))\n",
2206 defp->pc.proc_prefix, defp->pc.proc_name, StatIndex,
2207 defp->pc.proc_prefix, defp->pc.proc_opcodenum);
2211 h_opcode_stats_pkg(char *pprefix, int lowest, int highest, int nops,
2212 int statfuncs, char *ptype, list *proclist)
2220 "\n/* Opcode-related useful stats for %spackage: %s */\n",
2222 f_print(fout, "#define %sLOWEST_OPCODE %d\n", pprefix, lowest);
2223 f_print(fout, "#define %sHIGHEST_OPCODE %d\n", pprefix, highest);
2224 f_print(fout, "#define %sNUMBER_OPCODES %d\n\n", pprefix, nops);
2226 for (listp = proclist; listp != NULL;
2227 listp = listp->next)
2228 proc_h_case((definition *) listp->val);
2231 f_print(fout, "#define %sNO_OF_STAT_FUNCS\t%d\n\n",
2232 pprefix, statfuncs);
2233 f_print(fout, "AFS_RXGEN_EXPORT\n");
2234 f_print(fout, "extern const char *%sfunction_names[];\n\n",
2240 h_opcode_stats(void)
2242 if (combinepackages) {
2243 h_opcode_stats_pkg(MasterPrefix, master_lowest_opcode, master_highest_opcode, master_no_of_opcodes, no_of_stat_funcs_header[0], "Master ", proc_defined[0]);
2246 for (i = 0; i <= PackageIndex; i++) {
2247 h_opcode_stats_pkg(PackagePrefix[i], lowest_opcode[i], highest_opcode[i], no_of_opcodes[i], no_of_stat_funcs_header[i], "", proc_defined[i]);
2254 generate_multi_macros(definition * defp)
2256 char *startname = SplitStart, *endname = SplitEnd;
2265 f_print(fout, "\n#include <rx/rx_multi.h>");
2267 f_print(fout, "\n#define multi_%s%s(", PackagePrefix[PackageIndex],
2268 defp->pc.proc_name);
2269 for (plist = defp->pc.plists; plist; plist = plist->next) {
2270 if (plist->component_kind == DEF_PARAM) {
2273 f_print(fout, "%s", plist->pl.param_name);
2275 f_print(fout, ", %s", plist->pl.param_name);
2279 f_print(fout, ") \\\n");
2281 startname = "Start";
2284 f_print(fout, "\tmulti_Body(%s%s%s(multi_call", startname,
2285 PackagePrefix[PackageIndex], defp->pc.proc_name);
2286 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 0);
2287 for (plist = defp->pc.plists; plist; plist = plist->next) {
2288 if (plist->component_kind == DEF_PARAM)
2289 f_print(fout, ", %s", plist->pl.param_name);
2291 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 1);
2292 f_print(fout, "), %s%s%s(multi_call", endname,
2293 PackagePrefix[PackageIndex], defp->pc.proc_name);
2294 do_split(defp, IN, &numofparams, DEF_INPARAM, 0);
2295 for (plist = defp->pc.plists; plist; plist = plist->next) {
2296 if (plist->component_kind == DEF_PARAM) {
2297 f_print(fout, ", %s", plist->pl.param_name);
2300 do_split(defp, IN, &numofparams, DEF_INPARAM, 1);
2301 f_print(fout, "))\n\n");
2306 IsRxgenToken(token * tokp)
2308 if (tokp->kind == TOK_PACKAGE || tokp->kind == TOK_PREFIX
2309 || tokp->kind == TOK_SPECIAL || tokp->kind == TOK_STARTINGOPCODE
2310 || tokp->kind == TOK_SPLITPREFIX || tokp->kind == TOK_PROC
2311 || tokp->kind == TOK_STATINDEX)
2317 IsRxgenDefinition(definition * def)
2319 if (def->def_kind == DEF_PACKAGE || def->def_kind == DEF_PREFIX
2320 || def->def_kind == DEF_SPECIAL || def->def_kind == DEF_STARTINGOPCODE
2321 || def->def_kind == DEF_SPLITPREFIX || def->def_kind == DEF_PROC)