MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cgiRewriteURL

Function cgiRewriteURL

cgi-bin/ipp-var.c:792–919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790 */
791
792char * /* O - New URL */
793cgiRewriteURL(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") ||

Callers 7

cgiSetIPPObjectVarsFunction · 0.85
mainFunction · 0.85
do_class_opFunction · 0.85
mainFunction · 0.85
do_printer_opFunction · 0.85
do_set_allowed_usersFunction · 0.85
do_set_defaultFunction · 0.85

Calls 4

httpGetHostnameFunction · 0.85
httpSeparateURIFunction · 0.85
_cups_strcasecmpFunction · 0.85
_cups_strncasecmpFunction · 0.85

Tested by

no test coverage detected