/* Returns 1 if successful */
bool_t rpc_loc_event_cb_f_type_svc(
      rpc_loc_event_cb_f_type_args *argp,
      rpc_loc_event_cb_f_type_rets *ret,
      struct svc_req *req)
{
    // The lower word of cd_id is the index
    int index = argp->cb_id & 0xFFFF;

    /* Callback not registered, or unexpected ID (shouldn't happen) */
    if (index >= LOC_API_CB_MAX_CLIENTS || loc_glue_callback_table[index].cb_func == NULL)
    {
        LOC_LOGE("Warning: No callback handler %d.\n", index);
        ret->loc_event_cb_f_type_result = 0;
        return 1; /* simply return */
    }

    LOC_LOGV("proc: %x  prog: %x  vers: %x\n",
         (int) req->rq_proc,
         (int) req->rq_prog,
         (int) req->rq_vers);

    LOC_LOGV("Callback received: %x (cb_id=%p handle=%d ret_ptr=%d)\n",
         (int) argp->loc_event,
               argp->cb_id,
         (int) argp->loc_handle,
         (int) ret);

    /* Forward callback to real callback procedure */
    rpc_loc_client_handle_type        loc_handle = argp->loc_handle;
    rpc_loc_event_mask_type           loc_event  = argp->loc_event;
    const rpc_loc_event_payload_u_type*  loc_event_payload =
        (const rpc_loc_event_payload_u_type*) argp->loc_event_payload;

    /* Gives control to synchronous call handler */
    loc_api_callback_process_sync_call(loc_handle, loc_event, loc_event_payload);

    int32 rc = (loc_glue_callback_table[index].cb_func)(loc_glue_callback_table[index].user,
                                                        loc_handle, loc_event, loc_event_payload);

    LOC_LOGV("cb_func=%p", loc_glue_callback_table[index].cb_func);

    ret->loc_event_cb_f_type_result = rc;

    return 1; /* ok */
}
/* Returns 1 if successful */
bool_t rpc_loc_event_cb_f_type_0x00010001_svc(
        rpc_loc_event_cb_f_type_args *argp,
        rpc_loc_event_cb_f_type_rets *ret,
        struct svc_req *req)
{
    /* Callback not registered, or unexpected ID (shouldn't happen) */
    if (loc_api_saved_cb == NULL || argp->cb_id != LOC_API_CB_ID)
    {
        LOGD("Warning: No callback handler.\n");
        ret->loc_event_cb_f_type_result = 0;
        return 1; /* simply return */
    }

    LOGD("proc: %x  prog: %x  vers: %x\n",
            (int) req->rq_proc,
            (int) req->rq_prog,
            (int) req->rq_vers);

    LOGD("Callback received: %x (handle=%d ret_ptr=%d)\n",
            (int) argp->loc_event,
            (int) argp->loc_handle,
            (int) ret);

    /* Forward callback to real callback procedure */
    rpc_loc_client_handle_type        loc_handle = argp->loc_handle;
    rpc_loc_event_mask_type           loc_event  = argp->loc_event;
    const rpc_loc_event_payload_u_type*  loc_event_payload =
        (const rpc_loc_event_payload_u_type*) argp->loc_event_payload;

    /* Gives control to synchronous call handler */
    loc_api_callback_process_sync_call(loc_handle, loc_event, loc_event_payload);

    int32 rc = loc_api_saved_cb(loc_handle, loc_event, loc_event_payload);
    ret->loc_event_cb_f_type_result = rc;

    return 1; /* ok */
}