summaryrefslogtreecommitdiff
path: root/testprogs/win32/npecho/npecho_client.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-09-28 13:47:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:06 -0500
commit4ad69c3deec3470849270fb180a78f8a4e78f854 (patch)
treeb6269cb088ca7ac3bd9aeb837f83c83ea2d3d2c6 /testprogs/win32/npecho/npecho_client.c
parentf7c5e5a3987ea773203f6052e9cac34ae8992131 (diff)
downloadsamba-4ad69c3deec3470849270fb180a78f8a4e78f854.tar.gz
samba-4ad69c3deec3470849270fb180a78f8a4e78f854.tar.bz2
samba-4ad69c3deec3470849270fb180a78f8a4e78f854.zip
r10576: Add testprog for named pipes. Also add GNUmakefile's for cross-compilation
using mingw32 (This used to be commit 30ba8fdc3dc8dba543686591a27b819b8f9444db)
Diffstat (limited to 'testprogs/win32/npecho/npecho_client.c')
-rwxr-xr-xtestprogs/win32/npecho/npecho_client.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/testprogs/win32/npecho/npecho_client.c b/testprogs/win32/npecho/npecho_client.c
new file mode 100755
index 0000000000..4131bd3792
--- /dev/null
+++ b/testprogs/win32/npecho/npecho_client.c
@@ -0,0 +1,50 @@
+/*
+ * Simple Named Pipe Client
+ * (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+ * Published to the public domain
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+#define ECHODATA "Black Dog"
+
+int main(int argc, char *argv[])
+{
+ HANDLE h;
+ DWORD numread = 0;
+ char outbuffer[512];
+
+ if (argc == 1) {
+ printf("Usage: %s pipename\n", argv[0]);
+ printf(" Where pipename is something like \\\\servername\\NPECHO\n");
+ return -1;
+ }
+
+ h = CreateFile(argv[1], GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ printf("Error opening: %d\n", GetLastError());
+ return -1;
+ }
+
+ if (!WriteFile(h, ECHODATA, strlen(ECHODATA), NULL, NULL)) {
+ printf("Error writing: %d\n", GetLastError());
+ return -1;
+ }
+
+ if (!ReadFile(h, outbuffer, strlen(ECHODATA), NULL, NULL)) {
+ printf("Error reading: %d\n", GetLastError());
+ return -1;
+ }
+
+ printf("Read: %s\n", outbuffer);
+
+ if (!TransactNamedPipe(h, ECHODATA, strlen(ECHODATA), outbuffer, strlen(ECHODATA), &numread, NULL)) {
+ printf("TransactNamedPipe failed: %d!\n", GetLastError());
+ return -1;
+ }
+
+ printf("Result: %s\n", outbuffer);
+
+ return 0;
+}