コード例 #1
0
ファイル: m8260_pci_erratum9.c プロジェクト: 1x23/unifi-gpl
static int indirect_write_config(struct pci_bus *pbus, unsigned int devfn, int where,
			 int size, u32 value)
{
	struct pci_controller *hose = pbus->sysdata;
	u8 cfg_type = 0;
	if (ppc_md.pci_exclude_device)
		if (ppc_md.pci_exclude_device(pbus->number, devfn))
			return PCIBIOS_DEVICE_NOT_FOUND;

	if (hose->set_cfg_type)
		if (pbus->number != hose->first_busno)
			cfg_type = 1;

	out_be32(hose->cfg_addr,
		 (((where & 0xfc) | cfg_type) << 24) | (devfn << 16)
		 | ((pbus->number - hose->bus_offset) << 8) | 0x80);

	switch (size)
	{
		case 1:
			cfg_write(value, hose->cfg_data + (where & 3), u8, out_8);
			break;
		case 2:
			cfg_write(value, hose->cfg_data + (where & 2), u16, out_le16);
			break;
		case 4:
			cfg_write(value, hose->cfg_data + (where & 0), u32, out_le32);
			break;
	}		
	return PCIBIOS_SUCCESSFUL;
}
コード例 #2
0
ファイル: config.c プロジェクト: olegv142/micro-config
void cfg_chkpt_cb(struct config* cfg, struct cfg_type const* t, struct cfg_obj_header const* h, struct cfg_obj_footer const* f)
{
	// write it to snapshot
	int a = cfg->active_area;
	unsigned res = cfg_write(cfg, a ^ 1, t, h + 1, h->i, h->j_sz);
	BUG_ON(!res);
}
コード例 #3
0
void guiDone(void)
{
    if (initialized) {
        uiMainRender = 0;

        if (gui_save_pos) {
            gui_main_pos_x = guiApp.mainWindow.X;
            gui_main_pos_y = guiApp.mainWindow.Y;
            gui_sub_pos_x  = guiApp.subWindow.X;
            gui_sub_pos_y  = guiApp.subWindow.Y;
        }

#ifdef CONFIG_ASS
        ass_enabled       = gtkASS.enabled;
        ass_use_margins   = gtkASS.use_margins;
        ass_top_margin    = gtkASS.top_margin;
        ass_bottom_margin = gtkASS.bottom_margin;
#endif

        cfg_write();
        wsXDone();
    }

    appFreeStruct();
    free(guiIcon.collection);

    if (gui_conf) {
        m_config_free(gui_conf);
        gui_conf = NULL;
    }

    mp_msg(MSGT_GPLAYER, MSGL_V, "GUI done.\n");
}
コード例 #4
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);
}
コード例 #5
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);
}
コード例 #6
0
ファイル: gft.c プロジェクト: bobrippling/comm
void gft_quit()
{
	CLOSE();
	cfg_write(); /* must be before gtk shutdown */
	/* FIXME: cancel stuff that's in progress */
	gtk_main_quit(); /* gtk exit here only */
}
コード例 #7
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);
}
コード例 #8
0
ファイル: profile.cpp プロジェクト: dyne/MuSE
bool Profile::write_str(const char *section, const char *option, const char *value) {
  //  func("Profile::write_int(%s,%s,%s)",section,option,value);
  if(!cfg_write(profile_path, section, option, value)) {
    warning("Profile::write_str(%s,%s,%s) : %s",
	  section,option,value,profile_path);
    return(false);
  }
  return(true);
}
コード例 #9
0
ファイル: config.c プロジェクト: olegv142/micro-config
static unsigned cfg_put(
		struct config* cfg,
		const struct cfg_type* t,
		void const* pval,
		unsigned char i,
		unsigned char j_sz
	)
{
	unsigned res;
	int a = cfg->active_area;
	BUG_ON(a < 0);
	res = cfg_write(cfg, cfg->active_area, t, pval, i, j_sz);
	if (res)
		return res;
	// Free space by check pointing
	cfg_chkpt(cfg);
	return cfg_write(cfg, cfg->active_area, t, pval, i, j_sz);
}
コード例 #10
0
ファイル: config.c プロジェクト: olegv142/micro-config
static void cfg_commit_status(struct config* cfg, int a, cfg_area_status_t st)
{
	unsigned res;
	if (cfg->area[a].invalid || cfg->area[a].status >= st)
		return;
	res = cfg_write(cfg, a, 0, 0, st, 0);
	BUG_ON(!res);
	cfg->area[a].status = st;
}
コード例 #11
0
ファイル: cfg.c プロジェクト: jwgcarlson/OPSEC
int cfg_write_file(Config cfg, const char* filename, const char* mode) {
    FILE* f = fopen(filename, mode);
    if(f == NULL) {
        fprintf(stderr, "Config: could not write to file '%s'\n", filename);
        return CFG_FILE_ERROR;
    }
    cfg_write(cfg, f);
    fclose(f);
    return CFG_OKAY;
}
コード例 #12
0
ファイル: pci-exynos.c プロジェクト: qkdang/m462
static int exynos_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
				u32 val)
{
	int ret;

	exynos_pcie_sideband_dbi_w_mode(pp, true);
	ret = cfg_write(pp->dbi_base + (where & ~0x3), where, size, val);
	exynos_pcie_sideband_dbi_w_mode(pp, false);
	return ret;
}
コード例 #13
0
ファイル: profile.cpp プロジェクト: dyne/MuSE
bool Profile::write_float(const char *section, const char *option, const float value) {
  char temp[MAX_VALUE_SIZE];
  
  snprintf(temp,MAX_VALUE_SIZE,"%.1f",value);
  if(!cfg_write(profile_path, section, option, temp)) {
    warning("Profile::write_float(%s,%s,%s) : %s",
	    section,option,value,profile_path);
    return false;
  }
  return true;
}
コード例 #14
0
const char * MergeTest::result(cfg_t cfg) {
    CPE_DEF_ERROR_MONITOR(em, cpe_error_log_to_consol, NULL);

    mem_buffer_clear(&m_result_buffer);
    struct write_stream_buffer stream = CPE_WRITE_STREAM_BUFFER_INITIALIZER(&m_result_buffer);

    EXPECT_EQ(0, cfg_write((write_stream_t)&stream, cfg, &em));
    stream_putc((write_stream_t)&stream, 0);

    return (const char *)mem_buffer_make_exactly(&m_result_buffer);
}
コード例 #15
0
ファイル: profile.cpp プロジェクト: dyne/MuSE
bool Profile::write_int(const char *section, const char *option, const int value) {
  //  func("Profile::write_int(%s,%s,%i)",section,option,value);
  char temp[MAX_VALUE_SIZE];

  snprintf(temp,MAX_VALUE_SIZE,"%i",value);
  if(!cfg_write(profile_path, section, option, temp)) {
    warning("Profile::write_int(%s,%s,%s) : %s",
	  section,option,value,profile_path);
    return(false);
  }
  return(true);
}
コード例 #16
0
ファイル: config.c プロジェクト: BackupTheBerlios/most
extern void
CLI_config_write (void)
{
    if (CLI_config.state == CLI_CFG_STATE_SAVED)
        return;
    CLI_config.state = CLI_CFG_STATE_SAVED;
    CLI_config.checksum = NET_inet_chksum (&CLI_config,
                                           (ACE_u16_t) (sizeof (CLI_config) -
                                                        sizeof (CLI_config.checksum)));
    if (cfg_write != NULL){
        cfg_write();
    }
}
コード例 #17
0
ファイル: rjio.c プロジェクト: XilongPei/TreeServer
/*
 * ----------------------------------------------------------
 *            closeRJ()
 * ----------------------------------------------------------
 */
