]> pd.if.org Git - mmurtl/blob - msamples/service/testsvc.c
autocommit for file dated 1995-02-05 10:18:56
[mmurtl] / msamples / service / testsvc.c
1 /* Test client for the NUMBERS System Service.\r
2    Run this program from another CLI when Service is running\r
3 */\r
4 \r
5 #include <stdio.h>\r
6 #include "\OSSOurce\MKernel.h"\r
7 \r
8 unsigned long Number;                   /* The number to return */\r
9 unsigned long Exch;             /* Where hte service will respond */\r
10 unsigned long Message[2];       /* The Message from the service */\r
11 \r
12 void main(void)\r
13 {\r
14 unsigned long Error, rqhndl;\r
15 \r
16         Error = AllocExch(&Exch);         /* get an exchange */\r
17 \r
18         if (Error)\r
19                 printf("Error %d allocating Exchange.\r\n", Error);\r
20 \r
21         Error = Request("NUMBERS ", 1, Exch, &rqhndl,\r
22                                         0,                                                      /* No Send ptrs */\r
23                     &Number, 4, 0, 0,\r
24                     0,0,0);\r
25         if (Error)\r
26                 printf("Error %d from Request.\r\n", Error);\r
27 \r
28         if (!Error)\r
29         {\r
30                 Error = WaitMsg(Exch, Message);\r
31 \r
32                 if (Error)\r
33                         printf("Error %d from WaitMsg.\r\n", Error);\r
34                 else\r
35                 {\r
36                         if (Message[1])\r
37                                 printf("Error %d from NUMBERS Service.\r\n", Message[1]);\r
38                         else\r
39                                 printf("NUMBERS Service gave out number: %d.\r\n", Number);\r
40                 }\r
41         }\r
42 \r
43         DeAllocExch(Exch);      /* it's nice to do this for the OS */\r
44 }\r