MALOC  0.1
vsh.h
1 /*
2  * ***************************************************************************
3  * MALOC = < Minimal Abstraction Layer for Object-oriented C >
4  * Copyright (C) 1994--2000 Michael Holst
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation; either version 2 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  * rcsid="$Id: vsh.h,v 1.15 2002/10/01 21:29:45 mholst Exp $"
21  * ***************************************************************************
22  */
23 
24 /*
25  * ***************************************************************************
26  * File: vsh.h < vsh.c, ... >
27  *
28  * Purpose: Header file for vsh, a bourne-compatible shell.
29  *
30  * Author: Michael Holst
31  * ***************************************************************************
32  */
33 
34 #ifndef _VSH_H_
35 #define _VSH_H_
36 
37 #include <maloc/maloc_base.h>
38 
39 #include <maloc/vsys.h>
40 
41 /*
42  * ***************************************************************************
43  * Class Vsh: Parameters and datatypes
44  * ***************************************************************************
45  */
46 
47 /*
48  * ***************************************************************************
49  * Class Vsh: Definition
50  * ***************************************************************************
51  */
52 
53 typedef struct Vsh {
54 
55  Vmem *vmem; /* the memory manager */
56  int iMadeVmem; /* did i make vmem or was it inherited */
57 
58  char processArgs; /* whether the shell should process (argc,argv) */
59 
60  int envValuLen; /* number of environment variables */
61  int envInfoLen; /* number of environment variable help strings */
62  char **envValu; /* the environment variables */
63  char **envInfo; /* the environment variable help strings */
64 
65  FILE *inUnit; /* input unit */
66  FILE *scUnit; /* script input unit */
67  FILE *clUnit; /* input unit */
68  FILE *cinUnit; /* input unit */
69  char cinName[80]; /* input unit */
70 
71  char PR[80]; /* minimal prompt (just the binary name) */
72  char PR_PATH[80]; /* full prompt (with user,hostname,path,etc) */
73  char PR_EXIT[80]; /* the exit print string */
74 
75  int cmdKey; /* external supershell command key */
76  void *Ext_thee; /* external supershell object */
77 
78  char *buf; /* internal buffer */
79  int bufsize; /* internal buffer size */
80 
81  /* external supershell builtin function */
82  int (*Ext_builtin)(void *thee, int argc, char **argv);
83 
84 } Vsh;
85 
86 /*
87  * ***************************************************************************
88  * Class Vsh: Inlineable methods (vsh.c)
89  * ***************************************************************************
90  */
91 
92 #if !defined(VINLINE_MALOC)
93 #else /* if defined(VINLINE_MALOC) */
94 #endif /* if !defined(VINLINE_MALOC) */
95 
96 /*
97  * ***************************************************************************
98  * Class Vsh: Non-inlineable methods (vsh.c)
99  * ***************************************************************************
100  */
101 
102 Vsh* Vsh_ctor(Vmem *vmem, int argc, char **argv);
103 void Vsh_dtor(Vsh **thee);
104 
105 int Vsh_shell(Vsh *thee, char *pPR, void *pthee,
106  int (*builtin)(void *thee, int argc, char **argv));
107 
108 int Vsh_putenv(Vsh *thee, const char *envi, const char *valu);
109 int Vsh_putenvInfo(Vsh *thee, const char *envi, const char *valu);
110 int Vsh_putenvInt(Vsh *thee, const char *envi, const int valu);
111 int Vsh_putenvReal(Vsh *thee, const char *envi, const double valu);
112 
113 char *Vsh_getenv(Vsh *thee, const char *envi);
114 char *Vsh_getenvInfo(Vsh *thee, const char *envi);
115 int Vsh_getenvInt(Vsh *thee, const char *envi);
116 double Vsh_getenvReal(Vsh *thee, const char *envi);
117 
118 void Vsh_remove(Vsh *thee, const char *envi);
119 void Vsh_wipe(Vsh *thee);
120 
121 void Vsh_memChk(Vsh *thee);
122 
123 Vio *Vsh_ioSetup(Vsh *thee, char *key);
124 void Vsh_ioCleanup(Vsh *thee, Vio **sock);
125 
126 #endif /* _VSH_H_ */
127 
128