Пример #1
0
void init_dict()
{
    allocate();

    /* create "hidden" names */
    forth_chain    = new_name(NULL, ".forth.", 7, 1);
    compiler_chain = new_name(NULL, ".compiler.", 10, 1);

    init_chain(forth_chain, initial_forth);
    init_chain(compiler_chain, initial_compiler);
}
void scene_view::mousePressEvent(QMouseEvent *event)
{
    auto btns = event->buttons();
    const bool mouse_left = btns.testFlag(Qt::LeftButton);

    if (m_mode == mode_add && mouse_left && !m_selected_add.id.empty())
    {
        m_objects.push_back(m_selected_add);
        m_objects.back().name = new_name("object", m_objects);
        update_objects_tree();
    }

    if (m_mode == mode_zone && mouse_left)
    {
        add_zone(m_zone_add);
        m_zones.back().name = new_name("zone", m_zones);
        update_objects_tree();
    }

    if (m_mode == mode_path && mouse_left)
    {
        auto p0 = nya_math::vec4(m_cursor_pos, m_selected_add.y);
        const auto &sel_paths = m_selection["paths"];
        if (sel_paths.empty())
        {
            path p;
            p.name = new_name("path", m_paths);
            p.points.push_back(p0);
            m_paths.push_back(p);
            update_objects_tree();
            set_selection("paths", m_paths.size() - 1);
        }
        else
        {
            int idx = *sel_paths.rbegin();
            if (idx < (int)m_paths.size())
            {
                m_paths[idx].points.push_back(p0);
                set_selection("paths", idx);
            }
        }
    }

    m_mouse_x = event->localPos().x();
    m_mouse_y = event->localPos().y();

    update();
}
Пример #3
0
	std::string file_renamed_alert::message() const
	{
		char msg[200 + TORRENT_MAX_PATH * 2];
		snprintf(msg, sizeof(msg), "%s: file %d renamed to %s"
			, torrent_alert::message().c_str(), index, new_name());
		return msg;
	}
Пример #4
0
wxString ScrolledWidgetsPane::RenameDupFieldName(const wxString& old_name)
{
	wxString new_name(old_name);
    while (field_dict.find(new_name) != field_dict.end() ||
           field_dict.find(new_name.Upper()) != field_dict.end() ||
           field_dict.find(new_name.Lower()) != field_dict.end()) {
        
    	// duplicated name, try to append suffix in the form "_x"
    	wxRegEx regex;
    	long suffix_number = 1;
    	regex.Compile("_[0-9]+$");
    	if ( regex.Matches(new_name) ) {
    		wxString tmp_suffix = new_name.AfterLast('_');
    		if (tmp_suffix.ToLong(&suffix_number)) {
    			new_name = new_name.BeforeLast('_');
    			suffix_number += 1;
    		}
    	}
    	if (new_name.EndsWith("_")) new_name << suffix_number;
    	else new_name << "_" << suffix_number;
    	
    	int max_len = GdaConst::datasrc_field_lens[ds_type];
    	if ( new_name.length() > max_len ) {
    		int offset = new_name.length() - max_len;
    		wxString first_part = new_name.BeforeLast('_');
    		wxString last_part = new_name.AfterLast('_');
    		first_part = TruncateFieldName(first_part, first_part.length()-offset);
    		new_name = first_part + "_" + last_part;
    	}
    }
    return new_name;
}
Пример #5
0
// add an enum even if its name already exists
enum_t add_dup_enum(DieHolder &enumeration_holder, char const *name,
                    flags_t flag)
{
  enum_t enum_id = add_enum(BADADDR, name, flag);

  // failed to add?
  if(enum_id == BADNODE)
  {
    qstring new_name(name);

    while(enum_id == BADNODE)
    {
      new_name.append('_');
      EnumCmp enum_cmp(new_name.c_str());

      // check if there is an existing equal enum
      // with the same new name
      if(enum_cmp.equal(enumeration_holder))
      {
        enum_id = enum_cmp.get_enum_id();
      }
      else
      {
        enum_id = add_enum(BADADDR, new_name.c_str(), flag);
      }
    }
  }

  return enum_id;
}
Пример #6
0
// add a struct/union even if its name already exists
tid_t add_dup_struc(DieHolder &structure_holder, char const *name,
                    uint32 *ordinal)
{
  bool const is_union = structure_holder.get_tag() == DW_TAG_union_type;
  tid_t struc_id = add_struc(BADADDR, name, is_union);

  // failed to add?
  if(struc_id == BADNODE)
  {
    qstring new_name(name);

    while(struc_id == BADNODE)
    {
      new_name.append('_');
      StrucCmp struc_cmp(new_name.c_str());

      // check if there is an existing equal struct/union
      // with the same new name
      if(struc_cmp.equal(structure_holder))
      {
        struc_id = struc_cmp.get_struc_id();
        *ordinal = struc_cmp.get_ordinal();
      }
      else
      {
        struc_id = add_struc(BADADDR, new_name.c_str(), is_union);
      }
    }
  }

  return struc_id;
}
Пример #7
0
int
TAO_Transient_Bindings_Map::shared_bind (const char * id,
                                         const char * kind,
                                         CORBA::Object_ptr obj,
                                         CosNaming::BindingType type,
                                         int rebind)
{
  TAO_ExtId new_name (id, kind);
  TAO_IntId new_entry (obj, type);
  TAO_IntId old_entry;

  if (rebind == 0)
    // Do a normal bind.
    return this->map_.bind (new_name, new_entry);

  else
    // Rebind.
    {
      // Check that types of old and new entries match.
      if (this->map_.find (new_name,
                           old_entry) == 0
          && type != old_entry.type_)
        return -2;

      else
        return this->map_.rebind (new_name, new_entry);
    }
}
Пример #8
0
/* (name)  ( link a u hidden - 'suffix) */
void mu_name_()
{
    struct dict_name *pnm = new_name(
        (struct dict_name *)ST3, (char *)ST2, ST1, TOP);
    DROP(3);
    TOP = (addr)pnm;
}
Пример #9
0
/*
 * spec_dearchive() - Recreate a spec that was archived on this XDR stream.
 */
