Commit 7eb89932 7eb899324a1dbe4d3bfcc73d9c0da8b4d4991f3e by Jakob Kaivo

More mailx functionality

1 parent 88d64cd7
......@@ -16,16 +16,54 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "mail.h"
#include "table.h"
/*
* hel[p]
* ?
* *
* hel[p] [command]
* ? [command]
*/
int
mail_help (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
if (argc < 2)
{
int i = 0;
while (mail_command_table[i].synopsis != 0)
printf ("%s\n", mail_command_table[i++].synopsis);
return 0;
}
else
{
int status = 0;
int command = 0;
while (++command < argc)
{
char *cmd = argv[command];
int i = 0, printed = 0, sl = 0, ll = 0, len = strlen (cmd);
while (mail_command_table[i].shortname != 0 && printed == 0)
{
sl = strlen (mail_command_table[i].shortname);
ll = strlen (mail_command_table[i].longname);
if (sl == len && !strcmp (mail_command_table[i].shortname, cmd))
{
printed = 1;
printf ("%s\n", mail_command_table[i].synopsis);
}
else if (sl < len && !strncmp (mail_command_table[i].longname,
cmd, len))
{
printed = 1;
printf ("%s\n", mail_command_table[i].synopsis);
}
i++;
}
if (printed == 0)
{
printf ("Unknown command: %s\n", cmd);
status = 1;
}
}
}
return 1;
}
......
......@@ -16,14 +16,43 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "mail.h"
#include "table.h"
/*
* l[ist]
* *
*/
int
mail_list (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
return 1;
int i = 0, pos = 0, columns = 80, len = 0;
char *cmd;
char *col = getenv ("COLUMNS");
if (col)
columns = strtol (col, NULL, 10);
for (i=0; mail_command_table[i].shortname != 0; i++)
{
len = strlen (mail_command_table[i].longname);
if (len < 1)
{
cmd = mail_command_table[i].shortname;
len = strlen (cmd);
}
else
cmd = mail_command_table[i].longname;
pos += len + 1;
if (pos >= columns)
{
pos = 0;
printf ("\n");
}
printf ("%s ", cmd);
}
printf ("\n");
return 0;
}
......
......@@ -117,6 +117,7 @@ static struct mail_command_entry mail_command_table[] = {
{ "z", "", mail_z, "z[+|-]" },
{ "!", "", mail_bang, "!command" },
{ "=", "=", mail_eq, "=" },
{ "#", "#", NULL, "# comment" },
{ 0, 0, 0, 0,}
};
......