net: Make it possible to translate the connection status descriptions.
Francois Gouget
fgouget at free.fr
Mon Aug 1 08:55:01 CDT 2011
Also remove the description for USE_DISCONN as it is in fact a synonym
for USE_SESSLOST.
---
This can be applied independently from the lmuse.h patch and the other
net.rc patch.
programs/net/net.c | 20 ++++++++++++++++----
programs/net/net.rc | 6 ++++++
programs/net/resources.h | 6 ++++++
3 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/programs/net/net.c b/programs/net/net.c
index e5e47c8..815eadf 100644
--- a/programs/net/net.c
+++ b/programs/net/net.c
@@ -55,14 +55,22 @@ 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" };
+ char *status[STRING_RECONN-STRING_OK+1];
resume_handle = 0;
buffer = NULL;
if(argc<3)
{
+ HMODULE hmod = GetModuleHandleW(NULL);
+
+ /* Load the status strings */
+ for (i = 0; i < sizeof(status)/sizeof(*status); i++)
+ {
+ status[i] = HeapAlloc(GetProcessHeap(), 0, 1024);
+ LoadStringA(hmod, STRING_OK+i, status[i], 1024);
+ printf("i=%d desc=%s\n", i, status[i]);
+ }
+
do {
rc = NetUseEnum(NULL, 2, (BYTE **) &buffer, 2048, &read, &total, &resume_handle);
if (rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS)
@@ -78,12 +86,16 @@ static BOOL net_use(int argc, char *argv[])
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,
+ output_string(STRING_USE_ENTRY, status[connection->ui2_status], connection->ui2_local,
connection->ui2_remote, connection->ui2_refcount);
if (buffer != NULL) NetApiBufferFree(buffer);
} while (rc == ERROR_MORE_DATA);
+ /* Release the status strings */
+ for (i = 0; i < sizeof(status)/sizeof(*status); i++)
+ HeapFree(GetProcessHeap(), 0, status[i]);
+
return TRUE;
}
diff --git a/programs/net/net.rc b/programs/net/net.rc
index dfc7e21..f805f4a 100644
--- a/programs/net/net.rc
+++ b/programs/net/net.rc
@@ -42,4 +42,10 @@ STRINGTABLE
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"
+ STRING_OK, "OK"
+ STRING_PAUSED, "Paused"
+ STRING_SESSLOST, "Disconnected"
+ STRING_NETERR "A network error occurred"
+ STRING_CONN "Connection is being made"
+ STRING_RECONN, "Reconnecting"
}
diff --git a/programs/net/resources.h b/programs/net/resources.h
index 659e47f..cdb1c44 100644
--- a/programs/net/resources.h
+++ b/programs/net/resources.h
@@ -35,3 +35,9 @@
#define STRING_NO_ENTRIES 115
#define STRING_USE_HEADER 116
#define STRING_USE_ENTRY 117
+#define STRING_OK 118
+#define STRING_PAUSED 119
+#define STRING_SESSLOST 120
+#define STRING_NETERR 121
+#define STRING_CONN 122
+#define STRING_RECONN 123
--
1.7.5.4
More information about the wine-patches
mailing list