void test_001(gpointer *fixture, gconstpointer data) { GType type = g_type_from_name("Log4gTTCCLayout"); g_assert(type); Log4gLayout *layout = g_object_new(type, NULL); g_assert(layout); log4g_layout_activate_options(layout); type = g_type_from_name("Log4gRollingFileAppender"); g_assert(type); Log4gAppender *appender = g_object_new(type, "file", "rolling-file-appender-test.txt", "max-backup-index", 4, "maximum-file-size", 10, NULL); g_assert(appender); log4g_appender_set_layout(appender, layout); log4g_appender_activate_options(appender); g_object_unref(layout); for (gint i = 0; i < 10; ++i) { va_list ap; memset(&ap, 0, sizeof ap); Log4gLoggingEvent *event = log4g_logging_event_new( "org.gnome.test", log4g_level_DEBUG(), __func__, __FILE__, G_STRINGIFY(__LINE__), "test message", ap); g_assert(event); log4g_appender_do_append(appender, event); g_object_unref(event); usleep(20); } g_object_unref(appender); }
static void gst_dshowaudiodec_base_init (gpointer klass) { GstDshowAudioDecClass *audiodec_class = (GstDshowAudioDecClass *) klass; GstPadTemplate *src, *sink; GstCaps *srccaps, *sinkcaps; GstElementClass *element_class = GST_ELEMENT_CLASS (klass); char *description; audiodec_class->entry = tmp; description = g_strdup_printf ("DirectShow %s Decoder Wrapper", tmp->element_longname); gst_element_class_set_details_simple (element_class, description, "Codec/Decoder/Audio", description, "Sebastien Moutte <*****@*****.**>"); g_free (description); sinkcaps = gst_caps_from_string (tmp->sinkcaps); srccaps = gst_caps_from_string ( "audio/x-raw-int," "width = (int)[1, 32]," "depth = (int)[1, 32]," "rate = (int)[1, MAX]," "channels = (int)[1, MAX]," "signed = (boolean)true," "endianness = (int)" G_STRINGIFY(G_LITTLE_ENDIAN)); sink = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sinkcaps); src = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps); /* register */ gst_element_class_add_pad_template (element_class, src); gst_element_class_add_pad_template (element_class, sink); }
void test_001(G_GNUC_UNUSED gpointer *fixture, G_GNUC_UNUSED gconstpointer data) { GType type = g_type_from_name("Log4gSimpleLayout"); g_assert(type); Log4gLayout *layout = g_object_new(type, NULL); g_assert(layout); log4g_layout_activate_options(layout); va_list ap; memset(&ap, 0, sizeof ap); Log4gLoggingEvent *event = log4g_logging_event_new("org.gnome.test", log4g_level_DEBUG(), __func__, __FILE__, G_STRINGIFY(__LINE__), "test message", ap); g_assert(event); type = g_type_from_name("Log4gConsoleAppender"); g_assert(type); Log4gAppender *appender = g_object_new(type, "target", "stdout", NULL); g_assert(appender); log4g_appender_set_layout(appender, layout); log4g_appender_activate_options(appender); g_object_unref(layout); log4g_appender_do_append(appender, event); log4g_appender_close(appender); g_object_unref(event); g_object_unref(appender); }
void daemon_init (void) { GDBusConnection *conn; GError *error; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, log_debug, G_STRINGIFY (DEFAULT_BACKEND_TYPE)); gvfs_setup_debug_handler (); #ifdef SIGPIPE /* Ignore SIGPIPE to avoid killing daemons on cancelled transfer * * See https://bugzilla.gnome.org/show_bug.cgi?id=649041 * */ signal (SIGPIPE, SIG_IGN); #endif error = NULL; conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (!conn) { g_printerr ("Error connecting to D-Bus: %s (%s, %d)\n", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); exit (1); } g_object_unref (conn); }
void _rut_pointalism_grid_init_type (void) { static RutRefableVTable refable_vtable = { rut_refable_simple_ref, rut_refable_simple_unref, _rut_pointalism_grid_free }; static RutComponentableVTable componentable_vtable = { .copy = _rut_pointalism_grid_copy }; static RutPrimableVTable primable_vtable = { .get_primitive = rut_pointalism_grid_get_primitive }; static RutMeshableVTable meshable_vtable = { .get_mesh = rut_pointalism_grid_get_pick_mesh }; static RutIntrospectableVTable introspectable_vtable = { rut_simple_introspectable_lookup_property, rut_simple_introspectable_foreach_property }; RutType *type = &rut_pointalism_grid_type; #define TYPE RutPointalismGrid rut_type_init (type, G_STRINGIFY (TYPE)); rut_type_add_interface (type, RUT_INTERFACE_ID_REF_COUNTABLE, offsetof (TYPE, ref_count), &refable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_COMPONENTABLE, offsetof (TYPE, component), &componentable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_PRIMABLE, 0, /* no associated properties */ &primable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_MESHABLE, 0, /* no associated properties */ &meshable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_INTROSPECTABLE, 0, &introspectable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_SIMPLE_INTROSPECTABLE, offsetof (TYPE, introspectable), NULL); #undef TYPE }
static void gst_omx_audio_dec_class_init (GstOMXAudioDecClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstAudioDecoderClass *audio_decoder_class = GST_AUDIO_DECODER_CLASS (klass); gobject_class->finalize = gst_omx_audio_dec_finalize; element_class->change_state = GST_DEBUG_FUNCPTR (gst_omx_audio_dec_change_state); audio_decoder_class->open = GST_DEBUG_FUNCPTR (gst_omx_audio_dec_open); audio_decoder_class->close = GST_DEBUG_FUNCPTR (gst_omx_audio_dec_close); audio_decoder_class->start = GST_DEBUG_FUNCPTR (gst_omx_audio_dec_start); audio_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_omx_audio_dec_stop); audio_decoder_class->flush = GST_DEBUG_FUNCPTR (gst_omx_audio_dec_flush); audio_decoder_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_audio_dec_set_format); audio_decoder_class->handle_frame = GST_DEBUG_FUNCPTR (gst_omx_audio_dec_handle_frame); klass->cdata.type = GST_OMX_COMPONENT_TYPE_FILTER; klass->cdata.default_src_template_caps = "audio/x-raw, " "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, " G_STRINGIFY (OMX_AUDIO_MAXCHANNELS) " ], " "format = (string) " GST_AUDIO_FORMATS_ALL; }
static void gst_omx_audio_enc_class_init (GstOMXAudioEncClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstAudioEncoderClass *audio_encoder_class = GST_AUDIO_ENCODER_CLASS (klass); gobject_class->finalize = gst_omx_audio_enc_finalize; element_class->change_state = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_change_state); audio_encoder_class->start = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_start); audio_encoder_class->stop = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_stop); audio_encoder_class->flush = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_flush); audio_encoder_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_set_format); audio_encoder_class->handle_frame = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_handle_frame); audio_encoder_class->sink_event = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_sink_event); klass->cdata.type = GST_OMX_COMPONENT_TYPE_FILTER; klass->cdata.default_sink_template_caps = "audio/x-raw, " "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, " G_STRINGIFY (OMX_AUDIO_MAXCHANNELS) " ], " "format = (string) { S8, U8, S16LE, S16BE, U16LE, U16BE, " "S24LE, S24BE, U24LE, U24BE, S32LE, S32BE, U32LE, U32BE }"; }
static void test_govirt_http(void) { OvirtProxy *proxy; OvirtApi *api; GError *error = NULL; GovirtMockHttpd *httpd; httpd = govirt_mock_httpd_new(GOVIRT_HTTPS_PORT); govirt_mock_httpd_disable_tls(httpd, TRUE); govirt_mock_httpd_add_request(httpd, "GET", "/ovirt-engine/api", "<api></api>"); govirt_mock_httpd_start(httpd); g_setenv("GOVIRT_DISABLE_HTTPS", "1", TRUE); g_test_expect_message("libgovirt", G_LOG_LEVEL_WARNING, "Using plain text HTTP connection"); g_test_expect_message("libgovirt", G_LOG_LEVEL_CRITICAL, "ovirt_proxy_set_api_from_xml: assertion 'vms != NULL' failed"); proxy = ovirt_proxy_new("localhost:" G_STRINGIFY(GOVIRT_HTTPS_PORT)); api = ovirt_proxy_fetch_api(proxy, &error); g_test_assert_expected_messages(); g_assert_nonnull(api); g_assert_no_error(error); g_object_unref(proxy); g_unsetenv("GOVIRT_DISABLE_HTTPS"); govirt_mock_httpd_stop(httpd); }
GType c_main_window_get_type (void) { static GType type = 0; if (G_UNLIKELY (!type)) { GTypeInfo const info = { sizeof (CMainWindowIface), NULL, NULL, (GClassInitFunc) c_main_window_iface_init, NULL, NULL, 0, 0, NULL }; type = g_type_register_static (G_TYPE_INTERFACE, G_STRINGIFY (CMainWindow), &info, 0); g_type_interface_add_prerequisite (type, GTK_TYPE_WINDOW); } return type; }
/** * D-Bus callback for the version get method call * * @param msg The D-Bus message to reply to * @return TRUE on success, FALSE on failure */ static gboolean version_get_dbus_cb(DBusMessage *const msg) { static const gchar *const versionstring = G_STRINGIFY(PRG_VERSION); DBusMessage *reply = NULL; gboolean status = FALSE; mce_log(LL_DEBUG, "Received version information request"); /* Create a reply */ reply = dbus_new_method_reply(msg); /* Append the version information */ if (dbus_message_append_args(reply, DBUS_TYPE_STRING, &versionstring, DBUS_TYPE_INVALID) == FALSE) { mce_log(LL_CRIT, "Failed to append reply argument to D-Bus message " "for %s.%s", MCE_REQUEST_IF, MCE_VERSION_GET); dbus_message_unref(reply); goto EXIT; } /* Send the message */ status = dbus_send_message(reply); EXIT: return status; }
void test_001(gpointer *fixture, gconstpointer data) { GType type = g_type_from_name("Log4gCouchdbAppender"); g_assert(type); Log4gAppender *appender = g_object_new(type, "database-name", "couchdb_appender_test", NULL); g_assert(appender); log4g_appender_activate_options(appender); va_list ap; memset(&ap, 0, sizeof ap); for (gint i = 0; i < 5; ++i) { log4g_mdc_put("couchdb-appender-test", "test in loop %d", i); log4g_ndc_push("LOOP %d", i); Log4gLoggingEvent *event = log4g_logging_event_new( "org.gnome.test", log4g_level_DEBUG(), __func__, __FILE__, G_STRINGIFY(__LINE__), "test message", ap); g_assert(event); log4g_appender_do_append(appender, event); g_object_unref(event); usleep(20); } g_object_unref(appender); }
void test_001(gpointer *fixture, gconstpointer data) { GType type = g_type_from_name("Log4gSimpleLayout"); g_assert(type); Log4gLayout *layout = g_object_new(type, NULL); g_assert(layout); log4g_layout_activate_options(layout); type = g_type_from_name("Log4gSyslogAppender"); g_assert(type); Log4gAppender *appender = g_object_new(type, "ident", "syslog-appender-test", "option", LOG_USER, "facility", LOG_CONS, NULL); g_assert(appender); log4g_appender_set_layout(appender, layout); log4g_appender_activate_options(appender); g_object_unref(layout); for (gint i = 0; i < 5; ++i) { log4g_ndc_push("LOOP %d", i); va_list ap; memset(&ap, 0, sizeof ap); Log4gLoggingEvent *event = log4g_logging_event_new( "org.gnome.test", log4g_level_INFO(), __func__, __FILE__, G_STRINGIFY(__LINE__), "test message", ap); g_assert(event); log4g_appender_do_append(appender, event); g_object_unref(event); usleep(20); } g_object_unref(appender); }
static void test_govirt_https_ca(void) { OvirtProxy *proxy; OvirtApi *api; GError *error = NULL; GovirtMockHttpd *httpd; httpd = govirt_mock_httpd_new(GOVIRT_HTTPS_PORT); govirt_mock_httpd_add_request(httpd, "GET", "/ovirt-engine/api", "<api></api>"); govirt_mock_httpd_start(httpd); g_setenv("GOVIRT_NO_SSL_STRICT", "1", TRUE); g_test_expect_message("libgovirt", G_LOG_LEVEL_WARNING, "Disabling strict checking of SSL certificates"); g_test_expect_message("libgovirt", G_LOG_LEVEL_CRITICAL, "ovirt_proxy_set_api_from_xml: assertion 'vms != NULL' failed"); proxy = ovirt_proxy_new("localhost:" G_STRINGIFY(GOVIRT_HTTPS_PORT)); api = ovirt_proxy_fetch_api(proxy, &error); g_test_assert_expected_messages(); g_assert_nonnull(api); g_assert_no_error(error); g_object_unref(proxy); g_unsetenv("GOVIRT_NO_SSL_STRICT"); g_test_expect_message("libgovirt", G_LOG_LEVEL_WARNING, "Error while getting collection: Unacceptable TLS certificate"); proxy = ovirt_proxy_new("localhost:" G_STRINGIFY(GOVIRT_HTTPS_PORT)); api = ovirt_proxy_fetch_api(proxy, &error); g_test_assert_expected_messages(); g_assert_null(api); g_assert_error(error, REST_PROXY_ERROR, REST_PROXY_ERROR_SSL); g_assert_cmpstr(error->message, ==, "Unacceptable TLS certificate"); g_clear_error(&error); g_test_expect_message("libgovirt", G_LOG_LEVEL_CRITICAL, "ovirt_proxy_set_api_from_xml: assertion 'vms != NULL' failed"); ovirt_proxy_set_mock_ca(proxy); api = ovirt_proxy_fetch_api(proxy, &error); g_test_assert_expected_messages(); g_assert_nonnull(api); g_assert_no_error(error); g_clear_object(&proxy); govirt_mock_httpd_stop(httpd); }
static void _rut_fold_init_type (void) { static RutRefableVTable refable_vtable = { rut_refable_simple_ref, rut_refable_simple_unref, _rut_fold_free }; static RutGraphableVTable graphable_vtable = { NULL, /* child removed */ NULL, /* child added */ NULL /* parent changed */ }; static RutSizableVTable sizable_vtable = { rut_composite_sizable_set_size, rut_composite_sizable_get_size, rut_composite_sizable_get_preferred_width, rut_composite_sizable_get_preferred_height, rut_composite_sizable_add_preferred_size_callback }; static RutIntrospectableVTable introspectable_vtable = { rut_simple_introspectable_lookup_property, rut_simple_introspectable_foreach_property }; RutType *type = &rut_fold_type; #define TYPE RutFold rut_type_init (type, G_STRINGIFY (TYPE)); rut_type_add_interface (type, RUT_INTERFACE_ID_REF_COUNTABLE, offsetof (TYPE, ref_count), &refable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_GRAPHABLE, offsetof (TYPE, graphable), &graphable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_SIZABLE, 0, /* no implied properties */ &sizable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_COMPOSITE_SIZABLE, offsetof (TYPE, vbox), NULL); /* no vtable */ rut_type_add_interface (type, RUT_INTERFACE_ID_INTROSPECTABLE, 0, /* no implied properties */ &introspectable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_SIMPLE_INTROSPECTABLE, offsetof (TYPE, introspectable), NULL); /* no implied vtable */ #undef TYPE }
void gkr_debug_message (GkrDebugFlags flag, const gchar *format, ...) { static gsize initialized_flags = 0; const gchar *messages_env; const gchar *debug_env; va_list args; if (g_once_init_enter (&initialized_flags)) { messages_env = g_getenv ("G_MESSAGES_DEBUG"); debug_env = g_getenv ("GKR_DEBUG"); #ifdef GKR_DEBUG if (debug_env == NULL) debug_env = G_STRINGIFY (GKR_DEBUG); #endif /* * If the caller is selectively asking for certain debug * messages with the GKR_DEBUG environment variable, then * we install our own output handler and only print those * messages. This happens irrespective of G_MESSAGES_DEBUG */ if (messages_env == NULL && debug_env != NULL) g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, on_gkr_log_debug, NULL); /* * If the caller is using G_MESSAGES_DEBUG then we enable * all our debug messages, and let Glib filter which ones * to display. */ if (messages_env != NULL && debug_env == NULL) debug_env = "all"; gkr_debug_set_flags (debug_env); #ifdef FOR_WHEN_ALL_ELSE_FAILS openlog ("libgnome-keyring", LOG_NDELAY | LOG_PID, LOG_AUTHPRIV); gkr_debug_set_flags ("all"); #endif g_once_init_leave (&initialized_flags, 1); } if (flag & current_flags) { va_start (args, format); g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); va_end (args); } #ifdef FOR_WHEN_ALL_ELSE_FAILS va_start (args, format); vsyslog (LOG_ERR, format, args); va_end (args); #endif }
/** * Just print version and quit */ static void print_version (void) { printf ("XMMS2 version " XMMS_VERSION "\n"); printf ("Copyright (C) 2003-2012 XMMS2 Team\n"); printf ("This is free software; see the source for copying conditions.\n"); printf ("There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n"); printf ("PARTICULAR PURPOSE.\n"); printf (" Using glib version %d.%d.%d (compiled against " G_STRINGIFY (GLIB_MAJOR_VERSION) "." G_STRINGIFY (GLIB_MINOR_VERSION) "." G_STRINGIFY (GLIB_MICRO_VERSION) ")\n", glib_major_version, glib_minor_version, glib_micro_version); exit (EXIT_SUCCESS); }
std::vector<std::string> Platform::getConfigPaths() { const gchar * const *datadirs = g_get_system_data_dirs(); std::vector<std::string> dirs; /* Always prefer config files in the current directory */ dirs.push_back(std::string(".") + G_DIR_SEPARATOR); /* Otherwise prefer the app's current directory */ if (binary_path) dirs.push_back(std::string(binary_path) + G_DIR_SEPARATOR); dirs.push_back(std::string(G_STRINGIFY(DATADIR)) + G_DIR_SEPARATOR); dirs.push_back(std::string(G_STRINGIFY(SYSCONFDIR)) + G_DIR_SEPARATOR); for(gsize i = 0; datadirs[i] != NULL; ++i) dirs.push_back(std::string(datadirs[i]) + G_DIR_SEPARATOR + "repsnapper" + G_DIR_SEPARATOR); return dirs; }
/** * Display version information */ static void version(void) { fprintf(stdout, _("%s v%s\n%s"), progname, G_STRINGIFY(PRG_VERSION), _("Written by David Weinehall.\n" "\n" "Copyright (C) 2004-2010 Nokia Corporation. " "All rights reserved.\n")); }
static gboolean caps_cache_open (WockyCapsCache *self) { gint ret; gchar *error; g_return_val_if_fail (self->priv->db == NULL, FALSE); ret = sqlite3_open (self->priv->path, &self->priv->db); if (ret != SQLITE_OK) { DEBUG ("opening database %s failed: %s", self->priv->path, sqlite3_errmsg (self->priv->db)); goto err; } if (!caps_cache_check_version (self)) goto err; ret = sqlite3_exec (self->priv->db, "PRAGMA user_version = " G_STRINGIFY (DB_USER_VERSION) ";" "PRAGMA journal_mode = MEMORY;" "PRAGMA synchronous = OFF", NULL, NULL, &error); if (ret != SQLITE_OK) { DEBUG ("failed to set user_version, turn off fsync() and " "turn off on-disk journalling: %s", error); sqlite3_free (error); goto err; } ret = sqlite3_exec (self->priv->db, "CREATE TABLE IF NOT EXISTS capabilities (\n" " node text PRIMARY KEY,\n" " disco_reply text,\n" " timestamp int)", NULL, NULL, &error); if (ret != SQLITE_OK) { DEBUG ("failed to ensure table exists: %s", error); sqlite3_free (error); goto err; } return TRUE; err: sqlite3_close (self->priv->db); self->priv->db = NULL; return FALSE; }
void setup(Fixture *fixture, G_GNUC_UNUSED gconstpointer data) { log4g_mdc_put("foo", "bar"); log4g_ndc_push("baz"); va_list ap; memset(&ap, 0, sizeof ap); fixture->event = log4g_logging_event_new("org.gnome.test", log4g_level_DEBUG(), __func__, __FILE__, G_STRINGIFY(__LINE__), "foo bar baz", ap); g_assert(fixture->event); }
void daemon_setup (void) { char *name, *up; up = g_ascii_strup (G_STRINGIFY (DEFAULT_BACKEND_TYPE), -1); /* translators: This is the default daemon's application name, * the %s is the type of the backend, like "FTP" */ name = g_strdup_printf (_("%s File System Service"), up); g_set_application_name (name); g_free (name); g_free (up); }
static void _rut_button_init_type (void) { static RutRefableVTable refable_vtable = { rut_refable_simple_ref, rut_refable_simple_unref, _rut_button_free }; static RutGraphableVTable graphable_vtable = { NULL, /* child remove */ NULL, /* child add */ NULL /* parent changed */ }; static RutPaintableVTable paintable_vtable = { _rut_button_paint }; static RutSizableVTable sizable_vtable = { rut_button_set_size, rut_button_get_size, rut_button_get_preferred_width, rut_button_get_preferred_height, NULL /* add_preferred_size_callback */ }; RutType *type = &rut_button_type; #define TYPE RutButton rut_type_init (type, G_STRINGIFY (TYPE)); rut_type_add_interface (type, RUT_INTERFACE_ID_REF_COUNTABLE, offsetof (TYPE, ref_count), &refable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_GRAPHABLE, offsetof (TYPE, graphable), &graphable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_PAINTABLE, offsetof (TYPE, paintable), &paintable_vtable); rut_type_add_interface (type, RUT_INTERFACE_ID_SIZABLE, 0, /* no implied properties */ &sizable_vtable); #undef TYPE }
static bool mce_do_version(const char *arg) { (void)arg; static const char vers[] = G_STRINGIFY(PRG_VERSION); static const char info[] = "Written by David Weinehall.\n" "\n" "Copyright (C) 2004-2010 Nokia Corporation. " "All rights reserved.\n"; fprintf(stdout, "%s v%s\n%s", progname, vers, info); exit(EXIT_SUCCESS); }
/* Called when we get number of elements for a specific key */ static void rspamd_redis_stat_key (redisAsyncContext *c, gpointer r, gpointer priv) { struct rspamd_redis_stat_cbdata *cbdata = priv; redisReply *reply = r; ucl_object_t *obj; glong num = 0; if (cbdata->wanna_die) { return; } cbdata->inflight --; if (c->err == 0 && r != NULL) { if (G_LIKELY (reply->type == REDIS_REPLY_INTEGER)) { num = reply->integer; } else if (reply->type == REDIS_REPLY_STRING) { rspamd_strtol (reply->str, reply->len, &num); } if (num < 0) { msg_err ("bad learns count: %L", (gint64)num); num = 0; } obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "used"); if (obj) { obj->value.iv += num; } obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "total"); if (obj) { obj->value.iv += num; } obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "size"); if (obj) { /* Size of key + size of int64_t */ obj->value.iv += num * (sizeof (G_STRINGIFY (G_MAXINT64)) + sizeof (guint64) + sizeof (gpointer)); } } if (cbdata->inflight == 0) { rspamd_redis_async_cbdata_cleanup (cbdata); } }
static char *g_tls_policy(guint64 hub, const char *key) { if(!db_certificate) return G_STRINGIFY(VAR_TLSP_DISABLE); char *r = db_vars_get(hub, key); if(!r) return NULL; static char num[2] = {}; // Compatibility with old versions if(r && r[0] >= '0' && r[0] <= '2' && !r[1]) num[0] = var_tls_policy_ops[r[0]-'0'].num; else num[0] = flags_raw(var_tls_policy_ops, FALSE, r, NULL); num[0] += '0'; return num; }
void cogl_texture_unref (CoglHandle handle) { if (!cogl_is_texture (handle)) { g_warning (G_STRINGIFY (cogl_texture_unref) ": Ignoring unref of Cogl handle " "due to type mismatch"); return; } _COGL_HANDLE_DEBUG_UNREF (CoglTexture, handle); cogl_handle_unref (handle); }
static void test_govirt_list_duplicate_vms(void) { OvirtProxy *proxy; OvirtApi *api; OvirtCollection *vms; OvirtResource *vm; GError *error = NULL; GovirtMockHttpd *httpd; const char *vms_body = "<vms> \ <vm href=\"api/vms/uuid0\" id=\"uuid0\"> \ <name>vm0</name> \ </vm> \ <vm href=\"api/vms/uuid1\" id=\"uuid1\"> \ <name>vm0</name> \ </vm> \ </vms>"; httpd = govirt_mock_httpd_new(GOVIRT_HTTPS_PORT); govirt_mock_httpd_add_request(httpd, "GET", "/ovirt-engine/api", "<api><link href=\"/ovirt-engine/api/vms\" rel=\"vms\"/></api>"); govirt_mock_httpd_add_request(httpd, "GET", "/ovirt-engine/api/vms", vms_body); govirt_mock_httpd_start(httpd); proxy = ovirt_proxy_new("localhost:" G_STRINGIFY(GOVIRT_HTTPS_PORT)); ovirt_proxy_set_mock_ca(proxy); api = ovirt_proxy_fetch_api(proxy, &error); g_test_assert_expected_messages(); g_assert_nonnull(api); g_assert_no_error(error); g_test_expect_message("libgovirt", G_LOG_LEVEL_MESSAGE, "'vm' resource with the same name ('vm0') already exists"); vms = ovirt_api_get_vms(api); ovirt_collection_fetch(vms, proxy, &error); g_test_assert_expected_messages(); g_assert_no_error(error); vm = ovirt_collection_lookup_resource(vms, "vm0"); g_assert_nonnull(vm); g_object_unref(vm); g_object_unref(proxy); govirt_mock_httpd_stop(httpd); }
static char *g_ffc(guint64 hub, const char *key) { #ifndef HAVE_POSIX_FADVISE return G_STRINGIFY(VAR_FFC_NONE); #else char *r = db_vars_get(hub, key); if(!r) return NULL; static char num[4]; // true/false check is for compatibility with old versions g_snprintf(num, 4, "%d", strcmp(r, "true") == 0 ? VAR_FFC_UPLOAD | VAR_FFC_HASH : strcmp(r, "false") == 0 ? VAR_FFC_NONE : flags_raw(var_ffc_ops, TRUE, r, NULL) ); return num; #endif }
static void gst_dshowaudiodec_base_init (gpointer klass) { GstDshowAudioDecClass *audiodec_class = (GstDshowAudioDecClass *) klass; GstPadTemplate *src, *sink; GstCaps *srccaps, *sinkcaps; GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementDetails details; const AudioCodecEntry *tmp; gpointer qdata; qdata = g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), DSHOW_CODEC_QDATA); /* element details */ tmp = audiodec_class->entry = (AudioCodecEntry *) qdata; details.longname = g_strdup_printf ("DirectShow %s Decoder Wrapper", tmp->element_longname); details.klass = g_strdup ("Codec/Decoder/Audio"); details.description = g_strdup_printf ("DirectShow %s Decoder Wrapper", tmp->element_longname); details.author = "Sebastien Moutte <*****@*****.**>"; gst_element_class_set_details (element_class, &details); g_free (details.longname); g_free (details.klass); g_free (details.description); sinkcaps = gst_caps_from_string (tmp->sinkcaps); srccaps = gst_caps_from_string ( "audio/x-raw-int," "width = (int)[1, 32]," "depth = (int)[1, 32]," "rate = (int)[1, MAX]," "channels = (int)[1, MAX]," "signed = (boolean)true," "endianness = (int)" G_STRINGIFY(G_LITTLE_ENDIAN)); sink = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sinkcaps); src = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps); /* register */ gst_element_class_add_pad_template (element_class, src); gst_element_class_add_pad_template (element_class, sink); }
static void _rig_rpc_peer_init_type (void) { static RutRefableVTable refable_vtable = { rut_refable_simple_ref, rut_refable_simple_unref, _rig_rpc_peer_free }; RutType *type = &rig_rpc_peer_type; #define TYPE RigRPCPeer rut_type_init (type, G_STRINGIFY (TYPE)); rut_type_add_interface (type, RUT_INTERFACE_ID_REF_COUNTABLE, offsetof (TYPE, ref_count), &refable_vtable); #undef TYPE }