#include <mysql/mysql.h>
#endif
/* .----------------------------------------------------------------------.
- / 0. C<<1 typedefs and public gloabl variables, updated 2008-02-03 xCh.
+ / 0. C<<1 typedefs and public global variables, updated 2008-02-03 xCh.
'----------------------------------------------------------------------- */
-typedef char * str; /* #ifdef USE_MODULE_UNICODE...typedef wchar_t * str; */
+typedef void * any;
typedef unsigned char * buf; /* this will be always 8-bit usigned char * */
typedef FILE * file;
typedef int bool;
-extern str NIL,EOL,OFS,IFS;
+#ifdef USE_WCHAR_T
+typedef wchar_t * str;
+#else
+typedef char * str; /* Warning: full wchar_t support not yet implemented! */
+#endif
+extern str NIL, EOL, OFS, IFS, LANG, errstr; /* used for: perror(errstr) */
extern unsigned RANDOM_SEED;
-#define _EXPORT_GLOBALS str NIL="(null)", EOL="\n", OFS=" ", IFS=" \t\n", LANG=NULL; unsigned RANDOM_SEED=0;
+#define _EXPORT_GLOBALS \
+str NIL="(null)", EOL="\n", OFS=" ", IFS=" \t\n", LANG=NULL; \
+str errstr="C<<1 0xdead"; \
+unsigned RANDOM_SEED=0;
/* .----------------------------------------------------------------------.
/ 1. C<<1 then buddhist section, updated 2008-02-04 xCh.
'----------------------------------------------------------------------- */
//#define __(METHOD,...) ( _ASSERT(ARG1(__VA_ARGS__,)), (*( __cll1_seekmethod(ARG1(__VA_ARGS__,),METHOD) )) ( __VA_ARGS__ ) )
#define call(OBJTYPE,METHOD,...) { int _N=0; OBJTYPE _OBJ; /* <-' */ while( (_OBJ=(OBJTYPE)_cll1_for_ptrs(_N++,__VA_ARGS__,NIL))!=(OBJTYPE)NIL ) _(_OBJ,METHOD); }
#define def_community(TYPE,INTERFACE) def_obj(TYPE) { INTERFACE __interface; };
-#define anonymous void *
/* ---- variable declarators -------------------------------------------- */
#define Get_obj(ID,MEM,...) MEM ID=get_obj(MEM,__VA_ARGS__)
#define Get_obj_as(ID,COMMUNITY,MEM,...) MEM ID=get_obj_as(COMMUNITY,MEM,INTERFACE,__VA_ARGS__)
//#define _FOR_COLUMNS(A,B,C) _NEW(I,0) for( prefix(A,B,C) ; A ; ((A!=B)&&prefix(A,B,C)||(A=NULL) ),_I++ )
//#define _FOR_VALID_COLUMNS(A,B,C) _NEW(I,0) for( prefix(A,B,C) ; A ; ((A!=B)&&prefix(A,B,C))||(A=NULL) ) if(*A&&++_I)
#define _NEW(NAME,VALUE) for(_##NAME##atom=get_mem(_##NAME##Atom),_##NAME##atom->NAME=(VALUE),_##NAME##atom->c=1,push(_##NAME##atom,_##NAME##stack);_##NAME##atom->c||(pop(_##NAME##atom,_##NAME##stack),0);_##NAME##atom->c--)
-#define _ANYSTACK(NAME) _##NAME##Atom _##NAME##atom,_##NAME##stack=NULL;
+#define _ANYSTACK(NAME) extern _##NAME##Atom _##NAME##atom, _##NAME##stack; _##NAME##Atom _##NAME##atom,_##NAME##stack=NULL;
#define _EXPORT_STACKS _ANYSTACK(I) _ANYSTACK(S) _ANYSTACK(F) _ANYSTACK(CTX) _ANYSTACK(E)
_ANYATOM(I, int I;int J);
_ANYATOM(S, str S);
//#define _CLL1_THROW(ERR)
//#define _CLL1_TRY _NEW_E for(bind_exception(0,NULL);;) if () {.... if(_Eatom->SYS) { if(_Eatom->RET) return; else break;} else { }
-
/* .----------------------------------------------------------------------.
/ 98. We have have done our homework - now let's have some fun:
'----------------------------------------------------------------------- */
#define _IMPL_INTERFACE //_SQL_IFC _CAKE_IFC _STD_IFC _X_IFC
#define _IMPLEMENT_CLL1_LIBRARY _INIT_VARIABLES _IMPL_FUNCTIONS _IMPL_INTERFACE
//this will be probably accomplished some other way...
-//#ifndef DISABLE_CLL1_LIBRARY_IMPLEMENTATION
+#ifndef DISABLE_LIBRARY_CLL1
_IMPLEMENT_CLL1_LIBRARY
-//#endif
-#define _PROGRAM _cll1_program
+#endif
+#ifdef USE_LC_NUMERIC
+#define _LC_ALL LC_ALL
+#else
+//#define _LC_ALL LC_COLLATE|LC_CTYPE|LC_MESSAGES|LC_MONETARY|LC_TIME
+#define _LC_ALL LC_TIME
+#endif
#define _DECLARE_PROGRAM void _PROGRAM(int argc, char **argv)
+#define _PROGRAM _cll1_program
#define program \
_DECLARE_PROGRAM; \
int main(int argc, char **argv) \
{ \
- LANG=setlocale(LC_ALL, ""); \
+ LANG=setlocale(_LC_ALL, ""); \
try \
{ \
_PROGRAM(argc,argv); \
return 0; \
} \
- else \
- return -1; \
+ else_switch_failures \
+ { \
+ case SYSTEM_FAILURE: \
+ perror(errstr); /* and return -1 */ \
+ default: \
+ return -1; \
+ } \
} \
_DECLARE_PROGRAM
#ifdef USE_PREPROCESSOR
--- /dev/null
+#include "cll1.h"
+
+program
+{
+ str a,b;
+ time_t t = time(NULL);
+ int f;
+ str filename = "blabla.txt";
+
+ print("Local language (enviroment) is set to:", LANG);
+ print("C<<1 automatically activates locales LC_COLLATE|LC_CTYPE|LC_MESSAGES|LC_MONETARY|LC_TIME but not LC_NUMERIC:");
+ a = "¾luklý kùò";
+ b = "®LUKLÝ KÙÒ";
+ printf("str_order(\"%s\",\"%s\") = %d\n",a,b,str_order(a,b));
+ printf("eq(\"%s\",\"%s\") = %s\n",a,b,btoa(eq(a,b)));
+ printf("eq(\"%s\",\"%s\") = %s\n",a,a,btoa(eq(a,a)));
+ printf("eqi(\"%s\",\"%s\") = %s\n",a,b,btoa(eqi(a,b)));
+ printf("PI will be displayed as: %f\n",PI);
+ print("Time will be displayed as: ", ctime(&t));
+ print("Error mesages will be displayed as: ");
+ f = open(filename,"r");
+ if(f<0)
+ {
+ errstr = filename;
+ fail(SYSTEM_FAILURE);
+ }
+}