Ejemplo n.º 1
0
int
save_config (void)
{
	int fh, i;
	char *config, *new_config;

	check_prefs_dir ();

	config = default_file ();
	new_config = g_strconcat (config, ".new", NULL);
	
	fh = g_open (new_config, OFLAGS | O_TRUNC | O_WRONLY | O_CREAT, 0600);
	if (fh == -1)
	{
		g_free (new_config);
		return 0;
	}

	if (!cfg_put_str (fh, "version", PACKAGE_VERSION))
	{
		g_free (new_config);
		return 0;
	}
		
	i = 0;
	do
	{
		switch (vars[i].type)
		{
		case TYPE_STR:
			if (!cfg_put_str (fh, vars[i].name, (char *) &prefs + vars[i].offset))
			{
				g_free (new_config);
				return 0;
			}
			break;
		case TYPE_INT:
		case TYPE_BOOL:
			if (!cfg_put_int (fh, *((int *) &prefs + vars[i].offset), vars[i].name))
			{
				g_free (new_config);
				return 0;
			}
		}
		i++;
	}
	while (vars[i].name);

	if (close (fh) == -1)
	{
		g_free (new_config);
		return 0;
	}

#ifdef WIN32
	g_unlink (config);	/* win32 can't rename to an existing file */
#endif
	if (g_rename (new_config, config) == -1)
	{
		g_free (new_config);
		return 0;
	}
	g_free (new_config);

	return 1;
}
Ejemplo n.º 2
0
void
load_config (void)
{
	char *cfg, *sp, *buf;
	const char *username, *realname;
	int res, val, i;
#ifdef WIN32
	char out[256];
#endif

	check_prefs_dir ();
	username = g_get_user_name ();
	if (!username)
		username = "******";

	/* We hid Real name from the Network List, so don't use the user's name unnoticeably */
	/* realname = g_get_real_name ();
	if ((realname && realname[0] == 0) || !realname)
		realname = username; */
	realname = "realname";

	username = convert_with_fallback (username, "username");
	realname = convert_with_fallback (realname, "realname");

	memset (&prefs, 0, sizeof (struct hexchatprefs));

	/* put in default values, anything left out is automatically zero */
	
	/* BOOLEANS */
	prefs.hex_away_show_once = 1;
	prefs.hex_away_track = 1;
	prefs.hex_dcc_auto_resume = 1;
#ifndef WIN32
	prefs.hex_dcc_fast_send = 1;
#endif
	prefs.hex_gui_autoopen_chat = 1;
	prefs.hex_gui_autoopen_dialog = 1;
	prefs.hex_gui_autoopen_recv = 1;
	prefs.hex_gui_autoopen_send = 1;
	prefs.hex_gui_input_icon = 1;
	prefs.hex_gui_input_nick = 1;
	prefs.hex_gui_input_spell = 1;
	prefs.hex_gui_input_style = 1;
	prefs.hex_gui_join_dialog = 1;
	prefs.hex_gui_quit_dialog = 1;
	/* prefs.hex_gui_slist_skip = 1; */
	prefs.hex_gui_tab_chans = 1;
	prefs.hex_gui_tab_dialogs = 1;
	prefs.hex_gui_tab_dots = 1;
	prefs.hex_gui_tab_icons = 1;
	prefs.hex_gui_tab_server = 1;
	prefs.hex_gui_tab_sort = 1;
	prefs.hex_gui_topicbar = 1;
	prefs.hex_gui_tray = 1;
	prefs.hex_gui_tray_blink = 1;
	prefs.hex_gui_ulist_count = 1;
	prefs.hex_gui_ulist_icons = 1;
	prefs.hex_gui_ulist_resizable = 1;
	prefs.hex_gui_ulist_style = 1;
	prefs.hex_gui_win_save = 1;
	prefs.hex_identd = 1;
	prefs.hex_input_flash_hilight = 1;
	prefs.hex_input_flash_priv = 1;
	prefs.hex_input_tray_hilight = 1;
	prefs.hex_input_tray_priv = 1;
	/* prefs.hex_irc_who_join = 1; prevent kicks and bans caused by overwhelming who'ing after reconnects */
	prefs.hex_irc_whois_front = 1;
	prefs.hex_net_auto_reconnect = 1;
	prefs.hex_net_throttle = 1;
	prefs.hex_stamp_log = 1;
	prefs.hex_stamp_text = 1;
	prefs.hex_text_autocopy_text = 1;
	prefs.hex_text_indent = 1;
	prefs.hex_text_replay = 1;
	prefs.hex_text_search_follow = 1;
	prefs.hex_text_show_marker = 1;
	prefs.hex_text_show_sep = 1;
	prefs.hex_text_stripcolor_replay = 1;
	prefs.hex_text_stripcolor_topic = 1;
	prefs.hex_text_thin_sep = 1;
	prefs.hex_text_wordwrap = 1;
	prefs.hex_url_grabber = 1;

	/* NUMBERS */
	prefs.hex_away_size_max = 300;
	prefs.hex_away_timeout = 60;
	prefs.hex_completion_amount = 5;
	prefs.hex_dcc_auto_recv = 1;			/* browse mode */
	prefs.hex_dcc_blocksize = 1024;
	prefs.hex_dcc_permissions = 0600;
	prefs.hex_dcc_stall_timeout = 60;
	prefs.hex_dcc_timeout = 180;
	prefs.hex_flood_ctcp_num = 5;
	prefs.hex_flood_ctcp_time = 30;
	prefs.hex_flood_msg_num = 5;
	/*FIXME*/ prefs.hex_flood_msg_time = 30;
	prefs.hex_gui_chanlist_maxusers = 9999;
	prefs.hex_gui_chanlist_minusers = 5;
	prefs.hex_gui_dialog_height = 256;
	prefs.hex_gui_dialog_width = 500;
	prefs.hex_gui_lagometer = 1;
	prefs.hex_gui_lang = 15;
	prefs.hex_gui_pane_left_size = 128;		/* with treeview icons we need a bit bigger space */
	prefs.hex_gui_pane_right_size = 100;
	prefs.hex_gui_pane_right_size_min = 80;
	prefs.hex_gui_tab_layout = 2;			/* 0=Tabs 1=Reserved 2=Tree */
	prefs.hex_gui_tab_newtofront = 2;
	prefs.hex_gui_tab_pos = 1;
	prefs.hex_gui_tab_trunc = 20;
	prefs.hex_gui_throttlemeter = 1;
	prefs.hex_gui_ulist_pos = 3;
	prefs.hex_gui_win_height = 400;
	prefs.hex_gui_win_width = 640;
	prefs.hex_input_balloon_time = 20;
	prefs.hex_irc_ban_type = 2;
	prefs.hex_irc_join_delay = 3;
	prefs.hex_net_reconnect_delay = 10;
	prefs.hex_notify_timeout = 15;
	prefs.hex_text_max_indent = 256;
	prefs.hex_text_max_lines = 500;
	prefs.hex_text_tint_blue = 195;
	prefs.hex_text_tint_green = 195;
	prefs.hex_text_tint_red = 195;
	prefs.hex_url_grabber_limit = 100; 		/* 0 means unlimited */

	/* STRINGS */
	strcpy (prefs.hex_away_reason, _("I'm busy"));
	strcpy (prefs.hex_completion_suffix, ",");
#ifdef WIN32
	if (portable_mode () || !get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal", out, sizeof (out)))
	{
		snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\downloads", get_xdir ());
	}
	else
	{
		snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\Downloads", out);
	}
#else
	if (g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD))
		strcpy (prefs.hex_dcc_dir, g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD));
	else
		strcpy (prefs.hex_dcc_dir, g_build_filename (g_get_home_dir (), "Downloads", NULL));
