<commit_before>/* ozmhelper_main.cpp

Copyright (c) 2014, <NAME>. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

*/
#include <QCoreApplication>
#include <QString>
#include <QStringList>
#include <iostream>
#include <string.h>
#include <stdio.h>

#include "ozmhelper.h"

QString version = "v0.1";
QString appname = "OZMHelper";

void usageDsdt2Bios()
{
    printf("dsdt2bios command\n"
            " usage:\n"
            "\t%s --dsdt2bios -i AmiBoardInfo.bin -d DSDT.aml -o outputdir\n\n"
            " parameters:\n" \
            "\t-i, --input\t\tInput file (AmiBoardInfo)\n"
            "\t-d, --dsdt\t\tDSDT.aml file\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageFfsConvert()
{
    printf("ffsconvert command\n"
            " usage:\n"
            "\t%s --ffsconvert -o outputdir -i ffsdir\n\n"
            " parameters:\n"
            "\t-i, --input\t\tInput directory\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageOzmCreate()
{
    printf("ozmcreate command\n" \
            " usage:\n"
            "\t%s --ozmcreate -k kextdir -f ffsdir -d DSDT.aml -o outputdir -i BIOS.ROM\n\n"
            " parameters:\n"
            "\t-k, --kext [dir]\t\tKEXT directory\n"
            "\t-f, --ffs [dir]\t\tFFS directory (OZM files)\n"
            "\t-d, --dsdt [file]\t\tDSDT.aml file\n"
            "\t-i, --input\t\tInput file\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageOzmExtract()
{
    printf("ozmextract command\n"
            " usage:\n"
            "\t%s --ozmextract -o outputdir -i OZM.ROM\n\n"
            " parameters:\n"
            "\t-i, --input\t\tInput file\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageDSDTExtract()
{
    printf("dsdtextract command\n"
            " usage:\n"
            "\t%s --dsdtextract -o outputdir -i OZMBIOS_or_BIOS.ROM\n\n"
            " parameters:\n"
            "\t-i, --input\t\tInput file\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageGeneral()
{
    printf("Usage:\n" \
            "\t%s [COMMAND] [PARAMETERS...]\n\n"
            "Available commands:\n"
            "\t--dsdtextract\t\tExtracts DSDT from BIOS\n"
            "\t--ozmextract\t\tExtracts Ozmosis files (ffs) from BIOS\n"
            "\t--ozmcreate\t\tPatches Original BIOS with Ozmosis\n"
            "\t--ffsconvert\t\tConverts kext-directories to FFS\n"
            "\t--dsdt2bios\t\tInjects (bigger) DSDT into AmiBoardInfo\n"
            "\t--help, -h\t\tPrint this\n\n",qPrintable(appname));
}

void versionInfo()
{
    printf("%s - %s\n",qPrintable(appname), qPrintable(version));
}

void usageAll()
{
    usageGeneral();
    usageDSDTExtract();
    usageOzmExtract();
    usageOzmCreate();
    usageFfsConvert();
    usageDsdt2Bios();
}

int main(int argc, char *argv[])
{
    bool help = false;
    bool dsdtextract = false;
    bool ozmextract = false;
    bool ozmcreate = false;
    bool ffsconvert = false;
    bool dsdt2bios = false;
    QString inputpath = "";
    QString output = "";
    QString ffsdir = "";
    QString kextdir = "";
    QString dsdtfile = "";

    QCoreApplication a(argc, argv);
    a.setOrganizationName("CodeRush");
    a.setOrganizationDomain("coderush.me");
    a.setApplicationName("OZMHelper");

    OZMHelper w;
    UINT8 result = ERR_SUCCESS;


    if (argc == 1) {
        usageGeneral();
        printf("ERROR: No options supplied!\n");
        return ERR_GENERIC_CALL_NOT_SUPPORTED;
    }

    //
    // Parse command line
    //
    argc --;
    argv ++;


    if ((strcasecmp(argv[0], "-h") == 0) || (strcasecmp(argv[0], "--help") == 0)) {
        usageAll();
        return ERR_SUCCESS;
    }

    if (strcasecmp(argv[0], "--version") == 0) {
        versionInfo();
        return ERR_SUCCESS;
    }

    while (argc > 0) {

        if (strcasecmp(argv[0], "--dsdtextract") == 0) {
            dsdtextract = true;
            argc --;
            argv ++;
            continue;
        }

        if (strcasecmp(argv[0], "--ozmextract") == 0) {
            ozmextract = true;
            argc --;
            argv ++;
            continue;
        }

        if (strcasecmp(argv[0], "--ozmcreate") == 0) {
            ozmcreate = true;
            argc --;
            argv ++;
            continue;
        }

        if (strcasecmp(argv[0], "--ffsconvert") == 0) {
            ffsconvert = true;
            argc --;
            argv ++;
            continue;
        }

        if (strcasecmp(argv[0], "--dsdt2bios") == 0) {
            ffsconvert = true;
            argc --;
            argv ++;
            continue;
        }

        if ((strcasecmp(argv[0], "-f") == 0) || (strcasecmp(argv[0], "--ffs") == 0)) {
            if (argv[1] == NULL || argv[1][0] == '-') {
                printf("Invalid option value\n"
                       "Input FFS directory is missing for -f option\n");
                goto fail;
            }
            ffsdir = argv[1];
            argc -= 2;
            argv += 2;
            continue;
        }

        if ((strcasecmp(argv[0], "-k") == 0) || (strcasecmp(argv[0], "--kext") == 0)) {<commit_msg>oops.. again -_-<commit_after>/* ozmhelper_main.cpp

Copyright (c) 2014, <NAME>. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

*/
#include <QCoreApplication>
#include <QString>
#include <QStringList>
#include <iostream>
#include <string.h>
#include <stdio.h>

#include "ozmhelper.h"

QString version = "v0.1";
QString appname = "OZMHelper";

void usageDsdt2Bios()
{
    printf("dsdt2bios command\n"
            " usage:\n"
            "\t%s --dsdt2bios -i AmiBoardInfo.bin -d DSDT.aml -o outputdir\n\n"
            " parameters:\n" \
            "\t-i, --input\t\tInput file (AmiBoardInfo)\n"
            "\t-d, --dsdt\t\tDSDT.aml file\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageFfsConvert()
{
    printf("ffsconvert command\n"
            " usage:\n"
            "\t%s --ffsconvert -o outputdir -i ffsdir\n\n"
            " parameters:\n"
            "\t-i, --input\t\tInput directory\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageOzmCreate()
{
    printf("ozmcreate command\n" \
            " usage:\n"
            "\t%s --ozmcreate -k kextdir -f ffsdir -d DSDT.aml -o outputdir -i BIOS.ROM\n\n"
            " parameters:\n"
            "\t-k, --kext [dir]\t\tKEXT directory\n"
            "\t-f, --ffs [dir]\t\tFFS directory (OZM files)\n"
            "\t-d, --dsdt [file]\t\tDSDT.aml file\n"
            "\t-i, --input\t\tInput file\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageOzmExtract()
{
    printf("ozmextract command\n"
            " usage:\n"
            "\t%s --ozmextract -o outputdir -i OZM.ROM\n\n"
            " parameters:\n"
            "\t-i, --input\t\tInput file\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageDSDTExtract()
{
    printf("dsdtextract command\n"
            " usage:\n"
            "\t%s --dsdtextract -o outputdir -i OZMBIOS_or_BIOS.ROM\n\n"
            " parameters:\n"
            "\t-i, --input\t\tInput file\n"
            "\t-o, --out [dir]\t\tOutput directory\n"
            "\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
}

void usageGeneral()
{
    printf("Usage:\n" \
            "\t%s [COMMAND] [PARAMETERS...]\n\n"
            "Available commands:\n"
            "\t--dsdtextract\t\tExtracts DSDT from BIOS\n"
            "\t--ozmextract\t\tExtracts Ozmosis files (ffs) from BIOS\n"
            "\t--ozmcreate\t\tPatches Original BIOS with Ozmosis\n"
            "\t--ffsconvert\t\tConverts kext-directories to FFS\n"
            "\t--dsdt2bios\t\tInjects (bigger) DSDT into AmiBoardInfo\n"
            "\t--help, -h\t\tPrint this\n\n",qPrintable(appname));
}

void versionInfo()
{
    printf("%s - %s\n",qPrintable(appname), qPrintable(version));
}

void usageAll()
{
    usageGeneral();
    usageDSDTExtract();
    usageOzmExtract();
    usageOzmCreate();
    usageFfsConvert();
    usageDsdt2Bios();
}

int main(int argc, char *argv[])
{
    bool help = false;
    bool dsdtextract = false;
    bool ozmextract = false;
    bool ozmcreate = false;
    bool ffsconvert = false;
    bool dsdt2bios = false;
    QString inputpath = "";
    QString output = "";
    QString ffsdir = "";
    QString kextdir = "";
    QString dsdtfile = "";

    QCoreApplication a(argc, argv);
    a.setOrganizationName("CodeRush");
    a.setOrganizationDomain("coderush.me");
    a.setApplicationName("OZMHelper");

    OZMHelper w;
    UINT8 result = ERR_SUCCESS;


    if (argc == 1) {
        usageGeneral();
        printf("ERROR: No options supplied!\n");
        return ERR_GENERIC_CALL_NOT_SUPPORTED;
    }

    //
    // Parse command line
    //
    argc --;
    argv ++;


    if ((strcasecmp(argv[0], "-h") == 0) || (strcasecmp(argv[0], "--help") == 0)) {
        usageAll();
        return ERR_SUCCESS;
    }

    if (strcasecmp(argv[0], "--version") == 0) {
        versionInfo();
        return ERR_SUCCESS;
    }

    while (argc > 0) {

        if (strcasecmp(argv[0], "--dsdtextract") == 0) {
            dsdtextract = true;
            argc --;
            argv ++;
            continue;
        }

        if (strcasecmp(argv[0], "--ozmextract") == 0) {
            ozmextract = true;
            argc --;
            argv ++;
            continue;
        }

        if (strcasecmp(argv[0], "--ozmcreate") == 0) {
            ozmcreate = true;
            argc --;
            argv ++;
            continue;
        }

        if (strcasecmp(argv[0], "--ffsconvert") == 0) {
            ffsconvert = true;
            argc --;
            argv ++;
            continue;
        }

        if (strcasecmp(argv[0], "--dsdt2bios") == 0) {
            dsdt2bios = true;
            argc --;
            argv ++;
            continue;
        }

        if ((strcasecmp(argv[0], "-f") == 0) || (strcasecmp(argv[0], "--ffs") == 0)) {
            if (argv[1] == NULL || argv[1][0] == '-') {
                printf("Invalid option value\n"
                       "Input FFS directory is missing for -f option\n");
                goto fail;
            }
            ffsdir = argv[1];
            argc -= 2;
            argv += 2;
            continue;
        }

        if ((strcasecmp(argv[0], "-k") == 0) || (strcasecmp(argv[0], "--kext") == 0)) {
{'fraction_non_alphanumeric': 0.16273504273504275, 'fraction_numerical': 0.007948717948717949, 'mean_word_length': 1.7826397146254458, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '1852455', 'n_tokens_mistral': 4139, 'n_tokens_neox': 4087, 'n_words': 870}