// file messages.txt
// part of Palantir documentation
// Palantir version 0.5

After successful installation you may find file 'messages.h' in djgpp/include
directory. It contains all msg codes your program can recognise. If you
want to extend standard set of messages, add your own code to the end of
this file. I offer a notification agreement : for global hardware msg use
prefix H_ ,e.g. H_MOUSE, for detailed hardware event use prefix E_, e.g.
E_R_UP - release of right mouse button and for software events use prefix APP_,
e.g. APP_START.

Here is description of msg format:

H_MOUSE - generated by mouse daemon
int p1 - packed information about mouse status.
int p2 - pointer to the keyboard_device structure. (device *dev)
To decode p1 use macros :
but_(p1) - mouse button state (same as Allegro used),
x_(p1) - mouse position x,
y_(p1) - mouse position y.

but_() may returns one of values :
E_L_PRESSED - left button in pressed state
E_M_PRESSED - middle ...
E_R_PRESSED - right ...
E_L_UP - left button released
E_M_UP - middle ...
E_R_UP - right ...
E_L_DOWN - left button pressed
E_M_DOWN - middle
E_R_DOWN - right
E_LDBL_CLICK - left button double clicked
E_MDBL_CLICK - middle ...
E_RDBL_CLICK - right ...
E_L_CLICK - left button clicked
E_M_CLICK - middle ...
E_R_CLICK - right ...
Note the difference between E_x_CLICK and E_x_UP : CLICK event occurred only
if x,y of PRESSED button equals to the x,y RELEASED button.
You may change 'dbl_click_delay' variable to adjust occurrence of
DBL_CLICK event.

H_KEYBOARD - generated by keyboard daemon
int p1 - packed information about keyboard
int p2 - pointer to the keyboard_device structure. (device *dev)
To decode p1 use macros :
scan_(p1) - scan code of pressed button,
ascii_(p1) - ASCII code of pressed button.
key_shifts_(p1) - status of control keys (Ctrl, Alt, Shifts, etc.)
(same format as Allegro used).
ctrl_(p1,c) - return 1 if Ctrl-c pressed, i.e. ctrl_(p1,'Q') returns TRUE if
you pressed 'Ctrl-Q'.
alt_(p1,c) - the same as ctrl_ macro but for the 'Alt' key but parameter c is
scancode, i.e. alt_(p1,KEY_A) returns TRUE if you pressed 'Alt-A'.

H_COMM_OUT - generated by comm write daemon
int p1 - byte send to the port
int p2 - pointer to the comm_device structure. (device *dev)

H_COMM_IN - generated by comm write daemon
int p1 - byte received from the port
int p2 - pointer to the comm_device structure. (device *dev)

E_TIMER_PERIOD - generated by scheduler daemon
int p1 - period passed
int p2 - pointer to the data structure 'scheduled_app' :
typedef struct
{ dz_app *app;
  time_t time_of_next_call;
  time_t period;
} scheduled_app;

APP_START - generated by application wrapper.
int p1 - pointer to the data structure 'dz_app':
typedef struct
{ res_status status;
  lwp *lwp_thread;
  char szName[64];
  int (*msg_handler)(a_message code,int p1,int p2);
  void *app_usrdata;
  fifo_queue *msg_queue;
} dz_app;
int p2 - 'void *args' argument passed to the lwp_spawn().

APP_STOP - generated on system shutdown
int p1 - unused
int p2 - unused

E_COMM_STRING - generated by 'Wait string application' (see 'apps.txt')
int p1 - (waiting_string*)pointer to the data structure 'waiting_string' :
typedef struct
{ dz_app *app;//application which wait for string
  device *dev;//port
  int status;//0 - active string; 1 - passive string (not processed)
  char *string;//waited string
  char *string_buf;//runtime buffer
  int string_len;
  int string_buf_len;
} waiting_string;
int p2 - just shortcat pointer to the p1->dev field. Comm port on which
given string was resieved.

E_COMM_DELIMITERS- generated by 'Wait delimiters application' (see 'apps.txt')
int p1 - (waiting_delimiter*) pointer to the data structure
         'waiting_delimiter' :
typedef struct
{ dz_app *app;//application wich wait for delimiter
  device *dev;//port
  int status;//0 - active string; 1 - passive string (not processed)
  char *delimiter1;//waited delimiter1
  char *delimiter1_buf;//runtime buffer
  int delimiter1_len;
  int delimiter1_buf_len;
  char *delimiter2;//waited delimiter2
  char *delimiter2_buf;//runtime buffer
  int delimiter2_len;
  int delimiter2_buf_len;
  buf_status_type buffer_status;
  int buffer_len;
  int buffer_max_len;
  char *buffer; //buffer for delimited text
} waiting_delimiter;
int p2 - (char*)strdup(p1->buffer). Note, you should free((char*)p2)
         after using it.