CAMLprim value netcgi2_apache_request_print_char (value rv, value cv) { CAMLparam2 (rv, cv); request_rec *r = Request_rec_val (rv); int c = Int_val (cv); if (ap_rputc (c, r) == EOF) raise_sys_error(copy_string("Netcgi_mod#out_channel#output_char")); CAMLreturn (Val_unit); }
value mlgz_gzopen_gen(value name, value mode) { gzFile str; str = gzopen(String_val(name), String_val(mode)) ; if(str==NULL){ if(errno==0) raise_out_of_memory(); else raise_sys_error(concat_strings(String_val(name), strerror(errno))); } return Val_ptr(str); }
value caml_history_truncate_file(value name, value nlines) { CAMLparam2(name, nlines); int result; result = history_truncate_file( String_val(name), Long_val(nlines) ); if (result != 0) { CAMLlocal1(error); error = copy_string(strerror( result )); raise_sys_error( error ); } CAMLreturn(Val_unit); }
value caml_write_history(value name) { CAMLparam1(name); int result; result = write_history( String_val(name) ); if (result != 0) { CAMLlocal1(error); error = copy_string(strerror( result )); raise_sys_error( error ); } CAMLreturn(Val_unit); }
static void caml_ba_sys_error(void) { char buffer[512]; DWORD errnum; errnum = GetLastError(); if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errnum, 0, buffer, sizeof(buffer), NULL)) sprintf(buffer, "Unknown error %ld\n", errnum); raise_sys_error(copy_string(buffer)); }
value caml_read_history(value name) { CAMLparam1(name); int result; result = read_history( String_val(name) ); if (result == ENOENT) { raise_not_found(); } else if (result != 0) { CAMLlocal1(error); error = copy_string(strerror( result )); raise_sys_error( error ); } CAMLreturn(Val_unit); }
/* raise the library exception or the Sys_error exn */ static void mlgz_error(gzFile file) { int errnum; const char *msg; msg = gzerror(file, &errnum); if(errnum < 0){ gzclose(file) ; switch(errnum){ case Z_ERRNO : raise_sys_error(copy_string(strerror(errno))) ; case Z_MEM_ERROR : raise_out_of_memory() ; default : raise_mlgz_exn(msg) ; } } }
static void caml_wthread_error(char * msg) { char errmsg[1024]; sprintf(errmsg, "%s: error code %lx", msg, GetLastError()); raise_sys_error(copy_string(errmsg)); }