File: sash.h

package info (click to toggle)
sash 3.7-7.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 380 kB
  • ctags: 306
  • sloc: ansic: 6,232; sh: 148; makefile: 35
file content (153 lines) | stat: -rw-r--r-- 4,634 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * Copyright (c) 2002 by David I. Bell
 * Permission is granted to use, distribute, or modify this source,
 * provided that this copyright notice remains intact.
 *
 * Definitions for stand-alone shell for system maintainance for Linux.
 */

#ifndef	SASH_H
#define	SASH_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <memory.h>
#include <time.h>
#include <ctype.h>

#if __OpenBSD__
#include <sys/param.h>
#endif

#if __Linux__
#include <malloc.h>
#endif


#define	PATH_LEN	1024
#define	CMD_LEN		10240
#define	ALIAS_ALLOC	20
#define	EXPAND_ALLOC	1024
#define	STDIN		0
#define	STDOUT		1
#define	MAX_SOURCE	10
#define	BUF_SIZE	8192


#define	isBlank(ch)	(((ch) == ' ') || ((ch) == '\t'))
#define	isDecimal(ch)	(((ch) >= '0') && ((ch) <= '9'))
#define	isOctal(ch)	(((ch) >= '0') && ((ch) <= '7'))
#define	isWildCard(ch)	(((ch) == '*') || ((ch) == '?') || ((ch) == '['))

#ifndef MAX
#define MAX(x, y)	((x) > (y) ? (x) : (y))
#endif
#ifndef MIN
#define MIN(x, y)	((x) < (y) ? (x) : (y))
#endif

typedef	int	BOOL;

#define	FALSE	((BOOL) 0)
#define	TRUE	((BOOL) 1)


/*
 * Built-in command functions.
 */
extern	void	do_alias(int argc, const char ** argv);
extern	void	do_aliasall(int argc, const char ** argv);
extern	void	do_cd(int argc, const char ** argv);
extern	void	do_exec(int argc, const char ** argv);
extern	void	do_exit(int argc, const char ** argv);
extern	void	do_prompt(int argc, const char ** argv);
extern	void	do_source(int argc, const char ** argv);
extern	void	do_umask(int argc, const char ** argv);
extern	void	do_unalias(int argc, const char ** argv);
extern	void	do_help(int argc, const char ** argv);
extern	void	do_ln(int argc, const char ** argv);
extern	void	do_cp(int argc, const char ** argv);
extern	void	do_mv(int argc, const char ** argv);
extern	void	do_rm(int argc, const char ** argv);
extern	void	do_chmod(int argc, const char ** argv);
extern	void	do_mkdir(int argc, const char ** argv);
extern	void	do_rmdir(int argc, const char ** argv);
extern	void	do_mknod(int argc, const char ** argv);
extern	void	do_chown(int argc, const char ** argv);
extern	void	do_chgrp(int argc, const char ** argv);
extern	void	do_sum(int argc, const char ** argv);
extern	void	do_sync(int argc, const char ** argv);
extern	void	do_printenv(int argc, const char ** argv);
extern	void	do_more(int argc, const char ** argv);
extern	void	do_cmp(int argc, const char ** argv);
extern	void	do_touch(int argc, const char ** argv);
extern	void	do_ls(int argc, const char ** argv);
extern	void	do_dd(int argc, const char ** argv);
extern	void	do_tar(int argc, const char ** argv);
extern	void	do_ar(int argc, const char ** argv);
extern	void	do_mount(int argc, const char ** argv);
extern	void	do_umount(int argc, const char ** argv);
extern	void	do_setenv(int argc, const char ** argv);
extern	void	do_pwd(int argc, const char ** argv);
extern	void	do_echo(int argc, const char ** argv);
extern	void	do_kill(int argc, const char ** argv);
extern	void	do_grep(int argc, const char ** argv);
extern	void	do_file(int argc, const char ** argv);
extern	void	do_find(int argc, const char ** argv);
extern	void	do_ed(int argc, const char ** argv);
extern	void	do_where(int argc, const char ** argv);

#if	HAVE_GZIP
extern	void	do_gzip(int argc, const char ** argv);
extern	void	do_gunzip(int argc, const char ** argv);
#endif

#if	HAVE_LINUX_ATTR
extern	void	do_lsattr(int argc, const char ** argv);
extern	void	do_chattr(int argc, const char ** argv);
#endif


/*
 * Global utility routines.
 */
extern	const char *	modeString(int mode);
extern	const char *	timeString(time_t timeVal);
extern	BOOL		isDirectory(const char * name);
extern	BOOL		isDevice(const char * name);
extern	int		nameSort(const void * p1, const void * p2);
extern	char *		getChunk(int size);
extern	char *		chunkstrdup(const char *);
extern	void		freeChunks(void);
extern	int		fullWrite(int fd, const char * buf, int len);
extern	int		fullRead(int fd, char * buf, int len);
extern	BOOL		match(const char * text, const char * pattern);

extern	const char *	buildName
	(const char * dirName, const char * fileName);

extern	BOOL	makeArgs
	(const char * cmd, int * argcPtr, const char *** argvPtr);

extern	BOOL	copyFile
	(const char * srcName, const char * destName, BOOL setModes);

extern	BOOL	makeString
	(int argc, const char ** argv, char * buf, int bufLen);

extern	int	expandWildCards
	(const char * fileNamePattern, const char *** retFileTable);


/*
 * Global variable to indicate that an SIGINT occurred.
 * This is used to stop processing.
 */
extern	BOOL	intFlag;

#endif

/* END CODE */