version 1.15, 2003/04/06 18:49:18 |
version 1.16, 2003/06/19 20:31:08 |
|
|
if (doinline == 0) |
if (doinline == 0) |
return; |
return; |
/* May cause lint to complain. but ... */ |
/* May cause lint to complain. but ... */ |
fprintf(fout, "\tint32_t *buf;\n\n"); |
fprintf(fout, "\tint32_t *buf;\n"); |
} |
} |
|
|
static void |
static void |
|
|
print_ifclose(indent) |
print_ifclose(indent) |
int indent; |
int indent; |
{ |
{ |
fprintf(fout, ")) {\n"); |
fprintf(fout, "))\n"); |
tabify(fout, indent); |
tabify(fout, indent); |
fprintf(fout, "\treturn (FALSE);\n"); |
fprintf(fout, "\treturn (FALSE);\n"); |
tabify(fout, indent); |
|
fprintf(fout, "}\n"); |
|
} |
} |
|
|
static void |
static void |
|
|
if (alt) { |
if (alt) { |
print_ifopen(indent, alt); |
print_ifopen(indent, alt); |
print_ifarg(objname); |
print_ifarg(objname); |
|
print_ifarg(amax); |
} else { |
} else { |
print_ifopen(indent, "vector"); |
print_ifopen(indent, "vector"); |
print_ifarg("(char *)"); |
print_ifarg("(char *)"); |
fprintf(fout, "%s", objname); |
fprintf(fout, "%s,\n", objname); |
|
tabify(fout, indent); |
|
fprintf(fout, " %s", amax); |
} |
} |
print_ifarg(amax); |
|
if (!alt) { |
if (!alt) { |
print_ifsizeof(prefix, type); |
print_ifsizeof(prefix, type); |
} |
} |
|
|
if (streq(type, "string")) { |
if (streq(type, "string")) { |
print_ifopen(indent, alt); |
print_ifopen(indent, alt); |
print_ifarg(objname); |
print_ifarg(objname); |
|
print_ifarg(amax); |
} else { |
} else { |
if (alt) { |
if (alt) { |
print_ifopen(indent, alt); |
print_ifopen(indent, alt); |
|
|
} |
} |
print_ifarg("(char **)"); |
print_ifarg("(char **)"); |
if (*objname == '&') { |
if (*objname == '&') { |
fprintf(fout, "%s.%s_val, (u_int *)%s.%s_len", |
fprintf(fout, "%s.%s_val,\n\t (u_int *)%s.%s_len", |
objname, name, objname, name); |
objname, name, objname, name); |
} else { |
} else { |
fprintf(fout, "&%s->%s_val, (u_int *)&%s->%s_len", |
fprintf(fout, "&%s->%s_val,\n\t (u_int *)&%s->%s_len", |
objname, name, objname, name); |
objname, name, objname, name); |
} |
} |
|
fprintf(fout, ",\n\t %s", amax); |
} |
} |
print_ifarg(amax); |
|
if (!alt) { |
if (!alt) { |
print_ifsizeof(prefix, type); |
print_ifsizeof(prefix, type); |
} |
} |
|
|
emit_enum(def) |
emit_enum(def) |
definition *def; |
definition *def; |
{ |
{ |
|
fprintf(fout, "\n"); |
|
|
print_ifopen(1, "enum"); |
print_ifopen(1, "enum"); |
print_ifarg("(enum_t *)objp"); |
print_ifarg("(enum_t *)objp"); |
print_ifclose(1); |
print_ifclose(1); |
|
|
char *vecformat = "objp->%s_u.%s"; |
char *vecformat = "objp->%s_u.%s"; |
char *format = "&objp->%s_u.%s"; |
char *format = "&objp->%s_u.%s"; |
|
|
|
fprintf(fout, "\n"); |
print_stat(1, &def->def.un.enum_decl); |
print_stat(1, &def->def.un.enum_decl); |
fprintf(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); |
fprintf(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); |
for (cl = def->def.un.cases; cl != NULL; cl = cl->next) { |
for (cl = def->def.un.cases; cl != NULL; cl = cl->next) { |
|
|
|
|
object = alloc(len); |
object = alloc(len); |
if (object == NULL) { |
if (object == NULL) { |
fprintf(stderr, "Fatal error : no memory\n"); |
fprintf(stderr, "Fatal error: no memory\n"); |
crash(); |
crash(); |
} |
} |
if (isvectordef(cs->type, cs->rel)) { |
if (isvectordef(cs->type, cs->rel)) { |
|
|
fprintf(fout, "\tdefault:\n"); |
fprintf(fout, "\tdefault:\n"); |
object = alloc(len); |
object = alloc(len); |
if (object == NULL) { |
if (object == NULL) { |
fprintf(stderr, "Fatal error : no memory\n"); |
fprintf(stderr, "Fatal error: no memory\n"); |
crash(); |
crash(); |
} |
} |
if (isvectordef(dflt->type, dflt->rel)) { |
if (isvectordef(dflt->type, dflt->rel)) { |
|
|
fprintf(fout, "\tint i;\n"); |
fprintf(fout, "\tint i;\n"); |
break; |
break; |
} |
} |
|
fprintf(fout, "\n"); |
|
|
size = 0; |
size = 0; |
can_inline = 0; |
can_inline = 0; |
for (dl = def->def.st.decls; dl != NULL; dl = dl->next) |
for (dl = def->def.st.decls; dl != NULL; dl = dl->next) |
|
|
flag = PUT; |
flag = PUT; |
for (j = 0; j < 2; j++) { |
for (j = 0; j < 2; j++) { |
if (flag == PUT) |
if (flag == PUT) |
fprintf(fout, "\n\tif (xdrs->x_op == XDR_ENCODE) {\n"); |
fprintf(fout, "\tif (xdrs->x_op == XDR_ENCODE) {\n"); |
else |
else |
fprintf(fout, "\t\treturn (TRUE);\n\t} else if (xdrs->x_op == XDR_DECODE) {\n"); |
fprintf(fout, "\t\treturn (TRUE);\n\t} else if (xdrs->x_op == XDR_DECODE) {\n"); |
|
|
|
|
/* this is required to handle arrays */ |
/* this is required to handle arrays */ |
|
|
if (sizestr == NULL) |
if (sizestr == NULL) |
plus = " "; |
plus = ""; |
else |
else |
plus = "+"; |
plus = "+"; |
|
|
if (ptr->length != 1) |
if (ptr->length != 1) |
snprintf(ptemp, sizeof ptemp, |
snprintf(ptemp, sizeof ptemp, |
" %s %s * %d", plus, |
"%s%s* %d", plus, |
dl->decl.array_max, |
dl->decl.array_max, |
ptr->length); |
ptr->length); |
else |
else |
snprintf(ptemp, sizeof ptemp, |
snprintf(ptemp, sizeof ptemp, |
" %s %s ", plus, |
"%s%s", plus, |
dl->decl.array_max); |
dl->decl.array_max); |
|
|
/* now concatenate to sizestr !!!! */ |
/* now concatenate to sizestr !!!! */ |
|
|
sizestr = strdup(ptemp); |
sizestr = strdup(ptemp); |
if (sizestr == NULL) { |
if (sizestr == NULL) { |
fprintf(stderr, |
fprintf(stderr, |
"Fatal error : no memory\n"); |
"Fatal error: no memory\n"); |
crash(); |
crash(); |
} |
} |
} else { |
} else { |
|
|
sizestr = (char *)realloc(sizestr, len); |
sizestr = (char *)realloc(sizestr, len); |
if (sizestr == NULL) { |
if (sizestr == NULL) { |
fprintf(stderr, |
fprintf(stderr, |
"Fatal error : no memory\n"); |
"Fatal error: no memory\n"); |
crash(); |
crash(); |
} |
} |
/* build up length of array */ |
/* build up length of array */ |
|
|
/* were already looking at a |
/* were already looking at a |
* xdr_inlineable structure */ |
* xdr_inlineable structure */ |
if (sizestr == NULL) |
if (sizestr == NULL) |
fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %d * BYTES_PER_XDR_UNIT);", |
fprintf(fout, |
size); |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs,\n\t\t %d * BYTES_PER_XDR_UNIT);", size); |
else |
else if (size == 0) |
if (size == 0) |
fprintf(fout, |
fprintf(fout, |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs,\n\t\t %s * BYTES_PER_XDR_UNIT);", |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %s * BYTES_PER_XDR_UNIT);", |
|
sizestr); |
sizestr); |
else |
else |
fprintf(fout, |
fprintf(fout, |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs, (%d + %s)* BYTES_PER_XDR_UNIT);", |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs,\n\t\t (%d + %s) * BYTES_PER_XDR_UNIT);", size, sizestr); |
size, sizestr); |
|
|
|
fprintf(fout, "\n\t\tif (buf == NULL) {\n"); |
fprintf(fout, |
|
"\n\t\tif (buf == NULL) {\n"); |
|
|
psav = cur; |
psav = cur; |
while (cur != dl) { |
while (cur != dl) { |
|
|
emit_inline(&cur->decl, flag); |
emit_inline(&cur->decl, flag); |
cur = cur->next; |
cur = cur->next; |
} |
} |
|
|
fprintf(fout, "\t\t}\n"); |
fprintf(fout, "\t\t}\n"); |
} |
} |
} |
} |
|
|
sizestr = NULL; |
sizestr = NULL; |
print_stat(2, &dl->decl); |
print_stat(2, &dl->decl); |
} |
} |
|
|
} |
} |
if (i > 0) { |
if (i > 0) { |
if (sizestr == NULL && size < doinline) { |
if (sizestr == NULL && size < doinline) { |
|
|
/* were already looking at a xdr_inlineable |
/* were already looking at a xdr_inlineable |
* structure */ |
* structure */ |
if (sizestr == NULL) |
if (sizestr == NULL) |
fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %d * BYTES_PER_XDR_UNIT);", |
fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs,\n\t\t %d * BYTES_PER_XDR_UNIT);", |
size); |
size); |
else |
else |
if (size == 0) |
if (size == 0) |
fprintf(fout, |
fprintf(fout, |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %s * BYTES_PER_XDR_UNIT);", |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs,\n\t\t %s * BYTES_PER_XDR_UNIT);", |
sizestr); |
sizestr); |
else |
else |
fprintf(fout, |
fprintf(fout, |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs, (%d + %s)* BYTES_PER_XDR_UNIT);", |
"\t\tbuf = (int32_t *)XDR_INLINE(xdrs,\n\t\t (%d + %s) * BYTES_PER_XDR_UNIT);", |
size, sizestr); |
size, sizestr); |
|
|
fprintf(fout, "\n\t\tif (buf == NULL) {\n"); |
fprintf(fout, "\n\t\tif (buf == NULL) {\n"); |
|
|
char *amax = def->def.ty.array_max; |
char *amax = def->def.ty.array_max; |
relation rel = def->def.ty.rel; |
relation rel = def->def.ty.rel; |
|
|
|
fprintf(fout, "\n"); |
print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name); |
print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name); |
} |
} |
|
|