35 const char *terminator,
49 if (!path || (strlen (path) == 0)) {
61 node->version = getVersion (path+1, &curPath);
62 if (curPath ==
NULL) {
66 if (curPath[0] ==
'/') {
70 node->next = parseRedPath (curPath);
72 node->next = parseRedPath (path+1);
79 curPath = getStringTill (path,
"/", &end);
81 parseNode (curPath, node, &endNode);
84 endNode->next = parseRedPath (end+1);
99 cleanupRedPath (node->next);
102 free (node->version);
105 if (node->nodeName) {
106 free (node->nodeName);
113 if (node->propName) {
114 free (node->propName);
130 return getStringTill (path,
"/", end);
143 char *nodeName = getStringTill (path,
"[", &indexStart);
147 node->nodeName = nodeName;
148 if (indexStart ==
NULL) {
161 index = getStringTill (indexStart,
"]",
NULL);
162 tmpIndex = (size_t)
strtoull (index, &indexEnd, 0);
163 if (indexEnd != index) {
165 node->next->index = tmpIndex;
166 node->next->isIndex =
true;
170 opChars =
strpbrk (index,
"<>=~");
171 if (opChars ==
NULL) {
173 node->next->op =
strdup (
"exists");
174 node->next->propName = index;
178 node->next->propName = (
char *)malloc ((opChars - index)+1);
179 memcpy (node->next->propName, index, (opChars - index));
180 node->next->propName[(opChars - index)] = 0;
184 if ((opChars[tmpIndex] ==
'=') || (opChars[tmpIndex] ==
'<') || (opChars[tmpIndex] ==
'>') || (opChars[tmpIndex] ==
'~')) {
192 node->next->op = (
char *)malloc (tmpIndex+1);
193 memcpy (node->next->op, opChars, tmpIndex);
194 node->next->op[tmpIndex] = 0;
196 node->next->value =
strdup (opChars+tmpIndex);
203 const char *terminator,
210 end = strstr ((
char *)
string, terminator);
220 ret = (
char *)malloc ((end-
string)+1);
221 memcpy (ret,
string, (end-
string));
222 ret[(end-string)] = 0;
char * strpbrk(const char *s1, const char *s2)
char * strdup(const char *str)
unsigned long long strtoull(const char *nptr, char **endptr, int base)