Sunday, January 20, 2019

My common forms

In a file called maps.h, it is below the fold.  Designing a snippet made easy, pick a common form, the ones most of the other snippets are using. They are types, you can cast them onto args list, and two snippets communicate like a full duplex call. Flush does this to feed xchars the flush buffer.  I am adding push and pop typedefs for stacks mapped to args. Notice all formats include a cmd field, this is the method entry into the destination table.

Scalar strings have no device, or owner, anonymous with no line of symmetry. They are not default, that is the purpose of the system, adapt to one and two lines of symmetry on strings. Noe the two top fields, the return status values, and the entry definition.  It is the top values, return status, the one common header definition I could not eliminate. I wanted to do the zero return is normal, leave the other status flags to users.  Couldn't do it. But that top line is the only requirement in this header, the others area, well known (entrytype, keyvalue) or purely optional commons.

We have a default of what I call  single line of symmetry because the default is to assume a scrolling console windows and single line command window, with echo. Flush can be null, but command line is always at least available. That is why IO manager has to move a cursor in x and have a command line history in y; no way to avoid the default.
enum { NOTFOUND=0,CONTINUE,EXIT,QUIT,SUCCESS,ERROR};
typedef int EntryType(int*,void**);
typedef union {
unsigned long l;
char txt[8];
char * s;
}Key;

typedef struct {
Key cmd;
Key key;
long val;
} KeyValue;
typedef struct {
Key cmd;
char *ptr;
} Scalar;  
typedef struct {
Key cmd;
Key dev;
char * ptr;
long x;
} XString;
typedef struct {
Key cmd;
Key dev;
char *  ptr;
long x;
long y;
} XYString;
typedef struct {
Key cmd;
Key dev;
long dx;
long dy;
} XYCursor;

#define pk(a)  *((unsigned long *) #a)
#define pkstr(a)  *((long *) a)
#define prtchrs(ptr)  i=0; while(ptr[i] && (i < 8)) putchar(ptr[i++])

No comments: