Reference

libch(3)

Universal C library

NAME

libch - Universal C library

SYNOPSIS

#include "libch.h"

DESCRIPTION

This is my universal C library called programmers - exspecially new ones - with providing them small solutions for common programming tasks.
WARNING: This is BETA Software and my contain BUGS !

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

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.

Functions

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];
/***			DEBUG 					*/
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);

AUTHOR

Copyright 1998,1999 by Christian Hammers <[email protected]>. This software is licensed by the LGPL.