⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nxproto.h

📁 开放源码实时操作系统源码.
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
 * Copyright (c) 2000 Alex Holden <alex@linuxhacker.org>
 *
 * Nano-X Core Protocol Header
 * 
 * These structures define the Nano-X client/server protocol.
 * Much of this has been modeled after the X11 implementation.
 * Note that all NX Protocol requests should have all data quantities
 * properly aligned. This is assured by hand-coding each NX request
 * structure.  Unlike Xlib, fixed size request structs don't have to
 * be a multiple of 4 bytes, since the length field is a byte count
 * and GetReq() automatically pads all requests to 4-byte boundaries.
 * Request structs for variable size data, however, must be hand-padded
 * to 4-byte alignment, as variable data starts after sizeof(structure).
 * Also, the hilength/length fields store the unaligned byte count, so
 * that extra code isn't required to de-crypt extra data size or
 * big packets.
 */

/*
 * The following is provided to allow limiting the maximum
 * request size that will be sent (not received) using this protocol.
 * The protocol allows for 2^24 byte maximum, but the
 * server currently allocates the MAXREQUESTSZ in a stack buffer.
 * Also, the client realloc's the request queue to 
 * the largest size asked for, and currently never reduces it.
 *
 * Routines like GrArea will split packets to be <= MAXREQUESTSZ
 * automatically.
 *
 * NOTE: MAXREQUESTSZ must be an _aligned_ multiple of 4, meaning
 * that MAXREQUESTSZ = (MAXREQUESTSZ + 3) & ~3.
 */
#define MAXREQUESTSZ	30000		/* max request size (65532)*/

typedef unsigned char	BYTE8;		/* 1 byte*/
typedef unsigned short	UINT16;		/* 2 bytes*/
typedef short		INT16;		/* 2 bytes*/
typedef unsigned long	UINT32;		/* 4 bytes*/

#if ELKS
typedef UINT16		IDTYPE;
#define ALIGNSZ		2	/* 2 byte packet alignment*/
#else
typedef UINT32		IDTYPE;
#define ALIGNSZ		4	/* 4 byte packet alignment*/
#endif

/* all requests share this header*/
typedef struct {
	BYTE8	reqType;	/* request code*/
	BYTE8	hilength;	/* upper 24 bits of unaligned length*/
	UINT16	length;		/* lower 16 bits of unaligned length*/
} nxReq;

/* Allocate a fixed size request from request buffer*/
#define AllocReq(name) \
	((nx##name##Req *)nxAllocReq(GrNum##name,sizeof(nx##name##Req), 0))

/* Allocate a request, but allocate n extra bytes*/
#define AllocReqExtra(name,n) \
	((nx##name##Req *)nxAllocReq(GrNum##name,sizeof(nx##name##Req), n))

/* return pointer to variable length data*/
#define GetReqData(req)		((void *)((char *)req + sizeof(* (req))))

/* FIXME fails when sizeof(int) == 2*/
/* get request total valid data length, including header*/
#define GetReqLen(req)		(((req)->hilength << 16) | (req)->length)

/* get request variable data length, not including fixed size structure*/
#define GetReqVarLen(req)	(GetReqLen(req) - sizeof(* (req)))

/* get request total aligned length*/
#define GetReqAlignedLen(req)	((GetReqLen(req) + (ALIGNSZ-1)) & ~(ALIGNSZ-1))

void * 	nxAllocReq(int type, long size, long extra);
void	nxFlushReq(long newsize, int reply_needed);
void 	nxAssignReqbuffer(char *buffer, long size);
void 	nxWriteSocket(char *buf, int todo);
int	nxCalcStringBytes(void *str, int count, int flags);

#if notyet
/* all replies share this header*/
typedef struct {
	BYTE8	repType;	/* reply code*/
	BYTE8	hilength;	/* upper 24 bits of unaligned length*/
	UINT16	length;		/* lower 16 bits of unaligned length*/
} nxReply;

/* reply types if not equal to request type*/
#define GrNumErrorReply		255
#define GrNumEventReply		254
#endif /* notyet*/

#define GrNumOpen               0
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	UINT32	pid;
} nxOpenReq;

#define GrNumClose              1
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
} nxCloseReq;

#define GrNumGetScreenInfo      2
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
} nxGetScreenInfoReq;

#define GrNumNewWindow          3
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	parentid;
	INT16	x;
	INT16	y;
	INT16	width;
	INT16	height;
	UINT32	backgroundcolor;
	UINT32	bordercolor;
	INT16	bordersize;
} nxNewWindowReq;

#define GrNumNewInputWindow     4
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	parentid;
	INT16	x;
	INT16	y;
	INT16	width;
	INT16	height;
} nxNewInputWindowReq;

#define GrNumDestroyWindow      5
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
} nxDestroyWindowReq;

#define GrNumNewGC              6
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
} nxNewGCReq;

#define GrNumCopyGC		7
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
} nxCopyGCReq;

