| 542 | */ |
| 543 | |
| 544 | void |
| 545 | cupsSetUserAgent(const char *user_agent)/* I - User-Agent string or @code NULL@ */ |
| 546 | { |
| 547 | _cups_globals_t *cg = _cupsGlobals(); |
| 548 | /* Thread globals */ |
| 549 | #ifdef _WIN32 |
| 550 | SYSTEM_INFO sysinfo; /* System information */ |
| 551 | OSVERSIONINFOW version; /* OS version info */ |
| 552 | const char *machine; /* Hardware/machine name */ |
| 553 | #elif defined(__APPLE__) |
| 554 | struct utsname name; /* uname info */ |
| 555 | char version[256]; /* macOS/iOS version */ |
| 556 | size_t len; /* Length of value */ |
| 557 | #else |
| 558 | struct utsname name; /* uname info */ |
| 559 | #endif /* _WIN32 */ |
| 560 | |
| 561 | |
| 562 | if (user_agent) |
| 563 | { |
| 564 | strlcpy(cg->user_agent, user_agent, sizeof(cg->user_agent)); |
| 565 | return; |
| 566 | } |
| 567 | |
| 568 | if (cg->uatokens < _CUPS_UATOKENS_OS) |
| 569 | { |
| 570 | switch (cg->uatokens) |
| 571 | { |
| 572 | default : |
| 573 | case _CUPS_UATOKENS_NONE : |
| 574 | cg->user_agent[0] = '\0'; |
| 575 | break; |
| 576 | case _CUPS_UATOKENS_PRODUCT_ONLY : |
| 577 | strlcpy(cg->user_agent, "CUPS IPP", sizeof(cg->user_agent)); |
| 578 | break; |
| 579 | case _CUPS_UATOKENS_MAJOR : |
| 580 | snprintf(cg->user_agent, sizeof(cg->user_agent), "CUPS/%d IPP/2", CUPS_VERSION_MAJOR); |
| 581 | break; |
| 582 | case _CUPS_UATOKENS_MINOR : |
| 583 | snprintf(cg->user_agent, sizeof(cg->user_agent), "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR, CUPS_VERSION_MINOR); |
| 584 | break; |
| 585 | case _CUPS_UATOKENS_MINIMAL : |
| 586 | strlcpy(cg->user_agent, CUPS_MINIMAL " IPP/2.1", sizeof(cg->user_agent)); |
| 587 | break; |
| 588 | } |
| 589 | return; |
| 590 | } |
| 591 | |
| 592 | #ifdef _WIN32 |
| 593 | /* |
| 594 | * Gather Windows version information for the User-Agent string... |
| 595 | */ |
| 596 | |
| 597 | typedef NTSTATUS(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); |
| 598 | |
| 599 | memset(&version, 0, sizeof(version)); |
| 600 | version.dwOSVersionInfoSize = sizeof(version); |
| 601 |
no test coverage detected