
		     		- LIB CH -

				Version 1.0

*Introduction:
==============
This is my universal C library called "libch". It is intendet to help C
programmers - exspecially new ones - with providing them small solutions
for common programming tasks.

If you have remarks or suggestions I would be happy if you would write me
an email !

read you,
 
    -christian-


*Legal Note:
============
 This file is part of my universal C library "libch".
 Copyright (C) 1998  Christian Hammers <ch@westend.com>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.

 This library 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
 Library General Public License for more details.

 You should have received a copy of the GNU Library General Public
 License along with this library; if not, write to the Free
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

		A BIG FAT note on the database routines:
		========================================
The msql and mysql database functions are NOT formal part of this library. 
They are considered as a feature that is provided with the source.
That is a must because some of the supported databases are/might be not
free software and I do not want my library depend on non GPL software.
If you want to use them: here they are. If you do not want to, you do not
have to ! They are just gimmicks.
                ========================================


*Overview:
==========
The library is splitted up in several logical parts.
CGI		The lack of good and easy CGI routines was the main reason
		for that I started this project. With this part it is easy
		to get the HTML form parameters independent of the method
		(post/get). URL encoding support exists, too.

DEBUG		Because CGI programs are hard to debug I decided to make me
		some helpers. The first routine is simply called "___();"
		and works exactly like printf but writes to a filed in the
		/tmp directory. The second one is the macro "____" which
		prints the line # of the source file into this debug file.
		both functions do imediately close the debug file so that
		its content is save even if the CGI program crashed !!!

		Also some save malloc/free functions are provided.

HTML		Here are two functions to convert HTML char encodings.

INET		Several functions that checks if hostnames/domainnames and
		IP addresses were given in a valid format.

REGEX		Until now just one function that matches a string against a
		regular expression. (Because regcomp and regexec are so
		ugly to use)

TIME		Some EASY to remember functions that converts a date in one
		of the forms "time_t", "date string", "struct tm" to one of
		the others. (Ever tried to convert "30.10.1998" to struct
		tm ?)

PGSQL		These functions are an easy to use, easy to remember
(MYSQL)		frontend for the three SQL databases msql, mysql and pgsql.
(MSQL)		The functions are written in a way that allows you to write
		your program INDEPENDEND of the database server you use.
		Simply change 1 #define statement to switch between these
		three databases. (see also note on top of this document)
		Of course only one or two of them can be compiled, skipping
		the others. You need the database header files to compile
		them.

*Content:
=========
Here a summary of the library content is given. It might be out dated and
is only provided as an overview. Check the header file if you are curious.

typedef	char	string[300];

void 		ch_debug(char *format, ...);
#define ____ 	ch_debug("LINE:%d",__LINE__);
#define ___ 	ch_debug
void 		ch_done(); 
void 		ch_panic(char *format, ...); 
void 	       *ch_malloc(size_t size); 

/***			CGI						*/	
void 		ch_cgi_panic(char *format, ...); 
void 		ch_cgi_init(); 
void 		ch_cgi_dump();
char 	       *ch_cgi_unescape(char *s);
void 		ch_cgi_get_value(char *name, char *buffer, int bufsize);
int 		ch_cgi_isset_value(char *name); 

/***			HTML						*/	
int 		ch_html_escape (char *out, const unsigned char *in, int maxout);
int 		ch_html_unescape (char *out, const unsigned char *in, int maxout);

/***			TIME						*/	
time_t 		ch_time_get();
int 		ch_time_tm2timet(struct tm *tm_in, time_t *timet_out);
int 		ch_time_tm2str(struct tm *tm_in, char *str_out);
int 		ch_time_timet2tm(time_t timet_in, struct tm *tm_out);
int 		ch_time_timet2str(time_t timet_in, char *str_out);
int 		ch_time_str2tm(char *str_in, struct tm *tm_out);
int 		ch_time_str2timet(char *str_in, time_t *timet_out);

/***			SQL						*/	
#define		ch_sql_main_t		
#define 	ch_sql_res_t	
#define 	ch_sql_row_t

void 		ch_sql_open(char *name);
void 		ch_sql_close();
char 	       *ch_sql_error();
int 		ch_sql_query(char *query);
ch_sql_res_t   *ch_sql_store_result();
int 		ch_sql_num_rows(ch_sql_res_t *result);
ch_sql_row_t 	ch_sql_fetch_row(ch_sql_res_t *result);
void 		ch_sql_free_result(ch_sql_res_t *result); 

/***			INET						*/	
int 		ch_inet_errno;
int 		ch_inet_gethost(char *src, char *dst, int maxlen);
int		ch_inet_getdomain(char *src, char *dst, int maxlen);
int		ch_inet_gettld(char *src, char *dst, int maxlen);
int 		ch_inet_validhost(char *host);
int 		ch_inet_validdomain(char *domain);
int 		ch_inet_validtld(char *tld);
int 		ch_inet_checkfqdn(char *s);
int 		ch_inet_checkdomain(char *s);
int 		ch_inet_checkdedomain(char *s);
int 		ch_inet_checkcomdomain(char *s); 
int 		ch_inet_validip(char *ip);

/***			REGEX						*/	
int 		ch_regex_match(char *s, char *ex);


EOT
