| 790 | */ |
| 791 | |
| 792 | char * /* O - New URL */ |
| 793 | cgiRewriteURL(const char *uri, /* I - Current URI */ |
| 794 | char *url, /* O - New URL */ |
| 795 | int urlsize, /* I - Size of URL buffer */ |
| 796 | const char *newresource) /* I - Replacement resource */ |
| 797 | { |
| 798 | char scheme[HTTP_MAX_URI], |
| 799 | userpass[HTTP_MAX_URI], |
| 800 | hostname[HTTP_MAX_URI], |
| 801 | rawresource[HTTP_MAX_URI], |
| 802 | resource[HTTP_MAX_URI], |
| 803 | /* URI components... */ |
| 804 | *rawptr, /* Pointer into rawresource */ |
| 805 | *resptr; /* Pointer into resource */ |
| 806 | int port; /* Port number */ |
| 807 | static int ishttps = -1; /* Using encryption? */ |
| 808 | static const char *server; /* Name of server */ |
| 809 | static char servername[1024]; |
| 810 | /* Local server name */ |
| 811 | static const char hexchars[] = "0123456789ABCDEF"; |
| 812 | /* Hexadecimal conversion characters */ |
| 813 | |
| 814 | |
| 815 | /* |
| 816 | * Check if we have been called before... |
| 817 | */ |
| 818 | |
| 819 | if (ishttps < 0) |
| 820 | { |
| 821 | /* |
| 822 | * No, initialize static vars for the conversion... |
| 823 | * |
| 824 | * First get the server name associated with the client interface as |
| 825 | * well as the locally configured hostname. We'll check *both* of |
| 826 | * these to see if the printer URL is local... |
| 827 | */ |
| 828 | |
| 829 | if ((server = getenv("SERVER_NAME")) == NULL) |
| 830 | server = ""; |
| 831 | |
| 832 | httpGetHostname(NULL, servername, sizeof(servername)); |
| 833 | |
| 834 | /* |
| 835 | * Then flag whether we are using SSL on this connection... |
| 836 | */ |
| 837 | |
| 838 | ishttps = getenv("HTTPS") != NULL; |
| 839 | } |
| 840 | |
| 841 | /* |
| 842 | * Convert the URI to a URL... |
| 843 | */ |
| 844 | |
| 845 | httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass, |
| 846 | sizeof(userpass), hostname, sizeof(hostname), &port, |
| 847 | rawresource, sizeof(rawresource)); |
| 848 | |
| 849 | if (!strcmp(scheme, "ipp") || |
no test coverage detected