scx/c/xlib/extension.c

49 lines
1.4 KiB
C
Raw Normal View History

2001-05-08 10:21:00 -04:00
#include "xlib.h"
static s48_value P_List_Extensions (d) s48_value d; {
s48_value ret;
2001-05-08 10:21:00 -04:00
int n;
register i;
register char **p;
S48_DECLARE_GC_PROTECT(1);
2001-05-08 10:21:00 -04:00
Check_Type (d, T_Display);
Disable_Interrupts;
p = XListExtensions (DISPLAY(d)->dpy, &n);
Enable_Interrupts;
ret = s48_make_vector (n, S48_NULL);
S48_GC_PROTECT_1 (ret);
2001-05-08 10:21:00 -04:00
for (i = 0; i < n; i++) {
s48_value e;
2001-05-08 10:21:00 -04:00
e = Make_String (p[i], strlen (p[i]));
S48_VECTOR_SET(ret, i, e;)
2001-05-08 10:21:00 -04:00
}
S48_GC_UNPROTECT;
2001-05-08 10:21:00 -04:00
XFreeExtensionList (p);
return ret;
}
static s48_value P_Query_Extension (d, name) s48_value d, name; {
2001-05-08 10:21:00 -04:00
int opcode, event, error;
s48_value ret, t;
S48_DECLARE_GC_PROTECT(2);
2001-05-08 10:21:00 -04:00
Check_Type (d, T_Display);
if (!XQueryExtension (DISPLAY(d)->dpy, Get_Strsym (name), &opcode,
&event, &error))
return S48_FALSE;
t = ret = P_Make_List (s48_enter_integer (3), S48_NULL);
S48_GC_PROTECT_2 (ret, t);
S48_CAR (t) = (opcode ? s48_enter_integer (opcode) : S48_FALSE); t = S48_CDR (t);
S48_CAR (t) = (event ? s48_enter_integer (event) : S48_FALSE); t = S48_CDR (t);
S48_CAR (t) = (error ? s48_enter_integer (error) : S48_FALSE);
S48_GC_UNPROTECT;
2001-05-08 10:21:00 -04:00
return ret;
}
elk_init_xlib_extension () {
Define_Primitive (P_List_Extensions, "list-extensions", 1, 1, EVAL);
Define_Primitive (P_Query_Extension, "query-extension", 2, 2, EVAL);
}