2001-05-08 10:21:00 -04:00
|
|
|
#include "xlib.h"
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
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;
|
2001-05-14 09:48:37 -04:00
|
|
|
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;
|
2001-05-14 09:48:37 -04:00
|
|
|
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++) {
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value e;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
|
|
|
e = Make_String (p[i], strlen (p[i]));
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_VECTOR_SET(ret, i, e;)
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_GC_UNPROTECT;
|
2001-05-08 10:21:00 -04:00
|
|
|
XFreeExtensionList (p);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Query_Extension (d, name) s48_value d, name; {
|
2001-05-08 10:21:00 -04:00
|
|
|
int opcode, event, error;
|
2001-05-14 09:48:37 -04:00
|
|
|
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))
|
2001-05-14 09:48:37 -04:00
|
|
|
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);
|
|
|
|
}
|