Menu

[r3316]: / trunk / src / trace.c  Maximize  Restore  History

Download this file

64 lines (43 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "xmlrpc-c/base_int.h"
#include "xmlrpc-c/string_int.h"
static size_t
nextLineSize(const char * const string,
size_t const startPos,
size_t const stringSize) {
/*----------------------------------------------------------------------------
Return the length of the line that starts at offset 'startPos' in the
string 'string', which is 'stringSize' characters long.
'string' in not NUL-terminated.
A line begins at beginning of string or after a newline character and
runs through the next newline character or end of string. The line
includes the newline character at the end, if any.
-----------------------------------------------------------------------------*/
size_t i;
for (i = startPos; i < stringSize && string[i] != '\n'; ++i);
if (i < stringSize)
++i; /* Include the newline */
return i - startPos;
}
void
xmlrpc_traceXml(const char * const label,
const char * const xml,
size_t const xmlLength) {
if (getenv("XMLRPC_TRACE_XML")) {
size_t cursor; /* Index into xml[] */
fprintf(stderr, "%s:\n\n", label);
for (cursor = 0; cursor < xmlLength; ) {
/* Print one line of XML */
size_t const lineSize = nextLineSize(xml, cursor, xmlLength);
const char * const xmlPrintableLine =
xmlrpc_makePrintable_lp(&xml[cursor], lineSize);
fprintf(stderr, "%s\n", xmlPrintableLine);
cursor += lineSize;
xmlrpc_strfree(xmlPrintableLine);
}
fprintf(stderr, "\n");
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.