Mercurial > pidgin
annotate src/protocols/yahoo/login.c @ 2475:ba7ee4c1908c
[gaim-migrate @ 2488]
BMiller's fixes so gg compiles on solaris
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Wed, 10 Oct 2001 20:03:17 +0000 |
| parents | cff133e0ec0c |
| children |
| rev | line source |
|---|---|
| 2086 | 1 /* |
| 2 * libyay | |
| 3 * | |
| 4 * Copyright (C) 2001 Eric Warmenhoven <warmenhoven@yahoo.com> | |
| 5 * | |
| 6 * This program is free software; you can redistribute it and/or modify | |
| 7 * it under the terms of the GNU General Public License as published by | |
| 8 * the Free Software Foundation; either version 2 of the License, or | |
| 9 * (at your option) any later version. | |
| 10 * | |
| 11 * This program is distributed in the hope that it will be useful, | |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 * GNU General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU General Public License | |
| 17 * along with this program; if not, write to the Free Software | |
| 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 * | |
| 20 */ | |
| 21 | |
| 22 #include "internal.h" | |
|
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
23 #include <string.h> |
| 2086 | 24 |
| 25 int yahoo_send_login(struct yahoo_session *session, const char *name, const char *password) | |
| 26 { | |
| 27 char *buf = g_malloc(1024 + strlen(name) + strlen(password)); | |
| 28 char *a, *b; | |
| 29 int at; | |
| 30 struct yahoo_conn *conn; | |
| 31 | |
| 32 if (!buf) | |
| 33 return 0; | |
| 34 | |
| 35 if (!(conn = yahoo_getconn_type(session, YAHOO_CONN_TYPE_AUTH))) | |
| 36 return 0; | |
| 37 | |
| 38 if (!(a = yahoo_urlencode(name))) | |
| 39 return 0; | |
| 40 if (!(b = yahoo_urlencode(password))) { | |
| 41 g_free(a); | |
| 42 return 0; | |
| 43 } | |
| 44 | |
| 45 at = g_snprintf(buf, 1024 + strlen(name) + strlen(password), | |
| 46 "GET %s%s/config/ncclogin?login=%s&passwd=%s&n=1 HTTP/1.0\r\n" | |
| 47 "User-Agent: " YAHOO_USER_AGENT "\r\n" | |
| 48 "Host: %s\r\n\r\n", | |
| 49 session->proxy_type ? "http://" : "", | |
| 50 session->proxy_type ? session->auth_host : "", | |
| 51 a, b, session->auth_host); | |
| 52 | |
| 53 g_free(a); | |
| 54 g_free(b); | |
| 55 | |
| 56 if (yahoo_write(session, conn, buf, at) != at) { | |
| 57 g_free(buf); | |
| 58 return 0; | |
| 59 } | |
| 60 | |
| 61 g_free(buf); | |
| 62 session->name = g_strdup(name); | |
| 63 return at; | |
| 64 } | |
| 65 | |
| 66 int yahoo_finish_logon(struct yahoo_session *session, enum yahoo_status status) | |
| 67 { | |
| 68 char *buf = NULL, *tmp = NULL; | |
| 69 int ret; | |
| 70 struct yahoo_conn *conn; | |
| 71 | |
| 72 if (!session || !session->login_cookie) | |
| 73 return 0; | |
| 74 | |
| 75 if (!(conn = yahoo_getconn_type(session, YAHOO_CONN_TYPE_MAIN))) | |
| 76 return 0; | |
| 77 | |
| 78 if (session->identities) { | |
| 79 if (!(tmp = g_strjoinv(",", session->identities))) | |
| 80 return 0; | |
| 81 } else | |
| 82 tmp = ""; | |
| 83 | |
| 84 if (!(buf = g_strconcat(session->login_cookie, "\001", session->name, tmp, NULL))) { | |
| 85 g_free(tmp); | |
| 86 return 0; | |
| 87 } | |
| 88 | |
| 89 ret = yahoo_write_cmd(session, conn, YAHOO_SERVICE_LOGON, session->name, buf, status); | |
| 90 g_free(buf); | |
| 91 if (session->identities) | |
| 92 g_free(tmp); | |
| 93 | |
| 94 return ret; | |
| 95 } |
