<commit_before>/*
 * Copyright (C) 1994, Index Data I/S 
 * All rights reserved.
 * <NAME>, <NAME>
 *
 * $Log: odr.c,v $
 * Revision 1.1  1995-03-07 09:23:15  quinn
 * Installing top-level API and documentation.
 *
 *
 */

#include <stdio.h>
#include <stdlib.h>

#include <odr.h>

char *odr_errlist[] =
{
    "No (unknown) error",
    "Memoy allocation failed",
    "System error",
    "No space in buffer",
    "Required data element missing",
    "Unexpected tag",
    "Other error"
};

void odr_perror(ODR o, char *message)
{
    fprintf(stderr, "%s: %s\n", message, odr_errlist[o->error]);
}

void odr_setprint(ODR o, FILE *file)
{
    o->print = file;
}

ODR odr_createmem(int direction)
{
    struct odr *r;

    if (!(r = malloc(sizeof(*r))))
    	return 0;
    r->direction = direction;
    r->print = stdout;
    r->buf = 0;
    r->buflen = 0;
    odr_reset(r);
    return r;
}

void odr_reset(ODR o)
{
    o->error = ONONE;
    o->bp = 0;
    o->left = o->buflen;
    o->t_class = -1;
    o->t_tag = -1;
    o->indent = 0;
    o->stackp = 0;
}
    
void odr_destroy(ODR o)
{
    free(o);
}
<commit_msg>Addded some method functions to the ODR type.<commit_after>/*
 * Copyright (C) 1994, Index Data I/S 
 * All rights reserved.
 * <NAME>, <NAME>
 *
 * $Log: odr.c,v $
 * Revision 1.2  1995-03-07 10:19:05  quinn
 * Addded some method functions to the ODR type.
 *
 * Revision 1.1  1995/03/07  09:23:15  quinn
 * Installing top-level API and documentation.
 *
 *
 */

#include <stdio.h>
#include <stdlib.h>

#include <odr.h>

char *odr_errlist[] =
{
    "No (unknown) error",
    "Memoy allocation failed",
    "System error",
    "No space in buffer",
    "Required data element missing",
    "Unexpected tag",
    "Other error"
};

void odr_perror(ODR o, char *message)
{
    fprintf(stderr, "%s: %s\n", message, odr_errlist[o->error]);
}

int odr_errno(ODR o)
{
    return o->error;
}

void odr_setprint(ODR o, FILE *file)
{
    o->print = file;
}

ODR odr_createmem(int direction)
{
    struct odr *r;

    if (!(r = malloc(sizeof(*r))))
    	return 0;
    r->direction = direction;
    r->print = stdout;
    r->buf = 0;
    r->buflen = 0;
    odr_reset(r);
    return r;
}

void odr_reset(ODR o)
{
    o->error = ONONE;
    o->bp = 0;
    o->left = o->buflen;
    o->t_class = -1;
    o->t_tag = -1;
    o->indent = 0;
    o->stackp = 0;
}
    
void odr_destroy(ODR o)
{
    free(o);
}

void odr_setbuf(ODR o, char *buf, int len)
{
    o->buf = o->bp = (unsigned char *) buf;
    o->buflen = o->left = len;
}

char *odr_getbuf(ODR o, int *len)
{
    *len = o->bp - o->buf;
    return (char *) o->buf;
}    

{'fraction_non_alphanumeric': 0.17016405951926747, 'fraction_numerical': 0.027470431133155285, 'mean_word_length': 2.5625, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1288647', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1087, 'n_words': 275}