Added logdata action (still needs byte limit). See #40.

This commit is contained in:
brectanus
2007-08-10 00:22:15 +00:00
parent 765dfd0274
commit 8f6385f784
7 changed files with 79 additions and 5 deletions

View File

@@ -450,13 +450,43 @@ char *log_escape_raw(apr_pool_t *mp, const unsigned char *text, unsigned long in
unsigned long int i, j;
for (i = 0, j = 0; i < text_length; i++, j += 4) {
apr_snprintf((char *)ret+j, 5, "\\x%02x", text[i]);
ret[j] = '\\';
ret[j+1] = 'x';
c2x(text[i], ret+j+2);
}
ret[text_length * 4] = '\0';
return (char *)ret;
}
/**
* Transform text to ASCII printable or hex escaped
*/
char *log_escape_hex(apr_pool_t *mp, const unsigned char *text, unsigned long int text_length) {
unsigned char *ret = apr_palloc(mp, text_length * 4 + 1);
unsigned long int i, j;
for (i = 0, j = 0; i < text_length; i++) {
if ( (text[i] == '"')
||(text[i] == '\\')
||(text[i] <= 0x1f)
||(text[i] >= 0x7f))
{
ret[j] = '\\';
ret[j+1] = 'x';
c2x(text[i], ret+j+2);
j += 4;
}
else {
ret[j] = text[i];
j ++;
}
}
ret[j] = '\0';
return (char *)ret;
}
/**
* Transform input into a form safe for logging.
*/