(bind-func fits-open-file
(lambda (path)
(let ((files:|1,i8*|* (alloc))
(err:i8* (alloc 40))
(status:i32* (alloc)))
(ffopen (bitcast files i8**) path 1 status)
(ffgerr (pref status 0) err)
(printf "file ptr:%p\n" (aref files 0))
(if (<> (pref status 0) 0)
(begin (printf "error loading fits file: %s\n" err)
null)
(aref files 0)))))