source: trunk/server/testprogs/win32/midltests/todo/midltests-pipe-04-struct.idl

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 6.5 KB
Line 
1#ifndef MIDLTESTS_C_CODE
2
3[
4 uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
5 pointer_default(unique)
6]
7interface midltests
8{
9 typedef pipe char pipe_char;
10 typedef pipe hyper pipe_hyper;
11 typedef struct {
12 long l;
13 short s;
14 } structtype;
15 typedef pipe structtype pipe_structtype;
16
17 struct msg {
18 long l;
19 [size_is(l)] char *m;
20 };
21
22 long midltests_fn(
23 [out,ref] struct msg *out1,
24 [out] pipe_structtype outp,
25 [in] pipe_structtype inp,
26 [in] struct msg in1
27 );
28
29 long midltests_ping( [in] struct msg in1);
30
31}
32
33#elif MIDLTESTS_C_CODE
34
35struct pipe_char_state {
36 const char *name;
37 unsigned long count;
38 unsigned long sleep;
39};
40
41void pipe_char_pull(
42 char * _state,
43 unsigned char * buf,
44 unsigned long esize,
45 unsigned long * ecount)
46{
47 struct pipe_char_state *state = (struct pipe_char_state *)_state;
48
49 printf("pull1:%s: esize[%u] ecount[%u]\n",
50 state->name, esize, *ecount);
51 *ecount = state->count--;
52 if (*ecount > esize) {
53 *ecount = esize;
54 }
55 memset(buf, 0xDD, *ecount * sizeof(*buf));
56 printf("pull2:%s: esize[%u] ecount[%u]\n",
57 state->name, esize, *ecount);
58}
59
60void pipe_char_push(
61 char * _state,
62 unsigned char * buf,
63 unsigned long ecount)
64{
65 struct pipe_char_state *state = (struct pipe_char_state *)_state;
66
67 printf("push:%s: ecount[%u]\n",
68 state->name, ecount);
69}
70
71void pipe_char_alloc(
72 char * _state,
73 unsigned long bsize,
74 unsigned char * * buf,
75 unsigned long * bcount)
76{
77 struct pipe_char_state *state = (struct pipe_char_state *)_state;
78
79 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
80 state->name, bsize, *bcount);
81 *bcount = bsize / sizeof(**buf);
82 *buf = malloc(*bcount * sizeof(**buf));
83 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
84 state->name, bsize, *bcount);
85}
86
87struct pipe_hyper_state {
88 const char *name;
89 unsigned long count;
90 unsigned long sleep;
91};
92
93void pipe_hyper_pull(
94 char * _state,
95 hyper * buf,
96 unsigned long esize,
97 unsigned long * ecount)
98{
99 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
100
101 printf("pull1:%s: esize[%u] ecount[%u]\n",
102 state->name, esize, *ecount);
103 *ecount = state->count--;
104 if (*ecount > esize) {
105 *ecount = esize;
106 }
107 memset(buf, 0xDD, *ecount * sizeof(*buf));
108 printf("pull2:%s: esize[%u] ecount[%u]\n",
109 state->name, esize, *ecount);
110}
111
112void pipe_hyper_push(
113 char * _state,
114 hyper * buf,
115 unsigned long ecount)
116{
117 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
118
119 printf("push:%s: ecount[%u]\n",
120 state->name, ecount);
121}
122
123void pipe_hyper_alloc(
124 char * _state,
125 unsigned long bsize,
126 hyper * * buf,
127 unsigned long * bcount)
128{
129 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
130
131 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
132 state->name, bsize, *bcount);
133 *bcount = bsize / sizeof(**buf);
134 *buf = malloc(*bcount * sizeof(**buf));
135 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
136 state->name, bsize, *bcount);
137}
138struct pipe_structtype_state {
139 const char *name;
140 unsigned long count;
141 unsigned long sleep;
142};
143
144void pipe_structtype_pull(
145 char * _state,
146 structtype * buf,
147 unsigned long esize,
148 unsigned long * ecount)
149{
150 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
151
152 printf("pull1:%s: esize[%u] ecount[%u]\n",
153 state->name, esize, *ecount);
154 *ecount = state->count--;
155 if (*ecount > esize) {
156 *ecount = esize;
157 }
158 memset(buf, 0xDD, *ecount * sizeof(*buf));
159 printf("pull2:%s: esize[%u] ecount[%u]\n",
160 state->name, esize, *ecount);
161}
162
163void pipe_structtype_push(
164 char * _state,
165 structtype * buf,
166 unsigned long ecount)
167{
168 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
169
170 printf("push:%s: ecount[%u]\n",
171 state->name, ecount);
172}
173
174void pipe_structtype_alloc(
175 char * _state,
176 unsigned long bsize,
177 structtype * * buf,
178 unsigned long * bcount)
179{
180 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
181
182 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
183 state->name, bsize, *bcount);
184 *bcount = bsize / sizeof(**buf);
185 *buf = malloc(*bcount * sizeof(**buf));
186 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
187 state->name, bsize, *bcount);
188}
189static void midltests(void)
190{
191 struct msg out1;
192 unsigned char out1b[3];
193 struct pipe_structtype_state outs;
194 pipe_structtype outp;
195 struct pipe_structtype_state ins;
196 pipe_structtype inp;
197 struct msg in1;
198 unsigned char in1b[3];
199
200 in1.l = sizeof(in1b);
201 memset(&in1b, 0xAA, sizeof(in1b));
202 in1.m = in1b;
203
204 memset(&outs, 0, sizeof(outs));
205 outs.name = "outp";
206 memset(&outp, 0, sizeof(outp));
207 outp.pull = pipe_structtype_pull;
208 outp.push = pipe_structtype_push;
209 outp.alloc = pipe_structtype_alloc;
210 outp.state = (char *)&outs;
211
212 memset(&ins, 0, sizeof(ins));
213 ins.name = "inp";
214 ins.count = 1;
215 memset(&inp, 0, sizeof(inp));
216 inp.pull = pipe_structtype_pull;
217 inp.push = pipe_structtype_push;
218 inp.alloc = pipe_structtype_alloc;
219 inp.state = (char *)&ins;
220
221 out1.l = sizeof(out1b);
222 memset(&out1b, 0xFF, sizeof(out1b));
223 out1.m = out1b;
224
225 cli_midltests_ping(in1);
226 cli_midltests_fn(&out1, outp, inp, in1);
227}
228
229long srv_midltests_fn(
230 /* [ref][out] */ struct msg *out1,
231 /* [out] */ pipe_structtype outp,
232 /* [in] */ pipe_structtype inp,
233 /* [in] */ struct msg in1)
234{
235 structtype inb[500];
236 unsigned long inb_len = 0;
237 structtype *outb = NULL;
238 unsigned long outb_size = 0;
239 unsigned long outb_len = 0;
240
241 printf("srv_midltests_fn: Start\n");
242
243 do {
244 inp.pull(inp.state, inb, sizeof(inb), &inb_len);
245 printf("pull inp_len[%u]\n", inb_len);
246 } while (inb_len > 0);
247
248 outb_size = 5;
249 do {
250 outp.alloc(outp.state, outb_size, &outb, &outb_len);
251 memset(outb, 0xCC, outb_len * sizeof(*outb));
252 outp.push(outp.state, outb, outb_len);
253 printf("push outb_len[%u]\n", outb_len);
254 //Sleep(1000);
255 outb_size--;
256 } while (outb_len > 0);
257
258 out1->l = 3;
259 out1->m = (unsigned char *)malloc(out1->l);
260 memset(out1->m, 0xBB, out1->l);
261 printf("srv_midltests_fn: End\n");
262 return 0x65757254;
263}
264
265long srv_midltests_ping(
266 /* [in] */ struct msg in1)
267{
268 printf("srv_midltests_fn: Start\n");
269 printf("srv_midltests_fn: End\n");
270 return 0x65757254;
271}
272#endif
Note: See TracBrowser for help on using the repository browser.