source: trunk/server/testprogs/win32/midltests/todo/midltests-pipe-03-hyper.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: 4.8 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
12 struct msg {
13 long l;
14 [size_is(l)] char *m;
15 };
16
17 long midltests_fn(
18 [out,ref] struct msg *out1,
19 [out] pipe_hyper outp,
20 [in] pipe_hyper inp,
21 [in] struct msg in1
22 );
23}
24
25#elif MIDLTESTS_C_CODE
26
27struct pipe_char_state {
28 const char *name;
29 unsigned long count;
30 unsigned long sleep;
31};
32
33void pipe_char_pull(
34 char * _state,
35 unsigned char * buf,
36 unsigned long esize,
37 unsigned long * ecount)
38{
39 struct pipe_char_state *state = (struct pipe_char_state *)_state;
40
41 printf("pull1:%s: esize[%u] ecount[%u]\n",
42 state->name, esize, *ecount);
43 *ecount = state->count--;
44 if (*ecount > esize) {
45 *ecount = esize;
46 }
47 memset(buf, 0xDD, *ecount * sizeof(*buf));
48 printf("pull2:%s: esize[%u] ecount[%u]\n",
49 state->name, esize, *ecount);
50}
51
52void pipe_char_push(
53 char * _state,
54 unsigned char * buf,
55 unsigned long ecount)
56{
57 struct pipe_char_state *state = (struct pipe_char_state *)_state;
58
59 printf("push:%s: ecount[%u]\n",
60 state->name, ecount);
61}
62
63void pipe_char_alloc(
64 char * _state,
65 unsigned long bsize,
66 unsigned char * * buf,
67 unsigned long * bcount)
68{
69 struct pipe_char_state *state = (struct pipe_char_state *)_state;
70
71 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
72 state->name, bsize, *bcount);
73 *bcount = bsize / sizeof(**buf);
74 *buf = malloc(*bcount * sizeof(**buf));
75 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
76 state->name, bsize, *bcount);
77}
78
79struct pipe_hyper_state {
80 const char *name;
81 unsigned long count;
82 unsigned long sleep;
83};
84
85void pipe_hyper_pull(
86 char * _state,
87 hyper * buf,
88 unsigned long esize,
89 unsigned long * ecount)
90{
91 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
92
93 printf("pull1:%s: esize[%u] ecount[%u]\n",
94 state->name, esize, *ecount);
95 *ecount = state->count--;
96 if (*ecount > esize) {
97 *ecount = esize;
98 }
99 memset(buf, 0xDD, *ecount * sizeof(*buf));
100 printf("pull2:%s: esize[%u] ecount[%u]\n",
101 state->name, esize, *ecount);
102}
103
104void pipe_hyper_push(
105 char * _state,
106 hyper * buf,
107 unsigned long ecount)
108{
109 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
110
111 printf("push:%s: ecount[%u]\n",
112 state->name, ecount);
113}
114
115void pipe_hyper_alloc(
116 char * _state,
117 unsigned long bsize,
118 hyper * * buf,
119 unsigned long * bcount)
120{
121 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
122
123 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
124 state->name, bsize, *bcount);
125 *bcount = bsize / sizeof(**buf);
126 *buf = malloc(*bcount * sizeof(**buf));
127 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
128 state->name, bsize, *bcount);
129}
130static void midltests(void)
131{
132 struct msg out1;
133 unsigned char out1b[3];
134 struct pipe_hyper_state outs;
135 pipe_hyper outp;
136 struct pipe_hyper_state ins;
137 pipe_hyper inp;
138 struct msg in1;
139 unsigned char in1b[3];
140
141 in1.l = sizeof(in1b);
142 memset(&in1b, 0xAA, sizeof(in1b));
143 in1.m = in1b;
144
145 memset(&outs, 0, sizeof(outs));
146 outs.name = "outp";
147 memset(&outp, 0, sizeof(outp));
148 outp.pull = pipe_hyper_pull;
149 outp.push = pipe_hyper_push;
150 outp.alloc = pipe_hyper_alloc;
151 outp.state = (char *)&outs;
152
153 memset(&ins, 0, sizeof(ins));
154 ins.name = "inp";
155 ins.count = 1;
156 memset(&inp, 0, sizeof(inp));
157 inp.pull = pipe_hyper_pull;
158 inp.push = pipe_hyper_push;
159 inp.alloc = pipe_hyper_alloc;
160 inp.state = (char *)&ins;
161
162 out1.l = sizeof(out1b);
163 memset(&out1b, 0xFF, sizeof(out1b));
164 out1.m = out1b;
165
166 cli_midltests_fn(&out1, outp, inp, in1);
167}
168
169long srv_midltests_fn(
170 /* [ref][out] */ struct msg *out1,
171 /* [out] */ pipe_hyper outp,
172 /* [in] */ pipe_hyper inp,
173 /* [in] */ struct msg in1)
174{
175 hyper inb[500];
176 unsigned long inb_len = 0;
177 hyper *outb = NULL;
178 unsigned long outb_size = 0;
179 unsigned long outb_len = 0;
180
181 printf("srv_midltests_fn: Start\n");
182
183 do {
184 inp.pull(inp.state, inb, sizeof(inb), &inb_len);
185 printf("pull inp_len[%u]\n", inb_len);
186 } while (inb_len > 0);
187
188 outb_size = 5;
189 do {
190 outp.alloc(outp.state, outb_size, &outb, &outb_len);
191 memset(outb, 0xCC, outb_len * sizeof(*outb));
192 outp.push(outp.state, outb, outb_len);
193 printf("push outb_len[%u]\n", outb_len);
194 //Sleep(1000);
195 outb_size--;
196 } while (outb_len > 0);
197
198 out1->l = 3;
199 out1->m = (unsigned char *)malloc(out1->l);
200 memset(out1->m, 0xBB, out1->l);
201 printf("srv_midltests_fn: End\n");
202 return 0x65757254;
203}
204
205#endif
Note: See TracBrowser for help on using the repository browser.