1 /***********************************************************************/
2 /* Open Visualization Data Explorer */
3 /* (C) Copyright IBM Corp. 1989,1999 */
4 /* ALL RIGHTS RESERVED */
5 /* This code licensed under the */
6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */
7 /***********************************************************************/
8
9 #include <dxconfig.h>
10
11
12
13
14 #include <stdio.h>
15 #include <dx/dx.h>
16 #include "../dpexec/parse.h"
17
18 extern Error DXRegisterForNotification(char *, Pointer); /* from libdx/notify.c */
19 extern Error DXNotifyRegistered(char *); /* from libdx/notify.c */
20 extern Error DXGetVariable(char *, Object *); /* from dpexec/variable.c */
21 extern Error DXSetVariable(char *, Object); /* from dpexec/variable.c */
22
23 #define NAME in[0]
24 #define DEFAULT in[1]
25 #define RESULT out[0]
26
_getv(Object * args)27 static Error _getv(Object *args)
28 {
29 char *name;
30
31 if (DXExtractString(args[0], &name))
32 if (! DXGetVariable(name, &args[1]))
33 args[1] = NULL;
34
35 return OK;
36 }
37
_setv(Object * args)38 static Error _setv(Object *args)
39 {
40 char *name;
41
42 if (DXExtractString(args[0], &name))
43 if (! DXSetVariable(name, args[1]))
44 args[1] = NULL;
45
46 return OK;
47 }
48
49
50 int
m_DXLInputNamed(Object * in,Object * out)51 m_DXLInputNamed(Object *in, Object *out)
52 {
53 char *name;
54 Object *args = DXAllocate(2*sizeof(Object));
55 Pointer modid;
56
57 if (! DXExtractString(NAME, &name))
58 {
59 DXSetError(ERROR_BAD_PARAMETER, "name");
60 return ERROR;
61 }
62
63 args[0] = NAME;
64 args[1] = NULL;
65
66 if (! _dxf_ExRunOn(1, _getv, (Pointer)args, 0))
67 {
68 DXSetError(ERROR_INTERNAL, "_getv");
69 return ERROR;
70 }
71
72 if (args[1])
73 RESULT = args[1];
74 else
75 RESULT = DEFAULT;
76
77 modid = DXGetModuleId();
78
79 if (! DXRegisterForNotification(name, modid))
80 return ERROR;
81
82 DXFreeModuleId(modid);
83
84 DXFree((Pointer)args);
85
86 return OK;
87 }
88
89 #define VALUE in[1]
90
91 int
m_SetDXLInputNamed(Object * in,Object * out)92 m_SetDXLInputNamed(Object *in, Object *out)
93 {
94 char *name;
95 Object *args = DXAllocate(2*sizeof(Object));
96
97 if (! DXExtractString(NAME, &name))
98 {
99 DXSetError(ERROR_BAD_PARAMETER, "name");
100 return ERROR;
101 }
102
103 args[0] = NAME;
104 args[1] = VALUE;
105
106 if (! _dxf_ExRunOn(1, _setv, (Pointer)args, 0))
107 {
108 DXSetError(ERROR_INTERNAL, "_setv");
109 return ERROR;
110 }
111
112 DXNotifyRegistered(name);
113
114 DXFree((Pointer)args);
115
116 return OK;
117 }
118