bool_t
spec_dearchive(
	char  	      **old_spec_id_ptr,
	char  	      **new_spec_id_ptr,
	char	      **path_as_archived,
	Lstar_string_map_list_ptr renamings,
	char  	       *where_to_create,
	bool_t		preserve__props,
	bool_t	      (*dearchive_this_path)(char *, void *),
	void	       *context,
	int		verbosity,
	XDR    	       *xdrs,
 	Tt_status      *err )
{
	_Tt_string	where( where_to_create );

	*err = TT_OK;
	*old_spec_id_ptr = NULL;
	*new_spec_id_ptr = NULL;
	*path_as_archived = NULL;
	if (xdrs->x_op == XDR_ENCODE) {
		return FALSE;
	} else if (xdrs->x_op == XDR_DECODE) {
		Lstar_spec spec;
		_Tt_string path;

		if (! spec.xdr(xdrs)) {
			return FALSE;
		}
		*old_spec_id_ptr = _tt_strdup( spec.id() );
		*path_as_archived = _tt_strdup( spec.path() );
		path = spec.path();
		if (    (dearchive_this_path == NULL)
		     || (dearchive_this_path( (char *)path, context )))
		{
			_Tt_string _new_name = new_name( spec.path(),
						         renamings );
			if (_new_name.len() > 0) {
				if (verbosity > 2) {
					fprintf( stderr, "%s => ",
						 (char *)spec.path() );
				}
				spec.path_set( _new_name );
				if (verbosity > 2) {
					fprintf( stderr, "%s\n",
						 (char *)spec.path() );
				}
			}
			*new_spec_id_ptr =
				spec.write_self( where, preserve__props, err );
			if (! IS_TT_ERR(*err) && (verbosity > 1)) {
				spec.print( stdout );
			}
		}
	}
	return TRUE;

} /* spec_dearchive() */
Пример #10
0
int symbol_table<T>::add_symbol(const char* sym_name, T sym_value)
{
  std::string new_name(sym_name);
  for( typename std::deque<std::pair<std::string,T> >::iterator it = symbols.begin() ; it != symbols.end() ; it++ )
    if( it->first.compare(new_name) == 0 )
      return -1;
  symbols.push_back(std::pair<std::string,T>(new_name,sym_value));
  return 0;
}
Пример #11
0
void LLInventoryObject::rename(const std::string& n)
{
	std::string new_name(n);
	correctInventoryName(new_name);
	if( !new_name.empty() && new_name != mName )
	{
		mName = new_name;
	}
}
Пример #12
0
user user_set::new_user(const std::string &token) {
	if (tokens.count(token) == 0) {
		user u(token, new_name());
		names.emplace(std::make_pair(u.name(), u));
		tokens.emplace(std::make_pair(u.token(), u));
		return u;
	}
	return tokens.at(token);
}
Пример #13
0
/*----------------function to return a pointer to a node (old or new)---------*/
nodeptr find_node(nameptr head, char in_name[], char in_id)
{
	nameptr p;
	
	if (head==NULL)				/* empty list */
	{
		p=new_name();
		name_header=p;
		strcpy(p->name,in_name);
		p->addr=new_node();
		p->next=NULL;
		p->addr->node_id=in_id;
		if (in_id=='v') strcpy(p->addr->node_data.va_term.v_name,in_name);
		if (in_id=='c') 
		{
			strcpy(p->addr->node_data.cn_term.c_name,in_name);
			p->addr->node_data.cn_term.c_value=123.45;	
			/* any initial value other than 0 and 1 */
		}
		return(p->addr);
	}
	
	p=head;	
	while ((strcmp(p->name,in_name)!=0)&&(p->next!=NULL))	p=p->next;
	
	if (strcmp(p->name,in_name)==0) return(p->addr);		/* name found */
	
	if (p->next==NULL)				/* no such name, add a new one at end*/
	{								
		p->next=new_name();
		strcpy(p->next->name,in_name);
		p->next->addr=new_node();
		p->next->next=NULL;
		p->next->addr->node_id=in_id;
		if (in_id=='v') strcpy(p->next->addr->node_data.va_term.v_name,in_name);
		if (in_id=='c') 
		{
			strcpy(p->next->addr->node_data.cn_term.c_name,in_name);
			p->next->addr->node_data.cn_term.c_value=123.45;
			/* any initial value other than 0 and 1 */
		}
		return(p->next->addr);
	}
}
Пример #14
0
void wxGenericDirDialog::OnNew( wxCommandEvent& WXUNUSED(event) )
{
    wxTreeItemId id = m_dirCtrl->GetTreeCtrl()->GetSelection();
    if ((id == m_dirCtrl->GetTreeCtrl()->GetRootItem()) ||
        (m_dirCtrl->GetTreeCtrl()->GetItemParent(id) == m_dirCtrl->GetTreeCtrl()->GetRootItem()))
    {
        wxMessageDialog msg(this, _("You cannot add a new directory to this section."),
                            _("Create directory"), wxOK | wxICON_INFORMATION );
        msg.ShowModal();
        return;
    }

    wxTreeItemId parent = id ; // m_dirCtrl->GetTreeCtrl()->GetItemParent( id );
    wxDirItemData *data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData( parent );
    wxASSERT( data );

    wxString new_name( _("NewName") );
    wxString path( data->m_path );
    if (!wxEndsWithPathSeparator(path))
        path += wxFILE_SEP_PATH;
    path += new_name;
    if (wxDirExists(path))
    {
        // try NewName0, NewName1 etc.
        int i = 0;
        do {
            new_name = _("NewName");
            wxString num;
            num.Printf( wxT("%d"), i );
            new_name += num;

            path = data->m_path;
            if (!wxEndsWithPathSeparator(path))
                path += wxFILE_SEP_PATH;
            path += new_name;
            i++;
        } while (wxDirExists(path));
    }

    wxLogNull log;
    if (!wxMkdir(path))
    {
        wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        return;
    }

    wxDirItemData *new_data = new wxDirItemData( path, new_name, true );

    // TODO: THIS CODE DOESN'T WORK YET. We need to avoid duplication of the first child
    // of the parent.
    wxTreeItemId new_id = m_dirCtrl->GetTreeCtrl()->AppendItem( parent, new_name, 0, 0, new_data );
    m_dirCtrl->GetTreeCtrl()->EnsureVisible( new_id );
    m_dirCtrl->GetTreeCtrl()->EditLabel( new_id );
}
Пример #15
0
char *
add_vector(const char **args, int narg)
{
    char *tmp;
    assert(narg);
    tmp = new_name("vec"); /* XXX coallesce */
    symtab = new_symbol(tmp, NULL, narg);
    free(tmp);
    symtab->val = (void *)args; /* XXX abuse */
    return symtab->key;
}
Пример #16
0
void LLInventoryObject::rename(const std::string& n)
{
	std::string new_name(n);
	LLStringUtil::replaceNonstandardASCII(new_name, ' ');
	LLStringUtil::replaceChar(new_name, '|', ' ');
	LLStringUtil::trim(new_name);
	LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN);

	if( new_name != mName )
	{
		mName = new_name;
	}
}
bool CPicTransition::run_effect(char *effect_name,unsigned extra)
{
	QString new_name(effect_name);
	for(int i=0;i<=cur_effect_len;i++) {
		if(effect_list[i].name.compare(new_name,Qt::CaseInsensitive)==0) {
			if(effect_list[i].fun!=NULL)
				effect_list[i].fun(&src_area,&dst_area,extra);
				return true;
		}
	}
	return false;
	//copy_area(&src_area,&dst_area,extra);
	
}
Пример #18
0
int
remove_any_file (const char *path, int recurse)
{
  struct L_STAT stat_buffer;

  if (L_LSTAT (path, &stat_buffer) < 0)
    return 0;

  if (S_ISDIR (stat_buffer.st_mode))
    if (recurse)
      {
	DIR *dirp = opendir (path);
	struct dirent *dp;

	if (dirp == NULL)
	  return 0;

	while (dp = readdir (dirp), dp && !is_dot_or_dotdot (dp->d_name))
	  {
	    char *path_buffer = new_name (path, dp->d_name);

	    if (!remove_any_file (path_buffer, 1))
	      {
		int saved_errno = errno;

		free (path_buffer);
		closedir (dirp);
		errno = saved_errno; /* FIXME: errno should be read-only */
		return 0;
	      }
	    free (path_buffer);
	  }
	closedir (dirp);
	return rmdir (path) >= 0;
      }
    else
      {
	/* FIXME: Saving errno might not be needed anymore, now that
	   extract_archive tests for the special case before recovery.  */
	int saved_errno = errno;

	if (rmdir (path) >= 0)
	  return 1;
	errno = saved_errno;	/* FIXME: errno should be read-only */
	return 0;
      }

  return unlink (path) >= 0;
}
Пример #19
0
char *
add_string(const char *arg)
{
    char *tmp;
    struct SYM *p;
    for (p = symtab; p; p = p->next) {
        if (p->type == SYMBOL_STRING && !strcmp(p->val, arg)) {
            return p->key;
        }
    }
    tmp = new_name("str");
    symtab = new_symbol(tmp, arg, SYMBOL_STRING);
    free(tmp);
    return symtab->key;
}
Пример #20
0
void wxFileCtrl::OnListEndLabelEdit( wxListEvent &event )
{
    wxFileData *fd = (wxFileData*)event.m_item.m_data;
    wxASSERT( fd );

    if ((event.GetLabel().empty()) ||
            (event.GetLabel() == _(".")) ||
            (event.GetLabel() == _("..")) ||
            (event.GetLabel().First( wxFILE_SEP_PATH ) != wxNOT_FOUND))
    {
        wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
        return;
    }

    wxString new_name( wxPathOnly( fd->GetFilePath() ) );
    new_name += wxFILE_SEP_PATH;
    new_name += event.GetLabel();

    wxLogNull log;

    if (wxFileExists(new_name))
    {
        wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
    }

    if (wxRenameFile(fd->GetFilePath(),new_name))
    {
        fd->SetNewName( new_name, event.GetLabel() );

        ignoreChanges = true;
        SetItemState( event.GetItem(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
        ignoreChanges = false;

        UpdateItem( event.GetItem() );
        EnsureVisible( event.GetItem() );
    }
    else
    {
        wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
    }
}
Пример #21
0
void wxFileCtrl::MakeDir()
{
    wxString new_name( _("NewName") );
    wxString path( m_dirName );
    path += wxFILE_SEP_PATH;
    path += new_name;
    if (wxFileExists(path))
    {
        // try NewName0, NewName1 etc.
        int i = 0;
        do {
            new_name = _("NewName");
            wxString num;
            num.Printf( wxT("%d"), i );
            new_name += num;

            path = m_dirName;
            path += wxFILE_SEP_PATH;
            path += new_name;
            i++;
        } while (wxFileExists(path));
    }

    wxLogNull log;
    if (!wxMkdir(path))
    {
        wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        return;
    }

    wxFileData *fd = new wxFileData( path, new_name, wxFileData::is_dir, wxFileIconsTable::folder );
    wxListItem item;
    item.m_itemId = 0;
    item.m_col = 0;
    long id = Add( fd, item );

    if (id != -1)
    {
        SortItems(m_sort_field, m_sort_foward);
        id = FindItem( 0, (long)fd );
        EnsureVisible( id );
        EditLabel( id );
    }
    else
        delete fd;
}
Пример #22
0
void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event)
{
    if (event.IsEditCancelled())
        return;

    if ((event.GetLabel().empty()) ||
        (event.GetLabel() == wxT(".")) ||
        (event.GetLabel() == wxT("..")) ||
        (event.GetLabel().Find(wxT('/')) != wxNOT_FOUND) ||
        (event.GetLabel().Find(wxT('\\')) != wxNOT_FOUND) ||
        (event.GetLabel().Find(wxT('|')) != wxNOT_FOUND))
    {
        wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
        return;
    }

    wxTreeItemId treeid = event.GetItem();
    wxDirItemData *data = (wxDirItemData*)m_treeCtrl->GetItemData( treeid );
    wxASSERT( data );

    wxString new_name( wxPathOnly( data->m_path ) );
    new_name += wxString(wxFILE_SEP_PATH);
    new_name += event.GetLabel();

    wxLogNull log;

    if (wxFileExists(new_name))
    {
        wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
    }

    if (wxRenameFile(data->m_path,new_name))
    {
        data->SetNewDirName( new_name );
    }
    else
    {
        wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
    }
}
bool CPicTransition::register_effect(const char* effect_name,unsigned effect_fun)
{
	if(cur_effect_len>=(MAX_EFFECT-1)) return false;
	
	QString new_name(effect_name);
	if(cur_effect_len<0) {
		 effect_list[++cur_effect_len].name  += new_name;
		 effect_list[cur_effect_len].fun   = (effect_fun_t)effect_fun;
	} else {
		for(int i=0;i<=cur_effect_len;i++) {
			if(effect_list[i].name.compare(new_name,Qt::CaseInsensitive)==0) return false;
		}
		effect_list[++cur_effect_len].name  += new_name;
		effect_list[cur_effect_len].fun  = (effect_fun_t)effect_fun;
	}
	return true;
}
Пример #24
0
void rotate(std::string dir, size_t boot_count)
{
    try 
    {
        log_pattern m = find_greatest_index(dir, boot_count);
        std::stringstream ss;
        ss << m.prefix << '.' << std::setfill('0') << std::setw(6) << m.boot_count;
        log_pattern new_name(m);
        new_name.is_active = false;
        ++new_name.sequence_number;
        rename( (dir+"/"+ss.str()).c_str(), (dir+"/"+new_name.name()).c_str());
    } 
    catch(std::out_of_range const & e)
    {
        //File not found.
        //Nothing to rotate.
    }
}
Пример #25
0
wxString ScrolledWidgetsPane::GetSuggestFieldName(const wxString& old_name)
{
	wxString new_name(old_name);
	
	// if illegal name
	new_name = RemoveIllegalChars(new_name);
	
	// if name too long
	new_name = TruncateFieldName(new_name);
	
	// check duplicate name
    new_name = RenameDupFieldName(new_name);
	
	field_names_dict[old_name] = new_name;
	
    // add any new suggest name to search dict
    field_dict[new_name] = true;
    
	return new_name;
}
Пример #26
0
// give suggested field name based on GdaConst::DataSourceType
wxString ScrolledWidgetsPane::GetSuggestFieldName(int field_idx)
{
    wxString old_name = old_field_names[field_idx];
	wxString new_name(old_name);
	
	// if illegal name
	new_name = RemoveIllegalChars(new_name);
	
	// if name too long
	new_name = TruncateFieldName(new_name);
	
	// check duplicate name
    new_name = RenameDupFieldName(new_name);

    // put it to new field name list
    new_field_names[field_idx] = new_name;
	
    // add any new suggest name to search dict
    field_dict[new_name] = true;
    
	return new_name;
}
Пример #27
0
  void TesterAnalizer::insert_testcases( std::fstream * stream, std::string name )
  {
    std::string line;
    std::string new_name( name );
    new_name.append( ".temp" );

    std::fstream new_source( new_name, WRITE|APPEND );

    if( new_source.is_open() )
    {
      while( std::getline( (* stream ), line ) )
      {
        if( line.find( "*/" ) != std::string::npos )
        {
          line.pop_back();
          line.pop_back();
        }

        for( int i = 0; i < data->methods.size(); i++ )
        {
          if( line.find( data->methods[ i ].name ) != std::string::npos )
          {
            long found = new_source.tellp();
            new_source.seekp( found-10 );

            std::string testcase = create_testcases( data->methods[ i ] );
            new_source << testcase << std::endl;
          }
        }

        new_source << line << std::endl;
      }

      new_source.close();
    }

    std::remove( name.c_str() );
    std::rename( new_name.c_str(), name.c_str() );
  }
// Reset all the values for the parcel in preparation for a sale
void LLFloaterAuction::doResetParcel()
{
	LLParcel* parcelp = mParcelp->getParcel();
	LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion();

	if (parcelp
		&& region
		&& !mParcelUpdateCapUrl.empty())
	{
		LLSD body;
		std::string empty;

		// request new properties update from simulator
		U32 message_flags = 0x01;
		body["flags"] = ll_sd_from_U32(message_flags);

		// Set all the default parcel properties for auction
		body["local_id"] = parcelp->getLocalID();

		U32 parcel_flags = PF_ALLOW_LANDMARK |
						   PF_ALLOW_FLY	|
						   PF_CREATE_GROUP_OBJECTS |
						   PF_ALLOW_ALL_OBJECT_ENTRY |
						   PF_ALLOW_GROUP_OBJECT_ENTRY |
						   PF_ALLOW_GROUP_SCRIPTS |
						   PF_RESTRICT_PUSHOBJECT |
						   PF_SOUND_LOCAL |
						   PF_ALLOW_VOICE_CHAT |
						   PF_USE_ESTATE_VOICE_CHAN;

		body["parcel_flags"] = ll_sd_from_U32(parcel_flags);
		
		// Build a parcel name like "Ahern (128,128) PG 4032m"
		std::ostringstream parcel_name;
		LLVector3 center_point( parcelp->getCenterpoint() );
		center_point.snap(0);		// Get rid of fractions
		parcel_name << region->getName() 
					<< " ("
					<< (S32) center_point.mV[VX]
					<< ","
					<< (S32) center_point.mV[VY]						
					<< ") "
					<< region->getSimAccessString()
					<< " "
					<< parcelp->getArea()
					<< "m";

		std::string new_name(parcel_name.str().c_str());
		body["name"] = new_name;
		getChild<LLUICtrl>("parcel_text")->setValue(new_name);	// Set name in dialog as well, since it won't get updated otherwise

		body["sale_price"] = (S32) 0;
		body["description"] = empty;
		body["music_url"] = empty;
		body["media_url"] = empty;
		body["media_desc"] = empty;
		body["media_type"] = LLMIMETypes::getDefaultMimeType();
		body["media_width"] = (S32) 0;
		body["media_height"] = (S32) 0;
		body["auto_scale"] = (S32) 0;
		body["media_loop"] = (S32) 0;
		body["obscure_media"] = (S32) 0; // OBSOLETE - no longer used
		body["obscure_music"] = (S32) 0; // OBSOLETE - no longer used
		body["media_id"] = LLUUID::null;
		body["group_id"] = MAINTENANCE_GROUP_ID;	// Use maintenance group
		body["pass_price"] = (S32) 10;		// Defaults to $10
		body["pass_hours"] = 0.0f;
		body["category"] = (U8) LLParcel::C_NONE;
		body["auth_buyer_id"] = LLUUID::null;
		body["snapshot_id"] = LLUUID::null;
		body["user_location"] = ll_sd_from_vector3( LLVector3::zero );
		body["user_look_at"] = ll_sd_from_vector3( LLVector3::zero );
		body["landing_type"] = (U8) LLParcel::L_DIRECT;

		llinfos << "Sending parcel update to reset for auction via capability to: "
			<< mParcelUpdateCapUrl << llendl;
		LLHTTPClient::post(mParcelUpdateCapUrl, body, new LLHTTPClient::Responder());

		// Send a message to clear the object return time
		LLMessageSystem *msg = gMessageSystem;
		msg->newMessageFast(_PREHASH_ParcelSetOtherCleanTime);
		msg->nextBlockFast(_PREHASH_AgentData);
		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
		msg->nextBlockFast(_PREHASH_ParcelData);
		msg->addS32Fast(_PREHASH_LocalID, parcelp->getLocalID());
		msg->addS32Fast(_PREHASH_OtherCleanTime, 5);			// 5 minute object auto-return

		msg->sendReliable(region->getHost());

		// Clear the access lists
		clearParcelAccessLists(parcelp, region);
	}
}
Пример #29
0
/* Examine the directories under directory_name and delete any
   files that were not there at the time of the back-up. */
static bool
try_purge_directory (char const *directory_name)
{
  char *current_dir;
  char *cur, *arc, *p;
  char *temp_stub = NULL;
  struct dumpdir *dump;

  if (!is_dumpdir (&current_stat_info))
    return false;

  current_dir = savedir (directory_name);

  if (!current_dir)
    /* The directory doesn't exist now.  It'll be created.  In any
       case, we don't have to delete any files out of it.  */
    return false;

  /* Verify if dump directory is sane */
  if (!dumpdir_ok (current_stat_info.dumpdir))
    return false;

  /* Process renames */
  for (arc = current_stat_info.dumpdir; *arc; arc += strlen (arc) + 1)
    {
      if (*arc == 'X')
	{
#define TEMP_DIR_TEMPLATE "tar.XXXXXX"
	  size_t len = strlen (arc + 1);
	  temp_stub = xrealloc (temp_stub, len + 1 + sizeof TEMP_DIR_TEMPLATE);
	  memcpy (temp_stub, arc + 1, len);
	  temp_stub[len] = '/';
	  memcpy (temp_stub + len + 1, TEMP_DIR_TEMPLATE,
		  sizeof TEMP_DIR_TEMPLATE);
	  if (!mkdtemp (temp_stub))
	    {
	      ERROR ((0, errno,
		      _("Cannot create temporary directory using template %s"),
		      quote (temp_stub)));
	      free (temp_stub);
	      free (current_dir);
	      return false;
	    }
	}
      else if (*arc == 'R')
	{
	  char *src, *dst;
	  src = arc + 1;
	  arc += strlen (arc) + 1;
	  dst = arc + 1;

	  /* Ensure that neither source nor destination are absolute file
	     names (unless permitted by -P option), and that they do not
	     contain dubious parts (e.g. ../).

	     This is an extra safety precaution. Besides, it might be
	     necessary to extract from archives created with tar versions
	     prior to 1.19. */

	  if (*src)
	    src = safer_name_suffix (src, false, absolute_names_option);
	  if (*dst)
	    dst = safer_name_suffix (dst, false, absolute_names_option);

	  if (*src == 0)
	    src = temp_stub;
	  else if (*dst == 0)
	    dst = temp_stub;

	  if (!rename_directory (src, dst))
	    {
	      free (temp_stub);
	      free (current_dir);
	      /* FIXME: Make sure purge_directory(dst) will return
		 immediately */
	      return false;
	    }
	}
    }

  free (temp_stub);

  /* Process deletes */
  dump = dumpdir_create (current_stat_info.dumpdir);
  p = NULL;
  for (cur = current_dir; *cur; cur += strlen (cur) + 1)
    {
      const char *entry;
      struct stat st;
      if (p)
	free (p);
      p = new_name (directory_name, cur);

      if (deref_stat (false, p, &st))
	{
	  if (errno != ENOENT) /* FIXME: Maybe keep a list of renamed
				  dirs and check it here? */
	    {
	      stat_diag (p);
	      WARN ((0, 0, _("%s: Not purging directory: unable to stat"),
		     quotearg_colon (p)));
	    }
	  continue;
	}

      if (!(entry = dumpdir_locate (dump, cur))
	  || (*entry == 'D' && !S_ISDIR (st.st_mode))
	  || (*entry == 'Y' && S_ISDIR (st.st_mode)))
	{
	  if (one_file_system_option && st.st_dev != root_device)
	    {
	      WARN ((0, 0,
		     _("%s: directory is on a different device: not purging"),
		     quotearg_colon (p)));
	      continue;
	    }

	  if (! interactive_option || confirm ("delete", p))
	    {
	      if (verbose_option)
		fprintf (stdlis, _("%s: Deleting %s\n"),
			 program_name, quote (p));
	      if (! remove_any_file (p, RECURSIVE_REMOVE_OPTION))
		{
		  int e = errno;
		  ERROR ((0, e, _("%s: Cannot remove"), quotearg_colon (p)));
		}
	    }
	}
    }
  free (p);
  dumpdir_free (dump);
  
  free (current_dir);
  return true;
}
Пример #30
0
    void TestArchivingOfParameters() throw (Exception)
    {
        OutputFileHandler handler("archive", false);
        std::string archive_filename;
        archive_filename = handler.GetOutputDirectoryFullPath() + "parameterised_ode.arch";
        double param_value;
        std::string param_name;
        { // Save
            AbstractOdeSystem * const p_ode = new ParameterisedOde;

            TS_ASSERT_EQUALS(p_ode->GetNumberOfParameters(), 1u);
            param_value = p_ode->GetParameter(0);
            param_name = p_ode->rGetParameterNames()[0];

            std::ofstream ofs(archive_filename.c_str());
            boost::archive::text_oarchive output_arch(ofs);
            output_arch << p_ode;
            delete p_ode;
        }
        { // Normal load
            std::ifstream ifs(archive_filename.c_str(), std::ios::binary);
            boost::archive::text_iarchive input_arch(ifs);
            AbstractOdeSystem* p_ode;
            input_arch >> p_ode;

            TS_ASSERT_EQUALS(p_ode->GetSystemName(), "ParameterisedOde");
            TS_ASSERT_EQUALS(p_ode->GetParameter(0), param_value);
            TS_ASSERT_EQUALS(p_ode->rGetParameterNames()[0], param_name);
            TS_ASSERT_EQUALS(p_ode->GetNumberOfParameters(), 1u);

            delete p_ode;
        }
        { // Load with param name changed
            ParameterisedOde ode;
            boost::shared_ptr<const AbstractOdeSystemInformation> p_info = ode.GetSystemInformation();
            AbstractOdeSystemInformation* p_mod_info = const_cast<AbstractOdeSystemInformation*>(p_info.get());
            std::string new_name("new_param_name");
            TS_ASSERT_DIFFERS(p_mod_info->mParameterNames[0], new_name);
            p_mod_info->mParameterNames[0] = new_name;

            std::ifstream ifs(archive_filename.c_str(), std::ios::binary);
            boost::archive::text_iarchive input_arch(ifs);
            AbstractOdeSystem* p_ode;
            TS_ASSERT_THROWS_CONTAINS(input_arch >> p_ode, "Archive specifies a parameter 'a' which does not appear in this class.");
            // Mend the ODE system info for the following tests.
            p_mod_info->mParameterNames[0] = param_name;
        }
        { // Load with a parameter added
            ParameterisedOde ode;
            boost::shared_ptr<const AbstractOdeSystemInformation> p_info = ode.GetSystemInformation();
            AbstractOdeSystemInformation* p_mod_info = const_cast<AbstractOdeSystemInformation*>(p_info.get());

            p_mod_info->mParameterNames.push_back("new_name");

            std::ifstream ifs(archive_filename.c_str(), std::ios::binary);
            boost::archive::text_iarchive input_arch(ifs);
            AbstractOdeSystem* p_ode;
            TS_ASSERT_THROWS_CONTAINS(input_arch >> p_ode, "Number of ODE parameters in archive does not match number in class.");
            // Mend the ODE system info for the following tests.
            p_mod_info->mParameterNames.resize(1u);
        }
        { // Load with a parameter added, and the constructor providing a default
            ParameterisedOde ode;
            boost::shared_ptr<const AbstractOdeSystemInformation> p_info = ode.GetSystemInformation();
            AbstractOdeSystemInformation* p_mod_info = const_cast<AbstractOdeSystemInformation*>(p_info.get());

            p_mod_info->mParameterNames.push_back("new_name");

            std::ifstream ifs(archive_filename.c_str(), std::ios::binary);
            boost::archive::text_iarchive input_arch(ifs);
            AbstractOdeSystem* p_ode;
            ParameterisedOde::fakeSecondParameter = true;
            input_arch >> p_ode;
            delete p_ode;
            // Mend the ODE system info for the following tests.
            ParameterisedOde::fakeSecondParameter = false;
            p_mod_info->mParameterNames.resize(1u);
        }
        { // Load with no defaults provided by the constructor
            ParameterisedOde::noParameterDefaults = true;
            std::ifstream ifs(archive_filename.c_str(), std::ios::binary);
            boost::archive::text_iarchive input_arch(ifs);
            AbstractOdeSystem* p_ode;
            input_arch >> p_ode;
            delete p_ode;
            // Mend the ODE system info for the following tests.
            ParameterisedOde::noParameterDefaults = false;
        }
    }