rpc_tblout.c (141152) | rpc_tblout.c (141614) |
---|---|
1/* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. 8 * --- 22 unchanged lines hidden (view full) --- 31 32#if 0 33#ifndef lint 34static char sccsid[] = "@(#)rpc_tblout.c 1.4 89/02/22 (C) 1988 SMI"; 35#endif 36#endif 37 38#include <sys/cdefs.h> | 1/* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. 8 * --- 22 unchanged lines hidden (view full) --- 31 32#if 0 33#ifndef lint 34static char sccsid[] = "@(#)rpc_tblout.c 1.4 89/02/22 (C) 1988 SMI"; 35#endif 36#endif 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/usr.bin/rpcgen/rpc_tblout.c 141152 2005-02-02 22:14:10Z alfred $"); | 39__FBSDID("$FreeBSD: head/usr.bin/rpcgen/rpc_tblout.c 141614 2005-02-10 10:44:29Z alfred $"); |
40 41/* 42 * rpc_tblout.c, Dispatch table outputter for the RPC protocol compiler 43 * Copyright (C) 1989, Sun Microsystems, Inc. 44 */ 45#include <err.h> 46#include <stdio.h> 47#include <string.h> 48#include "rpc_parse.h" 49#include "rpc_util.h" 50 51#define TABSIZE 8 52#define TABCOUNT 5 53#define TABSTOP (TABSIZE*TABCOUNT) 54 55static char tabstr[TABCOUNT+1] = "\t\t\t\t\t"; 56 57static char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n"; | 40 41/* 42 * rpc_tblout.c, Dispatch table outputter for the RPC protocol compiler 43 * Copyright (C) 1989, Sun Microsystems, Inc. 44 */ 45#include <err.h> 46#include <stdio.h> 47#include <string.h> 48#include "rpc_parse.h" 49#include "rpc_util.h" 50 51#define TABSIZE 8 52#define TABCOUNT 5 53#define TABSTOP (TABSIZE*TABCOUNT) 54 55static char tabstr[TABCOUNT+1] = "\t\t\t\t\t"; 56 57static char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n"; |
58static char tbl_end[] = "\n};\n"; | 58static char tbl_end[] = "};\n"; |
59 | 59 |
60static char null_entry[] = "\n\t{\n\ 61 \tNULL,\n\ | 60static char null_entry[] = "\n\t(char *(*)())0,\n\ |
62 \t(xdrproc_t) xdr_void,\t\t\t0,\n\ | 61 \t(xdrproc_t) xdr_void,\t\t\t0,\n\ |
63 \t(xdrproc_t) xdr_void,\t\t\t0,\n\ 64 \t}"; | 62 \t(xdrproc_t) xdr_void,\t\t\t0,\n"; |
65 66 67static char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n"; 68 69extern int nullproc( proc_list * ); 70static void write_table( definition * ); 71static void printit( char *, char * ); 72 --- 43 unchanged lines hidden (view full) --- 116 "\n/*\n * WARNING: table out of order\n */\n"); 117 if (warning == 0) { 118 warnx("WARNING %s table is out of order", progvers); 119 warning = 1; 120 nonfatalerrors = 1; 121 } 122 expected = current + 1; 123 } | 63 64 65static char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n"; 66 67extern int nullproc( proc_list * ); 68static void write_table( definition * ); 69static void printit( char *, char * ); 70 --- 43 unchanged lines hidden (view full) --- 114 "\n/*\n * WARNING: table out of order\n */\n"); 115 if (warning == 0) { 116 warnx("WARNING %s table is out of order", progvers); 117 warning = 1; 118 nonfatalerrors = 1; 119 } 120 expected = current + 1; 121 } |
124 f_print(fout, ",\n\n\t{\n\tRPCGEN_ACTION("); | 122 f_print(fout, "\n\t(char *(*)())RPCGEN_ACTION("); |
125 126 /* routine to invoke */ 127 if( Cflag && !newstyle ) 128 pvname_svc(proc->proc_name, vp->vers_num); 129 else { 130 if( newstyle ) 131 f_print( fout, "_"); /* calls internal func */ 132 pvname(proc->proc_name, vp->vers_num); --- 4 unchanged lines hidden (view full) --- 137 if( proc->arg_num > 1 ) 138 printit((char*) NULL, proc->args.argname ); 139 else 140 /* do we have to do something special for newstyle */ 141 printit( proc->args.decls->decl.prefix, 142 proc->args.decls->decl.type ); 143 /* result info */ 144 printit(proc->res_prefix, proc->res_type); | 123 124 /* routine to invoke */ 125 if( Cflag && !newstyle ) 126 pvname_svc(proc->proc_name, vp->vers_num); 127 else { 128 if( newstyle ) 129 f_print( fout, "_"); /* calls internal func */ 130 pvname(proc->proc_name, vp->vers_num); --- 4 unchanged lines hidden (view full) --- 135 if( proc->arg_num > 1 ) 136 printit((char*) NULL, proc->args.argname ); 137 else 138 /* do we have to do something special for newstyle */ 139 printit( proc->args.decls->decl.prefix, 140 proc->args.decls->decl.type ); 141 /* result info */ 142 printit(proc->res_prefix, proc->res_type); |
145 f_print(fout, "\t}"); | |
146 } 147 148 /* print the table trailer */ 149 f_print(fout, tbl_end); 150 f_print(fout, tbl_nproc, progvers, progvers, progvers); 151 } 152} 153 154static void 155printit(prefix, type) 156 char *prefix; 157 char *type; 158{ 159 int len; 160 int tabs; 161 162 | 143 } 144 145 /* print the table trailer */ 146 f_print(fout, tbl_end); 147 f_print(fout, tbl_nproc, progvers, progvers, progvers); 148 } 149} 150 151static void 152printit(prefix, type) 153 char *prefix; 154 char *type; 155{ 156 int len; 157 int tabs; 158 159 |
163 len = fprintf(fout, "\t(xdrproc_t) xdr_%s,", stringfix(type)); | 160 len = fprintf(fout, "\txdr_%s,", stringfix(type)); |
164 /* account for leading tab expansion */ 165 len += TABSIZE - 1; 166 /* round up to tabs required */ 167 tabs = (TABSTOP - len + TABSIZE - 1)/TABSIZE; 168 f_print(fout, "%s", &tabstr[TABCOUNT-tabs]); 169 170 if (streq(type, "void")) { 171 f_print(fout, "0"); 172 } else { | 161 /* account for leading tab expansion */ 162 len += TABSIZE - 1; 163 /* round up to tabs required */ 164 tabs = (TABSTOP - len + TABSIZE - 1)/TABSIZE; 165 f_print(fout, "%s", &tabstr[TABCOUNT-tabs]); 166 167 if (streq(type, "void")) { 168 f_print(fout, "0"); 169 } else { |
173 f_print(fout, " sizeof ( "); | 170 f_print(fout, "sizeof ( "); |
174 /* XXX: should "follow" be 1 ??? */ 175 ptype(prefix, type, 0); 176 f_print(fout, ")"); 177 } 178 f_print(fout, ",\n"); 179} | 171 /* XXX: should "follow" be 1 ??? */ 172 ptype(prefix, type, 0); 173 f_print(fout, ")"); 174 } 175 f_print(fout, ",\n"); 176} |