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.
263 gint found_count = 0, dropped_count = 0;
265 GError *error = NULL;
269 PWARN (
"No pre-existing state found, ignoring drop request");
275 groups = g_key_file_get_groups (state_file, &num_groups);
276 for (i = 0; i < num_groups; i++)
278 if (g_strstr_len (groups[i], -1, partial_name))
280 DEBUG (
"Section \"%s\" matches \"%s\", removing", groups[i], partial_name);
282 if (!g_key_file_remove_group (state_file, groups[i], &error))
284 PWARN (
"Warning: unable to remove section %s.\n %s",
287 g_error_free (error);
296 LEAVE(
"Found %i sections matching \"%s\", successfully removed %i",
297 found_count, partial_name, dropped_count);
298 return dropped_count;
#define DEBUG(format, args...)
Print a debugging message.
#define ENTER(format, args...)
Print a function entry debugging message.
#define PWARN(format, args...)
Log a warning.
#define LEAVE(format, args...)
Print a function exit debugging message.