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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
/**************************************************************************
utils.c - declaration for misc utils this is
mixed bag of functions so it is
not realy a module hense no need
for a utils prefix its functions
-------------------
begin : Thur Jan 31 2002
copyright : (C) 2001 by Keith Isdale
email : [email protected]
**************************************************************************/
/**************************************************************************
* *
* This program 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. *
* *
**************************************************************************/
#ifndef XSLDBG_UTILS_H
#define XSLDBG_UTILS_H
#ifndef BUILD_DOCS
#include <stdio.h>
#include <string.h>
#include <libxml/tree.h>
#include <libxml/debugXML.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/xsltutils.h>
#include <libxml/xpath.h>
#endif
#include "xsldbg.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
Make things simpler when working between char* and xmlChar* .
By definition a char is the same size as an xmlChar(unsigned char).
*/
#ifndef BUILD_DOCS
#define xmlStrLen(text) strlen((char*)(text))
#define xmlStrCat(a, b) strcat((char*)(a), (char*)(b))
#define xmlStrCmp(a, b) strcmp((char*)(a), (char*)(b))
#define xmlStrnCmp(a, b, c) strncmp((char*)(a), (char*)(b), c)
#define xmlStrCpy(a, b) strcpy((char*)(a), (char*)(b))
#define xmlStrnCpy(a, b, c) strncpy((char*)(a),(char*)(b), c)
#define xmlStrChr(a, b) strchr((char*)(a), b)
#define xmlStrrChr(a, b) strrchr((char*)(a), b)
#endif
/* what char is use to separate directories in an URI*/
#define URISEPARATORCHAR '/'
/* Handle the differences in path and quote character between
* win32 and *nix systems */
#ifdef WIN32
#define QUOTECHAR ' '
#define PATHCHAR '\\'
#else
#define QUOTECHAR '\"'
#define PATHCHAR '/'
#endif
/* JRF: Although RISC OS native paths use . as a separator, the arguments
to xsldbg are passed in unix or URI form, and thus the above
specification is correct. */
/**
* _IS_BLANK:
* @c: an UNICODE value (int)
*
* Macro to check the following production in the XML spec
*
* [3] S ::= (#x20 | #x9 | #xD | #xA)+
*/
#define _IS_BLANK(c) (((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
((c) == 0x0D))
#ifdef USE_GNOME_DOCS
/**
* trimString:
* @text : A valid string with leading or trailing spaces
*
* Remove leading and trailing spaces off @text
* stores result back into @text
* Returns 1 on success,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Remove leading and trailing spaces off @p text
* stores result back into @p text
*
* @returns 1 on success,
* 0 otherwise
*
* @param text A valid string with leading or trailing spaces
*/
#endif
#endif
int trimString(xmlChar * text);
#ifdef USE_GNOME_DOCS
/**
* splitString:
* @textIn: The string to split
* @maxStrings: The max number of strings to put into @out
* @out: Is valid and at least the size of @maxStrings
*
* Split string by white space and put into @out
*
* Returns 1 on success,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Spit string by white space and put into @p out
*
* @returns 1 on success,
* 0 otherwise
*
* @param textIn The string to split
* @param maxStrings The max number of strings to put into @p out
* @param out Is valid and at least the size of @p maxStrings
*/
#endif
#endif
int splitString(xmlChar * textIn, int maxStrings, xmlChar ** out);
#ifdef USE_GNOME_DOCS
/**
* lookupName:
* @name : Is valid
* @matchList : A NULL terminated list of names to use as lookup table
*
* Lookup and name in a list
*
* Returns The id of name found in @matchList,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Lookup and name in a list
*
*
* @returns The id of name found in @p matchList
* 0 otherwise
*
* @param name Is valid
* @param matchList A NULL terminated list of names to use as lookup table
*
*/
#endif
#endif
int lookupName(xmlChar * name, xmlChar ** matchList);
#ifdef USE_GNOME_DOCS
/**
* fullTQName:
* @nameURI : TQName part of name
* @name : Local part of name
*
* Join nameURI to name
*
* Returns a copy of "nameURI:name"
*
*/
#else
#ifdef USE_KDE_DOCS
/**
* Join nameURI to name
*
* @returns a copy of "nameURI:name"
* fullTQName:
* @param nameURI : TQName part of name
* @param name : Local part of name
*
*
*/
#endif
#endif
xmlChar * fullTQName(const xmlChar* nameURI, const xmlChar * name);
#ifdef __cplusplus
}
#endif
#endif
|