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;
73 * Character arrays to keep list of function names as we process the file
76 char function_list[MAX_PACKAGES]
77 [MAX_FUNCTIONS_PER_PACKAGE]
78 [MAX_FUNCTION_NAME_LEN];
79 int function_list_index;
81 /* static prototypes */
82 static void isdefined(definition * defp);
83 static void def_struct(definition * defp);
84 static void def_program(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_BodyofOldStyleProc_setup(void);
146 static void proc_er_case(definition * defp);
147 static void er_TailofOldStyleProc_setup(void);
152 * return the next definition you see
160 defp = ALLOC(definition);
161 memset(defp, 0, sizeof(definition));
196 def_special(&dec, defp);
199 case TOK_STARTINGOPCODE:
200 def_startingopcode(defp);
205 customize_struct(defp);
207 case TOK_SPLITPREFIX:
212 if (tok.kind == TOK_LPAREN) {
214 check_proc(defp, &tok, 1);
216 check_proc(defp, &tok, 0);
219 check_proc(defp, &tok, 0);
223 check_proc(defp, &tok, 1);
226 error("definition keyword expected");
228 if (!IsRxgenToken(&tok)) {
229 scan(TOK_SEMICOLON, &tok);
237 isdefined(definition * defp)
239 STOREVAL(&defined, defp);
244 def_struct(definition * defp)
252 defp->def_kind = DEF_STRUCT;
254 scan(TOK_IDENT, &tok);
255 defp->def_name = tok.str;
256 scan(TOK_LBRACE, &tok);
257 tailp = &defp->def.st.decls;
259 get_declaration(&dec, DEF_STRUCT);
260 /* If a structure contains an array, then we're going
261 * to need to be clever about freeing it */
262 if (dec.rel == REL_ARRAY) {
265 decls = ALLOC(decl_list);
268 tailp = &decls->next;
269 scan(TOK_SEMICOLON, &tok);
271 } while (tok.kind != TOK_RBRACE);
276 STOREVAL(&complex_defined, defp);
280 def_program(definition * defp)
284 version_list **vtailp;
288 defp->def_kind = DEF_PROGRAM;
289 scan(TOK_IDENT, &tok);
290 defp->def_name = tok.str;
291 scan(TOK_LBRACE, &tok);
292 vtailp = &defp->def.pr.versions;
293 scan(TOK_VERSION, &tok);
295 scan(TOK_IDENT, &tok);
296 vlist = ALLOC(version_list);
297 vlist->vers_name = tok.str;
298 scan(TOK_LBRACE, &tok);
299 ptailp = &vlist->procs;
301 plist = ALLOC(proc_list);
302 get_type(&plist->res_prefix, &plist->res_type, DEF_PROGRAM);
303 if (streq(plist->res_type, "opaque")) {
304 error("illegal result type");
306 scan(TOK_IDENT, &tok);
307 plist->proc_name = tok.str;
308 scan(TOK_LPAREN, &tok);
309 get_type(&plist->arg_prefix, &plist->arg_type, DEF_PROGRAM);
310 if (streq(plist->arg_type, "opaque")) {
311 error("illegal argument type");
313 scan(TOK_RPAREN, &tok);
314 scan(TOK_EQUAL, &tok);
316 scan(TOK_SEMICOLON, &tok);
317 plist->proc_num = tok.str;
319 ptailp = &plist->next;
321 } while (tok.kind != TOK_RBRACE);
323 vtailp = &vlist->next;
324 scan(TOK_RBRACE, &tok);
325 scan(TOK_EQUAL, &tok);
327 vlist->vers_num = tok.str;
328 scan(TOK_SEMICOLON, &tok);
329 scan2(TOK_VERSION, TOK_RBRACE, &tok);
330 } while (tok.kind == TOK_VERSION);
331 scan(TOK_EQUAL, &tok);
333 defp->def.pr.prog_num = tok.str;
338 def_enum(definition * defp)
342 enumval_list **tailp;
344 defp->def_kind = DEF_ENUM;
345 scan(TOK_IDENT, &tok);
346 defp->def_name = tok.str;
347 scan(TOK_LBRACE, &tok);
348 tailp = &defp->def.en.vals;
350 scan(TOK_IDENT, &tok);
351 elist = ALLOC(enumval_list);
352 elist->name = tok.str;
353 elist->assignment = NULL;
354 scan3(TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok);
355 if (tok.kind == TOK_EQUAL) {
357 elist->assignment = tok.str;
358 scan2(TOK_COMMA, TOK_RBRACE, &tok);
361 tailp = &elist->next;
362 } while (tok.kind != TOK_RBRACE);
367 def_const(definition * defp)
371 defp->def_kind = DEF_CONST;
372 scan(TOK_IDENT, &tok);
373 defp->def_name = tok.str;
374 scan(TOK_EQUAL, &tok);
375 scan2(TOK_IDENT, TOK_STRCONST, &tok);
376 defp->def.co = tok.str;
380 def_union(definition * defp)
387 defp->def_kind = DEF_UNION;
388 scan(TOK_IDENT, &tok);
389 defp->def_name = tok.str;
390 scan(TOK_SWITCH, &tok);
391 scan(TOK_LPAREN, &tok);
392 get_declaration(&dec, DEF_UNION);
393 defp->def.un.enum_decl = dec;
394 tailp = &defp->def.un.cases;
395 scan(TOK_RPAREN, &tok);
396 scan(TOK_LBRACE, &tok);
397 scan(TOK_CASE, &tok);
398 while (tok.kind == TOK_CASE) {
399 scan(TOK_IDENT, &tok);
400 cases = ALLOC(case_list);
401 cases->case_name = tok.str;
402 scan(TOK_COLON, &tok);
403 get_declaration(&dec, DEF_UNION);
404 cases->case_decl = dec;
406 tailp = &cases->next;
407 scan(TOK_SEMICOLON, &tok);
408 scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
411 if (tok.kind == TOK_DEFAULT) {
412 scan(TOK_COLON, &tok);
413 get_declaration(&dec, DEF_UNION);
414 defp->def.un.default_decl = ALLOC(declaration);
415 *defp->def.un.default_decl = dec;
416 scan(TOK_SEMICOLON, &tok);
417 scan(TOK_RBRACE, &tok);
419 defp->def.un.default_decl = NULL;
425 def_typedef(definition * defp)
429 defp->def_kind = DEF_TYPEDEF;
430 get_declaration(&dec, DEF_TYPEDEF);
431 defp->def_name = dec.name;
432 defp->def.ty.old_prefix = dec.prefix;
433 defp->def.ty.old_type = dec.type;
434 defp->def.ty.rel = dec.rel;
435 defp->def.ty.array_max = dec.array_max;
440 get_declaration(declaration * dec, defkind dkind)
444 get_type(&dec->prefix, &dec->type, dkind);
445 dec->rel = REL_ALIAS;
446 if (streq(dec->type, "void")) {
449 scan2(TOK_STAR, TOK_IDENT, &tok);
450 if (tok.kind == TOK_STAR) {
451 dec->rel = REL_POINTER;
452 scan(TOK_IDENT, &tok);
455 if (peekscan(TOK_LBRACKET, &tok)) {
456 if (dec->rel == REL_POINTER) {
457 error("no array-of-pointer declarations -- use typedef");
459 dec->rel = REL_VECTOR;
461 dec->array_max = tok.str;
462 scan(TOK_RBRACKET, &tok);
463 } else if (peekscan(TOK_LANGLE, &tok)) {
464 if (dec->rel == REL_POINTER) {
465 error("no array-of-pointer declarations -- use typedef");
467 dec->rel = REL_ARRAY;
468 if (peekscan(TOK_RANGLE, &tok)) {
469 dec->array_max = "~0"; /* unspecified size, use max */
472 dec->array_max = tok.str;
473 scan(TOK_RANGLE, &tok);
476 if (streq(dec->type, "opaque")) {
477 if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
478 error("array declaration expected");
480 } else if (streq(dec->type, "string")) {
481 if (dec->rel != REL_ARRAY) {
482 error(" variable-length array declaration expected");
489 get_type(char **prefixp, char **typep, defkind dkind)
503 scan(TOK_IDENT, &tok);
511 (void)peekscan(TOK_INT, &tok);
514 *typep = "afs_int32";
515 (void)peekscan(TOK_INT, &tok);
518 if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
519 error("voids allowed only inside union and program definitions");
534 error("expected type specifier");
540 unsigned_dec(char **typep)
553 (void)peekscan(TOK_INT, &tok);
557 *typep = "afs_uint32";
558 (void)peekscan(TOK_INT, &tok);
572 def_package(definition * defp)
576 defp->def_kind = DEF_PACKAGE;
577 scan(TOK_IDENT, &tok);
578 defp->def_name = tok.str;
579 no_of_stat_funcs = 0;
580 if (PackageIndex++ >= MAX_PACKAGES)
581 error("Exceeded upper limit of package statements\n");
582 function_list_index = 0;
583 PackagePrefix[PackageIndex] = tok.str;
584 if (MasterPrefix == NULL)
585 MasterPrefix = tok.str;
586 no_of_opcodes[PackageIndex] = highest_opcode[PackageIndex] =
587 opcodesnotallowed[PackageIndex] = 0;
588 lowest_opcode[PackageIndex] = 99999;
589 proc_defined[PackageIndex] = NULL;
590 PackageStatIndex[PackageIndex] = NULL;
594 def_prefix(definition * defp)
598 defp->def_kind = DEF_PREFIX;
599 scan(TOK_IDENT, &tok);
600 defp->def_name = tok.str;
601 ServerPrefix = tok.str;
605 def_statindex(definition * defp)
610 defp->def_kind = DEF_CONST;
612 if (PackageIndex < 0)
613 error("'statindex' command must follow 'package' command!\n");
614 if (PackageStatIndex[PackageIndex])
615 error("Cannot have more then one 'statindex' per package!\n");
616 if (InvalidConstant(tok.str))
617 error("Index in 'statindex' command must be a constant!");
619 alloc(strlen(PackagePrefix[PackageIndex]) + strlen("STATINDEX") + 1);
620 strcpy(name, PackagePrefix[PackageIndex]);
621 strcat(name, "STATINDEX");
622 defp->def_name = name;
623 defp->def.co = tok.str;
624 PackageStatIndex[PackageIndex] = name;
628 def_startingopcode(definition * defp)
632 defp->def_kind = DEF_STARTINGOPCODE;
633 scan(TOK_IDENT, &tok);
634 defp->def_name = tok.str;
635 if (InvalidConstant(defp->def_name))
636 error("Opcode in 'startingopcode' command must be a constant!");
637 lowest_opcode[PackageIndex] = master_lowest_opcode = atoi(tok.str);
638 if (lowest_opcode[PackageIndex] < 0
639 || lowest_opcode[PackageIndex] > 99999)
641 ("startingopcode number is out of bounds (must be >= 0 < 100000)");
642 master_opcodenumber = lowest_opcode[PackageIndex];
643 opcodesnotallowed[PackageIndex] = 1;
647 def_split(definition * defp)
651 defp->def_kind = DEF_SPLITPREFIX;
656 scan(TOK_EQUAL, &tok);
657 scan(TOK_IDENT, &tok);
658 SplitStart = tok.str;
661 scan(TOK_EQUAL, &tok);
662 scan(TOK_IDENT, &tok);
668 error("syntax error in the 'splitprefix' line");
670 } while (tok.kind != TOK_SEMICOLON);
671 if (!SplitStart && !SplitEnd)
672 error("At least one param should be passed to 'splitprefix' cmd");
677 customize_struct(definition * defp)
681 definition *defp1 = ALLOC(definition);
682 spec_list *specs, **tailp;
684 defp->def_kind = DEF_CUSTOMIZED;
685 defp1->def_kind = DEF_SPECIAL;
686 tailp = &defp1->def.sd.specs;
687 for (listp = defp->def.st.decls; listp; listp = listp->next) {
689 if (streq(dec->type, "string") || (dec->rel == REL_POINTER)) {
690 specs = ALLOC(spec_list);
691 specs->sdef.string_name = dec->name;
692 specs->sdef.string_value = defp->def_name;
694 tailp = &specs->next;
698 STOREVAL(&special_defined, defp1);
702 structname(char *name)
704 static char namecontents[150];
707 strcpy(namecontents, name);
709 if (!strncmp(pnt, "struct", 6))
711 while (isspace(*pnt))
714 while (*pnt != ' ' && *pnt != '\0')
722 def_special(declaration * dec, definition * defp)
725 spec_list *specs, **tailp;
728 defp->def_kind = DEF_SPECIAL;
729 get_type(&dec->prefix, &dec->type, DEF_SPECIAL);
730 dec->rel = REL_POINTER;
731 scan(TOK_IDENT, &tok);
732 tailp = &defp->def.sd.specs;
734 specs = ALLOC(spec_list);
735 specs->sdef.string_name = tok.str;
736 get_param_type(defp, dec, &specs->sdef.string_value, &typename);
738 tailp = &specs->next;
739 scan2(TOK_COMMA, TOK_SEMICOLON, &tok);
740 if (tok.kind == TOK_SEMICOLON)
743 } while (tok.kind == TOK_IDENT);
745 STOREVAL(&special_defined, defp);
749 proc1_list *Proc_list, **Proc_listp;
752 check_proc(definition * defp, token * tokp, int noname)
758 if (PackageIndex < 0)
759 error("Procedure must be in a package!\n");
761 tokp->kind = TOK_PROC;
762 defp->def_kind = DEF_PROC;
764 defp->pc.proc_name = "";
766 defp->pc.proc_name = tokp->str;
768 defp->pc.proc_prefix = alloc(strlen(PackagePrefix[PackageIndex]) + 1);
769 strcpy(defp->pc.proc_prefix, PackagePrefix[PackageIndex]);
770 scan2(TOK_LPAREN, TOK_IDENT, &tok);
771 defp->pc.proc_serverstub = NULL;
772 if (tok.kind == TOK_IDENT) {
773 defp->pc.proc_serverstub = tok.str;
774 scan(TOK_LPAREN, &tok);
776 analyze_ProcParams(defp, &tok);
777 defp->pc.proc_opcodenum = -1;
778 scan4(TOK_SPLIT, TOK_MULTI, TOK_EQUAL, TOK_SEMICOLON, &tok);
779 if (tok.kind == TOK_MULTI) {
781 defp->pc.multi_flag = 1;
782 scan2(TOK_EQUAL, TOK_SEMICOLON, &tok);
784 defp->pc.multi_flag = 0;
786 if (tok.kind == TOK_SPLIT) {
788 defp->pc.split_flag = 1;
789 scan2(TOK_EQUAL, TOK_SEMICOLON, &tok);
791 defp->pc.split_flag = 0;
793 if (tok.kind == TOK_EQUAL) {
794 if (opcodesnotallowed[PackageIndex])
795 error("Opcode assignment isn't allowed here!");
797 if (InvalidConstant(tok.str))
798 error("Illegal Opcode assignment (Must be a constant opcode!)");
799 if (opcodenum_is_defined(atoi(tok.str)))
800 error("The opcode number is already used by a previous proc");
801 defp->pc.proc_opcodename = tok.str;
802 defp->pc.proc_opcodenum = atoi(tok.str);
803 if (defp->pc.proc_opcodenum < lowest_opcode[PackageIndex])
804 lowest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
805 if (defp->pc.proc_opcodenum < master_lowest_opcode)
806 master_lowest_opcode = defp->pc.proc_opcodenum;
807 if (defp->pc.proc_opcodenum > highest_opcode[PackageIndex])
808 highest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
809 if (defp->pc.proc_opcodenum > master_highest_opcode)
810 master_highest_opcode = defp->pc.proc_opcodenum;
811 scan(TOK_SEMICOLON, &tok);
813 if (master_opcodenumber == 99999)
814 master_opcodenumber = 0;
815 defp->pc.proc_opcodenum = master_opcodenumber++;
816 if (defp->pc.proc_opcodenum < lowest_opcode[PackageIndex])
817 lowest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
818 if (defp->pc.proc_opcodenum > highest_opcode[PackageIndex])
819 highest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
820 if (defp->pc.proc_opcodenum > master_highest_opcode)
821 master_highest_opcode = defp->pc.proc_opcodenum;
822 opcodesnotallowed[PackageIndex] = 1; /* force it */
824 no_of_opcodes[PackageIndex]++, master_no_of_opcodes++;
826 generate_code(defp, 0, 1);
827 if (Cflag || cflag) {
828 generate_code(defp, 1, 1);
830 generate_multi_macros(defp);
832 generate_code(defp, proc_split, 0);
835 if (function_list_index >= MAX_FUNCTIONS_PER_INTERFACE) {
836 error("too many functions in interface, "
837 "increase MAX_FUNCTIONS_PER_INTERFACE");
839 sprintf(function_list[PackageIndex][function_list_index], "%s%s%s",
840 prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
842 function_list_index++;
843 no_of_stat_funcs_header[PackageIndex]++;
849 #define LEGALNUMS "0123456789"
851 InvalidConstant(char *name)
857 slen = (int)strlen(name);
858 return (slen != strspn(name, map));
862 opcodenum_is_defined(int opcode_num)
867 for (listp = proc_defined[PackageIndex]; listp != NULL;
868 listp = listp->next) {
869 defp = (definition *) listp->val;
870 if (opcode_num == defp->pc.proc_opcodenum)
878 analyze_ProcParams(definition * defp, token * tokp)
881 decl_list *decls, **tailp;
883 Proc_listp = &defp->pc.plists;
884 tailp = &defp->def.st.decls;
887 Proc_list = ALLOC(proc1_list);
888 memset(Proc_list, 0, sizeof(proc1_list));
889 Proc_list->pl.param_flag = 0;
890 switch (tokp->kind) {
892 hdle_param_tok(defp, &dec, tokp, DEF_INPARAM);
895 hdle_param_tok(defp, &dec, tokp, DEF_OUTPARAM);
898 hdle_param_tok(defp, &dec, tokp, DEF_INOUTPARAM);
904 hdle_param_tok(defp, &dec, tokp, DEF_NULL);
907 *Proc_listp = Proc_list;
908 Proc_listp = &Proc_list->next;
909 decls = ALLOC(decl_list);
910 memset(decls, 0, sizeof(decl_list));
911 if (tokp->kind != TOK_RPAREN)
914 tailp = &decls->next;
915 } while (tokp->kind != TOK_RPAREN);
921 generate_code(definition * defp, int proc_split_flag, int multi_flag)
924 handle_split_proc(defp, multi_flag);
926 if (Cflag || cflag) {
927 cs_Proc_CodeGeneration(defp, 0, "");
930 ss_Proc_CodeGeneration(defp);
932 if (Sflag || (cflag && xflag && !proc_split_flag))
933 STOREVAL(&proc_defined[PackageIndex], defp);
938 handle_split_proc(definition * defp, int multi_flag)
940 char *startname = SplitStart, *endname = SplitEnd;
947 if (Cflag || cflag) {
949 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 0);
951 cs_Proc_CodeGeneration(defp, 1, startname);
953 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 1);
954 do_split(defp, IN, &numofparams, DEF_INPARAM, 0);
956 cs_Proc_CodeGeneration(defp, (multi_flag ? 3 : 2), endname);
958 do_split(defp, IN, &numofparams, DEF_INPARAM, 1);
962 ss_Proc_CodeGeneration(defp);
967 do_split(definition * defp, int direction, int *numofparams,
968 defkind param_kind, int restore_flag)
973 defp->pc.paramtypes[direction] = *numofparams;
974 for (plist = defp->pc.plists; plist; plist = plist->next) {
975 if (plist->component_kind == DEF_NULL
976 && plist->pl.param_kind == param_kind)
977 plist->component_kind = DEF_PARAM;
980 *numofparams = defp->pc.paramtypes[direction];
981 defp->pc.paramtypes[direction] = 0;
982 for (plist = defp->pc.plists; plist; plist = plist->next) {
983 if (plist->component_kind == DEF_PARAM
984 && plist->pl.param_kind == param_kind)
985 plist->component_kind = DEF_NULL;
992 hdle_param_tok(definition * defp, declaration * dec, token * tokp,
995 static defkind last_param_kind = DEF_NULL;
997 if (par_kind == DEF_NULL)
998 Proc_list->pl.param_kind = last_param_kind;
1000 Proc_list->pl.param_kind = par_kind;
1001 last_param_kind = Proc_list->pl.param_kind;
1002 defp->pc.paramtypes[(int)last_param_kind]++;
1003 Proc_list->component_kind = DEF_PARAM;
1004 Proc_list->code = alloc(250);
1005 Proc_list->scode = alloc(250);
1006 get_declaration(dec, DEF_PARAM);
1007 Proc_list->pl.param_name = dec->name;
1008 get1_param_type(defp, dec, &Proc_list->pl.param_type);
1010 scan2(TOK_COMMA, TOK_RPAREN, tokp);
1011 if (tokp->kind == TOK_COMMA)
1017 get1_param_type(definition * defp, declaration * dec, char **param_type)
1019 char typecontents[100];
1021 if (streq(dec->type, "string")) {
1022 *param_type = "char *";
1025 strcpy(typecontents, dec->prefix);
1026 strcat(typecontents, " ");
1027 strcat(typecontents, dec->type);
1028 strcat(typecontents, " *");
1029 } else if (dec->rel == REL_POINTER) {
1030 strcpy(typecontents, dec->type);
1031 strcat(typecontents, " *");
1033 strcpy(typecontents, dec->type);
1034 *param_type = alloc(100);
1035 strcpy(*param_type, typecontents);
1041 get_param_type(definition * defp, declaration * dec, char **param_type,
1044 char typecontents[100];
1046 if (streq(dec->type, "string")) {
1047 *typename = "wrapstring";
1048 *param_type = "char *";
1050 *typename = dec->type;
1052 strcpy(typecontents, dec->prefix);
1053 strcat(typecontents, " ");
1054 strcat(typecontents, dec->type);
1055 strcat(typecontents, " *");
1056 dec->rel = REL_POINTER;
1057 } else if (dec->rel == REL_POINTER) {
1058 strcpy(typecontents, dec->type);
1059 strcat(typecontents, " *");
1061 strcpy(typecontents, dec->type);
1062 *param_type = alloc(100);
1063 strcpy(*param_type, typecontents);
1070 hndle_param_tail(definition * defp, declaration * dec, token * tokp,
1075 if (dec->rel == REL_POINTER)
1076 Proc_list->pl.param_flag |= INDIRECT_PARAM;
1078 Proc_list->pl.param_flag &= ~INDIRECT_PARAM;
1080 if (!(Proc_list->pl.param_flag & INDIRECT_PARAM))
1083 sprintf(Proc_list->code, "xdr_%s(&z_xdrs, %s%s)", typename, amp,
1084 Proc_list->pl.param_name);
1085 sprintf(Proc_list->scode, "xdr_%s(z_xdrs, &%s)", typename,
1086 Proc_list->pl.param_name);
1087 scan2(TOK_COMMA, TOK_RPAREN, tokp);
1088 if (tokp->kind == TOK_COMMA)
1095 cs_Proc_CodeGeneration(definition * defp, int split_flag, char *procheader)
1098 cs_ProcName_setup(defp, procheader, split_flag);
1100 cs_ProcParams_setup(defp, split_flag);
1101 cs_ProcMarshallInParams_setup(defp, split_flag);
1102 if (split_flag != 1) {
1103 cs_ProcSendPacket_setup(defp, split_flag);
1104 cs_ProcUnmarshallOutParams_setup(defp);
1106 cs_ProcTail_setup(defp, split_flag);
1109 if (!kflag && !split_flag && uflag) {
1110 ucs_ProcName_setup(defp, "ubik_", split_flag);
1112 ucs_ProcParams_setup(defp, split_flag);
1113 ucs_ProcTail_setup(defp, split_flag);
1119 cs_ProcName_setup(definition * defp, char *procheader, int split_flag)
1126 first_arg = "struct rx_call *z_call";
1128 first_arg = "struct rx_connection *z_conn";
1132 first_arg = "z_call";
1134 first_arg = "z_conn";
1139 f_print(fout, "int %s%s%s%s(%s", procheader, prefix,
1140 PackagePrefix[PackageIndex], defp->pc.proc_name, first_arg);
1142 if ((strlen(procheader) + strlen(prefix) +
1143 strlen(PackagePrefix[PackageIndex]) + strlen(defp->pc.proc_name)) >=
1144 MAX_FUNCTION_NAME_LEN) {
1145 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1148 for (plist = defp->pc.plists; plist; plist = plist->next) {
1149 if (plist->component_kind == DEF_PARAM) {
1152 if (plist->pl.param_kind == DEF_INPARAM &&
1153 strcmp(plist->pl.param_type, "char *") == 0) {
1154 f_print(fout, "const ");
1156 if (plist->pl.param_flag & OUT_STRING) {
1157 f_print(fout, "%s *%s", plist->pl.param_type,
1158 plist->pl.param_name);
1160 f_print(fout, "%s %s", plist->pl.param_type,
1161 plist->pl.param_name);
1164 f_print(fout, " %s", plist->pl.param_name);
1165 plist->pl.param_flag &= ~PROCESSED_PARAM;
1169 f_print(fout, ")\n");
1174 cs_ProcParams_setup(definition * defp, int split_flag)
1176 proc1_list *plist, *plist1;
1182 f_print(fout, "\tstruct rx_connection *z_conn;\n");
1184 f_print(fout, "\tstruct rx_call *z_call;\n");
1186 for (plist = defp->pc.plists; plist; plist = plist->next) {
1187 if (plist->component_kind == DEF_PARAM
1188 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1189 if (plist->pl.param_flag & OUT_STRING) {
1190 f_print(fout, "\t%s *%s", plist->pl.param_type,
1191 plist->pl.param_name);
1193 f_print(fout, "\t%s %s", plist->pl.param_type,
1194 plist->pl.param_name);
1196 plist->pl.param_flag |= PROCESSED_PARAM;
1197 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1198 if ((plist1->component_kind == DEF_PARAM)
1199 && streq(plist->pl.param_type, plist1->pl.param_type)
1200 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1202 char *pntr = strchr(plist1->pl.param_type, '*');
1205 if (plist1->pl.param_flag & OUT_STRING) {
1206 f_print(fout, ", *%s%s", star, plist1->pl.param_name);
1208 f_print(fout, ", %s%s", star, plist1->pl.param_name);
1210 plist1->pl.param_flag |= PROCESSED_PARAM;
1213 f_print(fout, ";\n");
1220 cs_ProcMarshallInParams_setup(definition * defp, int split_flag)
1222 int noofparams, i = 0;
1226 defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT] +
1227 defp->pc.paramtypes[OUT];
1229 f_print(fout, "{\n");
1231 f_print(fout, "\tstruct rx_call *z_call = rx_NewCall(z_conn);\n");
1232 if ((!split_flag) || (split_flag == 1)) {
1233 if (opcodesnotallowed[PackageIndex]) {
1234 f_print(fout, "\tstatic int z_op = %d;\n",
1235 defp->pc.proc_opcodenum);
1237 f_print(fout, "\tstatic int z_op = %s;\n",
1238 defp->pc.proc_opcodename);
1241 f_print(fout, "\tint z_result;\n");
1242 if (!(split_flag > 1) || (noofallparams != 0)) {
1243 f_print(fout, "\tXDR z_xdrs;\n");
1246 if ((!split_flag) || (split_flag == 1)) {
1247 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_ENCODE);\n");
1248 f_print(fout, "\n\t/* Marshal the arguments */\n");
1249 f_print(fout, "\tif ((!xdr_int(&z_xdrs, &z_op))");
1250 noofparams = defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT];
1251 for (plist = defp->pc.plists, dl = defp->def.st.decls; plist;
1252 plist = plist->next, dl = dl->next) {
1253 if (plist->component_kind == DEF_PARAM
1254 && (plist->pl.param_kind == DEF_INPARAM
1255 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1256 f_print(fout, "\n\t || (!%s)", plist->code);
1257 if (++i == noofparams) {
1259 ") {\n\t\tz_result = RXGEN_CC_MARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1266 ") {\n\t\tz_result = RXGEN_CC_MARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1274 cs_ProcSendPacket_setup(definition * defp, int split_flag)
1276 int noofoutparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1278 if (noofoutparams) {
1279 f_print(fout, "\t/* Un-marshal the reply arguments */\n");
1281 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
1283 f_print(fout, "\tz_xdrs.x_op = XDR_DECODE;\n");
1290 cs_ProcUnmarshallOutParams_setup(definition * defp)
1296 noofparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1298 for (plist = defp->pc.plists, dl = defp->def.st.decls, i = 0; plist;
1299 plist = plist->next, dl = dl->next) {
1300 if (plist->component_kind == DEF_PARAM
1301 && (plist->pl.param_kind == DEF_OUTPARAM
1302 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1304 f_print(fout, "\tif ((!%s)", plist->code);
1306 f_print(fout, "\n\t || (!%s)", plist->code);
1308 if (++i == noofparams) {
1310 ") {\n\t\tz_result = RXGEN_CC_UNMARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1319 cs_ProcTail_setup(definition * defp, int split_flag)
1321 f_print(fout, "\tz_result = RXGEN_SUCCESS;\n");
1322 if (defp->can_fail) {
1323 f_print(fout, "fail:\n");
1326 f_print(fout, "\tz_result = rx_EndCall(z_call, z_result);\n");
1328 if (xflag && split_flag != 1) {
1329 f_print(fout, "\tif (rx_enable_stats) {\n");
1330 if (PackageStatIndex[PackageIndex]) {
1332 "\t rx_RecordCallStatistics(z_call, %s,\n",
1333 PackageStatIndex[PackageIndex]);
1336 "\t rx_RecordCallStatistics(z_call, \n"
1337 "\t\t(((afs_uint32)(ntohs(rx_ServiceIdOf(rx_ConnectionOf(z_call))) << 16)) |\n"
1338 "\t\t((afs_uint32)ntohs(rx_PortOf(rx_PeerOf(rx_ConnectionOf(z_call)))))),\n");
1340 f_print(fout, "\t\t%d, %sNO_OF_STAT_FUNCS, 1);\n",
1341 no_of_stat_funcs, PackagePrefix[PackageIndex]);
1342 f_print(fout, "\t}\n\n");
1344 f_print(fout, "\treturn z_result;\n}\n\n");
1349 ss_Proc_CodeGeneration(definition * defp)
1352 ss_ProcName_setup(defp);
1354 ss_ProcParams_setup(defp);
1355 ss_ProcSpecial_setup(defp);
1356 ss_ProcUnmarshallInParams_setup(defp);
1357 ss_ProcCallRealProc_setup(defp);
1358 ss_ProcMarshallOutParams_setup(defp);
1359 ss_ProcTail_setup(defp);
1365 ss_ProcName_setup(definition * defp)
1369 if ((strlen(prefix) + strlen(PackagePrefix[PackageIndex]) +
1370 strlen(defp->pc.proc_name)) >= MAX_FUNCTION_NAME_LEN) {
1371 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1375 f_print(fout, "static afs_int32 _%s%s%s(", prefix,
1376 PackagePrefix[PackageIndex], defp->pc.proc_name);
1377 f_print(fout, "struct rx_call *z_call, XDR *z_xdrs)\n{\n");
1378 f_print(fout, "\t" "afs_int32 z_result;\n");
1380 for (plist = defp->pc.plists; plist; plist = plist->next)
1381 if (plist->component_kind == DEF_PARAM) {
1382 plist->pl.param_flag &= ~(PROCESSED_PARAM);
1383 plist->pl.string_name = NULL;
1390 ss_ProcParams_setup(definition * defp)
1392 proc1_list *plist, *plist1;
1396 for (plist = defp->pc.plists; plist; plist = plist->next) {
1397 if ((plist->component_kind == DEF_PARAM)
1398 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1399 if (plist->pl.param_flag & INDIRECT_PARAM) {
1400 char pres = '\0', *pntr = strchr(plist->pl.param_type, '*');
1406 f_print(fout, "\t%s %s", plist->pl.param_type,
1407 plist->pl.param_name);
1409 } else if (strchr(plist->pl.param_type, '*') == 0) {
1410 f_print(fout, "\t%s %s", plist->pl.param_type,
1411 plist->pl.param_name);
1413 plist->pl.param_flag |= FREETHIS_PARAM;
1414 f_print(fout, "\t%s %s=(%s)0", plist->pl.param_type,
1415 plist->pl.param_name, plist->pl.param_type);
1417 plist->pl.param_flag |= PROCESSED_PARAM;
1418 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1419 if ((plist1->component_kind == DEF_PARAM)
1420 && streq(plist->pl.param_type, plist1->pl.param_type)
1421 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1422 if (plist1->pl.param_flag & INDIRECT_PARAM) {
1423 f_print(fout, ", %s", plist1->pl.param_name);
1424 } else if (strchr(plist1->pl.param_type, '*') == 0) {
1425 f_print(fout, ", %s", plist1->pl.param_name);
1427 plist1->pl.param_flag |= FREETHIS_PARAM;
1428 f_print(fout, ", *%s=(%s)0", plist1->pl.param_name,
1429 plist1->pl.param_type);
1431 plist1->pl.param_flag |= PROCESSED_PARAM;
1434 f_print(fout, ";\n");
1437 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1438 defp1 = (definition *) listp->val;
1439 for (plist = defp->pc.plists; plist; plist = plist->next) {
1440 if (plist->component_kind == DEF_PARAM
1441 && (plist->pl.param_kind == DEF_OUTPARAM
1442 || plist->pl.param_kind == DEF_INOUTPARAM)
1443 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1444 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1445 switch (defp1->pc.rel) {
1455 fprintf(fout, "\n");
1460 ss_ProcSpecial_setup(definition * defp)
1466 for (listp = special_defined; listp != NULL; listp = listp->next) {
1467 defp1 = (definition *) listp->val;
1469 for (plist = defp->pc.plists; plist; plist = plist->next) {
1470 if (plist->component_kind == DEF_PARAM
1471 && (plist->pl.param_kind == DEF_INPARAM
1472 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1473 spec_list *spec = defp1->def.sd.specs;
1475 strcpy(string, structname(spec->sdef.string_value));
1476 if (streq(string, structname(plist->pl.param_type))) {
1477 plist->pl.string_name = spec->sdef.string_name;
1478 plist->pl.param_flag |= FREETHIS_PARAM;
1479 fprintf(fout, "\n\t%s.%s = 0;", plist->pl.param_name,
1480 spec->sdef.string_name);
1485 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1486 defp1 = (definition *) listp->val;
1487 for (plist = defp->pc.plists; plist; plist = plist->next) {
1488 if (plist->component_kind == DEF_PARAM) {
1489 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1490 plist->pl.param_flag |= FREETHIS_PARAM;
1491 switch (defp1->pc.rel) {
1493 plist->pl.string_name = alloc(40);
1495 f_print(fout, "\n\t%s.val = 0;",
1496 plist->pl.param_name);
1497 f_print(fout, "\n\t%s.len = 0;",
1498 plist->pl.param_name);
1499 s_print(plist->pl.string_name, "val");
1501 f_print(fout, "\n\t%s.%s_val = 0;",
1502 plist->pl.param_name, defp1->def_name);
1503 f_print(fout, "\n\t%s.%s_len = 0;",
1504 plist->pl.param_name, defp1->def_name);
1505 s_print(plist->pl.string_name, "%s_val",
1510 f_print(fout, "\n\t%s = 0;", plist->pl.param_name);
1511 plist->pl.string_name = NULL;
1520 for (listp = complex_defined; listp != NULL; listp = listp->next) {
1521 defp1 = (definition *) listp->val;
1522 for (plist = defp->pc.plists; plist; plist = plist->next) {
1523 if (plist->component_kind == DEF_PARAM) {
1524 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1525 plist->pl.param_flag |= FREETHIS_PARAM;
1526 fprintf(fout, "\n\tmemset(&%s, 0, sizeof(%s));",
1527 plist->pl.param_name, defp1->def_name);
1533 f_print(fout, "\n");
1538 ss_ProcUnmarshallInParams_setup(definition * defp)
1540 int noofparams, noofoutparams, i;
1543 noofparams = defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT];
1544 noofoutparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1545 for (plist = defp->pc.plists, i = 0; plist; plist = plist->next) {
1546 if (plist->component_kind == DEF_PARAM
1547 && (plist->pl.param_kind == DEF_INPARAM
1548 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1550 f_print(fout, "\n\tif ((!%s)",
1551 (plist->scode ? plist->scode : plist->code));
1553 f_print(fout, "\n\t || (!%s)",
1554 (plist->scode ? plist->scode : plist->code));
1556 if (++i == noofparams) {
1557 if (!noofoutparams) {
1558 f_print(fout, ") {\n");
1560 f_print(fout, ") {\n");
1563 "\t\tz_result = RXGEN_SS_UNMARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1572 ss_ProcCallRealProc_setup(definition * defp)
1577 f_print(fout, "\tz_result = %s%s%s%s(z_call", prefix, ServerPrefix,
1578 PackagePrefix[PackageIndex], defp->pc.proc_name);
1579 for (plist = defp->pc.plists; plist; plist = plist->next) {
1580 if (plist->component_kind == DEF_PARAM) {
1581 if (plist->pl.param_flag & INDIRECT_PARAM) {
1582 f_print(fout, ", &%s", plist->pl.param_name);
1584 if (plist->pl.param_flag & OUT_STRING) {
1585 f_print(fout, ", &%s", plist->pl.param_name);
1587 f_print(fout, ", %s", plist->pl.param_name);
1592 f_print(fout, ");\n");
1594 f_print(fout, "\tif (z_result)\n\t\treturn z_result;\n");
1600 ss_ProcMarshallOutParams_setup(definition * defp)
1605 noofparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1607 f_print(fout, "\tz_xdrs->x_op = XDR_ENCODE;\n");
1609 for (plist = defp->pc.plists, i = 0; plist; plist = plist->next) {
1610 if (plist->component_kind == DEF_PARAM
1611 && (plist->pl.param_kind == DEF_OUTPARAM
1612 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1614 f_print(fout, "\tif ((!%s)",
1615 (plist->scode ? plist->scode : plist->code));
1617 f_print(fout, "\n\t || (!%s)",
1618 (plist->scode ? plist->scode : plist->code));
1620 if (++i == noofparams) {
1621 f_print(fout, ")\n\t\tz_result = RXGEN_SS_MARSHAL;\n");
1629 ss_ProcTail_frees(char *xdrfunc, int *somefrees) {
1631 f_print(fout, "\tz_xdrs->x_op = XDR_FREE;\n");
1632 f_print(fout, "\tif ((!%s)", xdrfunc);
1635 f_print(fout, "\n\t || (!%s)", xdrfunc);
1641 ss_ProcTail_setup(definition * defp)
1648 if (defp->can_fail) {
1649 f_print(fout, "fail:\n");
1652 for (plist = defp->pc.plists; plist; plist = plist->next) {
1653 if (plist->component_kind == DEF_PARAM
1654 && (plist->pl.param_flag & FREETHIS_PARAM))
1655 ss_ProcTail_frees(plist->scode, &somefrees);
1658 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1659 defp1 = (definition *) listp->val;
1660 for (plist = defp->pc.plists; plist; plist = plist->next) {
1661 if (plist->component_kind == DEF_PARAM
1662 && (plist->pl.param_kind == DEF_OUTPARAM
1663 || plist->pl.param_kind == DEF_INOUTPARAM)
1664 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1665 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1666 switch (defp1->pc.rel) {
1669 ss_ProcTail_frees(plist->scode, &somefrees);
1679 for (listp = uniondef_defined; listp != NULL; listp = listp->next) {
1680 defp1 = (definition *) listp->val;
1681 for (plist = defp->pc.plists; plist; plist = plist->next) {
1682 if (plist->component_kind == DEF_PARAM
1683 && (plist->pl.param_kind == DEF_OUTPARAM
1684 || plist->pl.param_kind == DEF_INOUTPARAM)
1685 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1686 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1687 if (plist->pl.param_flag & INDIRECT_PARAM) {
1688 ss_ProcTail_frees(plist->scode, &somefrees);
1696 f_print(fout, ")\n");
1697 f_print(fout, "\t\tz_result = RXGEN_SS_XDRFREE;\n\n");
1701 f_print(fout, "\tif (rx_enable_stats) {\n");
1702 f_print(fout, "\t rx_RecordCallStatistics(z_call,");
1703 if (PackageStatIndex[PackageIndex]) {
1704 f_print(fout, " %s,\n", PackageStatIndex[PackageIndex]);
1707 "\n\t\t(((afs_uint32)(ntohs(rx_ServiceIdOf(rx_ConnectionOf(z_call))) << 16)) |\n"
1708 "\t\t((afs_uint32)ntohs(rx_ServiceOf(rx_ConnectionOf(z_call))->servicePort))),\n");
1710 f_print(fout, "\t\t%d, %sNO_OF_STAT_FUNCS, 0);\n",
1711 no_of_stat_funcs, PackagePrefix[PackageIndex]);
1712 f_print(fout, "\t}\n\n");
1715 f_print(fout, "\treturn z_result;\n");
1716 f_print(fout, "}\n\n");
1721 ucs_ProcName_setup(definition * defp, char *procheader, int split_flag)
1727 f_print(fout, "int %s%s%s%s(struct ubik_client *aclient, afs_int32 aflags",
1728 procheader, prefix, PackagePrefix[PackageIndex],
1729 defp->pc.proc_name);
1731 f_print(fout, "int %s%s%s%s(aclient, aflags", procheader, prefix,
1732 PackagePrefix[PackageIndex], defp->pc.proc_name);
1735 if ((strlen(procheader) + strlen(prefix) +
1736 strlen(PackagePrefix[PackageIndex]) + strlen(defp->pc.proc_name)) >=
1737 MAX_FUNCTION_NAME_LEN) {
1738 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1741 for (plist = defp->pc.plists; plist; plist = plist->next) {
1742 if (plist->component_kind == DEF_PARAM) {
1745 if (plist->pl.param_kind == DEF_INPARAM &&
1746 strcmp(plist->pl.param_type, "char *") == 0) {
1747 f_print(fout, "const ");
1749 if (plist->pl.param_flag & OUT_STRING) {
1750 f_print(fout, "%s *%s", plist->pl.param_type,
1751 plist->pl.param_name);
1753 f_print(fout, "%s %s", plist->pl.param_type,
1754 plist->pl.param_name);
1757 plist->pl.param_flag &= ~PROCESSED_PARAM;
1758 f_print(fout, " %s", plist->pl.param_name);
1762 f_print(fout, ")\n");
1768 ucs_ProcParams_setup(definition * defp, int split_flag)
1770 proc1_list *plist, *plist1;
1775 f_print(fout, "\tstruct ubik_client *aclient;\n\tafs_int32 aflags;\n");
1776 for (plist = defp->pc.plists; plist; plist = plist->next) {
1777 if (plist->component_kind == DEF_PARAM
1778 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1779 if (plist->pl.param_flag & OUT_STRING) {
1780 f_print(fout, "\t%s *%s", plist->pl.param_type,
1781 plist->pl.param_name);
1783 f_print(fout, "\t%s %s", plist->pl.param_type,
1784 plist->pl.param_name);
1786 plist->pl.param_flag |= PROCESSED_PARAM;
1787 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1788 if ((plist1->component_kind == DEF_PARAM)
1789 && streq(plist->pl.param_type, plist1->pl.param_type)
1790 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1792 char *pntr = strchr(plist1->pl.param_type, '*');
1795 if (plist1->pl.param_flag & OUT_STRING) {
1796 f_print(fout, ", *%s%s", star, plist1->pl.param_name);
1798 f_print(fout, ", %s%s", star, plist1->pl.param_name);
1800 plist1->pl.param_flag |= PROCESSED_PARAM;
1803 f_print(fout, ";\n");
1809 ucs_ProcTail_setup(definition * defp, int split_flag)
1813 f_print(fout, "{\tafs_int32 rcode, code, newHost, thisHost, i, _ucount;\n");
1814 f_print(fout, "\tint chaseCount, pass, needsync;\n");
1815 #if 0 /* goes with block below */
1816 f_print(fout, "\tint j, inlist;\n");
1818 f_print(fout, "\tstruct rx_connection *tc;\n");
1819 f_print(fout, "\tstruct rx_peer *rxp;\n");
1820 f_print(fout, "\tshort origLevel;\n\n");
1821 f_print(fout, "\tif (!aclient)\n");
1822 f_print(fout, "\t\treturn UNOENT;\n");
1823 f_print(fout, "\tLOCK_UBIK_CLIENT(aclient);\n\n");
1824 f_print(fout, "\t restart:\n");
1825 f_print(fout, "\torigLevel = aclient->initializationState;\n");
1826 f_print(fout, "\trcode = UNOSERVERS;\n");
1827 f_print(fout, "\tchaseCount = needsync = 0;\n\n");
1828 #if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
1829 f_print(fout, "\tinlist = 0;\n");
1830 f_print(fout, "\tLOCK_UCLNT_CACHE;\n");
1831 f_print(fout, "\tfor (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {\n");
1832 f_print(fout, "\t\tif (calls_needsync[j] == (int *)%s%s%s) {\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1833 f_print(fout, "\t\t\tinlist = needsync = 1;\n");
1834 f_print(fout, "\t\t\tbreak;\n");
1835 f_print(fout, "\t\t}\n");
1836 f_print(fout, "\t}\n");
1837 f_print(fout, "\tUNLOCK_UCLNT_CACHE;\n");
1839 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");
1840 f_print(fout, "\tfor (pass = 0; pass < 2; pass++) { /*p */\n");
1841 f_print(fout, "\t\t/* For each entry in our servers list */\n");
1842 f_print(fout, "\t\tfor (_ucount = 0;; _ucount++) { /*s */\n\n");
1843 f_print(fout, "\t\tif (needsync) {\n");
1844 f_print(fout, "\t\t\t/* Need a sync site. Lets try to quickly find it */\n");
1845 f_print(fout, "\t\t\tif (aclient->syncSite) {\n");
1846 f_print(fout, "\t\t\t\tnewHost = aclient->syncSite; /* already in network order */\n");
1847 f_print(fout, "\t\t\t\taclient->syncSite = 0; /* Will reset if it works */\n");
1848 f_print(fout, "\t\t\t} else if (aclient->conns[3]) {\n");
1849 f_print(fout, "\t\t\t\t/* If there are fewer than four db servers in a cell,\n");
1850 f_print(fout, "\t\t\t\t* there's no point in making the GetSyncSite call.\n");
1851 f_print(fout, "\t\t\t\t* At best, it's a wash. At worst, it results in more\n");
1852 f_print(fout, "\t\t\t\t* RPCs than you would otherwise make.\n");
1853 f_print(fout, "\t\t\t\t*/\n");
1854 f_print(fout, "\t\t\t\ttc = aclient->conns[_ucount];\n");
1855 f_print(fout, "\t\t\t\tif (tc && rx_ConnError(tc)) {\n");
1856 f_print(fout, "\t\t\t\t\taclient->conns[_ucount] = tc = ubik_RefreshConn(tc);\n");
1857 f_print(fout, "\t\t\t\t}\n");
1858 f_print(fout, "\t\t\t\tif (!tc)\n");
1859 f_print(fout, "\t\t\t\t\tbreak;\n");
1860 f_print(fout, "\t\t\t\tcode = VOTE_GetSyncSite(tc, &newHost);\n");
1861 f_print(fout, "\t\t\t\tif (aclient->initializationState != origLevel)\n");
1862 f_print(fout, "\t\t\t\t\tgoto restart; /* somebody did a ubik_ClientInit */\n");
1863 f_print(fout, "\t\t\t\tif (code)\n");
1864 f_print(fout, "\t\t\t\t\tnewHost = 0;\n");
1865 f_print(fout, "\t\t\t\tnewHost = htonl(newHost); /* convert to network order */\n");
1866 f_print(fout, "\t\t\t} else {\n");
1867 f_print(fout, "\t\t\t\tnewHost = 0;\n");
1868 f_print(fout, "\t\t\t}\n");
1869 f_print(fout, "\t\t\tif (newHost) {\n");
1870 f_print(fout, "\t\t\t\t/* position count at the appropriate slot in the client\n");
1871 f_print(fout, "\t\t\t\t* structure and retry. If we can't find in slot, we'll\n");
1872 f_print(fout, "\t\t\t\t* just continue through the whole list \n");
1873 f_print(fout, "\t\t\t\t*/\n");
1874 f_print(fout, "\t\t\t\tfor (i = 0; i < MAXSERVERS && aclient->conns[i]; i++) {\n");
1875 f_print(fout, "\t\t\t\t\trxp = rx_PeerOf(aclient->conns[i]);\n");
1876 f_print(fout, "\t\t\t\t\tthisHost = rx_HostOf(rxp);\n");
1877 f_print(fout, "\t\t\t\t\tif (!thisHost)\n");
1878 f_print(fout, "\t\t\t\t\t\tbreak;\n");
1879 f_print(fout, "\t\t\t\t\tif (thisHost == newHost) {\n");
1880 f_print(fout, "\t\t\t\t\t\tif (chaseCount++ > 2)\n");
1881 f_print(fout, "\t\t\t\t\t\t\tbreak; /* avoid loop asking */\n");
1882 f_print(fout, "\t\t\t\t\t\t_ucount = i; /* this index is the sync site */\n");
1883 f_print(fout, "\t\t\t\t\t\tbreak;\n");
1884 f_print(fout, "\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n");
1885 f_print(fout, "\t\t/*needsync */\n");
1886 f_print(fout, "\t\ttc = aclient->conns[_ucount];\n");
1887 f_print(fout, "\t\tif (tc && rx_ConnError(tc)) {\n");
1888 f_print(fout, "\t\t\taclient->conns[_ucount] = tc = ubik_RefreshConn(tc);\n");
1889 f_print(fout, "\t\t}\n");
1890 f_print(fout, "\t\tif (!tc)\n");
1891 f_print(fout, "\t\t\tbreak;\n\n");
1892 f_print(fout, "\t\tif ((pass == 0) && (aclient->states[_ucount] & CFLastFailed)) {\n");
1893 f_print(fout, "\t\t\tcontinue; /* this guy's down */\n");
1894 f_print(fout, "\t\t}\n");
1896 f_print(fout, "\t\trcode = %s%s%s(tc\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1897 for (plist = defp->pc.plists; plist; plist = plist->next) {
1898 if (plist->component_kind == DEF_PARAM) {
1899 plist->pl.param_flag &= ~PROCESSED_PARAM;
1900 f_print(fout, ", %s", plist->pl.param_name);
1903 f_print(fout, ");\n");
1904 f_print(fout, "\t\tif (aclient->initializationState != origLevel) {\n");
1905 f_print(fout, "\t\t\t/* somebody did a ubik_ClientInit */\n");
1906 f_print(fout, "\t\t\tif (rcode)\n");
1907 f_print(fout, "\t\t\t\tgoto restart; /* call failed */\n");
1908 f_print(fout, "\t\t\telse\n");
1909 f_print(fout, "\t\t\t\tgoto done; /* call suceeded */\n");
1910 f_print(fout, "\t\t}\n");
1911 f_print(fout, "\t\tif (rcode < 0) { /* network errors */\n");
1912 f_print(fout, "\t\t\taclient->states[_ucount] |= CFLastFailed; /* Mark server down */\n");
1913 f_print(fout, "\t\t} else if (rcode == UNOTSYNC) {\n");
1914 f_print(fout, "\t\t\tneedsync = 1;\n");
1915 f_print(fout, "\t\t} else if (rcode != UNOQUORUM) {\n");
1916 f_print(fout, "\t\t\t/* either misc ubik code, or misc appl code, or success. */\n");
1917 f_print(fout, "\t\t\taclient->states[_ucount] &= ~CFLastFailed; /* mark server up*/\n");
1918 f_print(fout, "\t\t\tgoto done; /* all done */\n");
1919 f_print(fout, "\t\t}\n");
1920 f_print(fout, "\t\t} /*s */\n");
1921 f_print(fout, "\t} /*p */\n\n");
1922 f_print(fout, "\tdone:\n");
1923 f_print(fout, "\tif (needsync) {\n");
1925 #if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
1926 f_print(fout, "\t\tif (!inlist) { /* Remember proc call that needs sync site */\n");
1927 f_print(fout, "\t\t\tLOCK_UCLNT_CACHE;\n");
1928 f_print(fout, "\t\t\tcalls_needsync[synccount % SYNCCOUNT] = (int *)%s%s%s;\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1929 f_print(fout, "\t\t\tsynccount++;\n");
1930 f_print(fout, "\t\t\tUNLOCK_UCLNT_CACHE;\n");
1931 f_print(fout, "\t\t\tinlist = 1;\n");
1932 f_print(fout, "\t\t}\n");
1934 f_print(fout, "\t\tif (!rcode) { /* Remember the sync site - cmd successful */\n");
1935 f_print(fout, "\t\t\trxp = rx_PeerOf(aclient->conns[_ucount]);\n");
1936 f_print(fout, "\t\t\taclient->syncSite = rx_HostOf(rxp);\n");
1937 f_print(fout, "\t\t}\n");
1938 f_print(fout, "\t}\n");
1939 f_print(fout, "\tUNLOCK_UBIK_CLIENT(aclient);\n");
1940 f_print(fout, "\treturn rcode;\n}\n\n");
1945 opcode_holes_exist(void)
1949 for (i = lowest_opcode[PackageIndex]; i < highest_opcode[PackageIndex];
1951 if (!opcodenum_is_defined(i))
1959 er_Proc_CodeGeneration(void)
1963 temp = PackageIndex;
1964 if (!combinepackages)
1966 for (; PackageIndex <= temp; PackageIndex++) {
1967 if (proc_defined[PackageIndex] == NULL)
1969 if (combinepackages || opcode_holes_exist()) {
1970 er_HeadofOldStyleProc_setup();
1971 er_BodyofOldStyleProc_setup();
1972 er_TailofOldStyleProc_setup();
1974 er_ProcDeclExterns_setup();
1975 er_ProcProcsArray_setup();
1976 er_ProcMainBody_setup();
1979 PackageIndex = temp;
1984 er_ProcDeclExterns_setup(void)
1992 f_print(fout, "\n");
1993 for (listp = proc_defined[PackageIndex]; listp != NULL;
1994 listp = listp->next) {
1995 defp = (definition *) listp->val;
1996 if (defp->pc.proc_serverstub) {
1997 f_print(fout, "afs_int32 %s();\n", defp->pc.proc_serverstub);
2004 er_ProcProcsArray_setup(void)
2009 if ((listp = proc_defined[PackageIndex])) {
2010 defp = (definition *) listp->val;
2012 f_print(fout, "\nstatic char *opnames%d[] = {\"%s%s\"",
2013 PackageIndex, defp->pc.proc_prefix, defp->pc.proc_name);
2016 if (defp->pc.proc_serverstub) {
2017 f_print(fout, "\nstatic afs_int32 (*StubProcsArray%d[])() = {%s",
2018 PackageIndex, defp->pc.proc_serverstub);
2021 "\nstatic afs_int32 (*StubProcsArray%d[])(struct rx_call *z_call, XDR *z_xdrs) = {_%s%s%s",
2022 PackageIndex, prefix, defp->pc.proc_prefix,
2023 ((definition *) listp->val)->pc.proc_name);
2024 defp = (definition *) listp->val;
2027 listp = listp->next;
2029 for (; listp != NULL; listp = listp->next) {
2030 defp = (definition *) listp->val;
2032 f_print(fout, ", \"%s%s\"",defp->pc.proc_prefix,defp->pc.proc_name);
2035 if (defp->pc.proc_serverstub) {
2036 f_print(fout, ",%s", defp->pc.proc_serverstub);
2038 f_print(fout, ", _%s%s%s", prefix, defp->pc.proc_prefix,
2039 defp->pc.proc_name);
2043 f_print(fout, "};\n\n");
2048 er_ProcMainBody_setup(void)
2051 f_print(fout, "char *%sTranslateOpCode(int op)\n{\n",
2052 PackagePrefix[PackageIndex]);
2053 f_print(fout, "\tif (op < %sLOWEST_OPCODE || op > %sHIGHEST_OPCODE)\n\t\treturn NULL;\n",
2054 PackagePrefix[PackageIndex], PackagePrefix[PackageIndex]);
2055 f_print(fout, "\treturn opnames%d[op - %sLOWEST_OPCODE];\n}\n",
2056 PackageIndex, PackagePrefix[PackageIndex]);
2059 f_print(fout, "int %s%sExecuteRequest(struct rx_call *z_call)\n",
2060 prefix, PackagePrefix[PackageIndex]);
2061 f_print(fout, "{\n\tint op;\n");
2062 f_print(fout, "\tXDR z_xdrs;\n");
2063 f_print(fout, "\t" "afs_int32 z_result;\n\n");
2064 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
2066 "\tif (!xdr_int(&z_xdrs, &op))\n\t\tz_result = RXGEN_DECODE;\n");
2068 "\telse if (op < %sLOWEST_OPCODE || op > %sHIGHEST_OPCODE)\n\t\tz_result = RXGEN_OPCODE;\n",
2069 PackagePrefix[PackageIndex], PackagePrefix[PackageIndex]);
2071 "\telse\n\t\tz_result = (*StubProcsArray%d[op - %sLOWEST_OPCODE])(z_call, &z_xdrs);\n",
2072 PackageIndex, PackagePrefix[PackageIndex]);
2073 f_print(fout, "\treturn hton_syserr_conv(z_result);\n}\n");
2078 er_HeadofOldStyleProc_setup(void)
2081 f_print(fout, "char *%sTranslateOpCode(int op)\n{\n",
2082 (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
2086 "\nint %s%sExecuteRequest (struct rx_call *z_call)\n",
2088 (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
2089 f_print(fout, "{\n");
2090 f_print(fout, "\tint op;\n");
2091 f_print(fout, "\tXDR z_xdrs;\n");
2092 f_print(fout, "\t" "afs_int32 z_result;\n\n");
2093 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
2094 f_print(fout, "\tz_result = RXGEN_DECODE;\n");
2095 f_print(fout, "\tif (!xdr_int(&z_xdrs, &op)) goto fail;\n");
2097 f_print(fout, "\tswitch (op) {\n");
2101 er_BodyofOldStyleProc_setup(void)
2105 if (combinepackages) {
2106 int temp = PackageIndex;
2107 for (PackageIndex = 0; PackageIndex <= temp; PackageIndex++) {
2108 for (listp = proc_defined[PackageIndex]; listp != NULL;
2109 listp = listp->next)
2110 proc_er_case((definition *) listp->val);
2112 PackageIndex = temp;
2114 for (listp = proc_defined[PackageIndex]; listp != NULL;
2115 listp = listp->next)
2116 proc_er_case((definition *) listp->val);
2122 proc_er_case(definition * defp)
2125 f_print(fout, "\t\tcase %d:", defp->pc.proc_opcodenum);
2126 f_print(fout, "\treturn \"%s%s\";\n",
2127 defp->pc.proc_prefix, defp->pc.proc_name);
2130 if (opcodesnotallowed[PackageIndex]) {
2131 f_print(fout, "\t\tcase %d:\n", defp->pc.proc_opcodenum);
2133 f_print(fout, "\t\tcase %s:\n", defp->pc.proc_opcodename);
2135 if (defp->pc.proc_serverstub) {
2136 f_print(fout, "\t\t\tz_result = %s(z_call, &z_xdrs);\n",
2137 defp->pc.proc_serverstub);
2139 f_print(fout, "\t\t\tz_result = _%s%s%s(z_call, &z_xdrs);\n", prefix,
2140 defp->pc.proc_prefix, defp->pc.proc_name);
2142 f_print(fout, "\t\t\tbreak;\n");
2147 er_TailofOldStyleProc_setup(void)
2149 f_print(fout, "\t\tdefault:\n");
2151 f_print(fout, "\t\t\treturn NULL;\n\t}\n}\n");
2154 f_print(fout, "\t\t\tz_result = RXGEN_OPCODE;\n");
2155 f_print(fout, "\t\t\tbreak;\n\t}\n");
2156 f_print(fout, "fail:\n");
2157 f_print(fout, "\treturn z_result;\n}\n");
2161 h_ProcMainBody_setup(void)
2163 f_print(fout,"\nextern int %s%sExecuteRequest(struct rx_call *);\n",
2164 prefix, PackagePrefix[PackageIndex]);
2168 h_HeadofOldStyleProc_setup(void)
2170 f_print(fout,"\nextern int %s%sExecuteRequest(struct rx_call *);\n",
2172 (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
2176 h_Proc_CodeGeneration(void)
2180 temp = PackageIndex;
2181 if (!combinepackages)
2183 for (; PackageIndex <= temp; PackageIndex++) {
2184 if (combinepackages || opcode_holes_exist()) {
2185 h_HeadofOldStyleProc_setup();
2187 h_ProcMainBody_setup();
2190 PackageIndex = temp;
2194 h_opcode_stats(void)
2196 if (combinepackages) {
2198 "\n/* Opcode-related useful stats for Master package: %s */\n",
2200 f_print(fout, "#define %sLOWEST_OPCODE %d\n", MasterPrefix,
2201 master_lowest_opcode);
2202 f_print(fout, "#define %sHIGHEST_OPCODE %d\n", MasterPrefix,
2203 master_highest_opcode);
2204 f_print(fout, "#define %sNUMBER_OPCODES %d\n\n", MasterPrefix,
2205 master_no_of_opcodes);
2207 f_print(fout, "#define %sNO_OF_STAT_FUNCS\t%d\n\n", MasterPrefix,
2208 no_of_stat_funcs_header[0]);
2209 f_print(fout, "AFS_RXGEN_EXPORT\n");
2210 f_print(fout, "extern const char *%sfunction_names[];\n\n",
2215 for (i = 0; i <= PackageIndex; i++) {
2217 "\n/* Opcode-related useful stats for package: %s */\n",
2219 f_print(fout, "#define %sLOWEST_OPCODE %d\n", PackagePrefix[i],
2221 f_print(fout, "#define %sHIGHEST_OPCODE %d\n",
2222 PackagePrefix[i], highest_opcode[i]);
2223 f_print(fout, "#define %sNUMBER_OPCODES %d\n\n",
2224 PackagePrefix[i], no_of_opcodes[i]);
2226 f_print(fout, "#define %sNO_OF_STAT_FUNCS\t%d\n\n",
2227 PackagePrefix[i], no_of_stat_funcs_header[i]);
2228 f_print(fout, "AFS_RXGEN_EXPORT\n");
2229 f_print(fout, "extern const char *%sfunction_names[];\n\n",
2238 generate_multi_macros(definition * defp)
2240 char *startname = SplitStart, *endname = SplitEnd;
2249 f_print(fout, "\n#include <rx/rx_multi.h>");
2251 f_print(fout, "\n#define multi_%s%s(", PackagePrefix[PackageIndex],
2252 defp->pc.proc_name);
2253 for (plist = defp->pc.plists; plist; plist = plist->next) {
2254 if (plist->component_kind == DEF_PARAM) {
2257 f_print(fout, "%s", plist->pl.param_name);
2259 f_print(fout, ", %s", plist->pl.param_name);
2263 f_print(fout, ") \\\n");
2265 startname = "Start";
2268 f_print(fout, "\tmulti_Body(%s%s%s(multi_call", startname,
2269 PackagePrefix[PackageIndex], defp->pc.proc_name);
2270 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 0);
2271 for (plist = defp->pc.plists; plist; plist = plist->next) {
2272 if (plist->component_kind == DEF_PARAM)
2273 f_print(fout, ", %s", plist->pl.param_name);
2275 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 1);
2276 f_print(fout, "), %s%s%s(multi_call", endname,
2277 PackagePrefix[PackageIndex], defp->pc.proc_name);
2278 do_split(defp, IN, &numofparams, DEF_INPARAM, 0);
2279 for (plist = defp->pc.plists; plist; plist = plist->next) {
2280 if (plist->component_kind == DEF_PARAM) {
2281 f_print(fout, ", %s", plist->pl.param_name);
2284 do_split(defp, IN, &numofparams, DEF_INPARAM, 1);
2285 f_print(fout, "))\n\n");
2290 IsRxgenToken(token * tokp)
2292 if (tokp->kind == TOK_PACKAGE || tokp->kind == TOK_PREFIX
2293 || tokp->kind == TOK_SPECIAL || tokp->kind == TOK_STARTINGOPCODE
2294 || tokp->kind == TOK_SPLITPREFIX || tokp->kind == TOK_PROC
2295 || tokp->kind == TOK_STATINDEX)
2301 IsRxgenDefinition(definition * def)
2303 if (def->def_kind == DEF_PACKAGE || def->def_kind == DEF_PREFIX
2304 || def->def_kind == DEF_SPECIAL || def->def_kind == DEF_STARTINGOPCODE
2305 || def->def_kind == DEF_SPLITPREFIX || def->def_kind == DEF_PROC)