#define COMMON_DEFS
// Minimum support is reurn status
// NOTFOUND,0 and SUCCESS 1
// These values are stable
enum { NOTFOUND=0,SUCCESS,CONTINUE,EXIT,QUIT,ERROR};
extern int flush_file; // general purpose printf destination
// How horrid, a MAXINT!!
#define MAXINT 0x8000
#ifdef COMMON_MAPS
// Anything below this table
// is optional
// Typical things a 64 bit field might be
typedef int EntryType(int*,void**);
extern EntryType * ExecCommand;
typedef union {
unsigned long l;
char txt[8];
char * src;
void * vp;
EntryType * entry;
}Arg;
// Common type casts of the args array
typedef struct {
Arg cmd;
Arg arg1;
Arg arg2;
Arg arg3;
} Command;
// Common type casts of the args array
typedef struct {
Arg cmd;
EntryType * exec;
char * entry;
char * device;
char * flag;
} Bind;
typedef struct {
Arg cmd;
Arg key;
unsigned long def;
} KeyValue;
typedef struct {
Arg cmd;
Arg key;
char *ptr;
} Scalar;
typedef struct {
Arg cmd;
Arg key;
char * ptr;
long x;
} XString;
typedef struct {
Arg cmd;
Arg key;
char * ptr;
long x;
long y;
} XYString;
typedef struct {
Arg cmd;
Arg win;
long x;
long y;
} XYCursor;
typedef struct {
Arg cmd;
char * win;
Arg x;
Arg y;
Arg width;
Arg height;
} Rectangle;
// direct binary interface to xcb interface
// common macros
#define pk(a) *((unsigned long *) #a)
#define pkstr(a) *((long *) a)
#define prtchrs(ptr) i=0; while(ptr[i] && (i < 8)) putchar(ptr[i++])
#define convert(a) ( (a.l < MAXINT) ? a.l : atoi(a.src))
#define SYMBOL(Val) typedef struct Sym {\
Arg key;\
Val def;\
int type;\
struct Sym * less;\
struct Sym * more;\
struct Sym * parent;\
Val symlink;\
} Sym;\
typedef Sym * PSym;\
Sym * put_key(Arg v);\
Sym * get_key(Arg v);\
int list_keys(PSym p)
Arg arg_str(char * str) {
Arg a;
int i=0;
a.l=0;
while( (i<8) && str[i]) {a.txt[i] = str[i];i++;}
return(a);
}
Arg arg_long(long l) {
Arg a;
a.l=l;
return(a);
}
Arg arg_key(char * key) {
int base=0;
KeyValue c;
c.cmd.src = "GetKey";
c.key.src = key;
ExecCommand(&base,(void **) &c);
return(arg_long(c.def));
}
// putting ints to string
char * ItoA(int x,char * str) {
char * n="0123456789";
int i=0;
int k;
while(x) {
for(k=i;k > 0;k--) str[k]=str[k-1];
k = x % 10;
str[0]= n[k];
x/=10;
i++;
}
str[i]=0;
return(str);
}
#endif
#endif
No comments:
Post a Comment