process2.c

来自「unix编程实践教程代码。适合初学者」· C语言 代码 · 共 39 行

C
39
字号
#include	<stdio.h>#include	"smsh.h"/* process2.c   - version 2 - supports builtins * command processing layer *  * The process(char **arglist) function is called by the main loop * It sits in front of the execute() function.  This layer handles * two main classes of processing: * 	a) built-in functions (e.g. exit(), set, =, read, .. ) * 	b) control structures (e.g. if, while, for) */int is_control_command(char *);int do_control_command(char **);int ok_to_execute();int builtin_command(char **, int *);int process(char **args)/* * purpose: process user command * returns: result of processing command * details: if a built-in then call appropriate function, if not execute() *  errors: arise from subroutines, handled there */{	int		rv = 0;	if ( args[0] == NULL )		rv = 0;	else if ( is_control_command(args[0]) )		rv = do_control_command(args);	else if ( ok_to_execute() )		if ( !builtin_command(args,&rv) )			rv = execute(args);	return rv;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?