+#define insert(NODE,HEAD,EXP,K) { if(HEAD) { void **_L=NULL, *H=HEAD; /**/ for_search(HEAD,H,EXP(HEAD->K,NODE->K)) { if(_L) {*_L=NODE; NODE->__next=HEAD; } else push(NODE,H); break; } else _L=(void *)&(HEAD->__next); if(!HEAD)*_L=NODE; HEAD=H; } else if (NODE) { push(NODE,HEAD); HEAD->__next=NULL; } }
+#define sort(NODE,HEAD,EXP,K) { void *_NEXT; /**/ NODE=HEAD; HEAD=NULL; do { _NEXT=NODE->__next; NODE->__next=NULL; insert(NODE,HEAD,EXP,K); NODE=_NEXT; } while(_NEXT); }
+/* .----------------------------------------------------------------------.
+ / 7. C<<1 builtin iterators and conditionals, updated 2008-01-26 xCh.
+ '----------------------------------------------------------------------- */
+#define loop while(TRUE)
+#define repeat(N) if(N>0) _NEW_I for_range(_I,1,N)
+#define for_range(VAR,FROM,TO) for( VAR=FROM ; FROM<=TO?VAR<=TO:VAR>=TO ; FROM<=TO?VAR++:VAR--)
+#define for_each(NODE,HEAD) for(NODE=HEAD; NODE; NODE=NODE->__next)
+#define for_search(NODE,HEAD,EXPR) for_each(NODE,HEAD) if(EXPR)
+#define for_file_lines(STR,F) /* _NEW_F for() */
+#define for_ints(VAR,...) _NEW_I for( _I=0 ; (VAR=_cll1_it_ints(_I,__VA_ARGS__,-1))>=0 ; _I++)
+#define for_strs(VAR,...) _NEW_I for( _I=0 ; (VAR=_cll1_it_strs(_I,__VA_ARGS__,(void *)&_cll1_it_strs))!=(void *)&_cll1_it_strs ; _I++)
+#define if_exists(A,B,C) for_search(A,B,C) break; if(A)
+#define for_args _NEW_I for(_I=1;_I<argc;_I++)
+#define if_args if(argc>1)
+#define if_arg(VAL) if(eq(argv[_I],VAL))
+#define this_arg argv[_I]
+#define next_arg ((_I+1<argc)?argv[_I]:NULL)
+#define skip_next _I++
+/* .----------------------------------------------------------------------.
+ / 8. C<<1 object oriented infrastructure, updated 2008-01-26
+ '----------------------------------------------------------------------- */
+#define define_metaobject(METATYPE,ITYPE) struct METATYPE { struct ITYPE *__interface; };
+#define define_interface(MTYPE,ITYPE) struct ITYPE *_construct_##_##MTYPE##_##ITYPE(void *dummy, ...) { define_mem(_FACE,IFACE); va_list(ap); _FACE=get_mem(IFACE) _bind_##_##MTYPE##_##ITYPE(_FACE); return _FACE; } void _bind_##_##MTYPE##_##ITYPE(struct IFACE *_FACE)
+#define bind_method(METHOD,FUNCTION) _FACE->METHOD=FUNCTION
+#define construct_interface(MTYPE,...) _construct_##_##MTYPE##_##_ARG1(__VA_ARGS__)((void *)__get_##_##MTYPE##_##__VA_ARGS__)
+#define get_object(TYPE,...) (struct TYPE *)_cll1_allocate_object(sizeof(struct TYPE), __VA_ARGS__)
+#define construct_object(TYPE,...)
+//#define _(OBJECT,...) (_ASSERT(OBJECT),/**/(*(OBJECT->interface->_ARG1(__VA_ARGS__,)))/**/(OBJECT,OBJECT->interface->__VA_ARGS__)/**/)
+/* .----------------------------------------------------------------------.
+ / 9. implementation of C<<1 library functions, updated 2008-01-26 xCh.
+ '----------------------------------------------------------------------- */
+#define _MALLOC void *_cll1_malloc(size_t size,...) { /*temporary solution*/ return malloc(size); }
+#define _CLL1_FPRINT(IOSTREAM,LASTARG) { int p2=0;char *ofs=coalesce(OFS,"\0");va_list ap; /**/ for(va_start(ap,s);s!=LASTARG;s=va_arg(ap,char *)) { if(p2 && *ofs) fputs(ofs,IOSTREAM); else p2=1; fputs(coalesce(s,NIL),IOSTREAM); } va_end(ap); if(EOL && *EOL) fputs(EOL,IOSTREAM); }
+#define _PRINT void _cll1_print(char *s,...) _CLL1_FPRINT(stdout,(void *)&_cll1_print)
+#define _FPRINT void _cll1_fprint(FILE *f,char *s,...) _CLL1_FPRINT(f,(void *)&_cll1_fprint)
+#define _CLL1_FECHO(IOSTREAM,LASTARG) { va_list ap; /**/ for(va_start(ap,s);s!=LASTARG;s=va_arg(ap,char *)) fputs(coalesce(s,NIL),IOSTREAM); va_end(ap); }
+#define _ECHO void _cll1_echo(char *s,...) _CLL1_FECHO(stdout,(void *)&_cll1_echo)
+#define _FECHO void _cll1_fecho(FILE *f,char *s,...) _CLL1_FECHO(f,(void *)&_cll1_fecho)
+#define _IT_INTS int _cll1_it_ints(int i, int n, ...) { int j=0;va_list ap; /**/ va_start(ap,n); while(n>=0 && j++<i) n=va_arg(ap,int); return n; }
+#define _IT_STRS char *_cll1_it_strs(int i, char *s, ...) { int j=0;va_list ap; /**/ va_start(ap,s); while(s!=(void *)&_cll1_it_strs && j++<i) s=va_arg(ap,char *); return s; }
+/* .----------------------------------------------------------------------.
+ / 10. C<<1 globals and private macros, updated 2008-01-27 by xCh.
+ '----------------------------------------------------------------------- */
+#define _ARG1(ARG1,...) ARG1
+#define _ARG2(ARG1,ARG2,...) ARG2
+#define _ISTACK struct _IAtom { int i; int _23; list(_IAtom); } *_Iatom,*_Istack=NULL;
+#define _SSTACK struct _SAtom { char *s; int _23; list(_SAtom); } *_Satom,*_Sstack=NULL;
+#define _FSTACK struct _FAtom { FILE *F; int _23; list(_FAtom); } *_Fatom,*_Fstack=NULL;
+#define _MSTACK struct _MAtom { void *ptr; size_t size; int _23; tree(_MAtom); } *_Matom,*_Mstack=NULL;
+#define _NEW_(ATOM,STACK,TYPE) (ATOM=get_mem(TYPE),ATOM->_23=1,push(ATOM,STACK);ATOM->_23||pop(ATOM,STACK)&&0;ATOM->_23--)
+#define _NEW_I for _NEW_(_Iatom,_Istack,_IAtom)
+#define _NEW_S for _NEW_(_Satom,_Sstack,_SAtom)
+#define _NEW_F for _NEW_(_Fatom,_Fstack,_FAtom)
+#define _I (_Iatom->i)
+#define _S (_Satom->s)
+#define _F (_Satom->F)
+#define _FOR_COLUMNS(A,B,C) _NEW_I for(_I=0,prefix(A,B,C);A;((A!=B)&&prefix(A,B,C)||(A=NULL)),_I++)
+#define _FOR_VALID_COLUMNS(A,B,C) _NEW_I for(_I=0,prefix(A,B,C);A;((A!=B)&&prefix(A,B,C))||(A=NULL)) if(*A&&++_I)
+/* .----------------------------------------------------------------------.
+ / 11. C<<1 CGI and FASTCGI handling, updated 2008-01-16 by xCh.
+ '----------------------------------------------------------------------- */
+#ifdef USE_LIBRARY_FASTCGI
+#define while_fastcgi_accept while(FCGI_Accept()>=0)
+#define USE_MODULE_CGI
+#endif
+#ifdef USE_MODULE_CGI
+#define cgi(MIME) { char *PTR; /***/ recycle_context(_CGI); _CGIdict=NULL; for_split_str(PTR,getenv("QUERY_STRING"),'&') /* _init_cgi */ if(MIME) printf("Content-type: %s\r\n\r\n",MIME); }
+//todo #define _GETCGI char *getcgi(VAR) { }
+#define _CGIDICT define_context(_CGI); struct _CGIVariable { char *V; dictionary(_CGIVariable); } *_CGIvariable,*_CGIdict;
+#else
+#define _CGIDICT
+#endif
+/* .----------------------------------------------------------------------.
+ / 12. MySQL infrastructure and wrappers - updated 2007-12-19 by xCh.
+ '----------------------------------------------------------------------- */
+#ifdef USE_LIBRARY_MYSQL
+#define mysql_connect(S,U,P,D) ((_SQLCatom=get_mem(_SQLCAtom)) && push(_SQLCatom,_SQLCstack) && (_SQLCatom->C=mysql_init(NULL)),(_SQLCatom->C && mysql_real_connect(_SQLCatom->C,S,U,P,D,0,NULL,0)?_SQLCatom->C:NULL))
+#define for_mysql_query_results(ROW,QUERY) _NEW_(_SQLRatom,_SQLRstack,_SQLRAtom)for(_SQLRatom->R=(mysql_query(_SQLCatom->C,QUERY)?NULL:mysql_use_result(_SQLCatom->C)),ROW=(_SQLRatom->R?mysql_fetch_row(_SQLRatom->R):NULL);ROW;ROW=mysql_fetch_row(_SQLRatom->R))
+#define _SQLCSTACK struct _SQLCAtom { MYSQL *C; int _23; list(_SQLCAtom); } *_SQLCatom,*_SQLCstack=NULL;
+#define _SQLRSTACK struct _SQLRAtom { MYSQL_RES *R; int _23; list(_SQLRAtom); } *_SQLRatom,*_SQLRstack=NULL;
+#else
+#define _SQLCSTACK
+#define _SQLRSTACK
+#endif
+/* ------------------------------------------------------------------- */
+/* old - from version 0.6 */
+/* =================================================================== */
+/*
+obsolete