コード例 #1
0
ファイル: init.c プロジェクト: OS2World/APP-INTERNET-NFTP
void write_config (void)
{
    char    cfgfile[MAX_PATH], *p;
    int     rc, x0, y0, i;

    rc = video_get_window_pos (&x0, &y0);
    if (rc == 0)
    {
        cfg_set_integer (CONFIG_NFTP, fl_opt.platform_nick, "x0", x0);
        cfg_set_integer (CONFIG_NFTP, fl_opt.platform_nick, "y0", y0);
    }

    cfg_set_integer (CONFIG_NFTP, fl_opt.platform_nick, "rows", video_vsize());
    cfg_set_integer (CONFIG_NFTP, fl_opt.platform_nick, "cols", video_hsize());

    for (i=0; i<sizeof(runtime_flags)/sizeof(runtime_flags[0]); i++)
    {
        if (runtime_flags[i].name != NULL)
            cfg_set_boolean (CONFIG_NFTP, NULL, runtime_flags[i].name, *(runtime_flags[i].value));
    }

    p = fly_get_font ();
    cfg_set_string (CONFIG_NFTP, fl_opt.platform_nick, "font", p);
    free (p);

    cfg_set_string (CONFIG_NFTP, "", "local-directory-left", local[V_LEFT].dir.name);
    cfg_set_string (CONFIG_NFTP, "", "local-directory-right", local[V_RIGHT].dir.name);

    strcpy (cfgfile, paths.user_libpath);
    str_cats (cfgfile, "nftp.cfg");
    cfg_write (CONFIG_NFTP, cfgfile);
}
コード例 #2
0
ファイル: config.c プロジェクト: CharlesLio/schismtracker
void cfg_save(void)
{
        char *ptr;
        cfg_file_t cfg;

        ptr = dmoz_path_concat(cfg_dir_dotschism, "config");
        cfg_init(&cfg, ptr);
        free(ptr);

        // this wart is here because Storlek is retarded
        cfg_delete_key(&cfg, "Directories", "filename_pattern");

        cfg_set_string(&cfg, "Directories", "modules", cfg_dir_modules);
        cfg_set_string(&cfg, "Directories", "samples", cfg_dir_samples);
        cfg_set_string(&cfg, "Directories", "instruments", cfg_dir_instruments);
        /* No, it's not a directory, but whatever. */
        cfg_set_string(&cfg, "Directories", "module_pattern", cfg_module_pattern);
        cfg_set_string(&cfg, "Directories", "export_pattern", cfg_export_pattern);

        cfg_save_info(&cfg);
        cfg_save_patedit(&cfg);
        cfg_save_audio(&cfg);
        cfg_save_palette(&cfg);
        cfg_save_disko(&cfg);
        cfg_save_dmoz(&cfg);

        cfg_write(&cfg);
        cfg_free(&cfg);
}
コード例 #3
0
ファイル: config.c プロジェクト: CharlesLio/schismtracker
void cfg_atexit_save(void)
{
        char *ptr;
        cfg_file_t cfg;

        ptr = dmoz_path_concat(cfg_dir_dotschism, "config");
        cfg_init(&cfg, ptr);
        free(ptr);

        cfg_atexit_save_audio(&cfg);

        /* TODO: move these config options to video.c, this is lame :)
        Or put everything here, which is what the note in audio_loadsave.cc
        says. Very well, I contradict myself. */
        cfg_set_string(&cfg, "Video", "driver", video_driver_name());
        cfg_set_number(&cfg, "Video", "fullscreen", !!(video_is_fullscreen()));
        cfg_set_number(&cfg, "Video", "mouse_cursor", video_mousecursor_visible());
        cfg_set_number(&cfg, "Video", "lazy_redraw", !!(status.flags & LAZY_REDRAW));

        cfg_set_number(&cfg, "General", "vis_style", status.vis_style);
        cfg_set_number(&cfg, "General", "time_display", status.time_display);
        cfg_set_number(&cfg, "General", "classic_mode", !!(status.flags & CLASSIC_MODE));
        cfg_set_number(&cfg, "General", "make_backups", !!(status.flags & MAKE_BACKUPS));
        cfg_set_number(&cfg, "General", "numbered_backups", !!(status.flags & NUMBERED_BACKUPS));

        cfg_set_number(&cfg, "General", "accidentals_as_flats", !!(status.flags & ACCIDENTALS_AS_FLATS));
        cfg_set_number(&cfg, "General", "meta_is_ctrl", !!(status.flags & META_IS_CTRL));
        cfg_set_number(&cfg, "General", "altgr_is_alt", !!(status.flags & ALTGR_IS_ALT));

        cfg_set_number(&cfg, "General", "midi_like_tracker", !!(status.flags & MIDI_LIKE_TRACKER));
        /* Say, whose bright idea was it to make this a string setting?
        The config file is human editable but that's mostly for developer convenience and debugging
        purposes. These sorts of things really really need to be options in the GUI so that people
        don't HAVE to touch the settings. Then we can just use an enum (and we *could* in theory
        include comments to the config by default listing what the numbers are, but that shouldn't
        be necessary in most cases. */
        switch (status.fix_numlock_setting) {
        case NUMLOCK_ALWAYS_ON:
                cfg_set_string(&cfg, "General", "numlock_setting", "on");
                break;
        case NUMLOCK_ALWAYS_OFF:
                cfg_set_string(&cfg, "General", "numlock_setting", "off");
                break;
        case NUMLOCK_HONOR:
                cfg_set_string(&cfg, "General", "numlock_setting", "system");
                break;
        case NUMLOCK_GUESS:
                /* leave empty */
                break;
        };

        /* hm... most of the time probably nothing's different, so saving the
        config file here just serves to make the backup useless. maybe add a
        'dirty' flag to the config parser that checks if any settings are
        actually *different* from those in the file? */

        cfg_write(&cfg);
        cfg_free(&cfg);
}
コード例 #4
0
ファイル: config.c プロジェクト: CharlesLio/schismtracker
static void cfg_save_palette(cfg_file_t *cfg)
{
        int n;
        char palette_text[49] = "";

        cfg_set_number(cfg, "General", "palette", current_palette_index);

        for (n = 0; n < 48; n++) {
                /* Changed older implementation for this, since it is not vital
                to have speed here and the compiler printed a warning */
                palette_text[n] = palette_trans[current_palette[n/3][n%3]];
        }
        palette_text[48] = '\0';
        cfg_set_string(cfg, "General", "palette_cur", palette_text);
}
コード例 #5
0
ファイル: midi-core.c プロジェクト: CharlesLio/schismtracker
void cfg_save_midi(cfg_file_t *cfg)
{
        struct cfg_section *c;
        struct midi_provider *p;
        struct midi_port *q;
        midi_config_t *md, *mc;
        char buf[33];
        char *ss;
        int i, j;

        CFG_SET_MI(flags);
        CFG_SET_MI(pitch_depth);
        CFG_SET_MI(amplification);
        CFG_SET_MI(c5note);

        song_lock_audio();
        md = &default_midi_config;

        /* overwrite default */
        mc = &current_song->midi_config;
        memcpy(md, mc, sizeof(midi_config_t));

        cfg_set_string(cfg,"MIDI","start", md->start);
        cfg_set_string(cfg,"MIDI","stop", md->stop);
        cfg_set_string(cfg,"MIDI","tick", md->tick);
        cfg_set_string(cfg,"MIDI","note_on", md->note_on);
        cfg_set_string(cfg,"MIDI","note_off", md->note_off);
        cfg_set_string(cfg,"MIDI","set_volume", md->set_volume);
        cfg_set_string(cfg,"MIDI","set_panning", md->set_panning);
        cfg_set_string(cfg,"MIDI","set_bank", md->set_bank);
        cfg_set_string(cfg,"MIDI","set_program", md->set_program);
        for (i = 0; i < 16; i++) {
                snprintf(buf, 32, "SF%X", i);
                cfg_set_string(cfg, "MIDI", buf, md->sfx[i]);
        }
        for (i = 0; i < 128; i++) {
                snprintf(buf, 32, "Z%02X", i + 0x80);
                cfg_set_string(cfg, "MIDI", buf, md->zxx[i]);
        }
        song_unlock_audio();

        /* write out only enabled midi ports */
        i = 1;
        SDL_mutexP(midi_mutex);
        q = NULL;
        for (p = port_providers; p; p = p->next) {
                while (midi_port_foreach(p, &q)) {
                        ss = q->name;
                        if (!ss) continue;
                        while (isspace(*ss)) ss++;
                        if (!*ss) continue;
                        if (!q->io) continue;

                        snprintf(buf, 32, "MIDI Port %d", i); i++;
                        cfg_set_string(cfg, buf, "name", ss);
                        ss = p->name;
                        if (ss) {
                                while (isspace(*ss)) ss++;
                                if (*ss) {
                                        cfg_set_string(cfg, buf, "provider", ss);
                                }
                        }
                        cfg_set_number(cfg, buf, "input", q->io & MIDI_INPUT ? 1 : 0);
                        cfg_set_number(cfg, buf, "output", q->io & MIDI_OUTPUT ? 1 : 0);
                }
        }
        //TODO: Save number of MIDI-IP ports
        SDL_mutexV(midi_mutex);

        /* delete other MIDI port sections */
        for (c = cfg->sections; c; c = c->next) {
                j = -1;
                sscanf(c->name, "MIDI Port %d", &j);
                if (j < i) continue;
                c->omit = 1;
        }

}
コード例 #6
0
ファイル: init.c プロジェクト: OS2World/APP-INTERNET-NFTP
void init_config (void)
{
    char    inifile[MAX_PATH], ifile[MAX_PATH];
    char    cfgfile[MAX_PATH];
    int     i;

    // set defaults
    cfg_set_string (CONFIG_NFTP, fl_opt.platform_nick, "language", "english");

    // read stored customizations
    strcpy (cfgfile, paths.user_libpath);
    str_cats (cfgfile, "nftp.cfg");
    if (fl_opt.has_console && !fl_opt.initialized)
        fly_ask_ok (0, "loading %s......\n", cfgfile);
    cfg_read (CONFIG_NFTP, cfgfile);

    if (cmdline.language != NULL)
    {
        cfg_set_string (CONFIG_NFTP, fl_opt.platform_nick, "language", cmdline.language);
    }

    // load nftp.ini
    strcpy (inifile, paths.user_libpath);
    str_cats (inifile, "nftp.ini");
    if (fl_opt.has_console && !fl_opt.initialized)
        fly_ask_ok (0, "loading %s......\n", inifile);

    if (access (inifile, F_OK) != 0)
    {
        // looking for nftp.i file in user dir, then in system dir
        strcpy (ifile, paths.user_libpath);
        str_cats (ifile, "nftp.i");
        if (access (ifile, R_OK) != 0)
        {
            strcpy (ifile, paths.system_libpath);
            str_cats (ifile, "nftp.i");
            if (access (ifile, R_OK) != 0)
                fly_error ("Cannot find nftp.i neither in %s nor in %s",
                           paths.user_libpath, paths.system_libpath);
        }
        if (copy_file (ifile, inifile))
            fly_error ("Error copying %s to %s", ifile, inifile);
    }

    if (access (inifile, R_OK) != 0)
    {
        fly_error ("Cannot read %s", inifile);
    }

    GetProfileOptions (inifile);

    if (cmdline.slowlink) options.slowlink = TRUE;
    if (options.slowlink) fl_opt.use_ceol = TRUE;

    for (i=0; i<sizeof(runtime_flags)/sizeof(runtime_flags[0]); i++)
    {
        *(runtime_flags[i].value) = runtime_flags[i].def;
        if (runtime_flags[i].name != NULL &&
            cfg_check_boolean (CONFIG_NFTP, NULL, runtime_flags[i].name))
            *(runtime_flags[i].value) = cfg_get_boolean (CONFIG_NFTP, NULL, runtime_flags[i].name);
    }

    for (i=0; i<MAX_SITE; i++)
    {
        status.resolve_symlinks[i] = TRUE;
        status.use_flags[i] = TRUE;
        status.use_proxy[i] = FALSE;
        status.passive_mode[i] = FALSE;
    }
}
コード例 #7
0
ファイル: getoptns.c プロジェクト: OS2World/APP-INTERNET-NFTP
void GetProfileOptions (char *ini_name)
{
    char    *p, buf[16];
    int     i;

    if (infLoad (ini_name) < 0)
    {
        fly_error (M("Error loading %s; terminating"), ini_name);
    }

    // put defaults in place

    for (i=0; i<sizeof(boptions)/sizeof(boptions[0]); i++) *(boptions[i].value) = boptions[i].def;
    for (i=0; i<sizeof(ioptions)/sizeof(ioptions[0]); i++) *(ioptions[i].value) = ioptions[i].def;
    for (i=0; i<sizeof(soptions)/sizeof(soptions[0]); i++) *(soptions[i].value) = soptions[i].def;
    for (i=0; i<sizeof(xoptions)/sizeof(xoptions[0]); i++) if (xoptions[i].def != 255) *(xoptions[i].value) = xoptions[i].def;

    if (fl_opt.is_unix || fl_opt.platform == PLATFORM_OS2_X || fl_opt.platform == PLATFORM_OS2_X11) options.pseudographics = 2;

    // some defaults
    options.psw_file = str_strdup1 (paths.user_libpath, 9);
    str_cats (options.psw_file, "nftp.psw");
    
    options.history_file = str_strdup1 (paths.user_libpath, 9);
    str_cats (options.history_file, "nftp.hst");
    
    // retrieve options
    
    for (i=0; i<sizeof(boptions)/sizeof(boptions[0]); i++)
        infGetBoolean (boptions[i].sect, boptions[i].name, boptions[i].value);

    for (i=0; i<sizeof(ioptions)/sizeof(ioptions[0]); i++)
        infGetInteger (ioptions[i].sect, ioptions[i].name, ioptions[i].value);

    for (i=0; i<sizeof(soptions)/sizeof(soptions[0]); i++)
        infGetString (soptions[i].sect, soptions[i].name, soptions[i].value);
    
    for (i=0; i<sizeof(xoptions)/sizeof(xoptions[0]); i++)
        infGetHexbyte (xoptions[i].sect, xoptions[i].name, (char *)xoptions[i].value);


    if (infGetInteger (sect_psw, "encryption-type", &options.psw_enctype) < 0)
    {
        if (fl_opt.platform != PLATFORM_UNIX_TERM && fl_opt.platform != PLATFORM_UNIX_X11)
            options.psw_enctype = 2;
    }
    
    if (infGetBoolean (sect_options, "query-bfs-attributes-support", &options.query_bfsattrs) < 0)
    {
        if (fl_opt.platform == PLATFORM_BEOS_TERM) options.query_bfsattrs = TRUE;
        else                                       options.query_bfsattrs = FALSE;
    }

    if (options.user_agent == NULL)
    {
        strcpy (buf, NFTP_VERSION);
        str_strip2 (buf, " ");
        options.user_agent = str_join ("NFTP-", buf);
    }
    
    // post-config
    
    if (fl_opt.has_osmenu) fl_opt.menu_onscreen = FALSE;
    
    // INI file editor
    
    if (fl_opt.platform == PLATFORM_OS2_VIO)
    {
        options.texteditor = "tedit.exe";
        infGetString (sect_options, "text-editor-os2vio", &options.texteditor);
    }
    
    if (fl_opt.platform == PLATFORM_OS2_PM)
    {
        options.texteditor = "e.exe";
        infGetString (sect_options, "text-editor-os2pm", &options.texteditor);
    }
    
    if (fl_opt.platform == PLATFORM_OS2_X || fl_opt.platform == PLATFORM_OS2_X11)
    {
        options.texteditor = "xedit.exe";
        infGetString (sect_options, "text-editor-os2x", &options.texteditor);
    }
    
    if (fl_opt.platform == PLATFORM_WIN32_CONS)
    {
        options.texteditor = "Notepad.exe";
        infGetString (sect_options, "text-editor-win32cons", &options.texteditor);
    }

    if (fl_opt.platform == PLATFORM_WIN32_GUI)
    {
        options.texteditor = "Notepad.exe";
        infGetString (sect_options, "text-editor-win32gui", &options.texteditor);
    }

    if (fl_opt.platform == PLATFORM_BEOS_TERM)
    {
        options.texteditor = "vi";
        infGetString (sect_options, "text-editor-beosterm", &options.texteditor);
    }
    
    if (fl_opt.platform == PLATFORM_UNIX_TERM)
    {
        options.texteditor = "vi";
        infGetString (sect_options, "text-editor-unixterm", &options.texteditor);
    }

    if (fl_opt.platform == PLATFORM_UNIX_X11)
    {
        options.texteditor = "xedit";
        infGetString (sect_options, "text-editor-unix_x11", &options.texteditor);
    }

    // others
    
    if (options.log_trans)
    {
        if (infGetString (sect_options, "log-transfers-name", &p) == 0)
        {
            strcpy (options.log_trans_name, p);
            free (p);
        }
        else
        {
            strcpy (options.log_trans_name, paths.user_libpath);
            str_cats (options.log_trans_name, "nftp.fls");
        }
    }
    
    if (infGetString (sect_options, "bookmarks-file", &p) == 0)
    {
        strcpy (options.bmk_name, p);
        free (p);
    }
    else
    {
        strcpy (options.bmk_name, paths.user_libpath);
        str_cats (options.bmk_name, "nftp.bmk");
    }
    
    // registration information
    
    if ((cfg_get_string (CONFIG_NFTP, NULL, "registration-name"))[0] == '\0')
    {
        if (infGetString (sect_registration, "name", &p) == 0)
        {
            cfg_set_string (CONFIG_NFTP, NULL, "registration-name", p);
            free (p);
        }

        if (infGetString (sect_registration, "code", &p) == 0)
        {
            cfg_set_string (CONFIG_NFTP, NULL, "registration-code", p);
            free (p);
        }
    }

    // clear key definition table
    for (i=0; i<sizeof(options.keytable)/sizeof(int); i++)
    {
        options.keytable[i]  = KEY_NOTHING;
        options.keytable2[i] = KEY_NOTHING;
    }
    
    def_key_assignments ();
    key_assignments ();
    
    // retrieve colours
    if ((options.monochrome && !cmdline.colour) || cmdline.monochrome)
    {
        options.attr_pointer_marked_dir = VID_REVERSE;
        options.attr_pointer_marked     = VID_REVERSE;
        options.attr_pointer_dir        = VID_REVERSE;
        options.attr_pointer            = VID_REVERSE;
        options.attr_pointer_desc       = VID_REVERSE;
        options.attr_marked_dir         = VID_BRIGHT;
        options.attr_marked             = VID_BRIGHT;
        options.attr_dir                = VID_NORMAL;
        options.attr_description        = VID_NORMAL;           
        options.attr_                   = VID_NORMAL;           
                                                                
        options.attr_background         = VID_NORMAL;           
        options.attr_status             = VID_NORMAL;
        options.attr_status2            = VID_REVERSE;
        options.attr_statmarked         = VID_REVERSE;
        options.attr_tr_info            = VID_NORMAL;           
        options.attr_help               = VID_REVERSE;          
        options.attr_status_local       = VID_NORMAL;

        options.attr_tp_file     = VID_NORMAL;
        options.attr_tp_dir      = VID_NORMAL;
        options.attr_tp_file_m   = VID_NORMAL;
        options.attr_tp_dir__m   = VID_NORMAL;
        options.attr_tp_file_p   = VID_REVERSE;
        options.attr_tp_dir__p   = VID_REVERSE;
        options.attr_tp_file_mp  = VID_REVERSE;
        options.attr_tp_dir__mp  = VID_REVERSE;
        
        options.attr_cntr_header        = VID_REVERSE;
        options.attr_cntr_resp          = VID_NORMAL;
        options.attr_cntr_cmd           = VID_BRIGHT;
        options.attr_cntr_comment       = VID_BRIGHT;

        options.attr_bmrk_back          = VID_REVERSE;
        options.attr_bmrk_pointer       = VID_NORMAL;
        options.attr_bmrk_hostpath      = VID_REVERSE;
        options.attr_bmrk_hostpath_pointer = VID_BRIGHT;
    }

    infFree ();
}