/* --------------------------------------------------- */
/* Header-file BASIS 1.0, (C) Wabnig Harald, 25.5.2002 */
/* --------------------------------------------------- */

#ifndef BASIS_INCLUDE
#define BASIS_INCLUDE

#include <ctype.h>
#include <stdio.h>
#include <math.h>
#ifdef WIN32
#include <windows.h>
#endif

/* ----------------------------- */

#ifndef WIN32
#define _PDEL       '/'
#define _PTAR       "/bin/tar"
#define _PRM        "/bin/rm"
#define _PMV        "mv"
#define _PCP        "cp"
#else
#define _PDEL       '\\'
#define _PTAR       "tar"
#define _PRM        "rm"
#define _PMV        "move"
#define _PCP        "copy"

#define VERS_UNKNOWN    0   /* default */
#define VERS_NT         1
#define VERS_WIN        2

extern int winvers;

extern void Get_WinVers(void);
#endif

#include "boolean.h"
#include "mymemory.h"
#include "liste.h"
#include "tree.h"
#include "hashtab.h"

#define MAXFN   80
#define LINEMAX 1000
#define STRGMAX 10000

/* -------------------------------------------------------------- */
/* Character-Functions:                                           */
/* -------------------------------------------------------------- */

extern char * Up(const char * strg);
extern char * Low(const char * strg);
extern void tolowerstr(char * strg);
extern void toupperstr(char * strg);

extern int digit(char c);
extern int hexdigit(char c);
extern int letter(char c);
extern int ndigit(char c);

extern int is_empty_string();
extern int is_valid_name();

/* -------------------------------------------------------------- */
/* Suffix-Functions:                                              */
/* -------------------------------------------------------------- */

extern char * setsuffix(char * fn, char * suffix);
extern char * clearsuffix(char * fn);
extern char * getsuffix(char * fn);

/* -------------------------------------------------------------- */
/* FileIO-Functions:                                              */
/* -------------------------------------------------------------- */

#define IFPS_MAX    10

#ifndef WIN32_1
extern FILE *ifp; /* Filepointer to actual input file */
#else
extern HFILE ifp; /* Filepointer to actual input file */
#endif
extern char infn[MAXFN];
extern void in_file();
extern void in_nofile();
extern int in_eof(void);

#define OFPS_MAX    10
#ifndef WIN32_1
extern FILE *ofp; /* Filepointer to actual output file */
#else
extern HFILE ofp; /* Filepointer to actual input file */
#endif
extern char outfn[MAXFN];
extern void out_file();
extern void out_nofile();

extern int exists_file(char *);
extern int fileexists(char *);
extern int filesize(char *);
extern int filemodified(char *);
extern int del_file(char *);
extern int validfilename(char *);

extern int exists_directory(char * dirname);
extern void make_directory(char * dirname);
extern void remove_directory(char * dirname);

#define MAXSUFFICES 20
extern List genfnlist(char *);
extern List extractfnlist(List *, char *);
extern void sortfnlist(List *);
extern List genactfnlist(char * opt);
extern List genfilelist(char * path, char * pattern);

extern int matching_string(char * line, char * str1);
extern List genfnpatternlist(char * path, char * pattern);

/* -------------------------------------------------------------- */
/* TextIO-Functions:                                              */
/* -------------------------------------------------------------- */

#define chEOL   '\n'
#define chEOT   '\1'
#define chEOF   (char) EOF

extern char xch;

extern char char2bool(char);
extern char bool2char(int);

extern void write_eol(); 
extern void write_eot();
extern void write_char(); 

extern void write_line(char *);
extern void write_string(char *);
extern void write_text(char **);
extern int write_file(char * filename, char * data);
extern int write_binfile(char * filename, char * data, int size);

extern char read_char();
extern void read_line_tab(char * str);
extern char * read_line();
extern char ** read_text();
extern char * read_file(char * filename);
extern void * read_binfile(char * filename, int * fsize);

extern void print_text(char **);

/* ------------------------------ */
/* Functions find & replace       */
/* ------------------------------ */

extern int basis_open_file(char * fn);
extern void basis_write_file(void);

extern char * basis_in_line(char * line);
extern void basis_out_line(char * line);

extern int basis_find(char * line, char * strg);
extern int basis_replace(char * line, char * str1, char * str2);

#endif


