// **************************************************************** // * The main function puts everything together so that the shell * // * can work. * // **************************************************************** int main(int argc, char **argv, char **envp) { int fd, i; char c; char *input_str = calloc(BUFFERSIZE, sizeof(char*)); char *cmd = calloc(BUFFERSIZE, sizeof(char*)); // ignore the standard interrupt signal (ctrl+c) signal(SIGINT, SIG_IGN); // assign interrupt signal (ctrl+c) to the signal handler function signal(SIGINT, sig_hdlr); // prepare screen and fetch necessary data initilize(envp); // main loop might be stopped by typing 'quit', 'exit' or by pressing 'ctrl+d' while(strcmp(input_str, QUIT_CMD) != 0 && strcmp(input_str, EXIT_CMD) != 0 && c != EOF) { // get input c = getchar(); // this switch-case statement read and prepare the input string switch(c) { case NEWLINE_SYMBOL: // if no command is inserted, just print the prompt again if(input_str[0] != NULL_SYMBOL) { // erase cmd variable memset(cmd, 0, BUFFERSIZE); // parse the command line cmd = prepare_inputs(input_str); // special case: change directory call if(strncmp(cmd, CD, 2) == 0) { cd(inputs[1]); // all other command calls } else { get_cmd_pth(cmd); cmd_exec(cmd, envp); } free_arr(inputs); } // print the prompt again after hitting enter print_prompt(); memset(input_str, 0, BUFFERSIZE); break; default: // prepare the input string strncat(input_str, &c, 1); break; } } // free allocated memories free(cmd); free(input_str); free_arr(paths); // print new line if 'ctrl+d' is pressed if(c == EOF) printf(NEWLINE_STR); // end of main return 0; }
void BSSRDF::evaluate_inputs( const ShadingContext& shading_context, InputEvaluator& input_evaluator, const ShadingPoint& shading_point, const size_t offset) const { input_evaluator.evaluate(get_inputs(), shading_point.get_uv(0), offset); prepare_inputs(input_evaluator.data() + offset); }
// **************************************************************** // * This function clears the screen, for our new shell to open * // * and prints the prompt for the first time. * // * Also, it gets all the paths where the system commands may be * // * stored, by calling get_paths(). * // **************************************************************** void initilize(char **envp) { char *cmd = calloc(BUFFERSIZE, sizeof(char*)); get_paths(envp); cmd = prepare_inputs(CLEAR); get_cmd_pth(cmd); cmd_exec(cmd, envp); sig_hdlr(0); free_arr(inputs); }
void* BSDF::evaluate_inputs( const ShadingContext& shading_context, const ShadingPoint& shading_point) const { void* data = shading_context.get_arena().allocate(compute_input_data_size()); get_inputs().evaluate( shading_context.get_texture_cache(), shading_point.get_uv(0), data); prepare_inputs( shading_context.get_arena(), shading_point, data); return data; }