2 Unix SMB/CIFS implementation.
3 run the "simple" example (D)COM program
5 Copyright (C) Jelmer Vernooij 2004
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "lib/com/com.h"
24 #include "librpc/gen_ndr/com_dcom.h"
25 #include "lib/cmdline/popt_common.h"
27 #define DEFAULT_TRANS 4096
29 static BOOL
test_readwrite(TALLOC_CTX
*mem_ctx
, const char *host
)
35 struct IUnknown
*interfaces
[3];
37 struct com_context
*ctx
;
42 dcom_client_init(ctx
, cmdline_credentials
);
44 GUID_from_string(COM_ISTREAM_UUID
, &IID
[0]);
45 GUID_from_string(COM_IUNKNOWN_UUID
, &IID
[1]);
46 GUID_from_string(CLSID_SIMPLE
, &clsid
);
49 error
= dcom_create_object(ctx
, &clsid
,
54 error
= com_create_object(ctx
, &clsid
, 2, IID
, interfaces
, results
);
57 if (!W_ERROR_IS_OK(error
)) {
58 printf("(d)com_create_object failed - %s\n", win_errstr(error
));
62 error
= IStream_Read((struct IStream
*)interfaces
[0], mem_ctx
, NULL
, 20, 20, 30);
63 if (!W_ERROR_IS_OK(error
)) {
64 printf("IStream::Read() failed - %s\n", win_errstr(error
));
68 for (i
= 0; i
< 5; i
++) {
72 error
= IStream_Write((struct IStream
*)interfaces
[0], mem_ctx
, &test_data
, 5, NULL
);
73 if (!W_ERROR_IS_OK(error
)) {
74 printf("IStream::Write() failed - %s\n", win_errstr(error
));
78 IUnknown_Release((struct IUnknown
*)interfaces
[1], mem_ctx
);
83 BOOL
torture_com_simple(void)
86 TALLOC_CTX
*mem_ctx
= talloc_init("torture_dcom_simple");
87 const char *host
= lp_parm_string(-1, "dcom", "host");
89 ret
&= test_readwrite(mem_ctx
, host
);