#endif
	strcpy (prefs.hex_dnsprogram, "host");
	strcpy (prefs.hex_gui_ulist_doubleclick, "QUERY %s");
	strcpy (prefs.hex_input_command_char, "/");
	strcpy (prefs.hex_irc_logmask, "%n-%c.log");
	strcpy (prefs.hex_irc_nick1, username);
	strcpy (prefs.hex_irc_nick2, username);
	strcat (prefs.hex_irc_nick2, "_");
	strcpy (prefs.hex_irc_nick3, username);
	strcat (prefs.hex_irc_nick3, "__");
	strcpy (prefs.hex_irc_no_hilight, "NickServ,ChanServ,InfoServ,N,Q");
	strcpy (prefs.hex_irc_part_reason, _("Leaving"));
	strcpy (prefs.hex_irc_quit_reason, prefs.hex_irc_part_reason);
	strcpy (prefs.hex_irc_real_name, realname);
	strcpy (prefs.hex_irc_user_name, username);
	snprintf (prefs.hex_sound_dir, sizeof (prefs.hex_sound_dir), "%s" G_DIR_SEPARATOR_S "sounds", get_xdir ());
	strcpy (prefs.hex_stamp_log_format, "%b %d %H:%M:%S ");
	strcpy (prefs.hex_stamp_text_format, "[%H:%M:%S] ");
