예제 #1
0
/*
 * Lstar_spec_prop::write_self() - Write this prop onto the given spec.
 */
Tt_status Lstar_spec_prop::
write_self( char *spec_id, bool_t preserve__props )
{
	/*
	 * If we're not root and this is a blessed property,
	 * do not attempt to write it.
	 * Insert link here to policy statement about prop names in tt_c.h.
	 */
	if (    (_propname[0] == '_')
	     && (    (! preserve__props)
	          || (getuid() != 0)))
	{
		return TT_OK;
	}
	_Tt_string_list_cursor value_cursor( this->_values );
	char	*val;
	int	len;
	while (value_cursor.next()) {
		val = (char *)(*value_cursor);
		len = (*value_cursor).len();
		note_err( tt_spec_bprop_add( spec_id, (char *)_propname,
					    (unsigned char *)val, len));
		if (IS_TT_ERR(err_noted)) {
			return err_noted;
		}
	}
	return err_noted;
}
예제 #2
0
/*
 * Lstar_spec::write_self() - Recreate a spec like the one we are, returning
 *	the id of the spec created.  The string returned must be freed
 *	using tt_free().
 */
char * Lstar_spec::
write_self( _Tt_string where, bool_t preserve__props, Tt_status *err )
{
	char	       *spec_created = NULL;
	_Tt_string	path;

	if (this->_path.len() <= 0) {
		*err = TT_ERR_PATH;
		return NULL;
	}
	/*
	 * TO_DO: tt_spec_create() won't convert /./ to / in a path
	 * if the path doesn't exist.
	 */
	if (this->_path.left(2) == "./") {
		this->_path = this->_path.right( _path.len() - 2 );
	}
	/*
	 * If the archived path is absolute, ignore <where>.
	 */
	if (this->_path[0] == '/') {
		path = this->_path;
	} else {
		path = where.cat( "/" ).cat( this->_path );
	}
	note_ptr_err( tt_spec_create( (char *)path ));
	*err = err_noted;
	spec_created = ptr_returned;
	if (IS_TT_ERR(err_noted)) {
		return spec_created;
	}
	note_err( tt_spec_type_set( spec_created, (char *)this->_type ));
	*err = err_noted;
	if (IS_TT_ERR(err_noted)) {
		return spec_created;
	}
	Lstar_spec_prop_list_cursor prop_cursor( this->_props );
	while (prop_cursor.next()) {
		*err = prop_cursor->write_self( spec_created, preserve__props );
	}
	note_err( tt_spec_write( spec_created ));
	*err = err_noted;
	return spec_created;
}
예제 #3
0
파일: tttar_api.C 프로젝트: juddy/edcde
/*
 * path_lstt_archive() - Archive the specs on the given path. 
 */
static bool_t
path_lstt_archive(
	_Tt_string		path,
	int			verbosity,
	XDR		       *xdrs )
{
	_Tt_string_list	       *specs;
	Object_kind		obj_kind;
	int			num_specs_archived = 0;
	int			num_links_archived = 0;
	bool_t			val2return	   = TRUE;

	specs		= new _Tt_string_list;
	note_err( tt_file_objects_query( (char *)path, gather_specs, NULL, specs ));
	if (IS_TT_ERR(err_noted)) {
		delete specs;
		return TRUE;
	}
	while (! specs->is_empty()) {
		_Tt_string  spec = specs->top();
		Tt_status   tt_err;

		obj_kind = SPEC;
		specs->pop();
		if (! xdr_enum( xdrs, (enum_t *)&obj_kind )) {
			fprintf( stderr, "%s: ! xdr_enum()\n",
				 (char *)our_process_name );
			val2return = FALSE;
			break;
		}
		if (! spec_archive( (char *)spec, (char *)path, verbosity,
				    xdrs, &tt_err ))
		{
			val2return = FALSE;
			break;
		}
		num_specs_archived++;
	}
	if ((verbosity && num_specs_archived > 0 ) || (verbosity > 1)) {
		if (verbosity > 1) {
			fprintf( stderr, "\n" );
		}
		fprintf( stderr, "a %s: %d %s\n", (char *)path,
		         num_specs_archived,
		         ((num_specs_archived == 1) ? "spec" : "specs" ));
	}
	delete specs;
	return val2return;

} /* path_lstt_archive() */
예제 #4
0
/*
 * Lstar_spec_prop::Lstar_spec_prop()
 */
Lstar_spec_prop::
Lstar_spec_prop( _Tt_string id, _Tt_string propname )
{
	_propname = propname;
	_values = new _Tt_string_list();
	/*
	 * Get how many values are in the spec's property.
	 */
	note_int_err( tt_spec_prop_count( (char *)id, (char *)propname ));
	switch (err_noted) {
	    case TT_ERR_PROPNAME:
	    case TT_ERR_OBJID:
	    case TT_ERR_DBAVAIL:
		return;
	    case TT_ERR_DBEXIST:
	    default:
		if (IS_TT_ERR(err_noted)) {
			return;
		}
	}
	int num_values = int_returned;
	/*
	 * Push the property's values onto our list in reverse order,
	 * to preserve the order they had.
	 */
	for (int n = num_values - 1; n >= 0; n--) {
		int		len;
		unsigned char  *value;

		note_err( tt_spec_bprop( (char *)id, (char *)propname, n, &value, &len ));
		switch (err_noted) {
		    case TT_ERR_PROPNAME:
		    case TT_ERR_OBJID:
		    case TT_ERR_DBAVAIL:
			return;
		    case TT_ERR_NUM:
			continue;
		    case TT_ERR_DBEXIST:
		    default:
			if (IS_TT_ERR(err_noted)) {
				return;
			}
		}
		_Tt_string val( value, len );
		this->_values->push( val );
	}
}