Changeset 51 for trunk/samba/source/ndpsmb/smbwrp.c
- Timestamp:
- Aug 6, 2007, 1:05:05 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/samba/source/ndpsmb/smbwrp.c
r49 r51 2 2 3 3 #include "smbwrp.h" 4 5 //PS 6 static int 7 net_share_enum_rpc(struct cli_state *cli, 8 void (*fn)(const char *name, 9 uint32 type, 10 const char *comment, 11 void *state), 12 void *state) 13 { 14 int i; 15 WERROR result; 16 ENUM_HND enum_hnd; 17 uint32 info_level = 1; 18 uint32 preferred_len = 0xffffffff; 19 uint32 type; 20 SRV_SHARE_INFO_CTR ctr; 21 fstring name = ""; 22 fstring comment = ""; 23 void *mem_ctx; 24 struct rpc_pipe_client *pipe_hnd; 25 NTSTATUS nt_status; 26 27 /* Open the server service pipe */ 28 pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &nt_status); 29 if (!pipe_hnd) { 30 DEBUG(1, ("net_share_enum_rpc pipe open fail!\n")); 31 return -1; 32 } 33 34 /* Allocate a context for parsing and for the entries in "ctr" */ 35 mem_ctx = talloc_init("libsmbclient: net_share_enum_rpc"); 36 if (mem_ctx == NULL) { 37 DEBUG(0, ("out of memory for net_share_enum_rpc!\n")); 38 cli_rpc_pipe_close(pipe_hnd); 39 return -1; 40 } 41 42 /* Issue the NetShareEnum RPC call and retrieve the response */ 43 init_enum_hnd(&enum_hnd, 0); 44 result = rpccli_srvsvc_net_share_enum(pipe_hnd, 45 mem_ctx, 46 info_level, 47 &ctr, 48 preferred_len, 49 &enum_hnd); 50 51 /* Was it successful? */ 52 if (!W_ERROR_IS_OK(result) || ctr.num_entries == 0) { 53 /* Nope. Go clean up. */ 54 goto done; 55 } 56 57 /* For each returned entry... */ 58 for (i = 0; i < ctr.num_entries; i++) { 59 60 /* pull out the share name */ 61 rpcstr_pull_unistr2_fstring( 62 name, &ctr.share.info1[i].info_1_str.uni_netname); 63 64 /* pull out the share's comment */ 65 rpcstr_pull_unistr2_fstring( 66 comment, &ctr.share.info1[i].info_1_str.uni_remark); 67 68 /* Get the type value */ 69 type = ctr.share.info1[i].info_1.type; 70 71 /* Add this share to the list */ 72 (*fn)(name, type, comment, state); 73 } 74 75 done: 76 /* Close the server service pipe */ 77 cli_rpc_pipe_close(pipe_hnd); 78 79 /* Free all memory which was allocated for this request */ 80 TALLOC_FREE(mem_ctx); 81 82 /* Tell 'em if it worked */ 83 return W_ERROR_IS_OK(result) ? 0 : -1; 84 } 85 //PS 4 86 5 87 /* … … 1306 1388 smbwrp_special_add(".", state); 1307 1389 smbwrp_special_add("..", state); 1308 if (cli_RNetShareEnum(cli, smbwrp_share_add, state) < 0) 1390 // if (cli_RNetShareEnum(cli, smbwrp_share_add, state) < 0) 1391 if (net_share_enum_rpc(cli, smbwrp_share_add, state) < 0 && 1392 cli_RNetShareEnum(cli,smbwrp_share_add, state) < 0) 1309 1393 { 1310 1394 return os2cli_errno(cli);
Note:
See TracChangeset
for help on using the changeset viewer.