static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if ((brl->data = malloc(sizeof(*brl->data)))) { memset(brl->data, 0, sizeof(*brl->data)); if (connectResource(brl, device)) { unsigned char response[MAXIMUM_RESPONSE_SIZE]; if (probeBrailleDisplay(brl, PROBE_RETRY_LIMIT, NULL, PROBE_INPUT_TIMEOUT, writeIdentityRequest, readPacket, &response, sizeof(response), isIdentityResponse)) { setBrailleKeyTable(brl, &KEY_TABLE_DEFINITION(all)); MAKE_OUTPUT_TABLE(0X01, 0X04, 0X10, 0X02, 0X08, 0X20, 0X40, 0X80); brl->textColumns = MAXIMUM_CELL_COUNT; brl->data->forceRewrite = 1; return 1; } disconnectBrailleResource(brl, NULL); } free(brl->data); } else { logMallocError(); } return 0; }
static void brl_destruct (BrailleDisplay *brl) { disconnectBrailleResource(brl, NULL); if (brl->data) { free(brl->data); brl->data = NULL; } }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if ((brl->data = malloc(sizeof(*brl->data)))) { memset(brl->data, 0, sizeof(*brl->data)); if (connectResource(brl, device)) { unsigned char response[MAXIMUM_RESPONSE_SIZE]; if (probeBrailleDisplay(brl, PROBE_RETRY_LIMIT, NULL, PROBE_INPUT_TIMEOUT, writeIdentityRequest, readPacket, &response, sizeof(response), isIdentityResponse)) { { const KeyTableDefinition *ktd = &KEY_TABLE_DEFINITION(all); brl->keyBindings = ktd->bindings; brl->keyNameTables = ktd->names; } { static const DotsTable dots = { 0X01, 0X04, 0X10, 0X02, 0X08, 0X20, 0X40, 0X80 }; makeOutputTable(dots); } brl->textColumns = MAXIMUM_CELL_COUNT; brl->data->forceRewrite = 1; return 1; } disconnectBrailleResource(brl, NULL); } free(brl->data); } else { logMallocError(); } return 0; }