Deleted Added
full compact
view.c (161207) view.c (202980)
1/*
2 * Copyright (c) 2000-2002, Boris Popov
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $Id: view.c,v 1.9 2002/02/20 09:26:42 bp Exp $
33 */
34
35#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2000-2002, Boris Popov
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $Id: view.c,v 1.9 2002/02/20 09:26:42 bp Exp $
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/contrib/smbfs/smbutil/view.c 161207 2006-08-11 12:35:22Z keramida $");
36__FBSDID("$FreeBSD: head/contrib/smbfs/smbutil/view.c 202980 2010-01-25 18:35:58Z yongari $");
37
38#include <sys/endian.h>
39#include <sys/param.h>
40#include <sys/errno.h>
41#include <sys/stat.h>
42#include <sys/iconv.h>
43#include <err.h>
44#include <stdio.h>

--- 19 unchanged lines hidden (view full) ---

64};
65
66int
67cmd_view(int argc, char *argv[])
68{
69 struct smb_ctx sctx, *ctx = &sctx;
70 struct smb_share_info_1 *rpbuf, *ep;
71 char *cp;
37
38#include <sys/endian.h>
39#include <sys/param.h>
40#include <sys/errno.h>
41#include <sys/stat.h>
42#include <sys/iconv.h>
43#include <err.h>
44#include <stdio.h>

--- 19 unchanged lines hidden (view full) ---

64};
65
66int
67cmd_view(int argc, char *argv[])
68{
69 struct smb_ctx sctx, *ctx = &sctx;
70 struct smb_share_info_1 *rpbuf, *ep;
71 char *cp;
72 u_int32_t remark;
72 u_int16_t type;
73 int error, opt, bufsize, i, entries, total;
74
75
76 if (argc < 2)
77 view_usage();
78 if (smb_ctx_init(ctx, argc, argv, SMBL_VC, SMBL_VC, SMB_ST_ANY) != 0)
79 exit(1);

--- 32 unchanged lines hidden (view full) ---

112 error = smb_rap_NetShareEnum(ctx, 1, rpbuf, bufsize, &entries, &total);
113 if (error &&
114 error != (SMB_ERROR_MORE_DATA | SMB_RAP_ERROR)) {
115 smb_error("unable to list resources", error);
116 exit(1);
117 }
118 for (ep = rpbuf, i = 0; i < entries; i++, ep++) {
119 type = le16toh(ep->shi1_type);
73 u_int16_t type;
74 int error, opt, bufsize, i, entries, total;
75
76
77 if (argc < 2)
78 view_usage();
79 if (smb_ctx_init(ctx, argc, argv, SMBL_VC, SMBL_VC, SMB_ST_ANY) != 0)
80 exit(1);

--- 32 unchanged lines hidden (view full) ---

113 error = smb_rap_NetShareEnum(ctx, 1, rpbuf, bufsize, &entries, &total);
114 if (error &&
115 error != (SMB_ERROR_MORE_DATA | SMB_RAP_ERROR)) {
116 smb_error("unable to list resources", error);
117 exit(1);
118 }
119 for (ep = rpbuf, i = 0; i < entries; i++, ep++) {
120 type = le16toh(ep->shi1_type);
121 remark = le32toh(ep->shi1_remark);
122 remark &= 0xFFFF;
120
123
121 cp = (char*)rpbuf + ep->shi1_remark;
124 cp = (char*)rpbuf + remark;
122 printf("%-12s %-10s %s\n", ep->shi1_netname,
123 shtype[min(type, sizeof shtype / sizeof(char *) - 1)],
125 printf("%-12s %-10s %s\n", ep->shi1_netname,
126 shtype[min(type, sizeof shtype / sizeof(char *) - 1)],
124 ep->shi1_remark ? nls_str_toloc(cp, cp) : "");
127 remark ? nls_str_toloc(cp, cp) : "");
125 }
126 printf("\n%d shares listed from %d available\n", entries, total);
127 free(rpbuf);
128 return 0;
129}
130
131
132void
133view_usage(void)
134{
135 printf(
136 "usage: smbutil view [connection options] //[user@]server\n"
137 );
138 exit(1);
139}
140
128 }
129 printf("\n%d shares listed from %d available\n", entries, total);
130 free(rpbuf);
131 return 0;
132}
133
134
135void
136view_usage(void)
137{
138 printf(
139 "usage: smbutil view [connection options] //[user@]server\n"
140 );
141 exit(1);
142}
143