
/* C<<1 header file v0.2 - style sheet for ANSI C  */
/* Please pronounce as "cee-shift-left-by-one" :)  */
/* GNUpyright(G)2003 Michael xChaos Polak, x@n.cz  */

#ifndef __CLL1H__
#define __CLL1H__

#include <stdio.h>
#include <string.h>

#define not !
#define TRUE 1
#define FALSE 0

#define every(A,B) for( A=B; A; A=A->next)
#define search(A,B,C) every(A,B) if(C)

#define order_by(K1,K2) (K1>K2)
#define desc_order_by(K1,K2) (K1<K2)
#define sort_by(K1,K2) (strcmp(K1, K2)>0)
#define desc_sort_by(K1,K2) (strcmp(K1, K2)<0)

#define create(A,T) { A=(struct T *)malloc(sizeof(struct T)); A->next=NULL; }
#define push(A,B) { if(A && A!=B) A->next=B; B=A; }
#define append(A,B) { if(B) { void *N=A; A->next=NULL; search(A,B,!A->next) {A->next=N; break;}} else push(A,B); }
#define insert(A,B,EXP,K) { if(B) { void **L=NULL, *H=B; 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); }
#define remove(A,B,C) { void **D=NULL; search(A,B,C) { if(D)*D=A->next; else B=A->next; free(A); } else D=(void *)&(A->next); }
#define drop(A,B) { for( A=B; A ; B=A, A=A->next, free(B)); B=NULL; }

#define eq(A,B) !strcmp(A,B)
#define string(S,LEN) { S=(char *)malloc(LEN); *S=0; }
#define duplicate(A,B) if(A) { B=string(strlen(A)); strcpy(B,A); }

#define loop while(1)
#define iterate(VAR,FROM,TO) for(VAR=FROM; VAR <= TO; VAR++)

#endif

