<commit_before>// External public includes
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>

// Public disir interface
#include <disir/disir.h>
#include <disir/context.h>

// Private
#include "context_private.h"
#include "config.h"
#include "section.h"
#include "keyval.h"
#include "log.h"
#include "mold.h"

static enum disir_status
get_value_input_check (struct disir_context *context, const char *type,
                       struct disir_value **storage)
{
    enum disir_status status;

    status = CONTEXT_NULL_INVALID_TYPE_CHECK (context);
    if (status != DISIR_STATUS_OK)
    {
        // Already logged
        return status;
    }

    status = CONTEXT_TYPE_CHECK (context, DISIR_CONTEXT_KEYVAL);
    if (status != DISIR_STATUS_OK)
    {
        // Already logged ?
        return status;
    }

    if (dc_context_type (context) == DISIR_CONTEXT_KEYVAL)
    {
        if (dc_context_type (context->cx_root_context) == DISIR_CONTEXT_MOLD)
        {
            dx_context_error_set (context,
                              "cannot get %s value on KEYVAL whose top-level is MOLD", type);
            return DISIR_STATUS_WRONG_CONTEXT;
        }
        if (context->cx_keyval->kv_mold_equiv == NULL)
        {
            dx_context_error_set (context,
                                  "cannot get value on context without a MOLD");
            return DISIR_STATUS_MOLD_MISSING;
        }

        *storage = &context->cx_keyval->kv_value;
    }
    else
    {
        dx_context_error_set (context, "Context %s slipped through guard. Not handled.",
                              dc_context_type_string (context));
        return DISIR_STATUS_INTERNAL_ERROR;
    }

    return DISIR_STATUS_OK;
}

static enum disir_status
set_value_input_check (struct disir_context *context, const char *type,<commit_msg>feat: get_value input check support default<commit_after>// External public includes
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>

// Public disir interface
#include <disir/disir.h>
#include <disir/context.h>

// Private
#include "context_private.h"
#include "config.h"
#include "section.h"
#include "keyval.h"
#include "log.h"
#include "mold.h"

static enum disir_status
get_value_input_check (struct disir_context *context, const char *type,
                       struct disir_value **storage)
{
    enum disir_status status;

    status = CONTEXT_NULL_INVALID_TYPE_CHECK (context);
    if (status != DISIR_STATUS_OK)
    {
        // Already logged
        return status;
    }

    status = CONTEXT_TYPE_CHECK (context, DISIR_CONTEXT_KEYVAL, DISIR_CONTEXT_DEFAULT);
    if (status != DISIR_STATUS_OK)
    {
        // Already logged ?
        return status;
    }

    if (dc_context_type (context) == DISIR_CONTEXT_KEYVAL)
    {
        if (dc_context_type (context->cx_root_context) == DISIR_CONTEXT_MOLD)
        {
            dx_context_error_set (context,
                              "cannot get %s value on KEYVAL whose top-level is MOLD", type);
            return DISIR_STATUS_WRONG_CONTEXT;
        }
        if (context->cx_keyval->kv_mold_equiv == NULL)
        {
            dx_context_error_set (context,
                                  "cannot get value on context without a MOLD");
            return DISIR_STATUS_MOLD_MISSING;
        }

        *storage = &context->cx_keyval->kv_value;
    }
    else if (dc_context_type (context) == DISIR_CONTEXT_DEFAULT)
    {
        *storage = &context->cx_default->de_value;
    }
    else
    {
        dx_context_error_set (context, "Context %s slipped through guard. Not handled.",
                              dc_context_type_string (context));
        return DISIR_STATUS_INTERNAL_ERROR;
    }

    return DISIR_STATUS_OK;
}

static enum disir_status
set_value_input_check (struct disir_context *context, const char *type,
{'fraction_non_alphanumeric': 0.09341935483870968, 'fraction_numerical': 0.0, 'mean_word_length': 2.4918918918918918, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1262245', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1206, 'n_words': 286}