/*
 * smallsh.h
 * File Revision 1
 * Primary header for smallsh.
 * (c) 1999 Addison Wesley Longman, Inc.
 * (c) 2000 Jacob Lundberg, jacob@chaos2.org
 */


/*
 * 2000.11.05	Acquire initial code
 *		Adjust style and values
 */


#ifndef __SMALLSH_H__
#define __SMALLSH_H__


#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>


/*
 * boolean logic
 * We provide a form that gcc will accept by default. However, it isn't
 * strictly correct to define arbitrary values for both members of an enum
 * so unless we know we're compiling with a GNU C compiler we'll refrain.
 */
#ifdef __GNUC__

typedef enum boolean {
   false = 0,
   true = !false
} bool;

#else /* def __GNUC__ */

typedef int bool;
#define  false  0
#define  true   !false

#endif /* def __GNUC__ */


/* Some boxen define pid_t in odd places, so... */
#ifndef pid_t
typedef __pid_t pid_t;
#endif /* ndef pid_t */


/* Symbol types reading from the commandline. */
typedef enum _sh_symbol {
   SH_SYM_AMP,                  /* & (ampersand)    */
   SH_SYM_ARG,                  /*   (regular word) */
   SH_SYM_EOL,                  /*   (end of line)  */
   SH_SYM_GT,                   /* > (greater than) */
   SH_SYM_LT,                   /* < (less than)    */
   SH_SYM_SC,                   /* ; (semicolon)    */
} sh_symbol;


/* Maximum number of command args. */
#define  MAXARG                 1023
/* Maximum length of input lines. */
#define  MAXBUF                 1023
/* String printed as the prompt. */
#define  PROMPT                 ": "


/* Task types. */
typedef enum _sh_task_whence {
   SH_TASK_FORE,                /* foreground tasks */
   SH_TASK_BACK                 /* background tasks */
} sh_task_whence;


/* Exported functional prototypes. */
int runcommand(char **cline, sh_task_whence where, char *inp, char *oup);
int userin(char *p);
void procline(void);
void doprompt(char *p);


#endif /* ndef __SMALLSH_H__ */

