Ejemplo n.º 1
0
/*
 * Print the C-version of an xdr definition
 */
void
print_datadef(definition * def)
{
    if (Sflag)
	scan_print = 0;
    if ((def->def_kind != DEF_CONST) && (!IsRxgenDefinition(def))) {
	f_print(fout, "\n");
    }
    switch (def->def_kind) {
    case DEF_CUSTOMIZED:
    case DEF_STRUCT:
	pstructdef(def);
	break;
    case DEF_UNION:
	puniondef(def);
	break;
    case DEF_ENUM:
	penumdef(def);
	break;
    case DEF_TYPEDEF:
	ptypedef(def);
	break;
    case DEF_PROGRAM:
	pprogramdef(def);
	break;
    case DEF_PROC:
	psprocdef(def);
	break;
    case DEF_CONST:
	pconstdef(def);
	break;
    default:
	break;
    }
    if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST
	&& (!IsRxgenDefinition(def))) {
	f_print(fout, "bool_t xdr_%s(XDR *xdrs, %s *objp);\n", def->def_name,
		def->def_name);
    }
    if (def->def_kind != DEF_CONST && (!IsRxgenDefinition(def))) {
	f_print(fout, "\n");
    }
    if (Sflag)
	scan_print = 1;
}
Ejemplo n.º 2
0
/*
 * Compile into an XDR routine output file
 */
static void
c_output(char *infile, char *define, int extend, char *outfile, int append)
{
    definition *def;
    char *include;
    char *outfilename;
    long tell;
    char fullname[1024];
    char *currfile = (OutFileFlag ? OutFile : infile);
    int i, j;

    open_input(infile, define);
    cflag = 1;
    memset(fullname, 0, sizeof(fullname));
    if (append) {
	strcpy(fullname, prefix);
	strcat(fullname, infile);
    } else
	strcpy(fullname, infile);
    outfilename = extend ? extendfile(fullname, outfile) : outfile;
    open_output(infile, outfilename);
    f_print(fout, "/* Machine generated file -- Do NOT edit */\n\n");
    if (xflag) {
	if (kflag) {
	    f_print(fout, "#include \"afsconfig.h\"\n");
	    f_print(fout, "#include \"afs/param.h\"\n");
	} else {
	    f_print(fout, "#include <afsconfig.h>\n");
	    f_print(fout, "#include <afs/param.h>\n");
	    f_print(fout, "#include <roken.h>\n");
	}
	f_print(fout, "#ifdef AFS_NT40_ENV\n");
	f_print(fout, "#define AFS_RXGEN_EXPORT __declspec(dllexport)\n");
	f_print(fout, "#endif /* AFS_NT40_ENV */\n");
    }
    if (currfile && (include = extendfile(currfile, ".h"))) {
	if (kflag) {
	    f_print(fout, "#include \"%s\"\n\n", include);
	} else
	    f_print(fout, "#include \"%s\"\n\n", include);
	free(include);
    } else {
	/* In case we can't include the interface's own header file... */
	if (kflag) {
	    f_print(fout, "#include \"h/types.h\"\n");
	    f_print(fout, "#include \"h/socket.h\"\n");
	    f_print(fout, "#include \"h/file.h\"\n");
	    f_print(fout, "#include \"h/stat.h\"\n");
	    f_print(fout, "#include \"netinet/in.h\"\n");
	    f_print(fout, "#include \"h/time.h\"\n");
	    f_print(fout, "#include \"rx/xdr.h\"\n");
	    f_print(fout, "#include \"afs/rxgen_consts.h\"\n");
	} else {
	    f_print(fout, "#include <rx/xdr.h>\n");
	}
    }

    tell = ftell(fout);
    while ((def = get_definition())) {
	if (!yflag) {
	    if ((!IsRxgenDefinition(def)) && def->def_kind != DEF_CUSTOMIZED)
		emit(def);
	}
    }

    /*
     * Print out array containing list of all functions in the interface
     * in order
     */

    if (xflag) {
	for (j = 0; j <= PackageIndex; j++) {
	    f_print(fout, "AFS_RXGEN_EXPORT\n");
	    f_print(fout, "const char *%sfunction_names[] = {\n",
		    PackagePrefix[j]);

	    for (i = 0; i < no_of_stat_funcs_header[j]; i++) {
		if (i == 0) {
		    f_print(fout, "\t\"%s\"", function_list[j][i]);
		} else {
		    f_print(fout, ",\n\t\"%s\"", function_list[j][i]);
		}
	    }


	    f_print(fout, "\n};\n");
	}
	er_Proc_CodeGeneration();
    }

    if (extend && tell == ftell(fout)) {
	(void)unlink(outfilename);
    }
    cflag = 0;
}