/* This file is part of TSL.
 *
 * TSL is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * TSL 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TSL; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ASSERT_H
#include <assert.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif

#define SID_LISTITEM -100
#define SID_LIST -101 

#define MAX_VERSION 1

struct listitem_struct {
	int id;
	void *value1;
	void *value2;
	struct listitem_struct *next;
};

struct list_struct {
	int id;
	struct listitem_struct *first;		/* The first item in the list */
	struct listitem_struct *current;  /* The current position within the list */
	int count;												/* The number of items in the list */
};

/* Forward declarations from main.c */
extern int timeout_flag;

/* Forward declarations from signal.c */
void catch_sig( int signo );

/* Forward declarations from list.c */
struct listitem_struct *listitem_create( void *value1, void *value2 );
struct list_struct *list_create();
void list_add( struct list_struct *list, void *value1, void *value2 );
int list_count( struct list_struct *list );
void list_rewind( struct list_struct *list );
void *list_get1( struct list_struct *list );
void *list_get2( struct list_struct *list );
void list_next( struct list_struct *list );
void list_clear( struct list_struct *list );
struct list_struct *list_create_from_string( char *input );
void list_free( struct list_struct *list );
int list_atlast( struct list_struct *list );
void list_set1( struct list_struct *list, void *value );
void list_set2( struct list_struct *list, void *value );
int list_findfirst( struct list_struct *list, char *searchfor );
int list_findnext( struct list_struct *list, char *searchfor );

/* Forward declarations from parse.c */
struct list_struct *process_tsl( char *filename );

/* Forward declarations from netio.c */
int tsl_connect( char *host, int socket );
int get_char( int sockfd );
void send_string( int sockfd, char *string );
int netmatch( char *match );

/* Forward declarations from runtime.c */
void runtime( int sockfd, struct list_struct *sections );
char *get_expanded( char *word, struct list_struct *vars,
	struct list_struct *rotary, int recurse_factor );

