Mercurial > pidgin.yaz
comparison src/util.c @ 1009:d496fe2614a6
[gaim-migrate @ 1019]
command-line options for the app. not for the applet because most of the time you don't run it from the command line anyway. thanks bmiller
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 20 Oct 2000 00:35:30 +0000 |
parents | 2586b2a3725e |
children | 38452403563b |
comparison
equal
deleted
inserted
replaced
1008:1b99caffcd98 | 1009:d496fe2614a6 |
---|---|
1178 break; | 1178 break; |
1179 } | 1179 } |
1180 } | 1180 } |
1181 return dispstyle; | 1181 return dispstyle; |
1182 } | 1182 } |
1183 | |
1184 | |
1185 void show_usage (int mode, char *name) | |
1186 { | |
1187 switch (mode) { | |
1188 case 0: /* full help text */ | |
1189 printf ("Usage: %s [OPTION]...\n\n" | |
1190 " -a, --acct display account editor window\n" | |
1191 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" | |
1192 " account(s) to use)\n" | |
1193 " -u, --user=NAME use account NAME\n" | |
1194 " -v, --version display version information window\n" | |
1195 " -h, --help display this help and exit\n", name); | |
1196 break; | |
1197 case 1: /* short message */ | |
1198 printf ("Try `%s -h' for more information.\n", name); | |
1199 break; | |
1200 } | |
1201 } | |
1202 | |
1203 | |
1204 void set_first_user (char *name) | |
1205 { | |
1206 struct aim_user *u; | |
1207 | |
1208 u = find_user (name); | |
1209 | |
1210 if (!u) { /* new user */ | |
1211 u = g_new0(struct aim_user, 1); | |
1212 g_snprintf(u->username, sizeof(u->username), "%s", name); | |
1213 u->protocol = 0 /* PROTO_TOC */; | |
1214 aim_users = g_list_prepend (aim_users, u); | |
1215 } else { /* user already exists */ | |
1216 aim_users = g_list_remove (aim_users, u); | |
1217 aim_users = g_list_prepend (aim_users, u); | |
1218 } | |
1219 save_prefs(); | |
1220 } | |
1221 | |
1222 | |
1223 /* <name> is a comma-separated list of names, or NULL | |
1224 if NULL and there is at least one user defined in .gaimrc, try to login. | |
1225 if not NULL, parse <name> into separate strings, look up each one in | |
1226 .gaimrc and, if it's there, try to login. | |
1227 returns: 0 if successful | |
1228 -1 if no user was found that had a saved password | |
1229 */ | |
1230 int do_auto_login (char *name) | |
1231 { | |
1232 struct aim_user *u; | |
1233 char **names, **n, *first = NULL; | |
1234 int retval = -1; | |
1235 | |
1236 if (name != NULL) { /* list of names given */ | |
1237 names = g_strsplit (name, ",", 32); | |
1238 for (n = names; *n != NULL; n++) { | |
1239 printf ("user %s...\n", *n); | |
1240 u = find_user(*n); | |
1241 if (u) { /* found a user */ | |
1242 if (first == NULL) | |
1243 first = g_strdup (*n); | |
1244 if (u->options & OPT_USR_REM_PASS) { | |
1245 printf ("got user %s\n", *n); | |
1246 retval = 0; | |
1247 serv_login(u); | |
1248 } | |
1249 } | |
1250 } | |
1251 /* make the first user listed the default */ | |
1252 if (first != NULL) | |
1253 set_first_user (first); | |
1254 g_strfreev (names); | |
1255 g_free (first); | |
1256 } else { /* no name given, use default */ | |
1257 u = (struct aim_user *)aim_users->data; | |
1258 if (u->options & OPT_USR_REM_PASS) { | |
1259 retval = 0; | |
1260 serv_login(u); | |
1261 } | |
1262 } | |
1263 | |
1264 return retval; | |
1265 } | |
1266 |