Commit 7eb89932 7eb899324a1dbe4d3bfcc73d9c0da8b4d4991f3e by Jakob Kaivo

More mailx functionality

1 parent 88d64cd7
...@@ -16,16 +16,54 @@ ...@@ -16,16 +16,54 @@
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 17
18 #include "mail.h" 18 #include "mail.h"
19 #include "table.h"
19 20
20 /* 21 /*
21 * hel[p] 22 * hel[p] [command]
22 * ? 23 * ? [command]
23 * *
24 */ 24 */
25 25
26 int 26 int
27 mail_help (int argc, char **argv) 27 mail_help (int argc, char **argv)
28 { 28 {
29 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 29 if (argc < 2)
30 {
31 int i = 0;
32 while (mail_command_table[i].synopsis != 0)
33 printf ("%s\n", mail_command_table[i++].synopsis);
34 return 0;
35 }
36 else
37 {
38 int status = 0;
39 int command = 0;
40 while (++command < argc)
41 {
42 char *cmd = argv[command];
43 int i = 0, printed = 0, sl = 0, ll = 0, len = strlen (cmd);
44 while (mail_command_table[i].shortname != 0 && printed == 0)
45 {
46 sl = strlen (mail_command_table[i].shortname);
47 ll = strlen (mail_command_table[i].longname);
48 if (sl == len && !strcmp (mail_command_table[i].shortname, cmd))
49 {
50 printed = 1;
51 printf ("%s\n", mail_command_table[i].synopsis);
52 }
53 else if (sl < len && !strncmp (mail_command_table[i].longname,
54 cmd, len))
55 {
56 printed = 1;
57 printf ("%s\n", mail_command_table[i].synopsis);
58 }
59 i++;
60 }
61 if (printed == 0)
62 {
63 printf ("Unknown command: %s\n", cmd);
64 status = 1;
65 }
66 }
67 }
30 return 1; 68 return 1;
31 } 69 }
......
...@@ -16,14 +16,43 @@ ...@@ -16,14 +16,43 @@
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 17
18 #include "mail.h" 18 #include "mail.h"
19 #include "table.h"
19 20
20 /* 21 /*
21 * l[ist] 22 * l[ist]
23 * *
22 */ 24 */
23 25
24 int 26 int
25 mail_list (int argc, char **argv) 27 mail_list (int argc, char **argv)
26 { 28 {
27 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 29 int i = 0, pos = 0, columns = 80, len = 0;
28 return 1; 30 char *cmd;
31 char *col = getenv ("COLUMNS");
32
33 if (col)
34 columns = strtol (col, NULL, 10);
35
36 for (i=0; mail_command_table[i].shortname != 0; i++)
37 {
38 len = strlen (mail_command_table[i].longname);
39 if (len < 1)
40 {
41 cmd = mail_command_table[i].shortname;
42 len = strlen (cmd);
43 }
44 else
45 cmd = mail_command_table[i].longname;
46
47 pos += len + 1;
48
49 if (pos >= columns)
50 {
51 pos = 0;
52 printf ("\n");
53 }
54 printf ("%s ", cmd);
55 }
56 printf ("\n");
57 return 0;
29 } 58 }
......
...@@ -117,6 +117,7 @@ static struct mail_command_entry mail_command_table[] = { ...@@ -117,6 +117,7 @@ static struct mail_command_entry mail_command_table[] = {
117 { "z", "", mail_z, "z[+|-]" }, 117 { "z", "", mail_z, "z[+|-]" },
118 { "!", "", mail_bang, "!command" }, 118 { "!", "", mail_bang, "!command" },
119 { "=", "=", mail_eq, "=" }, 119 { "=", "=", mail_eq, "=" },
120 { "#", "#", NULL, "# comment" },
120 { 0, 0, 0, 0,} 121 { 0, 0, 0, 0,}
121 }; 122 };
122 123
......