Subversion Repositories HelenOS

Rev

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

Rev 3425 Rev 4377
Line 38... Line 38...
38
#include "cmds.h"
38
#include "cmds.h"
39
#include "builtin_aliases.h"
39
#include "builtin_aliases.h"
40
 
40
 
41
extern volatile unsigned int cli_interactive;
41
extern volatile unsigned int cli_interactive;
42
 
42
 
43
int builtin_is_restricted(int pos)
-
 
44
{
-
 
45
    builtin_t *cmd = builtins;
-
 
46
    cmd += pos;
-
 
47
 
-
 
48
    if (cli_interactive && cmd->restricted <= 0)
-
 
49
        return 0;
-
 
50
    if (!cli_interactive && cmd->restricted >= 0)
-
 
51
        return 0;
-
 
52
 
-
 
53
    return 1;
-
 
54
}
-
 
55
 
-
 
56
int is_builtin(const char *command)
43
int is_builtin(const char *command)
57
{
44
{
58
    builtin_t *cmd;
45
    builtin_t *cmd;
59
    unsigned int i = 0;
46
    unsigned int i = 0;
60
 
47
 
61
    if (NULL == command)
48
    if (NULL == command)
62
        return -2;
49
        return -2;
63
 
50
 
64
    for (cmd = builtins; cmd->name != NULL; cmd++, i++) {
51
    for (cmd = builtins; cmd->name != NULL; cmd++, i++) {
65
        if (!strcmp(cmd->name, command))
52
        if (!str_cmp(cmd->name, command))
66
            return i;
53
            return i;
67
    }
54
    }
68
 
55
 
69
    return -1;
56
    return -1;
70
}
57
}
Line 75... Line 62...
75
 
62
 
76
    if (NULL == command)
63
    if (NULL == command)
77
        return -1;
64
        return -1;
78
 
65
 
79
    for(i=0; builtin_aliases[i] != NULL; i+=2) {
66
    for(i=0; builtin_aliases[i] != NULL; i+=2) {
80
        if (!strcmp(builtin_aliases[i], command))
67
        if (!str_cmp(builtin_aliases[i], command))
81
            return 1;
68
            return 1;
82
    }
69
    }
83
 
70
 
84
    return 0;
71
    return 0;
85
}
72
}
Line 90... Line 77...
90
 
77
 
91
    if (NULL == command)
78
    if (NULL == command)
92
        return (char *)NULL;
79
        return (char *)NULL;
93
 
80
 
94
    for(i=0; builtin_aliases[i] != NULL; i++) {
81
    for(i=0; builtin_aliases[i] != NULL; i++) {
95
        if (!strcmp(builtin_aliases[i], command))
82
        if (!str_cmp(builtin_aliases[i], command))
96
            return (char *)builtin_aliases[++i];
83
            return (char *)builtin_aliases[++i];
97
        i++;
84
        i++;
98
    }
85
    }
99
 
86
 
100
    return (char *)NULL;
87
    return (char *)NULL;