* For testing it might be needed to allow downgrades
* to NDR32. This is needed when you use 'pipe'.
*/
-//cpp_quote("#define DONOT_FORCE_NDR64 1")
+cpp_quote("#define DONOT_FORCE_NDR64 1")
[
uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
]
interface midltests
{
+ typedef pipe char pipe_char;
+ typedef pipe hyper pipe_hyper;
+ typedef struct {
+ long l;
+ short s;
+ } structtype;
+ typedef pipe structtype pipe_structtype;
+
+ struct msg {
+ long l;
+ [size_is(l)] char *m;
+ };
+
+ /*
+ * async pipes need to be passed by reference
+ */
long midltests_fn(
+ [out,ref] struct msg *out1,
+ [out,ref] pipe_structtype *outp,
+ [in,ref] pipe_structtype *inp,
+ [in] struct msg in1
);
+
+ long midltests_ping( [in] struct msg in1);
+
}
#elif MIDLTESTS_C_CODE
+struct pipe_char_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_char_pull(
+ char * _state,
+ unsigned char * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_char_push(
+ char * _state,
+ unsigned char * buf,
+ unsigned long ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_char_alloc(
+ char * _state,
+ unsigned long bsize,
+ unsigned char * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+
+struct pipe_hyper_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_hyper_pull(
+ char * _state,
+ hyper * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_hyper_push(
+ char * _state,
+ hyper * buf,
+ unsigned long ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_hyper_alloc(
+ char * _state,
+ unsigned long bsize,
+ hyper * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+struct pipe_structtype_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+RPC_STATUS pipe_structtype_pull(
+ char * _state,
+ structtype * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+RPC_STATUS pipe_structtype_push(
+ char * _state,
+ structtype * buf,
+ unsigned long ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+RPC_STATUS pipe_structtype_alloc(
+ char * _state,
+ unsigned long bsize,
+ structtype * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
static void midltests(void)
{
- cli_midltests_fn();
+ RPC_ASYNC_STATE aping;
+ RPC_ASYNC_STATE afn;
+ long ret;
+ struct msg out1;
+ unsigned char out1b[3];
+ struct pipe_structtype_state outs;
+ ASYNC_pipe_structtype outp;
+ struct pipe_structtype_state ins;
+ ASYNC_pipe_structtype inp;
+ struct msg in1;
+ unsigned char in1b[3000];
+
+ in1.l = sizeof(in1b);
+ memset(&in1b, 0xAA, sizeof(in1b));
+ in1.m = in1b;
+
+ memset(&outs, 0, sizeof(outs));
+ outs.name = "outp";
+ memset(&outp, 0, sizeof(outp));
+ outp.pull = pipe_structtype_pull;
+ outp.push = pipe_structtype_push;
+ outp.alloc = pipe_structtype_alloc;
+ outp.state = (char *)&outs;
+
+ memset(&ins, 0, sizeof(ins));
+ ins.name = "inp";
+ ins.count = 35;
+ memset(&inp, 0, sizeof(inp));
+ inp.pull = pipe_structtype_pull;
+ inp.push = pipe_structtype_push;
+ inp.alloc = pipe_structtype_alloc;
+ inp.state = (char *)&ins;
+
+ out1.l = sizeof(out1b);
+ memset(&out1b, 0xFF, sizeof(out1b));
+ out1.m = out1b;
+
+ RpcAsyncInitializeHandle(&aping, sizeof(aping));
+ cli_midltests_ping(&aping, in1);
+ while (TRUE) {
+ RPC_STATUS status;
+ status = RpcAsyncCompleteCall(&aping, &ret);
+ if (status != RPC_S_ASYNC_CALL_PENDING) {
+ break;
+ }
+ Sleep(100);
+ }
+ RpcAsyncInitializeHandle(&afn, sizeof(afn));
+ cli_midltests_fn(&afn, &out1, &outp, &inp, in1);
+ while (TRUE) {
+ RPC_STATUS status;
+ status = RpcAsyncCompleteCall(&aping, &ret);
+ if (status != RPC_S_ASYNC_CALL_PENDING) {
+ break;
+ }
+ Sleep(100);
+ }
}
-long srv_midltests_fn(void)
+void srv_midltests_fn(
+ PRPC_ASYNC_STATE midltests_fn_AsyncHandle,
+ /* [ref][out] */ struct msg *out1,
+ /* [out] */ ASYNC_pipe_structtype *outp,
+ /* [in] */ ASYNC_pipe_structtype *inp,
+ /* [in] */ struct msg in1)
{
+ long ret;
+ structtype inb[2500];
+ unsigned long inb_len = 0;
+ structtype *outb = NULL;
+ unsigned long outb_size = 0;
+ unsigned long outb_len = 0;
+
printf("srv_midltests_fn: Start\n");
+ fflush(stdout);
+
+ do {
+ inp->pull(inp->state, inb, sizeof(inb), &inb_len);
+ printf("pull inp_len[%u]\n", inb_len);
+ fflush(stdout);
+ } while (inb_len > 0);
+
+ outb_size = 50;
+ do {
+ outp->alloc(outp->state, outb_size, &outb, &outb_len);
+ memset(outb, 0xCC, outb_len * sizeof(*outb));
+ printf("push outb_len[%u]\n", outb_len);
+ fflush(stdout);
+ outp->push(outp->state, outb, outb_len);
+ //Sleep(1000);
+ outb_size--;
+ } while (outb_len > 0);
+
+ out1->l = 3;
+ out1->m = (unsigned char *)malloc(out1->l);
+ memset(out1->m, 0xBB, out1->l);
printf("srv_midltests_fn: End\n");
- return 0x65757254;
+ fflush(stdout);
+ ret = 0x65757254;
+ RpcAsyncCompleteCall(midltests_fn_AsyncHandle, &ret);
}
+void srv_midltests_ping(
+ PRPC_ASYNC_STATE midltests_ping_AsyncHandle,
+ /* [in] */ struct msg in1)
+{
+ long ret;
+ printf("srv_midltests_ping: Start\n");
+ printf("srv_midltests_ping: End\n");
+ ret = 0x65757254;
+ RpcAsyncCompleteCall(midltests_ping_AsyncHandle, &ret);
+}
#endif