From fbe39dfcc2387a913e094ebed61c7f53fe59ee38 Mon Sep 17 00:00:00 2001 From: sheldonh Date: Mon, 22 Apr 2002 16:15:20 +0000 Subject: Import smbfs-1.4.4. --- contrib/smbfs/smbutil/view.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'contrib/smbfs/smbutil/view.c') diff --git a/contrib/smbfs/smbutil/view.c b/contrib/smbfs/smbutil/view.c index e3e600f..42450df 100644 --- a/contrib/smbfs/smbutil/view.c +++ b/contrib/smbfs/smbutil/view.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Boris Popov + * Copyright (c) 2000-2002, Boris Popov * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: view.c,v 1.8 2001/08/22 03:33:38 bp Exp $ + * $Id: view.c,v 1.9 2002/02/20 09:26:42 bp Exp $ */ #include #include @@ -44,6 +44,8 @@ #include +#include + #include #include #include @@ -53,8 +55,8 @@ static char *shtype[] = { "disk", "printer", - "pipe", - "comm", + "comm", /* Communications device */ + "pipe", /* IPC Inter process communication */ "unknown" }; @@ -64,7 +66,9 @@ cmd_view(int argc, char *argv[]) struct smb_ctx sctx, *ctx = &sctx; struct smb_share_info_1 *rpbuf, *ep; char *cp; + u_int16_t type; int error, opt, bufsize, i, entries, total; + if (argc < 2) view_usage(); @@ -100,7 +104,7 @@ cmd_view(int argc, char *argv[]) } printf("Share Type Comment\n"); printf("-------------------------------\n"); - bufsize = 65535; + bufsize = 0xffe0; /* samba notes win2k bug with 65535 */ rpbuf = malloc(bufsize); error = smb_rap_NetShareEnum(ctx, 1, rpbuf, bufsize, &entries, &total); if (error && @@ -109,9 +113,11 @@ cmd_view(int argc, char *argv[]) exit(1); } for (ep = rpbuf, i = 0; i < entries; i++, ep++) { + type = letohs(ep->shi1_type); + cp = (char*)rpbuf + ep->shi1_remark; printf("%-12s %-10s %s\n", ep->shi1_netname, - shtype[ep->shi1_type], + shtype[min(type, sizeof shtype / sizeof(char *) - 1)], ep->shi1_remark ? nls_str_toloc(cp, cp) : ""); } printf("\n%d shares listed from %d available\n", entries, total); -- cgit v1.1