mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 11:28:25 +00:00
Change space indentation to tabs
This commit is contained in:
+79
-81
@@ -12,7 +12,7 @@ using namespace std;
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#define strcasecmp _stricmp
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@@ -75,34 +75,34 @@ EQEMuLog::~EQEMuLog() {
|
||||
bool EQEMuLog::open(LogIDs id) {
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
LockMutex lock(&MOpen);
|
||||
if (pLogStatus[id] & 4) {
|
||||
return false;
|
||||
}
|
||||
if (fp[id]) {
|
||||
//cerr<<"Warning: LogFile already open"<<endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (fp[id]) {
|
||||
//cerr<<"Warning: LogFile already open"<<endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
char exename[200] = "";
|
||||
const EQEmuExePlatform &platform = GetExecutablePlatform();
|
||||
if(platform == ExePlatformWorld) {
|
||||
snprintf(exename, sizeof(exename), "_world");
|
||||
} else if(platform == ExePlatformZone) {
|
||||
snprintf(exename, sizeof(exename), "_zone");
|
||||
} else if(platform == ExePlatformLaunch) {
|
||||
snprintf(exename, sizeof(exename), "_launch");
|
||||
} else if(platform == ExePlatformUCS) {
|
||||
snprintf(exename, sizeof(exename), "_ucs");
|
||||
} else if(platform == ExePlatformQueryServ) {
|
||||
snprintf(exename, sizeof(exename), "_queryserv");
|
||||
} else if(platform == ExePlatformSharedMemory) {
|
||||
snprintf(exename, sizeof(exename), "_shared_memory");
|
||||
}
|
||||
const EQEmuExePlatform &platform = GetExecutablePlatform();
|
||||
if(platform == ExePlatformWorld) {
|
||||
snprintf(exename, sizeof(exename), "_world");
|
||||
} else if(platform == ExePlatformZone) {
|
||||
snprintf(exename, sizeof(exename), "_zone");
|
||||
} else if(platform == ExePlatformLaunch) {
|
||||
snprintf(exename, sizeof(exename), "_launch");
|
||||
} else if(platform == ExePlatformUCS) {
|
||||
snprintf(exename, sizeof(exename), "_ucs");
|
||||
} else if(platform == ExePlatformQueryServ) {
|
||||
snprintf(exename, sizeof(exename), "_queryserv");
|
||||
} else if(platform == ExePlatformSharedMemory) {
|
||||
snprintf(exename, sizeof(exename), "_shared_memory");
|
||||
}
|
||||
|
||||
char filename[200];
|
||||
#ifndef NO_PIDLOG
|
||||
@@ -110,24 +110,24 @@ bool EQEMuLog::open(LogIDs id) {
|
||||
#else
|
||||
snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename);
|
||||
#endif
|
||||
fp[id] = fopen(filename, "a");
|
||||
if (!fp[id]) {
|
||||
fp[id] = fopen(filename, "a");
|
||||
if (!fp[id]) {
|
||||
cerr << "Failed to open log file: " << filename << endl;
|
||||
pLogStatus[id] |= 4; // set file state to error
|
||||
return false;
|
||||
}
|
||||
fputs("---------------------------------------------\n",fp[id]);
|
||||
write(id, "Starting Log: %s", filename);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
fputs("---------------------------------------------\n",fp[id]);
|
||||
write(id, "Starting Log: %s", filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
@@ -138,13 +138,13 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
|
||||
if (!logFileValid)
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
if (dofile)
|
||||
if (dofile)
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#else
|
||||
@@ -162,7 +162,7 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
|
||||
va_copy(tmpargptr, argptr);
|
||||
p(id, fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] ", LogNames[id]);
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
@@ -173,9 +173,9 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
|
||||
}
|
||||
}
|
||||
va_end(argptr);
|
||||
if (dofile)
|
||||
if (dofile)
|
||||
fprintf(fp[id], "\n");
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
@@ -184,19 +184,19 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
//write with Prefix and a VA_list
|
||||
bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list argptr) {
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
@@ -208,15 +208,15 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
|
||||
if (!logFileValid)
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
va_list tmpargptr;
|
||||
|
||||
if (dofile) {
|
||||
if (dofile) {
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] %s", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
|
||||
#else
|
||||
@@ -224,13 +224,13 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
|
||||
#endif
|
||||
va_copy(tmpargptr, argptr);
|
||||
vfprintf( fp[id], fmt, tmpargptr );
|
||||
}
|
||||
}
|
||||
if(logCallbackPva[id]) {
|
||||
msgCallbackPva p = logCallbackPva[id];
|
||||
va_copy(tmpargptr, argptr);
|
||||
p(id, prefix, fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] %s", LogNames[id], prefix);
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
@@ -241,26 +241,26 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
|
||||
}
|
||||
}
|
||||
va_end(argptr);
|
||||
if (dofile)
|
||||
if (dofile)
|
||||
fprintf(fp[id], "\n");
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8)
|
||||
fprintf(stderr, "\n");
|
||||
else
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
@@ -271,13 +271,13 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
|
||||
if (!logFileValid)
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
if (dofile)
|
||||
if (dofile)
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#else
|
||||
@@ -292,7 +292,7 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
|
||||
msgCallbackBuf p = logCallbackBuf[id];
|
||||
p(id, buf, size, count);
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] ", LogNames[id]);
|
||||
fwrite(buf, size, count, stderr);
|
||||
@@ -303,9 +303,9 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
|
||||
@@ -315,23 +315,23 @@ bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
|
||||
va_copy(tmpargptr, argptr);
|
||||
vfprintf( fp[id], fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8)
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
else
|
||||
vfprintf( stdout, fmt, argptr );
|
||||
}
|
||||
va_end(argptr);
|
||||
return true;
|
||||
return true;
|
||||
};
|
||||
|
||||
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
|
||||
if (!logFileValid) {
|
||||
#if EQDEBUG >= 10
|
||||
cerr << "Error: Dump() from null pointer"<<endl;
|
||||
cerr << "Error: Dump() from null pointer"<<endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (size == 0)
|
||||
return true;
|
||||
if (!LogFile)
|
||||
@@ -352,7 +352,7 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
|
||||
// Output as HEX
|
||||
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
|
||||
uint32 i;
|
||||
for(i=skip; i<size; i++) {
|
||||
for(i=skip; i<size; i++) {
|
||||
if ((i-skip)%cols==0) {
|
||||
if (i != skip)
|
||||
writeNTS(id, dofile, " | %s\n", ascii);
|
||||
@@ -369,7 +369,7 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
|
||||
ascii[j++] = data[i];
|
||||
else
|
||||
ascii[j++] = '.';
|
||||
}
|
||||
}
|
||||
uint32 k = ((i-skip)-1)%cols;
|
||||
if (k < 8)
|
||||
writeNTS(id, dofile, " ");
|
||||
@@ -388,8 +388,8 @@ void EQEMuLog::SetCallback(LogIDs id, msgCallbackFmt proc) {
|
||||
return;
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackFmt[id] = proc;
|
||||
}
|
||||
logCallbackFmt[id] = proc;
|
||||
}
|
||||
|
||||
void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) {
|
||||
@@ -397,8 +397,8 @@ void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) {
|
||||
return;
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackBuf[id] = proc;
|
||||
}
|
||||
logCallbackBuf[id] = proc;
|
||||
}
|
||||
|
||||
void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) {
|
||||
@@ -406,8 +406,8 @@ void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) {
|
||||
return;
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackPva[id] = proc;
|
||||
}
|
||||
logCallbackPva[id] = proc;
|
||||
}
|
||||
|
||||
void EQEMuLog::SetAllCallbacks(msgCallbackFmt proc) {
|
||||
@@ -437,5 +437,3 @@ void EQEMuLog::SetAllCallbacks(msgCallbackPva proc) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user