static gchar * parse_time (const gchar *response, const gchar *regex, const gchar *tag, GError **error) { GRegex *r; GMatchInfo *match_info = NULL; GError *match_error = NULL; guint year, month, day, hour, minute, second; gchar *result = NULL; r = g_regex_new (regex, 0, 0, NULL); g_assert (r != NULL); if (!g_regex_match_full (r, response, -1, 0, 0, &match_info, &match_error)) { if (match_error) { g_propagate_error (error, match_error); g_prefix_error (error, "Could not parse %s results: ", tag); } else { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Couldn't match %s reply", tag); } } else { if (mm_get_uint_from_match_info (match_info, 1, &year) && mm_get_uint_from_match_info (match_info, 2, &month) && mm_get_uint_from_match_info (match_info, 3, &day) && mm_get_uint_from_match_info (match_info, 4, &hour) && mm_get_uint_from_match_info (match_info, 5, &minute) && mm_get_uint_from_match_info (match_info, 6, &second)) { /* Return ISO-8601 format date/time string */ result = g_strdup_printf ("%04d/%02d/%02d %02d:%02d:%02d", year, month, day, hour, minute, second); } else { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Failed to parse %s reply", tag); } } if (match_info) g_match_info_free (match_info); g_regex_unref (r); return result; }
static gchar * smtp_auth_get_password (GoaSmtpAuth *self, GCancellable *cancellable, GError **error) { gchar *password; password = NULL; if (self->password != NULL) { password = g_strdup (self->password); } else if (self->provider != NULL && self->object != NULL) { GVariant *credentials; credentials = goa_utils_lookup_credentials_sync (self->provider, self->object, cancellable, error); if (credentials == NULL) { g_prefix_error (error, "Error looking up credentials for SMTP in keyring: "); goto out; } if (!g_variant_lookup (credentials, "smtp-password", "s", &password)) { g_set_error (error, GOA_ERROR, GOA_ERROR_FAILED, /* TODO: more specific */ _("Did not find smtp-password in credentials")); g_variant_unref (credentials); goto out; } g_variant_unref (credentials); } else { g_set_error (error, GOA_ERROR, GOA_ERROR_FAILED, /* TODO: more specific */ _("Cannot do SMTP authentication without a password")); goto out; } out: return password; }
static void mbpi_g_set_error(GMarkupParseContext *context, GError **error, GQuark domain, gint code, const gchar *fmt, ...) { va_list ap; gint line_number, char_number; g_markup_parse_context_get_position(context, &line_number, &char_number); va_start(ap, fmt); *error = g_error_new_valist(domain, code, fmt, ap); va_end(ap); g_prefix_error(error, "%s:%d ", MBPI_DATABASE, line_number); }
/* Compile all regexes inside a sortcriteria string. * Every regex (enclosed in <>) will be removed from the * sortcriteria spec, so that the returned string will * consist only of single letters. */ char *rm_pp_compile_patterns(RmSession *session, const char *sortcrit, GError **error) { /* Total of encountered patterns */ int pattern_count = 0; /* Copy of the sortcriteria without pattern specs in <> */ size_t minified_cursor = 0; char *minified_sortcrit = g_strdup(sortcrit); for(size_t i = 0; sortcrit[i]; i++) { /* Copy everything that is not a regex pattern */ minified_sortcrit[minified_cursor++] = sortcrit[i]; char curr_crit = tolower((unsigned char)sortcrit[i]); /* Check if it's a non-regex sortcriteria */ if(!((curr_crit == 'r' || curr_crit == 'x') && sortcrit[i + 1] == '<')) { continue; } GRegex *regex = NULL; /* Jump over the regex pattern part */ i += rm_pp_parse_pattern(&sortcrit[i + 1], ®ex, error); if(regex != NULL) { if(pattern_count < (int)RM_PATTERN_N_MAX && pattern_count != -1) { /* Append to already compiled patterns */ g_ptr_array_add(session->pattern_cache, regex); pattern_count++; } else if(pattern_count != -1) { g_set_error(error, RM_ERROR_QUARK, 0, _("Cannot add more than %ld regex patterns."), RM_PATTERN_N_MAX); /* Make sure to set the warning only once */ pattern_count = -1; g_regex_unref(regex); } else { g_regex_unref(regex); } } } g_prefix_error(error, _("Error while parsing sortcriteria patterns: ")); minified_sortcrit[minified_cursor] = 0; return minified_sortcrit; }
static gboolean complete_connection (NMDevice *device, NMConnection *connection, const char *specific_object, const GSList *existing_connections, GError **error) { NMSettingInfiniband *s_infiniband; const char *setting_mac; const char *hw_address; nm_utils_complete_generic (connection, NM_SETTING_INFINIBAND_SETTING_NAME, existing_connections, NULL, _("InfiniBand connection"), NULL, TRUE); s_infiniband = nm_connection_get_setting_infiniband (connection); if (!s_infiniband) { s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new (); nm_connection_add_setting (connection, NM_SETTING (s_infiniband)); } setting_mac = nm_setting_infiniband_get_mac_address (s_infiniband); hw_address = nm_device_get_hw_address (device); if (setting_mac) { /* Make sure the setting MAC (if any) matches the device's MAC */ if (!nm_utils_hwaddr_matches (setting_mac, -1, hw_address, -1)) { g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, _("connection does not match device")); g_prefix_error (error, "%s.%s: ", NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_MAC_ADDRESS); return FALSE; } } else { /* Lock the connection to this device by default */ g_object_set (G_OBJECT (s_infiniband), NM_SETTING_INFINIBAND_MAC_ADDRESS, hw_address, NULL); } if (!nm_setting_infiniband_get_transport_mode (s_infiniband)) g_object_set (G_OBJECT (s_infiniband), NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); return TRUE; }
/** * gimp_config_writer_new_gfile: * @file: a #GFile * @atomic: if %TRUE the file is written atomically * @header: text to include as comment at the top of the file * @error: return location for errors * * Creates a new #GimpConfigWriter and sets it up to write to * @file. If @atomic is %TRUE, a temporary file is used to avoid * possible race conditions. The temporary file is then moved to @file * when the writer is closed. * * Return value: a new #GimpConfigWriter or %NULL in case of an error * * Since: GIMP 2.10 **/ GimpConfigWriter * gimp_config_writer_new_gfile (GFile *file, gboolean atomic, const gchar *header, GError **error) { GimpConfigWriter *writer; GOutputStream *output; g_return_val_if_fail (G_IS_FILE (file), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (atomic) { output = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, error)); if (! output) g_prefix_error (error, _("Could not create temporary file for '%s': "), gimp_file_get_utf8_name (file)); } else { output = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, error)); } if (! output) return NULL; writer = g_slice_new0 (GimpConfigWriter); writer->output = output; writer->file = g_object_ref (file); writer->buffer = g_string_new (NULL); if (header) { gimp_config_writer_comment (writer, header); gimp_config_writer_linefeed (writer); } return writer; }
GError * meta2_backend_init(struct meta2_backend_s **result, struct sqlx_repository_s *repo, const gchar *ns, struct grid_lbpool_s *glp, struct hc_resolver_s *resolver) { GError *err = NULL; struct meta2_backend_s *m2 = NULL; gsize s; EXTRA_ASSERT(result != NULL); EXTRA_ASSERT(glp != NULL); EXTRA_ASSERT(repo != NULL); EXTRA_ASSERT(resolver != NULL); m2 = g_malloc0(sizeof(struct meta2_backend_s)); s = metautils_strlcpy_physical_ns(m2->backend.ns_name, ns, sizeof(m2->backend.ns_name)); if (sizeof(m2->backend.ns_name) <= s) { g_free(m2); return NEWERROR(CODE_BAD_REQUEST, "Namespace too long"); } m2->backend.type = NAME_SRVTYPE_META2; m2->backend.repo = repo; m2->backend.lb = glp; m2->policies = service_update_policies_create(); g_mutex_init(&m2->nsinfo_lock); m2->flag_precheck_on_generate = TRUE; err = sqlx_repository_configure_type(m2->backend.repo, NAME_SRVTYPE_META2, schema); if (NULL != err) { meta2_backend_clean(m2); g_prefix_error(&err, "Backend init error: "); return err; } m2->resolver = resolver; GRID_DEBUG("M2V2 backend created for NS[%s] and repo[%p]", m2->backend.ns_name, m2->backend.repo); *result = m2; return NULL; }
static gboolean dispatch_close (OstreeRepo *repo, StaticDeltaExecutionState *state, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; if (state->content_out) { if (!g_output_stream_flush (state->content_out, cancellable, error)) goto out; if (state->trusted) { if (!_ostree_repo_commit_trusted_content_bare (repo, state->checksum, &state->barecommitstate, state->uid, state->gid, state->mode, state->xattrs, cancellable, error)) goto out; } else { if (!_ostree_repo_commit_untrusted_content_bare (repo, state->checksum, &state->barecommitstate, state->uid, state->gid, state->mode, state->xattrs, cancellable, error)) goto out; } } if (!dispatch_unset_read_source (repo, state, cancellable, error)) goto out; g_clear_pointer (&state->xattrs, g_variant_unref); g_clear_object (&state->content_out); state->checksum_index++; state->output_target = NULL; ret = TRUE; out: if (!ret) g_prefix_error (error, "opcode open-splice-and-close: "); return ret; }
XUL_APIEXPORT xul_rc_e xul_prefs_open(xul_t * xul, const gchar * keyfile) { g_assert(XUL_IS_VALID(xul)); xul_error_raw_t *rawerror = NULL; if (g_key_file_load_from_file(xul->prefs->keyfile, keyfile, G_KEY_FILE_NONE, &rawerror)) { return XUL_SUCCESS; } g_prefix_error(&rawerror, "Unable to open %s: ", keyfile); xul_error_raw(xul, rawerror); return XUL_FAILURE; }
gboolean rpmostree_get_pkglist_for_root (GFile *root, HySack *out_sack, HyPackageList *out_pkglist, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; int rc; _cleanup_hysack_ HySack sack = NULL; _cleanup_hyquery_ HyQuery query = NULL; _cleanup_hypackagelist_ HyPackageList pkglist = NULL; #if BUILDOPT_HAWKEY_SACK_CREATE2 sack = hy_sack_create (NULL, NULL, gs_file_get_path_cached (root), NULL, HY_MAKE_CACHE_DIR); #else sack = hy_sack_create (NULL, NULL, gs_file_get_path_cached (root), HY_MAKE_CACHE_DIR); #endif if (sack == NULL) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Failed to create sack cache"); goto out; } rc = hy_sack_load_system_repo (sack, NULL, 0); if (!hif_error_set_from_hawkey (rc, error)) { g_prefix_error (error, "Failed to load system repo: "); goto out; } query = hy_query_create (sack); hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); pkglist = hy_query_run (query); ret = TRUE; gs_transfer_out_value (out_sack, &sack); gs_transfer_out_value (out_pkglist, &pkglist); out: return ret; }
static gboolean parse_origin (OstreeSysroot *self, int deployment_dfd, const char *deployment_name, GKeyFile **out_origin, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; g_autoptr(GKeyFile) ret_origin = NULL; g_autofree char *origin_path = g_strconcat ("../", deployment_name, ".origin", NULL); struct stat stbuf; g_autofree char *origin_contents = NULL; ret_origin = g_key_file_new (); if (fstatat (deployment_dfd, origin_path, &stbuf, 0) != 0) { if (errno == ENOENT) ; else { glnx_set_error_from_errno (error); goto out; } } else { origin_contents = glnx_file_get_contents_utf8_at (deployment_dfd, origin_path, NULL, cancellable, error); if (!origin_contents) goto out; if (!g_key_file_load_from_data (ret_origin, origin_contents, -1, 0, error)) goto out; } ret = TRUE; gs_transfer_out_value (out_origin, &ret_origin); out: if (error) g_prefix_error (error, "Parsing %s: ", origin_path); if (ret_origin) g_key_file_unref (ret_origin); return ret; }
static GError* _client_connect(struct gridd_client_s *client) { GError *err = NULL; client->fd = _connect(client->url, &err); if (client->fd < 0) { g_assert(err != NULL); g_prefix_error(&err, "Connect error: "); return err; } EXTRA_ASSERT(err == NULL); g_get_current_time(&(client->tv_step)); client->step = CONNECTING; return NULL; }
static char * get_app_id_from_pid (pid_t pid, GError **error) { g_autofree char *path = NULL; g_autofree char *content = NULL; g_auto(GStrv) lines = NULL; int i; path = g_strdup_printf ("/proc/%u/cgroup", pid); if (!g_file_get_contents (path, &content, NULL, error)) { g_prefix_error (error, "Can't find peer app id: "); return NULL; } lines = g_strsplit (content, "\n", -1); for (i = 0; lines[i] != NULL; i++) { if (g_str_has_prefix (lines[i], "1:name=systemd:")) { const char *unit = lines[i] + strlen ("1:name=systemd:"); g_autofree char *scope = g_path_get_basename (unit); if (g_str_has_prefix (scope, "flatpak-") && g_str_has_suffix (scope, ".scope")) { const char *name = scope + strlen ("flatpak-"); char *dash = strchr (name, '-'); if (dash != NULL) { *dash = 0; return g_strdup (name); } } else { return g_strdup (""); } } } g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Can't find peer app id: No name=systemd cgroup"); return NULL; }
GSList * gcluster_get_service_types(addr_info_t *addr, long timeout, GError ** error) { EXTRA_ASSERT (addr != NULL); gchar target[STRLEN_ADDRINFO]; grid_addrinfo_to_string (addr, target, sizeof(target)); GSList *out = NULL; MESSAGE req = metautils_message_create_named (NAME_MSGNAME_CS_GET_SRVNAMES); GError *err = gridd_client_exec_and_decode (target, ((gdouble)timeout)/1000.0, message_marshall_gba_and_clean(req), &out, strings_unmarshall); if (err) { g_prefix_error (&err, "Remote: "); g_error_transmit(error, err); } return out; }
static GError* _client_connect(struct gridd_client_s *client) { GError *err = NULL; client->fd = _connect(client->url, &err); if (client->fd < 0) { EXTRA_ASSERT(err != NULL); g_prefix_error(&err, "Connect error: "); return err; } EXTRA_ASSERT(err == NULL); client->tv_step = oio_ext_monotonic_time (); client->step = CONNECTING; return NULL; }
GError * meta1_backend_user_destroy(struct meta1_backend_s *m1, struct hc_url_s *url, gboolean force) { struct sqlx_sqlite3_s *sq3 = NULL; GError *err = _open_and_lock(m1, url, SQLX_OPEN_MASTERONLY, &sq3); if (!err) { gboolean done = FALSE; if (!(err = __info_user(sq3, url, FALSE, NULL))) err = __destroy_container(sq3, url, force, &done); if (NULL != err) g_prefix_error(&err, "Query error: "); sqlx_repository_unlock_and_close_noerror(sq3); } return err; }
static GError* tl_init_command(TCrawlerBus* conn, TCrawlerReq** req, gchar* crawlerName) { GError* err = NULL; if (!crawlerName) { err = crawler_bus_reqBase_init(conn, req); } else { err = crawler_bus_req_init(conn, req, crawlerName, SERVICE_PATH, SERVICE_IFACE_CONTROL); } if (err) { g_prefix_error(&err, "Failed to connected to %s services : ", ((crawlerName)?crawlerName:"")); return err; } return NULL; }
static GabbleJingleSession * ensure_session (GabbleJingleFactory *self, const gchar *sid, const gchar *from, JingleAction action, JingleDialect dialect, gboolean *new_session, GError **error) { GabbleJingleFactoryPrivate *priv = self->priv; gchar *key; GabbleJingleSession *sess; if (!wocky_decode_jid (from, NULL, NULL, NULL)) { g_prefix_error (error, "Couldn't parse sender '%s': ", from); return NULL; } /* If we can ensure the handle, we can decode the jid */ key = make_session_map_key (from, sid); sess = g_hash_table_lookup (priv->sessions, key); g_free (key); if (sess == NULL) { if (action == JINGLE_ACTION_SESSION_INITIATE) { sess = create_session (self, sid, from, dialect, FALSE); *new_session = TRUE; } else { g_set_error (error, WOCKY_XMPP_ERROR, WOCKY_JINGLE_ERROR_UNKNOWN_SESSION, "session %s is unknown", sid); return NULL; } } else { *new_session = FALSE; } return sess; }
void _rpmostree_set_prefix_error_from_errno (GError **error, gint errsv, const char *format, ...) { gs_free char *formatted = NULL; va_list args; va_start (args, format); formatted = g_strdup_vprintf (format, args); va_end (args); _rpmostree_set_error_from_errno (error, errsv); g_prefix_error (error, "%s", formatted); errno = errsv; }
static gboolean openssl_make_dummy_cert (const gchar *key_file, const gchar *out_file, GError **error) { gboolean ret = FALSE; gint exit_status; gchar *stderr_str = NULL; gchar *command_line = NULL; gchar *subject = generate_subject (); const gchar *argv[] = { "openssl", "req", "-x509", "-days", "36500", "-newkey", "rsa:2048", "-keyout", key_file, "-keyform", "PEM", "-nodes", "-out", out_file, "-outform", "PEM", "-subj", subject, NULL }; command_line = g_strjoinv (" ", (gchar **)argv); g_info ("Generating temporary certificate using: %s", command_line); if (!g_spawn_sync (NULL, (gchar **)argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &stderr_str, &exit_status, error) || !g_spawn_check_exit_status (exit_status, error)) { g_warning ("%s", stderr_str); g_prefix_error (error, "Error generating temporary self-signed dummy cert using openssl: "); goto out; } ret = TRUE; out: g_free (stderr_str); g_free (command_line); g_free (subject); return ret; }
GError* meta1_prefixes_load(struct meta1_prefixes_set_s *m1ps, const gchar *ns_name, const gchar *local_url, GArray **updated_prefixes, gboolean *meta0_ok) { GError *err = NULL; EXTRA_ASSERT(m1ps != NULL); EXTRA_ASSERT(ns_name != NULL); EXTRA_ASSERT(local_url != NULL); err = _cache_load_from_ns(m1ps, ns_name, local_url, updated_prefixes, meta0_ok); if (NULL != err) g_prefix_error(&err, "NS loading error : "); else GRID_DEBUG("Prefixes reloaded for NS[%s]", ns_name); return err; }
GError * conscience_remote_get_namespace (const char *cs, namespace_info_t **out) { MESSAGE req = metautils_message_create_named(NAME_MSGNAME_CS_GET_NSINFO); GByteArray *gba = NULL; GError *err = gridd_client_exec_and_concat (cs, CS_CLIENT_TIMEOUT, message_marshall_gba_and_clean(req), &gba); if (err) { g_assert (gba == NULL); g_prefix_error(&err, "request: "); return err; } *out = namespace_info_unmarshall(gba->data, gba->len, &err); g_byte_array_unref (gba); if (*out) return NULL; GSETERROR(&err, "Decoding error"); return err; }
gboolean gimp_levels_config_save_cruft (GimpLevelsConfig *config, GOutputStream *output, GError **error) { GString *string; gsize bytes_written; gint i; g_return_val_if_fail (GIMP_IS_LEVELS_CONFIG (config), FALSE); g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); string = g_string_new ("# GIMP Levels File\n"); for (i = 0; i < 5; i++) { gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; g_string_append_printf (string, "%d %d %d %d %s\n", (gint) (config->low_input[i] * 255.999), (gint) (config->high_input[i] * 255.999), (gint) (config->low_output[i] * 255.999), (gint) (config->high_output[i] * 255.999), g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", config->gamma[i])); } if (! g_output_stream_write_all (output, string->str, string->len, &bytes_written, NULL, error) || bytes_written != string->len) { g_prefix_error (error, _("Writing levels file failed: ")); g_string_free (string, TRUE); return FALSE; } g_string_free (string, TRUE); return TRUE; }
static GError * __del_container_services(struct sqlx_sqlite3_s *sq3, struct oio_url_s *url, const char *srvtype, gchar **urlv) { gint64 seq; GError *err = NULL; guint line = 1; if (!urlv || !*urlv) err = __del_container_all_services(sq3, url, srvtype); else { for (; !err && *urlv ; urlv++,line++) { gchar *end = NULL; errno = 0; seq = g_ascii_strtoll(*urlv, &end, 10); if ((end == *urlv) || (!seq && errno==EINVAL)) err = NEWERROR(CODE_BAD_REQUEST, "line %u : Invalid number", line); else err = __del_container_one_service(sq3, url, srvtype, seq); } } // delete properties / services if (!err) { struct meta1_service_url_s **used = NULL; // list all services type of cid err = __get_container_all_services(sq3, url, srvtype, &used); if (err) { g_prefix_error(&err, "Preliminary lookup error : "); } else { if ((!used || !*used)) { // service type not used for this container_id... // delete all properties about cid/srvtype __del_container_srvtype_properties(sq3, url, srvtype); } } meta1_service_url_cleanv (used); } return err; }
static void write_diagnostics_cb (GObject *source, GAsyncResult *result, gpointer user_data) { g_autoptr(GisFinishedPage) self = GIS_FINISHED_PAGE (user_data); GisFinishedPagePrivate *priv = gis_finished_page_get_instance_private (self); g_autoptr(GError) error = NULL; g_autoptr(GFile) output = gis_write_diagnostics_finish (result, &error); g_application_release (G_APPLICATION (GIS_PAGE (self)->driver)); if (output != NULL) { g_autofree gchar *basename_ = g_file_get_basename (output); g_autofree gchar *link = NULL; g_autofree gchar *markup = NULL; if (priv->gedit != NULL) { g_assert (error == NULL); g_autofree gchar *url = g_file_get_uri (output); link = g_markup_printf_escaped ("<a href=\"%s\">%s</a>", url, basename_); } else { link = g_strdup (basename_); } markup = g_strdup_printf (_("A debug log has been saved as %s."), link); gtk_label_set_markup (priv->diagnostics_label, markup); } else if (error != NULL) { g_prefix_error (&error, _("Failed to save debug log: ")); gtk_label_set_text (priv->diagnostics_label, error->message); g_warning ("%s: %s", G_STRFUNC, error->message); } /* else, both possible target directories were NULL */ }
static cmsHPROFILE lcms_image_get_profile (GimpColorConfig *config, gint32 image, GError **error) { GimpParasite *parasite; cmsHPROFILE profile = NULL; g_return_val_if_fail (image != -1, NULL); parasite = gimp_image_get_parasite (image, "icc-profile"); if (parasite) { profile = gimp_lcms_profile_open_from_data (gimp_parasite_data (parasite), gimp_parasite_data_size (parasite), error); if (! profile) g_prefix_error (error, _("Error parsing 'icc-profile': ")); gimp_parasite_free (parasite); } else if (config->rgb_profile) { GFile *file = g_file_new_for_path (config->rgb_profile); profile = gimp_lcms_profile_open_from_file (file, error); if (profile && ! gimp_lcms_profile_is_rgb (profile)) { g_set_error (error, 0, 0, _("Color profile '%s' is not for RGB color space"), gimp_file_get_utf8_name (file)); cmsCloseProfile (profile); profile = NULL; } g_object_unref (file); } return profile; }
GError* meta0_backend_get_all_meta1_ref(struct meta0_backend_s *m0, GPtrArray **result) { GError *err; EXTRA_ASSERT(m0 != NULL); EXTRA_ASSERT(result != NULL); if (NULL != (err = _reload(m0, TRUE))) { g_prefix_error(&err, "Reload error: "); return err; } g_rw_lock_reader_lock(&(m0->rwlock)); EXTRA_ASSERT(m0->array_meta1_ref != NULL); *result = meta0_utils_array_meta1ref_dup(m0->array_meta1_ref); g_rw_lock_reader_unlock(&(m0->rwlock)); return NULL; }
static GError * _client_manage_reply_data(struct gridd_client_s *client) { gsize s = 0; MESSAGE reply = NULL; GError *err = NULL; s = client->reply->len; message_create(&reply, NULL); if (!message_unmarshall(reply, client->reply->data, &s, &err)) { g_prefix_error(&err, "Decoding error: "); (void) message_destroy(reply, NULL); return err; } err = _client_manage_reply(client, reply); (void) message_destroy(reply, NULL); return err; }
GError* _db_count_bean(const struct bean_descriptor_s *descr, sqlite3 *db, const gchar *clause, GVariant **params, gint64 *pcount) { GError *err = NULL; sqlite3_stmt *stmt = NULL; gint rc; EXTRA_ASSERT(descr != NULL); EXTRA_ASSERT(db != NULL); EXTRA_ASSERT(pcount != NULL); if (!clause || !*clause) err = _db_prepare_statement(db, descr->sql_count, &stmt); else { gchar *sql = g_strconcat(descr->sql_count, " WHERE ", clause, NULL); err = _db_prepare_statement(db, sql, &stmt); g_free(sql); } if (NULL != err) { g_prefix_error(&err, "Prepare error: "); return err; } if (!(err = _stmt_apply_GV_parameters(stmt, params))) { while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) { *pcount = sqlite3_column_int64(stmt, 0); } if (unlikely(!(rc == SQLITE_OK || rc == SQLITE_DONE))) { err = NEWERROR(CODE_INTERNAL_ERROR, "Got an error from sqlite: (%d) %s", rc, sqlite_strerror(rc)); } } sqlite3_finalize(stmt); stmt = NULL; return err; }
GError * _db_get_bean(const struct bean_descriptor_s *descr, sqlite3 *db, const gchar *clause, GVariant **params, on_bean_f cb, gpointer u) { GError *err = NULL; sqlite3_stmt *stmt = NULL; gint rc; g_assert(descr != NULL); g_assert(db != NULL); g_assert(params != NULL); g_assert(cb != NULL); if (!clause || !*clause) err = _db_prepare_statement(db, descr->sql_select, &stmt); else { gchar *sql = g_strconcat(descr->sql_select, " WHERE ", clause, NULL); err = _db_prepare_statement(db, sql, &stmt); g_free(sql); } if (NULL != err) { g_prefix_error(&err, "Prepare error: "); return err; } if (!(err = _stmt_apply_GV_parameters(stmt, params))) { while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) cb(u, _row_to_bean(descr, stmt)); if (unlikely(!(rc == SQLITE_OK || rc == SQLITE_DONE))) { err = NEWERROR(CODE_INTERNAL_ERROR, "Got an error from sqlite: (%d) %s", rc, sqlite_strerror(rc)); } } sqlite3_finalize(stmt); stmt = NULL; return err; }