comparison src/proxy.c @ 8889:ae3f33870550

[gaim-migrate @ 9658] Get rid of a big old ugly function in proxy.c that was #if 0'ed out. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 06 May 2004 05:42:41 +0000
parents 28c0ebfd7a53
children 189ee7356c59
comparison
equal deleted inserted replaced
8888:8592f296db16 8889:ae3f33870550
787 } 787 }
788 788
789 #define HTTP_GOODSTRING "HTTP/1.0 200" 789 #define HTTP_GOODSTRING "HTTP/1.0 200"
790 #define HTTP_GOODSTRING2 "HTTP/1.1 200" 790 #define HTTP_GOODSTRING2 "HTTP/1.1 200"
791 791
792 #if 0
793 /* QQQ */
794 static void
795 http_uri_get_host(const char *uri)
796 {
797 GaimProxyInfo *info;
798
799 char *c, *d;
800 char buffer[2048];
801
802 char host[128];
803 char user[128];
804 char pass[128];
805 int port = 0;
806 int len = 0;
807
808 host[0] = '\0';
809 user[0] = '\0';
810 pass[0] = '\0';
811
812 gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
813 "gaimrc_parse_proxy_uri(%s)\n", proxy);
814
815 if ((c = strchr(proxy, ':')) == NULL)
816 {
817 gaim_debug(GAIM_DEBUG_ERROR, "gaimrc",
818 "No URI detected.\n");
819 /* No URI detected. */
820 return FALSE;
821 }
822
823 len = c - proxy;
824
825 if (strncmp(proxy, "http://", len + 3))
826 return FALSE;
827
828 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "Found HTTP proxy.\n");
829 /* Get past "://" */
830 c += 3;
831
832 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "Looking at %s\n", c);
833
834 for (;;)
835 {
836 *buffer = '\0';
837 d = buffer;
838
839 while (*c != '\0' && *c != '@' && *c != ':' && *c != '/')
840 *d++ = *c++;
841
842 *d = '\0';
843
844 if (*c == ':')
845 {
846 /*
847 * If there is a '@' in there somewhere, we are in the auth part.
848 * If not, host.
849 */
850 if (strchr(c, '@') != NULL)
851 strcpy(user, buffer);
852 else
853 strcpy(host, buffer);
854 }
855 else if (*c == '@')
856 {
857 if (user[0] == '\0')
858 strcpy(user, buffer);
859 else
860 strcpy(pass, buffer);
861 }
862 else if (*c == '/' || *c == '\0')
863 {
864 if (host[0] == '\0')
865 strcpy(host, buffer);
866 else
867 port = atoi(buffer);
868
869 /* Done. */
870 break;
871 }
872
873 c++;
874 }
875
876 /* NOTE: HTTP_PROXY takes precedence. */
877 info = gaim_global_proxy_get_info();
878
879 if (*host) gaim_proxy_info_set_host(info, host);
880 if (*user) gaim_proxy_info_set_username(info, user);
881 if (*pass) gaim_proxy_info_set_password(info, pass);
882
883 gaim_proxy_info_set_port(info, port);
884
885 gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
886 "Host: '%s', User: '%s', Password: '%s', Port: %d\n",
887 gaim_proxy_info_get_host(info),
888 gaim_proxy_info_get_username(info),
889 gaim_proxy_info_get_password(info),
890 gaim_proxy_info_get_port(info));
891
892 return TRUE;
893 }
894 #endif
895
896
897 static void 792 static void
898 http_complete(struct PHB *phb, gint source) 793 http_complete(struct PHB *phb, gint source)
899 { 794 {
900 gaim_debug(GAIM_DEBUG_INFO, "http proxy", "proxy connection established\n"); 795 gaim_debug(GAIM_DEBUG_INFO, "http proxy", "proxy connection established\n");
901 if(!phb->account || phb->account->gc) 796 if(!phb->account || phb->account->gc)