Commit 847c817e authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Add 'blc_command_forward_blc_channels' to make blc_command_loop automatically...

Add 'blc_command_forward_blc_channels' to make blc_command_loop automatically forward blc_channels without interpreting it
parent 3f7f12c1
......@@ -58,6 +58,13 @@ void pause_cb();
///Add a command in the list of possible command lines from the user.
void blc_command_add(const char *command_name, type_blc_command_cb callback, const char *prompt, const char *help, void *user_data);
/**If the command is the format of a blc_channel, the command is sent to stdout and the command is not interpreted.
/usr, /bin etc. may be interpreted as a blc_channel. use /usr/, /bin/ in this case.
Same for any command starting with . ^ / :
*/
void blc_command_forward_blc_channels();
///Remove a previously added command
void blc_command_remove(const char *command_name);
......
......@@ -57,15 +57,20 @@ static int blc_commands_nb = 0;
static sem_t *sems_to_unlock=NULL;
static int sems_to_unlock_nb=0;
static int forward_blc_channel=0;
void blc_loop_sem_to_unlock_on_stop(void *sem){
APPEND_ITEM(&sems_to_unlock, &sems_to_unlock_nb, &sem);
}
START_EXTERN_C
void blc_command_forward_blc_channels(){
forward_blc_channel=1;
}
void blc_command_display_help()
{
const blc_command *command;
......@@ -122,6 +127,18 @@ void blc_command_interpret_string(char const *input_string, size_t size){
const blc_command *command;
size_t name_size, line_capability=0;
if (forward_blc_channel) {
if (strchr("./^:", input_string[0])) //it starts with ., ^ , / , :, it may be a blc_channel.
if (memchr(&input_string[1], '/', size)==0) // There is no / after the first char it is a blc_channel. NOTE: It may be an error with /usr /bin the user has to use /usr/ /bin/ etc.
{
SYSTEM_ERROR_CHECK(puts(input_string), -1, NULL);
SYSTEM_ERROR_CHECK(fflush(stdout), -1, NULL);
return;
}
}
FOR_EACH(command, blc_commands, blc_commands_nb){
name_size = strlen(command->name);
if (strncmp(command->name, input_string, name_size) == 0){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment