From 0fee3572372e91caa6c2307a2c770871bd41b7a2 Mon Sep 17 00:00:00 2001 From: Nichole Mattera Date: Tue, 14 Sep 2010 20:53:34 +0000 Subject: [PATCH] --- JALOG_CONV.dev | 47 +++- JALOG_CONV_private.h | 10 +- JALOG_CONV_private.rc | 11 +- JALOG_CONV_private.res | Bin 5358 -> 0 bytes Makefile.win | 14 +- main.c | 590 +++++++++++++++++++++++++++++------------ resource.h | 23 ++ resource.rc | 25 ++ 8 files changed, 512 insertions(+), 208 deletions(-) delete mode 100644 JALOG_CONV_private.res mode change 100644 => 100755 main.c create mode 100644 resource.h create mode 100644 resource.rc diff --git a/JALOG_CONV.dev b/JALOG_CONV.dev index 5dd4f1e..b43c194 100644 --- a/JALOG_CONV.dev +++ b/JALOG_CONV.dev @@ -1,8 +1,8 @@ [Project] FileName=JALOG_CONV.dev Name=JALOG_CONV -UnitCount=1 -Type=1 +UnitCount=3 +Type=0 Ver=1 ObjFiles= Includes= @@ -10,15 +10,15 @@ Libs= PrivateResource=JALOG_CONV_private.rc ResourceIncludes= MakeIncludes= -Compiler=-D_GNU_SOURCE_@@_ +Compiler= CppCompiler= -Linker=-D_GNU_SOURCE_@@_ -IsCpp=0 -Icon=JALOG_CONV.ico +Linker= +IsCpp=1 +Icon= ExeOutput= ObjectOutput= -OverrideOutput=1 -OverrideOutputName=JALOG_CONV.EXE +OverrideOutput=0 +OverrideOutputName=JALOG_CONV.exe HostApplication= Folders= CommandLine= @@ -31,7 +31,7 @@ CompilerSettings=0000000000000000000000 [Unit1] FileName=main.c -CompileCpp=0 +CompileCpp=1 Folder= Compile=1 Link=1 @@ -40,20 +40,39 @@ OverrideBuildCmd=0 BuildCmd= [VersionInfo] -Major=1 -Minor=1 +Major=0 +Minor=2 Release=0 Build=89 LanguageID=1033 CharsetID=1252 CompanyName=Steven Mattera -FileVersion=1.0 +FileVersion=2.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 +ProductVersion=2.0 +AutoIncBuildNr=0 + +[Unit2] +FileName=resource.h +CompileCpp=1 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit3] +FileName=resource.rc +Folder=JALOG_CONV +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= diff --git a/JALOG_CONV_private.h b/JALOG_CONV_private.h index cbf1bf1..7862f2f 100644 --- a/JALOG_CONV_private.h +++ b/JALOG_CONV_private.h @@ -5,19 +5,19 @@ #define JALOG_CONV_PRIVATE_H /* VERSION DEFINITIONS */ -#define VER_STRING "1.1.0.89" -#define VER_MAJOR 1 -#define VER_MINOR 1 +#define VER_STRING "0.2.0.89" +#define VER_MAJOR 0 +#define VER_MINOR 2 #define VER_RELEASE 0 #define VER_BUILD 89 #define COMPANY_NAME "Steven Mattera" -#define FILE_VERSION "1.0" +#define FILE_VERSION "2.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" +#define PRODUCT_VERSION "2.0" #endif /*JALOG_CONV_PRIVATE_H*/ diff --git a/JALOG_CONV_private.rc b/JALOG_CONV_private.rc index c1c8080..2b03aa3 100644 --- a/JALOG_CONV_private.rc +++ b/JALOG_CONV_private.rc @@ -3,15 +3,14 @@ #include // include for version info constants - -A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JALOG_CONV.ico" +#include "resource.rc" // // TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... // 1 VERSIONINFO -FILEVERSION 1,1,0,89 -PRODUCTVERSION 1,1,0,89 +FILEVERSION 0,2,0,89 +PRODUCTVERSION 0,2,0,89 FILETYPE VFT_APP { BLOCK "StringFileInfo" @@ -19,14 +18,14 @@ FILETYPE VFT_APP BLOCK "040904E4" { VALUE "CompanyName", "Steven Mattera" - VALUE "FileVersion", "1.0" + VALUE "FileVersion", "2.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" + VALUE "ProductVersion", "2.0" } } BLOCK "VarFileInfo" diff --git a/JALOG_CONV_private.res b/JALOG_CONV_private.res deleted file mode 100644 index ed15ccfb49c68164618a0d84a0df7f1f2c1a2839..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5358 zcmd6r&1+m`6vofA1EEl21Q$|VgwjY63C+-rpwiM0ZHRVgWz?1ZifL(@hTJH&3+bYC zCF&}Ff|RaYbtjZ8U38U2DK1?KO1FyR@0@4unRjlIGVRKf%zNLD^FHS}&wK8jOj>_w9mT&GzzRcG&FBB-d}aPI0}@ zl}q8bC*pj_{2t~nY+G;HJ_7vao3J6i=Ks)i&O7HPVEniX&OZ%*&(ili+QolAi!D2D zZ*aZp2@UKnobK#kwZUCMR7jZ!4>2Y(DJa z!-w^H^ZI7kfddC{mOsw@et&g!_3v$_&49D1)9HYX^AG*&{r;Bx8K$v&yZ>Lm{uKVZ zHOgpmKed-w2XBO)+~1OC1`%8GeH2p?7H^DF-WW*tJ4wCT^;0S;{GDSXY) z;;&Nxd~U-7WoiNJO*+dTK#q@7!`X9GQZ?<|_3|CR&!+htm&on!c#NYuy2sGzO_Gy3S>C>l(zx9IphR%!B{WFg8 z4gQD^ro^X{M}Sa-fIL|sREfW%EIFC@U}B9U@No4h69RmG8~Trv1@!|svT(}iLo3rH z$i!6&ib5@A{qKekW@)AV>Jvh>N(#VYC`PT);S>@-rD$~0fewMT<1-`LI&Sq9WgPy( zr*)q77aEuu%g-Z3%Oha;LiovCLY3fBhS0+-I$gk(h4f+j^DSu$U#+JTB?>YYNqD1j zP5wMcxv80ChE?K1DffcF-V#=^^Je5TQSwjhhv-s1Be?0EC;IDABgvPl{oXMP#I0MXxM;{0I z&@yy{`p*gYqd)wmKRC)!2(+oTW)eTJ2RRB>l!VMo>R;-k0%o=3pRqDr365uG$HvqL zC^)0fmPPu79TkGWzhPHmIm5p56HGNWKgQe$tcvwsDCP z(zBE$qR1gt)%HX#(UN~oy8a=Nz)6AcG9ICxOFfSRZW!BhV*_9FIazwLF?9wOllT&? zQT*DNIRBSU%l6pRl>STcHw!JBp4Q0UEBL#RLwk?X_UycUL3_&1(K};j?PJDgXiw93 z`=$NozrNFdK4)BCV{y>%`eMZHdI0d&ZOyLPiYDWVGm@fx2j4Gg{$)v5#0;=Vy^f7i0afwb@_C>%~e% z^qcs*&Dku`%-)JjYQK~CRdzY}u7Wr8_dN&0*SRaw3bB?)SebnX`<5+$vlOeI!7AKc zfhD`jPK&HY=ccU#n>jwy&&_O>_2a}`=6Ws>s~9S+~56-Co diff --git a/Makefile.win b/Makefile.win index 13b6d85..dae1f83 100644 --- a/Makefile.win +++ b/Makefile.win @@ -7,27 +7,27 @@ 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 +LIBS = -L"C:/Dev-Cpp/lib" -mwindows 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 +BIN = JALOG_CONV.exe CXXFLAGS = $(CXXINCS) -CFLAGS = $(INCS) -D_GNU_SOURCE +CFLAGS = $(INCS) RM = rm -f .PHONY: all all-before all-after clean clean-custom -all: all-before JALOG_CONV.EXE all-after +all: all-before JALOG_CONV.exe all-after clean: clean-custom ${RM} $(OBJ) $(BIN) $(BIN): $(OBJ) - $(CC) $(LINKOBJ) -o "JALOG_CONV.EXE" $(LIBS) + $(CPP) $(LINKOBJ) -o "JALOG_CONV.exe" $(LIBS) main.o: main.c - $(CC) -c main.c -o main.o $(CFLAGS) + $(CPP) -c main.c -o main.o $(CXXFLAGS) -JALOG_CONV_private.res: JALOG_CONV_private.rc +JALOG_CONV_private.res: JALOG_CONV_private.rc resource.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 old mode 100644 new mode 100755 index 176b464..1d583e2 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ // main.c -// Jedi Academy Server Log Converter - Version 1.1 +// Jedi Academy Server Log Converter - Version 2.0 // // Created By Steven Mattera on August 30th 2010. // Copyright (c) 2010 Steven Mattera @@ -23,194 +23,432 @@ #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; - } +#include +#include "resource.h" + +enum { + ID_LOADEDIT = 1, + ID_LOADBUTTON, + ID_SAVEEDIT, + ID_SAVEBUTTON, + ID_CONVERTBUTTON +}; - logFile = openLogFile(argv[1]); - if (logFile == NULL) return -1; +LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + WNDCLASSEX wc; + MSG Msg; + HWND hwnd; - convFile = openConvFile(argv); - if (convFile == NULL) return -1; - - fputs("", convFile); + wc.cbSize = sizeof(WNDCLASSEX); + wc.style = 0; + wc.lpfnWndProc = WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON)); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); + wc.lpszMenuName = NULL; + wc.lpszClassName = "mainWindow"; + wc.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0); + + if (!RegisterClassEx(&wc)) { + MessageBox(NULL, "Window Registration Failed!", "Error", MB_ICONEXCLAMATION|MB_OK); + return 0; + } + + hwnd = CreateWindowEx(0, "mainWindow", "Jedi Academy Server Log Converter", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, (GetSystemMetrics(SM_CXSCREEN) - 500)/2, (GetSystemMetrics(SM_CYSCREEN) - 72)/2, 500, 100, NULL, NULL, hInstance, NULL); + + if (hwnd == NULL) { + MessageBox(NULL, "Window Creation Failed!", "Error", MB_ICONEXCLAMATION|MB_OK); + return 0; + } + + ShowWindow(hwnd, nCmdShow); + UpdateWindow(hwnd); + + MessageBox(hwnd, "Jedi Academy Server Log Converter\nCopyright (c) 2010 Steven Mattera \n\nJedi Academy Server Log Converter is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as published\nby the Free Software Foundation; either version 2 of the License, or (at your\noption) any later version.\n\nJedi Academy Server Log Converter is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRENTY; without even the implied warrenty of \nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public\nLicense for more deails.\n\nYou should have received a copy of the GNU General Public License along with\nJedi Academy Server Log Converter; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA", "Welcome to Jedi Academy Server Log Converter", MB_OK); + + while(GetMessage(&Msg, NULL, 0, 0) > 0) { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + + return Msg.wParam; +} - char * line; - char * lineProcessing; - char * convLine; - size_t currentPosition; - int color = 7; +LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + char szFileName[MAX_PATH] = ""; + OPENFILENAME ofn; - 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; - } + switch(msg) { + case WM_CREATE: + HFONT hfDefault; + HWND hLoadEdit; + HWND hLoadButton; + HWND hSaveEdit; + HWND hSaveButton; + HWND hConvertButton; - 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); - } + hLoadEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL, 10, 10, 300, 21, hwnd, (HMENU)ID_LOADEDIT, GetModuleHandle(NULL), NULL); + hLoadButton = CreateWindowEx(0, "BUTTON", "Input", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 320, 10, 70, 21, hwnd, (HMENU)ID_LOADBUTTON, GetModuleHandle(NULL), NULL); + hSaveEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL, 10, 41, 300, 21, hwnd, (HMENU)ID_SAVEEDIT, GetModuleHandle(NULL), NULL); + hSaveButton = CreateWindowEx(0, "BUTTON", "Output", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 320, 41, 70, 21, hwnd, (HMENU)ID_SAVEBUTTON, GetModuleHandle(NULL), NULL); + hConvertButton = CreateWindowEx(0, "BUTTON", "Convert", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 400, 10, 80, 52, hwnd, (HMENU)ID_CONVERTBUTTON, GetModuleHandle(NULL), NULL); + + hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + SendMessage(hLoadEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); + SendMessage(hLoadButton, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); + SendMessage(hSaveEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); + SendMessage(hSaveButton, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); + SendMessage(hConvertButton, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); + break; + case WM_CLOSE: + DestroyWindow(hwnd); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + case WM_COMMAND: + switch(wParam) { + case ID_LOADBUTTON: + ZeroMemory(&ofn, sizeof(ofn)); + + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "Log Files (*.log)\0*.log\0Log Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + ofn.lpstrDefExt = "log"; + + if(GetOpenFileName(&ofn)) { + HWND hLoadEdit = GetDlgItem(hwnd, ID_LOADEDIT); + SetWindowText(hLoadEdit, szFileName); + } + break; + case ID_SAVEBUTTON: + ZeroMemory(&ofn, sizeof(ofn)); + + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0RTF Files (*.rtf)\0*.rtf\0Text Files (*.txt)\0*.txt\0"; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + ofn.lpstrDefExt = "html"; + + if(GetSaveFileName(&ofn)) { + HWND hSaveEdit = GetDlgItem(hwnd, ID_SAVEEDIT); + SetWindowText(hSaveEdit, szFileName); + } + break; + case ID_CONVERTBUTTON: + HWND hLoadEdit = GetDlgItem(hwnd, ID_LOADEDIT); + HWND hLoadButton = GetDlgItem(hwnd, ID_LOADBUTTON); + HWND hSaveEdit = GetDlgItem(hwnd, ID_SAVEEDIT); + HWND hSaveButton = GetDlgItem(hwnd, ID_SAVEBUTTON); + + char loadFilename[MAX_PATH] = ""; + char saveFilename[MAX_PATH] = ""; + + FILE * loadFile, * saveFile; + + GetWindowText(hLoadEdit, loadFilename, MAX_PATH); + GetWindowText(hSaveEdit, saveFilename, MAX_PATH); + + if (strcmp(loadFilename, saveFilename) == 0) { + MessageBox(hwnd, "Can not overwrite input file with output file.", "Error", MB_ICONEXCLAMATION|MB_OK); break; - case 6: - if(color != 6) { - color = 6; - fputs("", convFile); - } + } + + loadFile = fopen(loadFilename, "r"); + if (loadFile == NULL) { + MessageBox(hwnd, "Opening file stream.", "Error", MB_ICONEXCLAMATION|MB_OK); break; - case 7: - if(color != 7) { - color = 7; - fputs("", convFile); - } + } + + saveFile = fopen(saveFilename, "w+"); + if (saveFile == NULL) { + MessageBox(hwnd, "Opening file stream.", "Error", MB_ICONEXCLAMATION|MB_OK); + fclose(loadFile); break; - case 0: - if(color != 8) { - color = 8; - fputs("", convFile); + } + + char * saveFileExt = strrchr(saveFilename,'.'); + char * line; + int color = 7; + + if (strcmp(saveFileExt, ".html") == 0) { + fputs("", saveFile); + + while (!feof(loadFile)) { + line = (char *)malloc(sizeof(char)*512); + memset(line, '\0', sizeof(char)*512); + + fgets(line, 512, loadFile); + if(color != 7) { + fputs("", saveFile); + 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("", saveFile); + } + break; + case 2: + if(color != 2) { + color = 2; + fputs("", saveFile); + } + break; + case 3: + if(color != 3) { + color = 3; + fputs("", saveFile); + } + break; + case 4: + if(color != 4) { + color = 4; + fputs("", saveFile); + } + break; + case 5: + if(color != 5) { + color = 5; + fputs("", saveFile); + } + break; + case 6: + if(color != 6) { + color = 6; + fputs("", saveFile); + } + break; + case 7: + if(color != 7) { + color = 7; + fputs("", saveFile); + } + break; + case 0: + if(color != 8) { + color = 8; + fputs("", saveFile); + } + break; + default: + fputc('^', saveFile); + fputc(line[n+1], saveFile); + break; + } + n++; + } + else if (line[n] == ':' && color != 7) { + fputs("", saveFile); + fputc(':', saveFile); + } + else if (line[n] == '\\' && color != 7) { + fputs("", saveFile); + fputc('\\', saveFile); + } + 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("", saveFile); + fputc(' ', saveFile); + } + else if (line[n] == ' ' && line[n+1] == 'b' && line[n+2] == 'y' && line[n+3] == ' ' && color != 7) { + fputs("", saveFile); + fputc(' ', saveFile); + } + else if (line[n] == '<') { + fputs("<", saveFile); + } + else if (line[n] == '>') { + fputs(">", saveFile); + } + else if (line[n] == '&') { + fputs("&", saveFile); + } + else if (line[n] != '\n' && line[n] != '\r') { + fputc(line[n], saveFile); + } + } + + fputs("
", saveFile); + + free(line); } - 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 if (line[n] == '<') { - fputs("<", convFile); - } - else if (line[n] == '>') { - fputs(">", convFile); - } - else if (line[n] == '&') { - fputs("&", convFile); - } - else if (line[n] != '\n' || line[n] != '\r') { - fputc(line[n], convFile); - } - } - - fputs("
", convFile); - - free(line); - } - - fputs("", convFile); + + fputs("", saveFile); + } + else if (strcmp(saveFileExt, ".rtf") == 0) { + fputs("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red255\\green255\\blue0;\\red0\\green0\\blue255;\\red255\\green0\\blue255;\\red0\\green255\\blue255;\\red255\\green255\\blue255;}\\margl1440\\margr1440\\vieww9000\\viewh8400\\viewkind0{\\*\\background {\\shp{\\*\\shpinst\\shpleft0\\shptop0\\shpright0\\shpbottom0\\shpfhdr0\\shpbxmargin\\shpbymargin\\shpwr0\\shpwrk0\\shpfblwtxt1\\shpz0\\shplid1025{\\sp{\\sn shapeType}{\\sv 1}}{\\sp{\\sn fFlipH}{\\sv 0}}{\\sp{\\sn fFlipV}{\\sv 0}}{\\sp{\\sn fillColor}{\\sv 12237498}}{\\sp{\\sn fFilled}{\\sv 1}}{\\sp{\\sn lineWidth}{\\sv 0}}{\\sp{\\sn fLine}{\\sv 0}}{\\sp{\\sn bWMode}{\\sv 9}}{\\sp{\\sn fBackground}{\\sv 1}}}}}\\pard\\tx720\\tx1440\\tx2160\\tx2880\\tx3600\\tx4320\\tx5040\\tx5760\\tx6480\\tx7200\\tx7920\\tx8640\\ql\\qnatural\\pardirnatural\\f0\\cf7 ", saveFile); - fclose(convFile); - fclose(logFile); - - return 0; -} + while (!feof(loadFile)) { + line = (char *)malloc(sizeof(char)*512); + memset(line, '\0', sizeof(char)*512); + + fgets(line, 512, loadFile); + if(color != 7) { + fputs("\\cf7 ", saveFile); + 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("\\cf1 ", saveFile); + } + break; + case 2: + if(color != 2) { + color = 2; + fputs("\\cf2 ", saveFile); + } + break; + case 3: + if(color != 3) { + color = 3; + fputs("\\cf3 ", saveFile); + } + break; + case 4: + if(color != 4) { + color = 4; + fputs("\\cf4 ", saveFile); + } + break; + case 5: + if(color != 5) { + color = 5; + fputs("\\cf5 ", saveFile); + } + break; + case 6: + if(color != 6) { + color = 6; + fputs("\\cf6 ", saveFile); + } + break; + case 7: + if(color != 7) { + color = 7; + fputs("\\cf7 ", saveFile); + } + break; + case 0: + if(color != 8) { + color = 8; + fputs("\\cf8 ", saveFile); + } + break; + default: + fputc('^', saveFile); + fputc(line[n+1], saveFile); + break; + } + n++; + } + else if (line[n] == ':' && color != 7) { + fputs("\\cf7 ", saveFile); + fputc(':', saveFile); + } + else if (line[n] == '\\') { + if (color != 7) fputs("\\cf7 \\\\", saveFile); + else fputs("\\\\", saveFile); + } + 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("\\cf7 ", saveFile); + } + else if (line[n] == ' ' && line[n+1] == 'b' && line[n+2] == 'y' && line[n+3] == ' ' && color != 7) { + fputs("\\cf7 ", saveFile); + } + else if (line[n] != '\n' && line[n] != '\r') { + fputc(line[n], saveFile); + } + } + + fputs("\\par ", saveFile); + + free(line); + } + + fputs("}", saveFile); + } + else { + while (!feof(loadFile)) { + line = (char *)malloc(sizeof(char)*513); + memset(line, '\0', sizeof(char)*513); + fgets(line, 512, loadFile); + + int n; + for (n = 0; n < strlen(line); n++) { + if(line[n] == '^') { + switch (atoi(&line[n+1])) { + case 1: + //Skip and don't put anything. + break; + case 2: + //Skip and don't put anything. + break; + case 3: + //Skip and don't put anything. + break; + case 4: + //Skip and don't put anything. + break; + case 5: + //Skip and don't put anything. + break; + case 6: + //Skip and don't put anything. + break; + case 7: + //Skip and don't put anything. + break; + case 0: + //Skip and don't put anything. + break; + default: + fputc('^', saveFile); + fputc(line[n+1], saveFile); + break; + } + n++; + } + else { + fputc(line[n], saveFile); + } + } -FILE * openLogFile(char *path) { - FILE * logFile = fopen(path, "r"); - - if(logFile == NULL) { - printf("Error: Opening reading stream.\n\n"); - system("pause"); - - return NULL; - } + free(line); + } + } - return logFile; -} + fclose(loadFile); + fclose(saveFile); -FILE * openConvFile(char *argv[]) { - char abs_exe_path[MAX_PATH]; + MessageBox(NULL, "Server log successfully converted.", "Conversion Complete", MB_ICONASTERISK|MB_OK); - 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; + break; + } + break; + default: + return DefWindowProc(hwnd, msg, wParam, lParam); } - - return convFile; + + return 0; } diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..3c450f8 --- /dev/null +++ b/resource.h @@ -0,0 +1,23 @@ +// resource.h +// Jedi Academy Server Log Converter - Version 2.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 +// + +#define IDI_MYICON 101 diff --git a/resource.rc b/resource.rc new file mode 100644 index 0000000..10a75ce --- /dev/null +++ b/resource.rc @@ -0,0 +1,25 @@ +// resource.rc +// Jedi Academy Server Log Converter - Version 2.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 "resource.h" + +IDI_MYICON ICON "JALOG_CONV.ico"