File size: 9,560 Bytes
10f2621 | 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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | /**
* @defgroup Vsh Vsh class
* @brief A bourne-compatible shell.
*/
/**
* @file vsh.h
* @ingroup Vsh
* @brief Header file for vsh, a bourne-compatible shell.
* @author Michael Holst
* @note None
* @version $Id: vsh.h,v 1.30 2010/08/12 05:40:29 fetk Exp $
*
* @attention
* @verbatim
*
* MALOC = < Minimal Abstraction Layer for Object-oriented C >
* Copyright (C) 1994-- Michael Holst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @endverbatim
*/
#ifndef _VSH_H_
#define _VSH_H_
#include <maloc/maloc_base.h>
#include <maloc/vsys.h>
/*
* ***************************************************************************
* Class Vsh: Parameters and datatypes
* ***************************************************************************
*/
/**
* @brief Contains public data members for Vsh class
* @author Michael Holst
* @ingroup Vsh
*/
struct sVsh {
/** @brief the memory manager */
Vmem *vmem;
/** @brief did i make vmem or was it inherited */
int iMadeVmem;
/** @brief whether the shell should process (argc,argv) */
char processArgs;
/** @brief number of environment variables */
int envValuLen;
/** @brief number of environment variable help strings */
int envInfoLen;
/** @brief the environment variables */
char **envValu;
/** @brief the environment variable help strings */
char **envInfo;
/** @brief input unit */
FILE *inUnit;
/** @brief script input unit */
FILE *scUnit;
/** @brief input unit */
FILE *clUnit;
/** @brief input unit */
FILE *cinUnit;
/** @brief input unit */
char cinName[VMAX_ARGLEN];
/** @brief minimal prompt (just the binary name) */
char PR[VMAX_ARGLEN];
/** @brief full prompt (user,hostname,path,etc) */
char PR_PATH[VMAX_ARGLEN];
/** @brief the exit print string */
char PR_EXIT[VMAX_ARGLEN];
/** @brief external supershell command key */
int cmdKey;
/** @brief external supershell object */
void *Ext_thee;
/** @brief internal buffer */
char *buf;
/** @brief internal buffer size */
int bufsize;
/** @brief external supershell builtin function */
int (*Ext_builtin)(void *thee, int argc, char **argv);
};
/**
* @brief Declaration of the Vsh class as the Vsh structure
* @author Michael Holst
* @ingroup Vsh
*/
typedef struct sVsh Vsh;
/*
* ***************************************************************************
* Class Vsh: Inlineable methods (vsh.c)
* ***************************************************************************
*/
#if !defined(VINLINE_MALOC)
#else /* if defined(VINLINE_MALOC) */
#endif /* if !defined(VINLINE_MALOC) */
/**
* @ingroup Vsh
* @brief Create the shell.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return Pointer to the new allocated Vsh object
* @param vmem Memory management object
* @param argc number of the command line arguments
* @param argv the command line arguments
*/
VEXTERNC Vsh* Vsh_ctor(Vmem *vmem, int argc, char **argv);
/**
* @ingroup Vsh
* @brief Destroy the shell.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return None
* @param thee Pointer to the Vsh object
*/
VEXTERNC void Vsh_dtor(Vsh **thee);
/**
* @ingroup Vsh
* @brief A bash-like shell with user-definable extensions.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return Success enumeration
* @param thee Pointer to the Vsh object
* @param pPR minimal prompt
* @param pthee the externally supplied builtin object pointer
* @param builtin external supershell builtin function
*/
VEXTERNC int Vsh_shell(Vsh *thee, char *pPR, void *pthee,
int (*builtin)(void *thee, int argc, char **argv));
/**
* @ingroup Vsh
* @brief Place a variable with a value in the environment.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return Success enumeration
* @param thee Pointer to the Vsh object
* @param envi environment string
* @param valu value string
*/
VEXTERNC int Vsh_putenv(Vsh *thee, const char *envi, const char *valu);
/**
* @ingroup Vsh
* @brief Place a variable with an info string in the environment.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return Success enumeration
* @param thee Pointer to the Vsh object
* @param envi environment string
* @param valu value string
*/
VEXTERNC int Vsh_putenvInfo(Vsh *thee, const char *envi, const char *valu);
/**
* @ingroup Vsh
* @brief Place a variable with a value (integer) in the environment.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return Success enumeration
* @param thee Pointer to the Vsh object
* @param envi environment string
* @param valu value string
*/
VEXTERNC int Vsh_putenvInt(Vsh *thee, const char *envi, const int valu);
/**
* @ingroup Vsh
* @brief Place a variable with a value (real) in the environment.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return Success enumeration
* @param thee Pointer to the Vsh object
* @param envi environment string
* @param valu value string
*/
VEXTERNC int Vsh_putenvReal(Vsh *thee, const char *envi, const double valu);
/**
* @ingroup Vsh
* @brief Get a value of variable in the environment.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return value of variable in the environment.
* @param thee Pointer to the Vsh object
* @param envi environment string
*/
VEXTERNC char *Vsh_getenv(Vsh *thee, const char *envi);
/**
* @ingroup Vsh
* @brief Get info associated with a variable in the environment.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return info associated with a variable in the environment.
* @param thee Pointer to the Vsh object
* @param envi environment string
*/
VEXTERNC char *Vsh_getenvInfo(Vsh *thee, const char *envi);
/**
* @ingroup Vsh
* @brief Get a value of variable in the environment as an integer.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return value of variable in the environment as an integer.
* @param thee Pointer to the Vsh object
* @param envi environment string
*/
VEXTERNC int Vsh_getenvInt(Vsh *thee, const char *envi);
/**
* @ingroup Vsh
* @brief Get a value of variable in the environment as a real.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return value of variable in the environment as a real.
* @param thee Pointer to the Vsh object
* @param envi environment string
*/
VEXTERNC double Vsh_getenvReal(Vsh *thee, const char *envi);
/**
* @ingroup Vsh
* @brief Remove a variable from the environment.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return None
* @param thee Pointer to the Vsh object
* @param envi environment string
*/
VEXTERNC void Vsh_remove(Vsh *thee, const char *envi);
/**
* @ingroup Vsh
* @brief Wipe the environment.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return None
* @param thee Pointer to the Vsh object
*/
VEXTERNC void Vsh_wipe(Vsh *thee);
/**
* @ingroup Vsh
* @brief Print the exact current malloc usage.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return None
* @param thee Pointer to the Vsh object
*/
VEXTERNC void Vsh_memChk(Vsh *thee);
/**
* @ingroup Vsh
* @brief Setup for an I/O command.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return socket for reading/writing the external data
* @param thee Pointer to the Vsh object
* @param key Pointer to different read/write option
*/
VEXTERNC Vio *Vsh_ioSetup(Vsh *thee, char *key);
/**
* @ingroup Vsh
* @brief Cleanup an I/O command.
* @author Michael Holst
* @note Class Vsh: Non-inlineable method (vsh.c)
* @return None
* @param thee Pointer to the Vsh object
* @param sock socket for reading/writing the external data
*/
VEXTERNC void Vsh_ioCleanup(Vsh *thee, Vio **sock);
#endif /* _VSH_H_ */
|