Commit 4f403bc1 4f403bc1d96965717ef16eaa2939f3ed13d8b1c8 by Sergey Poznyakoff

Minor fixes

1 parent 5a38250f
...@@ -38,15 +38,19 @@ ...@@ -38,15 +38,19 @@
38 38
39 #include <mailutils/pop3.h> 39 #include <mailutils/pop3.h>
40 #include <mailutils/iterator.h> 40 #include <mailutils/iterator.h>
41 #include <mailutils/error.h>
42 #include <mailutils/errno.h>
41 43
42 /* A structure which contains information on the commands this program 44 /* A structure which contains information on the commands this program
43 can understand. */ 45 can understand. */
44 46
45 typedef struct { 47 typedef struct
48 {
46 const char *name; /* User printable name of the function. */ 49 const char *name; /* User printable name of the function. */
47 int (*func) (char *); /* Function to call to do the job. */ 50 int (*func) (char *); /* Function to call to do the job. */
48 const char *doc; /* Documentation for this function. */ 51 const char *doc; /* Documentation for this function. */
49 } COMMAND; 52 }
53 COMMAND;
50 54
51 /* The names of functions that actually do the manipulation. */ 55 /* The names of functions that actually do the manipulation. */
52 int com_apop (char *); 56 int com_apop (char *);
...@@ -78,26 +82,26 @@ int valid_argument (const char *, char *); ...@@ -78,26 +82,26 @@ int valid_argument (const char *, char *);
78 void sig_int (int); 82 void sig_int (int);
79 83
80 COMMAND commands[] = { 84 COMMAND commands[] = {
81 { "apop", com_apop, "Authenticate with APOP: APOP user secret" }, 85 {"apop", com_apop, "Authenticate with APOP: APOP user secret"},
82 { "capa", com_capa, "List capabilities: capa" }, 86 {"capa", com_capa, "List capabilities: capa"},
83 { "disconnect", com_disconnect, "Close connection: disconnect" }, 87 {"disconnect", com_disconnect, "Close connection: disconnect"},
84 { "dele", com_dele, "Mark message: DELE msgno" }, 88 {"dele", com_dele, "Mark message: DELE msgno"},
85 { "exit", com_exit, "exit program" }, 89 {"exit", com_exit, "exit program"},
86 { "help", com_help, "Display this text" }, 90 {"help", com_help, "Display this text"},
87 { "?", com_help, "Synonym for `help'" }, 91 {"?", com_help, "Synonym for `help'"},
88 { "list", com_list, "List messages: LIST [msgno]" }, 92 {"list", com_list, "List messages: LIST [msgno]"},
89 { "noop", com_noop, "Send no operation: NOOP" }, 93 {"noop", com_noop, "Send no operation: NOOP"},
90 { "pass", com_pass, "Send passwd: PASS [passwd]" }, 94 {"pass", com_pass, "Send passwd: PASS [passwd]"},
91 { "connect", com_connect, "Open connection: connect hostname [port]" }, 95 {"connect", com_connect, "Open connection: connect hostname [port]"},
92 { "quit", com_quit, "Go to Update state : QUIT" }, 96 {"quit", com_quit, "Go to Update state : QUIT"},
93 { "retr", com_retr, "Dowload message: RETR msgno" }, 97 {"retr", com_retr, "Dowload message: RETR msgno"},
94 { "rset", com_rset, "Unmark all messages: RSET" }, 98 {"rset", com_rset, "Unmark all messages: RSET"},
95 { "stat", com_stat, "Get the size and count of mailbox : STAT [msgno]" }, 99 {"stat", com_stat, "Get the size and count of mailbox : STAT [msgno]"},
96 { "top", com_top, "Get the header of message: TOP msgno [lines]" }, 100 {"top", com_top, "Get the header of message: TOP msgno [lines]"},
97 { "uidl", com_uidl, "Get the uniq id of message: UIDL [msgno]" }, 101 {"uidl", com_uidl, "Get the unique id of message: UIDL [msgno]"},
98 { "user", com_user, "send login: USER user" }, 102 {"user", com_user, "send login: USER user"},
99 { "verbose", com_verbose, "Enable Protocol tracing: verbose [on|off]" }, 103 {"verbose", com_verbose, "Enable Protocol tracing: verbose [on|off]"},
100 { NULL, NULL, NULL } 104 {NULL, NULL, NULL}
101 }; 105 };
102 106
103 /* The name of this program, as taken from argv[0]. */ 107 /* The name of this program, as taken from argv[0]. */
...@@ -141,10 +145,10 @@ void ...@@ -141,10 +145,10 @@ void
141 initialize_readline () 145 initialize_readline ()
142 { 146 {
143 /* Allow conditional parsing of the ~/.inputrc file. */ 147 /* Allow conditional parsing of the ~/.inputrc file. */
144 rl_readline_name = (char *)"pop3"; 148 rl_readline_name = (char *) "pop3";
145 149
146 /* Tell the completer that we want a crack first. */ 150 /* Tell the completer that we want a crack first. */
147 rl_attempted_completion_function = (CPPFunction *)pop_completion; 151 rl_attempted_completion_function = (CPPFunction *) pop_completion;
148 } 152 }
149 153
150 /* Attempt to complete on the contents of TEXT. START and END bound the 154 /* Attempt to complete on the contents of TEXT. START and END bound the
...@@ -157,8 +161,8 @@ pop_completion (char *text, int start, int end) ...@@ -157,8 +161,8 @@ pop_completion (char *text, int start, int end)
157 { 161 {
158 char **matches; 162 char **matches;
159 163
160 (void)end; 164 (void) end;
161 matches = (char **)NULL; 165 matches = (char **) NULL;
162 166
163 /* If this word is at the start of the line, then it is a command 167 /* If this word is at the start of the line, then it is a command
164 to complete. Otherwise it is the name of a file in the current 168 to complete. Otherwise it is the name of a file in the current
...@@ -193,11 +197,11 @@ command_generator (const char *text, int state) ...@@ -193,11 +197,11 @@ command_generator (const char *text, int state)
193 list_index++; 197 list_index++;
194 198
195 if (strncmp (name, text, len) == 0) 199 if (strncmp (name, text, len) == 0)
196 return (dupstr(name)); 200 return (dupstr (name));
197 } 201 }
198 202
199 /* If no names matched, then return NULL. */ 203 /* If no names matched, then return NULL. */
200 return ((char *)NULL); 204 return ((char *) NULL);
201 } 205 }
202 206
203 #else 207 #else
...@@ -223,18 +227,17 @@ readline (char *prompt) ...@@ -223,18 +227,17 @@ readline (char *prompt)
223 } 227 }
224 228
225 void 229 void
226 add_history (const char *s) 230 add_history (const char *s ARG_UNUSED)
227 { 231 {
228 } 232 }
229 #endif 233 #endif
230 234
231 235
232 int 236 int
233 main (int argc, char **argv) 237 main (int argc ARG_UNUSED, char **argv)
234 { 238 {
235 char *line, *s; 239 char *line, *s;
236 240
237 (void)argc;
238 progname = strrchr (argv[0], '/'); 241 progname = strrchr (argv[0], '/');
239 if (progname) 242 if (progname)
240 progname++; 243 progname++;
...@@ -244,10 +247,10 @@ main (int argc, char **argv) ...@@ -244,10 +247,10 @@ main (int argc, char **argv)
244 initialize_readline (); /* Bind our completer. */ 247 initialize_readline (); /* Bind our completer. */
245 248
246 /* Loop reading and executing lines until the user quits. */ 249 /* Loop reading and executing lines until the user quits. */
247 for ( ; done == 0; ) 250 while (!done)
248 { 251 {
249 252
250 line = readline ((char *)"pop3> "); 253 line = readline ((char *) "pop3> ");
251 254
252 if (!line) 255 if (!line)
253 break; 256 break;
...@@ -263,7 +266,7 @@ main (int argc, char **argv) ...@@ -263,7 +266,7 @@ main (int argc, char **argv)
263 add_history (s); 266 add_history (s);
264 status = execute_line (s); 267 status = execute_line (s);
265 if (status != 0) 268 if (status != 0)
266 fprintf (stderr, "Error: %s\n", strerror(status)); 269 fprintf (stderr, "Error: %s\n", mu_strerror (status));
267 } 270 }
268 271
269 free (line); 272 free (line);
...@@ -321,7 +324,7 @@ find_command (name) ...@@ -321,7 +324,7 @@ find_command (name)
321 if (strcmp (name, commands[i].name) == 0) 324 if (strcmp (name, commands[i].name) == 0)
322 return (&commands[i]); 325 return (&commands[i]);
323 326
324 return ((COMMAND *)NULL); 327 return ((COMMAND *) NULL);
325 } 328 }
326 329
327 /* Strip whitespace from the start and end of STRING. Return a pointer 330 /* Strip whitespace from the start and end of STRING. Return a pointer
...@@ -393,18 +396,17 @@ com_apop (char *arg) ...@@ -393,18 +396,17 @@ com_apop (char *arg)
393 } 396 }
394 397
395 int 398 int
396 com_capa (char *arg) 399 com_capa (char *arg ARG_UNUSED)
397 { 400 {
398 list_t list = NULL; 401 list_t list = NULL;
399 int status = mu_pop3_capa (pop3, &list); 402 int status = mu_pop3_capa (pop3, &list);
400 (void)arg; 403
401 if (status == 0) 404 if (status == 0)
402 { 405 {
403 iterator_t iterator = NULL; 406 iterator_t iterator = NULL;
404 iterator_create (&iterator, list); 407 iterator_create (&iterator, list);
405 for (iterator_first (iterator); 408 for (iterator_first (iterator);
406 !iterator_is_done (iterator); 409 !iterator_is_done (iterator); iterator_next (iterator))
407 iterator_next (iterator))
408 { 410 {
409 char *capa = NULL; 411 char *capa = NULL;
410 iterator_current (iterator, (void **) &capa); 412 iterator_current (iterator, (void **) &capa);
...@@ -434,10 +436,10 @@ com_uidl (char *arg) ...@@ -434,10 +436,10 @@ com_uidl (char *arg)
434 { 436 {
435 char *uidl = NULL; 437 char *uidl = NULL;
436 iterator_current (uidl_iterator, (void **) &uidl); 438 iterator_current (uidl_iterator, (void **) &uidl);
437 printf ("UIDL: %s\n", (uidl) ? uidl : "") ; 439 printf ("UIDL: %s\n", (uidl) ? uidl : "");
438 } 440 }
439 iterator_destroy (&uidl_iterator); 441 iterator_destroy (&uidl_iterator);
440 list_destroy(&list); 442 list_destroy (&list);
441 } 443 }
442 } 444 }
443 else 445 else
...@@ -488,14 +490,13 @@ com_list (char *arg) ...@@ -488,14 +490,13 @@ com_list (char *arg)
488 } 490 }
489 491
490 int 492 int
491 com_noop (char *arg) 493 com_noop (char *arg ARG_UNUSED)
492 { 494 {
493 (void)arg;
494 return mu_pop3_noop (pop3); 495 return mu_pop3_noop (pop3);
495 } 496 }
496 497
497 static void 498 static void
498 echo_off(struct termios *stored_settings) 499 echo_off (struct termios *stored_settings)
499 { 500 {
500 struct termios new_settings; 501 struct termios new_settings;
501 tcgetattr (0, stored_settings); 502 tcgetattr (0, stored_settings);
...@@ -505,7 +506,7 @@ echo_off(struct termios *stored_settings) ...@@ -505,7 +506,7 @@ echo_off(struct termios *stored_settings)
505 } 506 }
506 507
507 static void 508 static void
508 echo_on(struct termios *stored_settings) 509 echo_on (struct termios *stored_settings)
509 { 510 {
510 tcsetattr (0, TCSANOW, stored_settings); 511 tcsetattr (0, TCSANOW, stored_settings);
511 } 512 }
...@@ -525,19 +526,18 @@ com_pass (char *arg) ...@@ -525,19 +526,18 @@ com_pass (char *arg)
525 echo_on (&stored_settings); 526 echo_on (&stored_settings);
526 putchar ('\n'); 527 putchar ('\n');
527 fflush (stdout); 528 fflush (stdout);
528 pass [strlen (pass) - 1] = '\0'; /* nuke the trailing line. */ 529 pass[strlen (pass) - 1] = '\0'; /* nuke the trailing line. */
529 arg = pass; 530 arg = pass;
530 } 531 }
531 return mu_pop3_pass (pop3, arg); 532 return mu_pop3_pass (pop3, arg);
532 } 533 }
533 534
534 int 535 int
535 com_stat (char *arg) 536 com_stat (char *arg ARG_UNUSED)
536 { 537 {
537 unsigned count, size; 538 unsigned count, size;
538 int status = 0; 539 int status = 0;
539 540
540 (void)arg;
541 count = size = 0; 541 count = size = 0;
542 status = mu_pop3_stat (pop3, &count, &size); 542 status = mu_pop3_stat (pop3, &count, &size);
543 fprintf (stdout, "Mesgs: %d Size %d\n", count, size); 543 fprintf (stdout, "Mesgs: %d Size %d\n", count, size);
...@@ -595,9 +595,8 @@ com_help (char *arg) ...@@ -595,9 +595,8 @@ com_help (char *arg)
595 } 595 }
596 596
597 int 597 int
598 com_rset (char *arg) 598 com_rset (char *arg ARG_UNUSED)
599 { 599 {
600 (void)arg;
601 return mu_pop3_rset (pop3); 600 return mu_pop3_rset (pop3);
602 } 601 }
603 602
...@@ -664,7 +663,7 @@ int ...@@ -664,7 +663,7 @@ int
664 com_connect (char *arg) 663 com_connect (char *arg)
665 { 664 {
666 char host[256]; 665 char host[256];
667 int port = 0; 666 int port = 110;
668 int status; 667 int status;
669 if (!valid_argument ("connect", arg)) 668 if (!valid_argument ("connect", arg))
670 return 1; 669 return 1;
...@@ -681,7 +680,9 @@ com_connect (char *arg) ...@@ -681,7 +680,9 @@ com_connect (char *arg)
681 680
682 if (verbose) 681 if (verbose)
683 com_verbose ("verbose on"); 682 com_verbose ("verbose on");
684 status = tcp_stream_create (&tcp, host, port, MU_STREAM_READ | MU_STREAM_NO_CHECK); 683 status =
684 tcp_stream_create (&tcp, host, port,
685 MU_STREAM_READ | MU_STREAM_NO_CHECK);
685 if (status == 0) 686 if (status == 0)
686 { 687 {
687 mu_pop3_set_carrier (pop3, tcp); 688 mu_pop3_set_carrier (pop3, tcp);
...@@ -695,7 +696,7 @@ com_connect (char *arg) ...@@ -695,7 +696,7 @@ com_connect (char *arg)
695 } 696 }
696 697
697 if (status != 0) 698 if (status != 0)
698 fprintf (stderr, "Failed to create pop3: %s\n", strerror (status)); 699 fprintf (stderr, "Failed to create pop3: %s\n", mu_strerror (status));
699 return status; 700 return status;
700 } 701 }
701 702
...@@ -713,9 +714,8 @@ com_disconnect (char *arg) ...@@ -713,9 +714,8 @@ com_disconnect (char *arg)
713 } 714 }
714 715
715 int 716 int
716 com_quit (char *arg) 717 com_quit (char *arg ARG_UNUSED)
717 { 718 {
718 (void)arg;
719 if (pop3) 719 if (pop3)
720 { 720 {
721 if (mu_pop3_quit (pop3) == 0) 721 if (mu_pop3_quit (pop3) == 0)
...@@ -733,9 +733,8 @@ com_quit (char *arg) ...@@ -733,9 +733,8 @@ com_quit (char *arg)
733 } 733 }
734 734
735 int 735 int
736 com_exit (char *arg) 736 com_exit (char *arg ARG_UNUSED)
737 { 737 {
738 (void)arg;
739 if (pop3) 738 if (pop3)
740 { 739 {
741 mu_pop3_disconnect (pop3); 740 mu_pop3_disconnect (pop3);
...@@ -758,4 +757,3 @@ valid_argument (const char *caller, char *arg) ...@@ -758,4 +757,3 @@ valid_argument (const char *caller, char *arg)
758 757
759 return 1; 758 return 1;
760 } 759 }
761
......