cwuser.h
上传用户:xiaoan1112
上传日期:2013-04-11
资源大小:19621k
文件大小:11k
源码类别:

操作系统开发

开发平台:

Visual C++

  1. /***
  2. * $Workfile:   cwuser.h  $
  3. * $Revision:   1.5  $
  4. *   $Author:   Dave Sewell  $
  5. *     $Date:   28 Sep 1990  9:54:46  $
  6. ***/
  7. #ifndef BYTE
  8. #define BYTE  unsigned char
  9. #endif
  10. #ifndef WORD
  11. #define WORD  unsigned short
  12. #endif
  13. #ifndef O_RAW
  14. #define O_RAW O_BINARY
  15. #endif
  16. #ifndef NULL
  17. #if defined(M_I86LM) || defined(M_I86CM) || defined(M_I86HM)
  18. #define NULL 0L
  19. #else
  20. #define NULL 0
  21. #endif
  22. #endif
  23. #ifndef NOPROC
  24. #define NOPROC ((int (*)())0)
  25. #endif
  26. #ifndef TRUE
  27. #include    "osdep.h"
  28. #endif
  29. /**** The following are a core of functions common to most applications ****/
  30. #include "bioskybd.h"
  31. #include "screen.h"
  32. /*** fatal error numbers ***/
  33. #define CREATE_PORTAL_FATAL_ERROR   1
  34. #define DISPLAYTEXTINPORTAL_FATAL_1 2
  35. #define DISPLAYTEXTINPORTAL_FATAL_2 3
  36. #define HELP_STACK_FULL_FATAL_ERROR 5
  37. #define HELP_MALLOC_FATAL_ERROR     7
  38. #define LIST_STACK_FULL_FATAL_ERROR 8
  39. #define LIST_STACK_EMPTY_FATAL_ERR  9
  40. #define OUT_OF_NEAR_HEAP_FATAL_ERROR 10
  41. #define PORTAL_TABLE_FULL_FATAL_ERROR 11
  42. #define LIST_SEARCH_ERROR 12
  43. /*** color definitions ***/
  44. #define INIT_NORMAL (color(CYAN,BLUE))
  45. #define INIT_REVERSE (color(BLUE,CYAN) | MONO_REVERSE)
  46. #define INIT_RBLINK (color(BLUE,CYAN) | MONO_REVERSE | BLINKING)
  47. #define INIT_INTENSE (color(CYAN,BLUE) | INTENSE)
  48. #define INIT_IBLINK (color(CYAN,BLUE) | INTENSE | BLINKING)
  49. #define LIST_NORMAL (color(WHITE,BLUE) | INTENSE | MONO_BOLD)
  50. #define LIST_DIM (color(WHITE,BLUE) | MONO_NORMAL)
  51. #define LIST_REVERSE (color(BLUE,WHITE) | MONO_REVERSE)
  52. #define LIST_RBLINK (color(BLUE,WHITE) | MONO_REVERSE | BLINKING)
  53. #define LIST_INTENSE (color(YELLOW,BLUE) | MONO_BOLD)
  54. #define LIST_IBLINK (color(YELLOW,BLUE) | BLINKING)
  55. #define ALERT_REVERSE (color(WHITE, MAGENTA) | INTENSE | MONO_REVERSE)
  56. #define NO_CLEAR    0x80
  57. struct portal
  58. {
  59.     BYTE frameLine;      /* Topmost line of frame on physical screen */
  60.     BYTE frameColumn;      /* Leftmost column of frame on physical screen */
  61.     BYTE frameHeight;      /* Height of frame on physical screen */
  62.     BYTE frameWidth;      /* Width of frame on physical screen */
  63.     BYTE saveFlag;      /* TRUE = save old screen (may have NO_CLEAR) */
  64.     BYTE borderType;      /* Type of border to use */
  65.     int  borderAttribute;    /* Attribute to use with border */
  66.     int  borderDeselect;     /* Border attribute when deselected. */
  67.     int  normal_attribute;   /* Normal attribute for portal body. */
  68.     char *headerText;      /* Pointer to header text */
  69. };
  70. typedef struct pcb
  71. {
  72.     struct portal p;
  73.     byte headerLen;      /* Max length of header, including null */
  74.     char *saveScreen;      /* Address of save screen */
  75.     BYTE portalLine;      /* Topmost line of portal on physical screen */
  76.     BYTE portalColumn;      /* Rightmost column of portal on physical screen */
  77.     BYTE portalHeight;      /* Height of portal */
  78.     BYTE portalWidth;      /* Width of portal */
  79. } PCB;
  80. #define NO_MESSAGE ((char *) 0)
  81. #define NOHEADER   ((char *)NULL) /* no header with the portal */
  82. #define NOBORDER   ((BYTE)0)   /* no border around portal */
  83. #define SINGLE    ((BYTE)1)   /* single line forms border */
  84. #define DOUBLE    ((BYTE)2)   /* double line forms border */
  85. #define SAVE    ((BYTE)1)   /* save old screen under portal */
  86. #define NOSAVE    ((BYTE)0)   /* don't save screen under portal */
  87. #define CURSOR_ON  ((BYTE)1)   /* turn the cursor on in the portal */
  88. #define CURSOR_OFF ((BYTE)0)   /* turn the cursor off in the portal */
  89. #define DIRECT    ((BYTE)1)   /* no virtual space for portal */
  90. #define VIRTUAL    ((BYTE)0)   /* create virtual space for portal */
  91. /**** valid key flags for SelectFromList ****/
  92. #define M_ESC     0x0001
  93. #define M_ESCAPE    0x0001
  94. #define M_INSERT    0x0002
  95. #define M_DELETE    0x0004
  96. #define M_MODIFY    0x0008
  97. #define M_SELECT    0x0010
  98. #define M_MDELETE   0x0020
  99. #define M_CYCLE     0x0040
  100. #define M_MMODIFY   0x0080
  101. #define M_MSELECT   0x0100
  102.     /* these are both only used in split screen mode, so the
  103.     *  verification checks should work fine.  M_MARKALL is
  104.     *  only used for verification, and the value is never
  105.     *  returned to the caller of SelectFromList, so it
  106.     *  we can identify this return value as a MKDIR.
  107.     */
  108. #define M_MARKALL   0x0200
  109. #define M_MKDIR     0x0200
  110. #define M_VIEW     0x0400
  111. #define M_RENAME    0x0800
  112. #define M_MARKPLUS  0x1000
  113. #define M_LEFT     0x2000
  114. #define M_RIGHT     0x4000
  115. #define TEXT_OFFSET 9
  116. /**** definition of list marking primitives ****/
  117. /* The following bit in the 1st byte of the record is used for the mark bit. */
  118. #define MARK_BIT    0x40
  119. #define Mark(element)    (*((char far *)element) |=  MARK_BIT)
  120. #define Unmark(element)    (*((char far *)element) &= ~MARK_BIT)
  121. #define IsMarked(element)  (*((char far *)element) &   MARK_BIT)
  122. /**** definition of list structure ****/
  123. /* NOTE: The 'text' field is declared as an array of 1 character.  However,
  124.  * the list manipulation procedures will allocate a memory buffer longer than
  125.  * the minimum size of the LIST structure.  The 'text' field is treated as a
  126.  * null-terminated string occupying the memory left over from that used by the
  127.  * other fields.
  128.  */
  129. typedef struct LIST_STRUCT
  130. {
  131.     BYTE marked;      /* whether or not element is marked */
  132.     struct LIST_STRUCT far *prev;    /* previous element in list */
  133.     struct LIST_STRUCT far *next;    /* next element in list */
  134.     char far *otherInfo;      /* pointer to auxiliary data */
  135.     char text[1];      /* text (primary data) for element */
  136. } LIST;
  137. typedef struct listptr
  138. {
  139.     LIST far *head;
  140.     LIST far *tail;
  141.     int (pascal *sortProc)();
  142. } LISTPTR;
  143. struct options {
  144.     char *text;      /* Description of option.     */
  145.     int  value;      /* Value to associate with the option.     */
  146. };
  147. struct menu {
  148.     byte center_line; /* Line (row) to center vertically on.     */
  149.     byte center_column;  /* Column to center horizontally on.     */
  150.     char *header; /* Header (title) for menu.     */
  151.     int  help_screen; /* Help screen number.     */
  152.     int  (*action)(int); /* Action routine.     */
  153.     struct options *options; /* Pointer to list of options.     */
  154. };
  155. /* Form definitions */
  156. struct edtstr {  /* Edit string type data structure     */
  157.     byte center_line; /* Line (row) where edit portal is centered */
  158.     byte center_column;  /* Column where edit portal is centered     */
  159.     byte portal_height;  /* Edit portal height     */
  160.     byte portal_width; /* Edit portal width     */
  161.     char *header; /* Header message for edit portal     */
  162. };
  163. struct fields {
  164.     void *data;      /* Pointer to data for field     */
  165.     int  bufsize;     /* size allocated for *data      */
  166.     byte line;     /* Line (in portal) of field     */
  167.     byte column;     /* Column (in portal) of field     */
  168.     byte width;      /* Width (in portal) of field     */
  169.     byte type;     /* Type of field     */
  170.     int flags;     /* Control Flags     */
  171.     int help_screen;     /* Help screen for field     */
  172.     char *prompt;     /* Prompt for field      */
  173.     void *info;      /* Pointer field specific data     */
  174. };
  175. struct form {
  176.     byte center_line; /* Line (row) to center vertically on.     */
  177.     byte center_column;  /* Column to center horizontally on.     */
  178.     byte form_height;
  179.     byte form_width;
  180.     char *header; /* Header (title) for menu.     */
  181.     int  help_screen; /* Help screen number.     */
  182.     int  exit_help_screen; /* Help screen number.     */
  183.     struct fields *fields; /* Pointer to list of fields.     */
  184. };
  185. struct form_control {
  186.     int (near _fastcall *input)(struct fields *, int, int *);
  187.     void (near _fastcall *output)(struct fields *);
  188.     int (near _fastcall *verify)(struct fields *);
  189. };
  190. /* Standard form field types */
  191. #define MENU_TYPE      0
  192. #define TIME_TYPE      1
  193. #define DATE_TYPE      2
  194. #define STRING_TYPE    3
  195. #define EDTSTR_TYPE    4
  196. #define PROMPT_TYPE    5
  197. #define NULL_TYPE      6
  198. /**** Field select key types ****/
  199. #define S_NONFUNC 0x00 /* Non function key cause selection */
  200. #define S_SELECT  0x01 /* K_SELECT key caused selection */
  201. #define S_MODIFY  0x02 /* K_MODIFY key caused selection */
  202. #define S_INSERT  0x04 /* K_INSERT key caused selection */
  203. #define S_DELETE  0x08 /* K_DELETE key caused selection */
  204. /**** fieldFlags Type masks ****/
  205. #define NORMAL_FIELD     0x00 /* normal editable field */
  206. #define LOCKED_FIELD     0x01 /* non accessable */
  207. #define REQUIRED_FIELD     0x02 /* verify field on form exit */
  208. #define PROMPT_FIELD     0x04 | LOCKED_FIELD
  209. #define RIGHT_FORMAT     0x40 /* right justification format */
  210. #define LEFT_FORMAT     0x80 /* left justification format */
  211. #define CENTER_FORMAT     0xC0 /* centering format */
  212. #define LONGEST_MONTH_NAME 9
  213. /**** Definition of edit return codes ****/
  214. #define E_CHANGE     0x01    /* Whether buffer was changed */
  215. #define E_ESCAPE     0x02    /* Whether buffer edit was canceled */
  216. #define E_SELECT     0x04    /* Whether changes confirmed */
  217. #define E_EMPTY      0x08    /* Whether buffer has anything in it */
  218. /* Video Scroll Directions */
  219. #define V_UP  ((BYTE)6)
  220. #define V_DOWN  ((BYTE)7)
  221. #define FATAL       1
  222. #define WARNING        2
  223. #define INFORM       3
  224. #define J_NONE       0
  225. #define J_LEFT       1
  226. #define J_RIGHT        2
  227. #define HEADER_NONE       -1
  228. #define HEADER_NORMAL       0
  229. #define NO_HELP_CONTEXT       -1
  230. extern int (* edit_portal_string_key_handler)(int);
  231. extern int currentPortal; // Index of current portal.
  232. extern PCB *portal[];         // Table of active portals.
  233. extern unsigned list_rec_size;
  234. extern unsigned list_num_recs;
  235. /*** Macros for doing writes within a portal. ***/
  236. extern unsigned origin;
  237. #define p_fill_attr(ul, size, c, att) fill_attr((ul)+origin, size, c, att)
  238. #define p_dispstr_attr(pos, buf, att) dispstr_attr((pos)+origin, buf, att)
  239. #define p_dispmem_attr(pos,buf,cnt,att) dispmem_attr((pos)+origin,buf,cnt,att)
  240. #define p_dispstr(pos,buf) dispstr((pos)+origin, buf)
  241. #define p_dispchar(pos,c) dispchar((pos)+origin, c)
  242. #define p_locate(row_col) locate((row_col)+origin)
  243. #define p_dispmem(pos, buff, cnt) dispmem((pos)+origin, buff, cnt)
  244. #define p_clear(ulpos, lrpos) clear((ulpos)+origin, (lrpos)+origin)
  245. #define p_scroll_up(ul,lr,att,cnt) scroll((ul)+origin,(lr)+origin,att,cnt,0)
  246. #define p_scroll_down(ul,lr,att,cnt) scroll((ul)+origin,(lr)+origin,att,cnt,1)
  247. #define p_fill(ulpos, size, c) fill((ulpos)+origin, size, c)
  248. #define p_shade(ulpos, height_width) shade((ulpos)+origin, height_width)
  249. #define p_save_zone(ulpos, size, buff) save_zone((ulpos)+origin, size, buff)
  250. #define p_restore_zone(ulpos,size,buff) restore_zone((ulpos)+origin,size,buff)
  251. /* date and time format controls */
  252. #define NORMAL_DATE        0x00
  253. #define USE_ALPHA_MONTH        0x01
  254. #define INCLUDE_DAY_OF_WEEK    0x02
  255. /* box_printf flags */
  256. #define BOX_HORIZ_FLAGS     0x03
  257. #define HORIZ_CENTER        0x00
  258. #define HORIZ_LEFT          0x02
  259. #define HORIZ_RIGHT         0x01
  260. #define BOX_VERT_FLAGS      0x0C
  261. #define VERT_CENTER         0x00
  262. #define VERT_TOP            0x08
  263. #define VERT_BOTTOM         0x04
  264. #define BOX_DOUBLE          0x00
  265. #define BOX_SINGLE          0x10
  266. #define BOX_SAVE            0x00
  267. #define BOX_NOSAVE          0x20
  268. #define BOX_BELL            0x40
  269. #include <stdarg.h>
  270. #ifndef CWFUNC
  271. #define CWFUNC 1
  272. #include    "cwfunc.h"
  273. #endif