Segmentation violation added by zilti on Tue Nov 22 19:00:51 2016
#> #ifndef MHTTPD_CHICKEN_INCLUDES #define MHTTPD_CHICKEN_INCLUDES #include <sys/types.h> #include <sys/select.h> #include <sys/socket.h> #include <microhttpd.h> #include <unistd.h> #endif <# (use r7rs) (import scheme) (import chicken) (use posix) (import foreign) (require-extension srfi-18) (define send-response (foreign-lambda* int ((c-pointer connection) (int status) (c-string page)) "struct MHD_Response * response; int ret; response = MHD_create_response_from_buffer (strlen(page), (void*) page, MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, status, response); C_return(ret);")) (define http-daemon (foreign-safe-lambda* c-pointer (((function int (c-pointer c-pointer c-string c-string c-string c-string size_t c-pointer)) handler) (int port)) "struct MHD_Daemon * daemon; daemon = calloc(1, sizeof(daemon)); daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, port, NULL, NULL, &handler, NULL, MHD_OPTION_END); C_return(daemon);")) (define kill-http-daemon (foreign-lambda* void ((c-pointer daemon)) "MHD_stop_daemon (daemon); free(daemon);")) (define-external (answer_to_connection (c-pointer cls) (c-pointer connection) (c-string url) (c-string method) (c-string version) (c-string upload-data) (size_t upload-data-size) (c-pointer con-cls)) int (let ((page "<html><body>Hello Browser!</body></html>")) (send-response connection (foreign-value "MHD_HTTP_OK" int) page))) (http-daemon answer_to_connection 8080) (sleep 20) ;; FOR REFERENCE: THE ERROR Error: segmentation violation Call history: machine-byte-order ##sys#require numbers.scm:267: ##sys#gc numbers.scm:1770: register-feature! microhttpd.scm:1: ##sys#require microhttpd.scm:1: ##sys#require microhttpd.scm:3: ##sys#provide microhttpd.lib.scm:11: ##sys#require microhttpd.lib.scm:57: http-daemon microhttpd.lib.scm:30: ##sys#gc microhttpd.lib.scm:30: g134 microhttpd.lib.scm:58: sleep <--