Mercurial > pidgin
comparison src/util.c @ 7134:67f9b43c402a
[gaim-migrate @ 7701]
I think this is the fifth Yahoo authentication method Gaim's seen in its
days. Please tell me if anything stops working.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Fri, 03 Oct 2003 23:01:13 +0000 |
parents | b003397b16fe |
children | d14e026611c0 |
comparison
equal
deleted
inserted
replaced
7133:28dd20b5f4cf | 7134:67f9b43c402a |
---|---|
1916 | 1916 |
1917 cb(user_data, g_strdup(_("g003: Error opening connection.\n")), 0); | 1917 cb(user_data, g_strdup(_("g003: Error opening connection.\n")), 0); |
1918 } | 1918 } |
1919 } | 1919 } |
1920 | 1920 |
1921 char * | |
1922 gaim_url_decode(const char *str) | |
1923 { | |
1924 static char buf[BUF_LEN]; | |
1925 int i, j = 0; | |
1926 char *bum; | |
1927 | |
1928 g_return_val_if_fail(str != NULL, NULL); | |
1929 | |
1930 for (i = 0; i < strlen(str); i++) { | |
1931 char hex[3]; | |
1932 | |
1933 if (str[i] != '%') | |
1934 buf[j++] = str[i]; | |
1935 else { | |
1936 strncpy(hex, str + ++i, 2); | |
1937 hex[2] = '\0'; | |
1938 | |
1939 /* i is pointing to the start of the number */ | |
1940 i++; | |
1941 | |
1942 /* | |
1943 * Now it's at the end and at the start of the for loop | |
1944 * will be at the next character. | |
1945 */ | |
1946 buf[j++] = strtol(hex, NULL, 16); | |
1947 } | |
1948 } | |
1949 | |
1950 buf[j] = '\0'; | |
1951 | |
1952 if (!g_utf8_validate(buf, -1, (const char **)&bum)) | |
1953 *bum = '\0'; | |
1954 | |
1955 return buf; | |
1956 } | |
1957 | |
1958 char * | |
1959 gaim_url_encode(const char *str) | |
1960 { | |
1961 static char buf[BUF_LEN]; | |
1962 int i, j = 0; | |
1963 | |
1964 g_return_val_if_fail(str != NULL, NULL); | |
1965 | |
1966 for (i = 0; i < strlen(str); i++) { | |
1967 if (isalnum(str[i])) | |
1968 buf[j++] = str[i]; | |
1969 else { | |
1970 sprintf(buf + j, "%%%02x", (unsigned char)str[i]); | |
1971 j += 3; | |
1972 } | |
1973 } | |
1974 | |
1975 buf[j] = '\0'; | |
1976 | |
1977 return buf; | |
1978 } | |
1921 | 1979 |
1922 /************************************************************************** | 1980 /************************************************************************** |
1923 * UTF8 String Functions | 1981 * UTF8 String Functions |
1924 **************************************************************************/ | 1982 **************************************************************************/ |
1925 char * | 1983 char * |