rpc_cout.c (99979) | rpc_cout.c (100441) |
---|---|
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. | 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 * | 8 * |
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. | 9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. |
12 * | 12 * |
13 * Sun RPC is provided with no support and without any obligation on the 14 * part of Sun Microsystems, Inc. to assist in its use, correction, 15 * modification or enhancement. | 13 * Sun RPC is provided with no support and without any obligation on the 14 * part of Sun Microsystems, Inc. to assist in its use, correction, 15 * modification or enhancement. |
16 * | 16 * |
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 * OR ANY PART THEREOF. | 17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 * OR ANY PART THEREOF. |
20 * | 20 * |
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 * or profits or other special, indirect and consequential damages, even if 23 * Sun has been advised of the possibility of such damages. | 21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 * or profits or other special, indirect and consequential damages, even if 23 * Sun has been advised of the possibility of such damages. |
24 * | 24 * |
25 * Sun Microsystems, Inc. 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 */ 29 | 25 * Sun Microsystems, Inc. 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 */ 29 |
30#ident "@(#)rpc_cout.c 1.14 93/07/05 SMI" | 30#ident "@(#)rpc_cout.c 1.14 93/07/05 SMI" |
31 | 31 |
32#ifndef lint | |
33#if 0 | 32#if 0 |
33#ifndef lint |
|
34static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI"; 35#endif | 34static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI"; 35#endif |
36static const char rcsid[] = 37 "$FreeBSD: head/usr.bin/rpcgen/rpc_cout.c 99979 2002-07-14 17:54:00Z alfred $"; | |
38#endif 39 | 36#endif 37 |
38#include <sys/cdefs.h> 39__FBSDID("$FreeBSD: head/usr.bin/rpcgen/rpc_cout.c 100441 2002-07-21 12:55:04Z charnier $"); 40 |
|
40/* 41 * rpc_cout.c, XDR routine outputter for the RPC protocol compiler 42 * Copyright (C) 1987, Sun Microsystems, Inc. 43 */ | 41/* 42 * rpc_cout.c, XDR routine outputter for the RPC protocol compiler 43 * Copyright (C) 1987, Sun Microsystems, Inc. 44 */ |
44#include <err.h> | |
45#include <ctype.h> 46#include <stdio.h> 47#include <string.h> 48#include "rpc_parse.h" 49#include "rpc_util.h" 50 51static void print_header( definition * ); 52static void print_trailer( void ); --- 40 unchanged lines hidden (view full) --- 93 break; 94 case DEF_STRUCT: 95 emit_struct(def); 96 break; 97 case DEF_TYPEDEF: 98 emit_typedef(def); 99 break; 100 /* DEF_CONST and DEF_PROGRAM have already been handled */ | 45#include <ctype.h> 46#include <stdio.h> 47#include <string.h> 48#include "rpc_parse.h" 49#include "rpc_util.h" 50 51static void print_header( definition * ); 52static void print_trailer( void ); --- 40 unchanged lines hidden (view full) --- 93 break; 94 case DEF_STRUCT: 95 emit_struct(def); 96 break; 97 case DEF_TYPEDEF: 98 emit_typedef(def); 99 break; 100 /* DEF_CONST and DEF_PROGRAM have already been handled */ |
101 default: | 101 default: |
102 break; 103 } 104 print_trailer(); 105} 106 107static int 108findtype(def, type) 109 definition *def; --- 243 unchanged lines hidden (view full) --- 353 f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); 354 for (cl = def->def.un.cases; cl != NULL; cl = cl->next) { 355 356 f_print(fout, "\tcase %s:\n", cl->case_name); 357 if (cl->contflag == 1) /* a continued case statement */ 358 continue; 359 cs = &cl->case_decl; 360 if (!streq(cs->type, "void")) { | 102 break; 103 } 104 print_trailer(); 105} 106 107static int 108findtype(def, type) 109 definition *def; --- 243 unchanged lines hidden (view full) --- 353 f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); 354 for (cl = def->def.un.cases; cl != NULL; cl = cl->next) { 355 356 f_print(fout, "\tcase %s:\n", cl->case_name); 357 if (cl->contflag == 1) /* a continued case statement */ 358 continue; 359 cs = &cl->case_decl; 360 if (!streq(cs->type, "void")) { |
361 object = alloc(strlen(def->def_name) + strlen(format) + 362 strlen(cs->name) + 1); | 361 object = xmalloc(strlen(def->def_name) + 362 strlen(format) + strlen(cs->name) + 1); |
363 if (isvectordef (cs->type, cs->rel)) { 364 s_print(object, vecformat, def->def_name, 365 cs->name); 366 } else { 367 s_print(object, format, def->def_name, 368 cs->name); 369 } 370 print_ifstat(2, cs->prefix, cs->type, cs->rel, 371 cs->array_max, object, cs->name); 372 free(object); 373 } 374 f_print(fout, "\t\tbreak;\n"); 375 } 376 dflt = def->def.un.default_decl; 377 if (dflt != NULL) { 378 if (!streq(dflt->type, "void")) { 379 f_print(fout, "\tdefault:\n"); | 363 if (isvectordef (cs->type, cs->rel)) { 364 s_print(object, vecformat, def->def_name, 365 cs->name); 366 } else { 367 s_print(object, format, def->def_name, 368 cs->name); 369 } 370 print_ifstat(2, cs->prefix, cs->type, cs->rel, 371 cs->array_max, object, cs->name); 372 free(object); 373 } 374 f_print(fout, "\t\tbreak;\n"); 375 } 376 dflt = def->def.un.default_decl; 377 if (dflt != NULL) { 378 if (!streq(dflt->type, "void")) { 379 f_print(fout, "\tdefault:\n"); |
380 object = alloc(strlen(def->def_name) + strlen(format) + 381strlen(dflt->name) + 1); | 380 object = xmalloc(strlen(def->def_name) + 381 strlen(format) + strlen(dflt->name) + 1); |
382 if (isvectordef (dflt->type, dflt->rel)) { 383 s_print(object, vecformat, def->def_name, 384 dflt->name); 385 } else { 386 s_print(object, format, def->def_name, 387 dflt->name); 388 } 389 --- 58 unchanged lines hidden (view full) --- 448 s_print(ptemp, "%s%s * %d", 449 plus, dl->decl.array_max, 450 ptr->length); 451 else 452 s_print(ptemp, "%s%s", plus, 453 dl->decl.array_max); 454 455 /* now concatenate to sizestr !!!! */ | 382 if (isvectordef (dflt->type, dflt->rel)) { 383 s_print(object, vecformat, def->def_name, 384 dflt->name); 385 } else { 386 s_print(object, format, def->def_name, 387 dflt->name); 388 } 389 --- 58 unchanged lines hidden (view full) --- 448 s_print(ptemp, "%s%s * %d", 449 plus, dl->decl.array_max, 450 ptr->length); 451 else 452 s_print(ptemp, "%s%s", plus, 453 dl->decl.array_max); 454 455 /* now concatenate to sizestr !!!! */ |
456 if (sizestr == NULL) 457 sizestr = strdup(ptemp); | 456 if (sizestr == NULL) { 457 sizestr = xstrdup(ptemp); 458 } |
458 else{ | 459 else{ |
459 sizestr = realloc(sizestr, | 460 sizestr = xrealloc(sizestr, |
460 strlen(sizestr) 461 +strlen(ptemp)+1); | 461 strlen(sizestr) 462 +strlen(ptemp)+1); |
462 if (sizestr == NULL){ 463 warnx("fatal error: no memory"); 464 crash(); 465 }; | |
466 sizestr = strcat(sizestr, ptemp); 467 /* build up length of array */ 468 } 469 } 470 } else { 471 if (i > 0) { 472 if (sizestr == NULL && size < inline){ 473 /* --- 274 unchanged lines hidden (view full) --- 748 free(upp_case); 749} 750 751char *upcase(str) 752char *str; 753{ 754 char *ptr, *hptr; 755 | 463 sizestr = strcat(sizestr, ptemp); 464 /* build up length of array */ 465 } 466 } 467 } else { 468 if (i > 0) { 469 if (sizestr == NULL && size < inline){ 470 /* --- 274 unchanged lines hidden (view full) --- 745 free(upp_case); 746} 747 748char *upcase(str) 749char *str; 750{ 751 char *ptr, *hptr; 752 |
756 ptr = (char *)malloc(strlen(str)+1); 757 if (ptr == (char *) NULL) 758 errx(1, "malloc failed"); | 753 ptr = (char *)xmalloc(strlen(str)+1); |
759 760 hptr = ptr; 761 while (*str != '\0') 762 *ptr++ = toupper(*str++); 763 764 *ptr = '\0'; 765 return (hptr); 766} | 754 755 hptr = ptr; 756 while (*str != '\0') 757 *ptr++ = toupper(*str++); 758 759 *ptr = '\0'; 760 return (hptr); 761} |