|
15 | 15 |
|
16 | 16 | #define MSG_MAX 512 /* guaranteed max message length */
|
17 | 17 | #define CHA_MAX 200 /* guaranteed max channel length */
|
18 |
| -#define VERSION "0.1.1" /* software version */ |
19 |
| -#define USAGE "kirc [-s hostname] [-p port] [-c channel] [-n nick] \ |
20 |
| -[-r real_name] [-u username] [-k password] [-a token] [-x init_command] \ |
21 |
| -[-w columns] [-W columns] [-o path] [-h|v|V]" |
22 | 18 |
|
23 | 19 | static int conn; /* connection socket */
|
24 | 20 | static char chan_default[MSG_MAX]; /* default channel for PRIVMSG */
|
@@ -275,35 +271,42 @@ keyboard_hit() {
|
275 | 271 | return byteswaiting;
|
276 | 272 | }
|
277 | 273 |
|
| 274 | +static void |
| 275 | +usage(void) { |
| 276 | + fputs("kirc [-s hostname] [-p port] [-c channel] [-n nick] \ |
| 277 | +[-r real_name] [-u username] [-k password] [-a token] [-x init_command] \ |
| 278 | +[-w columns] [-W columns] [-o path] [-h|v|V]\n", stderr); |
| 279 | + exit(EXIT_FAILURE); |
| 280 | +} |
| 281 | + |
278 | 282 | int
|
279 | 283 | main(int argc, char **argv) {
|
280 | 284 |
|
281 | 285 | int cval;
|
282 | 286 |
|
283 | 287 | while ((cval = getopt(argc, argv, "s:p:o:n:k:c:u:r:x:w:W:a:hvV")) != -1) {
|
284 | 288 | switch (cval) {
|
285 |
| - case 'V' : verb = 1; break; |
286 |
| - case 's' : host = optarg; break; |
287 |
| - case 'p' : port = optarg; break; |
288 |
| - case 'r' : real = optarg; break; |
289 |
| - case 'u' : user = optarg; break; |
290 |
| - case 'a' : auth = optarg; break; |
291 |
| - case 'o' : olog = optarg; break; |
292 |
| - case 'n' : nick = optarg; break; |
293 |
| - case 'k' : pass = optarg; break; |
294 |
| - case 'c' : chan = optarg; break; |
295 |
| - case 'x' : inic = optarg; break; |
296 |
| - case 'w' : gutl = atoi(optarg); break; |
297 |
| - case 'W' : cmax = atoi(optarg); break; |
298 |
| - case 'v' : printf("kirc %s\n", VERSION); return EXIT_SUCCESS; |
299 |
| - case 'h' : printf("usage: %s\n", USAGE); return EXIT_SUCCESS; |
300 |
| - case '?' : return EXIT_FAILURE; |
| 289 | + case 'V' : verb = 1; break; |
| 290 | + case 's' : host = optarg; break; |
| 291 | + case 'p' : port = optarg; break; |
| 292 | + case 'r' : real = optarg; break; |
| 293 | + case 'u' : user = optarg; break; |
| 294 | + case 'a' : auth = optarg; break; |
| 295 | + case 'o' : olog = optarg; break; |
| 296 | + case 'n' : nick = optarg; break; |
| 297 | + case 'k' : pass = optarg; break; |
| 298 | + case 'c' : chan = optarg; break; |
| 299 | + case 'x' : inic = optarg; break; |
| 300 | + case 'w' : gutl = atoi(optarg); break; |
| 301 | + case 'W' : cmax = atoi(optarg); break; |
| 302 | + case 'v' : puts("kirc 0.1.2\n"); break; |
| 303 | + case '?' : usage(); break; |
301 | 304 | }
|
302 | 305 | }
|
303 | 306 |
|
304 | 307 | if (!nick) {
|
305 | 308 | fputs("Nick not specified\n", stderr);
|
306 |
| - return EXIT_FAILURE; |
| 309 | + usage(); |
307 | 310 | }
|
308 | 311 |
|
309 | 312 | if (connection_initialize() != 0) {
|
|
0 commit comments