/*
 * $Id: config_file.h,v 1.4 1999/02/16 17:37:03 labovit Exp $
 */

#ifndef _LCONFIG_H
#define _LCONFIG_H

#include <mrt.h>

#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif




typedef struct _config_module_t {
  char *name;
  void_fn_t call_fn;
  void *arg;
  int	flags;		/* CF_WAIT, CF_DELIM, etc */
} config_module_t;

#define CF_WAIT		1	/* need to wait for thread to signal us data is ready */
#define CF_DELIM	2	/* we' somethings like router_bgp and need a ! delimiter */
#define CF_RAW		3       /* special control characters -- no interpretae */

typedef struct _config_t {
  char			*filename;
  int			line;		/* when parsing file, current lineno */
  trace_t		*trace;
  LINKED_LIST		*ll_modules;	/* linked list of config modules */
  pthread_cond_t	cond;
  pthread_mutex_t	mutex_cond_lock;
  int			ignore_errors;	/* flag if we should exit after encountering
					 * confi file error */
  char			*answer;	/* answer */
  int			answer_len;
  char			*cp;		/* pointer to current location in tmp */
  pthread_mutex_t	mutex_lock;	/* only one can enter config mode */
} config_t;

typedef struct _config_command_t {
  char *name;
  int_fn_t call_fn;
  char *format;
  char *description;
} config_command_t;


int config_debug (uii_connection_t *uii);
int config_from_file (trace_t *trace, char *filename);
int config_from_file2 (trace_t *trace, char *filename);
void get_comment_config (char *comment);
void get_comment_config2 (char *comment);
void get_uii_password ();
int config_add_module (int wait_flag, char *name, void_fn_t call_fn, void *arg);
int config_del_module (int flags, char *name, void_fn_t call_fn, void *arg);
void wait_config_data (void_fn_t call_fn, void *arg);
void get_debug_config (void);
int config_write (uii_connection_t *uii);
int config_comment (uii_connection_t *uii);
int show_config (uii_connection_t *uii);
int config_password (uii_connection_t *uii, char *password, int num, int access_list);
int no_config_password (uii_connection_t *uii);
int config_redirect (uii_connection_t *uii, char *directory);
int no_config_redirect (uii_connection_t *uii);
int get_alist_options (char *options, prefix_t **wildcard, int *refine, 
		       int *exact);
void config_notice (int flag, uii_connection_t *uii, char *format, ...);
int start_config (uii_connection_t *uii);
void end_config (uii_connection_t *uii);
int config_uii_port (uii_connection_t *uii, u_int port);
int no_config_uii_port (uii_connection_t *uii);
int config_add_output (char *format, ...);
void signal_config_data_ready ();
int parse_debug (uii_connection_t * uii, trace_t *tr);
int init_config (trace_t *tr);
int string2proto (char *proto_string);

extern config_t CONFIG;

#endif /* _LCONFIG_H */
