2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Guenther Deschner 2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include <sys/types.h>
30 static NET_API_STATUS
test_netfileenum(const char *hostname
,
33 NET_API_STATUS status
;
34 uint32_t entries_read
= 0;
35 uint32_t total_entries
= 0;
36 uint32_t resume_handle
= 0;
37 uint8_t *buffer
= NULL
;
40 struct FILE_INFO_2
*i2
= NULL
;
41 struct FILE_INFO_3
*i3
= NULL
;
43 printf("testing NetFileEnum level %d\n", level
);
46 status
= NetFileEnum(hostname
,
55 if (status
== 0 || status
== ERROR_MORE_DATA
) {
58 i2
= (struct FILE_INFO_2
*)buffer
;
61 i3
= (struct FILE_INFO_3
*)buffer
;
67 for (i
=0; i
<entries_read
; i
++) {
86 NetApiBufferFree(buffer
);
88 } while (status
== ERROR_MORE_DATA
);
97 NET_API_STATUS
netapitest_file(struct libnetapi_ctx
*ctx
,
100 NET_API_STATUS status
= 0;
101 uint32_t enum_levels
[] = { 2, 3 };
104 printf("NetFile tests\n");
108 for (i
=0; i
<ARRAY_SIZE(enum_levels
); i
++) {
110 status
= test_netfileenum(hostname
, enum_levels
[i
]);
112 NETAPI_STATUS(ctx
, status
, "NetFileEnum");
120 uint32_t levels
[] = { 2, 3 };
121 for (i
=0; i
<ARRAY_SIZE(levels
); i
++) {
122 uint8_t *buffer
= NULL
;
124 printf("testing NetFileGetInfo level %d\n", levels
[i
]);
126 status
= NetFileGetInfo(hostname
, fid
, levels
[i
], &buffer
);
127 if (status
&& status
!= 124) {
128 NETAPI_STATUS(ctx
, status
, "NetFileGetInfo");
137 printf("NetFile tests succeeded\n");
140 printf("NetFile testsuite failed with: %s\n",
141 libnetapi_get_error_string(ctx
, status
));