]> andersk Git - libfaim.git/blame - utils/aimpasswd/aimpasswd.c
Removed my passwords.
[libfaim.git] / utils / aimpasswd / aimpasswd.c
CommitLineData
9de3ca7e 1/*
2 * aimpasswd.c -- Change AIM password without logging in.
3 *
4 * Defintly not done yet.
5 *
6 * TODO: Make this work.
7 *
8 * -----------------------------------------------------------
9 *
10 * I'm releasing this code and all it's associated linkage
11 * under the GNU General Public License. For more information,
12 * please refer to http://www.fsf.org. For any questions,
13 * please contact me at the address below.
14 *
15 * (c) 1998/99 Adam Fritzler, PST, afritz@iname.com
16 *
17 * -----------------------------------------------------------
18 *
19 */
20
21/*
22 Current status:
23
24
25 */
26
27#include "aim.h" /* for struct defs, global ptrs, etc */
28
29int faimtest_parse_oncoming(struct command_rx_struct *, ...);
30int faimtest_parse_offgoing(struct command_rx_struct *, ...);
31int faimtest_parse_login_phase3d_f(struct command_rx_struct *, ...);
32int faimtest_auth_error(struct command_rx_struct *, ...);
33int faimtest_auth_success(struct command_rx_struct *, ...);
34int faimtest_parse_incoming_im(struct command_rx_struct *command, ...);
35int faimtest_parse_userinfo(struct command_rx_struct *command, ...);
36int faimtest_handleredirect(struct command_rx_struct *command, ...);
37int faimtest_authsvrready(struct command_rx_struct *command, ...);
38int faimtest_pwdchngdone(struct command_rx_struct *command, ...);
39int faimtest_serverready(struct command_rx_struct *command, ...);
40
41int bleu(struct command_rx_struct *blah, ...)
42{
43 return -1;
44}
45
46int main(void)
47{
48 /*
49 specify your custom command handlers here. I recommend
50 at least overriding the login_phase3d_f handler so that
51 you can have your own buddy list and profile. The
52 rest are probably only useful to override for UI
53 reasons.
54 */
55 rxcallback_t faimtest_callbacks[] = {
56 bleu, /* incoming IM */
57 bleu, /* oncoming buddy */
58 bleu, /* offgoing buddy */
59 NULL, /* last IM was missed 1 */
60 NULL, /* last IM was missed 2 */
61 NULL, /* login phase 4 packet C command 1 -- depricated */
62 NULL, /* login phase 4 packet C command 2 -- depricated */
63 NULL, /* login phase 2, first resp -- depricated */
64 faimtest_serverready, /* server ready -- **HANDLING REQUIRED** */
65 NULL, /* login phase 3 packet B -- depricated */
66 NULL, /* login phase 3D packet A -- depricated */
67 NULL, /* login phase 3D packet B -- depricated */
68 NULL, /* login phase 3D packet C -- depricated */
69 NULL, /* login phase 3D packet D -- depricated */
70 NULL, /* login phase 3D packet E -- depricated */
71 faimtest_handleredirect, /* redirect -- **HANDLING REQUIRED** */
72 NULL, /* last command bad */
73 NULL, /* missed some messages */
74 NULL, /* completely unknown command */
75 bleu, /* user info response */
76 NULL, /* user search by address response */
77 NULL, /* user serach by name response */
78 NULL, /* user search fail */
79 faimtest_auth_error,
80 faimtest_auth_success,
81 faimtest_authsvrready,
82 NULL,
83 faimtest_pwdchngdone,
84 faimtest_serverready,
85 0x00 /* terminating NULL -- REQUIRED */
86 };
87
88 aim_connrst(); /* reset connection array -- there's a better place for this*/
89 /* register our callback array (optional) */
90 aim_register_callbacks(faimtest_callbacks);
91
92
7c7d5b9e 93 aim_login("NAME", "PASS");
9de3ca7e 94 while (aim_select(NULL) > (struct aim_conn_t *)0)
95 {
96 if (aim_get_command() < 0)
97 {
98 printf("\afaimtest: connection error!\n");
99 }
100 else
101 aim_rxdispatch();
102 }
103
104 /* Close up */
105 printf("AIM just decided we didn't need to be here anymore, closing up.,,\n");
106
107 /* close up all connections, dead or no */
108 aim_logoff();
109
110 /* Get out */
111 exit(0);
112}
113
114int faimtest_serverready(struct command_rx_struct *command, ...)
115{
116 switch (command->conn->type)
117 {
118 case AIM_CONN_TYPE_BOS:
119 printf("requesting AUTH service\n");
120 aim_bos_reqservice(command->conn, 0x0007);
121 break;
122 default:
123 fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
124 }
125 return 0;
126}
127
128/*
129 handleredirect()...
130
131 This, of course, handles Service Redirects from OSCAR.
132
133 Should get passed in the following:
134 struct command_rx_struct *command
135 the raw command data
136 int serviceid
137 the destination service ID
138 char *serverip
139 the IP address of the service's server
140 char *cookie
141 the raw auth cookie
142 */
143int faimtest_handleredirect(struct command_rx_struct *command, ...)
144{
145 va_list ap;
146 int serviceid;
147 char *ip;
148 char *cookie;
149
150 va_start(ap, command);
151 serviceid = va_arg(ap, int);
152 ip = va_arg(ap, char *);
153 cookie = va_arg(ap, char *);
154 va_end(ap);
155
156 switch(serviceid)
157 {
158 case 0x0007: /* Authorizer */
159 {
160 struct aim_conn_t *tstconn;
161 /* Open a connection to the Auth */
162 tstconn = aim_newconn(AIM_CONN_TYPE_AUTH, ip);
163 /* Send the cookie to the Auth */
164 aim_auth_sendcookie(tstconn, cookie);
165 }
166 break;
167 default:
168 printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
169 /* dunno */
170 }
171
172 return 0;
173}
174
175int faimtest_auth_error(struct command_rx_struct *command, ...)
176{
177 va_list ap;
178 struct login_phase1_struct *logininfo;
179 char *errorurl;
180 short errorcode;
181
182 va_start(ap, command);
183 logininfo = va_arg(ap, struct login_phase1_struct *);
184 printf("Screen name: %s\n", logininfo->screen_name);
185 errorurl = va_arg(ap, char *);
186 printf("Error URL: %s\n", errorurl);
187 errorcode = va_arg(ap, short);
188 printf("Error code: 0x%02x\n", errorcode);
189 va_end(ap);
190
191 aim_conn_close(aim_getconn_type(AIM_CONN_TYPE_AUTH));
192 exit(0);
193
194 return 0;
195}
196
197int faimtest_auth_success(struct command_rx_struct *command, ...)
198{
199 va_list ap;
200 struct login_phase1_struct *logininfo;
201 struct aim_conn_t *bosconn = NULL;
202
203 va_start(ap, command);
204 logininfo = va_arg(ap, struct login_phase1_struct *);
205 va_end(ap);
206
207 printf("Screen name: %s\n", logininfo->screen_name);
208 printf("Reg status: %2d\n", logininfo->regstatus);
209 printf("Email: %s\n", logininfo->email);
210 printf("Cookie len: %d\n", sizeof(logininfo->cookie));
211 printf("BOS IP: %s\n", logininfo->BOSIP);
212
213 printf("Closing auth connection...\n");
214 aim_conn_close(command->conn);
215 bosconn = aim_newconn(AIM_CONN_TYPE_BOS, logininfo->BOSIP);
216 aim_auth_sendcookie(bosconn, logininfo->cookie);
217
218 return 0;
219}
220
221int faimtest_authsvrready(struct command_rx_struct *command, ...)
222{
223 /* should just be able to tell it we're ready too... */
224 aim_auth_clientready(command->conn);
225
226 /*
227 * This is where you'd really begin changing your password.
228 * However, this callback may get called for reasons other
229 * than you wanting to change your password. You should
230 * probably check that before actually doing it.
231 */
7c7d5b9e 232 //aim_auth_changepasswd(command->conn, "", "");
9de3ca7e 233
234 return 0;
235}
236
237int faimtest_pwdchngdone(struct command_rx_struct *command, ...)
238{
239 printf("PASSWORD CHANGE SUCCESSFUL!!!\n");
240 return 0;
241}
242
243
244
245
This page took 0.09946 seconds and 5 git commands to generate.