summaryrefslogtreecommitdiff
path: root/src/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands.c')
-rw-r--r--src/commands.c157
1 files changed, 7 insertions, 150 deletions
diff --git a/src/commands.c b/src/commands.c
index db26130..b52a5a1 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -18,6 +18,9 @@
#include <completion.h>
#include <utils.h>
+#include <shell.h>
+#include <users.h>
+
/* Function which tells you that you can't do this. */
void too_dangerous( char *caller )
{
@@ -47,82 +50,7 @@ int valid_argument( char *caller, char *arg )
/* String to pass to system (). This is for the LIST, VIEW and RENAME
commands. */
-static char syscom[PATH_MAX];
-
-/* List the file(s) named in arg. */
-int com_ls( char *arg )
-{
- if( !arg )
- arg = "";
-
- sprintf( syscom, "ls -FClg %s", arg );
- return( system( syscom ) );
-}
-
-int com_id( char *arg )
-{
- if( !arg )
- arg = "";
-
- sprintf (syscom, "id %s", arg);
- return( system( syscom ) );
-}
-
-int com_more( char *arg )
-{
- if( !valid_argument( "more", arg ) )
- return( 1 );
-
- sprintf (syscom, "more %s", arg);
- return( system( syscom ) );
-}
-
-int com_vi( char *arg )
-{
- if( !valid_argument( "vi", arg ) )
- return( 1 );
-
- sprintf (syscom, "vi %s", arg);
- return( system( syscom ) );
-}
-
-int com_rename( char *arg )
-{
- too_dangerous( "rename" );
- return( 1 );
-}
-
-int com_stat( char *arg )
-{
- struct stat finfo;
-
- if( !valid_argument( "stat", arg ) )
- return( 1 );
-
- if( stat( arg, &finfo ) == -1 )
- {
- perror( arg );
- return( 1 );
- }
-
- printf( "Statistics for `%s':\n", arg );
-
- printf( "%s has %ld link%s, and is %ld byte%s in length.\n", arg,
- finfo.st_nlink,
- (finfo.st_nlink == 1) ? "" : "s",
- finfo.st_size,
- (finfo.st_size == 1) ? "" : "s");
- printf( "Inode Last Change at: %s", ctime( &finfo.st_ctime ) );
- printf( " Last access at: %s", ctime( &finfo.st_atime ) );
- printf( " Last modified at: %s", ctime( &finfo.st_mtime ) );
- return( 0 );
-}
-
-int com_delete( char *arg )
-{
- too_dangerous( "delete" );
- return( 1 );
-}
+//static char syscom[PATH_MAX];
/* Print out help for ARG, or for all of the commands if ARG is
not present. */
@@ -166,79 +94,6 @@ int com_help( char *arg )
return( 0 );
}
-/* Change to the directory ARG. */
-int com_cd( char *arg )
-{
- if( !strcmp( arg, "~" ) )
- {
- arg = getenv( "HOME" );
- }
-
- if( chdir( arg ) == -1 )
- {
- perror( arg );
- return( 1 );
- }
-
- com_pwd( "" );
- return( 0 );
-}
-
-/* Print out the current working directory. */
-int com_pwd( char *ignore )
-{
- char dir[PATH_MAX], *s;
-
- s = getcwd( dir, PATH_MAX );
- if( s == 0 )
- {
- printf( "Error getting pwd: %s\n", dir );
- return( 1 );
- }
-
- printf( "Current directory is: %s\n", dir );
- return( 0 );
-}
-
-int com_ping( char *arg )
-{
- if( !valid_argument( "ping", arg ) )
- return( 1 );
-
- sprintf (syscom, "ping %s", arg);
- return( system( syscom ) );
-}
-
-int com_useradd( char *arg )
-{
- /* temporary STUB. Should use busctl or REST */
- if( !valid_argument( "useradd", arg ) )
- return( 1 );
-
- sprintf (syscom, "useradd %s", arg);
- return( system( syscom ) );
-}
-
-int com_userdel( char *arg )
-{
- /* temporary STUB. Should use busctl or REST */
- if( !valid_argument( "userdel", arg ) )
- return( 1 );
-
- sprintf (syscom, "userdel %s", arg);
- return( system( syscom ) );
-}
-
-int com_userlist( char *arg )
-{
- /* temporary STUB. Should use busctl or REST */
- if( !arg ) arg = "";
-
- sprintf (syscom, "cat /etc/passwd | cut -f1 -d':' %s", arg);
- return( system( syscom ) );
-}
-
-
/* The user wishes to quit using this program. Just set DONE non-zero. */
int com_quit( char *arg )
{
@@ -247,7 +102,9 @@ int com_quit( char *arg )
}
-
+/*
+ Menu:
+ */
int com_shell( char *arg )
{
if( !arg ) arg = "";