* xmlNewCharEncodingHandler: * @name: the encoding name, in UTF-8 format (ASCII actually) * @input: the xmlCharEncodingInputFunc to read that encoding * @output: the xmlCharEncodingOutputFunc to write that encoding * * Create and registers an xmlCharEncodingHandler. * * Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error). */
| 1344 | * Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error). |
| 1345 | */ |
| 1346 | xmlCharEncodingHandlerPtr |
| 1347 | xmlNewCharEncodingHandler(const char *name, |
| 1348 | xmlCharEncodingInputFunc input, |
| 1349 | xmlCharEncodingOutputFunc output) { |
| 1350 | xmlCharEncodingHandlerPtr handler; |
| 1351 | const char *alias; |
| 1352 | char upper[500]; |
| 1353 | int i; |
| 1354 | char *up = NULL; |
| 1355 | |
| 1356 | /* |
| 1357 | * Do the alias resolution |
| 1358 | */ |
| 1359 | alias = xmlGetEncodingAlias(name); |
| 1360 | if (alias != NULL) |
| 1361 | name = alias; |
| 1362 | |
| 1363 | /* |
| 1364 | * Keep only the uppercase version of the encoding. |
| 1365 | */ |
| 1366 | if (name == NULL) |
| 1367 | return(NULL); |
| 1368 | for (i = 0;i < 499;i++) { |
| 1369 | upper[i] = (char) toupper((unsigned char) name[i]); |
| 1370 | if (upper[i] == 0) break; |
| 1371 | } |
| 1372 | upper[i] = 0; |
| 1373 | up = xmlMemStrdup(upper); |
| 1374 | if (up == NULL) |
| 1375 | return(NULL); |
| 1376 | |
| 1377 | /* |
| 1378 | * allocate and fill-up an handler block. |
| 1379 | */ |
| 1380 | handler = (xmlCharEncodingHandlerPtr) |
| 1381 | xmlMalloc(sizeof(xmlCharEncodingHandler)); |
| 1382 | if (handler == NULL) { |
| 1383 | xmlFree(up); |
| 1384 | return(NULL); |
| 1385 | } |
| 1386 | memset(handler, 0, sizeof(xmlCharEncodingHandler)); |
| 1387 | handler->input = input; |
| 1388 | handler->output = output; |
| 1389 | handler->name = up; |
| 1390 | |
| 1391 | #ifdef LIBXML_ICONV_ENABLED |
| 1392 | handler->iconv_in = NULL; |
| 1393 | handler->iconv_out = NULL; |
| 1394 | #endif |
| 1395 | #ifdef LIBXML_ICU_ENABLED |
| 1396 | handler->uconv_in = NULL; |
| 1397 | handler->uconv_out = NULL; |
| 1398 | #endif |
| 1399 | |
| 1400 | /* |
| 1401 | * registers and returns the handler. |
| 1402 | */ |
| 1403 | xmlRegisterCharEncodingHandler(handler); |
nothing calls this directly
no test coverage detected