#include "xlib.h" static s48_value P_List_Extensions (d) s48_value d; { s48_value ret; int n; register i; register char **p; S48_DECLARE_GC_PROTECT(1); 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); for (i = 0; i < n; i++) { s48_value e; e = Make_String (p[i], strlen (p[i])); S48_VECTOR_SET(ret, i, e;) } S48_GC_UNPROTECT; XFreeExtensionList (p); return ret; } static s48_value P_Query_Extension (d, name) s48_value d, name; { int opcode, event, error; s48_value ret, t; S48_DECLARE_GC_PROTECT(2); 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; 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); }