1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "packer.h"
|
---|
8 | #include "cr_opcodes.h"
|
---|
9 | #include "cr_mem.h"
|
---|
10 | #include "cr_string.h"
|
---|
11 |
|
---|
12 |
|
---|
13 | /* XXX duplicated in unpack_context.c */
|
---|
14 | #define DISPLAY_NAME_LEN 256
|
---|
15 |
|
---|
16 | #define WRITE_BYTES( offset, data, len ) \
|
---|
17 | crMemcpy( data_ptr + (offset), data, len )
|
---|
18 |
|
---|
19 | void PACK_APIENTRY
|
---|
20 | crPackCreateContext( const char *dpyName, GLint visual, GLint shareCtx,
|
---|
21 | GLint *return_value, int *writeback )
|
---|
22 | {
|
---|
23 | char displayName[DISPLAY_NAME_LEN];
|
---|
24 | GET_PACKER_CONTEXT(pc);
|
---|
25 | unsigned char *data_ptr;
|
---|
26 | int len = DISPLAY_NAME_LEN + 32;
|
---|
27 |
|
---|
28 | /* clear the buffer, to silence valgrind */
|
---|
29 | crMemZero(displayName, DISPLAY_NAME_LEN);
|
---|
30 |
|
---|
31 | if (dpyName) {
|
---|
32 | crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
|
---|
33 | displayName[DISPLAY_NAME_LEN - 1] = 0;
|
---|
34 | }
|
---|
35 | else {
|
---|
36 | displayName[0] = 0;
|
---|
37 | }
|
---|
38 |
|
---|
39 | GET_BUFFERED_POINTER(pc, len);
|
---|
40 | WRITE_DATA( 0, GLint, len );
|
---|
41 | WRITE_DATA( 4, GLenum, CR_CREATECONTEXT_EXTEND_OPCODE );
|
---|
42 | WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
|
---|
43 | WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, visual );
|
---|
44 | WRITE_DATA( DISPLAY_NAME_LEN + 12, GLint, shareCtx );
|
---|
45 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 16, (void *) return_value );
|
---|
46 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 24, (void *) writeback );
|
---|
47 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
48 | }
|
---|
49 |
|
---|
50 | void PACK_APIENTRY
|
---|
51 | crPackCreateContextSWAP( const char *dpyName, GLint visual, GLint shareCtx,
|
---|
52 | GLint *return_value, int *writeback )
|
---|
53 | {
|
---|
54 | char displayName[DISPLAY_NAME_LEN];
|
---|
55 | GET_PACKER_CONTEXT(pc);
|
---|
56 | unsigned char *data_ptr;
|
---|
57 | int len = DISPLAY_NAME_LEN + 32;
|
---|
58 |
|
---|
59 | /* clear the buffer, to silence valgrind */
|
---|
60 | crMemZero(displayName, DISPLAY_NAME_LEN);
|
---|
61 |
|
---|
62 | if (dpyName) {
|
---|
63 | crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
|
---|
64 | displayName[DISPLAY_NAME_LEN - 1] = 0;
|
---|
65 | }
|
---|
66 | else {
|
---|
67 | displayName[0] = 0;
|
---|
68 | }
|
---|
69 |
|
---|
70 | GET_BUFFERED_POINTER(pc, len);
|
---|
71 | WRITE_DATA( 0, GLint, SWAP32(len) );
|
---|
72 | WRITE_DATA( 4, GLenum, SWAP32(CR_CREATECONTEXT_EXTEND_OPCODE) );
|
---|
73 | WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
|
---|
74 | WRITE_DATA( DISPLAY_NAME_LEN + 8, GLenum, SWAP32(visual) );
|
---|
75 | WRITE_DATA( DISPLAY_NAME_LEN + 12, GLenum, SWAP32(shareCtx) );
|
---|
76 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 16, (void *) return_value );
|
---|
77 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 24, (void *) writeback );
|
---|
78 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
79 | }
|
---|
80 |
|
---|
81 |
|
---|
82 | void PACK_APIENTRY crPackWindowCreate( const char *dpyName, GLint visBits, GLint *return_value, int *writeback )
|
---|
83 | {
|
---|
84 | char displayName[DISPLAY_NAME_LEN];
|
---|
85 | GET_PACKER_CONTEXT(pc);
|
---|
86 | unsigned char *data_ptr;
|
---|
87 |
|
---|
88 | /* clear the buffer, to silence valgrind */
|
---|
89 | crMemZero(displayName, DISPLAY_NAME_LEN);
|
---|
90 |
|
---|
91 | if (dpyName) {
|
---|
92 | crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
|
---|
93 | displayName[DISPLAY_NAME_LEN - 1] = 0;
|
---|
94 | }
|
---|
95 | else {
|
---|
96 | displayName[0] = 0;
|
---|
97 | }
|
---|
98 |
|
---|
99 | GET_BUFFERED_POINTER(pc, DISPLAY_NAME_LEN + 28 );
|
---|
100 | WRITE_DATA( 0, GLint, 28 );
|
---|
101 | WRITE_DATA( 4, GLenum, CR_WINDOWCREATE_EXTEND_OPCODE );
|
---|
102 | WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
|
---|
103 | WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, visBits );
|
---|
104 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 12, (void *) return_value );
|
---|
105 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 20, (void *) writeback );
|
---|
106 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
107 | }
|
---|
108 |
|
---|
109 | void PACK_APIENTRY crPackWindowCreateSWAP( const char *dpyName, GLint visBits, GLint *return_value, int *writeback )
|
---|
110 | {
|
---|
111 | char displayName[DISPLAY_NAME_LEN];
|
---|
112 | GET_PACKER_CONTEXT(pc);
|
---|
113 | unsigned char *data_ptr;
|
---|
114 |
|
---|
115 | /* clear the buffer, to silence valgrind */
|
---|
116 | crMemZero(displayName, DISPLAY_NAME_LEN);
|
---|
117 |
|
---|
118 | if (dpyName) {
|
---|
119 | crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
|
---|
120 | displayName[DISPLAY_NAME_LEN - 1] = 0;
|
---|
121 | }
|
---|
122 | else {
|
---|
123 | displayName[0] = 0;
|
---|
124 | }
|
---|
125 |
|
---|
126 | GET_BUFFERED_POINTER(pc, DISPLAY_NAME_LEN + 28 );
|
---|
127 | WRITE_DATA( 0, GLint, SWAP32(28) );
|
---|
128 | WRITE_DATA( 4, GLenum, SWAP32(CR_WINDOWCREATE_EXTEND_OPCODE) );
|
---|
129 | WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
|
---|
130 | WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, SWAP32(visBits) );
|
---|
131 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 12, (void *) return_value );
|
---|
132 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 20, (void *) writeback );
|
---|
133 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
134 | }
|
---|