From 22f71f5095f123f02c16a4e014f29a72151e433e Mon Sep 17 00:00:00 2001 From: Matias Israelson <57065102+israpps@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:06:00 -0300 Subject: [PATCH] refact --- .gitignore | 3 ++ .vscode/settings.json | 52 ++++++++++++++++++++++++++++++++++ exename.h | 25 ---------------- main.cpp | 61 ++++++++++++++++++++++++++++------------ shelteredsave2XML.depend | 35 ----------------------- shelteredsave2XML.layout | 20 ------------- 6 files changed, 98 insertions(+), 98 deletions(-) create mode 100644 .vscode/settings.json delete mode 100644 exename.h delete mode 100644 shelteredsave2XML.depend delete mode 100644 shelteredsave2XML.layout diff --git a/.gitignore b/.gitignore index a4fe19f..716a234 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ **.o **.obj **.res +*.depend +*.layout +/build diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0e0b9be --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,52 @@ +{ + "files.associations": { + "*.make": "makefile", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "ostream": "cpp", + "ranges": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "typeinfo": "cpp" + } +} \ No newline at end of file diff --git a/exename.h b/exename.h deleted file mode 100644 index e840f24..0000000 --- a/exename.h +++ /dev/null @@ -1,25 +0,0 @@ -/*************************************************************** - * Name: exename.h - * Purpose: generic functions to retireve program filename - * Author: matias israelson (aka: El_isra) (israelson-matias@hotmail.com) - * Created: 2021-03-31 - * Copyright: matias israelson (aka: El_isra) (https://github.com/israpps) - * License: GPL-3.0 - **************************************************************/ - - -#ifndef EXENAME_H_INCLUDED -#define EXENAME_H_INCLUDED -#include - std::string EXE_NAME (char* _argv0) - { - std::string temporary = _argv0; - return temporary.substr( temporary.find_last_of('\\')+ 1 ); - } - - std::string EXE_NAME (std::string _argv0) - { - return _argv0.substr(_argv0.find_last_of('\\') +1 ); - } - -#endif // EXENAME_H_INCLUDED diff --git a/main.cpp b/main.cpp index 3ed4307..d6b1762 100644 --- a/main.cpp +++ b/main.cpp @@ -22,53 +22,54 @@ #if defined(_WIN32) || defined(WIN32) #include #define PATHCOMP strcasecmp //windows is case insensitive! -#define COLOR(args) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),stoi(#args,0,16)); //pass a hex value between 00 and ff (or integer equivalent) +#define COLOR(args) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), std::stoi(#args,0,16)) //pass a hex value between 00 and ff (or integer equivalent) #else #define PATHCOMP strcmp -#define COLOR(args) +void COLOR(int arg); #endif uint8_t *buffer; std::string xor_data(uint8_t *buf, int size); int main(int argc, char* argv[]) { - COLOR(0f) + std::cout; + COLOR(0x0f); printf("Sheltered SaveFile Converter - By matias Israelson (AKA:El_isra)\n"); printf("Version [%s]\n",AutoVersion::FULLVERSION_STRING); - COLOR(07) - if(argc < 3) { - COLOR(0d) + COLOR(0x07); + if (argc < 3) { + COLOR(0x0d); fprintf(stderr, "Sintax errror.\n\tUsage: %s infile outfile\n",argv[0]); - COLOR(07) + COLOR(0x07); return 1; } - if (!PATHCOMP(argv[1], argv[2]) { + if (!PATHCOMP(argv[1], argv[2])) { fprintf(stderr, "error: input and output are the same!\n"); - return -1 + return -1; } - vector bytes; + std::vector bytes; - ifstream file1(argv[1], ios_base::in | ios_base::binary); + std::ifstream file1(argv[1], std::ios_base::in | std::ios_base::binary); if (!file1.is_open()) { - COLOR(0C) + COLOR(0x0C); fprintf(stderr, "Could not open %s for input\n", argv[1]); - COLOR(07) + COLOR(0x07); return 1; } - COLOR(07) + COLOR(0x07); while (file1.good()) { bytes.push_back(file1.get()); } size_t n = bytes.size(); uint8_t* buff = bytes.data(); - - std::ofstream out(argv[2], ios_base::binary); + printf("input file size: 0x%02lx", n); + std::ofstream out(argv[2], std::ios_base::binary); if (!out.is_open()) { - COLOR(0C) + COLOR(0x0C); fprintf(stderr, "Could not open %s for output\n", argv[2]); - COLOR(07) + COLOR(0x07); return 1; } out << xor_data(buff, n); @@ -90,3 +91,27 @@ std::string xor_data(uint8_t *buf,int size) } return output; } + + +#if defined(_WIN32) || defined(WIN32) +#else +void COLOR(int arg) { + switch (arg) + { + case 0x0F: + puts("\e[0;97m"); //strong white + break; + case 0x0D: + puts("\e[0;95m"); //strong magenta + break; + case 0x0C: + puts("\e[0;91m"); //strong red + break; + + case 0x07: + default: + puts("\e[0m"); + break; + } +} +#endif \ No newline at end of file diff --git a/shelteredsave2XML.depend b/shelteredsave2XML.depend deleted file mode 100644 index be6934b..0000000 --- a/shelteredsave2XML.depend +++ /dev/null @@ -1,35 +0,0 @@ -# depslib dependency file v1.0 -1628226885 source:d:\isr\shelteredsave2xml\main.cpp - - - - - - "exename.h" - -1628223245 d:\isr\shelteredsave2xml\exename.h - - -1628227221 source:d:\isr\shelteredsave2xml\pkg001.rc - "version.h" - -1628227104 d:\isr\shelteredsave2xml\version.h - -1628227221 source:d:\isr\isr_git\sheltered-save-converter\pkg001.rc - "version.h" - -1628230759 d:\isr\isr_git\sheltered-save-converter\version.h - -1628231120 source:d:\isr\isr_git\sheltered-save-converter\main.cpp - - - - - - - "exename.h" - "version.h" - -1628223245 d:\isr\isr_git\sheltered-save-converter\exename.h - - diff --git a/shelteredsave2XML.layout b/shelteredsave2XML.layout deleted file mode 100644 index 7ca5098..0000000 --- a/shelteredsave2XML.layout +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - -