Skip to content
option.h 1.64 KiB
Newer Older
Seblu's avatar
Seblu committed
/*
** option.h for 42sh
**
** Made by Seblu
** Login  <seblu@epita.fr>
**
** Started on  Tue Mar 21 18:50:03 2006 Seblu
Seblu's avatar
Seblu committed
** Last update Tue Nov 14 15:29:08 2006 seblu
Seblu's avatar
Seblu committed
*/

#ifndef OPTION_H_
# define OPTION_H_

#define DEBUG_OPTION 0

Seblu's avatar
Seblu committed
enum { OPTION_COUNT = 9 };

typedef struct option
Seblu's avatar
Seblu committed
{
Seblu's avatar
Seblu committed
  signed char	item[OPTION_COUNT];
Seblu's avatar
Seblu committed
  char		*command;
Seblu's avatar
Seblu committed
} s_option;
Seblu's avatar
Seblu committed

/*
** ==============
** FILE: option.c
** ==============
*/

/*!
** Create a new options structure
**
** @return A new options structure
*/
Seblu's avatar
Seblu committed
s_option	*option_init(void);

/*!
** Set default shell options
**
** @param opt option struct
*/
void		option_set_default(s_option *shopt);
Seblu's avatar
Seblu committed

/*!
** Set a shell option
**
** @param shopt structure to apply
** @param name name of the option to set
**
** @return 0 on failure, else 1
*/
Seblu's avatar
Seblu committed
int		option_set(s_option *shopt, const char *name);
Seblu's avatar
Seblu committed

/*!
** Unset a shell option
**
** @param shopt structure to apply
** @param name name of the option to unset
**
** @return 0 on failure, else 1
*/
Seblu's avatar
Seblu committed
int		option_unset(s_option *shopt, const char *name);
Seblu's avatar
Seblu committed

/*!
** Tell if an option is set. if option nane is not set return -1
**
** @param shopt structure where find
** @param name name to find
**
** @return 0 if unset, 1 if set and -1 if not exist
*/
Seblu's avatar
Seblu committed
int		option_isset(const s_option *shopt, const char *name);
Seblu's avatar
Seblu committed

/*!
** Return a list of know opt
**
** @return list of opt
*/
const char	**opt_get();

/*
** =====================
Seblu's avatar
Seblu committed
** FILE: getoption.c
Seblu's avatar
Seblu committed
** =====================
*/

/*!
Seblu's avatar
Seblu committed
** Parse the command line and set options
Seblu's avatar
Seblu committed
**
** @param opt shell opt structure to set with options
** @param argc program argc
** @param argv program argv
*/
Seblu's avatar
Seblu committed
void		getoptions(s_option *opt, int argc, char **argv);
Seblu's avatar
Seblu committed

#endif