add hex logging capability
r3755 | dcl | 2012-10-02 17:11:07 +1000 (Tue, 02 Oct 2012) | 1 line
This commit is contained in:
41
servlog.c
41
servlog.c
@@ -400,3 +400,44 @@ snprintf(fPath, 1023, "%s/", "../log");
|
|||||||
void SICSLogWrite(char *pText, OutCode eOut) {
|
void SICSLogWrite(char *pText, OutCode eOut) {
|
||||||
SICSLogWriteTime(pText, eOut, NULL);
|
SICSLogWriteTime(pText, eOut, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SICSLogWriteHexTime(const char* text, int count, OutCode eOut, struct timeval *tp) {
|
||||||
|
char hex[] = "0123456789ABCDEF";
|
||||||
|
char addr[20], left[80], right[80];
|
||||||
|
char *lp = left;
|
||||||
|
char *rp = right;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
if ((i & 0xF) == 0) {
|
||||||
|
if (i > 0) {
|
||||||
|
char line[132];
|
||||||
|
snprintf(line, sizeof(line)-1, "%-6s: %-49s | %-17s |", addr, left, right);
|
||||||
|
SICSLogWriteTime(line, eOut, tp);
|
||||||
|
}
|
||||||
|
snprintf(addr, sizeof(addr)-1, "%06x", i);
|
||||||
|
lp = left;
|
||||||
|
rp = right;
|
||||||
|
}
|
||||||
|
*lp++ = hex[(text[i] >> 4) & 0xF];
|
||||||
|
*lp++ = hex[(text[i]) & 0xF];
|
||||||
|
*lp++ = ' ';
|
||||||
|
if (text[i]>= ' ' && text[i] <= '~')
|
||||||
|
*rp++ = text[i];
|
||||||
|
else
|
||||||
|
*rp++ = '.';
|
||||||
|
if ((i & 0xF) == 8) {
|
||||||
|
*lp++ = ' ';
|
||||||
|
*rp++ = ' ';
|
||||||
|
}
|
||||||
|
*lp = *rp = '\0';
|
||||||
|
}
|
||||||
|
if (i > 0) {
|
||||||
|
char line[132];
|
||||||
|
snprintf(line, sizeof(line)-1, "%-6s: %-49s | %-17s |", addr, left, right);
|
||||||
|
SICSLogWriteTime(line, eOut, tp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SICSLogWriteHex(const char* text, int count, OutCode eOut) {
|
||||||
|
SICSLogWriteHexTime(text, count, eOut, NULL);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include "Scommon.h"
|
#include "Scommon.h"
|
||||||
void SICSLogWrite(char *ptext, OutCode eOut );
|
void SICSLogWrite(char *ptext, OutCode eOut );
|
||||||
void SICSLogWriteTime(char *ptext, OutCode eOut, struct timeval *tp );
|
void SICSLogWriteTime(char *ptext, OutCode eOut, struct timeval *tp );
|
||||||
|
void SICSLogWriteHex(const char* text, int count, OutCode eOut);
|
||||||
|
void SICSLogWriteHexTime(const char* text, int count, OutCode eOut, struct timeval *tp);
|
||||||
void SICSLogEnable(int flag);
|
void SICSLogEnable(int flag);
|
||||||
int KillCapture(SConnection *pCon);
|
int KillCapture(SConnection *pCon);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user