コード例 #1
0
ファイル: prefs_account.c プロジェクト: myclub2/sylpheed
void prefs_account_write_config_all(GList *account_list)
{
	GList *cur;
	gchar *rcpath;
	PrefFile *pfile;

	rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
	if ((pfile = prefs_file_open(rcpath)) == NULL) {
		g_free(rcpath);
		return;
	}
	g_free(rcpath);

	for (cur = account_list; cur != NULL; cur = cur->next) {
		tmp_ac_prefs = *(PrefsAccount *)cur->data;
		if (fprintf(pfile->fp, "[Account: %d]\n",
			    tmp_ac_prefs.account_id) <= 0 ||
		    prefs_file_write_param(pfile, param) < 0) {
			g_warning(_("failed to write configuration to file\n"));
			prefs_file_close_revert(pfile);
			return;
		}
		if (cur->next) {
			if (fputc('\n', pfile->fp) == EOF) {
				FILE_OP_ERROR(rcpath, "fputc");
				prefs_file_close_revert(pfile);
				return;
			}
		}
	}

	if (prefs_file_close(pfile) < 0)
		g_warning(_("failed to write configuration to file\n"));
}
コード例 #2
0
void prefs_display_header_write_config(void)
{
    gchar *rcpath;
    PrefFile *pfile;
    GSList *cur;

    debug_print(_("Writing configuration for displaying headers...\n"));

    rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                         DISPLAY_HEADER_RC, NULL);

    if ((pfile = prefs_file_open(rcpath)) == NULL) {
        g_warning(_("failed to write configuration to file\n"));
        g_free(rcpath);
        return;
    }

    for (cur = prefs_common.disphdr_list; cur != NULL;
            cur = cur->next) {
        DisplayHeaderProp *dp = (DisplayHeaderProp *)cur->data;
        gchar *dpstr;

        dpstr = display_header_prop_get_str(dp);
        if (fputs(dpstr, pfile->fp) == EOF ||
                fputc('\n', pfile->fp) == EOF) {
            FILE_OP_ERROR(rcpath, "fputs || fputc");
            prefs_file_close_revert(pfile);
            g_free(rcpath);
            g_free(dpstr);
            return;
        }
        g_free(dpstr);
    }

    g_free(rcpath);

    if (prefs_file_close(pfile) < 0) {
        g_warning(_("failed to write configuration to file\n"));
        return;
    }
}