Beispiel #1
0
void PrintXErrorAndCoredump(Display *dpy, XErrorEvent *error, char *MyName)
{
	char msg[256];
	Bool suc = False;

	msg[255] = 0;
#ifdef USE_GET_ERROR_TEXT
	/* can't call this from within an error handler! */
	/* DV (21-Nov-2000): Well, actually we *can* call it in an error
	 * handler since it does not trigger a protocol request. */
	if (error->error_code >= FirstExtensionError)
	{
		suc = FRenderGetErrorText(error->error_code, msg);
	}
	if (!suc)
		XGetErrorText(dpy, error->error_code, msg, sizeof(msg));
	fprintf(stderr,"%s: Cause of next X Error.\n", MyName);
	fprintf(stderr, "   Error: %d (%s)\n", error->error_code, msg);
#else
	fprintf(stderr,"%s: Cause of next X Error.\n", MyName);
	if (error->error_code >= FirstExtensionError)
	{
		suc = FRenderGetErrorText(error->error_code, msg);
	}
	if (suc)
		fprintf(stderr, "   Error: %d (%s)\n",
			error->error_code, msg);
	else
		fprintf(stderr, "   Error: %d (%s)\n",
			error->error_code, error_name(error->error_code));
#endif
	fprintf(stderr, "   Major opcode of failed request:  %d (%s)\n",
		error->request_code, request_name(error->request_code));
	fprintf(stderr, "   Minor opcode of failed request:  %d \n",
		error->minor_code);
	/* error->resourceid may be uninitialised. This is no proble since we
	 * are dumping core anyway. */
	fprintf(stderr, "   Resource id of failed request:  0x%lx \n",
		error->resourceid);

	/* leave a coredump */
	do_coredump();
}
Beispiel #2
0
int
main (int argc, char **argv)
{
  DScrobbler *scrobbler;
  GMainLoop *loop;

  g_thread_init (NULL);
  g_type_init ();

  loop = g_main_loop_new (NULL, TRUE);

  scrobbler = d_scrobbler_new ();

  if (!request_name ())
    return 0;

  g_main_loop_run (loop);

  g_object_unref (scrobbler);
  g_object_unref (loop);

  return 0;
}
Beispiel #3
0
int server()
{
    // setup connection to dbus
    boost::asio::io_context io;
    auto conn = std::make_shared<sdbusplus::asio::connection>(io);

    // test object server
    conn->request_name("xyz.openbmc_project.asio-test");
    auto server = sdbusplus::asio::object_server(conn);
    std::shared_ptr<sdbusplus::asio::dbus_interface> iface =
        server.add_interface("/xyz/openbmc_project/test",
                             "xyz.openbmc_project.test");
    // test generic properties
    iface->register_property("int", 33,
                             sdbusplus::asio::PropertyPermission::readWrite);
    std::vector<std::string> myStringVec = {"some", "test", "data"};
    std::vector<std::string> myStringVec2 = {"more", "test", "data"};

    iface->register_property("myStringVec", myStringVec,
                             sdbusplus::asio::PropertyPermission::readWrite);
    iface->register_property("myStringVec2", myStringVec2);

    // test properties with specialized callbacks
    iface->register_property("lessThan50", 23,
                             // custom set
                             [](const int& req, int& propertyValue) {
                                 if (req >= 50)
                                 {
                                     return -EINVAL;
                                 }
                                 propertyValue = req;
                                 return 1; // success
                             });
    iface->register_property(
        "TrailTime", std::string("foo"),
        // custom set
        [](const std::string& req, std::string& propertyValue) {
            propertyValue = req;
            return 1; // success
        },
        // custom get
        [](const std::string& property) {
            auto now = std::chrono::system_clock::now();
            auto timePoint = std::chrono::system_clock::to_time_t(now);
            return property + std::ctime(&timePoint);
        });

    // test method creation
    iface->register_method("TestMethod", [](const int32_t& callCount) {
        return std::make_tuple(callCount,
                               "success: " + std::to_string(callCount));
    });

    iface->register_method("TestFunction", foo);

    // fooYield has boost::asio::yield_context as first argument
    // so will be executed in coroutine context if called
    iface->register_method("TestYieldFunction",
                           [conn](boost::asio::yield_context yield, int val) {
                               return fooYield(yield, conn, val);
                           });

    iface->register_method("TestMethodWithMessage", methodWithMessage);

    iface->register_method("VoidFunctionReturnsInt", voidBar);

    iface->register_method("execute", ipmiInterface);

    iface->initialize();

    io.run();

    return 0;
}