Beispiel #1
0
ib_status_t ibpp_caught_ib_exception(
    ib_engine_t* engine,
    ib_status_t  status,
    const error& e
)
{
    std::string message;
    int level = 1;

    message = std::string(ib_status_to_string(status)) + ":";
    if (boost::get_error_info<errinfo_what>(e)) {
        message += *boost::get_error_info<errinfo_what>(e);
    }
    else {
        message += "IronBee++ Exception but no explanation provided.  "
                   "Please report as bug.";
    }

    if (boost::get_error_info<errinfo_level>(e)) {
        level = *boost::get_error_info<errinfo_level>(e);
    }

    if (engine) {
        ib_log(engine, level, "%s", message.c_str());
        ib_log_debug(engine, "%s", diagnostic_information(e).c_str() );
    } else {
        ib_util_log_error("%s", message.c_str());
        ib_util_log_debug("%s", diagnostic_information(e).c_str()
        );
    }
    return status;
}
Beispiel #2
0
ib_status_t ibpp_caught_boost_exception(
    ib_engine_t*            engine,
    const boost::exception& e
)
{
    std::string message;
    int level = 1;

    message = "Unknown boost::exception thrown: ";
    if (boost::get_error_info<boost::throw_function>(e)) {
        message += *boost::get_error_info<boost::throw_function>(e);
    }
    else {
        message += "No information provided.  Please report as bug.";
    }

    if (boost::get_error_info<errinfo_level>(e)) {
        level = *boost::get_error_info<errinfo_level>(e);
    }

    if (engine) {
        ib_log(engine, level, "%s", message.c_str());
        ib_log_debug(engine, "%s",
            diagnostic_information(e).c_str()
        );
    } else {
        ib_util_log_error("%s", message.c_str());
        ib_util_log_debug("%s", diagnostic_information(e).c_str()
        );
    }

    return IB_EUNKNOWN;
}
static bool button_pressed(void *event_system, uint32_t usage_page, uint32_t usage) {
    /* This magic comes straight from Substrate... I don't really understand
     * what it's doing.  In particular, where is the equivalent kernel
     * implementation on OS X?  Does it not exist?  But I guess Substrate is
     * emulating backboardd. */
    void *dummy = IOHIDEventCreateKeyboardEvent(NULL, mach_absolute_time(),
                                                usage_page, usage,
                                                0, 0);
    if (!dummy) {
        ib_log("couldn't create dummy HID event");
        return false;
    }
    void *event = IOHIDEventSystemCopyEvent(event_system,
                                            kIOHIDEventTypeKeyboard,
                                            dummy, 0);
    if (!event)
        return false;
    CFIndex ival = IOHIDEventGetIntegerValue(event, kIOHIDEventFieldKeyboardDown);
    return ival;
}