Subversion Repositories Kolibri OS

Rev

Rev 7792 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7792 Rev 8827
Line 1... Line -...
1
/// ===========================================================
-
 
2
 
-
 
3
int executable_run(char cmd[], char args[])
1
int executable_run(char cmd[], char args[]) {
4
{
-
 
5
 
-
 
6
	char	exec[FILENAME_MAX];
2
    char	exec[FILENAME_MAX];
7
	int		result;
3
    int		result;
Line 8... Line 4...
8
 
4
 
9
	if ( '/' == cmd[0]) // if path is absolute
5
    if ( '/' == cmd[0]) // if path is absolute
Line 13... Line 9...
13
		{
9
        {
14
			file_not_found(cmd);
10
            file_not_found(cmd);
15
			return FALSE;
11
            return FALSE;
16
		}
12
        }
17
	}
13
    } else {
18
	else 
-
 
19
	{
14
        strcpy(exec, cur_dir); // check file in current directory
20
		strcpy(exec, cur_dir); // check file in current directory
-
 
21
		if (exec[strlen(exec)-1] != '/') 
15
        if (exec[strlen(exec)-1] != '/') 
22
			strcat(exec, "/"); // add slash
16
            strcat(exec, "/"); // add slash
23
		strcat(exec, cmd);
17
        strcat(exec, cmd);
24
		
18
        
Line 37... Line 31...
37
	// if file exists:
31
    // if file exists:
Line 38... Line 32...
38
 
32
 
39
	// try to run as a program
33
    // try to run as a program
40
	result = program_run(exec, args);
34
    result = program_run(exec, args);
41
	if (result > 0)
-
 
42
	{
35
    if (result > 0) {
43
		if ( !program_console(result)  )
-
 
44
		{
36
        if ( !program_console(result)  ) {
45
				LAST_PID = result;
-
 
46
			#if LANG_ENG
37
            LAST_PID = result;
47
				printf ("  '%s' started. PID = %d\n\r", cmd, result);
-
 
48
			#elif LANG_RUS
-
 
49
				printf ("  '%s' § ¯ã饭. PID = %d\n\r", cmd, result);
-
 
50
			#endif
38
            printf (EXEC_STARTED_FMT, cmd, result);
51
		}
39
        }
52
		return TRUE;
-
 
53
	}
40
        return TRUE;
54
	else	
-
 
55
	{
41
    } else	{
56
		if ( script_check(exec) ) // if file is a valid script
42
        if ( script_check(exec) ) // if file is a valid script
57
		{
43
        {
58
			return script_run(exec, args);
44
            return script_run(exec, args);
59
		} else
45
        } else
60
		{
-
 
61
			#if LANG_ENG
46
        {
62
				printf ("Error in '%s' : script must start with #SHS line\n\r", cmd);
-
 
63
			#elif LANG_RUS
-
 
64
				printf ("Žè¨¡ª  ¢ '%s' : áªà¨¯â ¤®«¦¥­ ­ ç¨­ âìáï á® áâà®çª¨ #SHS\n\r", cmd);
-
 
65
			#endif
47
            printf (EXEC_SCRIPT_ERROR_FMT, cmd);
66
			return FALSE;
48
            return FALSE;
67
		}
49
        }
Line 68... Line 50...
68
	}
50
    }
Line 69... Line -...
69
 
-
 
70
}
-