X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=cll1.h;h=81f4887429725c08fb34b9397fdaaa47fa75f8f4;hb=5a5eb547235b4b5f306022cbfd6727828cc622e5;hp=d9e00713e2a84ff7f93beb8ed06097de79694de0;hpb=099b0ca0180a985138b03ed81290e7268e051756;p=svn%2FCll1h%2F.git diff --git a/cll1.h b/cll1.h index d9e0071..81f4887 100644 --- a/cll1.h +++ b/cll1.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #ifdef USE_LIBRARY_MYSQL #include @@ -59,7 +60,7 @@ #define Define_mem(ID,TYPE) struct TYPE *ID=NULL #define Define_mems(ID1,I2,TYPE) Define_mem(ID1,TYPE);Define_mem(ID2,TYPE) -/* .... well.. ehm.. not very useful... :-) */ +/* .... well....ehm...not very useful... :-) */ #define Create_var(ID,TYPE,INIT) TYPE ID=INIT #define Define_var(ID,TYPE) TYPE ID /* ------------------------------------------------------------------- */ @@ -79,7 +80,9 @@ #define for_range(VAR,FROM,TO) for( VAR=FROM ; FROM<=TO?VAR<=TO:VAR>=TO ; FROM<=TO?VAR++:VAR--) #define for_each(A,B) for(A=B; A; A=A->_next) #define for_search(A,B,C) for_each(A,B) if(C) -/* to do: #define for_file_lines(STR,F) _NEW_F for() */ +#define for_file_lines(STR,F) /* _NEW_F for() */ +#define for_ints(VAR,...) _NEW_I while(_iterate_ints(&VAR,_I,__VA_LIST) ) +#define for_strs(VAR,...) _NEW_S /* obsolete #define every(A,B) for( A=B; A; A=A->_next) */ /* obsolete #define search(A,B,C) every(A,B) if(C) */ /* obsolete #define find(A,B,C) search(A,B,C) break; if(A) */ @@ -90,24 +93,32 @@ /* ------------------------------------------------------------------- */ /* 5. C<<1 argument handling, updated 2008-01-16 by xCh. */ /* ------------------------------------------------------------------- */ -#define for_arguments _NEW_I if(argc>1) for(_I=1;_I1) +#define if_arg(VAL) if(eq(argv[_I],VAL)) +#define this_arg argv[_I] +#define next_arg ((_I+1=0) #define USE_MODULE_CGI #endif #ifdef USE_MODULE_CGI +#define cgi(MIME) /* _init_cgi */ if(MIME) printf("Content-type: %s\r\n\r\n",MIME); //todo getcgi(VAR) -//todo _init_cgi +//todo define_init_cgi //todo #define _QSTACK struct _QStack { char *Q; int _23; list(_QStack); } *_Qatom,*_Qstack=NULL; #endif /* ------------------------------------------------------------------- */ -/* 7. MySQL infrastructure and wrappers - updated 2007-12-19 by xCh. */ +/* 9. MySQL infrastructure and wrappers - updated 2007-12-19 by xCh. */ /* ------------------------------------------------------------------- */ #ifdef USE_LIBRARY_MYSQL #define mysql_connect(S,U,P,D) (create(_Matom,_MStack) && push(_Matom,_Mstack) && (_Matom->M=mysql_init(NULL)),(_Matom->M && mysql_real_connect(_Matom->M,S,U,P,D,0,NULL,0)?_Matom->M:NULL)) @@ -136,10 +147,14 @@ /* ------------------------------------------------------------------- */ #define insert(A,B,EXP,K) { if(B) { void **_L=NULL, *H=B; for_search(B,H,EXP(B->K,A->K)) { if(_L) {*_L=A; A->_next=B; } else push(A,H); break; } else _L=(void *)&(B->_next); if(!B)*_L=A; B=H; } else push(A,B); } #define sort(A,B,EXP,K) { void *_C; A=B; B=NULL; do { _C=A->_next; A->_next=NULL; insert(A,B,EXP,K); A=_C; } while(_C); } -/* String macros & sequences, updated 2004-04-19 by xCh. */ - -#define eq(A,B) !strcmp(A,B) +/* ------------------------------------------------------------------- */ +/* String macros & sequences, updated 2008-01-22 by xCh. */ +/* ------------------------------------------------------------------- */ +#define eq(A,B) (A && B && !strcmp(A,B)) +#define eqi(A,B) (A && B && !strcasecmp(A,B)) +/* Borland C legacy */ #define strcmpi(A,B) strcasecmp(A,B) +/* ------------------------------------------------------------------- */ /* obsolete #define strlwr(A) {char *_S=A; while(_&&*_S){*_S=tolower(*_S);_S++;}} @@ -170,20 +185,19 @@ obsolete /* Infrastructure, updated 2008-01-08 by xCh. */ /* ------------------------------------------------------------------- */ /* old #define program int _I; int main(int argc, char **argv) */ -#define _ISTACK struct _IStack { int I; int _23; list(_IStack); } *_Iatom,*_Istack=NULL -#define _SSTACK struct _SStack { char *S; int _23; list(_SSTACK); } *_Satom,*_Sstack=NULL -#define _FSTACK struct _FStack { FILE *F; int _23; list(_FSTACK); } *_Fatom,*_Fstack=NULL +#define _ISTACK struct _IStack { int I; int _23; list(_IStack); } *_Iatom,*_Istack=NULL; +#define _SSTACK struct _SStack { char *S; int _23; list(_SSTACK); } *_Satom,*_Sstack=NULL; +#define _FSTACK struct _FStack { FILE *F; int _23; list(_FSTACK); } *_Fatom,*_Fstack=NULL; -#define define_ccl1_globals _ISTACK; _SSTACK; _FSTACK; _MSTACK; _RSTACK; _QSTACK -#define program define_cll1_globals; int main(int argc, char **argv) #define _NEW_(ATOM,STACK,TYPE) (create(ATOM,TYPE),ATOM->_23=1,push(ATOM,STACK);ATOM->_23||pop(ATOM,STACK)&&0;ATOM->_23--) #define _NEW_I for _NEW_(_Iatom,_Istack,_IStack) //#define _NEW_I for(create(_Iatom,_IStack),_Iatom->_23=1,push(_Iatom,_Istack);_Iatom->_23||pop(_Iatom,_Istack)&&0;_Iatom->_23--) #define _NEW_S for(create(_Satom,_SStack),_Satom->_23=1,push(_Satom,_Sstack);_Satom->_23||pop(_Satom,_Sstack)&&0;_Satom->_23--) -#define _I _Iatom->I -#define _S _Satom->I -#define _F _Satom->F +#define _I (_Iatom->I) +#define _S (_Satom->I) +#define _F (_Satom->F) +#define skip_one _I++ /* I/O iterations, updated 2004-04-19 by xCh. */ @@ -235,10 +249,20 @@ obsolete #define get_interface(IFACE) __get_##_##IFACE(void) // must be function #define get_object(TYPE) (_CLL1_MALLOC(TYPE),CLL1_ASSERT(),) //#define _(OBJECT,FUNCTION) OBJECT==NULL?NULL::(*(OBJECT->__class->METHOD))(OBJECT -#endif + /* ------------------------------------------------------------------- */ /* some general ideas, unfinished */ //#define _CLL1_THROW(ERR) //#define _CLL1_TRY _NEW_E for(;;) if () {.... if(_Eatom->SYS) { if(_Eatom->RET) return; else break;} else { } -//#define _CLL1_ASSERT(EXPR) assert(EXPR) +//#define _ASSERT(EXPR) assert(EXPR) //#define _CLL1_MALLOC(TYPE) malloc(sizeof(TYPE)) + +/* ------------------------------------------------------------------- */ +/* Voila - here we go ! */ +/* ------------------------------------------------------------------- */ +#define define_cll1_globals _ISTACK _SSTACK _FSTACK _MSTACK _RSTACK //_QSTACK +#define implement_cll1_functions _ECHO /* _GET_STR _GET_MEM */ +#define implement_cll1_library define_cll1_globals implement_cll1_functions +#define program implement_cll1_library int main(int argc, char **argv) +/* ------------------------------------------------------------------- */ +#endif