void closeRJ( RJFILE *rf )
{
    int    i,year;
    char   buf[30];
    char   buf2[30];

    if ( !rf ) return;

    cfg_segment( rf->handle, szSummary, NULL);

    sprintf( buf, "%ld", rf->curdate );
    cfg_write( rf->handle, "OPTIME", buf, 1 );

    sprintf( buf, "%ld", rf->endate );
    cfg_write( rf->handle, "ETIME", buf, 1 );

    sprintf( buf, "%ld", rf->startdate );
    cfg_write( rf->handle, "STIME", buf, 1 );

    buf[4]='\0';
    year = atoi( buf );

    for( i=1; i<=12; i++ )
       {
       sprintf( buf, "%4d%02d", year, i); // make keyword
       sprintf( buf2, "%014ld", rf->segPos[i-1] );
       cfg_write( rf->handle, buf, buf2, 1 );
       }

    if ( rf->handle )
	cfg_close(rf->handle);

    rf->handle = 0;

    FreeDS( rf->ds );
    free(rf);
    rf = 0;
}
コード例 #18
0
ファイル: config.c プロジェクト: CharlesLio/schismtracker
void cfg_midipage_save(void)
{
        char *ptr;
        cfg_file_t cfg;

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

        cfg_save_midi(&cfg);

        cfg_write(&cfg);
        cfg_free(&cfg);
}
コード例 #19
0
ファイル: menu.c プロジェクト: Recontech/dsi-shield
int cb_save_restart(int cmd, void *data)
{
    if (cmd == CMD_ENTER)
    {
        cfg_write(&current_config);

        pp_printf("\033[2J\033[;H");
        pp_printf("Rebooting device...\n");
        delay(2000000);
        asm volatile ("li t0,0");
        asm volatile ("jr t0");

        //	exit(0);
    }
コード例 #20
0
ファイル: main.c プロジェクト: vbextreme/EasyFramework
int main()
{
	FILE* f = fopen("test","w+");
	
	cfg_write("daniele","1",f);
	cfg_write("pippo","4",f);
	cfg_write("urca","7",f);
	
	cfg_write("pippo","2",f);
	cfg_write("urca","3",f);
	
	fclose(f);
	
	f = fopen("test","r");
	char a[100],b[100];
	
		while ( cfg_read(a,b,f) )
		{
			printf("\'%s\' == \'%s\'\n",a,b);
		}
	fclose(f);
	
    return 0;
}
コード例 #21
0
ファイル: interface.c プロジェクト: pder/mplayer-svn
void guiDone(void)
{
    if(mygui)
    {
        fprintf(stderr, "[GUI] Closed by main mplayer window\n");
        fflush(stderr);
        PostThreadMessage(threadId, WM_QUIT, 0, 0);
        WaitForSingleObject(hThread, INFINITE);
        CloseHandle(hThread);
        mygui->uninit(mygui);
        nfree(mygui);
    }
    /* Remove tray icon */
    Shell_NotifyIcon(NIM_DELETE, &nid);
    cfg_write();
}
コード例 #22
0
ファイル: rjio.c プロジェクト: XilongPei/TreeServer
/*
 * ----------------------------------------------------------
 *            RJWrite()
 * ----------------------------------------------------------
 */
int  RJWrite( RJFILE *rf, char *date )
// append method
{
    int   d, i;
    char  datetmp[7];
    long  inc_size=0L;
    int   retval;

    retval = vaildDate( rf, date );

    d = (date[4] - '0') * 10 + (date[5] - '0') - 1;
    if ( d < 0 || d >= 12 ) 	return 0;

    if ( !retval ) return 0;
    if ( !rf->exist[d] ) {
	rf->exist[d] = 1;
	strncpy( datetmp, date, 6 );
	datetmp[6] = '\0';
	// rj  make group
	cfg_make(rf->handle,datetmp, 1);
	rf->segPos[d] = cfg_getPos(rf->handle);
	cfg_setSeg( rf->handle, rf->segPos[d] );
    }

    for( i=0; i< keynum; i++ )
       {
       cfg_write( rf->handle, FieldName[i].qkey, rf->ds->p[i], 2 );
       inc_size+=strlen(FieldName[i].qkey);
       inc_size++; // '='
       inc_size+=strlen(rf->ds->p[i]);
       inc_size+=2; // "\r\n"
       }
/* Modi 1995.6.19
    cfg_writeLine( rf->handle, "\r\n" );
    inc_size+=2;*/

    // update ds->segpos
    for( i=d+1; i<12; i++ ) {
       if( rf->segPos[i] != 0L )
	     rf->segPos[i] +=inc_size;
    }  // end of for

    return 1;
}
コード例 #23
0
ファイル: interface.c プロジェクト: EdwardNewK/mplayer
/**
 * @brief Stop and finalize the GUI.
 */
void guiDone(void)
{
    if (guiInitialized) {
        if (gui_save_pos) {
            gui_main_pos_x  = guiApp.mainWindow.X;
            gui_main_pos_y  = guiApp.mainWindow.Y;
            gui_video_pos_x = guiApp.videoWindow.X;
            gui_video_pos_y = guiApp.videoWindow.Y;
        }

        ass_enabled       = gtkASS.enabled;
        ass_use_margins   = gtkASS.use_margins;
        ass_top_margin    = gtkASS.top_margin;
        ass_bottom_margin = gtkASS.bottom_margin;

        cfg_write();

        if (guiApp.menuIsPresent)
            uiMenuDone();
        if (guiApp.playbarIsPresent)
            uiPlaybarDone();

        uiVideoDone();
        uiMainDone();

        wsDone();
    }

    uiUnsetFile();
    listMgr(PLAYLIST_DELETE, 0);
    listMgr(URLLIST_DELETE, 0);
    appFreeStruct();
    free(guiIcon.collection);

    if (gui_conf) {
        m_config_free(gui_conf);
        gui_conf = NULL;
    }

    mp_msg(MSGT_GPLAYER, MSGL_V, "GUI done.\n");
}
コード例 #24
0
void guiDone( void )
{
 mplMainRender=0;
 mp_msg( MSGT_GPLAYER,MSGL_V,"[GUI] done.\n" );

 if ( gui_save_pos )
  {
   gui_main_pos_x=appMPlayer.mainWindow.X; gui_main_pos_y=appMPlayer.mainWindow.Y;
   gui_sub_pos_x=appMPlayer.subWindow.X; gui_sub_pos_y=appMPlayer.subWindow.Y;
  }

#ifdef CONFIG_ASS
 ass_enabled = gtkASS.enabled;
 ass_use_margins = gtkASS.use_margins;
 ass_top_margin = gtkASS.top_margin;
 ass_bottom_margin = gtkASS.bottom_margin;
#endif

 cfg_write();
 wsXDone();
}
コード例 #25
0
ファイル: testio.cpp プロジェクト: jwgcarlson/OPSEC
int main(int argc, char* argv[]) {
    int nprocs, myid, root;
    int Ncells, Nmodes;
    Cell* cells;

    Config cfg = cfg_new();

    /* Initialize MPI */
    MPI_Init(&argc, &argv);
    MPI_Comm comm = MPI_COMM_WORLD;
    MPI_Comm_size(comm, &nprocs);
    MPI_Comm_rank(comm, &myid);
    root = nprocs - 1;

    /* Parse command line switches */
    int opt;
    const char* optstring = "hc:";
    while((opt = getopt(argc, argv, optstring)) != -1) {
        switch(opt) {
        case 'h':
            print_usage(stdout, argv[0]);
            return 0;
        case 'c':
            cfg_read_file(cfg, optarg);
            break;
        default:
            print_usage(stderr, argv[0]);
            MPI_Abort(comm, 1);
        }
    }

    /* Parse additional command line options */
    for(int i = optind; i < argc; i++)
        cfg_read_line(cfg, argv[i]);

    /* Debugging... */
    if(myid == root) {
        printf("# Config options\n");
        cfg_write(cfg, stdout);
    }

    if(myid == 0) {
        printf("Testing malloc...\n");
        char* test = (char*) malloc(72000*sizeof(char));
        if(test == NULL) {
            fprintf(stderr, "Could not allocate a measly 72000 bytes!\n");
            perror("system error:");
        }
        free(test);
    }

    /* Make sure all the necessary options are provided */
    if(!cfg_has_keys(cfg, "cellfile,specfile", ",")) {
        print_usage(stderr, argv[0]);
        MPI_Abort(comm, 1);
    }
    const char* cellfile = cfg_get(cfg, "cellfile");
    const char* specfile = cfg_get(cfg, "specfile");

    /* Read cells from file */
    if(myid == 0) printf("Reading cells from '%s' ...\n", cellfile);
    cells = ReadCells(comm, cellfile, Ncells);
    if(cells == NULL) {
        if(myid == 0) fprintf(stderr, "Failed to read cells.\n");
        if(myid == 0) perror("system error");
        MPI_Abort(comm, 1);
    }
    else {
        if(myid == 0) printf("Read %d cells.\n", Ncells);
        if(myid == 0) printf("  cells[0] = { %d, %d, %g, %g, %g, %g, %g, %g, %g, %g }\n", cells[0].a, cells[0].G, cells[0].rmin, cells[0].rmax, cells[0].mumin, cells[0].mumax, cells[0].phimin, cells[0].phimax, cells[0].Veff, cells[0].Nbar);
    }

    /* Read KL mode coefficients */
    Matrix B;   // cell -> KL mode projection matrix
    Matrix C;   // full covariance matrix in KL basis (diagonal)
    if(myid == 0) printf("Reading KL spectrum from '%s' ...\n", specfile);
    if(ReadSpectrum(comm, specfile, Nmodes, Ncells, B, C) != 0) {
        if(myid == 0) fprintf(stderr, "Failed to read spectrum.\n");
        if(myid == 0) perror("system error");
        MPI_Abort(comm, 1);
    }
    else {
        if(myid == 0) printf("Read spectrum: Nmodes = %d, Ncells = %d\n", Nmodes, Ncells);
    }

    /* Clean up nicely */
    free(cells);
    MPI_Finalize();

    return 0;
}
コード例 #26
0
ファイル: rjio.c プロジェクト: XilongPei/TreeServer
/*
 * ----------------------------------------------------------
 *            createRJ()
 * ----------------------------------------------------------
 */
RJFILE *createRJ( char *RJname )
// create a empty diary-sheet file, system'date was used.
{
    RJFILE *rf;
    int    i, iy;
    char   buf[30];
    char   buf2[30];
    SYSTEMTIME SystemTime;
    

// address of system time structure 
/* I am sure to create the file
    if( access( RJname, 0 ) == 0 )
    {
       // warning...
       if( ( rf = openRJ( RJname ) ) != NULL ) {
		return  rf;
       }
    }
*/
    rf = (RJFILE *)malloc( sizeof(RJFILE) );
    if( rf == NULL ) 	return NULL;
    memset( rf, '\0', sizeof(RJFILE) );

    if ( !(rf->handle = cfg_create(RJname, rjHEAD_SIZE) ) )
       {
       free (rf);
       return NULL;
       }

    if ( !(rf->ds = AllocDS()) )
    {
       cfg_close( rf->handle );
       free (rf);
       return NULL;
    }

    cfg_writeLine( rf->handle, RJFILEMARK );

    cfg_make(rf->handle, szSummary, 0);

    GetLocalTime( &SystemTime );
    for(iy = 0;  iy < MAXYEAR_RJIO;  iy++) {
       for( i=1; i<=12; i++ )
       {
		sprintf( buf, "%4d%02d", SystemTime.wYear+iy, i); // make keyword
		// enough to content 999,999,999,999
		sprintf( buf2,"%014ld",rf->segPos[i-1]);
		cfg_write( rf->handle, buf, buf2, 1 );
       }
    }

    sprintf(buf, "%4d%02d%02d", SystemTime.wYear,SystemTime.wMonth,SystemTime.wDay);
    cfg_write( rf->handle,"OPTIME", buf, 1 );
    cfg_write( rf->handle,"ETIME", buf, 1 );
    cfg_write( rf->handle,"STIME", buf, 1 );

    rf->curdate = atol( buf );
    rf->startdate = rf->curdate;
    rf->endate = rf->curdate;

    for( i=1; i<=12; i++ )
       {
       rf->segPos[i-1] = 0L;
       }

    InitializeCriticalSection( &(rf->dCriticalSection) );

    return  rf;
}