#ifdef WIN32
	if (find_font ("Consolas"))
	{
		strcpy (prefs.hex_text_font, "Consolas 10");
		strcpy (prefs.hex_text_font_main, "Consolas 10");
	}
	else
	{
		strcpy (prefs.hex_text_font, DEF_FONT);
		strcpy (prefs.hex_text_font_main, DEF_FONT);
	}
#else
	strcpy (prefs.hex_text_font, DEF_FONT);
	strcpy (prefs.hex_text_font_main, DEF_FONT);
#endif
	strcpy (prefs.hex_text_font_alternative, DEF_FONT_ALTER);
	strcpy (prefs.hex_text_spell_langs, g_getenv ("LC_ALL") ? g_getenv ("LC_ALL") : "en_US");

	/* private variables */
	prefs.local_ip = 0xffffffff;

	g_free ((char *)username);
	g_free ((char *)realname);

	if (g_file_get_contents (default_file (), &cfg, NULL, NULL))
	{
		i = 0;
		do
		{
			switch (vars[i].type)
			{
			case TYPE_STR:
				cfg_get_str (cfg, vars[i].name, (char *) &prefs + vars[i].offset,
								 vars[i].len);
				break;
			case TYPE_BOOL:
			case TYPE_INT:
				val = cfg_get_int_with_result (cfg, vars[i].name, &res);
				if (res)
					*((int *) &prefs + vars[i].offset) = val;
				break;
			}
			i++;
		}
		while (vars[i].name);

		g_free (cfg);

	} else
	{
#ifndef WIN32
#ifndef __EMX__
		/* OS/2 uses UID 0 all the time */
		if (getuid () == 0)
			fe_message (_("* Running IRC as root is stupid! You should\n"
							"  create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT);
#endif
#endif /* !WIN32 */

		g_mkdir (prefs.hex_dcc_dir, 0700);
		g_mkdir (prefs.hex_dcc_completed_dir, 0700);

		buf = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "addons", get_xdir ());
		g_mkdir (buf, 0700);
		g_free (buf);
	}
	if (prefs.hex_gui_win_height < 138)
		prefs.hex_gui_win_height = 138;
	if (prefs.hex_gui_win_width < 106)
		prefs.hex_gui_win_width = 106;

	sp = strchr (prefs.hex_irc_user_name, ' ');
	if (sp)
		sp[0] = 0;	/* spaces in username would break the login */
}
Ejemplo n.º 3
0
int
save_config (void)
{
    int fh, i;
    char *new_config, *config;

    check_prefs_dir ();

    config = default_file ();
    new_config = malloc (strlen (config) + 5);
    strcpy (new_config, config);
    strcat (new_config, ".new");

    fh = open (new_config, OFLAGS | O_TRUNC | O_WRONLY | O_CREAT, 0600);
    if (fh == -1)
    {
        free (new_config);
        return 0;
    }

    if (!cfg_put_str (fh, "version", PACKAGE_VERSION))
    {
        free (new_config);
        return 0;
    }

    i = 0;
    do
    {
        switch (vars[i].type)
        {
        case TYPE_STR:
            if (!cfg_put_str (fh, vars[i].name, (char *) &prefs + vars[i].offset))
            {
                free (new_config);
                return 0;
            }
            break;
        case TYPE_INT:
        case TYPE_BOOL:
            if (!cfg_put_int (fh, *((int *) &prefs + vars[i].offset), vars[i].name))
            {
                free (new_config);
                return 0;
            }
        }
        i++;
    }
    while (vars[i].name);

    if (close (fh) == -1)
    {
        free (new_config);
        return 0;
    }

    if (rename (new_config, config) == -1)
    {
        free (new_config);
        return 0;
    }
    free (new_config);

    return 1;
}
Ejemplo n.º 4
0
void
load_config (void)
{
	struct stat st;
	char *cfg, *sp;
	const char *username, *realname;
	int res, val, i, fh;

	check_prefs_dir ();
	username = g_get_user_name ();
	if (!username)
		username = "******";

	/* We hid Real name from the Network List, so don't use the user's name unnoticeably */
	/* realname = g_get_real_name ();
	if ((realname && realname[0] == 0) || !realname)
		realname = username; */
	realname = "realname";

	username = convert_with_fallback (username, "username");
	realname = convert_with_fallback (realname, "realname");

	memset (&prefs, 0, sizeof (struct xchatprefs));

	/* put in default values, anything left out is automatically zero */
	prefs.local_ip = 0xffffffff;
	prefs.irc_join_delay = 3;
	prefs.show_marker = 1;
	prefs.newtabstofront = 2;
	prefs.completion_amount = 5;
	prefs.away_timeout = 60;
	prefs.away_size_max = 300;
	prefs.away_track = 1;
	prefs.timestamp_logs = 1;
	prefs.truncchans = 20;
	prefs.autoresume = 1;
	prefs.show_away_once = 1;
	prefs.indent_nicks = 1;
	prefs.thin_separator = 1;
	prefs._tabs_position = 2; /* 2 = left */
#ifndef WIN32
	prefs.fastdccsend = 1;
#endif
	prefs.wordwrap = 1;
	prefs.autodialog = 1;
	prefs.gui_input_spell = 1;
	prefs.autoreconnect = 1;
	prefs.recon_delay = 10;
	prefs.autocopy_text = 1;
	prefs.text_replay = 1;
	prefs.text_stripcolor_replay = 1;
	prefs.text_stripcolor_topic = 1;
	prefs.tabchannels = 1;
	prefs.tab_layout = 2;	/* 0=Tabs 1=Reserved 2=Tree */
	prefs.tab_icons = 1;
	prefs.tab_sort = 1;
	prefs.paned_userlist = 1;
	prefs.newtabstofront = 2;
	prefs.use_server_tab = 1;
	prefs.privmsgtab = 1;
	/* prefs.colorednicks = 1; */
	prefs.style_inputbox = 1;
	prefs.style_namelistgad = 1;
	prefs.dccpermissions = 0600;
	prefs.max_lines = 500;
	prefs.mainwindow_width = 640;
	prefs.mainwindow_height = 400;
	prefs.dialog_width = 500;
	prefs.dialog_height = 256;
	prefs.gui_join_dialog = 1;
	prefs.gui_quit_dialog = 1;
	prefs.dcctimeout = 180;
	prefs.dccstalltimeout = 60;
	prefs.notify_timeout = 15;
	prefs.tint_red =
		prefs.tint_green =
		prefs.tint_blue = 195;
	prefs.auto_indent = 1;
	prefs.max_auto_indent = 256;
	prefs.show_separator = 1;
	prefs.dcc_blocksize = 1024;
	prefs.throttle = 1;
	 /*FIXME*/ prefs.msg_time_limit = 30;
	prefs.msg_number_limit = 5;
	prefs.ctcp_time_limit = 30;
	prefs.ctcp_number_limit = 5;
	prefs.topicbar = 1;
	prefs.lagometer = 1;
	prefs.throttlemeter = 1;
	prefs.autoopendccrecvwindow = 1;
	prefs.autoopendccsendwindow = 1;
	prefs.autoopendccchatwindow = 1;
	/* prevent kicks and bans caused by overwhelming who'ing after reconnects */
	/* prefs.userhost = 1; */
	prefs.gui_chanlist_maxusers = 9999;
	prefs.gui_chanlist_minusers = 5;
	prefs.gui_tray = 1;
	prefs.gui_pane_left_size = 128;		/* with treeview icons we need a bit bigger space */
	prefs.gui_pane_right_size = 100;
	prefs.gui_pane_right_size_min = 80;
	prefs.mainwindow_save = 1;
	prefs.bantype = 2;
	prefs.input_balloon_time = 20;
	prefs.input_flash_priv = prefs.input_flash_hilight = 1;
	prefs.input_tray_priv = prefs.input_tray_hilight = 1;
	prefs.autodccsend = 2;	/* browse mode */
	prefs.url_grabber = 1;
	prefs.url_grabber_limit = 100; /* 0 means unlimited */
	prefs.text_search_follow = 1;
	prefs.timestamp = 1;
#ifdef WIN32
	prefs.identd = 1;
#endif
	strcpy (prefs.spell_langs, g_getenv ("LC_ALL") ? g_getenv ("LC_ALL") : "en_US");
	strcpy (prefs.stamp_format, "[%H:%M:%S] ");
	strcpy (prefs.timestamp_log_format, "%b %d %H:%M:%S ");
	strcpy (prefs.logmask, "%n-%c.log");
	strcpy (prefs.nick_suffix, ",");
	strcpy (prefs.cmdchar, "/");
	strcpy (prefs.nick1, username);
	strcpy (prefs.nick2, username);
	strcat (prefs.nick2, "_");
	strcpy (prefs.nick3, username);
	strcat (prefs.nick3, "__");
	strcpy (prefs.realname, realname);
	strcpy (prefs.username, username);
#ifdef WIN32
	strcpy (prefs.sounddir, "./sounds");
	{
		char out[256];

		if (portable_mode () || !get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal", out, sizeof (out)))
		{
			snprintf (prefs.dccdir, sizeof (prefs.dccdir), "%s\\downloads", get_xdir_utf8 ());
		}
		else
		{
			snprintf (prefs.dccdir, sizeof (prefs.dccdir), "%s\\Downloads", out);
		}
	}
#else
	snprintf (prefs.sounddir, sizeof (prefs.sounddir), "%s/sounds", get_xdir_utf8 ());
	snprintf (prefs.dccdir, sizeof (prefs.dccdir), "%s/downloads", get_xdir_utf8 ());
#endif
	strcpy (prefs.doubleclickuser, "QUOTE WHOIS %s %s");
	strcpy (prefs.awayreason, _("I'm busy"));
	strcpy (prefs.quitreason, _("Leaving"));
	strcpy (prefs.partreason, prefs.quitreason);
	strcpy (prefs.font_normal, DEF_FONT);
#ifdef WIN32
	strcpy (prefs.font_main, DEF_FONT);
	strcpy (prefs.font_alternative, DEF_FONT_ALTER);
#endif
	strcpy (prefs.dnsprogram, "host");
	strcpy (prefs.irc_no_hilight, "NickServ,ChanServ,InfoServ,N,Q");

	g_free ((char *)username);
	g_free ((char *)realname);

	fh = open (default_file (), OFLAGS | O_RDONLY);
	if (fh != -1)
	{
		fstat (fh, &st);
		cfg = malloc (st.st_size + 1);
		cfg[0] = '\0';
		i = read (fh, cfg, st.st_size);
		if (i >= 0)
			cfg[i] = '\0';					/* make sure cfg is NULL terminated */
		close (fh);
		i = 0;
		do
		{
			switch (vars[i].type)
			{
			case TYPE_STR:
				cfg_get_str (cfg, vars[i].name, (char *) &prefs + vars[i].offset,
								 vars[i].len);
				break;
			case TYPE_BOOL:
			case TYPE_INT:
				val = cfg_get_int_with_result (cfg, vars[i].name, &res);
				if (res)
					*((int *) &prefs + vars[i].offset) = val;
				break;
			}
			i++;
		}
		while (vars[i].name);

		free (cfg);

	} else
	{
#ifndef WIN32
#ifndef __EMX__
		/* OS/2 uses UID 0 all the time */
		if (getuid () == 0)
			fe_message (_("* Running IRC as root is stupid! You should\n"
							"  create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT);
#endif
#endif /* !WIN32 */

		mkdir_utf8 (prefs.dccdir);
		mkdir_utf8 (prefs.dcc_completed_dir);
	}
	if (prefs.mainwindow_height < 138)
		prefs.mainwindow_height = 138;
	if (prefs.mainwindow_width < 106)
		prefs.mainwindow_width = 106;

	sp = strchr (prefs.username, ' ');
	if (sp)
		sp[0] = 0;	/* spaces in username would break the login */

	/* try to make sense of old ulist/tree position settings */
	if (prefs.gui_ulist_pos == 0)
	{
		prefs.gui_ulist_pos = 3;	/* top right */
		if (prefs._gui_ulist_left)
			prefs.gui_ulist_pos = 2;	/* bottom left */

		switch (prefs._tabs_position)
		{
		case 0:
			prefs.tab_pos = 6; /* bottom */
			break;
		case 1:
			prefs.tab_pos = 5;	/* top */
			break;
		case 2:
			prefs.tab_pos = 1; 	/* left */
			break;
		case 3:
			prefs.tab_pos = 4; 	/* right */
			break;
		case 4:
			prefs.tab_pos = 1;	/* (hidden)left */
			break;
		case 5:
			if (prefs._gui_ulist_left)
			{
				prefs.tab_pos = 1; 	/* above ulist left */
				prefs.gui_ulist_pos = 2;
			}
			else
			{
				prefs.tab_pos = 3; 	/* above ulist right */
				prefs.gui_ulist_pos = 4;
			}
			break;
		}
	}
}
Ejemplo n.º 5
0
void
load_config (void)
{
    struct stat st;
    char *cfg, *sp;
    const char *username, *realname;
    int res, val, i, fh;

    check_prefs_dir ();
    username = g_get_user_name ();
    if (!username)
        username = "******";

    realname = g_get_real_name ();
    if ((realname && realname[0] == 0) || !realname)
        realname = username;

    username = convert_with_fallback (username, "username");
    realname = convert_with_fallback (realname, "realname");

    memset (&prefs, 0, sizeof (struct xchatprefs));

    /* put in default values, anything left out is automatically zero */
    prefs.local_ip = 0xffffffff;
    prefs.irc_join_delay = 3;
    prefs.show_marker = 1;
    prefs.newtabstofront = 2;
    prefs.completion_amount = 9001;
    prefs.away_timeout = 60;
    prefs.away_size_max = 300;
    prefs.away_track = 1;
    prefs.timestamp_logs = 1;
    prefs.truncchans = 20;
    prefs.autoresume = 1;
    prefs.show_away_once = 1;
    prefs.indent_nicks = 1;
    prefs.thin_separator = 1;
    prefs._tabs_position = 2;   /* 2 = left */
    prefs.fastdccsend = 1;
    prefs.wordwrap = 1;
    prefs.autosave = 1;
    prefs.autodialog = 1;
    prefs.gui_input_spell = 1;
    prefs.autoreconnect = 1;
    prefs.recon_delay = 0;
    prefs.completion_sort = 1;
    prefs.tabchannels = 1;
    prefs.tab_layout = 2;       /* 0=Tabs 1=Reserved 2=Tree */
    prefs.tab_sort = 1;
    prefs.blink_timeout = 30;
    prefs.data_color = 2; /* 2 = blink once */
    prefs.talk_color = 1; /* 1 = stay solid */
    prefs.hilite_color = 1;
    prefs.paned_userlist = 1;
    prefs.newtabstofront = 2;
    prefs.use_server_tab = 1;
    prefs.privmsgtab = 1;
    /*prefs.style_inputbox = 1; */
    prefs.dccpermissions = 0600;
    prefs.max_lines = 500;
    prefs.mainwindow_width = 640;
    prefs.mainwindow_height = 400;
    prefs.dialog_width = 500;
    prefs.dialog_height = 256;
    prefs.gui_join_dialog = 1;
    prefs.gui_quit_dialog = 1;
    prefs.chanmodebuttons = 1;
    prefs.dcctimeout = 180;
    prefs.dccstalltimeout = 60;
    prefs.notify_timeout = 15;
    prefs.tint_red = prefs.tint_green = prefs.tint_blue = 195;
    prefs.auto_indent = 1;
    prefs.max_auto_indent = 256;
    prefs.show_separator = 1;
    prefs.dcc_blocksize = 1024;
    /*FIXME*/ prefs.msg_time_limit = 30;
    prefs.msg_number_limit = 5;
    prefs.ctcp_time_limit = 30;
    prefs.ctcp_number_limit = 5;
    prefs.topicbar = 1;
    prefs.lagometer = 1;
    prefs.raw_modes = 1;
    prefs.throttlemeter = 1;
    prefs.autoopendccrecvwindow = 1;
    prefs.autoopendccsendwindow = 1;
    prefs.autoopendccchatwindow = 1;
    prefs.userhost = 1;
    prefs.gui_url_mod = 4;      /* ctrl */
    prefs.gui_tray = 1;
    prefs.gui_pane_left_size = 100;
    prefs.gui_pane_right_size = 100;
    prefs.mainwindow_save = 1;
    prefs.bantype = 1;
    prefs.colorednicks = 1;
    prefs.input_balloon_time = 20;
    prefs.input_flash_priv = prefs.input_flash_hilight = 1;
    prefs.input_tray_priv = prefs.input_tray_hilight = 1;
    prefs.autodccsend = 2;      /* browse mode */
    prefs.logging = 1;
    strcpy (prefs.stamp_format, "[%H:%M] ");
    strcpy (prefs.timestamp_log_format, "[%b %d %Y @ %I:%M:%S%p] ");
    strcpy (prefs.logmask, "%n-%c.log");
    strcpy (prefs.nick_suffix, ",");
    strcpy (prefs.cmdchar, "/");
    strcpy (prefs.nick1, username);
    strcpy (prefs.nick2, username);
    strcat (prefs.nick2, "_");
    strcpy (prefs.nick3, username);
    strcat (prefs.nick3, "__");
    strcpy (prefs.realname, realname);
    strcpy (prefs.username, username);
    strcpy (prefs.doubleclickuser, "QUERY %s");
    strcpy (prefs.awayreason, _("I'm busy"));
    strcpy (prefs.quitreason, "GChat - http://gchat.notroll.net");
    strcpy (prefs.partreason, prefs.quitreason);
    strcpy (prefs.font_normal, DEF_FONT);
    strcpy (prefs.dnsprogram, "host");
    strcpy (prefs.irc_no_hilight, "NickServ,ChanServ");

    g_free ((char *) username);
    g_free ((char *) realname);

    fh = open (default_file (), OFLAGS | O_RDONLY);
    if (fh != -1)
    {
        fstat (fh, &st);
        cfg = malloc (st.st_size + 1);
        cfg[0] = '\0';
        i = read (fh, cfg, st.st_size);
        if (i >= 0)
            cfg[i] = '\0';    /* make sure cfg is NULL terminated */
        close (fh);
        i = 0;
        do
        {
            switch (vars[i].type)
            {
            case TYPE_STR:
                cfg_get_str (cfg, vars[i].name,
                             (char *) &prefs + vars[i].offset,
                             vars[i].len);
                break;
            case TYPE_BOOL:
            case TYPE_INT:
                val = cfg_get_int_with_result (cfg, vars[i].name, &res);
                if (res)
                    *((int *) &prefs + vars[i].offset) = val;
                break;
            }
            i++;
        }
        while (vars[i].name);

        free (cfg);

    }
    else
    {
#ifndef __EMX__
        /* OS/2 uses UID 0 all the time */
        if (getuid () == 0)
            fe_message (_("* Running IRC as root is stupid! You should\n"
                          "  create a User Account and use that to login.\n"),
                        FE_MSG_WARN | FE_MSG_WAIT);
#endif

        mkdir_utf8 (prefs.dccdir);
        mkdir_utf8 (prefs.dcc_completed_dir);
    }
    if (prefs.mainwindow_height < 138)
        prefs.mainwindow_height = 138;
    if (prefs.mainwindow_width < 106)
        prefs.mainwindow_width = 106;

    sp = strchr (prefs.username, ' ');
    if (sp)
        sp[0] = 0;              /* spaces in username would break the login */

    /* try to make sense of old ulist/tree position settings */
    if (prefs.gui_ulist_pos == 0)
    {
        prefs.gui_ulist_pos = 3;      /* top right */
        if (prefs._gui_ulist_left)
            prefs.gui_ulist_pos = 2;  /* bottom left */

        switch (prefs._tabs_position)
        {
        case 0:
            prefs.tab_pos = 6;      /* bottom */
            break;
        case 1:
            prefs.tab_pos = 5;      /* top */
            break;
        case 2:
            prefs.tab_pos = 1;      /* left */
            break;
        case 3:
            prefs.tab_pos = 4;      /* right */
            break;
        case 4:
            prefs.tab_pos = 1;      /* (hidden)left */
            break;
        case 5:
            if (prefs._gui_ulist_left)
            {
                prefs.tab_pos = 1;        /* above ulist left */
                prefs.gui_ulist_pos = 2;
            }
            else
            {
                prefs.tab_pos = 3;        /* above ulist right */
                prefs.gui_ulist_pos = 4;
            }
            break;
        }
    }
}