Skip to content
alias.h 1011 B
Newer Older
Seblu's avatar
Seblu committed
/*
** alias.h for 42sh
**
** Made by Seblu
** Login   <seblu@epita.fr>
**
** Started on  Wed Aug 23 00:32:09 2006 Seblu
** Last update Thu Nov 23 11:24:08 2006 seblu
Seblu's avatar
Seblu committed
*/

#ifndef ALIAS_H_
# define ALIAS_H_

# include <stddef.h>

Seblu's avatar
Seblu committed
enum {
  ALIAS_DEFAULT_SIZE = 5,
  ALIAS_PADDING = 5
};

Seblu's avatar
Seblu committed
typedef struct alias_item
Seblu's avatar
Seblu committed
{
  char		*name;
  char		*value;
Seblu's avatar
Seblu committed
} s_alias_item;
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
typedef struct alias
Seblu's avatar
Seblu committed
{
  size_t	size;
Seblu's avatar
Seblu committed
  size_t	count;
  s_alias_item	*table;
Seblu's avatar
Seblu committed
} s_alias;
Seblu's avatar
Seblu committed

/*!
** Create a new aliases database
**
** @return new alias database
*/
Seblu's avatar
Seblu committed
s_alias		*alias_init(void);
Seblu's avatar
Seblu committed

/*!
** Add an alias into an alias database
**
** @param aliases alias database
** @param name new alias name
** @param value new alias value
*/
int		alias_add(s_alias *alias, const char *name, const char *value);
Seblu's avatar
Seblu committed

/*!
** Remove an alias into an alias database
**
** @param aliases alias database
** @param name alias name to remove
**
Seblu's avatar
Seblu committed
** @return true, if alias was delete from database, else false
Seblu's avatar
Seblu committed
*/
Seblu's avatar
Seblu committed
int		alias_del(s_alias *alias, const char *name);
Seblu's avatar
Seblu committed

#endif