commit 7fe506355fbe4e0bc1daab98504866f0fb8294d1 Author: Nichole Mattera Date: Wed Sep 1 11:22:13 2010 +0000 Initial source code. diff --git a/JALOG_CONV.dev b/JALOG_CONV.dev new file mode 100644 index 0000000..5cbfb66 --- /dev/null +++ b/JALOG_CONV.dev @@ -0,0 +1,59 @@ +[Project] +FileName=JALOG_CONV.dev +Name=JALOG_CONV +UnitCount=1 +Type=1 +Ver=1 +ObjFiles= +Includes= +Libs= +PrivateResource=JALOG_CONV_private.rc +ResourceIncludes= +MakeIncludes= +Compiler=-D_GNU_SOURCE_@@_ +CppCompiler= +Linker=-D_GNU_SOURCE_@@_ +IsCpp=0 +Icon=JALOG_CONV.ico +ExeOutput= +ObjectOutput= +OverrideOutput=1 +OverrideOutputName=JALOG_CONV.EXE +HostApplication= +Folders= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=1 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000000000000000 + +[Unit1] +FileName=main.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=1 +Minor=0 +Release=0 +Build=84 +LanguageID=1033 +CharsetID=1252 +CompanyName=Steven Mattera +FileVersion=1.0 +FileDescription= +InternalName= +LegalCopyright=Copyright 2010 Steven Mattera. All Rights Reserved. +LegalTrademarks= +OriginalFilename=JALOG_CONV.EXE +ProductName=Jedi Academy Server Log Converter +ProductVersion=1.0 +AutoIncBuildNr=1 + diff --git a/JALOG_CONV.ico b/JALOG_CONV.ico new file mode 100644 index 0000000..7d9af9f Binary files /dev/null and b/JALOG_CONV.ico differ diff --git a/JALOG_CONV_private.h b/JALOG_CONV_private.h new file mode 100644 index 0000000..0ff6756 --- /dev/null +++ b/JALOG_CONV_private.h @@ -0,0 +1,23 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT ! */ + +#ifndef JALOG_CONV_PRIVATE_H +#define JALOG_CONV_PRIVATE_H + +/* VERSION DEFINITIONS */ +#define VER_STRING "1.0.0.84" +#define VER_MAJOR 1 +#define VER_MINOR 0 +#define VER_RELEASE 0 +#define VER_BUILD 84 +#define COMPANY_NAME "Steven Mattera" +#define FILE_VERSION "1.0" +#define FILE_DESCRIPTION "" +#define INTERNAL_NAME "" +#define LEGAL_COPYRIGHT "Copyright 2010 Steven Mattera. All Rights Reserved." +#define LEGAL_TRADEMARKS "" +#define ORIGINAL_FILENAME "JALOG_CONV.EXE" +#define PRODUCT_NAME "Jedi Academy Server Log Converter" +#define PRODUCT_VERSION "1.0" + +#endif /*JALOG_CONV_PRIVATE_H*/ diff --git a/JALOG_CONV_private.rc b/JALOG_CONV_private.rc new file mode 100644 index 0000000..fde3c07 --- /dev/null +++ b/JALOG_CONV_private.rc @@ -0,0 +1,37 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT! */ + +#include // include for version info constants + + +A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JALOG_CONV.ico" + +// +// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... +// +1 VERSIONINFO +FILEVERSION 1,0,0,84 +PRODUCTVERSION 1,0,0,84 +FILETYPE VFT_APP +{ + BLOCK "StringFileInfo" + { + BLOCK "040904E4" + { + VALUE "CompanyName", "Steven Mattera" + VALUE "FileVersion", "1.0" + VALUE "FileDescription", "" + VALUE "InternalName", "" + VALUE "LegalCopyright", "Copyright 2010 Steven Mattera. All Rights Reserved." + VALUE "LegalTrademarks", "" + VALUE "OriginalFilename", "JALOG_CONV.EXE" + VALUE "ProductName", "Jedi Academy Server Log Converter" + VALUE "ProductVersion", "1.0" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 1252 + } +} + diff --git a/JALOG_CONV_private.res b/JALOG_CONV_private.res new file mode 100644 index 0000000..6b4a205 Binary files /dev/null and b/JALOG_CONV_private.res differ diff --git a/Makefile.win b/Makefile.win new file mode 100644 index 0000000..13b6d85 --- /dev/null +++ b/Makefile.win @@ -0,0 +1,33 @@ +# Project: JALOG_CONV +# Makefile created by Dev-C++ 4.9.9.2 + +CPP = g++.exe +CC = gcc.exe +WINDRES = windres.exe +RES = JALOG_CONV_private.res +OBJ = main.o $(RES) +LINKOBJ = main.o $(RES) +LIBS = -L"C:/Dev-Cpp/lib" -D_GNU_SOURCE +INCS = -I"C:/Dev-Cpp/include" +CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" +BIN = JALOG_CONV.EXE +CXXFLAGS = $(CXXINCS) +CFLAGS = $(INCS) -D_GNU_SOURCE +RM = rm -f + +.PHONY: all all-before all-after clean clean-custom + +all: all-before JALOG_CONV.EXE all-after + + +clean: clean-custom + ${RM} $(OBJ) $(BIN) + +$(BIN): $(OBJ) + $(CC) $(LINKOBJ) -o "JALOG_CONV.EXE" $(LIBS) + +main.o: main.c + $(CC) -c main.c -o main.o $(CFLAGS) + +JALOG_CONV_private.res: JALOG_CONV_private.rc + $(WINDRES) -i JALOG_CONV_private.rc --input-format=rc -o JALOG_CONV_private.res -O coff diff --git a/main.c b/main.c new file mode 100644 index 0000000..e44a653 --- /dev/null +++ b/main.c @@ -0,0 +1,208 @@ +// main.c +// Jedi Academy Server Log Converter - Version 1.0 +// +// Created By Steven Mattera on August 30th 2010. +// Copyright (c) 2010 Steven Mattera +// +// Jedi Academy Server Log Converter is free software; you can +// redistribute it and/or modify it under the terms of the GNU General +// Public License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// Jedi Academy Server Log Converter is distributed in the hope that it +// will be useful, but WITHOUT ANY WARRENTY; without even the implied +// warrenty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more deails. +// +// You should have received a copy of the GNU General Public License +// along with Jedi Academy Server Log Converter; if not, write to the Free +// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +// USA +// + +#include +#include +#include +#include +#include + +FILE * openLogFile(char *path); +FILE * openConvFile(char *argv[]); + +int main(int argc, char *argv[]) { + FILE * logFile; + FILE * convFile; + + printf("Jedi Academy Server Log Converter\n"); + printf("Copyright (c) 2010 Steven Mattera \n\n"); + printf("Jedi Academy Server Log Converter is free software; you can redistribute it\n"); + printf("and/or modify it under the terms of the GNU General Public License as published\n"); + printf("by the Free Software Foundation; either version 2 of the License, or (at your\n"); + printf("option) any later version.\n\n"); + printf("Jedi Academy Server Log Converter is distributed in the hope that it will be\n"); + printf("useful, but WITHOUT ANY WARRENTY; without even the implied warrenty of \n"); + printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public\n"); + printf("License for more deails.\n\n"); + printf("You should have received a copy of the GNU General Public License along with\n"); + printf("Jedi Academy Server Log Converter; if not, write to the Free Software\n"); + printf("Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n\n"); + + if(argc != 2) { + printf("Usage: JALOG_CONV.EXE \n"); + system("pause"); + + return -1; + } + + logFile = openLogFile(argv[1]); + if (logFile == NULL) return -1; + + convFile = openConvFile(argv); + if (convFile == NULL) return -1; + + fputs("\n\n", convFile); + + char * line; + char * lineProcessing; + char * convLine; + size_t currentPosition; + int color = 7; + + while(!feof(logFile)) { + line = (char *)malloc(sizeof(char)*512); + memset(line, '\0', sizeof(char)*512); + + fgets(line, 512, logFile); + if(color != 7) { + fputs("", convFile); + color = 7; + } + + int n; + for (n = 0; n < strlen(line); n++) { + if(line[n] == '^') { + switch (atoi(&line[n+1])) { + case 1: + if(color != 1) { + color = 1; + fputs("", convFile); + } + break; + case 2: + if(color != 2) { + color = 2; + fputs("", convFile); + } + break; + case 3: + if(color != 3) { + color = 3; + fputs("", convFile); + } + break; + case 4: + if(color != 4) { + color = 4; + fputs("", convFile); + } + break; + case 5: + if(color != 5) { + color = 5; + fputs("", convFile); + } + break; + case 6: + if(color != 6) { + color = 6; + fputs("", convFile); + } + break; + case 7: + if(color != 7) { + color = 7; + fputs("", convFile); + } + break; + case 0: + if(color != 8) { + color = 8; + fputs("", convFile); + } + break; + default: + fputc('^', convFile); + fputc(line[n+1], convFile); + break; + } + n++; + } + else if (line[n] == ':' && color != 7) { + fputs("", convFile); + fputc(':', convFile); + } + else if (line[n] == '\\' && color != 7) { + fputs("", convFile); + fputc('\\', convFile); + } + else if (line[n] == ' ' && line[n+1] == 'k' && line[n+2] == 'i' && line[n+3] == 'l' && line[n+4] == 'l' && line[n+5] == 'e' && line[n+6] == 'd' && line[n+7] == ' ' && color != 7) { + fputs("", convFile); + fputc(' ', convFile); + } + else if (line[n] == ' ' && line[n+1] == 'b' && line[n+2] == 'y' && line[n+3] == ' ' && color != 7) { + fputs("", convFile); + fputc(' ', convFile); + } + else { + fputc(line[n], convFile); + } + } + + fputs("
\n", convFile); + + free(line); + } + + fputs("\n", convFile); + fputs("", convFile); + + fclose(convFile); + fclose(logFile); + + return 0; +} + +FILE * openLogFile(char *path) { + FILE * logFile = fopen(path, "r"); + + if(logFile == NULL) { + printf("Error: Opening reading stream.\n\n"); + system("pause"); + + return NULL; + } + + return logFile; +} + +FILE * openConvFile(char *argv[]) { + char abs_exe_path[MAX_PATH]; + + char * pch = strrchr(argv[0],'\\'); + strncpy(abs_exe_path, argv[0], pch-argv[0]+1); + free(pch); + + char convPath[PATH_MAX]; + sprintf(convPath, "%sJALOG_CONV.HTML", abs_exe_path); + FILE * convFile = fopen(convPath, "w+"); + + + if(convFile == NULL) { + printf("Error: Opening writing stream.\n\n"); + system("pause"); + + return NULL; + } + + return convFile; +}