2008-05-12 13:56:18 +04:00
/*
Samba Unix / Linux SMB client library
2002-04-05 05:36:28 +04:00
net help commands
Copyright ( C ) 2002 Jim McDonough ( jmcd @ us . ibm . com )
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2002-04-05 05:36:28 +04:00
( at your option ) any later version .
2008-05-12 13:56:18 +04:00
2002-04-05 05:36:28 +04:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2008-05-12 13:56:18 +04:00
2002-04-05 05:36:28 +04:00
You should have received a copy of the GNU General Public License
2008-05-12 13:56:18 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2002-04-05 05:36:28 +04:00
*/
# include "includes.h"
2004-10-07 08:01:18 +04:00
# include "utils/net.h"
2002-04-05 05:36:28 +04:00
2008-05-19 02:19:18 +04:00
static int net_usage ( struct net_context * c , int argc , const char * * argv ) ;
2008-05-15 12:14:41 +04:00
static int net_help_usage ( struct net_context * c , int argc , const char * * argv )
2002-04-05 05:36:28 +04:00
{
2008-05-19 02:19:18 +04:00
c - > display_usage = true ;
return net_usage ( c , argc , argv ) ;
2002-04-05 05:36:28 +04:00
}
2008-05-10 01:22:12 +04:00
static int net_usage ( struct net_context * c , int argc , const char * * argv )
2002-04-05 05:36:28 +04:00
{
2008-06-07 04:25:08 +04:00
struct functable * table = ( struct functable * ) c - > private_data ;
2008-05-19 02:19:18 +04:00
int i ;
2009-07-30 13:30:33 +04:00
d_printf ( _ ( " Usage: \n " ) ) ;
2008-05-19 02:19:18 +04:00
for ( i = 0 ; table [ i ] . funcname ! = NULL ; i + + ) {
if ( c - > display_usage ) {
2009-07-30 13:30:33 +04:00
d_printf ( _ ( " net %s usage: \n " ) , table [ i ] . funcname ) ;
2010-01-05 11:43:34 +03:00
d_printf ( " \n %s \n \n " , _ ( table [ i ] . usage ) ) ;
2008-05-19 02:19:18 +04:00
} else {
d_printf ( " %s %-15s %s \n " , " net " , table [ i ] . funcname ,
2010-01-05 11:43:34 +03:00
_ ( table [ i ] . description ) ) ;
2008-05-19 02:19:18 +04:00
}
}
2008-05-10 01:22:12 +04:00
net_common_flags_usage ( c , argc , argv ) ;
2002-04-05 05:36:28 +04:00
return - 1 ;
}
/*
handle " net help * " subcommands
*/
2008-05-10 01:22:12 +04:00
int net_help ( struct net_context * c , int argc , const char * * argv )
2002-04-05 05:36:28 +04:00
{
2008-06-07 04:25:08 +04:00
struct functable * func = ( struct functable * ) c - > private_data ;
2002-04-05 05:36:28 +04:00
2008-05-19 02:19:18 +04:00
if ( argc = = 0 ) {
return net_usage ( c , argc , argv ) ;
}
2006-02-04 01:19:41 +03:00
2008-05-19 02:19:18 +04:00
if ( StrCaseCmp ( argv [ 0 ] , " help " ) = = 0 ) {
return net_help_usage ( c , argc , argv ) ;
}
2002-04-05 05:36:28 +04:00
2008-05-19 02:19:18 +04:00
c - > display_usage = true ;
2008-06-07 04:25:08 +04:00
return net_run_function ( c , argc , argv , " net help " , func ) ;
2002-04-05 05:36:28 +04:00
}