⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msh.c

📁 为samsung2410 ARM移植的busybox工具包
💻 C
📖 第 1 页 / 共 5 页
字号:
/* vi: set sw=4 ts=4: *//* * Minix shell port for busybox * * This version of the Minix shell was adapted for use in busybox * by Erik Andersen <andersee@debian.org> and *    Vladimir Oleynik <dzo@simtreas.ru> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Original copyright notice is retained at the end of this file. *//* -------- sh.h -------- */#include <stdlib.h>#include <stdio.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include <sys/types.h>#include <signal.h>#include <errno.h>#include <setjmp.h>#include <stddef.h>#include <time.h>#include <sys/times.h>#include <sys/stat.h>#include <sys/wait.h>#include <sys/dir.h>#include <limits.h>#include "cmdedit.h"#include "busybox.h"#ifdef test//#undef BB_FEATURE_COMMAND_EDITINGconst char *applet_name = "msh";#define TEST_NEW_VERSION#define Abort() { fprintf(stderr, "Abort %d\n", __LINE__); abort(); }#else#undef TEST_NEW_VERSION#define Abort() abort()#endif/* * shell */#define LINELIM 4096#define NPUSH   8				/* limit to input nesting */#define NOFILE  20				/* Number of open files */#define NUFILE  10				/* Number of user-accessible files */#define FDBASE  10				/* First file usable by Shell *//* * values returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)/* * library and system defintions */typedef void xint;				/* base type of jmp_buf, for not broken compilers *//* * shell components */#define QUOTE   0200#define NOBLOCK ((struct op *)NULL)#define NOWORD  ((char *)NULL)#define NOWORDS ((char **)NULL)#define NOPIPE  ((int *)NULL)/* * Description of a command or an operation on commands. * Might eventually use a union. */struct op {	int type;					/* operation type, see below */	char **words;				/* arguments to a command */	struct ioword **ioact;		/* IO actions (eg, < > >>) */	struct op *left;	struct op *right;	char *str;					/* identifier for case and for */};#define TCOM    1				/* command */#define TPAREN  2				/* (c-list) */#define TPIPE   3				/* a | b */#define TLIST   4				/* a [&;] b */#define TOR     5				/* || */#define TAND    6				/* && */#define TFOR    7#define TDO     8#define TCASE   lues returned by wait */#define WAITSIG(s) ((s)&0177)#define WAITVAL(s) (((s)>>8)&0377)#define WAITCORE(s) (((s)&0200)!=0)

⌨️ 快捷键说明

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