#define GrNumGetGCInfo          8
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
} nxGetGCInfoReq;

#define GrNumDestroyGC          9
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
} nxDestroyGCReq;

#define GrNumMapWindow          10
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
} nxMapWindowReq;

#define GrNumUnmapWindow        11
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
} nxUnmapWindowReq;

#define GrNumRaiseWindow        12
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
} nxRaiseWindowReq;

#define GrNumLowerWindow        13
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
} nxLowerWindowReq;

#define GrNumMoveWindow         14
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
	INT16	x;
	INT16	y;
} nxMoveWindowReq;

#define GrNumResizeWindow       15
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
	INT16	width;
	INT16	height;
} nxResizeWindowReq;

#define GrNumGetWindowInfo      16
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
} nxGetWindowInfoReq;

#define GrNumGetFontInfo        17
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	fontid;
} nxGetFontInfoReq;

#define GrNumSetFocus           18
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
} nxSetFocusReq;

#define GrNumSetWindowCursor    19
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
	IDTYPE	cursorid;
} nxSetWindowCursorReq;

#define GrNumClearArea          20
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
	UINT16	x;
	UINT16	y;
	UINT16	width;
	UINT16	height;
	UINT16	exposeflag;
} nxClearAreaReq;

#define GrNumSelectEvents       21
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
	UINT32	eventmask;
} nxSelectEventsReq;

#define GrNumGetNextEvent       22
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
} nxGetNextEventReq;

#define GrNumCheckNextEvent     23
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
} nxCheckNextEventReq;

#define GrNumPeekEvent          24
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
} nxPeekEventReq;

#define GrNumLine               25
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x1;
	INT16	y1;
	INT16	x2;
	INT16	y2;
} nxLineReq;

#define GrNumPoint              26
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
} nxPointReq;

#define GrNumRect               27
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
	INT16	width;
	INT16	height;
} nxRectReq;

#define GrNumFillRect           28
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
	INT16	width;
	INT16	height;
} nxFillRectReq;

#define GrNumPoly               29
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	/*INT16 pointtable[];*/
} nxPolyReq;

#define GrNumFillPoly           30
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	/*INT16 pointtable[];*/
} nxFillPolyReq;

#define GrNumEllipse            31
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
	INT16	rx;
	INT16	ry;
} nxEllipseReq;

#define GrNumFillEllipse        32
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
	INT16	rx;
	INT16	ry;
} nxFillEllipseReq;

#define GrNumSetGCForeground    33
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
	UINT32	color;
} nxSetGCForegroundReq;

#define GrNumSetGCBackground    34
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
	UINT32	color;
} nxSetGCBackgroundReq;

#define GrNumSetGCUseBackground 35
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
	UINT16	flag;
} nxSetGCUseBackgroundReq;

#define GrNumSetGCMode          36
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
	UINT16	mode;
} nxSetGCModeReq;

#define GrNumSetGCFont          37
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
	IDTYPE	fontid;
} nxSetGCFontReq;

#define GrNumGetGCTextSize      38
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	gcid;
	UINT16	flags;
	UINT16	pad;
	/*BYTE8	text[];*/
} nxGetGCTextSizeReq;

#define GrNumReadArea           39
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	INT16	x;
	INT16	y;
	INT16	width;
	INT16	height;
} nxReadAreaReq;

#define GrNumArea               40
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
	INT16	width;
	INT16	height;
	INT16	pixtype;
	INT16	pad;
	/*UINT32 pixels[];*/
} nxAreaReq;

#define GrNumBitmap             41
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
	INT16	width;
	INT16	height;
	/*UINT16 bitmaptable[];*/
} nxBitmapReq;

#define GrNumText               42
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
	INT16	count;
	INT16	flags;
	/*BYTE8	text[];*/
} nxTextReq;

#define GrNumNewCursor          43
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	INT16	width;
	INT16	height;
	INT16	hotx;
	INT16	hoty;
	UINT32	fgcolor;
	UINT32	bgcolor;
	/*UINT16 fgbitmap[];*/
	/*UINT16 bgbitmap[];*/
} nxNewCursorReq;

#define GrNumMoveCursor         44
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	INT16	x;
	INT16	y;
} nxMoveCursorReq;

#define GrNumGetSystemPalette      45
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
} nxGetSystemPaletteReq;

#define GrNumFindColor             46
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	UINT32	color;
} nxFindColorReq;

#define GrNumReparentWindow        47
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	windowid;
	IDTYPE	parentid;
	INT16	x;
	INT16	y;
} nxReparentWindowReq;

#define GrNumDrawImageFromFile     48
typedef struct {
	BYTE8	reqType;
	BYTE8	hilength;
	UINT16	length;
	IDTYPE	drawid;
	IDTYPE	gcid;
	INT16	x;
	INT16	y;
	INT16	width;
	INT16	height;
	IDTYPE	flags;
	/*char path[];*/
} nxDrawImageFromFileReq;

#define GrNumLoadImageFromFile     49
typedef struct {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -