int
corecmd_get_hw_lcd_density(void)
{
    UICmdRespHeader resp;
    void* tmp = NULL;
    int status;

    status = _coreCmdProxy_send_command(AUICMD_GET_LCD_DENSITY, NULL, 0);
    if (status < 0) {
        return status;
    }
    status = _coreCmdProxy_get_response(&resp, &tmp);
    if (status < 0) {
        return status;
    }
    return resp.result;
}
int
corecmd_is_network_disabled()
{
    UICmdRespHeader resp;
    void* tmp = NULL;
    int status;

    status = _coreCmdProxy_send_command(AUICMD_CHK_NETWORK_DISABLED, NULL, 0);
    if (status < 0) {
        return status;
    }
    status = _coreCmdProxy_get_response(&resp, &tmp);
    if (status < 0) {
        return status;
    }
    return resp.result;
}
int
corecmd_get_netdelay(int index, NetworkLatency** netdelay)
{
    UICmdGetNetDelay req;
    UICmdRespHeader resp;
    UICmdGetNetDelayResp* resp_data = NULL;
    int status;

    // Initialize and send the query.
    req.index = index;
    status = _coreCmdProxy_send_command(AUICMD_GET_NETDELAY, &req, sizeof(req));
    if (status < 0) {
        return status;
    }

    // Obtain the response from the core.
    status = _coreCmdProxy_get_response(&resp, (void**)&resp_data);
    if (status < 0) {
        return status;
    }
    if (!resp.result) {
        NetworkLatency* ret;
        // Allocate memory for the returning NetworkLatency instance.
        // It includes: NetworkLatency structure +
        // size of zero-terminated "name" and "display" strings saved in
        // resp_data.
        *netdelay = malloc(sizeof(NetworkLatency) + 1 +
                           resp.resp_data_size - sizeof(UICmdGetNetDelayResp));
        ret = *netdelay;

        // Copy data obtained from the core to the returning NetworkLatency
        // instance.
        ret->min_ms = resp_data->min_ms;
        ret->max_ms = resp_data->max_ms;
        ret->name = (char*)ret + sizeof(NetworkLatency);
        strcpy((char*)ret->name, resp_data->name);
        ret->display = ret->name + strlen(ret->name) + 1;
        strcpy((char*)ret->display, resp_data->name + strlen(resp_data->name) + 1);
    }
    if (resp_data != NULL) {
        free(resp_data);
    }
    return resp.result;
}
int
corecmd_get_netdelay(int index, NetworkLatency** netdelay)
{
    UICmdGetNetDelay req;
    UICmdRespHeader resp;
    UICmdGetNetDelayResp* resp_data = NULL;
    int status;

    
    req.index = index;
    status = _coreCmdProxy_send_command(AUICMD_GET_NETDELAY, &req, sizeof(req));
    if (status < 0) {
        return status;
    }

    
    status = _coreCmdProxy_get_response(&resp, (void**)&resp_data);
    if (status < 0) {
        return status;
    }
    if (!resp.result) {
        NetworkLatency* ret;
        
        
        
        
        *netdelay = malloc(sizeof(NetworkLatency) + 1 +
                           resp.resp_data_size - sizeof(UICmdGetNetDelayResp));
        ret = *netdelay;

        
        
        ret->min_ms = resp_data->min_ms;
        ret->max_ms = resp_data->max_ms;
        ret->name = (char*)ret + sizeof(NetworkLatency);
        strcpy((char*)ret->name, resp_data->name);
        ret->display = ret->name + strlen(ret->name) + 1;
        strcpy((char*)ret->display, resp_data->name + strlen(resp_data->name) + 1);
    }
    if (resp_data != NULL) {
        free(resp_data);
    }
    return resp.result;
}
int
corecmd_get_netspeed(int index, NetworkSpeed** netspeed)
{
    UICmdGetNetSpeed req;
    UICmdRespHeader resp;
    UICmdGetNetSpeedResp* resp_data = NULL;
    int status;

    
    req.index = index;
    status = _coreCmdProxy_send_command(AUICMD_GET_NETSPEED, &req, sizeof(req));
    if (status < 0) {
        return status;
    }

    
    status = _coreCmdProxy_get_response(&resp, (void**)&resp_data);
    if (status < 0) {
        return status;
    }
    if (!resp.result) {
        NetworkSpeed* ret;
        
        
        
        
        *netspeed = malloc(sizeof(NetworkSpeed) + 1 +
                           resp.resp_data_size - sizeof(UICmdGetNetSpeedResp));
        ret = *netspeed;

        
        
        ret->upload = resp_data->upload;
        ret->download = resp_data->download;
        ret->name = (char*)ret + sizeof(NetworkSpeed);
        strcpy((char*)ret->name, resp_data->name);
        ret->display = ret->name + strlen(ret->name) + 1;
        strcpy((char*)ret->display, resp_data->name + strlen(resp_data->name) + 1);
    }
    if (resp_data != NULL) {
        free(resp_data);
    }
    return resp.result;
}
int
corecmd_get_qemu_path(int type,
                      const char* filename,
                      char* path,
                      size_t path_buf_size)
{
    UICmdRespHeader resp;
    char* resp_data = NULL;
    int status;

    // Initialize and send the query.
    uint32_t cmd_data_size = sizeof(UICmdGetQemuPath) + strlen(filename) + 1;
    UICmdGetQemuPath* req = (UICmdGetQemuPath*)malloc(cmd_data_size);
    if (req == NULL) {
        APANIC("corecmd_get_qemu_path is unable to allocate %u bytes\n",
               cmd_data_size);
    }
    req->type = type;
    strcpy(req->filename, filename);
    status = _coreCmdProxy_send_command(AUICMD_GET_QEMU_PATH, req,
                                        cmd_data_size);
    if (status < 0) {
        return status;
    }

    // Obtain the response from the core.
    status = _coreCmdProxy_get_response(&resp, (void**)&resp_data);
    if (status < 0) {
        return status;
    }
    if (!resp.result && resp_data != NULL) {
        strncpy(path, resp_data, path_buf_size);
        path[path_buf_size - 1] = '\0';
    }
    if (resp_data != NULL) {
        free(resp_data);
    }
    return resp.result;
}