Mercurial > pidgin.yaz
diff src/gaimrc.c @ 1560:72235e3fcff6
[gaim-migrate @ 1570]
Jason Boerner's --file patch. Also added/removed files from POTFILES.in and added the MSN protocol spec.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 10 Mar 2001 22:42:47 +0000 |
parents | ba8e6e211af5 |
children | bea407767ac1 |
line wrap: on
line diff
--- a/src/gaimrc.c Sat Mar 10 21:39:31 2001 +0000 +++ b/src/gaimrc.c Sat Mar 10 22:42:47 2001 +0000 @@ -812,54 +812,63 @@ char buf[1024]; int ver = 0; - if (getenv("HOME")) { + if (opt_rcfile_arg) + g_snprintf(buf, sizeof(buf), "%s", opt_rcfile_arg); + else if (getenv("HOME")) g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); - if ((f = fopen(buf, "r"))) { - fgets(buf, sizeof(buf), f); - sscanf(buf, "# .gaimrc v%d", &ver); - if ((ver <= 1) || (buf[0] != '#')) { - fclose(f); - set_defaults(FALSE); - save_prefs(); - load_prefs(); - return; - } + else { + set_defaults(TRUE); + return; + } + + if ((f = fopen(buf, "r"))) { + fgets(buf, sizeof(buf), f); + sscanf(buf, "# .gaimrc v%d", &ver); + if ((ver <= 1) || (buf[0] != '#')) { + fclose(f); + set_defaults(FALSE); + save_prefs(); + load_prefs(); + return; + } - while (!feof(f)) { - switch (gaimrc_parse_tag(f)) { - case -1: - /* Let the loop end, EOF */ - break; - case 0: - gaimrc_read_users(f); - break; - case 1: - gaimrc_read_options(f); - break; - case 2: - gaimrc_read_away(f); - break; + while (!feof(f)) { + switch (gaimrc_parse_tag(f)) { + case -1: + /* Let the loop end, EOF */ + break; + case 0: + gaimrc_read_users(f); + break; + case 1: + gaimrc_read_options(f); + break; + case 2: + gaimrc_read_away(f); + break; #ifdef GAIM_PLUGINS - case 3: - gaimrc_read_plugins(f); - break; + case 3: + gaimrc_read_plugins(f); + break; #endif - case 4: - gaimrc_read_pounce(f); - break; - case 5: - gaimrc_read_chat(f); - break; - case 6: - gaimrc_read_sounds(f); - break; - default: - /* NOOP */ - break; - } + case 4: + gaimrc_read_pounce(f); + break; + case 5: + gaimrc_read_chat(f); + break; + case 6: + gaimrc_read_sounds(f); + break; + default: + /* NOOP */ + break; } - fclose(f); } + fclose(f); + } else if (opt_rcfile_arg) { + g_snprintf(buf, sizeof(buf), _("Could not open config file %s."), opt_rcfile_arg); + do_error_dialog(buf, _("Preferences Error")); } if ((ver == 2) || (buf[0] != '#')) { @@ -872,22 +881,26 @@ FILE *f; char buf[BUF_LONG]; - if (getenv("HOME")) { + if (opt_rcfile_arg) + g_snprintf(buf, sizeof(buf), "%s", opt_rcfile_arg); + else if (getenv("HOME")) g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); - if ((f = fopen(buf, "w"))) { - fprintf(f, "# .gaimrc v%d\n", 4); - gaimrc_write_users(f); - gaimrc_write_options(f); - gaimrc_write_sounds(f); - gaimrc_write_away(f); - gaimrc_write_pounce(f); - gaimrc_write_chat(f); + else + return; + + if ((f = fopen(buf, "w"))) { + fprintf(f, "# .gaimrc v%d\n", 4); + gaimrc_write_users(f); + gaimrc_write_options(f); + gaimrc_write_sounds(f); + gaimrc_write_away(f); + gaimrc_write_pounce(f); + gaimrc_write_chat(f); #ifdef GAIM_PLUGINS - gaimrc_write_plugins(f); + gaimrc_write_plugins(f); #endif - fclose(f); - chmod(buf, S_IRUSR | S_IWUSR); - } + fclose(f); + chmod(buf, S_IRUSR | S_IWUSR); } }