Drop all sections from the state file whose name contains partial_name.
This function is meant to be called when an object is deleted for which state is kept. For example, when an account is deleted from GnuCash, all state sections that refer to it should get removed. In that case you can call this function with the account's guid as parameter.
267 gint found_count = 0, dropped_count = 0;
269 GError *error = NULL;
273 PWARN (
"No pre-existing state found, ignoring drop request");
279 groups = g_key_file_get_groups (state_file, &num_groups);
280 for (i = 0; i < num_groups; i++)
282 if (g_strstr_len (groups[i], -1, partial_name))
284 DEBUG (
"Section \"%s\" matches \"%s\", removing", groups[i], partial_name);
286 if (!g_key_file_remove_group (state_file, groups[i], &error))
288 PWARN (
"Warning: unable to remove section %s.\n %s",
291 g_error_free (error);
300 LEAVE(
"Found %i sections matching \"%s\", successfully removed %i",
301 found_count, partial_name, dropped_count);
302 return dropped_count;
#define DEBUG(format, args...)
#define ENTER(format, args...)
#define PWARN(format, args...)
#define LEAVE(format, args...)