Beispiel #1
0
void open_files(void)
{
    create_file_names();

    if (input_file == 0)
    {
        input_file = fopen(input_file_name, "r");
        if (input_file == 0)
            open_error(input_file_name);
    }

    action_file = fopen(action_file_name, "w");
    if (action_file == 0)
        open_error(action_file_name);

    entry_file = fopen(entry_file_name, "w");
    if (entry_file == 0)
        open_error(entry_file_name);

    text_file = fopen(text_file_name, "w");
    if (text_file == 0)
        open_error(text_file_name);

    if (vflag)
    {
        verbose_file = fopen(verbose_file_name, "w");
        if (verbose_file == 0)
            open_error(verbose_file_name);
    }

    if (dflag)
    {
        defines_file = fopen(defines_file_name, "w");
        if (defines_file == 0)
            open_error(defines_file_name);
        union_file = fopen(union_file_name, "w");
        if (union_file ==  0)
            open_error(union_file_name);
    }

    output_file = fopen(output_file_name, "w");
    if (output_file == 0)
        open_error(output_file_name);

    if (rflag)
    {
        code_file = fopen(code_file_name, "w");
        if (code_file == 0)
            open_error(code_file_name);
    }
    else
        code_file = output_file;


    interface_file = fopen(interface_file_name, "w");
    if (interface_file == 0)
      open_error(interface_file_name);
}
Beispiel #2
0
void open_files(void)
{
	create_file_names();

	if (input_file == 0)
	{
		input_file = fopen(input_file_name, "r");
		if (input_file == 0)
			open_error(input_file_name);
	}

	action_file = fopen(action_file_name, "w");
	if (action_file == 0)
		open_error(action_file_name);

	text_file = fopen(text_file_name, "w");
	if (text_file == 0)
		open_error(text_file_name);

	if (vflag)
	{
		verbose_file = fopen(verbose_file_name, "w");
		if (verbose_file == 0)
			open_error(verbose_file_name);
	}

	if (dflag)
	{
		defines_file = fopen(defines_file_name, "w");
		if (defines_file == 0)
			open_error(defines_file_name);
		union_file = fopen(union_file_name, "w");
		if (union_file == 0)
			open_error(union_file_name);
	}

	output_file = fopen(output_file_name, "w");
	if (output_file == 0)
		open_error(output_file_name);
	if (emitident)
		fprintf(output_file, "#ident \"%s: %s\"\n", myname, yaccversion);

	if (rflag)
	{
		code_file = fopen(code_file_name, "w");
		if (code_file == 0)
			open_error(code_file_name);
	} else
		code_file = output_file;
}
Beispiel #3
0
void open_files()
{
    create_file_names();

    action_file = fopen(action_file_name, "w");
    if (action_file == 0)
	open_error(action_file_name);

    text_file = fopen(text_file_name, "w");
    if (text_file == 0)
	open_error(text_file_name);

    if (vflag)
    {
	verbose_file = fopen(verbose_file_name, "w");
	if (verbose_file == 0)
	    open_error(verbose_file_name);
    }

    if (dflag)
    {
	defines_file = fopen(defines_file_name, "w");
	if (defines_file == 0)
	    open_error(defines_file_name);
	union_file = fopen(union_file_name, "w");
	if (union_file ==  0)
	    open_error(union_file_name);
    }

    output_file = fopen(output_file_name, "w");
    if (output_file == 0)
	open_error(output_file_name);

    if (rflag)
    {
	code_file = fopen(code_file_name, "w");
	if (code_file == 0)
	    open_error(code_file_name);
    }
    else
	code_file = output_file;
}
Beispiel #4
0
static void
open_files (void)
{
    create_file_names();

    if (input_file == 0)
    {
	input_file = fopen(input_file_name, "r");
	if (input_file == 0)
	    open_error(input_file_name);
    }

    action_file = fopen(action_file_name, "w");
    if (action_file == 0)
	open_error(action_file_name);

    prolog_file = fopen(prolog_file_name, "w");
    if (prolog_file == 0)
	open_error(prolog_file_name);

    local_file = fopen(local_file_name, "w");
    if (local_file == 0)
	open_error(local_file_name);

    if (vflag)
    {
	verbose_file = fopen(verbose_file_name, "w");
	if (verbose_file == 0)
	    open_error(verbose_file_name);
    }

    if (output_file == 0)
    {
        if (output_file_name != 0) {
            output_file = fopen(output_file_name, "w");
            if (output_file == 0)
                open_error(output_file_name);
        } else {
            output_file = stdout;
        }
    }
}
Beispiel #5
0
/*
 * Copy from inout-file to out-file and from in-file to inout-file.
 */
