summaryrefslogtreecommitdiff
path: root/lib/py_aes.c
blob: 6f60a29f39f88aad6c3d7adbb1f285231b3259d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#include "ldg_Python.h"
#include <gem.h>

extern PyObject *GEMError;

/* --- Application Library --- */
static PyObject* __CDECL py_appl_init(PyObject *self, PyObject *args)
{
int ret;

    ret = appl_init();
    return Py_BuildValue("i",ret);
}

static PyObject* __CDECL py_appl_exit(PyObject *self, PyObject *args)
{
int ret;

    ret = appl_exit();
    return Py_BuildValue("i",ret);
}

static PyObject* __CDECL py_appl_write(PyObject *self, PyObject *args)
{
int ret;
int app_id;
char *message;
int msg_length;
    
    if(!PyArg_ParseTuple(args,"iiy*",&app_id,&msg_length,&message))
        return NULL;
    
    ret = appl_write(app_id,msg_length,message);
    return Py_BuildValue("i",ret);
}

/* --- Forms Library --- */
static PyObject* __CDECL py_form_alert(PyObject *self, PyObject *args)
{
char *text;
int x;
    
    if(!PyArg_ParseTuple(args,"is",&x,&text))
        return NULL;
        
    x = form_alert(x,text);
    return Py_BuildValue("i",x);
}

/* --- Resources Library --- */
static PyObject* __CDECL py_rsrc_load(PyObject *self, PyObject *args)
{
char *file;
int x;
    
    if(!PyArg_ParseTuple(args,"s",&file))
        return NULL;
        
    if(rsrc_load(file) == 0) {
        PyErr_SetString(GEMError,"Resource failed to load");
        return NULL;
    }
    
    Py_INCREF(Py_None);
    return Py_None;
}

static PyObject* __CDECL py_rsrc_gaddr(PyObject *self, PyObject *args)
{
char *file;
int type, index;
void *gaddr;
    
    if(!PyArg_ParseTuple(args,"ii",&type,&index))
        return NULL;
        
    if(rsrc_gaddr(type,index,&gaddr) == 0) {
        PyErr_SetString(GEMError,"Resource item was not found");
        return NULL;
    }
    
    return PyCapsule_New(gaddr,NULL,NULL);
}

/* --- Windows Library --- */
static PyObject* __CDECL py_wind_create(PyObject *self, PyObject *args)
{
int type, x, y, w, h;
int ret;
    
    if(!PyArg_ParseTuple(args,"i(iiii)",&type,&x,&y,&w,&h))
        return NULL;
    
    return Py_BuildValue("i",wind_create(type,x,y,w,h));
}

static PyObject* __CDECL py_wind_close(PyObject *self, PyObject *args)
{
int id;
    
    if(!PyArg_ParseTuple(args,"i",&id))
        return NULL;
    
    if(wind_close(id) == 0) {
        PyErr_SetString(GEMError,"Window failed to close");
        return NULL;
    }
    
    Py_INCREF(Py_None);
    return Py_None;
}

static PyObject* __CDECL py_wind_delete(PyObject *self, PyObject *args)
{
int id;
    
    if(!PyArg_ParseTuple(args,"i",&id))
        return NULL;
    
    if(wind_delete(id) == 0) {
        PyErr_SetString(GEMError,"Window was not deleted");
        return NULL;
    }
    
    Py_INCREF(Py_None);
    return Py_None;
}

static PyObject* __CDECL py_wind_open(PyObject *self, PyObject *args)
{
int id, x, y, w, h;
int ret;
    
    if(!PyArg_ParseTuple(args,"i(iiii)",&id,&x,&y,&w,&h))
        return NULL;
        
    ret = wind_open(type,x,y,w,h);
    if(ret == 0) {
        PyErr_SetString(GEMError,"Window could not be opened");
        return NULL;
    }
    
    Py_INCREF(Py_None);
    return Py_None;
}

static PyObject* __CDECL py_wind_get(PyObject *self, PyObject *args)
{
int id, gp;
int w1, w2, w3, w4;
int ret;
    
    if(!PyArg_ParseTuple(args,"ii",&id,&gp))
        return NULL;
        
    ret = wind_get(id,gp,&w1,&w2,&w3,&w4);
    if(ret == 0) {
        PyErr_SetString(GEMError,"Window request failed");
        return NULL;
    }
    
    switch(gp) {
    
        case WF_WORKXYWH:
        case WF_WINXCFG:
        case WF_WINX:
        case WF_WIDGETS:
        case WF_UNICONIFY:
        case WF_TOP:
        case WF_PREVXYWH:
        case WF_OWNER:
        case WF_NTOOLBAR:
        case WF_NEXTXYWH:
        case WF_MINXYWH:
        case WF_FULLXYWH:
        case WF_FTOOLBAR:
        case WF_FIRSTXYWH:
        case WF_DDELAY:
        case WF_CURRXYWH:
            return Py_BuildValue("(iiii)", w1, w2, w3, w4);
            break;
        case WF_DCOLOR:
        case WF_ICONIFY:
        case WF_NEWDESK:
            return Py_BuildValue("(iii)", w1, w2, w3);
            break;
        case WF_MENU:
        case WF_TOOLBAR:
        case WF_M_WINDLIST:
            return Py_BuildValue("(ii)", w1, w2);
            break;
        case XA:
            return Py_BuildValue("ii", ret, w1);
            break;
        case WF_BEVENT:
        case WF_BOTTOM:
        case WF_HSLIDE:
        case WF_HSLSIZE:
        case WF_KIND:
        case WF_M_OWNER:
        case WF_SHADE:
        case WF_VSLIDE:
        case WF_VSLSIZE:
        default:
            return Py_BuildValue("i", w1);
            break;
    }
    
    Py_INCREF(Py_None);
    return Py_None;
}