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>
46 #include "rpc_parse.h"
49 list *proc_defined[MAX_PACKAGES], *special_defined, *typedef_defined,
51 char *SplitStart = NULL;
52 char *SplitEnd = NULL;
53 char *MasterPrefix = NULL;
54 char *ServerPrefix = "";
55 char *PackagePrefix[MAX_PACKAGES];
56 char *PackageStatIndex[MAX_PACKAGES];
57 int no_of_stat_funcs = 0; /*
58 * current function number in client interface
61 int no_of_stat_funcs_header[MAX_PACKAGES]; /*
62 * Total number of functions in client
65 int no_of_opcodes[MAX_PACKAGES], master_no_of_opcodes = 0;
66 int lowest_opcode[MAX_PACKAGES], master_lowest_opcode = 99999;
67 int highest_opcode[MAX_PACKAGES], master_highest_opcode = 0;
68 int master_opcodenumber = 99999;
69 int opcodesnotallowed[MAX_PACKAGES];
70 int combinepackages = 0;
71 int PackageIndex = -1;
72 int PerProcCounter = 0;
76 * Character arrays to keep list of function names as we process the file
79 char function_list[MAX_PACKAGES]
80 [MAX_FUNCTIONS_PER_PACKAGE]
81 [MAX_FUNCTION_NAME_LEN];
82 int function_list_index;
84 /* static prototypes */
85 static void isdefined(definition * defp);
86 static void def_struct(definition * defp);
87 static void def_program(definition * defp);
88 static void def_enum(definition * defp);
89 static void def_const(definition * defp);
90 static void def_union(definition * defp);
91 static void def_typedef(definition * defp);
92 static void get_declaration(declaration * dec, defkind dkind);
93 static void get_type(char **prefixp, char **typep, defkind dkind);
94 static void unsigned_dec(char **typep);
95 static void def_package(definition * defp);
96 static void def_prefix(definition * defp);
97 static void def_statindex(definition * defp);
98 static void def_startingopcode(definition * defp);
99 static void def_split(definition * defp);
100 static void customize_struct(definition * defp);
101 static char *structname(char *name);
102 static void def_special(declaration * dec, definition * defp);
103 static void check_proc(definition * defp, token * tokp, int noname);
104 static int InvalidConstant(char *name);
105 static int opcodenum_is_defined(int opcode_num);
106 static void analyze_ProcParams(definition * defp, token * tokp);
107 static void generate_code(definition * defp, int proc_split_flag,
109 static void handle_split_proc(definition * defp, int multi_flag);
110 static void do_split(definition * defp, int direction, int *numofparams,
111 defkind param_kind, int restore_flag);
112 static void hdle_param_tok(definition * defp, declaration * dec, token * tokp,
114 static void get1_param_type(definition * defp, declaration * dec,
116 static void get_param_type(definition * defp, declaration * dec,
117 char **param_type, char **typename);
119 static void hndle_param_tail(definition * defp, declaration * dec,
120 token * tokp, char *typename);
122 static void cs_Proc_CodeGeneration(definition * defp, int split_flag,
124 static void cs_ProcName_setup(definition * defp, char *procheader,
126 static void cs_ProcParams_setup(definition * defp, int split_flag);
127 static void cs_ProcMarshallInParams_setup(definition * defp, int split_flag);
128 static void cs_ProcSendPacket_setup(definition * defp, int split_flag);
129 static void cs_ProcUnmarshallOutParams_setup(definition * defp);
130 static void cs_ProcTail_setup(definition * defp, int split_flag);
131 static void ucs_ProcName_setup(definition * defp, char *procheader,
133 static void ucs_ProcParams_setup(definition * defp, int split_flag);
134 static void ucs_ProcTail_setup(definition * defp, int split_flag);
135 static void ss_Proc_CodeGeneration(definition * defp);
136 static void ss_ProcName_setup(definition * defp);
137 static void ss_ProcParams_setup(definition * defp, int *somefrees);
138 static void ss_ProcSpecial_setup(definition * defp, int *somefrees);
139 static void ss_ProcUnmarshallInParams_setup(definition * defp);
140 static void ss_ProcCallRealProc_setup(definition * defp);
141 static void ss_ProcMarshallOutParams_setup(definition * defp);
142 static void ss_ProcTail_setup(definition * defp, int somefrees);
143 static int opcode_holes_exist(void);
144 static void er_ProcDeclExterns_setup(void);
145 static void er_ProcProcsArray_setup(void);
146 static void er_ProcMainBody_setup(void);
147 static void er_HeadofOldStyleProc_setup(void);
148 static void er_BodyofOldStyleProc_setup(void);
149 static void proc_er_case(definition * defp);
150 static void er_TailofOldStyleProc_setup(void);
155 * return the next definition you see
163 defp = ALLOC(definition);
164 memset((char *)defp, 0, sizeof(definition));
200 def_special(&dec, defp);
203 case TOK_STARTINGOPCODE:
204 def_startingopcode(defp);
209 customize_struct(defp);
211 case TOK_SPLITPREFIX:
216 if (tok.kind == TOK_LPAREN) {
218 check_proc(defp, &tok, 1);
220 check_proc(defp, &tok, 0);
223 check_proc(defp, &tok, 0);
227 check_proc(defp, &tok, 1);
230 error("definition keyword expected");
232 if (!IsRxgenToken(&tok)) {
233 scan(TOK_SEMICOLON, &tok);
241 isdefined(definition * defp)
243 STOREVAL(&defined, defp);
248 def_struct(definition * defp)
255 defp->def_kind = DEF_STRUCT;
257 scan(TOK_IDENT, &tok);
258 defp->def_name = tok.str;
259 scan(TOK_LBRACE, &tok);
260 tailp = &defp->def.st.decls;
262 get_declaration(&dec, DEF_STRUCT);
263 decls = ALLOC(decl_list);
266 tailp = &decls->next;
267 scan(TOK_SEMICOLON, &tok);
269 } while (tok.kind != TOK_RBRACE);
275 def_program(definition * defp)
279 version_list **vtailp;
283 defp->def_kind = DEF_PROGRAM;
284 scan(TOK_IDENT, &tok);
285 defp->def_name = tok.str;
286 scan(TOK_LBRACE, &tok);
287 vtailp = &defp->def.pr.versions;
288 scan(TOK_VERSION, &tok);
290 scan(TOK_IDENT, &tok);
291 vlist = ALLOC(version_list);
292 vlist->vers_name = tok.str;
293 scan(TOK_LBRACE, &tok);
294 ptailp = &vlist->procs;
296 plist = ALLOC(proc_list);
297 get_type(&plist->res_prefix, &plist->res_type, DEF_PROGRAM);
298 if (streq(plist->res_type, "opaque")) {
299 error("illegal result type");
301 scan(TOK_IDENT, &tok);
302 plist->proc_name = tok.str;
303 scan(TOK_LPAREN, &tok);
304 get_type(&plist->arg_prefix, &plist->arg_type, DEF_PROGRAM);
305 if (streq(plist->arg_type, "opaque")) {
306 error("illegal argument type");
308 scan(TOK_RPAREN, &tok);
309 scan(TOK_EQUAL, &tok);
311 scan(TOK_SEMICOLON, &tok);
312 plist->proc_num = tok.str;
314 ptailp = &plist->next;
316 } while (tok.kind != TOK_RBRACE);
318 vtailp = &vlist->next;
319 scan(TOK_RBRACE, &tok);
320 scan(TOK_EQUAL, &tok);
322 vlist->vers_num = tok.str;
323 scan(TOK_SEMICOLON, &tok);
324 scan2(TOK_VERSION, TOK_RBRACE, &tok);
325 } while (tok.kind == TOK_VERSION);
326 scan(TOK_EQUAL, &tok);
328 defp->def.pr.prog_num = tok.str;
333 def_enum(definition * defp)
337 enumval_list **tailp;
339 defp->def_kind = DEF_ENUM;
340 scan(TOK_IDENT, &tok);
341 defp->def_name = tok.str;
342 scan(TOK_LBRACE, &tok);
343 tailp = &defp->def.en.vals;
345 scan(TOK_IDENT, &tok);
346 elist = ALLOC(enumval_list);
347 elist->name = tok.str;
348 elist->assignment = NULL;
349 scan3(TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok);
350 if (tok.kind == TOK_EQUAL) {
352 elist->assignment = tok.str;
353 scan2(TOK_COMMA, TOK_RBRACE, &tok);
356 tailp = &elist->next;
357 } while (tok.kind != TOK_RBRACE);
362 def_const(definition * defp)
366 defp->def_kind = DEF_CONST;
367 scan(TOK_IDENT, &tok);
368 defp->def_name = tok.str;
369 scan(TOK_EQUAL, &tok);
370 scan2(TOK_IDENT, TOK_STRCONST, &tok);
371 defp->def.co = tok.str;
375 def_union(definition * defp)
382 defp->def_kind = DEF_UNION;
383 scan(TOK_IDENT, &tok);
384 defp->def_name = tok.str;
385 scan(TOK_SWITCH, &tok);
386 scan(TOK_LPAREN, &tok);
387 get_declaration(&dec, DEF_UNION);
388 defp->def.un.enum_decl = dec;
389 tailp = &defp->def.un.cases;
390 scan(TOK_RPAREN, &tok);
391 scan(TOK_LBRACE, &tok);
392 scan(TOK_CASE, &tok);
393 while (tok.kind == TOK_CASE) {
394 scan(TOK_IDENT, &tok);
395 cases = ALLOC(case_list);
396 cases->case_name = tok.str;
397 scan(TOK_COLON, &tok);
398 get_declaration(&dec, DEF_UNION);
399 cases->case_decl = dec;
401 tailp = &cases->next;
402 scan(TOK_SEMICOLON, &tok);
403 scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
406 if (tok.kind == TOK_DEFAULT) {
407 scan(TOK_COLON, &tok);
408 get_declaration(&dec, DEF_UNION);
409 defp->def.un.default_decl = ALLOC(declaration);
410 *defp->def.un.default_decl = dec;
411 scan(TOK_SEMICOLON, &tok);
412 scan(TOK_RBRACE, &tok);
414 defp->def.un.default_decl = NULL;
420 def_typedef(definition * defp)
424 defp->def_kind = DEF_TYPEDEF;
425 get_declaration(&dec, DEF_TYPEDEF);
426 defp->def_name = dec.name;
427 defp->def.ty.old_prefix = dec.prefix;
428 defp->def.ty.old_type = dec.type;
429 defp->def.ty.rel = dec.rel;
430 defp->def.ty.array_max = dec.array_max;
435 get_declaration(declaration * dec, defkind dkind)
439 get_type(&dec->prefix, &dec->type, dkind);
440 dec->rel = REL_ALIAS;
441 if (streq(dec->type, "void")) {
444 scan2(TOK_STAR, TOK_IDENT, &tok);
445 if (tok.kind == TOK_STAR) {
446 dec->rel = REL_POINTER;
447 scan(TOK_IDENT, &tok);
450 if (peekscan(TOK_LBRACKET, &tok)) {
451 if (dec->rel == REL_POINTER) {
452 error("no array-of-pointer declarations -- use typedef");
454 dec->rel = REL_VECTOR;
456 dec->array_max = tok.str;
457 scan(TOK_RBRACKET, &tok);
458 } else if (peekscan(TOK_LANGLE, &tok)) {
459 if (dec->rel == REL_POINTER) {
460 error("no array-of-pointer declarations -- use typedef");
462 dec->rel = REL_ARRAY;
463 if (peekscan(TOK_RANGLE, &tok)) {
464 dec->array_max = "~0"; /* unspecified size, use max */
467 dec->array_max = tok.str;
468 scan(TOK_RANGLE, &tok);
471 if (streq(dec->type, "opaque")) {
472 if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
473 error("array declaration expected");
475 } else if (streq(dec->type, "string")) {
476 if (dec->rel != REL_ARRAY) {
477 error(" variable-length array declaration expected");
484 get_type(char **prefixp, char **typep, defkind dkind)
498 scan(TOK_IDENT, &tok);
506 (void)peekscan(TOK_INT, &tok);
509 *typep = "afs_int32";
510 (void)peekscan(TOK_INT, &tok);
513 if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
514 error("voids allowed only inside union and program definitions");
529 error("expected type specifier");
535 unsigned_dec(char **typep)
548 (void)peekscan(TOK_INT, &tok);
552 *typep = "afs_uint32";
553 (void)peekscan(TOK_INT, &tok);
567 def_package(definition * defp)
571 defp->def_kind = DEF_PACKAGE;
572 scan(TOK_IDENT, &tok);
573 defp->def_name = tok.str;
574 no_of_stat_funcs = 0;
575 if (PackageIndex++ >= MAX_PACKAGES)
576 error("Exceeded upper limit of package statements\n");
577 function_list_index = 0;
578 PackagePrefix[PackageIndex] = tok.str;
579 if (MasterPrefix == NULL)
580 MasterPrefix = tok.str;
581 no_of_opcodes[PackageIndex] = highest_opcode[PackageIndex] =
582 opcodesnotallowed[PackageIndex] = 0;
583 lowest_opcode[PackageIndex] = 99999;
584 proc_defined[PackageIndex] = NULL;
585 PackageStatIndex[PackageIndex] = NULL;
589 def_prefix(definition * defp)
593 defp->def_kind = DEF_PREFIX;
594 scan(TOK_IDENT, &tok);
595 defp->def_name = tok.str;
596 ServerPrefix = tok.str;
600 def_statindex(definition * defp)
605 defp->def_kind = DEF_CONST;
607 if (PackageIndex < 0)
608 error("'statindex' command must follow 'package' command!\n");
609 if (PackageStatIndex[PackageIndex])
610 error("Cannot have more then one 'statindex' per package!\n");
611 if (InvalidConstant(tok.str))
612 error("Index in 'statindex' command must be a constant!");
614 alloc(strlen(PackagePrefix[PackageIndex]) + strlen("STATINDEX") + 1);
615 strcpy(name, PackagePrefix[PackageIndex]);
616 strcat(name, "STATINDEX");
617 defp->def_name = name;
618 defp->def.co = tok.str;
619 PackageStatIndex[PackageIndex] = name;
623 def_startingopcode(definition * defp)
627 defp->def_kind = DEF_STARTINGOPCODE;
628 scan(TOK_IDENT, &tok);
629 defp->def_name = tok.str;
630 if (InvalidConstant(defp->def_name))
631 error("Opcode in 'startingopcode' command must be a constant!");
632 lowest_opcode[PackageIndex] = master_lowest_opcode = atoi(tok.str);
633 if (lowest_opcode[PackageIndex] < 0
634 || lowest_opcode[PackageIndex] > 99999)
636 ("startingopcode number is out of bounds (must be >= 0 < 100000)");
637 master_opcodenumber = lowest_opcode[PackageIndex];
638 opcodesnotallowed[PackageIndex] = 1;
642 def_split(definition * defp)
646 defp->def_kind = DEF_SPLITPREFIX;
651 scan(TOK_EQUAL, &tok);
652 scan(TOK_IDENT, &tok);
653 SplitStart = tok.str;
656 scan(TOK_EQUAL, &tok);
657 scan(TOK_IDENT, &tok);
663 error("syntax error in the 'splitprefix' line");
665 } while (tok.kind != TOK_SEMICOLON);
666 if (!SplitStart && !SplitEnd)
667 error("At least one param should be passed to 'splitprefix' cmd");
672 customize_struct(definition * defp)
676 definition *defp1 = ALLOC(definition);
677 spec_list *specs, **tailp;
679 defp->def_kind = DEF_CUSTOMIZED;
680 defp1->def_kind = DEF_SPECIAL;
681 tailp = &defp1->def.sd.specs;
682 for (listp = defp->def.st.decls; listp; listp = listp->next) {
684 if (streq(dec->type, "string") || (dec->rel == REL_POINTER)) {
685 specs = ALLOC(spec_list);
686 specs->sdef.string_name = dec->name;
687 specs->sdef.string_value = defp->def_name;
689 tailp = &specs->next;
693 STOREVAL(&special_defined, defp1);
697 structname(char *name)
699 static char namecontents[150];
702 strcpy(namecontents, name);
704 if (!strncmp(pnt, "struct", 6))
706 while (isspace(*pnt))
709 while (*pnt != ' ' && *pnt != '\0')
717 def_special(declaration * dec, definition * defp)
720 spec_list *specs, **tailp;
723 defp->def_kind = DEF_SPECIAL;
724 get_type(&dec->prefix, &dec->type, DEF_SPECIAL);
725 dec->rel = REL_POINTER;
726 scan(TOK_IDENT, &tok);
727 tailp = &defp->def.sd.specs;
729 specs = ALLOC(spec_list);
730 specs->sdef.string_name = tok.str;
731 get_param_type(defp, dec, &specs->sdef.string_value, &typename);
733 tailp = &specs->next;
734 scan2(TOK_COMMA, TOK_SEMICOLON, &tok);
735 if (tok.kind == TOK_SEMICOLON)
738 } while (tok.kind == TOK_IDENT);
740 STOREVAL(&special_defined, defp);
744 proc1_list *Proc_list, **Proc_listp;
747 check_proc(definition * defp, token * tokp, int noname)
753 if (PackageIndex < 0)
754 error("Procedure must be in a package!\n");
756 tokp->kind = TOK_PROC;
757 defp->def_kind = DEF_PROC;
759 defp->pc.proc_name = "";
761 defp->pc.proc_name = tokp->str;
763 defp->pc.proc_prefix = alloc(strlen(PackagePrefix[PackageIndex]) + 1);
764 strcpy(defp->pc.proc_prefix, PackagePrefix[PackageIndex]);
765 scan2(TOK_LPAREN, TOK_IDENT, &tok);
766 defp->pc.proc_serverstub = NULL;
767 if (tok.kind == TOK_IDENT) {
768 defp->pc.proc_serverstub = tok.str;
769 scan(TOK_LPAREN, &tok);
771 analyze_ProcParams(defp, &tok);
772 defp->pc.proc_opcodenum = -1;
773 scan4(TOK_SPLIT, TOK_MULTI, TOK_EQUAL, TOK_SEMICOLON, &tok);
774 if (tok.kind == TOK_MULTI) {
776 defp->pc.multi_flag = 1;
777 scan2(TOK_EQUAL, TOK_SEMICOLON, &tok);
779 defp->pc.multi_flag = 0;
781 if (tok.kind == TOK_SPLIT) {
783 defp->pc.split_flag = 1;
784 scan2(TOK_EQUAL, TOK_SEMICOLON, &tok);
786 defp->pc.split_flag = 0;
788 if (tok.kind == TOK_EQUAL) {
789 if (opcodesnotallowed[PackageIndex])
790 error("Opcode assignment isn't allowed here!");
792 if (InvalidConstant(tok.str))
793 error("Illegal Opcode assignment (Must be a constant opcode!)");
794 if (opcodenum_is_defined(atoi(tok.str)))
795 error("The opcode number is already used by a previous proc");
796 defp->pc.proc_opcodename = tok.str;
797 defp->pc.proc_opcodenum = atoi(tok.str);
798 if (defp->pc.proc_opcodenum < lowest_opcode[PackageIndex])
799 lowest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
800 if (defp->pc.proc_opcodenum < master_lowest_opcode)
801 master_lowest_opcode = defp->pc.proc_opcodenum;
802 if (defp->pc.proc_opcodenum > highest_opcode[PackageIndex])
803 highest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
804 if (defp->pc.proc_opcodenum > master_highest_opcode)
805 master_highest_opcode = defp->pc.proc_opcodenum;
806 scan(TOK_SEMICOLON, &tok);
808 if (master_opcodenumber == 99999)
809 master_opcodenumber = 0;
810 defp->pc.proc_opcodenum = master_opcodenumber++;
811 if (defp->pc.proc_opcodenum < lowest_opcode[PackageIndex])
812 lowest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
813 if (defp->pc.proc_opcodenum > highest_opcode[PackageIndex])
814 highest_opcode[PackageIndex] = defp->pc.proc_opcodenum;
815 if (defp->pc.proc_opcodenum > master_highest_opcode)
816 master_highest_opcode = defp->pc.proc_opcodenum;
817 opcodesnotallowed[PackageIndex] = 1; /* force it */
819 no_of_opcodes[PackageIndex]++, master_no_of_opcodes++;
821 generate_code(defp, 0, 1);
822 if (Cflag || cflag) {
823 generate_code(defp, 1, 1);
825 generate_multi_macros(defp);
827 generate_code(defp, proc_split, 0);
830 if (function_list_index >= MAX_FUNCTIONS_PER_INTERFACE) {
831 error("too many functions in interface, "
832 "increase MAX_FUNCTIONS_PER_INTERFACE");
834 sprintf(function_list[PackageIndex][function_list_index], "%s%s%s",
835 prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
837 function_list_index++;
838 no_of_stat_funcs_header[PackageIndex]++;
844 #define LEGALNUMS "0123456789"
846 InvalidConstant(char *name)
852 slen = (int)strlen(name);
853 return (slen != strspn(name, map));
857 opcodenum_is_defined(int opcode_num)
862 for (listp = proc_defined[PackageIndex]; listp != NULL;
863 listp = listp->next) {
864 defp = (definition *) listp->val;
865 if (opcode_num == defp->pc.proc_opcodenum)
873 analyze_ProcParams(definition * defp, token * tokp)
876 decl_list *decls, **tailp;
878 Proc_listp = &defp->pc.plists;
879 tailp = &defp->def.st.decls;
882 Proc_list = ALLOC(proc1_list);
883 memset((char *)Proc_list, 0, sizeof(proc1_list));
884 Proc_list->pl.param_flag = 0;
885 switch (tokp->kind) {
887 hdle_param_tok(defp, &dec, tokp, DEF_INPARAM);
890 hdle_param_tok(defp, &dec, tokp, DEF_OUTPARAM);
893 hdle_param_tok(defp, &dec, tokp, DEF_INOUTPARAM);
899 hdle_param_tok(defp, &dec, tokp, DEF_NULL);
902 *Proc_listp = Proc_list;
903 Proc_listp = &Proc_list->next;
904 decls = ALLOC(decl_list);
905 memset((char *)decls, 0, sizeof(decl_list));
906 if (tokp->kind != TOK_RPAREN)
909 tailp = &decls->next;
910 } while (tokp->kind != TOK_RPAREN);
916 generate_code(definition * defp, int proc_split_flag, int multi_flag)
919 handle_split_proc(defp, multi_flag);
921 if (Cflag || cflag) {
922 cs_Proc_CodeGeneration(defp, 0, "");
925 ss_Proc_CodeGeneration(defp);
928 STOREVAL(&proc_defined[PackageIndex], defp);
933 handle_split_proc(definition * defp, int multi_flag)
935 char *startname = SplitStart, *endname = SplitEnd;
942 if (Cflag || cflag) {
944 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 0);
946 cs_Proc_CodeGeneration(defp, 1, startname);
948 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 1);
949 do_split(defp, IN, &numofparams, DEF_INPARAM, 0);
951 cs_Proc_CodeGeneration(defp, (multi_flag ? 3 : 2), endname);
953 do_split(defp, IN, &numofparams, DEF_INPARAM, 1);
957 ss_Proc_CodeGeneration(defp);
962 do_split(definition * defp, int direction, int *numofparams,
963 defkind param_kind, int restore_flag)
968 defp->pc.paramtypes[direction] = *numofparams;
969 for (plist = defp->pc.plists; plist; plist = plist->next) {
970 if (plist->component_kind == DEF_NULL
971 && plist->pl.param_kind == param_kind)
972 plist->component_kind = DEF_PARAM;
975 *numofparams = defp->pc.paramtypes[direction];
976 defp->pc.paramtypes[direction] = 0;
977 for (plist = defp->pc.plists; plist; plist = plist->next) {
978 if (plist->component_kind == DEF_PARAM
979 && plist->pl.param_kind == param_kind)
980 plist->component_kind = DEF_NULL;
987 hdle_param_tok(definition * defp, declaration * dec, token * tokp,
990 static defkind last_param_kind = DEF_NULL;
992 if (par_kind == DEF_NULL)
993 Proc_list->pl.param_kind = last_param_kind;
995 Proc_list->pl.param_kind = par_kind;
996 last_param_kind = Proc_list->pl.param_kind;
997 defp->pc.paramtypes[(int)last_param_kind]++;
998 Proc_list->component_kind = DEF_PARAM;
999 Proc_list->code = alloc(250);
1000 Proc_list->scode = alloc(250);
1001 get_declaration(dec, DEF_PARAM);
1002 Proc_list->pl.param_name = dec->name;
1003 get1_param_type(defp, dec, &Proc_list->pl.param_type);
1005 scan2(TOK_COMMA, TOK_RPAREN, tokp);
1006 if (tokp->kind == TOK_COMMA)
1012 get1_param_type(definition * defp, declaration * dec, char **param_type)
1014 char typecontents[100];
1016 if (streq(dec->type, "string")) {
1017 *param_type = "char *";
1020 strcpy(typecontents, dec->prefix);
1021 strcat(typecontents, " ");
1022 strcat(typecontents, dec->type);
1023 strcat(typecontents, " *");
1024 } else if (dec->rel == REL_POINTER) {
1025 strcpy(typecontents, dec->type);
1026 strcat(typecontents, " *");
1028 strcpy(typecontents, dec->type);
1029 *param_type = alloc(100);
1030 strcpy(*param_type, typecontents);
1036 get_param_type(definition * defp, declaration * dec, char **param_type,
1039 char typecontents[100];
1041 if (streq(dec->type, "string")) {
1042 *typename = "wrapstring";
1043 *param_type = "char *";
1045 *typename = dec->type;
1047 strcpy(typecontents, dec->prefix);
1048 strcat(typecontents, " ");
1049 strcat(typecontents, dec->type);
1050 strcat(typecontents, " *");
1051 dec->rel = REL_POINTER;
1052 } else if (dec->rel == REL_POINTER) {
1053 strcpy(typecontents, dec->type);
1054 strcat(typecontents, " *");
1056 strcpy(typecontents, dec->type);
1057 *param_type = alloc(100);
1058 strcpy(*param_type, typecontents);
1065 hndle_param_tail(definition * defp, declaration * dec, token * tokp,
1070 if (dec->rel == REL_POINTER)
1071 Proc_list->pl.param_flag |= INDIRECT_PARAM;
1073 Proc_list->pl.param_flag &= ~INDIRECT_PARAM;
1075 if (!(Proc_list->pl.param_flag & INDIRECT_PARAM))
1078 sprintf(Proc_list->code, "xdr_%s(&z_xdrs, %s%s)", typename, amp,
1079 Proc_list->pl.param_name);
1080 sprintf(Proc_list->scode, "xdr_%s(z_xdrs, &%s)", typename,
1081 Proc_list->pl.param_name);
1082 scan2(TOK_COMMA, TOK_RPAREN, tokp);
1083 if (tokp->kind == TOK_COMMA)
1090 cs_Proc_CodeGeneration(definition * defp, int split_flag, char *procheader)
1093 cs_ProcName_setup(defp, procheader, split_flag);
1095 cs_ProcParams_setup(defp, split_flag);
1096 cs_ProcMarshallInParams_setup(defp, split_flag);
1097 if (split_flag != 1) {
1098 cs_ProcSendPacket_setup(defp, split_flag);
1099 cs_ProcUnmarshallOutParams_setup(defp);
1101 cs_ProcTail_setup(defp, split_flag);
1104 if (!kflag && !split_flag && uflag) {
1105 ucs_ProcName_setup(defp, "ubik_", split_flag);
1107 ucs_ProcParams_setup(defp, split_flag);
1108 ucs_ProcTail_setup(defp, split_flag);
1114 cs_ProcName_setup(definition * defp, char *procheader, int split_flag)
1121 first_arg = "register struct rx_call *z_call";
1123 first_arg = "register struct rx_connection *z_conn";
1127 first_arg = "z_call";
1129 first_arg = "z_conn";
1134 f_print(fout, "int %s%s%s%s(%s", procheader, prefix,
1135 PackagePrefix[PackageIndex], defp->pc.proc_name, first_arg);
1137 if ((strlen(procheader) + strlen(prefix) +
1138 strlen(PackagePrefix[PackageIndex]) + strlen(defp->pc.proc_name)) >=
1139 MAX_FUNCTION_NAME_LEN) {
1140 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1143 for (plist = defp->pc.plists; plist; plist = plist->next) {
1144 if (plist->component_kind == DEF_PARAM) {
1146 if (plist->pl.param_flag & OUT_STRING) {
1147 f_print(fout, ",%s *%s", plist->pl.param_type,
1148 plist->pl.param_name);
1150 f_print(fout, ",%s %s", plist->pl.param_type,
1151 plist->pl.param_name);
1154 f_print(fout, ", %s", plist->pl.param_name);
1155 plist->pl.param_flag &= ~PROCESSED_PARAM;
1159 f_print(fout, ")\n");
1164 cs_ProcParams_setup(definition * defp, int split_flag)
1166 proc1_list *plist, *plist1;
1172 f_print(fout, "\tregister struct rx_connection *z_conn;\n");
1174 f_print(fout, "\tregister struct rx_call *z_call;\n");
1176 for (plist = defp->pc.plists; plist; plist = plist->next) {
1177 if (plist->component_kind == DEF_PARAM
1178 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1179 if (plist->pl.param_flag & OUT_STRING) {
1180 f_print(fout, "\t%s *%s", plist->pl.param_type,
1181 plist->pl.param_name);
1183 f_print(fout, "\t%s %s", plist->pl.param_type,
1184 plist->pl.param_name);
1186 plist->pl.param_flag |= PROCESSED_PARAM;
1187 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1188 if ((plist1->component_kind == DEF_PARAM)
1189 && streq(plist->pl.param_type, plist1->pl.param_type)
1190 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1192 char *pntr = strchr(plist1->pl.param_type, '*');
1195 if (plist1->pl.param_flag & OUT_STRING) {
1196 f_print(fout, ", *%s%s", star, plist1->pl.param_name);
1198 f_print(fout, ", %s%s", star, plist1->pl.param_name);
1200 plist1->pl.param_flag |= PROCESSED_PARAM;
1203 f_print(fout, ";\n");
1210 cs_ProcMarshallInParams_setup(definition * defp, int split_flag)
1212 int noofparams, i = 0;
1216 defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT] +
1217 defp->pc.paramtypes[OUT];
1219 f_print(fout, "{\n");
1221 f_print(fout, "\tstruct rx_call *z_call = rx_NewCall(z_conn);\n");
1222 if ((!split_flag) || (split_flag == 1)) {
1223 if (opcodesnotallowed[PackageIndex]) {
1224 f_print(fout, "\tstatic int z_op = %d;\n",
1225 defp->pc.proc_opcodenum);
1227 f_print(fout, "\tstatic int z_op = %s;\n",
1228 defp->pc.proc_opcodename);
1231 f_print(fout, "\tint z_result;\n");
1232 if (!(split_flag > 1) || (noofallparams != 0)) {
1233 f_print(fout, "\tXDR z_xdrs;\n");
1236 * Print out client side stat gathering call
1238 if (xflag && split_flag != 1) {
1239 f_print(fout, "\tstruct clock __QUEUE, __EXEC;\n");
1242 if ((!split_flag) || (split_flag == 1)) {
1243 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_ENCODE);\n");
1244 f_print(fout, "\n\t/* Marshal the arguments */\n");
1245 f_print(fout, "\tif ((!xdr_int(&z_xdrs, &z_op))");
1246 noofparams = defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT];
1247 for (plist = defp->pc.plists, dl = defp->def.st.decls; plist;
1248 plist = plist->next, dl = dl->next) {
1249 if (plist->component_kind == DEF_PARAM
1250 && (plist->pl.param_kind == DEF_INPARAM
1251 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1252 f_print(fout, "\n\t || (!%s)", plist->code);
1253 if (++i == noofparams) {
1255 ") {\n\t\tz_result = RXGEN_CC_MARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1262 ") {\n\t\tz_result = RXGEN_CC_MARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1270 cs_ProcSendPacket_setup(definition * defp, int split_flag)
1272 int noofoutparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1274 if (noofoutparams) {
1275 f_print(fout, "\t/* Un-marshal the reply arguments */\n");
1277 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
1279 f_print(fout, "\tz_xdrs.x_op = XDR_DECODE;\n");
1286 cs_ProcUnmarshallOutParams_setup(definition * defp)
1292 noofparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1294 for (plist = defp->pc.plists, dl = defp->def.st.decls, i = 0; plist;
1295 plist = plist->next, dl = dl->next) {
1296 if (plist->component_kind == DEF_PARAM
1297 && (plist->pl.param_kind == DEF_OUTPARAM
1298 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1300 f_print(fout, "\tif ((!%s)", plist->code);
1302 f_print(fout, "\n\t || (!%s)", plist->code);
1304 if (++i == noofparams) {
1306 ") {\n\t\tz_result = RXGEN_CC_UNMARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1315 cs_ProcTail_setup(definition * defp, int split_flag)
1317 f_print(fout, "\tz_result = RXGEN_SUCCESS;\n");
1318 if (defp->can_fail) {
1319 f_print(fout, "fail:\n");
1322 f_print(fout, "\tz_result = rx_EndCall(z_call, z_result);\n");
1324 if (xflag && split_flag != 1) {
1325 f_print(fout, "\tif (rx_enable_stats) {\n");
1326 f_print(fout, "\t clock_GetTime(&__EXEC);\n");
1327 f_print(fout, "\t clock_Sub(&__EXEC, &z_call->startTime);\n");
1328 f_print(fout, "\t __QUEUE = z_call->startTime;\n");
1329 f_print(fout, "\t clock_Sub(&__QUEUE, &z_call->queueTime);\n");
1330 if (PackageStatIndex[PackageIndex]) {
1333 "\t rx_IncrementTimeAndCount(z_conn->peer, %s,\n",
1334 PackageStatIndex[PackageIndex]);
1337 "\t rx_IncrementTimeAndCount(z_call->conn->peer, %s,\n",
1338 PackageStatIndex[PackageIndex]);
1343 "\t rx_IncrementTimeAndCount(z_conn->peer,\n"
1344 "\t\t(((afs_uint32)(ntohs(z_conn->serviceId) << 16)) \n"
1345 "\t\t| ((afs_uint32)ntohs(z_conn->peer->port))),\n");
1348 "\t rx_IncrementTimeAndCount(z_call->conn->peer,\n"
1349 "\t\t(((afs_uint32)(ntohs(z_call->conn->serviceId) << 16)) |\n"
1350 "\t\t((afs_uint32)ntohs(z_call->conn->peer->port))),\n");
1354 f_print(fout, "\t\t%d, %sNO_OF_STAT_FUNCS, &__QUEUE, &__EXEC,\n",
1355 no_of_stat_funcs, PackagePrefix[PackageIndex]);
1357 "\t\t&z_call->bytesSent, &z_call->bytesRcvd, 1);\n");
1359 f_print(fout, "\t}\n\n");
1361 f_print(fout, "\treturn z_result;\n}\n\n");
1366 ss_Proc_CodeGeneration(definition * defp)
1371 ss_ProcName_setup(defp);
1373 ss_ProcParams_setup(defp, &somefrees);
1374 ss_ProcSpecial_setup(defp, &somefrees);
1375 ss_ProcUnmarshallInParams_setup(defp);
1376 ss_ProcCallRealProc_setup(defp);
1377 ss_ProcMarshallOutParams_setup(defp);
1378 ss_ProcTail_setup(defp, somefrees);
1384 ss_ProcName_setup(definition * defp)
1388 if ((strlen(prefix) + strlen(PackagePrefix[PackageIndex]) +
1389 strlen(defp->pc.proc_name)) >= MAX_FUNCTION_NAME_LEN) {
1390 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1394 f_print(fout, "static afs_int32 _%s%s%s(", prefix,
1395 PackagePrefix[PackageIndex], defp->pc.proc_name);
1396 f_print(fout, "struct rx_call *z_call, XDR *z_xdrs)\n{\n");
1397 f_print(fout, "\t" "afs_int32 z_result;\n");
1399 f_print(fout, "\tstruct clock __QUEUE, __EXEC;\n");
1402 for (plist = defp->pc.plists; plist; plist = plist->next)
1403 if (plist->component_kind == DEF_PARAM) {
1404 plist->pl.param_flag &= ~(PROCESSED_PARAM);
1405 plist->pl.string_name = NULL;
1412 ss_ProcParams_setup(definition * defp, int *somefrees)
1414 proc1_list *plist, *plist1;
1418 for (plist = defp->pc.plists; plist; plist = plist->next) {
1419 if ((plist->component_kind == DEF_PARAM)
1420 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1421 if (plist->pl.param_flag & INDIRECT_PARAM) {
1422 char pres = '\0', *pntr = strchr(plist->pl.param_type, '*');
1428 f_print(fout, "\t%s %s", plist->pl.param_type,
1429 plist->pl.param_name);
1431 } else if (strchr(plist->pl.param_type, '*') == 0) {
1432 f_print(fout, "\t%s %s", plist->pl.param_type,
1433 plist->pl.param_name);
1435 plist->pl.param_flag |= FREETHIS_PARAM;
1437 f_print(fout, "\t%s %s=(%s)0", plist->pl.param_type,
1438 plist->pl.param_name, plist->pl.param_type);
1440 plist->pl.param_flag |= PROCESSED_PARAM;
1441 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1442 if ((plist1->component_kind == DEF_PARAM)
1443 && streq(plist->pl.param_type, plist1->pl.param_type)
1444 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1445 if (plist1->pl.param_flag & INDIRECT_PARAM) {
1446 f_print(fout, ", %s", plist1->pl.param_name);
1447 } else if (strchr(plist1->pl.param_type, '*') == 0) {
1448 f_print(fout, ", %s", plist1->pl.param_name);
1450 plist1->pl.param_flag |= FREETHIS_PARAM;
1452 f_print(fout, ", *%s=(%s)0", plist1->pl.param_name,
1453 plist1->pl.param_type);
1455 plist1->pl.param_flag |= PROCESSED_PARAM;
1458 f_print(fout, ";\n");
1461 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1462 defp1 = (definition *) listp->val;
1463 for (plist = defp->pc.plists; plist; plist = plist->next) {
1464 if (plist->component_kind == DEF_PARAM
1465 && (plist->pl.param_kind == DEF_OUTPARAM
1466 || plist->pl.param_kind == DEF_INOUTPARAM)
1467 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1468 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1469 switch (defp1->pc.rel) {
1478 fprintf(fout, "\n");
1483 ss_ProcSpecial_setup(definition * defp, int *somefrees)
1489 for (listp = special_defined; listp != NULL; listp = listp->next) {
1490 defp1 = (definition *) listp->val;
1491 for (plist = defp->pc.plists; plist; plist = plist->next) {
1492 if (plist->component_kind == DEF_PARAM
1493 && (plist->pl.param_kind == DEF_INPARAM
1494 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1495 spec_list *spec = defp1->def.sd.specs;
1497 strcpy(string, structname(spec->sdef.string_value));
1498 if (streq(string, structname(plist->pl.param_type))) {
1499 plist->pl.string_name = spec->sdef.string_name;
1500 plist->pl.param_flag |= FREETHIS_PARAM;
1502 fprintf(fout, "\n\t%s.%s = 0;", plist->pl.param_name,
1503 spec->sdef.string_name);
1509 fprintf(fout, "\n");
1510 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1511 defp1 = (definition *) listp->val;
1512 for (plist = defp->pc.plists; plist; plist = plist->next) {
1513 if (plist->component_kind == DEF_PARAM) {
1514 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1515 plist->pl.param_flag |= FREETHIS_PARAM;
1517 switch (defp1->pc.rel) {
1519 f_print(fout, "\n\t%s.%s_val = 0;",
1520 plist->pl.param_name, defp1->def_name);
1521 f_print(fout, "\n\t%s.%s_len = 0;",
1522 plist->pl.param_name, defp1->def_name);
1523 plist->pl.string_name = alloc(40);
1524 s_print(plist->pl.string_name, "%s_val",
1528 f_print(fout, "\n\t%s = 0;", plist->pl.param_name);
1529 plist->pl.string_name = NULL;
1536 f_print(fout, "\n");
1541 ss_ProcUnmarshallInParams_setup(definition * defp)
1543 int noofparams, noofoutparams, i;
1546 noofparams = defp->pc.paramtypes[IN] + defp->pc.paramtypes[INOUT];
1547 noofoutparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1548 for (plist = defp->pc.plists, i = 0; plist; plist = plist->next) {
1549 if (plist->component_kind == DEF_PARAM
1550 && (plist->pl.param_kind == DEF_INPARAM
1551 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1553 f_print(fout, "\n\tif ((!%s)",
1554 (plist->scode ? plist->scode : plist->code));
1556 f_print(fout, "\n\t || (!%s)",
1557 (plist->scode ? plist->scode : plist->code));
1559 if (++i == noofparams) {
1560 if (!noofoutparams) {
1561 f_print(fout, ") {\n");
1563 f_print(fout, ") {\n");
1566 "\t\tz_result = RXGEN_SS_UNMARSHAL;\n\t\tgoto fail;\n\t}\n\n");
1575 ss_ProcCallRealProc_setup(definition * defp)
1580 f_print(fout, "\tz_result = %s%s%s%s(z_call", prefix, ServerPrefix,
1581 PackagePrefix[PackageIndex], defp->pc.proc_name);
1582 for (plist = defp->pc.plists; plist; plist = plist->next) {
1583 if (plist->component_kind == DEF_PARAM) {
1584 if (plist->pl.param_flag & INDIRECT_PARAM) {
1585 f_print(fout, ", &%s", plist->pl.param_name);
1587 if (plist->pl.param_flag & OUT_STRING) {
1588 f_print(fout, ", &%s", plist->pl.param_name);
1590 f_print(fout, ", %s", plist->pl.param_name);
1595 f_print(fout, ");\n");
1597 f_print(fout, "\tif (z_result)\n\t\treturn z_result;\n");
1603 ss_ProcMarshallOutParams_setup(definition * defp)
1608 noofparams = defp->pc.paramtypes[INOUT] + defp->pc.paramtypes[OUT];
1610 f_print(fout, "\tz_xdrs->x_op = XDR_ENCODE;\n");
1612 for (plist = defp->pc.plists, i = 0; plist; plist = plist->next) {
1613 if (plist->component_kind == DEF_PARAM
1614 && (plist->pl.param_kind == DEF_OUTPARAM
1615 || plist->pl.param_kind == DEF_INOUTPARAM)) {
1617 f_print(fout, "\tif ((!%s)",
1618 (plist->scode ? plist->scode : plist->code));
1620 f_print(fout, "\n\t || (!%s)",
1621 (plist->scode ? plist->scode : plist->code));
1623 if (++i == noofparams) {
1624 f_print(fout, ")\n\t\tz_result = RXGEN_SS_MARSHAL;\n");
1633 ss_ProcTail_setup(definition * defp, int somefrees)
1640 if (defp->can_fail) {
1641 f_print(fout, "fail:\n");
1643 for (plist = defp->pc.plists; plist; plist = plist->next) {
1644 if (plist->component_kind == DEF_PARAM
1645 && (plist->pl.param_flag & FREETHIS_PARAM))
1649 f_print(fout, "\tz_xdrs->x_op = XDR_FREE;\n");
1650 for (plist = defp->pc.plists; plist; plist = plist->next) {
1651 if (plist->component_kind == DEF_PARAM
1652 && (plist->pl.param_flag & FREETHIS_PARAM)) {
1653 char *dot = "", *extens = "";
1654 if (plist->pl.string_name) {
1656 extens = plist->pl.string_name;
1658 f_print(fout, "\tif (!%s) goto fail1;\n", plist->scode);
1661 for (listp = typedef_defined; listp != NULL; listp = listp->next) {
1662 defp1 = (definition *) listp->val;
1663 for (plist = defp->pc.plists; plist; plist = plist->next) {
1664 if (plist->component_kind == DEF_PARAM
1665 && (plist->pl.param_kind == DEF_OUTPARAM
1666 || plist->pl.param_kind == DEF_INOUTPARAM)
1667 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1668 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1669 switch (defp1->pc.rel) {
1672 if (!somefrees && !firsttime) {
1674 f_print(fout, "\tz_xdrs->x_op = XDR_FREE;\n");
1677 f_print(fout, "\tif (!%s) goto fail1;\n",
1685 for (listp = uniondef_defined; listp != NULL; listp = listp->next) {
1686 defp1 = (definition *) listp->val;
1687 for (plist = defp->pc.plists; plist; plist = plist->next) {
1688 if (plist->component_kind == DEF_PARAM
1689 && (plist->pl.param_kind == DEF_OUTPARAM
1690 || plist->pl.param_kind == DEF_INOUTPARAM)
1691 && !(plist->pl.param_flag & FREETHIS_PARAM)) {
1692 if (streq(defp1->def_name, structname(plist->pl.param_type))) {
1693 if (plist->pl.param_flag & INDIRECT_PARAM) {
1694 if (!somefrees && !firsttime) {
1696 f_print(fout, "\tz_xdrs->x_op = XDR_FREE;\n");
1699 f_print(fout, "\tif (!%s) goto fail1;\n",
1708 f_print(fout, "\tif (rx_enable_stats) {\n");
1709 f_print(fout, "\t clock_GetTime(&__EXEC);\n");
1710 f_print(fout, "\t clock_Sub(&__EXEC, &z_call->startTime);\n");
1711 f_print(fout, "\t __QUEUE = z_call->startTime;\n");
1712 f_print(fout, "\t clock_Sub(&__QUEUE, &z_call->queueTime);\n");
1713 f_print(fout, "\t rx_IncrementTimeAndCount(z_call->conn->peer,");
1714 if (PackageStatIndex[PackageIndex]) {
1715 f_print(fout, " %s,\n", PackageStatIndex[PackageIndex]);
1718 "\n\t\t(((afs_uint32)(ntohs(z_call->conn->serviceId) << 16)) |\n"
1719 "\t\t((afs_uint32)ntohs(z_call->conn->service->servicePort))),\n");
1721 f_print(fout, "\t\t%d, %sNO_OF_STAT_FUNCS, &__QUEUE, &__EXEC,\n",
1722 no_of_stat_funcs, PackagePrefix[PackageIndex]);
1723 f_print(fout, "\t\t&z_call->bytesSent, &z_call->bytesRcvd, 0);\n");
1724 f_print(fout, "\t}\n\n");
1727 f_print(fout, "\treturn z_result;\n");
1729 f_print(fout, "fail1:\n");
1732 f_print(fout, "\tif (rx_enable_stats) {\n");
1733 f_print(fout, "\t clock_GetTime(&__EXEC);\n");
1734 f_print(fout, "\t clock_Sub(&__EXEC, &z_call->startTime);\n");
1735 f_print(fout, "\t __QUEUE = z_call->startTime;\n");
1736 f_print(fout, "\t clock_Sub(&__QUEUE, &z_call->queueTime);\n");
1738 "\t rx_IncrementTimeAndCount(z_call->conn->peer,");
1739 if (PackageStatIndex[PackageIndex]) {
1740 f_print(fout, " %s,\n", PackageStatIndex[PackageIndex]);
1743 "\n\t\t(((afs_uint32)(ntohs(z_call->conn->serviceId) << 16)) |\n"
1744 "\t\t((afs_uint32)ntohs(z_call->conn->service->servicePort))),\n");
1746 f_print(fout, "\t\t%d, %sNO_OF_STAT_FUNCS, &__QUEUE, &__EXEC,\n",
1747 no_of_stat_funcs, PackagePrefix[PackageIndex]);
1749 "\t\t&z_call->bytesSent, &z_call->bytesRcvd, 0);\n");
1750 f_print(fout, "\t}\n\n");
1753 f_print(fout, "\treturn RXGEN_SS_XDRFREE;\n}\n\n");
1755 f_print(fout, "}\n\n");
1761 ucs_ProcName_setup(definition * defp, char *procheader, int split_flag)
1767 f_print(fout, "int %s%s%s%s(register struct ubik_client *aclient, afs_int32 aflags",
1768 procheader, prefix, PackagePrefix[PackageIndex],
1769 defp->pc.proc_name);
1771 f_print(fout, "int %s%s%s%s(aclient, aflags", procheader, prefix,
1772 PackagePrefix[PackageIndex], defp->pc.proc_name);
1775 if ((strlen(procheader) + strlen(prefix) +
1776 strlen(PackagePrefix[PackageIndex]) + strlen(defp->pc.proc_name)) >=
1777 MAX_FUNCTION_NAME_LEN) {
1778 error("function name is too long, increase MAX_FUNCTION_NAME_LEN");
1781 for (plist = defp->pc.plists; plist; plist = plist->next) {
1782 if (plist->component_kind == DEF_PARAM) {
1784 if (plist->pl.param_flag & OUT_STRING) {
1785 f_print(fout, ",%s *%s", plist->pl.param_type,
1786 plist->pl.param_name);
1788 f_print(fout, ",%s %s", plist->pl.param_type,
1789 plist->pl.param_name);
1792 plist->pl.param_flag &= ~PROCESSED_PARAM;
1793 f_print(fout, ", %s", plist->pl.param_name);
1797 f_print(fout, ")\n");
1803 ucs_ProcParams_setup(definition * defp, int split_flag)
1805 proc1_list *plist, *plist1;
1810 f_print(fout, "\tregister struct ubik_client *aclient;\n\tafs_int32 aflags;\n");
1811 for (plist = defp->pc.plists; plist; plist = plist->next) {
1812 if (plist->component_kind == DEF_PARAM
1813 && !(plist->pl.param_flag & PROCESSED_PARAM)) {
1814 if (plist->pl.param_flag & OUT_STRING) {
1815 f_print(fout, "\t%s *%s", plist->pl.param_type,
1816 plist->pl.param_name);
1818 f_print(fout, "\t%s %s", plist->pl.param_type,
1819 plist->pl.param_name);
1821 plist->pl.param_flag |= PROCESSED_PARAM;
1822 for (plist1 = defp->pc.plists; plist1; plist1 = plist1->next) {
1823 if ((plist1->component_kind == DEF_PARAM)
1824 && streq(plist->pl.param_type, plist1->pl.param_type)
1825 && !(plist1->pl.param_flag & PROCESSED_PARAM)) {
1827 char *pntr = strchr(plist1->pl.param_type, '*');
1830 if (plist1->pl.param_flag & OUT_STRING) {
1831 f_print(fout, ", *%s%s", star, plist1->pl.param_name);
1833 f_print(fout, ", %s%s", star, plist1->pl.param_name);
1835 plist1->pl.param_flag |= PROCESSED_PARAM;
1838 f_print(fout, ";\n");
1844 ucs_ProcTail_setup(definition * defp, int split_flag)
1848 f_print(fout, "{\tafs_int32 rcode, code, newHost, thisHost, i, _ucount;\n");
1849 f_print(fout, "\tint chaseCount, pass, needsync, inlist;\n");
1850 #if 0 /* goes with block below */
1851 f_print(fout, "\tint j;\n");
1853 f_print(fout, "\tstruct rx_connection *tc;\n");
1854 f_print(fout, "\tstruct rx_peer *rxp;\n");
1855 f_print(fout, "\tshort origLevel;\n\n");
1856 f_print(fout, "\tif (!aclient)\n");
1857 f_print(fout, "\t\treturn UNOENT;\n");
1858 f_print(fout, "\tLOCK_UBIK_CLIENT(aclient);\n\n");
1859 f_print(fout, "\t restart:\n");
1860 f_print(fout, "\torigLevel = aclient->initializationState;\n");
1861 f_print(fout, "\trcode = UNOSERVERS;\n");
1862 f_print(fout, "\tchaseCount = inlist = needsync = 0;\n\n");
1863 #if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
1864 f_print(fout, "\tLOCK_UCLNT_CACHE;\n");
1865 f_print(fout, "\tfor (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {\n");
1866 f_print(fout, "\t\tif (calls_needsync[j] == (int *)%s%s%s) {\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1867 f_print(fout, "\t\t\tinlist = needsync = 1;\n");
1868 f_print(fout, "\t\t\tbreak;\n");
1869 f_print(fout, "\t\t}\n");
1870 f_print(fout, "\t}\n");
1871 f_print(fout, "\tUNLOCK_UCLNT_CACHE;\n");
1873 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");
1874 f_print(fout, "\tfor (pass = 0; pass < 2; pass++) { /*p */\n");
1875 f_print(fout, "\t\t/* For each entry in our servers list */\n");
1876 f_print(fout, "\t\tfor (_ucount = 0;; _ucount++) { /*s */\n\n");
1877 f_print(fout, "\t\tif (needsync) {\n");
1878 f_print(fout, "\t\t\t/* Need a sync site. Lets try to quickly find it */\n");
1879 f_print(fout, "\t\t\tif (aclient->syncSite) {\n");
1880 f_print(fout, "\t\t\t\tnewHost = aclient->syncSite; /* already in network order */\n");
1881 f_print(fout, "\t\t\t\taclient->syncSite = 0; /* Will reset if it works */\n");
1882 f_print(fout, "\t\t\t} else if (aclient->conns[3]) {\n");
1883 f_print(fout, "\t\t\t\t/* If there are fewer than four db servers in a cell,\n");
1884 f_print(fout, "\t\t\t\t* there's no point in making the GetSyncSite call.\n");
1885 f_print(fout, "\t\t\t\t* At best, it's a wash. At worst, it results in more\n");
1886 f_print(fout, "\t\t\t\t* RPCs than you would otherwise make.\n");
1887 f_print(fout, "\t\t\t\t*/\n");
1888 f_print(fout, "\t\t\t\ttc = aclient->conns[_ucount];\n");
1889 f_print(fout, "\t\t\t\tif (tc && rx_ConnError(tc)) {\n");
1890 f_print(fout, "\t\t\t\t\taclient->conns[_ucount] = tc = ubik_RefreshConn(tc);\n");
1891 f_print(fout, "\t\t\t\t}\n");
1892 f_print(fout, "\t\t\t\tif (!tc)\n");
1893 f_print(fout, "\t\t\t\t\tbreak;\n");
1894 f_print(fout, "\t\t\t\tcode = VOTE_GetSyncSite(tc, &newHost);\n");
1895 f_print(fout, "\t\t\t\tif (aclient->initializationState != origLevel)\n");
1896 f_print(fout, "\t\t\t\t\tgoto restart; /* somebody did a ubik_ClientInit */\n");
1897 f_print(fout, "\t\t\t\tif (code)\n");
1898 f_print(fout, "\t\t\t\t\tnewHost = 0;\n");
1899 f_print(fout, "\t\t\t\tnewHost = htonl(newHost); /* convert to network order */\n");
1900 f_print(fout, "\t\t\t} else {\n");
1901 f_print(fout, "\t\t\t\tnewHost = 0;\n");
1902 f_print(fout, "\t\t\t}\n");
1903 f_print(fout, "\t\t\tif (newHost) {\n");
1904 f_print(fout, "\t\t\t\t/* position count at the appropriate slot in the client\n");
1905 f_print(fout, "\t\t\t\t* structure and retry. If we can't find in slot, we'll\n");
1906 f_print(fout, "\t\t\t\t* just continue through the whole list \n");
1907 f_print(fout, "\t\t\t\t*/\n");
1908 f_print(fout, "\t\t\t\tfor (i = 0; i < MAXSERVERS && aclient->conns[i]; i++) {\n");
1909 f_print(fout, "\t\t\t\t\trxp = rx_PeerOf(aclient->conns[i]);\n");
1910 f_print(fout, "\t\t\t\t\tthisHost = rx_HostOf(rxp);\n");
1911 f_print(fout, "\t\t\t\t\tif (!thisHost)\n");
1912 f_print(fout, "\t\t\t\t\t\tbreak;\n");
1913 f_print(fout, "\t\t\t\t\tif (thisHost == newHost) {\n");
1914 f_print(fout, "\t\t\t\t\t\tif (chaseCount++ > 2)\n");
1915 f_print(fout, "\t\t\t\t\t\t\tbreak; /* avoid loop asking */\n");
1916 f_print(fout, "\t\t\t\t\t\t_ucount = i; /* this index is the sync site */\n");
1917 f_print(fout, "\t\t\t\t\t\tbreak;\n");
1918 f_print(fout, "\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n");
1919 f_print(fout, "\t\t/*needsync */\n");
1920 f_print(fout, "\t\ttc = aclient->conns[_ucount];\n");
1921 f_print(fout, "\t\tif (tc && rx_ConnError(tc)) {\n");
1922 f_print(fout, "\t\t\taclient->conns[_ucount] = tc = ubik_RefreshConn(tc);\n");
1923 f_print(fout, "\t\t}\n");
1924 f_print(fout, "\t\tif (!tc)\n");
1925 f_print(fout, "\t\t\tbreak;\n\n");
1926 f_print(fout, "\t\tif ((pass == 0) && (aclient->states[_ucount] & CFLastFailed)) {\n");
1927 f_print(fout, "\t\t\tcontinue; /* this guy's down */\n");
1928 f_print(fout, "\t\t}\n");
1930 f_print(fout, "\t\trcode = %s%s%s(tc\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1931 for (plist = defp->pc.plists; plist; plist = plist->next) {
1932 if (plist->component_kind == DEF_PARAM) {
1933 plist->pl.param_flag &= ~PROCESSED_PARAM;
1934 f_print(fout, ", %s", plist->pl.param_name);
1937 f_print(fout, ");\n");
1938 f_print(fout, "\t\tif (aclient->initializationState != origLevel) {\n");
1939 f_print(fout, "\t\t\t/* somebody did a ubik_ClientInit */\n");
1940 f_print(fout, "\t\t\tif (rcode)\n");
1941 f_print(fout, "\t\t\t\tgoto restart; /* call failed */\n");
1942 f_print(fout, "\t\t\telse\n");
1943 f_print(fout, "\t\t\t\tgoto done; /* call suceeded */\n");
1944 f_print(fout, "\t\t}\n");
1945 f_print(fout, "\t\tif (rcode < 0) { /* network errors */\n");
1946 f_print(fout, "\t\t\taclient->states[_ucount] |= CFLastFailed; /* Mark server down */\n");
1947 f_print(fout, "\t\t} else if (rcode == UNOTSYNC) {\n");
1948 f_print(fout, "\t\t\tneedsync = 1;\n");
1949 f_print(fout, "\t\t} else if (rcode != UNOQUORUM) {\n");
1950 f_print(fout, "\t\t\t/* either misc ubik code, or misc appl code, or success. */\n");
1951 f_print(fout, "\t\t\taclient->states[_ucount] &= ~CFLastFailed; /* mark server up*/\n");
1952 f_print(fout, "\t\t\tgoto done; /* all done */\n");
1953 f_print(fout, "\t\t}\n");
1954 f_print(fout, "\t\t} /*s */\n");
1955 f_print(fout, "\t} /*p */\n\n");
1956 f_print(fout, "\tdone:\n");
1957 f_print(fout, "\tif (needsync) {\n");
1958 f_print(fout, "\t\tif (!inlist) { /* Remember proc call that needs sync site */\n");
1959 #if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
1960 f_print(fout, "\t\t\tLOCK_UCLNT_CACHE;\n");
1961 f_print(fout, "\t\t\tcalls_needsync[synccount % SYNCCOUNT] = (int *)%s%s%s;\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
1962 f_print(fout, "\t\t\tsynccount++;\n");
1963 f_print(fout, "\t\t\tUNLOCK_UCLNT_CACHE;\n");
1965 f_print(fout, "\t\t\tinlist = 1;\n");
1966 f_print(fout, "\t\t}\n");
1967 f_print(fout, "\t\tif (!rcode) { /* Remember the sync site - cmd successful */\n");
1968 f_print(fout, "\t\t\trxp = rx_PeerOf(aclient->conns[_ucount]);\n");
1969 f_print(fout, "\t\t\taclient->syncSite = rx_HostOf(rxp);\n");
1970 f_print(fout, "\t\t}\n");
1971 f_print(fout, "\t}\n");
1972 f_print(fout, "\tUNLOCK_UBIK_CLIENT(aclient);\n");
1973 f_print(fout, "\treturn rcode;\n}\n\n");
1978 opcode_holes_exist(void)
1982 for (i = lowest_opcode[PackageIndex]; i < highest_opcode[PackageIndex];
1984 if (!opcodenum_is_defined(i))
1992 er_Proc_CodeGeneration(void)
1996 temp = PackageIndex;
1997 if (!combinepackages)
1999 for (; PackageIndex <= temp; PackageIndex++) {
2000 if (proc_defined[PackageIndex] == NULL)
2002 if (combinepackages || opcode_holes_exist()) {
2003 er_HeadofOldStyleProc_setup();
2004 er_BodyofOldStyleProc_setup();
2005 er_TailofOldStyleProc_setup();
2007 er_ProcDeclExterns_setup();
2008 er_ProcProcsArray_setup();
2009 er_ProcMainBody_setup();
2012 PackageIndex = temp;
2017 er_ProcDeclExterns_setup(void)
2022 f_print(fout, "\n");
2023 for (listp = proc_defined[PackageIndex]; listp != NULL;
2024 listp = listp->next) {
2025 defp = (definition *) listp->val;
2026 if (defp->pc.proc_serverstub) {
2027 f_print(fout, "afs_int32 %s();\n", defp->pc.proc_serverstub);
2034 er_ProcProcsArray_setup(void)
2039 if ((listp = proc_defined[PackageIndex])) {
2040 defp = (definition *) listp->val;
2041 if (defp->pc.proc_serverstub) {
2042 f_print(fout, "\nstatic afs_int32 (*StubProcsArray%d[])() = {%s",
2043 PackageIndex, defp->pc.proc_serverstub);
2046 "\nstatic afs_int32 (*StubProcsArray%d[])(struct rx_call *z_call, XDR *z_xdrs) = {_%s%s%s",
2047 PackageIndex, prefix, defp->pc.proc_prefix,
2048 ((definition *) listp->val)->pc.proc_name);
2049 defp = (definition *) listp->val;
2051 listp = listp->next;
2053 for (; listp != NULL; listp = listp->next) {
2054 defp = (definition *) listp->val;
2055 if (defp->pc.proc_serverstub) {
2056 f_print(fout, ",%s", defp->pc.proc_serverstub);
2058 f_print(fout, ", _%s%s%s", prefix, defp->pc.proc_prefix,
2059 defp->pc.proc_name);
2062 f_print(fout, "};\n\n");
2067 er_ProcMainBody_setup(void)
2069 f_print(fout, "int %s%sExecuteRequest(register struct rx_call *z_call)\n",
2070 prefix, PackagePrefix[PackageIndex]);
2071 f_print(fout, "{\n\tint op;\n");
2072 f_print(fout, "\tXDR z_xdrs;\n");
2073 f_print(fout, "\t" "afs_int32 z_result;\n\n");
2074 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
2076 "\tif (!xdr_int(&z_xdrs, &op))\n\t\tz_result = RXGEN_DECODE;\n");
2078 "\telse if (op < %sLOWEST_OPCODE || op > %sHIGHEST_OPCODE)\n\t\tz_result = RXGEN_OPCODE;\n",
2079 PackagePrefix[PackageIndex], PackagePrefix[PackageIndex]);
2081 "\telse\n\t\tz_result = (*StubProcsArray%d[op - %sLOWEST_OPCODE])(z_call, &z_xdrs);\n",
2082 PackageIndex, PackagePrefix[PackageIndex]);
2083 f_print(fout, "\treturn hton_syserr_conv(z_result);\n}\n");
2088 er_HeadofOldStyleProc_setup(void)
2091 "\nint %s%sExecuteRequest (register struct rx_call *z_call)\n",
2093 (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
2094 f_print(fout, "{\n");
2095 f_print(fout, "\tint op;\n");
2096 f_print(fout, "\tXDR z_xdrs;\n");
2097 f_print(fout, "\t" "afs_int32 z_result;\n\n");
2098 f_print(fout, "\txdrrx_create(&z_xdrs, z_call, XDR_DECODE);\n");
2099 f_print(fout, "\tz_result = RXGEN_DECODE;\n");
2100 f_print(fout, "\tif (!xdr_int(&z_xdrs, &op)) goto fail;\n");
2101 f_print(fout, "\tswitch (op) {\n");
2105 er_BodyofOldStyleProc_setup(void)
2109 if (combinepackages) {
2110 int temp = PackageIndex;
2111 for (PackageIndex = 0; PackageIndex <= temp; PackageIndex++) {
2112 for (listp = proc_defined[PackageIndex]; listp != NULL;
2113 listp = listp->next)
2114 proc_er_case((definition *) listp->val);
2116 PackageIndex = temp;
2118 for (listp = proc_defined[PackageIndex]; listp != NULL;
2119 listp = listp->next)
2120 proc_er_case((definition *) listp->val);
2126 proc_er_case(definition * defp)
2128 if (opcodesnotallowed[PackageIndex]) {
2129 f_print(fout, "\t\tcase %d:\n", defp->pc.proc_opcodenum);
2131 f_print(fout, "\t\tcase %s:\n", defp->pc.proc_opcodename);
2133 if (defp->pc.proc_serverstub) {
2134 f_print(fout, "\t\t\tz_result = %s(z_call, &z_xdrs);\n",
2135 defp->pc.proc_serverstub);
2137 f_print(fout, "\t\t\tz_result = _%s%s%s(z_call, &z_xdrs);\n", prefix,
2138 defp->pc.proc_prefix, defp->pc.proc_name);
2140 f_print(fout, "\t\t\tbreak;\n");
2145 er_TailofOldStyleProc_setup(void)
2147 f_print(fout, "\t\tdefault:\n");
2148 f_print(fout, "\t\t\tz_result = RXGEN_OPCODE;\n");
2149 f_print(fout, "\t\t\tbreak;\n\t}\n");
2150 f_print(fout, "fail:\n");
2151 f_print(fout, "\treturn z_result;\n}\n");
2156 h_opcode_stats(void)
2158 if (combinepackages) {
2160 "\n/* Opcode-related useful stats for Master package: %s */\n",
2162 f_print(fout, "#define %sLOWEST_OPCODE %d\n", MasterPrefix,
2163 master_lowest_opcode);
2164 f_print(fout, "#define %sHIGHEST_OPCODE %d\n", MasterPrefix,
2165 master_highest_opcode);
2166 f_print(fout, "#define %sNUMBER_OPCODES %d\n\n", MasterPrefix,
2167 master_no_of_opcodes);
2169 f_print(fout, "#define %sNO_OF_STAT_FUNCS\t%d\n\n", MasterPrefix,
2170 no_of_stat_funcs_header[0]);
2171 f_print(fout, "AFS_RXGEN_EXPORT\n");
2172 f_print(fout, "extern const char *%sfunction_names[];\n\n",
2177 for (i = 0; i <= PackageIndex; i++) {
2179 "\n/* Opcode-related useful stats for package: %s */\n",
2181 f_print(fout, "#define %sLOWEST_OPCODE %d\n", PackagePrefix[i],
2183 f_print(fout, "#define %sHIGHEST_OPCODE %d\n",
2184 PackagePrefix[i], highest_opcode[i]);
2185 f_print(fout, "#define %sNUMBER_OPCODES %d\n\n",
2186 PackagePrefix[i], no_of_opcodes[i]);
2188 f_print(fout, "#define %sNO_OF_STAT_FUNCS\t%d\n\n",
2189 PackagePrefix[i], no_of_stat_funcs_header[i]);
2190 f_print(fout, "AFS_RXGEN_EXPORT\n");
2191 f_print(fout, "extern const char *%sfunction_names[];\n\n",
2200 generate_multi_macros(definition * defp)
2202 char *startname = SplitStart, *endname = SplitEnd;
2211 f_print(fout, "\n#include <rx/rx_multi.h>");
2213 f_print(fout, "\n#define multi_%s%s(", PackagePrefix[PackageIndex],
2214 defp->pc.proc_name);
2215 for (plist = defp->pc.plists; plist; plist = plist->next) {
2216 if (plist->component_kind == DEF_PARAM) {
2219 f_print(fout, "%s", plist->pl.param_name);
2221 f_print(fout, ", %s", plist->pl.param_name);
2225 f_print(fout, ") \\\n");
2227 startname = "Start";
2230 f_print(fout, "\tmulti_Body(%s%s%s(multi_call", startname,
2231 PackagePrefix[PackageIndex], defp->pc.proc_name);
2232 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 0);
2233 for (plist = defp->pc.plists; plist; plist = plist->next) {
2234 if (plist->component_kind == DEF_PARAM)
2235 f_print(fout, ", %s", plist->pl.param_name);
2237 do_split(defp, OUT, &numofparams, DEF_OUTPARAM, 1);
2238 f_print(fout, "), %s%s%s(multi_call", endname,
2239 PackagePrefix[PackageIndex], defp->pc.proc_name);
2240 do_split(defp, IN, &numofparams, DEF_INPARAM, 0);
2241 for (plist = defp->pc.plists; plist; plist = plist->next) {
2242 if (plist->component_kind == DEF_PARAM) {
2243 f_print(fout, ", %s", plist->pl.param_name);
2246 do_split(defp, IN, &numofparams, DEF_INPARAM, 1);
2247 f_print(fout, "))\n\n");
2252 IsRxgenToken(token * tokp)
2254 if (tokp->kind == TOK_PACKAGE || tokp->kind == TOK_PREFIX
2255 || tokp->kind == TOK_SPECIAL || tokp->kind == TOK_STARTINGOPCODE
2256 || tokp->kind == TOK_SPLITPREFIX || tokp->kind == TOK_PROC
2257 || tokp->kind == TOK_STATINDEX)
2263 IsRxgenDefinition(definition * def)
2265 if (def->def_kind == DEF_PACKAGE || def->def_kind == DEF_PREFIX
2266 || def->def_kind == DEF_SPECIAL || def->def_kind == DEF_STARTINGOPCODE
2267 || def->def_kind == DEF_SPLITPREFIX || def->def_kind == DEF_PROC)