/****************************************************************

                     IOSERV.H
      Header for IOSERV_S.LIB, and similar for other models.
      This library is for IO services and auxiliary functions.

*******************************************************************/

#include <stdio.h>
#ifndef ioserv_included
#define ioserv_included
#ifndef dbhost_included
#include "dbhost.h"
#endif
#ifndef misc_included
#include "misc.h"
#endif

typedef NAME_LIST_ENTRY_TYPE *NAME_LIST_TYPE;
#define includes(s,c)  (strchr(s,c) != NULL)
#define ECHO 1
#define NOECHO 0

/***************************************************************

   Header for PARAM.C and OPTION.C

*/

typedef struct
{
   char *name;
   int  code;
   int (*function)();
   char *argument;
} OPTION_TYPE;
/* perhaps index zero should be used for "end", terminating the option list */

typedef struct
{
   char *prompt;
   char *format;
   void *parameter;
   int  type;
} PARAMETER_LIST_ENTRY_TYPE;

#define TYPE_CHAR     2
#define TYPE_LONG     5
#define TYPE_FLOAT    7
#define TYPE_DOUBLE   8
#define TYPE_STRING  10
#define TYPE_INT     12    /* number of bytes is machine default */
#define TYPE_TRANS   16
#define TYPE_QUOTE   17
#define NPATHMAX 160   /* size of file name strings */

#if PROTOTYPE_ALLOWED

/*
    FUNCTIONS IN GETLN_NC.C
*/
char *non_blank(char*line);
int getline_nc(FILE *fp, char *line_buffer, int n);
/*
    FUNCTIONS IN ERRCHK.C
*/
FILE *check_fopen(char *fn, char *mode);
void check_error(int test, char *message);
/*
    FUNCTIONS IN ERRNF.C
*/
int error_found(int test_value, char *message);
/*
    FUNCTIONS IN OPTION.C
*/
int get_option_index(OPTION_TYPE *list, char *word);
int execute_options(FILE *fp, OPTION_TYPE *list, int echo);
int execute_one_option(FILE *fp, OPTION_TYPE *list);
char *get_option_name(OPTION_TYPE *list, int number);
void list_options(OPTION_TYPE *list);

int logical_or(FILE *fp, char *arg, int code);
int skip_to(FILE *fp, char *arg, int code);
int set_code(FILE *fp, char *arg, int code);
int set_long_bit(FILE *fp, char *arg, int code);
int op_get_param(FILE *fp, char *arg, int code);
/*
    FUNCTIONS IN PARAM.C
*/
int get_parameters(FILE *fp, PARAMETER_LIST_ENTRY_TYPE *pl,
                   NAME_LIST_TYPE *nl_array);
int print_parameters(FILE *fp, PARAMETER_LIST_ENTRY_TYPE *pl,                                                                                                           
                     NAME_LIST_TYPE *nl_array, char *separator);
/*
    FUNCTIONS IN REPT_MSG.C
*/
void set_msg_file(FILE *fp);
void report_msg(char *msg);
/*
    FUNCTIONS IN new_ext.c
*/
void new_extension(char *new_name, char *old_name, char *extension);

/*
   FUNCTIONS IN yr4digit.c
*/
int yr4digit(int yr);


#else
/*
    FUNCTIONS IN GETLN_NC.C
*/
char *non_blank();
int getline_nc();
/*
    FUNCTIONS IN ERRCHK.C
*/
FILE *check_fopen();
void check_error();
/*
    FUNCTIONS IN ERRNF.C
*/
int error_found();
/*
    FUNCTIONS IN OPTION.C
*/
int get_option_index();
int execute_options();
int execute_one_option();
char *get_option_name();
void list_options();

int logical_or();
int skip_to();
int set_code();
int set_long_bit();
int op_get_param();
/*
    FUNCTIONS IN PARAM.C
*/
int get_parameters();
int print_parameters();
/*
    FUNCTIONS IN REPT_MSG.C
*/
void set_msg_file();
void report_msg();
/*
    FUNCTIONS IN new_ext.c
*/
void new_extension();

/*
   FUNCTIONS IN yr4digit.c
*/
int yr4digit();


#endif

/* 1999/07/30 Pierre Jaccard */
#include "../gfi/src/plugs/ioserv.h"

#endif /* ifndef ioserv_included */
