Welcome to the CHICKEN Scheme pasting service

trouble with xlib ffi added by retroj on Fri Dec 8 02:19:30 2017

;; this one prints what appear to be memory addresses
;;
(define (window-get-icons display window)
  (let ((property (xinternatom display "_NET_WM_ICON" 0)))
    (let-location ((xa_ret_type unsigned-long)
                   (ret_format int)
                   (ret_nitems unsigned-long)
                   (ret_bytes_after unsigned-long)
                   (ret_data (c-pointer unsigned-char)))
      (let ((status (xgetwindowproperty display window property
                                        0 #x77777777 0
                                        ANYPROPERTYTYPE
                                        (location xa_ret_type)
                                        (location ret_format)
                                        (location ret_nitems)
                                        (location ret_bytes_after)
                                        (location ret_data))))
        (if ret_data
            ((foreign-lambda* int (((c-pointer unsigned-long) data))
               "int width = *(int*)data;"
               "printf(\"%d\\n\",width);"
               "C_return(width);")
             (location ret_data))
            -1)))))

;; This one works as expected (prints expected icon widths)
;;
(define window-get-icons2
  (foreign-lambda* int ((c-pointer disp) (unsigned-long window))
    "unsigned long nitems, bytesafter;"
    "unsigned char *ret;"
    "int format;"
    "Atom type;"
    "Atom net_wm_icon = XInternAtom(disp, \"_NET_WM_ICON\", 0);"
    "XGetWindowProperty(disp, window, net_wm_icon,"
    "                   0, 0x77777777, 0,"
    "                   6,"
    "                   &type, &format, &nitems, &bytesafter, &ret);"
    "if (!ret) { C_return(-1); }"
    "int width = *(int*)ret;"
    "XFree(ret);"
    "printf(\"%d\\n\",width);"
    "C_return(width);"))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the result of `(apply + (list -3 4 2))'?
Visually impaired? Let me spell it for you (wav file) download WAV