Tim Schwartz : net.exe: Lists existing NetUse connections.
Alexandre Julliard
julliard at winehq.org
Tue Nov 6 08:24:45 CST 2007
Module: wine
Branch: master
Commit: 26b182fd92c45635905b4c20c313b134e11b6109
URL: http://source.winehq.org/git/wine.git/?a=commit;h=26b182fd92c45635905b4c20c313b134e11b6109
Author: Tim Schwartz <tim at sanityinternet.com>
Date: Mon Nov 5 15:02:49 2007 -0600
net.exe: Lists existing NetUse connections.
---
programs/net/En.rc | 3 +++
programs/net/Makefile.in | 2 +-
programs/net/net.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
programs/net/resources.h | 3 +++
4 files changed, 52 insertions(+), 1 deletions(-)
diff --git a/programs/net/En.rc b/programs/net/En.rc
index f3d8f4f..aff6d1d 100644
--- a/programs/net/En.rc
+++ b/programs/net/En.rc
@@ -37,4 +37,7 @@ STRINGTABLE
STRING_STOP_SVC_SUCCESS, "The %s service was stopped successfully.\n"
STRING_STOP_SVC_FAIL, "The %s service failed to stop.\n"
STRING_HELP_USAGE, "The syntax of this command is:\n\nNET HELP command\n -or-\nNET command /HELP\n\n Commands available are:\n NET HELP NET START NET STOP\n"
+ STRING_NO_ENTRIES, "There are no entries in the list.\n"
+ STRING_USE_HEADER, "\nStatus Local Remote\n---------------------------------------------------------------\n"
+ STRING_USE_ENTRY, "%s %S %S Open resources: %lu\n"
}
diff --git a/programs/net/Makefile.in b/programs/net/Makefile.in
index 5364f4e..8ababf7 100644
--- a/programs/net/Makefile.in
+++ b/programs/net/Makefile.in
@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = net.exe
APPMODE = -mconsole
-IMPORTS = user32 advapi32 kernel32
+IMPORTS = netapi32 user32 advapi32 kernel32
C_SRCS = net.c
diff --git a/programs/net/net.c b/programs/net/net.c
index 4bc3652..f27c853 100644
--- a/programs/net/net.c
+++ b/programs/net/net.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <windows.h>
+#include <lm.h>
#include "resources.h"
#define NET_START 0001
@@ -36,6 +37,45 @@ int output_string(int msg, ...)
return 0;
}
+static BOOL net_use(int argc, char *argv[])
+{
+ USE_INFO_2 *buffer, *connection;
+ DWORD read, total, resume_handle, rc, i;
+ const char *status_description[] = { "OK", "Paused", "Disconnected", "An error occurred",
+ "A network error occurred", "Connection is being made",
+ "Reconnecting" };
+ resume_handle = 0;
+ buffer = NULL;
+
+ if(argc<3)
+ {
+ do {
+ rc = NetUseEnum(NULL, 2, (BYTE **) &buffer, 2048, &read, &total, &resume_handle);
+ if (rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS)
+ {
+ break;
+ }
+
+ if(total == 0)
+ {
+ output_string(STRING_NO_ENTRIES);
+ break;
+ }
+
+ output_string(STRING_USE_HEADER);
+ for (i = 0, connection = buffer; i < read; ++i, ++connection)
+ output_string(STRING_USE_ENTRY, status_description[connection->ui2_status], connection->ui2_local,
+ connection->ui2_remote, connection->ui2_refcount);
+
+ if (buffer != NULL) NetApiBufferFree(buffer);
+ } while (rc == ERROR_MORE_DATA);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static BOOL StopService(SC_HANDLE SCManager, SC_HANDLE serviceHandle)
{
LPENUM_SERVICE_STATUS dependencies = NULL;
@@ -159,5 +199,10 @@ int main(int argc, char *argv[])
return 0;
}
+ if(!strcasecmp(argv[1], "use"))
+ {
+ if(!net_use(argc, argv)) return 1;
+ }
+
return 0;
}
diff --git a/programs/net/resources.h b/programs/net/resources.h
index 4c1c167..c5199fd 100644
--- a/programs/net/resources.h
+++ b/programs/net/resources.h
@@ -30,3 +30,6 @@
#define STRING_STOP_SVC_SUCCESS 112
#define STRING_STOP_SVC_FAIL 113
#define STRING_HELP_USAGE 114
+#define STRING_NO_ENTRIES 115
+#define STRING_USE_HEADER 116
+#define STRING_USE_ENTRY 117
More information about the wine-cvs
mailing list