Example #1
0
void RelationData::save(QTextStream & st, bool ref, QString & warning) const
{
    if (ref)
        st << "relation_ref " << get_ident() << " // " << (name);
    else {
        nl_indent(st);
        st << "relation " << get_ident() << " " << stringify(type);

        if (name != default_name(type)) {
            st << " name ";
            save_string(name, st);
        }

        indent(+1);

        BasicData::save(st, warning);

        if (original_id != 0) {
            nl_indent(st);
            st << "oid " << original_id;
        }

        bool assoc = isa_association(type);

        nl_indent(st);
        indent(+1);
        st << "a ";
        save_role(a, assoc, st, warning);
        start->save(st, TRUE, warning);
        indent(-1);

        nl_indent(st);
        indent(+1);
        st << "b";

        if (!RelationData::uni_directional(type)) {
            st << " ";
            save_role(b, assoc, st, warning);
            end->save(st, TRUE, warning);
        }
        else {
            if (!b.multiplicity.isEmpty()) {
                st << " multiplicity ";
                save_string(b.multiplicity, st);
            }

            st << " parent ";
            end_removed_from->save(st, TRUE, warning);
        }

        indent(-1);

        if ((association.type != 0) || !association.explicit_type.isEmpty()) {
            nl_indent(st);
            association.save(st, warning, "association_type ", "association_explicit_type ");
        }

        indent(-1);
    }
}
Example #2
0
void save_presets(int do_update)
{
    FILE *f=fopen("powder.def", "wb");
    unsigned char sig[4] = {0x50, 0x44, 0x65, 0x66};
    unsigned char tmp = sdl_scale;
    if(!f)
        return;
    fwrite(sig, 1, 4, f);
    save_string(f, svf_user);
    save_string(f, svf_pass);
    fwrite(&tmp, 1, 1, f);
    tmp = cmode;
    fwrite(&tmp, 1, 1, f);
    tmp = svf_admin;
    fwrite(&tmp, 1, 1, f);
    tmp = svf_mod;
    fwrite(&tmp, 1, 1, f);
    save_string(f, http_proxy_string);
    tmp = SAVE_VERSION;
    fwrite(&tmp, 1, 1, f);
    tmp = MINOR_VERSION;
    fwrite(&tmp, 1, 1, f);
    tmp = do_update;
    fwrite(&tmp, 1, 1, f);
    fclose(f);
}
Example #3
0
void Tool::save() 
{
  QByteArray newdef;
  Q3TextStream st(newdef, QIODevice::WriteOnly);
	
  st.setEncoding(Q3TextStream::Latin1);

  st << "// 'tool' \"the executable\" \"displayed string\" {target}+";
  
  for (unsigned rank = 0; rank != ntools; rank += 1) {
    ATool & tool = tools[rank];
    
    st << "\ntool ";
    save_string(tools[rank].display, st);
    st << ' ';
    save_string(tools[rank].cmd, st);
    
    for (int index = 0; index != sizeof(ToolCase) / sizeof(*ToolCase); index += 1) {
      if (tool.applicable[ToolCase[index].kind]) {
	st << ' ' << ToolCase[index].key;
      }
    }
  }
  st << '\n';
  
  st << '\000';
  save_if_needed("tools", newdef);
}
Example #4
0
char *
pcePPReference(PceObject ref)
{ if ( isInteger(ref) )
  { Any addr = longToPointer(valInt(ref));
    char *rval = pp(addr);

    if ( rval[0] != '@' )
    { char tmp[256];
      sprintf(tmp, "@" INTPTR_FORMAT, valInt(ref));
      return save_string(tmp);
    } else
      return rval;
  } else if ( isName(ref) )
  { Any addr;

    if ( !(addr = getObjectAssoc(ref)) )
    { char tmp[256];

      sprintf(tmp, "@%s", strName(ref));
      return save_string(tmp);
    } else
      return pp(addr);
  } else
    return save_string("invalid reference");
}
Example #5
0
void CodDirsCanvas::save(QTextStream & st, bool ref, QString & warning) const
{
    if (ref)
        st << "dirscanvas_ref " << get_ident();
    else {
        nl_indent(st);
        st << "dirscanvas " << get_ident() << " z " << zValue() << " ";
        link->save(st, TRUE, warning);

        indent(+1);

        settings.save_msg(st);

        if (label != 0) {
            nl_indent(st);
            st << "forward_label ";
            save_string(label->get_name().toLatin1().constData(), st);
            save_xyz(st, label, " xyz");
        }

        if (backward_label != 0) {
            nl_indent(st);
            st << "backward_label ";
            save_string(backward_label->get_name().toLatin1().constData(), st);
            save_xyz(st, backward_label, " xyz");
        }

        indent(-1);
    }
}
Example #6
0
void Tool::save()
{
    QSharedPointer<QByteArray> newdef(new QByteArray());
    QTextStream st(newdef.data(), QIODevice::WriteOnly);

    //st.setEncoding(QTextStream::Latin1);
    st.setCodec(QTextCodec::codecForName("latin1"));
    st << "// 'tool' \"the executable\" \"displayed string\" {target}+";

    for (unsigned rank = 0; rank != ntools; rank += 1) {
        ATool & tool = tools[rank];

        st << "\ntool ";
        save_string(tools[rank].display.toLatin1().constData(), st);
        st << " ";
        save_string(tools[rank].cmd.toLatin1().constData(), st);

        for (int index = 0; index != sizeof(ToolCase) / sizeof(*ToolCase); index += 1) {
            if (tool.applicable[ToolCase[index].kind]) {
                st << " " << ToolCase[index].key;
            }
        }
    }

    st << '\n';

    st << '\000';
    st.flush();
    save_if_needed("tools", newdef);
}
Example #7
0
void FragmentCanvas::save(QTextStream & st, bool ref, QString & warning) const {
  if (ref) {
    st << "fragment_ref " << get_ident();
  }
  else {
    nl_indent(st);
    
    st << "fragment " << get_ident() << ' ';
    save_string(name, st);
    indent(+1);
    nl_indent(st);
    if (itscolor != UmlDefaultColor)
      st << "color " << stringify(itscolor) << ' ';
    if (refer != 0) {
      st << "refer ";
      refer->save(st, TRUE, warning);
      nl_indent(st);
    }
    if (! form.isEmpty()) {
      st << "form ";
      save_string(form, st);
      st << ' ';
    }
    save_xyzwh(st, this, "xyzwh");
    
    Q3PtrListIterator<FragmentSeparatorCanvas> it(separators);
    
    for (; it.current(); ++it)
      it.current()->save(st, FALSE, warning);
    
    indent(-1);
    nl_indent(st);
    st << "end";
  }
}
Example #8
0
int main (void) {
	PageManager* pm = new_page_manager(".");
	printf("I Made my pm\n");
	printf("My index path is: %s\n", pm->index_path);
	RawPage* new_page = new_data_page(pm);
	printf("new page fd is %d at memory addr %p\n", new_page->fd, new_page->page);
	// Save some strings
	PageRef* str_1 = save_string(new_page, "Hello There");
	PageRef* str_2 = save_string(new_page, "I am a second string");
	printf("Before unload page\n");
	unload_page(new_page);
	printf("After unloda page\n");
	// load some strings
	load_string(pm, str_1);
	load_string(pm, str_2);

	//make our tree page
	RawPage* t_page = new_tree_page(pm);
	TreeNode* test_node = malloc(sizeof(TreeNode));
	memset(test_node, 0, sizeof(TreeNode));
	test_node->size = 0;
	test_node->order = 2;
	test_node->num_leaves = 0;
	test_node->parent.page_type = 0xDE110;
	test_node->parent.page_num = 31337;
	test_node->parent.node_offset = 31337;
	PageRef* node1 = save_node(t_page, test_node);
	unload_page(t_page);
	load_node(pm, node1);

}
Example #9
0
static int
cvtchar(register const char *sp)
/* convert a character to a terminfo push */
{
    unsigned char c = 0;
    int len;

    switch (*sp) {
    case '\\':
	switch (*++sp) {
	case '\'':
	case '$':
	case '\\':
	case '%':
	    c = *sp;
	    len = 2;
	    break;
	case '\0':
	    c = '\\';
	    len = 1;
	    break;
	case '0':
	case '1':
	case '2':
	case '3':
	    len = 1;
	    while (isdigit(UChar(*sp))) {
		c = 8 * c + (*sp++ - '0');
		len++;
	    }
	    break;
	default:
	    c = *sp;
	    len = 2;
	    break;
	}
	break;
    case '^':
	c = (*++sp & 0x1f);
	len = 2;
	break;
    default:
	c = *sp;
	len = 1;
    }
    if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') {
	dp = save_string(dp, "%\'");
	dp = save_char(dp, c);
	dp = save_char(dp, '\'');
    } else {
	dp = save_string(dp, "%{");
	if (c > 99)
	    dp = save_char(dp, c / 100 + '0');
	if (c > 9)
	    dp = save_char(dp, ((int) (c / 10)) % 10 + '0');
	dp = save_char(dp, c % 10 + '0');
	dp = save_char(dp, '}');
    }
    return len;
}
Example #10
0
def_t *
emit_structure (const char *name, int su, struct_def_t *defs, type_t *type,
				void *data, storage_class_t storage)
{
	int         i, j;
	int         saw_null = 0;
	int         saw_func = 0;
	symbol_t   *struct_sym;
	symbol_t   *field_sym;
	def_t      *struct_def;
	def_t       field_def;

	name = save_string (name);
	if (!type)
		type = make_structure (0, su, defs, 0)->type;
	if (!is_struct (type) || (su == 's' && type->meta != ty_struct)
		|| (su == 'u' && type->meta != ty_union))
		internal_error (0, "structure %s type mismatch", name);
	for (i = 0, field_sym = type->t.symtab->symbols; field_sym;
		 i++, field_sym = field_sym->next) {
		if (!defs[i].name)
			internal_error (0, "structure %s unexpected end of defs", name);
		if (field_sym->type != defs[i].type)
			internal_error (0, "structure %s.%s field type mismatch", name,
							defs[i].name);
		if ((!defs[i].emit && saw_func) || (defs[i].emit && saw_null))
			internal_error (0, "structure %s mixed emit/copy", name);
		if (!defs[i].emit)
			saw_null = 1;
		if (defs[i].emit)
			saw_func = 1;
	}
	if (defs[i].name)
		internal_error (0, "structure %s too many defs", name);
	if (storage != sc_global && storage != sc_static)
		internal_error (0, "structure %s must be global or static", name);

	struct_sym = make_symbol (name, type, pr.far_data, storage);

	struct_def = struct_sym->s.def;
	if (struct_def->initialized)
		internal_error (0, "structure %s already initialized", name);
	struct_def->initialized = struct_def->constant = 1;
	struct_def->nosave = 1;

	for (i = 0, field_sym = type->t.symtab->symbols; field_sym;
		 i++, field_sym = field_sym->next) {
		field_def.type = field_sym->type;
		field_def.name = save_string (va ("%s.%s", name, field_sym->name));
		field_def.space = struct_def->space;
		field_def.offset = struct_def->offset + field_sym->s.offset;
		if (!defs[i].emit) {
			//FIXME relocs? arrays? structs?
			pr_type_t  *val = (pr_type_t *) data;
			memcpy (D_POINTER (void, &field_def), val,
					type_size (field_def.type) * sizeof (pr_type_t));
			data = &val[type_size (field_def.type)];
		} else {
			if (is_array (field_def.type)) {
Example #11
0
void FormalParamData::save(QTextStream & st, QString & warning) const {
  nl_indent(st);
  st << "formal name ";
  save_string(name, st);
  st << " type ";
  save_string(type, st);
  default_value.save(st, warning, " default_value ", " explicit_default_value ");
  nl_indent(st);	// default_value may produce a comment
  extends.save(st, warning, "  extends ", "  explicit_extends ");
}
Example #12
0
int  C_THISCLASS::save_config(unsigned char *data)
{
	int pos=0;
  data[pos++]=1;
  save_string(data,pos,effect_exp[0]);
  save_string(data,pos,effect_exp[1]);
  save_string(data,pos,effect_exp[2]);
	PUT_INT(blend); pos+=4;
	PUT_INT(subpixel); pos+=4;
	return pos;
}
Example #13
0
void ParamData::save(QTextStream & st, QString & warning) const
{
    nl_indent(st);
    st << "  param " << stringify(dir) << " name ";
    save_string(name, st);
    type.save(st, warning, " type ", " explicit_type ");

    if (!default_value.isEmpty()) {
        nl_indent(st);
        st << "    defaultvalue ";
        save_string(default_value, st);
    }
}
Example #14
0
void HaveKeyValueData::save(Q3TextStream & st) const {
  if (nkeyvalues) {
    nl_indent(st);
    st << "ncouples " << nkeyvalues;
    
    for (unsigned i = 0; i != nkeyvalues; i += 1) {
      nl_indent(st);
      st << "key ";
      save_string(keyvalues[i].get_key(), st);
      st << " value ";
      save_string(keyvalues[i].get_value(), st);
    }
  }
}
Example #15
0
void BasicData::save(Q3TextStream & st, QString &) const {
  if (! stereotype.isEmpty()) {
    nl_indent(st);
    st << "stereotype ";
    save_string(stereotype, st);
  }
}
Example #16
0
bool
try_pk (string family, int size, int dpi, int dsize,
	tex_font_metric& tfm, font_glyphs& pk)
{
  // cout << "Try pk " << family << size << " at " << dpi << " dpi\n";
#ifdef USE_FREETYPE
  // Substitute by True Type font ?
  int tt_size= size<333? size: (size+50)/100;
  int tt_dpi = size<333? dpi : (size * dpi) / (100 * tt_size);
  string tt_name= tt_find_name (family, tt_size);
  if (tt_name != "") {
    if (font_glyphs::instances -> contains (tt_name))
      pk= font_glyphs (tt_name);
    else pk= tt_font_glyphs (tt_name, tt_size, tt_dpi);
    return true;
  }
#endif // USE_FREETYPE

  // Open regular pk font
  string name_pk= family * as_string (size) * "." * as_string (dpi) * "pk";
  if (font_glyphs::instances -> contains (name_pk)) {
    pk = font_glyphs (name_pk);
    return true;
  }
  if (dsize == 0) {
    int old_size= size;
    size= tfm->size;
    dpi = mag (dpi, old_size, size);
  }
  string size_name (dsize==0? string (""): as_string (size));
  string name (family * size_name * "." * as_string (dpi) * "pk");
  if (DEBUG_STD) debug_fonts << "Open pk " << name << "\n";
  url u= resolve_tex (name);
  if (is_none (u)) {
    if (exists (url ("$TEXMACS_HOME_PATH/fonts/error", name))) {
      if (DEBUG_STD)
        debug_fonts << "Error during " << name << " loading\n";
      return false;
    }
    if (get_setting ("MAKEPK") != "false") {
      system_wait ("Generating font file", name);
      make_tex_pk (family * size_name, dpi, as_int (get_setting ("DPI")));
      system_wait ("");
      u= resolve_tex (name);
      if (is_none (u)) {
	reset_pk_path ();
	u= resolve_tex (name);
      }
    }
    if (is_none (u)) {
      save_string (url ("$TEXMACS_HOME_PATH/fonts/error", name), "");
      if (DEBUG_STD)
        debug_fonts << "Error during " << name << " loading\n";
      return false;
    }
  }
  pk = font_glyphs (tm_new<pk_font_glyphs_rep> (name_pk,
					    tm_new<pk_loader> (u, tfm, dpi)));
  return true;
}
void filestorage::save_string(t_filestore file_type,
							  const std::string &filename,
							  const std::string &data,
							  bool overwrite) {

	if (filename == "") {
		throw std::invalid_argument("Fail to open file for write: empty filename");
	}

	fs::path file_with_path;
	try {

		file_with_path = prepare_path_for_write(file_type, filename, overwrite);
		fs::ofstream file(file_with_path, std::ios::out | std::ios::binary);

		if (file.is_open()) {
			file << data;
		} else {
			throw std::invalid_argument("Fail to open file for write: " + filename);
		}
		file.close();
		_dbg2("Successfully saved string to:" << file_with_path.native());

	} catch(overwrite_error &err) {
		std::cout << err.what() << std::endl;
		if(text_ui::ask_user_forpermission("overwrite file?")){
			save_string(file_type, filename, data, true);
		} else {
			_dbg2("Fail to save string");
		}
	}
}
Example #18
0
void
setup_texmacs () {
  url settings_file= "$TEXMACS_HOME_PATH/system/settings.scm";
  debug_boot << "Welcome to TeXmacs " TEXMACS_VERSION "\n";
  debug_boot << HRULE;

  set_setting ("VERSION", TEXMACS_VERSION);
  setup_tex ();
  setup_inkscape_extension ();
  
  string s= scheme_tree_to_block (texmacs_settings);
  //cout << "settings_t= " << texmacs_settings << "\n";
  //cout << "settings_s= " << s << "\n";
  if (save_string (settings_file, s) || load_string (settings_file, s, false)) {
    failed_error << HRULE;
    failed_error << "I could not save or reload the file\n\n";
    failed_error << "\t" << settings_file << "\n\n";
    failed_error << "Please give me full access control over this file and\n";
    failed_error << "rerun 'TeXmacs'.\n";
    failed_error << HRULE;
    FAILED ("unable to write settings");
  }
  
  debug_boot << HRULE;
  debug_boot << "Installation completed successfully !\n";
  debug_boot << "I will now start up the editor\n";
  debug_boot << HRULE;
}
Example #19
0
File: save.c Project: Azizou/XaoS
static void
save_stringc(struct uih_context *uih, const char *name, const char *param)
{
    start_save(uih, name);
    save_string(uih, param);
    stop_save(uih);
}
Example #20
0
void
cache_save (string buffer) {
  if (cache_changed->contains (buffer)) {
    url cache_file= texmacs_home_path * url ("system/cache/" * buffer);
    string cached;
    iterator<tree> it= iterate (cache_data);
    if (buffer == "file_cache" || buffer == "doc_cache") {
      while (it->busy ()) {
	tree ckey= it->next ();
	if (ckey[0] == buffer) {
	  cached << ckey[1]->label << "\n";
	  cached << cache_data [ckey]->label << "\n";
	  cached << "%-%-tm-cache-%-%\n";
	}
      }
    }
    else {
      cached << "(tuple\n";
      while (it->busy ()) {
	tree ckey= it->next ();
	if (ckey[0] == buffer) {
	  cached << tree_to_scheme (ckey[1]) << " ";
	  cached << tree_to_scheme (cache_data [ckey]) << "\n";
	}
      }
      cached << ")";
    }
    (void) save_string (cache_file, cached);
    cache_changed->remove (buffer);
  }
}
Example #21
0
void Settings::SaveToFile(std::ostream &os, void (*save_string)(std::ostream &os, const std::string &s)) const
{
	for (int i = 0; i < number_of_fields; ++i)
	{
		save_string( os, get_names(i) );
	}
}
Example #22
0
void DeploymentNodeCanvas::save(Q3TextStream & st, bool ref, QString & warning) const {
  if (ref)
    st << "deploymentnodecanvas_ref " << get_ident() << " // " << browser_node->get_name();
  else {
    nl_indent(st);
    st << "deploymentnodecanvas " << get_ident() << ' ';
    indent(+1);
    browser_node->save(st, TRUE, warning);
    if (!iname.isEmpty()) {
      nl_indent(st);
      st << "name ";
      save_string(iname, st);  
    }
    nl_indent(st);
    if (write_horizontally != UmlDefaultState)
      st << "write_horizontally " << stringify(write_horizontally) << ' ';
    if (show_stereotype_properties != UmlDefaultState)
      st << "show_stereotype_properties " << stringify(show_stereotype_properties) << ' ';
    if (itscolor != UmlDefaultColor)
      st << "color " << stringify(itscolor) << ' ';
    save_xyzwh(st, this, "xyzwh");
    save_stereotype_property(st, warning);
    indent(-1);
    nl_indent(st);
    st << "end";
  }
}
Example #23
0
void enter(struct node **node, char *word)
{
    int result;

    char *save_string(char *);

    if ((*node) == NULL) {
        (*node) = malloc(sizeof(struct node));
        if ((*node) == NULL)
            memory_error();

        (*node)->left = NULL;
        (*node)->right = NULL;
        (*node)->word = save_string(word);
        return;
    }

    result = strcmp((*node)->word, word);

    if (result == 0)
        return;
    if (result < 0)
        enter(&(*node)->right, word);
    else
        enter(&(*node)->left, word);
}
Example #24
0
void CodClassInstCanvas::save(QTextStream & st, bool ref, QString & warning) const {
  if (ref)
    st << "classinstance_ref " << get_ident() << " // "
      << full_name();
  else if (browser_node->get_type() == UmlClass) {
    nl_indent(st);
    st << "classinstance " << get_ident() << ' ';
    browser_node->save(st, TRUE, warning);
    nl_indent(st);
    ClassInstCanvas::save(st);
    st << " name ";
    save_string(iname, st);
    st << ' ';
    save_xyz(st, this, " xyz");
  }
  else {
    nl_indent(st);
    st << "classinstancecanvas " << get_ident() << ' ';
    browser_node->save(st, TRUE, warning);

    indent(+1);
    nl_indent(st);
    save_xyz(st, this, "xyz");
    ClassInstCanvas::save(st);
    save_stereotype_property(st, warning);    
    indent(-1);
    
    nl_indent(st);
    st << "end";
  }
}
Example #25
0
void 
gs_fix_bbox (url eps, int x1, int y1, int x2, int y2) {
// used to restore appropriate bounding box of an eps file in case epswrite 
// spuriously changes it (see gs_to_eps)
  string outbuf, buf;
  int inx1, iny1, inx2, iny2;
  bool err = load_string (eps, buf, false);
  if (!err) {
    if (DEBUG_CONVERT) debug_convert<< "fix_bbox input bbox : ";
    if ( !ps_read_bbox (buf, inx1, iny1, inx2, iny2 ) ) 
      return; //bbox not found... should not occur
    if (inx1!=x1 || iny1!=y1 || inx2!=x2 || iny2!=y2) {
      int pos= search_forwards ("%%BoundingBox:", buf);
      pos += 14;
      outbuf << buf(0, pos)
        << " " << as_string(x1) << " " << as_string(y1) 
        << " " << as_string(x2) << " " << as_string(y2) << "\n";
      skip_line (buf, pos);
      if (read (buf, pos, "%%HiResBoundingBox:")) skip_line (buf, pos);
      outbuf << buf(pos, N(buf));
      save_string (eps, outbuf, true);
      if (DEBUG_CONVERT) 
        debug_convert<< "restored bbox : " << ps_read_bbox (outbuf, x1, y1, x2, y2 )<<LF;
    }  
    set_imgbox_cache(eps->t, x2-x1, y2-y1, x1, y1);
  } 
}
Example #26
0
static inline char *
save_char(char *s, int c)
{
    static char temp[2];
    temp[0] = (char) c;
    return save_string(s, temp);
}
Example #27
0
static NCURSES_INLINE char *
save_char(char *s, int c)
{
    static char temp[2];
    temp[0] = (char) c;
    return save_string(s, temp);
}
Example #28
0
static char *
save_tc_inequality(char *bufptr, int c1, int c2)
{
    bufptr = save_string(bufptr, "%>");
    bufptr = save_tc_char(bufptr, c1);
    bufptr = save_tc_char(bufptr, c2);
    return bufptr;
}
Example #29
0
symbol_t *
new_symbol (const char *name)
{
	symbol_t   *symbol;
	ALLOC (256, symbol_t, symbols, symbol);
	symbol->name = save_string (name);
	return symbol;
}
Example #30
0
void panel_save_setup (WPanel *panel, char *section)
{
    char buffer [40];
    int  i;
    
    sprintf (buffer, "%d", panel->reverse);
    save_string (section, "reverse", buffer, profile_name);
    sprintf (buffer, "%d", panel->case_sensitive);
    save_string (section, "case_sensitive", buffer, profile_name);
    for (i = 0; sort_names [i].key; i++)
	if (sort_names [i].sort_type == (sortfn *) panel->sort_type){
	    save_string (section, "sort_order",
				       sort_names [i].key, profile_name);
	    break;
	}

    for (i = 0; list_types [i].key; i++)
	if (list_types [i].list_type == panel->list_type){
	    save_string (section, PORT_LIST_MODE_NAME, list_types [i].key, profile_name);
	    break;
	}
    
    save_string (section, "user_format",
			       panel->user_format, profile_name);
			       
    for (i = 0; i < LIST_TYPES; i++){
	sprintf (buffer, "user_status%d", i);
	save_string (section, buffer, 
	    panel->user_status_format [i], profile_name);
    }
			       
    sprintf (buffer, "%d", panel->user_mini_status);
    save_string (section, "user_mini_status", buffer,
			       profile_name);
}