Created
September 25, 2015 17:45
-
-
Save ejcer/86de33f8e2c10ee19676 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool | |
execute_plugin(struct esh_command * cmd) | |
{ | |
struct list_elem * e = list_begin(&esh_plugin_list); | |
for (; e != list_end(&esh_plugin_list); e = list_next (e)){ | |
struct esh_plugin * currPlugin = list_entry(e, struct esh_plugin, elem); | |
if(currPlugin->process_builtin == NULL){ | |
continue; | |
} | |
return currPlugin->process_builtin(cmd); | |
} | |
return false; | |
} | |
// check to see if it is a valid plugin command. If it is, execute it | |
// returns so the plugin commands are never added to the job list | |
if (execute_plugin(possibleBuiltIn)) | |
{ | |
return; | |
} | |
/* Plugin processing functions */ | |
bool execute_plugin(struct esh_command * cmd); | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <pwd.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include "../esh.h" | |
#include <signal.h> | |
static bool | |
init_plugin(struct esh_shell *shell) | |
{ | |
printf("Plugin 'office-hours' initialized...\n"); | |
return true; | |
} | |
static bool | |
print_office_hours_builtin(struct esh_command *cmd){ | |
if( strcmp(cmd->argv[0], "officehours") != 0){ | |
printf("\n\nhurrr\n\n"); | |
fflush(stdout); | |
esh_sys_error("chdir: \n"); | |
return true; | |
} | |
if (strcmp(cmd->argv[0], "officehours") == 0){ | |
printf("\n\nhurrr\n\n"); | |
fflush(stdout); | |
return true; | |
} | |
printf("\n\nhurrr\n\n"); | |
fflush(stdout); | |
esh_sys_error("chdir: \n"); | |
return true; | |
} | |
struct esh_plugin esh_module = { | |
.rank = 10, | |
.init = init_plugin, | |
.process_builtin = print_office_hours_builtin | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment