<commit_before>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include "casn/casn.h"
#include "rpki-asn1/cms.h"
#include "rpki-asn1/crlv2.h"

static char *msgs[] = {
    "Usage: name of input file\n",
    "Suffix missing in %s\n",
    "Unknown type %s\n",
    "Error reading at %s\n",
};

void fatal(
    int err,
    char *param)
{
    fprintf(stderr, msgs[err], param);
    if (err)
        exit(err);
}

int main(
    int argc,
    char **argv)
{
    struct CMS cms;
    struct Certificate certificate;
    struct CertificateRevocationList crl;
    char *buf;
    int bsize;


    if (argc < 2)
        fatal(0, (char *)0);
    char *p = strrchr(argv[1], (int)'.');
    if (!p)
        fatal(1, (char *)0);
    if (!strcmp(p, ".cer"))
    {
        Certificate(&certificate, (ushort) 0);
        if (get_casn_file(&certificate.self, argv[1], 0) < 0)
            fatal(3, casn_err_struct.asn_map_string);
        bsize = dump_size(&certificate.self);
        buf = (char *)calloc(1, bsize + 8);
        dump_casn(&certificate.self, buf);
        printf("%s", buf);
        free(buf);
        delete_casn(&certificate.self);
    }
    else if (!strcmp(p, ".crl"))
    {
        CertificateRevocationList(&crl, (ushort) 0);
        if (get_casn_file(&crl.self, argv[1], 0) < 0)
            fatal(3, casn_err_struct.asn_map_string);
        bsize = dump_size(&crl.self);
        buf = (char *)calloc(1, bsize + 8);
        dump_casn(&crl.self, buf);
        printf("%s", buf);
        free(buf);
        delete_casn(&crl.self);
    }
    else if (!strcmp(p, ".man") || !strcmp(p, ".mft") || !strcmp(p, ".mnf") ||
             !strcmp(p, ".roa"))
    {
        CMS(&cms, (ushort) 0);
        if (get_casn_file(&cms.self, argv[1], 0) < 0)
            fatal(3, casn_err_struct.asn_map_string);
        bsize = dump_size(&cms.self);
        buf = (char *)calloc(1, bsize + 8);
        dump_casn(&cms.self, buf);
        printf("%s", buf);
        free(buf);
        delete_casn(&cms.self);
    }
    else
        fatal(2, p);
    return 0;
}
<commit_msg>support .gbr<commit_after>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include "casn/casn.h"
#include "rpki-asn1/cms.h"
#include "rpki-asn1/crlv2.h"

static char *msgs[] = {
    "Usage: name of input file\n",
    "Suffix missing in %s\n",
    "Unknown type %s\n",
    "Error reading at %s\n",
};

void fatal(
    int err,
    char *param)
{
    fprintf(stderr, msgs[err], param);
    if (err)
        exit(err);
}

int main(
    int argc,
    char **argv)
{
    struct CMS cms;
    struct Certificate certificate;
    struct CertificateRevocationList crl;
    char *buf;
    int bsize;


    if (argc < 2)
        fatal(0, (char *)0);
    char *p = strrchr(argv[1], (int)'.');
    if (!p)
        fatal(1, (char *)0);
    if (!strcmp(p, ".cer"))
    {
        Certificate(&certificate, (ushort) 0);
        if (get_casn_file(&certificate.self, argv[1], 0) < 0)
            fatal(3, casn_err_struct.asn_map_string);
        bsize = dump_size(&certificate.self);
        buf = (char *)calloc(1, bsize + 8);
        dump_casn(&certificate.self, buf);
        printf("%s", buf);
        free(buf);
        delete_casn(&certificate.self);
    }
    else if (!strcmp(p, ".crl"))
    {
        CertificateRevocationList(&crl, (ushort) 0);
        if (get_casn_file(&crl.self, argv[1], 0) < 0)
            fatal(3, casn_err_struct.asn_map_string);
        bsize = dump_size(&crl.self);
        buf = (char *)calloc(1, bsize + 8);
        dump_casn(&crl.self, buf);
        printf("%s", buf);
        free(buf);
        delete_casn(&crl.self);
    }
    else if (!strcmp(p, ".man") || !strcmp(p, ".mft") || !strcmp(p, ".mnf") ||
             !strcmp(p, ".roa") ||
             !strcmp(p, ".gbr"))
    {
        CMS(&cms, (ushort) 0);
        if (get_casn_file(&cms.self, argv[1], 0) < 0)
            fatal(3, casn_err_struct.asn_map_string);
        bsize = dump_size(&cms.self);
        buf = (char *)calloc(1, bsize + 8);
        dump_casn(&cms.self, buf);
        printf("%s", buf);
        free(buf);
        delete_casn(&cms.self);
    }
    else
        fatal(2, p);
    return 0;
}

{'fraction_non_alphanumeric': 0.17797017797017797, 'fraction_numerical': 0.015392015392015393, 'mean_word_length': 2.24921875, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, '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': '2932181', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1588, 'n_words': 341}