MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlSaveUri

Function xmlSaveUri

ThirdParty/libxml2/vtklibxml2/uri.c:1123–1387  ·  view source on GitHub ↗

* xmlSaveUri: * @uri: pointer to an xmlURI * * Save the URI as an escaped string * * Returns a new string (to be deallocated by caller) */

Source from the content-addressed store, hash-verified

1121 * Returns a new string (to be deallocated by caller)
1122 */
1123xmlChar *
1124xmlSaveUri(xmlURIPtr uri) {
1125 xmlChar *ret = NULL;
1126 xmlChar *temp;
1127 const char *p;
1128 int len;
1129 int max;
1130
1131 if (uri == NULL) return(NULL);
1132
1133
1134 max = 80;
1135 ret = (xmlChar *) xmlMallocAtomic(max + 1);
1136 if (ret == NULL)
1137 return(NULL);
1138 len = 0;
1139
1140 if (uri->scheme != NULL) {
1141 p = uri->scheme;
1142 while (*p != 0) {
1143 if (len >= max) {
1144 temp = xmlSaveUriRealloc(ret, &max);
1145 if (temp == NULL) goto mem_error;
1146 ret = temp;
1147 }
1148 ret[len++] = *p++;
1149 }
1150 if (len >= max) {
1151 temp = xmlSaveUriRealloc(ret, &max);
1152 if (temp == NULL) goto mem_error;
1153 ret = temp;
1154 }
1155 ret[len++] = ':';
1156 }
1157 if (uri->opaque != NULL) {
1158 p = uri->opaque;
1159 while (*p != 0) {
1160 if (len + 3 >= max) {
1161 temp = xmlSaveUriRealloc(ret, &max);
1162 if (temp == NULL) goto mem_error;
1163 ret = temp;
1164 }
1165 if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
1166 ret[len++] = *p++;
1167 else {
1168 int val = *(unsigned char *)p++;
1169 int hi = val / 0x10, lo = val % 0x10;
1170 ret[len++] = '%';
1171 ret[len++] = hi + (hi > 9? 'A'-10 : '0');
1172 ret[len++] = lo + (lo > 9? 'A'-10 : '0');
1173 }
1174 }
1175 } else {
1176 if ((uri->server != NULL) || (uri->port != PORT_EMPTY)) {
1177 if (len + 3 >= max) {
1178 temp = xmlSaveUriRealloc(ret, &max);
1179 if (temp == NULL) goto mem_error;
1180 ret = temp;

Callers 4

xmlXIncludeAddNodeFunction · 0.85
xmlPrintURIFunction · 0.85
xmlBuildURISafeFunction · 0.85
xmlBuildRelativeURISafeFunction · 0.85

Calls 1

xmlSaveUriReallocFunction · 0.85

Tested by

no test coverage detected