define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / workbench / demos / cxtest.c
blob6248c42bd89263dd547c08856fc83288fce04424
1 /*
2 Copyright © 1998-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Test program for Commodities
6 Lang: English
7 */
9 #include <proto/exec.h>
10 #include <proto/commodities.h>
11 #include <proto/intuition.h>
12 #include <intuition/intuition.h>
13 #include <exec/memory.h>
14 #include <libraries/commodities.h>
15 #include <dos/dos.h>
17 #include <stdio.h>
18 #include <stdlib.h>
20 struct IntuitionBase *IntuitionBase;
22 int main(int argc, char* argv[])
24 struct Library *CxBase;
25 CxObj *myBroker;
26 CxObj *filter;
27 CxObj *trans;
28 struct InputEvent myie;
29 struct Window *window;
31 struct NewBroker brok =
33 NB_VERSION,
34 "AROS TestBroker",
35 "SDuvan 20.04.98",
36 "Broker for testing the commodities library",
40 NULL, /* nb_Port - will be initialized below */
45 myie.ie_NextEvent = NULL;
46 myie.ie_Class = IECLASS_RAWKEY;
47 myie.ie_SubClass = IESUBCLASS_COMPATIBLE;
48 myie.ie_Code= 0x20;
49 myie.ie_Qualifier = 0;
51 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",39);
53 window = OpenWindowTags(NULL,
54 WA_IDCMP, IDCMP_RAWKEY,
55 WA_Height, 50,
56 WA_Width, 100,
57 TAG_END);
59 if(!window)
61 fprintf(stderr, "Window failed to open.\n");
62 exit(1);
66 fprintf(stderr, "Testing commodities.library...\n");
67 fflush(stderr);
68 CxBase = OpenLibrary("commodities.library", 0);
70 brok.nb_Port = CreateMsgPort();
72 if(CxBase == NULL)
74 fprintf(stderr, "Couldn't open commodities.library.\n");
75 return -1;
78 fprintf(stderr, "Calling CxBroker().\n");
79 fflush(stderr);
81 myBroker = CxBroker(&brok, NULL);
83 fprintf(stderr, "Broker installed.\n");
84 fflush(stderr);
86 if(myBroker == NULL)
88 fprintf(stderr, "Error in creating object.\n");
89 CloseLibrary(CxBase);
90 return -1;
93 fprintf(stderr, "Creating filter object.\n");
94 filter = CxFilter("rawkey return");
96 if(!filter)
98 fprintf(stderr, "Error in creating filter.\n");
99 CloseLibrary(CxBase);
100 return -1;
103 fprintf(stderr, "Filter created.\n");
105 AttachCxObj(myBroker, filter);
107 fprintf(stderr, "Filter attached.\n");
108 fflush(stderr);
111 /* int sig = AllocSignal(-1); */
113 /* trans = CxSignal(FindTask(NULL), sig); */
114 /* trans = CxDebug(1); */
115 trans = CxTranslate(&myie);
116 if(!trans)
118 fprintf(stderr, "Error in creating translator.\n");
119 return -1;
122 AttachCxObj(filter, trans);
124 ActivateCxObj(myBroker, TRUE);
126 fprintf(stderr, "Broker activated.\n");
127 fflush(stderr);
129 Wait(SIGBREAKF_CTRL_C);
130 /* Wait(SIGBREAKF_CTRL_C | 1 << sig); */
133 fprintf(stderr, "Deleting all objects.\n");
134 DeleteCxObjAll(myBroker);
136 CloseWindow(window);
138 fprintf(stderr, "Closing commodities.library...\n");
139 CloseLibrary(CxBase);
140 CloseLibrary((struct Library *)IntuitionBase);
141 fprintf(stderr, "All done.\n");
143 return 0;