#include "prefs_common.h"
#include "prefs_gtk.h"
#include "prefs_migration.h"
+#include "file-utils.h"
static GSList *_password_store;
else
p = password;
- debug_print("%s password '%s' in block (%d/%s)%s\n",
- (p == NULL ? "Deleting" : "Storing"),
- password_id, block_type, block_name,
- (encrypted ? ", already encrypted" : "") );
-
/* find correct block (create if needed) */
if ((block = _get_block(block_type, block_name)) == NULL) {
/* If caller wants to delete a password, and even its block
}
}
+ debug_print("%s password for '%s' in block (%d/%s)%s\n",
+ (p == NULL ? "Deleting" : "Storing"),
+ password_id, block_type, block_name,
+ (encrypted ? ", already encrypted" : "") );
+
if (p == NULL) {
/* NULL password was passed to us, so delete the entry with
* corresponding id */
debug_print("Reencrypting passwords in block (%d/%s).\n",
block->block_type, block->block_name);
- if (g_hash_table_size(block->entries) == 0)
+ if (block->entries == NULL || g_hash_table_size(block->entries) == 0)
continue;
keys = g_hash_table_get_keys(block->entries);
/* Write out the config_version */
line = g_strdup_printf("[config_version:%d]\n", CLAWS_CONFIG_VERSION);
- if (fputs(line, fp) == EOF) {
- FILE_OP_ERROR("password store, config_version", "fputs");
+ if (claws_fputs(line, fp) == EOF) {
+ FILE_OP_ERROR("password store, config_version", "claws_fputs");
g_free(line);
return -1;
}
g_free(line);
/* Add a newline if needed */
- if (_password_store != NULL && fputs("\n", fp) == EOF) {
- FILE_OP_ERROR("password store", "fputs");
+ if (_password_store != NULL && claws_fputs("\n", fp) == EOF) {
+ FILE_OP_ERROR("password store", "claws_fputs");
return -1;
}
continue; /* Just in case. */
/* Do not save empty blocks. */
- if (g_hash_table_size(block->entries) == 0)
+ if (block->entries == NULL || g_hash_table_size(block->entries) == 0)
continue;
/* Prepare the section header string and write it out. */
}
line = g_strdup_printf("[%s:%s]\n", typestr, block->block_name);
- if (fputs(line, fp) == EOF) {
- FILE_OP_ERROR("password store", "fputs");
+ if (claws_fputs(line, fp) == EOF) {
+ FILE_OP_ERROR("password store", "claws_fputs");
g_free(line);
return -1;
}
continue;
line = g_strdup_printf("%s %s\n", key, pwd);
- if (fputs(line, fp) == EOF) {
- FILE_OP_ERROR("password store", "fputs");
+ if (claws_fputs(line, fp) == EOF) {
+ FILE_OP_ERROR("password store", "claws_fputs");
g_free(line);
return -1;
}
g_list_free(keys);
/* Add a separating new line if there is another block remaining */
- if (item->next != NULL && fputs("\n", fp) == EOF) {
- FILE_OP_ERROR("password store", "fputs");
+ if (item->next != NULL && claws_fputs("\n", fp) == EOF) {
+ FILE_OP_ERROR("password store", "claws_fputs");
return -1;
}