diff -r 30113bfbe723 -r b3afb9f1e801 commands/listvdomain.cc --- a/commands/listvdomain.cc Sun Jan 20 00:12:17 2008 +0100 +++ b/commands/listvdomain.cc Sun Jan 20 00:22:09 2008 +0100 @@ -17,7 +17,7 @@ #include #include "config/configrc.h" #include "vpwentry/vpwentry.h" -#include "cli/cli.h" +#include "cli++/cli++.h" #include "fdbuf/fdbuf.h" #include "vcommand.h" @@ -34,7 +34,7 @@ // This program lists all the users in a domain. // The listing consists of one user per line, // and each line has three columns: -// the virtual user name, the mailbox directory (or C<-> if none is set), +// the virtual user name, C or C depending if the user has a mailbox, // and an optional list of forwarding addresses, all seperated by a space. cli_option cli_options[] = { @@ -49,18 +49,13 @@ void show_user(const vpwentry& vpw) { - if(o_noaliases && !vpw.mailbox) + if(o_noaliases && !vpw.has_mailbox) return; - if(o_nousers && !!vpw.mailbox) + if(o_nousers && vpw.has_mailbox) return; - fout << vpw.name; - if(!vpw.mailbox) - fout << " -"; - else { - fout << ' ' << vpw.mailbox; - if(!vpw.is_mailbox_enabled) - fout << "(disabled)"; - } + fout << vpw.name << (vpw.has_mailbox ? " Yes" : " No"); + if(!vpw.is_mailbox_enabled) + fout << "(disabled)"; for(mystring_iter iter(vpw.forwards, '\0'); iter; ++iter) fout << ' ' << *iter; fout << '\n'; @@ -84,9 +79,8 @@ fout << "User Mailbox Aliases\n"; if(argc) { - vpwentry* vpw; for(int i = 0; i < argc; i++) { - vpw = table->getbyname(argv[i]); + vpwentry* vpw = table->getbyname(argv[i]); if(!vpw) { if(!o_quiet) ferr << "listvdomain: unknown user '" << argv[i] << "'" << endl; @@ -105,9 +99,11 @@ ferr << "listvdomain: Can't open password table" << endl; return 1; } - vpwentry vpw; - while(r->get(vpw)) - show_user(vpw); + vpwentry* vpw; + while((vpw = r->get()) != 0) { + show_user(*vpw); + delete vpw; + } delete r; } return errors;