1 /* test.c - test the umapi lib */
2
3 #include <stdio.h>
4 #include <time.h>
5 #include "typesize.h"
6 #include "umapi.h"
7
8 #define areaName "/husky/echo/umapi.test"
9
printMsgHdr(tUmMsgHdr * msgHdr)10 void printMsgHdr(tUmMsgHdr *msgHdr)
11 {
12 int i;
13
14 printf("msgNr: %d\n", msgHdr->msgNr);
15 printf("flags: %d\n", msgHdr->flags);
16 printf("fromAddr: %s\n", umAddr2Str(msgHdr->fromAddr));
17 printf("toAddr: %s\n", umAddr2Str(msgHdr->toAddr));
18 printf("fromName: %s\n", msgHdr->fromName);
19 printf("toName: %s\n", msgHdr->toName);
20 printf("subject: %s\n", msgHdr->subject);
21 printf("dateWritten: %s", asctime(gmtime(&msgHdr->dateWritten)));
22 printf("dateArrived: %s", asctime(gmtime(&msgHdr->dateArrived)));
23 printf("dateRead: %s", asctime(gmtime(&msgHdr->dateRead)));
24 printf("replyTo: %d\n", msgHdr->replyTo);
25 printf("numReplies: %d\n", msgHdr->numReplies);
26 for (i = 0; i < msgHdr->numReplies; i++)
27 {
28 printf(" reply: %d\n", msgHdr->replies[i]);
29 }
30 }
31
printMsg(tUmMsg * msg)32 void printMsg(tUmMsg *msg)
33 {
34 int i;
35
36 printMsgHdr(msg->msgHdr);
37
38 if (msg->numKludges != 0)
39 {
40 printf("Kludges:\n");
41 for (i = 0; i < msg->numKludges; i++)
42 printf(" %s\n", msg->kludges[i]);
43 }
44
45 if (msg->numBody != 0)
46 {
47 printf("Body:\n");
48 for (i = 0; i < msg->numBody; i++)
49 printf(" %s\n", msg->body[i]);
50 }
51
52 printf("---\n");
53 }
54
main(int argc,char * argv[])55 int main(int argc, char *argv[])
56 {
57 tUmArea *area;
58 tUmMsg *msg;
59 tUmMsgHdr *msgHdr;
60
61 area = umAreaOpen(cUmAreaTypeSdm, areaName);
62
63 msgHdr = umAreaReadMsgHdr(area, 1);
64 if (msgHdr == NULL)
65 {
66 printf("could not read header of msg #1!\n");
67 }
68 else
69 {
70 printMsgHdr(msgHdr);
71 umMsgHdrDispose(msgHdr);
72 }
73 printf("\n");
74
75 msg = umAreaReadMsg(area, 1);
76 if (msg == NULL)
77 {
78 printf("could not read msg #1!\n");
79 }
80 else
81 {
82 printMsg(msg);
83 umMsgDispose(msg);
84 }
85 printf("\n");
86
87 umAreaClose(area);
88 }
89
90