CAMLprim value brlapiml_enterTtyMode(value handle, value tty, value driverName) { CAMLparam3(handle, tty, driverName); int res; brlapiCheckErrorWithCode(enterTtyMode, &res, Int_val(tty), String_val(driverName)); CAMLreturn(Val_int(res)); }
CAMLprim value brlapiml_sendRaw(value handle, value str) { CAMLparam2(handle, str); int res; unsigned char packet[BRLAPI_MAXPACKETSIZE]; ssize_t i, size = MIN(sizeof(packet), caml_string_length(str)); for (i=0; i<size; i++) packet[i] = Byte(str, i); brlapiCheckErrorWithCode(sendRaw, &res, packet, size); CAMLreturn(Val_int(res)); }
CAMLprim value brlapiml_recvRaw(value handle, value unit) { CAMLparam2(handle, unit); unsigned char packet[BRLAPI_MAXPACKETSIZE]; int i, size; CAMLlocal1(str); brlapiCheckErrorWithCode(recvRaw, &size, packet, sizeof(packet)); str = caml_alloc_string(size); for (i=0; i<size; i++) Byte(str, i) = packet[i]; CAMLreturn(str); }
CAMLprim value brlapiml_readKey(value handle, value unit) { CAMLparam2(handle, unit); int res; brlapi_keyCode_t keyCode; CAMLlocal1(retVal); brlapiCheckErrorWithCode(readKey, &res, 0, &keyCode); if (res==0) CAMLreturn(Val_int(0)); retVal = caml_alloc(1, 1); Store_field(retVal, 0, caml_copy_int64(keyCode)); CAMLreturn(retVal); }
CAMLprim value brlapiml_readKeyWithTimeout(value handle, value timeout_ms) { CAMLparam2(handle, timeout_ms); int res; brlapi_keyCode_t keyCode; CAMLlocal1(retVal); brlapiCheckErrorWithCode(readKeyWithTimeout, &res, Int_val(timeout_ms), &keyCode); if (res==0) CAMLreturn(Val_int(0)); retVal = caml_alloc(1, 1); Store_field(retVal, 0, caml_copy_int64(keyCode)); CAMLreturn(retVal); }