Subversion Repositories HelenOS

Rev

Rev 3425 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3425 Rev 4377
Line 51... Line 51...
51
#include "cmds.h"
51
#include "cmds.h"
52
#include "module_aliases.h"
52
#include "module_aliases.h"
53
 
53
 
54
extern volatile unsigned int cli_interactive;
54
extern volatile unsigned int cli_interactive;
55
 
55
 
56
int module_is_restricted(int pos)
-
 
57
{
-
 
58
    /* Restriction Levels:
-
 
59
     * -1 -> Available only in interactive mode
-
 
60
     *  0 -> Available in any mode
-
 
61
     *  1 -> Available only in non-interactive mode */
-
 
62
 
-
 
63
    module_t *mod = modules;
-
 
64
    mod += pos;
-
 
65
    /* We're interactive, and the module is OK to run */
-
 
66
    if (cli_interactive && mod->restricted <= 0)
-
 
67
        return 0;
-
 
68
    /* We're not interactive, and the module is OK to run */
-
 
69
    if (!cli_interactive && mod->restricted >= 0)
-
 
70
        return 0;
-
 
71
 
-
 
72
    /* Anything else is just a big fat no :) */
-
 
73
    return 1;
-
 
74
}
-
 
75
 
-
 
76
/* Checks if an entry function matching command exists in modules[], if so
56
/* Checks if an entry function matching command exists in modules[], if so
77
 * its position in the array is returned */
57
 * its position in the array is returned */
78
int is_module(const char *command)
58
int is_module(const char *command)
79
{
59
{
80
    module_t *mod;
60
    module_t *mod;
Line 82... Line 62...
82
 
62
 
83
    if (NULL == command)
63
    if (NULL == command)
84
        return -2;
64
        return -2;
85
 
65
 
86
    for (mod = modules; mod->name != NULL; mod++, i++) {
66
    for (mod = modules; mod->name != NULL; mod++, i++) {
87
        if (!strcmp(mod->name, command))
67
        if (!str_cmp(mod->name, command))
88
            return i;
68
            return i;
89
    }
69
    }
90
 
70
 
91
    return -1;
71
    return -1;
92
}
72
}
Line 99... Line 79...
99
 
79
 
100
    if (NULL == command)
80
    if (NULL == command)
101
        return -1;
81
        return -1;
102
 
82
 
103
    for(i=0; mod_aliases[i] != NULL; i+=2) {
83
    for(i=0; mod_aliases[i] != NULL; i+=2) {
104
        if (!strcmp(mod_aliases[i], command))
84
        if (!str_cmp(mod_aliases[i], command))
105
            return 1;
85
            return 1;
106
    }
86
    }
107
 
87
 
108
    return 0;
88
    return 0;
109
}
89
}
Line 115... Line 95...
115
 
95
 
116
    if (NULL == command)
96
    if (NULL == command)
117
        return (char *)NULL;
97
        return (char *)NULL;
118
 
98
 
119
    for(i=0; mod_aliases[i] != NULL; i++) {
99
    for(i=0; mod_aliases[i] != NULL; i++) {
120
        if (!strcmp(mod_aliases[i], command))
100
        if (!str_cmp(mod_aliases[i], command))
121
            return (char *)mod_aliases[++i];
101
            return (char *)mod_aliases[++i];
122
        i++;
102
        i++;
123
    }
103
    }
124
 
104
 
125
    return (char *)NULL;
105
    return (char *)NULL;