<commit_before>/* This file is part of the YAZ toolkit.
 * Copyright (C) 1995-2012 Index Data
 * See the file LICENSE for details.
 */
/**
 * \file odr_util.c
 * \brief Implements various ODR utilities
 */
#if HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdlib.h>
#include <string.h>
#include "odr-priv.h"
#include <yaz/oid_util.h>

void odr_prname(ODR o, const char *name)
{
    if (name)
        odr_printf(o, "%*s%s ", o->op->indent*4, "", name);
    else
        odr_printf(o, "%*s", o->op->indent*4, "");
}

int odp_more_chunks(ODR o, const unsigned char *base, int len)
{
    if (!len)
        return 0;
    if (len < 0) /* indefinite length */
    {
        if (*o->bp == 0 && *(o->bp + 1) == 0)
        {
            o->bp += 2;
            return 0;
        }
        else
            return 1;
    }
    else
        return o->bp - base < len;
}

Odr_oid *odr_oiddup_nmem(NMEM nmem, const Odr_oid *o)
{
    Odr_oid *r;

    if (!o)
        return 0;<commit_msg>Change APDU dump printing to avoid long leading blanks<commit_after>/* This file is part of the YAZ toolkit.
 * Copyright (C) 1995-2012 Index Data
 * See the file LICENSE for details.
 */
/**
 * \file odr_util.c
 * \brief Implements various ODR utilities
 */
#if HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdlib.h>
#include <string.h>
#include "odr-priv.h"
#include <yaz/oid_util.h>

void odr_prname(ODR o, const char *name)
{
    if (o->op->indent < 16)
        odr_printf(o, "%*s", o->op->indent * 2, "");
    else
        odr_printf(o, "level=%-7d%*s", o->op->indent, 
                   2 * (o->op->indent % 8) , "");
    if (name)
        odr_printf(o, "%s ", name);
}

int odp_more_chunks(ODR o, const unsigned char *base, int len)
{
    if (!len)
        return 0;
    if (len < 0) /* indefinite length */
    {
        if (*o->bp == 0 && *(o->bp + 1) == 0)
        {
            o->bp += 2;
            return 0;
        }
        else
            return 1;
    }
    else
        return o->bp - base < len;
}

Odr_oid *odr_oiddup_nmem(NMEM nmem, const Odr_oid *o)
{
    Odr_oid *r;

    if (!o)
        return 0;
{'fraction_non_alphanumeric': 0.15829383886255924, 'fraction_numerical': 0.01990521327014218, 'mean_word_length': 2.0594202898550726, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 31, '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': '6090529', 'n_tokens_mistral': 852, 'n_tokens_neox': 800, 'n_words': 224}