#include "Command_Solve.hpp"
#include "DLT_Utilities.hpp"

extern "C"
{
#include "windows.h"
#include "CSV_Utilities.hpp"
}

DLT_Log File;

// 命令行处理
void Pre_Command_Solve(void)
{
    // 获取命令行
    int argc;
    LPWSTR *argv;
    argv = CommandLineToArgvW(GetCommandLineW(), &argc);

    if (argc <= 1)
        return;

    DLT_Type::DLT_Err err;

    int size_needed = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
    char *strTo = (char *)malloc(size_needed);
    WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, &strTo[0], size_needed, NULL, NULL);

    err = File.load_from_file(strTo);

    DLT_Type::DLT_Msg_Node *p_list;
    File.get_msg_list(p_list);

    free(strTo);

    err = File.export_to_csv("test.csv");

    if (err == DLT_Type::DLT_ERROR_NONE)
        return;
}