Initial source code.

main
Nichole Mattera 14 years ago
commit 7fe506355f
  1. 59
      JALOG_CONV.dev
  2. BIN
      JALOG_CONV.ico
  3. 23
      JALOG_CONV_private.h
  4. 37
      JALOG_CONV_private.rc
  5. BIN
      JALOG_CONV_private.res
  6. 33
      Makefile.win
  7. 208
      main.c

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@ -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*/

@ -0,0 +1,37 @@
/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */
/* DO NOT EDIT! */
#include <windows.h> // 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
}
}

Binary file not shown.

@ -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

208
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 <stevenmattera@gmail.com>
//
// 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <unistd.h>
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 <stevenmattera@gmail.com>\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 <PATH_TO_LOG>\n");
system("pause");
return -1;
}
logFile = openLogFile(argv[1]);
if (logFile == NULL) return -1;
convFile = openConvFile(argv);
if (convFile == NULL) return -1;
fputs("<HTML>\n<BODY BGCOLOR='GRAY'>\n<FONT COLOR='WHITE'>", 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("</FONT><FONT COLOR='WHITE'>", 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("</FONT><FONT COLOR='RED'>", convFile);
}
break;
case 2:
if(color != 2) {
color = 2;
fputs("</FONT><FONT COLOR='GREEN'>", convFile);
}
break;
case 3:
if(color != 3) {
color = 3;
fputs("</FONT><FONT COLOR='YELLOW'>", convFile);
}
break;
case 4:
if(color != 4) {
color = 4;
fputs("</FONT><FONT COLOR='BLUE'>", convFile);
}
break;
case 5:
if(color != 5) {
color = 5;
fputs("</FONT><FONT COLOR='CYAN'>", convFile);
}
break;
case 6:
if(color != 6) {
color = 6;
fputs("</FONT><FONT COLOR='PURPLE'>", convFile);
}
break;
case 7:
if(color != 7) {
color = 7;
fputs("</FONT><FONT COLOR='WHITE'>", convFile);
}
break;
case 0:
if(color != 8) {
color = 8;
fputs("</FONT><FONT COLOR='BLACK'>", convFile);
}
break;
default:
fputc('^', convFile);
fputc(line[n+1], convFile);
break;
}
n++;
}
else if (line[n] == ':' && color != 7) {
fputs("</FONT><FONT COLOR='WHITE'>", convFile);
fputc(':', convFile);
}
else if (line[n] == '\\' && color != 7) {
fputs("</FONT><FONT COLOR='WHITE'>", 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("</FONT><FONT COLOR='WHITE'>", convFile);
fputc(' ', convFile);
}
else if (line[n] == ' ' && line[n+1] == 'b' && line[n+2] == 'y' && line[n+3] == ' ' && color != 7) {
fputs("</FONT><FONT COLOR='WHITE'>", convFile);
fputc(' ', convFile);
}
else {
fputc(line[n], convFile);
}
}
fputs("<BR>\n", convFile);
free(line);
}
fputs("</BODY>\n", convFile);
fputs("</HTML>", 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;
}
Loading…
Cancel
Save