Added error reporting to lpcsrv and lpcclt.
[reactos.git] / reactos / apps / tests / lpc / lpcclt.c
1 /* $Id: lpcclt.c,v 1.5 2000/01/22 22:22:48 ea Exp $
2 *
3 * DESCRIPTION: Simple LPC Client
4 * PROGRAMMER: David Welch
5 */
6 #include <ddk/ntddk.h>
7 #include <stdarg.h>
8 #include <string.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 HANDLE OutputHandle;
13 HANDLE InputHandle;
14
15 void debug_printf(char* fmt, ...)
16 {
17 va_list args;
18 char buffer[255];
19
20 va_start(args,fmt);
21 vsprintf(buffer,fmt,args);
22 WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
23 va_end(args);
24 }
25
26
27 int main(int argc, char* argv[])
28 {
29 UNICODE_STRING PortName;
30 NTSTATUS Status;
31 HANDLE PortHandle;
32 LPCMESSAGE Request;
33 ULONG ConnectInfoLength;
34
35 printf("(lpcclt.exe) Lpc client\n");
36
37 RtlInitUnicodeString(&PortName, L"\\TestPort");
38
39 printf("(lpcclt.exe) Connecting to port \"\\TestPort\"\n");
40 ConnectInfoLength = 0;
41 Status = NtConnectPort(&PortHandle,
42 &PortName,
43 NULL,
44 0,
45 0,
46 0,
47 NULL,
48 &ConnectInfoLength);
49 if (!NT_SUCCESS(Status))
50 {
51 printf("(lpcclt.exe) Failed to connect (Status = 0x%08X)\n", Status);
52 return EXIT_FAILURE;
53 }
54
55 strcpy(Request.MessageData, GetCommandLineA());
56 Request.ActualMessageLength = strlen(Request.MessageData);
57 Request.TotalMessageLength = sizeof(LPCMESSAGE);
58
59 printf("(lpcclt.exe) Sending message \"%s\"\n", (char *) Request.MessageData);
60 Status = NtRequestPort(PortHandle, &Request);
61 if (!NT_SUCCESS(Status))
62 {
63 printf("(lpcclt.exe) Failed to send request (Status = 0x%=8X)\n", Status);
64 return EXIT_FAILURE;
65 }
66
67 printf("(lpcclt.exe) Succeeded\n");
68 return EXIT_SUCCESS;
69 }