]> andersk Git - libfaim.git/blob - utils/aimpasswd/aimpasswd.c
Initial revision
[libfaim.git] / utils / aimpasswd / aimpasswd.c
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
29 int faimtest_parse_oncoming(struct command_rx_struct *, ...);
30 int faimtest_parse_offgoing(struct command_rx_struct *, ...);
31 int faimtest_parse_login_phase3d_f(struct command_rx_struct *, ...);
32 int faimtest_auth_error(struct command_rx_struct *, ...);
33 int faimtest_auth_success(struct command_rx_struct *, ...);
34 int faimtest_parse_incoming_im(struct command_rx_struct *command, ...);
35 int faimtest_parse_userinfo(struct command_rx_struct *command, ...);
36 int faimtest_handleredirect(struct command_rx_struct *command, ...);
37 int faimtest_authsvrready(struct command_rx_struct *command, ...);
38 int faimtest_pwdchngdone(struct command_rx_struct *command, ...);
39 int faimtest_serverready(struct command_rx_struct *command, ...);
40
41 int bleu(struct command_rx_struct *blah, ...)
42 {
43   return -1;
44 }
45
46 int 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
93   //aim_login("a275081780", "1Fritz");  /* not real password :) */
94   aim_login("diputs 81", "1Fritz");
95   while (aim_select(NULL) > (struct aim_conn_t *)0)
96     {
97       if (aim_get_command() < 0)
98         {
99           printf("\afaimtest: connection error!\n");
100         }
101       else
102         aim_rxdispatch();
103     }
104
105   /* Close up */
106   printf("AIM just decided we didn't need to be here anymore, closing up.,,\n");
107   
108   /* close up all connections, dead or no */
109   aim_logoff(); 
110
111   /* Get out */
112   exit(0);
113 }
114
115 int faimtest_serverready(struct command_rx_struct *command, ...)
116 {
117   switch (command->conn->type)
118     {
119     case AIM_CONN_TYPE_BOS:
120       printf("requesting AUTH service\n");
121       aim_bos_reqservice(command->conn, 0x0007);
122       break;
123     default:
124       fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
125     }
126   return 0;
127 }
128
129 /*
130   handleredirect()...
131
132   This, of course, handles Service Redirects from OSCAR.
133
134   Should get passed in the following:
135      struct command_rx_struct *command
136        the raw command data
137      int serviceid
138        the destination service ID
139      char *serverip
140        the IP address of the service's server
141      char *cookie
142        the raw auth cookie
143  */
144 int faimtest_handleredirect(struct command_rx_struct *command, ...)
145 {
146   va_list ap;
147   int serviceid;
148   char *ip;
149   char *cookie;
150
151   va_start(ap, command);
152   serviceid = va_arg(ap, int);
153   ip = va_arg(ap, char *);
154   cookie = va_arg(ap, char *);
155   va_end(ap);
156
157   switch(serviceid)
158     {
159     case 0x0007: /* Authorizer */
160       {
161         struct aim_conn_t *tstconn;
162         /* Open a connection to the Auth */
163         tstconn = aim_newconn(AIM_CONN_TYPE_AUTH, ip);
164         /* Send the cookie to the Auth */
165         aim_auth_sendcookie(tstconn, cookie);
166       }  
167       break;
168     default:
169       printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
170       /* dunno */
171     }
172
173   return 0;
174 }
175
176 int faimtest_auth_error(struct command_rx_struct *command, ...)
177 {
178   va_list ap;
179   struct login_phase1_struct *logininfo;
180   char *errorurl;
181   short errorcode;
182
183   va_start(ap, command);
184   logininfo = va_arg(ap, struct login_phase1_struct *);
185   printf("Screen name: %s\n", logininfo->screen_name);
186   errorurl = va_arg(ap, char *);
187   printf("Error URL: %s\n", errorurl);
188   errorcode = va_arg(ap, short);
189   printf("Error code: 0x%02x\n", errorcode);
190   va_end(ap);
191
192   aim_conn_close(aim_getconn_type(AIM_CONN_TYPE_AUTH));
193   exit(0);
194   
195   return 0;
196 }
197
198 int faimtest_auth_success(struct command_rx_struct *command, ...)
199 {
200   va_list ap;
201   struct login_phase1_struct *logininfo;
202   struct aim_conn_t *bosconn = NULL;
203
204   va_start(ap, command);
205   logininfo = va_arg(ap, struct login_phase1_struct *);
206   va_end(ap);
207   
208   printf("Screen name: %s\n", logininfo->screen_name);
209   printf("Reg status: %2d\n", logininfo->regstatus);
210   printf("Email: %s\n", logininfo->email);
211   printf("Cookie len: %d\n", sizeof(logininfo->cookie));
212   printf("BOS IP: %s\n", logininfo->BOSIP);
213
214   printf("Closing auth connection...\n");
215   aim_conn_close(command->conn);
216   bosconn = aim_newconn(AIM_CONN_TYPE_BOS, logininfo->BOSIP);
217   aim_auth_sendcookie(bosconn, logininfo->cookie);
218
219   return 0;
220 }
221
222 int faimtest_authsvrready(struct command_rx_struct *command, ...)
223 {
224   /* should just be able to tell it we're ready too... */
225   aim_auth_clientready(command->conn);
226
227   /*
228    * This is where you'd really begin changing your password.
229    *   However, this callback may get called for reasons other
230    *   than you wanting to change your password.  You should 
231    *   probably check that before actually doing it.
232    */
233   //aim_auth_changepasswd(command->conn, "Fritz", "1Fritz");
234
235   return 0;
236 }
237
238 int faimtest_pwdchngdone(struct command_rx_struct *command, ...)
239 {
240   printf("PASSWORD CHANGE SUCCESSFUL!!!\n");
241   return 0;
242 }
243
244
245
246
This page took 0.259618 seconds and 5 git commands to generate.