Esempio n. 1
0
int cmd_open
    (
        char** args
    )
{
    args[0] = "open";
    return shell_launch( args );
}
Esempio n. 2
0
int cmd_list
    (
        char** args
    )
{
    args[0] = "ls";
    return shell_launch( args );
} /* cmd_list() */
Esempio n. 3
0
int cmd_clear
    (
        char** args
    )
{
    args[0] = "clear";
    return shell_launch( args );
} /* cmd_clear() */
Esempio n. 4
0
int cmd_cd_list
    (
        char** args
    )
{
    cmd_cd( args );

    args[0] = "ls";
    args[1] = NULL;
    return shell_launch( args );
} /* cmd_cd_list() */
Esempio n. 5
0
int shell_execute(char *args)
{
  int i;
  char *newArgs = strdup(args);
  char **args_arr = malloc(sizeof(char **)*(strlen(newArgs)));
  args_arr = &newArgs;
  free(newArgs);
  if (args[0] == NULL) { // if user inputs an empty command 
    
    return 1;
  }
  for(i = 0; i < strlen(args-1); i++) // loop to run multiple args programs 
  {
    if (strcmp(&args[i], "exit") == 0) {
      return 0;
    }
    return shell_launch(&args[i]);
  }

  return shell_launch(&args[i]);
}
Esempio n. 6
0
int execute_command(char **args)                  //function to execute a user command
{
  int i;
  if (args[0] == NULL) {                          // If command is empty.
   return 1;
  }

  for (i = 0; i <(sizeof(shell_cmd)/sizeof(char*)); i++) {
    if (strcmp(args[0], shell_cmd[i]) == 0) {    //compare input command with given command list
      return (*command_list[i])(args);
	 
    }
  }
  return shell_launch(args);
}
Esempio n. 7
0
int cmd_vi
    (
        char** args
    )
{
    if( NULL == args[1] )
    {
        fprintf( stderr, "Expected another argument.\n" );
        return TRUE;
    }
    else
    {
        args[0] = "vi";
        return shell_launch( args );
    }
} /* cmd_vi() */
Esempio n. 8
0
int cmd_sublime_text_2
    (
        char** args
    )
{
    if( NULL == args[1] )
    {
        fprintf( stderr, "Expected another argument.\n" );
        return TRUE;
    }
    else
    {
        args[0] = "open";
        args[2] = "-a";
        args[3] = "sublime text 2";
        return shell_launch( args );
    }
} /* cmd_sublime_text_2() */
Esempio n. 9
0
int shell_execute
    (
        char** args
    )
{
    // Local variables
    int i;

    if( NULL == args[0] )
    {
        return TRUE;
    }

    for( i = 0; i < array_cnt( commands ); i++ )
    {
        if( 0 == strcmp( args[0], commands[i].cmd_string ) )
        {
            return (*(commands[i].function_ptr))(args);
        }
    }

    return shell_launch( args );
} /* shell_execute() */