Ejemplo n.º 1
0
void save_value (FILE *f, value v)
{ save_int (f, v -> tag);
  switch (v -> tag)
    { case string_value:	save_string (f, v -> u.str); break;
      case integer_value:	save_int (f, v -> u.inum); break;
      case real_value:		save_real (f, v -> u.rnum); break;
      case tuple_value:		save_value_list (f, v -> u.tuple); break;
      case small_lattice_value: save_int (f, v -> u.slat); break;
      case large_lattice_value: save_int_list (f, v -> u.elat); break;
      default: bad_tag (v -> tag, "save_value");
    };
};
Ejemplo n.º 2
0
Archivo: save.c Proyecto: Azizou/XaoS
static void
save_intc(struct uih_context *uih, const char *name, int number)
{
    start_save(uih, name);
    save_int(uih, number);
    stop_save(uih);
}
Ejemplo n.º 3
0
static void config_save(const char *path) {
    printf("Saving config to '%s'\n", path);

    file = fopen(path, "w");
    if(file == NULL) {
        moo_errorf("Couldn't write to .conf file '%s'", path);
        return;
    }

    int v;
    for(v = 0; v < sizeof(values)/sizeof(*values); v++) {
        save_int(values[v].name, *values[v].ptr);
    }

    fclose(file);
}
Ejemplo n.º 4
0
void save_value_list (FILE *f, value_list vl)
{ int ix;
  save_int (f, vl -> size);
  for (ix = 0; ix < vl -> size; ix++)
    save_value (f, vl -> array[ix]);
};
Ejemplo n.º 5
0
void  save_couple( int reference, short block, Couple *cptr )
{
	int chref ;					/* child reference						*/
	short child ;				/* loop counter							*/
	short new_child, deleted_child ;
	Person *pptr ;
	short pblock ;
	char *alert_ptr, alert_str[200] ;
	short i ;				/* loop counter							*/
	short changed = FALSE ;

	busy( BUSY_MORE ) ;

	save_int( &(cptr->reference), reference, &changed ) ;
	save_int( &(cptr->male_reference), male, &changed ) ;
	save_int( &(cptr->female_reference), female, &changed ) ;
	save_date( &(cptr->wedding_date), c_form_addrs.wed, c_form_addrs.wed_qual, &changed ) ;
	str_save( &(cptr->wedding_place), c_form_addrs.wep,
		&next_cstring_ptr[block], cblock_end[block], &changed ) ;
	str_save( &(cptr->wedd_wit1), c_form_addrs.ww1,
		&next_cstring_ptr[block], cblock_end[block], &changed ) ;
	str_save( &(cptr->wedd_wit2), c_form_addrs.ww2,
		&next_cstring_ptr[block], cblock_end[block], &changed ) ;
	str_save( &(cptr->wedding_source), c_form_addrs.cosrc,
		&next_cstring_ptr[block], cblock_end[block], &changed ) ;
	save_date( &(cptr->divorce_date), c_form_addrs.did, c_form_addrs.did_qual, &changed ) ;
	str_save( &(cptr->divorce_source), c_form_addrs.disrc,
		&next_cstring_ptr[block], cblock_end[block], &changed ) ;

	add_to_cidx( reference, cptr ) ;

	if( male )
	{
		pptr = get_pdata_ptr( male, &pblock ) ;
		if( pptr->sex == '?' )
		{
			pptr->sex = 'm' ;
			pblock_changed[pblock] = TRUE ;
		}
		add_coupling( male, reference ) ;
		sort_couplings( male ) ;
	}
	if( female )
	{
		pptr = get_pdata_ptr( female, &pblock ) ;
		if( pptr->sex == '?' )
		{
			pptr->sex = 'f' ;
			pblock_changed[pblock] = TRUE ;
		}
		add_coupling( female, reference ) ;
		sort_couplings( female ) ;
	}

	qsort( prog_array, (size_t) MAX_CHILDREN, (size_t) 4, child_compare ) ;

	if( prog_array[0] || old_prog_array[0] )
	{
		child = 0 ;
		while( chref = prog_array[child] )
		{
			new_child = TRUE ;
			for( i=0; i<MAX_CHILDREN; i++ )
				if( chref == old_prog_array[i] )  new_child = FALSE ;
			if( new_child )
			{
				pptr = get_pdata_ptr( chref, &pblock ) ;
				if( pptr->parents && pptr->parents != reference )
				{
					rsrc_gaddr( R_STRING, TWO_PARENTS, &alert_ptr ) ;
					sprintf( alert_str, alert_ptr, chref ) ;
					form_alert( 1, alert_str ) ;
					prog_array[child] = 0 ;
				}
				else
				{
					pptr->parents = reference ;
					pblock_changed[pblock] = TRUE ;
					changed = TRUE ;
				}
			}
			child++ ;
		}
		child = 0 ;
		while( chref = old_prog_array[child] )
		{
			deleted_child = TRUE ;
			for( i=0; i<MAX_CHILDREN; i++ )
				if( chref == prog_array[i] )  deleted_child = FALSE ;
			if( deleted_child )
			{
				pptr = get_pdata_ptr( chref, &pblock ) ;
				pptr->parents = 0 ;
				pblock_changed[pblock] = TRUE ;
				changed = TRUE ;
			}
			child++ ;
		}
	}
							/* resort array in case of deletions		*/
	qsort( prog_array, (size_t) MAX_CHILDREN, (size_t) 4, child_compare ) ;

	if( prog_array[0] )
		cput_references( &cptr->children, block, prog_array ) ;
	else  cptr->children = 0 ;

	if( changed )
	{
		cblock_changed[block] = TRUE ;
		load_person( edit_pers_ref, &edit_pers_block ) ;
		send_redraw_message( &pers_form.fm_box, pers_form.fm_handle ) ;
	}

	if( spouse_oset == number_spouses )		/* i.e. adding a new coupling	*/
	{
		number_spouses++ ;
		*( (char*) &pers_form.fm_ptr[NEXT_SPOUSE].ob_spec ) = '>' ;
		pers_form.fm_ptr[NEXT_SPOUSE].ob_flags |= TOUCHEXIT ;
	}

	if( reference == next_couple )  next_couple++ ;

	busy( BUSY_LESS ) ;

	if( next_couple >= c_index_size )  rsrc_form_alert( 1, C_INDEX_FULL ) ;

	if( overflowed )  rsrc_form_alert( 1, BK_FULL ) ;
}
Ejemplo n.º 6
0
Archivo: save.c Proyecto: Azizou/XaoS
void uih_saveframe(struct uih_context *uih)
{
    struct uih_savedcontext *s = uih->savec;
    int i;
    int resetsync = 0;
    if (uih->save) {
	changed = 0;
	if (s->firsttime)
	    save_noparam(uih, "initstate");
	if (s->nonfractalscreen && !uih->nonfractalscreen)
	    save_noparam(uih, "display"), s->nonfractalscreen = 0;
	for (i = uih_nfilters; i >= 0; i--) {
	    if (uih->filter[i] != NULL) {
		if (s->filter[i] != 1) {
		    start_save(uih, "filter");
		    save_keystring(uih, uih->filter[i]->action->shortname);
		    save_onoff(uih, 1);
		    s->filter[i] = 1;
		    stop_save(uih);
		}
	    } else if (s->filter[i] != 0) {
		s->filter[i] = 0;
		start_save(uih, "filter");
		save_keystring(uih, uih_filters[i]->shortname);
		save_onoff(uih, 0);
		stop_save(uih);
	    }
	}
	if (uih->palettechanged) {
	    switch (uih->palettetype) {
	    case 0:
		save_intc(uih, "defaultpalette", uih->paletteshift);
		break;
	    default:
		start_save(uih, "palette");
		save_int(uih, uih->palettetype);
		save_int(uih, uih->paletteseed);
		save_int(uih, uih->paletteshift);
		stop_save(uih);
		break;
	    }
	    uih->palettechanged = 0;
	    s->manualpaletteshift = 0;
	}
	if (s->manualpaletteshift != uih->manualpaletteshift)
	    save_intc(uih, "shiftpalette",
		      uih->manualpaletteshift - s->manualpaletteshift),
		s->manualpaletteshift = uih->manualpaletteshift;
	if (s->fcontext->currentformula != uih->fcontext->currentformula) {
	    save_keystringc(uih, "formula",
			    uih->fcontext->currentformula->shortname),
		s->fcontext->currentformula =
		uih->fcontext->currentformula;
#ifdef SFFE_USING
/*SFFE : malczak */
	    if ((int) (uih->fcontext->currentformula - formulas) == 24)	//user formula
	    {
		save_stringc(uih, "usrform", uih->parser->expression);
		if (uih->pinit)
		    save_stringc(uih, "usrformInit",
				 uih->pinit->expression);
		else
		    save_stringc(uih, "usrformInit", "");
	    };
/*SFFE : malczak */
#endif
	    set_formula(s->fcontext,
			(int) (uih->fcontext->currentformula - formulas));
	}
	if (s->mode >= UIH_SAVEALL)
	    save_intc(uih, "letterspersec", uih->letterspersec);
	if (s->mode > UIH_SAVEPOS) {
	    if (s->speedup != uih->speedup)
		save_floatc(uih, "speedup", uih->speedup), s->speedup =
		    uih->speedup;
	    if (s->maxstep != uih->maxstep)
		save_floatc(uih, "maxstep", uih->maxstep), s->maxstep =
		    uih->maxstep;
	    if (s->fastmode != uih->fastmode)
		save_nstringc(uih, "fastmode", uih->fastmode,
			      save_fastmode), s->fastmode = uih->fastmode;
	}
	if (s->juliamode != uih->juliamode)
	    save_onoffc(uih, "fastjulia", uih->juliamode), s->juliamode =
		uih->juliamode;
	if (s->cycling != uih->cycling)
	    save_onoffc(uih, "cycling", uih->cycling), s->cycling =
		uih->cycling;
	if (s->mode >= UIH_SAVEPOS
	    && s->fcontext->periodicity != uih->fcontext->periodicity)
	    save_onoffc(uih, "periodicity", uih->fcontext->periodicity),
		s->fcontext->periodicity = uih->fcontext->periodicity;
	if ((uih->cycling || s->mode >= UIH_SAVEALL)
	    && (s->cyclingspeed != uih->cyclingspeed
		|| s->direction != uih->direction * uih->cyclingdirection))
	    save_intc(uih, "cyclingspeed",
		      uih->cyclingspeed * uih->direction *
		      uih->cyclingdirection), s->cyclingspeed =
		uih->cyclingspeed, s->direction =
		uih->direction * uih->cyclingdirection;
	if ((s->mode > UIH_SAVEPOS && (uih->step || uih->zoomactive))
	    && (s->xcenter != uih->xcenter || s->ycenter != uih->ycenter))
	    save_coordc(uih, "zoomcenter", uih->xcenter, uih->ycenter),
		s->xcenter = uih->xcenter, s->ycenter = uih->ycenter;
	if ((!uih->fcontext->mandelbrot || uih->juliamode)
	    && (s->fcontext->pre != uih->fcontext->pre
		|| s->fcontext->pim != uih->fcontext->pim)) {
	    if (uih->juliamode && uih->pressed)
		save_coordc(uih, "morphjulia", uih->fcontext->pre,
			    uih->fcontext->pim), s->fcontext->pre =
		    uih->fcontext->pre, s->fcontext->pim =
		    uih->fcontext->pim;
	    else
		save_coordc(uih, "juliaseed", uih->fcontext->pre,
			    uih->fcontext->pim), s->fcontext->pre =
		    uih->fcontext->pre, s->fcontext->pim =
		    uih->fcontext->pim;
	}
	if (uih->fcontext->bre != s->fcontext->bre
	    || uih->fcontext->bim != s->fcontext->bim) {
	    save_coordc(uih, "perturbation", uih->fcontext->bre,
			uih->fcontext->bim), s->fcontext->bre =
		uih->fcontext->bre, s->fcontext->bim = uih->fcontext->bim;
	}
	if (uih->fastrotate != s->fastrotate && s->mode > UIH_SAVEPOS) {
	    save_onoffc(uih, "fastrotate", uih->fastrotate);
	    s->fastrotate = uih->fastrotate;
	}
	if (uih->fcontext->angle != s->fcontext->angle
	    && s->autorotate != 1) {
	    if (s->rotatepressed && s->mode == UIH_SAVEANIMATION)
		save_float2c(uih, "morphangle", uih->fcontext->angle, 5);
	    else
		save_float2c(uih, "angle", uih->fcontext->angle, 5);
	    s->rotatepressed = uih->rotatepressed;
	    s->fcontext->angle = uih->fcontext->angle;
	}
	if (uih->rotationspeed != s->rotationspeed
	    &&
	    ((s->mode > UIH_SAVEPOS
	      && uih->rotatemode == ROTATE_CONTINUOUS)
	     || s->mode >= UIH_SAVEALL)) {
	    save_float2c(uih, "rotationspeed", uih->rotationspeed, 6);
	    s->rotationspeed = uih->rotationspeed;
	}
	if (s->autorotate != (uih->rotatemode == ROTATE_CONTINUOUS)) {
	    s->autorotate = (uih->rotatemode == ROTATE_CONTINUOUS);
	    save_onoffc(uih, "autorotate", s->autorotate);
	}
	if (s->fcontext->maxiter != uih->fcontext->maxiter)
	    save_intc(uih, "maxiter", uih->fcontext->maxiter),
		s->fcontext->maxiter = uih->fcontext->maxiter;
	if (s->fcontext->bailout != uih->fcontext->bailout)
	    save_floatc(uih, "bailout", uih->fcontext->bailout),
		s->fcontext->bailout = uih->fcontext->bailout;
	if (s->fcontext->coloringmode != uih->fcontext->coloringmode)
	    save_intc(uih, "outcoloring", uih->fcontext->coloringmode),
		s->fcontext->coloringmode = uih->fcontext->coloringmode;
	if (s->fcontext->incoloringmode != uih->fcontext->incoloringmode)
	    save_intc(uih, "incoloring", uih->fcontext->incoloringmode),
		s->fcontext->incoloringmode =
		uih->fcontext->incoloringmode;
	if (s->fcontext->incoloringmode != uih->fcontext->incoloringmode)
	    save_intc(uih, "incoloring", uih->fcontext->incoloringmode),
		s->fcontext->incoloringmode =
		uih->fcontext->incoloringmode;
	if ((s->fcontext->incoloringmode == 10 || s->mode >= UIH_SAVEALL)
	    && s->fcontext->intcolor != uih->fcontext->intcolor)
	    save_intc(uih, "intcoloring", uih->fcontext->intcolor),
		s->fcontext->intcolor = uih->fcontext->intcolor;
	if ((s->fcontext->coloringmode == 10 || s->mode >= UIH_SAVEALL)
	    && s->fcontext->outtcolor != uih->fcontext->outtcolor)
	    save_intc(uih, "outtcoloring", uih->fcontext->outtcolor),
		s->fcontext->outtcolor = uih->fcontext->outtcolor;
	if (s->fcontext->mandelbrot != uih->fcontext->mandelbrot)
	    save_onoffc(uih, "julia", !uih->fcontext->mandelbrot),
		s->fcontext->mandelbrot = uih->fcontext->mandelbrot;
	if (s->mode > UIH_SAVEPOS
	    && s->fcontext->range != uih->fcontext->range)
	    save_intc(uih, "range", uih->fcontext->range),
		s->fcontext->range = uih->fcontext->range;
	if (s->fcontext->plane != uih->fcontext->plane)
	    save_intc(uih, "plane", uih->fcontext->plane),
		s->fcontext->plane = uih->fcontext->plane;
	if (s->zoomactive != uih->zoomactive && s->mode > UIH_SAVEPOS) {
	    switch (uih->zoomactive) {
	    case -1:
		save_noparam(uih, "unzoom");
		break;
	    case 1:
		save_noparam(uih, "zoom");
		break;
	    default:
		save_noparam(uih, "stop");
		break;
	    }
	    s->zoomactive = uih->zoomactive;
	}
	if ((s->mode >= UIH_SAVEPOS || uih->displaytext)
	    && s->color != uih->color) {
	    start_save(uih, "color");
	    save_nstring(uih, uih->color, uih_colornames);
	    stop_save(uih);
	    s->color = uih->color;
	}
	if (s->clearscreen) {
	    save_noparam(uih, "clearscreen");
	    s->clearscreen = 0;
	    s->nonfractalscreen = 1;
	}
	if (uih->displaytext) {
	    for (i = 0; i < 3; i++) {
		if (uih->displaytext & (1 << i)) {
		    if (s->ytextpos != i || s->xtextpos != uih->textpos[i]) {
			start_save(uih, "textpossition");
			save_nstring(uih, uih->xtextpos, xtextposnames);
			save_nstring(uih, uih->ytextpos, ytextposnames);
			stop_save(uih);
			s->xtextpos = uih->xtextpos;
			s->ytextpos = uih->ytextpos;
		    }
		    save_stringc(uih, "text", uih->text[i]);
		    s->nonfractalscreen = 1;
		}
	    }
	    save_noparam(uih, "textsleep");
	    uih->displaytext = 0;
	}
	if (s->autorotate && changed
	    && tl_lookup_timer(uih->savec->synctimer) > 500000)
	    save_float2c(uih, "angle", uih->fcontext->angle, 5),
		resetsync = 1;
	if (s->mode == UIH_SAVEPOS)
	    savepos(uih);
	else {
	    if (uih->viewchanged)
		savepos(uih), uih->viewchanged = 0;
	    else if (uih->moved)
		savepos3(uih), uih->moved = 0;
	    else if (((changed && uih->step) || last)
		     && tl_lookup_timer(uih->savec->synctimer) > 500000)
		resetsync = 1, savepos2(uih);
	}
	if (uih->savec->firsttime)
	    uih->savec->firsttime = 0;
	if (s->writefailed)
	    uih_save_disable(uih);
	if (resetsync)
	    tl_reset_timer(uih->savec->synctimer);
    }				/*if uih->save */
}