int
main(int argc, char *argv[])
{
    grpc_error_t ret;
    int result;
    char *conf, *array_size_str, *end;
    int array_size;
    char **in_file_array, **inout_file_array, **out_file_array;
    char *in_file, *inout_file, *out_file;

    if (argc < 6) {
        fprintf(stderr, "Usage: %s config count in-file inout-file out-file\n",
            argv[0]);
        exit(2);
    }

    conf = argv[1];
    array_size_str = argv[2];
    in_file = argv[3];
    inout_file = argv[4];
    out_file = argv[5];

    ret = grpc_initialize(conf);
    if (ret != GRPC_NO_ERROR) {
        fprintf(stderr,
            "grpc_initialize() error. (%s)\n", grpc_error_string(ret));
        exit(2);
    }

    array_size = strtol(array_size_str, &end, 0);
    if (*end != '\0') {
        fprintf(stderr, "Argument \"%s\" is not digit.\n", array_size_str);
        exit(1);
    } else if (array_size < 1){
        fprintf(stderr, "array_size %d < 1 (min)\n", array_size);
        exit(1);
    }

    result = create_file_names(array_size, in_file, inout_file, out_file,
        &in_file_array, &inout_file_array, &out_file_array);
    if (result == 0) {
        fprintf(stderr, "creating filenames failed\n");
        exit(1);
    }

    result = check_files(array_size, in_file_array, inout_file_array);
    if (result == 0) {
        fprintf(stderr, "files are not prepared. no test performed.\n");
        exit(1);
    }

    ret = grpc_function_handle_default(
        &handles, MODULE_NAME "/filename_array_test");
    if (ret != GRPC_NO_ERROR) {
        fprintf(stderr, "grpc_function_handle_default() error. (%s)\n",
            grpc_error_string(ret));
        exit(2);
    }

    ret = grpc_call(&handles,
        array_size, in_file_array, inout_file_array, out_file_array);
    if (ret != GRPC_NO_ERROR) {
        fprintf(stderr, "grpc_call() error. (%s)\n",
            grpc_error_string(ret));
        exit(2);
    }

    ret = grpc_function_handle_destruct(&handles);
    if (ret != GRPC_NO_ERROR) {
        fprintf(stderr, "grpc_function_handle_destruct() error. (%s)\n",
            grpc_error_string(ret));
        exit(2);
    }

    ret = grpc_finalize();
    if (ret != GRPC_NO_ERROR) {
        fprintf(stderr, "grpc_finalize() error. (%s)\n",
            grpc_error_string(ret));
        exit(2);
    }

    result = destroy_file_names(array_size, &in_file_array, &inout_file_array, &out_file_array);
    if (result == 0) {
        fprintf(stderr, "destroying filenames failed\n");
        exit(1);
    }
 
    return 0;
}
Beispiel #6
0
void open_files(void)
{
    create_file_names();

    if (input_file == 0)
    {
        input_file = fopen(input_file_name, "r");
        if (input_file == 0)
            open_error(input_file_name);
    }

#ifdef HAVE_MKSTEMP
    action_file = fdopen(action_fd, "w");
#else
    action_file = fopen(action_file_name, "w");
#endif
    if (action_file == 0)
        open_error(action_file_name);

#ifdef HAVE_MKSTEMP
    entry_file = fdopen(entry_fd, "w");
#else
    entry_file = fopen(entry_file_name, "w");
#endif
    if (entry_file == 0)
        open_error(entry_file_name);

#ifdef HAVE_MKSTEMP
    text_file = fdopen(text_fd, "w");
#else
    text_file = fopen(text_file_name, "w");
#endif
    if (text_file == 0)
        open_error(text_file_name);

    if (vflag)
    {
        verbose_file = fopen(verbose_file_name, "w");
        if (verbose_file == 0)
            open_error(verbose_file_name);
    }

    if (dflag)
    {
        defines_file = fopen(defines_file_name, "w");
        if (defines_file == 0)
            open_error(defines_file_name);
#ifdef HAVE_MKSTEMP
        union_file = fdopen(union_fd, "w");
#else
        union_file = fopen(union_file_name, "w");
#endif
        if (union_file ==  0)
            open_error(union_file_name);
    }

    output_file = fopen(output_file_name, "w");
    if (output_file == 0)
        open_error(output_file_name);

    if (rflag)
    {
        code_file = fopen(code_file_name, "w");
        if (code_file == 0)
            open_error(code_file_name);
    }
    else
        code_file = output_file;


    interface_file = fopen(interface_file_name, "w");
    if (interface_file == 0)
      open_error(interface_file_name);
}
Beispiel #7
0
static void
open_files(void)
{
    create_file_names();

    if (input_file == 0)
    {
	input_file = fopen(input_file_name, "r");
	if (input_file == 0)
	    open_error(input_file_name);
    }

    action_file = open_tmpfile("action_file");
    text_file = open_tmpfile("text_file");

    if (vflag)
    {
	verbose_file = fopen(verbose_file_name, "w");
	if (verbose_file == 0)
	    open_error(verbose_file_name);
    }

    if (gflag)
    {
	graph_file = fopen(graph_file_name, "w");
	if (graph_file == 0)
	    open_error(graph_file_name);
	fprintf(graph_file, "digraph %s {\n", file_prefix);
	fprintf(graph_file, "\tedge [fontsize=10];\n");
	fprintf(graph_file, "\tnode [shape=box,fontsize=10];\n");
	fprintf(graph_file, "\torientation=landscape;\n");
	fprintf(graph_file, "\trankdir=LR;\n");
	fprintf(graph_file, "\t/*\n");
	fprintf(graph_file, "\tmargin=0.2;\n");
	fprintf(graph_file, "\tpage=\"8.27,11.69\"; // for A4 printing\n");
	fprintf(graph_file, "\tratio=auto;\n");
	fprintf(graph_file, "\t*/\n");
    }

    if (dflag)
    {
	defines_file = fopen(defines_file_name, "w");
	if (defines_file == 0)
	    open_error(defines_file_name);
	union_file = open_tmpfile("union_file");
    }

    if (iflag)
    {
	externs_file = fopen(externs_file_name, "w");
	if (externs_file == 0)
	    open_error(externs_file_name);
    }

    output_file = fopen(output_file_name, "w");
    if (output_file == 0)
	open_error(output_file_name);

    if (rflag)
    {
	code_file = fopen(code_file_name, "w");
	if (code_file == 0)
	    open_error(code_file_name);
    }
    else
	code_file = output_file;
}
Beispiel #8
0
static void
open_files(void)
{
    int fd;

    create_file_names();

    if (input_file == NULL)
    {
	input_file = fopen(input_file_name, "r");
	if (input_file == NULL)
	    open_error(input_file_name);
    }

    fd = mkstemp(action_file_name);
    if (fd < 0 || (action_file = fdopen(fd, "w")) == NULL) {
        if (fd >= 0)
	    close(fd);
	open_error(action_file_name);
    }
    fd = mkstemp(text_file_name);
    if (fd < 0 || (text_file = fdopen(fd, "w")) == NULL) {
        if (fd >= 0)
	    close(fd);
	open_error(text_file_name);
    }
    fd = mkstemp(union_file_name);
    if (fd < 0 || (union_file = fdopen(fd, "w")) == NULL) {
        if (fd >= 0)
	    close(fd);
	open_error(union_file_name);
    }

    text_file = fopen(text_file_name, "w");
    if (text_file == NULL)
	open_error(text_file_name);

    if (vflag)
    {
	verbose_file = fopen(verbose_file_name, "w");
	if (verbose_file == NULL)
	    open_error(verbose_file_name);
    }

    if (dflag)
    {
	defines_file = fopen(defines_file_name, "w");
	if (defines_file == NULL)
	    open_error(defines_file_name);
	union_file = fopen(union_file_name, "w");
	if (union_file ==  NULL)
	    open_error(union_file_name);
    }

    output_file = fopen(output_file_name, "w");
    if (output_file == NULL)
	open_error(output_file_name);

    if (rflag)
    {
	code_file = fopen(code_file_name, "w");
	if (code_file == NULL)
	    open_error(code_file_name);
    }
    else
	code_file = output_file;
}