1 #ifndef MIDLTESTS_C_CODE
4 uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
5 pointer_default(unique)
9 typedef pipe char pipe_char;
17 [out,ref] struct msg *out1,
24 #elif MIDLTESTS_C_CODE
26 struct pipe_char_state {
\r
28 unsigned long count;
\r
29 unsigned long sleep;
\r
32 void pipe_char_pull(
\r
34 unsigned char * buf,
\r
35 unsigned long esize,
\r
36 unsigned long * ecount)
\r
38 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
40 printf("pull1:%s: esize[%u] ecount[%u]\n",
\r
41 state->name, esize, *ecount);
\r
42 *ecount = state->count--;
\r
43 if (*ecount > esize) {
\r
46 memset(buf, 0xDD, *ecount);
\r
47 printf("pull2:%s: esize[%u] ecount[%u]\n",
\r
48 state->name, esize, *ecount);
\r
51 void pipe_char_push(
\r
53 unsigned char * buf,
\r
54 unsigned long ecount)
\r
56 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
58 printf("push:%s: ecount[%u]\n",
\r
59 state->name, ecount);
\r
62 void pipe_char_alloc(
\r
64 unsigned long bsize,
\r
65 unsigned char * * buf,
\r
66 unsigned long * bcount)
\r
68 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
70 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
\r
71 state->name, bsize, *bcount);
\r
72 *bcount = bsize / sizeof(**buf);
\r
73 *buf = malloc(*bcount * sizeof(**buf));
\r
74 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
\r
75 state->name, bsize, *bcount);
\r
78 static void midltests(void)
81 unsigned char out1b[3];
82 struct pipe_char_state outs;
84 struct pipe_char_state ins;
87 unsigned char in1b[3];
90 memset(&in1b, 0xAA, sizeof(in1b));
93 memset(&outs, 0, sizeof(outs));
95 memset(&outp, 0, sizeof(outp));
96 outp.pull = pipe_char_pull;
97 outp.push = pipe_char_push;
98 outp.alloc = pipe_char_alloc;
99 outp.state = (char *)&outs;
101 memset(&ins, 0, sizeof(ins));
104 memset(&inp, 0, sizeof(inp));
105 inp.pull = pipe_char_pull;
106 inp.push = pipe_char_push;
107 inp.alloc = pipe_char_alloc;
108 inp.state = (char *)&ins;
110 out1.l = sizeof(out1b);
111 memset(&out1b, 0xFF, sizeof(out1b));
114 cli_midltests_fn(&out1, outp, inp, in1);
117 long srv_midltests_fn(
118 /* [ref][out] */ struct msg *out1,
\r
119 /* [out] */ pipe_char outp,
\r
120 /* [in] */ pipe_char inp,
\r
121 /* [in] */ struct msg in1)
124 unsigned long inb_len = 0;
126 unsigned long outb_size = 0;
127 unsigned long outb_len = 0;
129 printf("srv_midltests_fn: Start\n");
132 inp.pull(inp.state, inb, sizeof(inb), &inb_len);
133 printf("pull inp_len[%u]\n", inb_len);
134 } while (inb_len > 0);
138 outp.alloc(outp.state, outb_size, &outb, &outb_len);
139 memset(outb, 0xCC, outb_len);
140 outp.push(outp.state, outb, outb_len);
141 printf("push outb_len[%u]\n", outb_len);
144 } while (outb_len > 0);
147 out1->m = (unsigned char *)malloc(out1->l);
148 memset(out1->m, 0xBB, out1->l);
149 printf("srv_midltests_fn: End\n");