int GUTHTHILA_CALL guththila_write()

in guththila/src/guththila_xml_writer.c [115:174]


int GUTHTHILA_CALL guththila_write(
    guththila_xml_writer_t * wr,
    char *buff,
    size_t buff_size,
    const axutil_env_t * env);

/* 
 * Same functionality as the guththila_write only difference is here we are given 
 * a token to write, not a buffer.
 */
int GUTHTHILA_CALL guththila_write_token(
    guththila_xml_writer_t * wr,
    guththila_token_t * tok,
    const axutil_env_t * env);

int GUTHTHILA_CALL guththila_write_xtoken(
    guththila_xml_writer_t * wr,
    char *buff,
    size_t buff_len,
    const axutil_env_t * env);

/*
 * Private function for free the contents of a empty element.
 */
int GUTHTHILA_CALL guththila_free_empty_element(
    guththila_xml_writer_t *wr,
    const axutil_env_t *env);

GUTHTHILA_EXPORT guththila_xml_writer_t * GUTHTHILA_CALL
guththila_create_xml_stream_writer(
    guththila_char_t *file_name,
    const axutil_env_t * env)
{
    guththila_xml_writer_t * wr = AXIS2_MALLOC(env->allocator, sizeof(guththila_xml_writer_t));
    if(!wr)
        return NULL;
    wr->out_stream = fopen(file_name, "w");
    if(!wr->out_stream)
    {
        AXIS2_FREE(env->allocator, wr);
        return NULL;
    }
    if(!guththila_stack_init(&wr->element, env))
    {
        fclose(wr->out_stream);
        AXIS2_FREE(env->allocator, wr);
        return NULL;
    }
    if(!guththila_stack_init(&wr->namesp, env))
    {
        guththila_stack_un_init(&wr->element, env);
        fclose(wr->out_stream);
        AXIS2_FREE(env->allocator, wr);
        return NULL;
    }
    wr->type = GUTHTHILA_WRITER_FILE;
    wr->status = BEGINING;
    wr->next = 0;
    return wr;
}