| 432 | */ |
| 433 | |
| 434 | http_uri_status_t /* O - URI status */ |
| 435 | httpAssembleURIf( |
| 436 | http_uri_coding_t encoding, /* I - Encoding flags */ |
| 437 | char *uri, /* I - URI buffer */ |
| 438 | int urilen, /* I - Size of URI buffer */ |
| 439 | const char *scheme, /* I - Scheme name */ |
| 440 | const char *username, /* I - Username */ |
| 441 | const char *host, /* I - Hostname or address */ |
| 442 | int port, /* I - Port number */ |
| 443 | const char *resourcef, /* I - Printf-style resource */ |
| 444 | ...) /* I - Additional arguments as needed */ |
| 445 | { |
| 446 | va_list ap; /* Pointer to additional arguments */ |
| 447 | char resource[1024]; /* Formatted resource string */ |
| 448 | int bytes; /* Bytes in formatted string */ |
| 449 | |
| 450 | |
| 451 | /* |
| 452 | * Range check input... |
| 453 | */ |
| 454 | |
| 455 | if (!uri || urilen < 1 || !scheme || port < 0 || !resourcef) |
| 456 | { |
| 457 | if (uri) |
| 458 | *uri = '\0'; |
| 459 | |
| 460 | return (HTTP_URI_STATUS_BAD_ARGUMENTS); |
| 461 | } |
| 462 | |
| 463 | /* |
| 464 | * Format the resource string and assemble the URI... |
| 465 | */ |
| 466 | |
| 467 | va_start(ap, resourcef); |
| 468 | bytes = vsnprintf(resource, sizeof(resource), resourcef, ap); |
| 469 | va_end(ap); |
| 470 | |
| 471 | if ((size_t)bytes >= sizeof(resource)) |
| 472 | { |
| 473 | *uri = '\0'; |
| 474 | return (HTTP_URI_STATUS_OVERFLOW); |
| 475 | } |
| 476 | else |
| 477 | return (httpAssembleURI(encoding, uri, urilen, scheme, username, host, |
| 478 | port, resource)); |
| 479 | } |
| 480 | |
| 481 | |
| 482 | /* |
no test coverage detected