
/* This file was automatically generated by pclu.*/

#include "pclu_err.h"
#include "pclu_sys.h"


extern struct dbg_info* dbg_info_open_write;
#undef MY_TRACE_FLAG
#define MY_TRACE_FLAG open_write_TRACE
int open_write_TRACE;
extern struct OPS *int_ops;
static Vlist1 owns_open_write = {0, 1,{ {0, 2, "_init", &int_ops}
}
};
extern errcode streamOPopen();
extern errcode file_nameOPparse();
extern OWN_req stream_ownreqs;
extern struct OPS *stream_ops;
CLUREF STR_write;
static int open_write_own_init = 0;

/**** BEGIN PROCEDURE open_write ****/

errcode open_write(name, ret_1)
CLUREF name;
CLUREF *ret_1;
    {
    struct {
        struct dbg_info *DBG_INFO;
        int DBG_LINE;
        errcode err;
        errcode ecode2;
        CLUREF name;
        } locals;
    locals.name.num = UNINIT;
    locals.DBG_INFO = dbg_info_open_write;
    locals.name = name;
        if (open_write_own_init == 0) {
        stringOPcons("write", CLU_1, CLU_5, &STR_write);
        open_write_own_init = 1;
    }
    enter_proc(3);

  LINE(5);
    {
    {
    CLUREF T_2_1;
    CLUREF T_2_2;
    locals.err = file_nameOPparse(locals.name, &T_2_1);
    if (locals.err != ERR_ok) goto ex_1;
    locals.err = streamOPopen(T_2_1, STR_write, &T_2_2);
    if (locals.err != ERR_ok) goto ex_1;
    ret_1->num = T_2_2.num;
    }
    {signal (ERR_ok);}}
    goto end_1;
    ex_1:
        if (locals.err == ERR_bad_format) {signal(ERR_bad_format);}
        else if (locals.err == ERR_not_possible) {signal(ERR_not_possible);}
        else {
            goto ex_0;}
    end_1:;
    goto end_0;
    ex_0:
        {
            if (locals.err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(locals.err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE open_write ****/

extern struct OPS *string_ops;
typedef struct {
    int hdr;
    int count;
    char *name;
    char *fname;
    bool is_iter;
    int is_parmd;
    int addr;
    int nargs;
    Vlist1 *vals;
    siglist2 *sigs;
    Vlist3 *locals;
    Vlist1 *owns;
    Vlist0 *ptowns;
    Vlist0 *popowns;
    Slist1 *type_formals;
    Slist0 *op_formals;
    } dbg_info_open_write_actual;
static Vlist1 vals_open_write = {0, 1, { {0, 2, "", &stream_ops}}
};
static sig_desc0 sig_open_write_1 = {0, 3, "bad_format", {0, 0
}};
static sig_desc1 sig_open_write_2 = {0, 4, "not_possible", {0, 1
, { {0, 2, "", &string_ops}}}};
static siglist2 sigs_open_write = {0, 2, (sig_desc*)&sig_open_write_1, (sig_desc*)&sig_open_write_2};
static Vlist3 locals_open_write = {0, 3,{ {0, 2, "err", &int_ops},  {0, 2, "ecode2", &int_ops},  {0, 2, "name", &string_ops}}
};
static Vlist0 popowns_open_write = {0, 0};
Slist1 tformals_open_write = {0, 1, "t"};
Slist0 opformals_open_write = {0, 0};
dbg_info_open_write_actual dbg_info_open_write_data = {0, 12, 
    "open_write", "/common/pub/dcurtis-temp/pclu/lib/clu/open_write.clu", 0, 0, (int)open_write, 1, 
    &vals_open_write, &sigs_open_write, &locals_open_write, &owns_open_write, &NO_VALS, &NO_VALS, &tformals_open_write, &NO_PARMS};
    struct dbg_info *dbg_info_open_write = (struct dbg_info*)&dbg_info_open_write_data;
