#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Function which tells you that you can't do this. */ void too_dangerous( char *caller ) { fprintf( stderr, "%s: Too dangerous for me to distribute. Write it yourself.\n", caller ); } /* Return non-zero if ARG is a valid argument for CALLER, else print an error message and return zero. */ int valid_argument( char *caller, char *arg ) { if( !arg || !*arg ) { fprintf( stderr, "%s: Argument required.\n", caller ); return( 0 ); } return( 1 ); } /* **************************************************************** */ /* */ /* SILA Shell Commands */ /* */ /* **************************************************************** */ /* String to pass to system (). This is for the LIST, VIEW and RENAME commands. */ //static char syscom[PATH_MAX]; /* Print out help for ARG, or for all of the commands if ARG is not present. */ int com_help( char *arg ) { register int i; int printed = 0; for( i = 0; current->list[i].name; ++i ) { if( !*arg || (strcmp( arg, current->list[i].name ) == 0) ) { printf( " %-12s\t- %s.\n", current->list[i].name, current->list[i].doc ); printed++; } } if( printed ) printf( "\n" ); if( !printed ) { printf( "No commands match `%s'. Possibilties are:\n", arg ); for( i = 0; current->list[i].name; ++i ) { /* Print in six columns. */ if( printed == 6 ) { printed = 0; printf( "\n" ); } printf( "%s\t", current->list[i].name ); printed++; } if( printed ) printf( "\n" ); } return( 0 ); } /* The user wishes to quit using this program. Just set DONE non-zero. */ int com_quit( char *arg ) { done = 1; return( 0 ); } /* Menu: */ int com_shell( char *arg ) { if( !arg ) arg = ""; current = &shell; initialize_readline(); return( 0 ); } int com_users( char *arg ) { if( !arg ) arg = ""; current = &users; initialize_readline(); return( 0 ); } int com_top( char *arg ) { if( !arg ) arg = ""; current = ⊤ initialize_readline(); return( 0 ); }