Exemple #1
0
 std::string BugzillaLink::get_bug_url() const
 {
   std::string url;
   AttributeMap::const_iterator iter = get_attributes().find(URI_ATTRIBUTE_NAME);
   if(iter != get_attributes().end()) {
     url = iter->second;
   }
   return url;
 }
Exemple #2
0
ErrorCode ReadNC::read_header()
{
  dbgOut.tprint(1, "Reading header...\n");

  // Get the global attributes
  int numgatts;
  int success;
  success = NCFUNC(inq_natts )(fileId, &numgatts);
  if (success)
    MB_SET_ERR(MB_FAILURE, "Couldn't get number of global attributes");

  // Read attributes into globalAtts
  ErrorCode result = get_attributes(NC_GLOBAL, numgatts, globalAtts);MB_CHK_SET_ERR(result, "Trouble getting global attributes");
  dbgOut.tprintf(1, "Read %u attributes\n", (unsigned int) globalAtts.size());

  // Read in dimensions into dimNames and dimLens
  result = get_dimensions(fileId, dimNames, dimLens);MB_CHK_SET_ERR(result, "Trouble getting dimensions");
  dbgOut.tprintf(1, "Read %u dimensions\n", (unsigned int) dimNames.size());

  // Read in variables into varInfo
  result = get_variables();MB_CHK_SET_ERR(result, "Trouble getting variables");
  dbgOut.tprintf(1, "Read %u variables\n", (unsigned int) varInfo.size());

  return MB_SUCCESS;
}
// Default constructor
GenericLevelObj::GenericLevelObj(std::string obj_name) :
  sprite(),
  surface(),
  desc(),
  pos(Vector3f(0,0,0)),
  orig_pos(),
  section_name(obj_name),
  object_type(),
  ground_type(),
  speed(0),
  parallax(0.0),
  repeat(0),
  owner_id(0),
  release_rate(0),
  direction(),
  scroll_x(0),
  scroll_y(0),
  stretch_x(false),
  stretch_y(false),
  keep_aspect(false),
  para_x(0),
  para_y(0),
  color(0,0,0,0),
  origin(),
  small_stars(),
  middle_stars(),
  large_stars(),
  id(),
  target_id(),
  height(15),
  attribs(get_attributes(obj_name))
{
  if (attribs & HAS_SPRITE_FAKE)
    load_generic_surface();
}
void CL_DomElement::remove_attribute(const CL_DomString &name)
{
	if (impl)
	{
		CL_DomNamedNodeMap attributes = get_attributes();
		attributes.remove_named_item(name);
	}
}
Exemple #5
0
	void Shader::create(const std::string& name, Owner location){
	
		init();
		load_shaders(name,location);
		compile_shaders();
		link_shaders();
		get_attributes();
		get_uniforms();
	}
void CL_DomElement::remove_attribute_ns(
	const CL_DomString &namespace_uri,
	const CL_DomString &local_name)
{
	if (impl)
	{
		CL_DomNamedNodeMap attributes = get_attributes();
		attributes.remove_named_item_ns(namespace_uri, local_name);
	}
}
CL_DomAttr CL_DomElement::get_attribute_node(const CL_DomString &name) const
{
	if (impl)
	{
		CL_DomNamedNodeMap attributes = get_attributes();
		CL_DomAttr attribute = attributes.get_named_item(name).to_attr();
		return attribute;
	}
	return CL_DomAttr();
}
Exemple #8
0
struct Node* readfile(char *filename,int *Sample_Num,int *Atttr_Num,char *Atttr_Seq){

    FILE  *fp;
    int finished = 0;
    int i = 0, j,k;//m,n;
    char string[2000];
    char*ptr;
    struct Node *Sample;
    Sample=(struct Node *)malloc(sizeof(struct Node)*MAX_SAMPLE);
    
    get_attributes(filename,Atttr_Num,Atttr_Seq);

    fp=fopen(filename,"r");

	if(fp==NULL)
	{
		printf("\nError in opening ");
		return NULL;
	}
	//n = 0;
	//m = 0;
	k = 0;
	while(finished != 1){
		ptr= string;
		finished = get_line(ptr,fp);
		//printf("line read:%s\n",ptr);
		if(finished == 2){	//skip this line
			continue;
		}
		if(string[0] != '%' && string[0] != '@' && string[0] != '\0'){
			k = 0;
			for(j = 0; j < *Atttr_Num; j++){
				if(j == 0){
					if(Atttr_Seq[k] == 'r'){
						sscanf(ptr,"%f",&Sample[i].NumericAttributes[j]);
					}
					k++;
				}else{
					if(Atttr_Seq[k] == 'r'){
						sscanf(ptr,",%f",&Sample[i].NumericAttributes[j]);
					}
					k++;
				}
				do{ptr++;} while(*ptr != ',');
			}
			//printf("row%d\n",i);
			i++;
			(*Sample_Num)++;
		}
	}
		
	fclose(fp);
	return Sample;
}
bool CL_DomElement::has_attribute_ns(
	const CL_DomString &namespace_uri,
	const CL_DomString &local_name) const
{
	if (impl)
	{
		CL_DomNode attribute = get_attributes().get_named_item_ns(namespace_uri, local_name);
		return attribute.is_attr();
	}
	return false;
}
// print out the items stored in the two tables
void table_dump () {
   printf("Identifiers:\n");
   int ident_scp = 0;
   for (auto v: idents) {
      printf("%d\n", ident_scp);
      for (auto i = v->cbegin(); i != v->cend(); i++) {
         printf("\t %s %s\n", i->first->c_str(),
         get_attributes(i->second->attributes));
      }
      ident_scp++;
   }
   printf("Types:\n");
   for (auto i = types.cbegin(); i != types.cend(); i++) {
      printf("%s\n", i->first->c_str());
      for (auto j = i->second->fields->cbegin();
            j != i->second->fields->cend(); j++) {
         printf("\t%s %s\n", j->first->c_str(),
         get_attributes(j->second->attributes));
      }
   }
}
CL_DomAttr CL_DomElement::get_attribute_node_ns(
	const CL_DomString &namespace_uri,
	const CL_DomString &local_name) const
{
	if (impl)
	{
		CL_DomNamedNodeMap attributes = get_attributes();
		CL_DomAttr attribute = attributes.get_named_item_ns(namespace_uri, local_name).to_attr();
		return attribute;
	}
	return CL_DomAttr();
}
void symbol_dump (symbol *sym, string *name) {
   if (sym == NULL || name == NULL) return;   
   size_t depth = sym->block_num;
   for (size_t i = 0; i < depth; i++) fprintf(sym_file, "\t");
   fprintf(sym_file, "%s (%zu.%zu.%zu) {%zu} %s\n",
           name->c_str(),
           sym->filenum,
           sym->linenum,
           sym->offset, 
           sym->block_num,
           get_attributes(sym->attributes));
}
Exemple #13
0
static bool first_open(
	rtems_termios_tty *tty,
	rtems_termios_device_context *base,
	struct termios *term,
	rtems_libio_open_close_args_t *args
)
{
	struct apbuart_priv *uart = base_get_priv(base);

	uart->tty = tty;

	/* Inherit UART hardware parameters from bootloader on system console */
	if (uart->condev.flags & CONSOLE_FLAG_SYSCON_GRANT) {
		get_attributes(base, term);
		term->c_oflag |= ONLCR;
		set_attributes(base, term);
	}

	/* Enable TX/RX */
	uart->regs->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;

	if (uart->mode != TERMIOS_POLLED) {
		int ret;
		uint32_t ctrl;

		/* Register interrupt and enable it */
		ret = drvmgr_interrupt_register(
			uart->dev, 0, uart->devName, apbuart_cons_isr, tty
		);
		if (ret) {
			return false;
		}

		uart->sending = 0;

		/* Turn on RX interrupts */
		ctrl = uart->regs->ctrl;
		ctrl |= APBUART_CTRL_RI;
		if (uart->cap & CAP_DI) {
			/* Use RX FIFO interrupt only if delayed interrupt available. */
			ctrl |= (APBUART_CTRL_DI | APBUART_CTRL_RF);
		}
		uart->regs->ctrl = ctrl;
	}

	return true;
}
Exemple #14
0
Horizon::Implementation::Implementation (const BlockModel& al)
  : dry_bulk_density (al.number ("dry_bulk_density", -42.42e42)),
    SOM_C_per_N (al.number_sequence ("SOM_C_per_N")),
    C_per_N (al.number ("C_per_N", -42.42e42)),
    SOM_fractions (al.check ("SOM_fractions") 
                   ? al.number_sequence ("SOM_fractions")
                   : std::vector<double> ()),
    turnover_factor (al.number ("turnover_factor")),
    anisotropy (al.number ("anisotropy")),
    attributes (get_attributes (al.submodel_sequence ("attributes"))),
    dimensions (get_dimensions (al.submodel_sequence ("attributes"))),
    nitrification (Librarian::build_item<Nitrification> (al, "Nitrification")),
    secondary (Librarian::build_item<Secondary> (al, "secondary_domain")),
    r_pore_min (al.number ("r_pore_min")),
    primary_sorption_fraction (NAN),
    hor_heat (al.submodel ("HorHeat")),
    CEC (al.number ("CEC", -42.42e42))
{ }
void CL_DomElement::set_attribute(const CL_DomString &name, const CL_DomString &value)
{
	if (impl)
	{
		CL_DomNamedNodeMap attributes = get_attributes();
		CL_DomAttr attribute = attributes.get_named_item(name).to_attr();
		if (attribute.is_attr())
		{
			attribute.set_node_value(value);
		}
		else
		{
			attribute = get_owner_document().create_attribute(name);
			attribute.set_node_value(value);
			attributes.set_named_item(attribute);
		}
	}
}
Exemple #16
0
   void Tilemap::add_layer(std::map<unsigned, Surface>& tiles, xml_node node,
         int tilewidth, int tileheight)
   {
      Layer layer;
      int width  = node.attribute("width").as_int();
      int height = node.attribute("height").as_int();

      if (!width || !height)
         throw std::logic_error("Layer is empty.");

#if 0
      std::cerr << "Adding layer:" <<
         " Name: " << node.attribute("name").value() <<
         " Width: " << width <<
         " Height: " << height << std::endl;
#endif

      Utils::xml_node_walker walk{node.child("data"), "tile", "gid"};
      int index = 0;
      for (auto& gid_str : walk)
      {
         Pos pos = Pos(index % width, index / width);

         unsigned gid = Utils::stoi(gid_str);
         if (gid)
         {
            Blit::Surface surf = tiles[gid];
            surf.rect().pos = pos * Pos(tilewidth, tileheight);

            layer.cluster.vec().push_back({surf, Pos()});

            if (Utils::find_or_default(surf.attr(), "collision", "") == "true")
               collisions.insert(pos);
         }

         index++;
      }

      layer.attr = get_attributes(node.child("properties"), "property");
      layer.name = node.attribute("name").value();
      m_layers.push_back(std::move(layer));
   }
Exemple #17
0
	void DomElement::set_attribute_ns(
		const DomString &namespace_uri,
		const DomString &qualified_name,
		const DomString &value)
	{
		if (impl)
		{
			DomNamedNodeMap attributes = get_attributes();
			DomAttr attribute = attributes.get_named_item_ns(namespace_uri, qualified_name).to_attr();
			if (attribute.is_attr())
			{
				attribute.set_node_value(value);
			}
			else
			{
				attribute = get_owner_document().create_attribute_ns(namespace_uri, qualified_name);
				attribute.set_node_value(value);
				attributes.set_named_item_ns(attribute);
			}
		}
	}
Exemple #18
0
/*
* DER encode a DistinguishedName
*/
void X509_DN::encode_into(DER_Encoder& der) const
   {
   std::multimap<OID, std::string> dn_info = get_attributes();

   der.start_cons(SEQUENCE);

   if(!dn_bits.empty())
      der.raw_bytes(dn_bits);
   else
      {
      do_ava(der, dn_info, PRINTABLE_STRING, "X520.Country");
      do_ava(der, dn_info, DIRECTORY_STRING, "X520.State");
      do_ava(der, dn_info, DIRECTORY_STRING, "X520.Locality");
      do_ava(der, dn_info, DIRECTORY_STRING, "X520.Organization");
      do_ava(der, dn_info, DIRECTORY_STRING, "X520.OrganizationalUnit");
      do_ava(der, dn_info, DIRECTORY_STRING, "X520.CommonName");
      do_ava(der, dn_info, PRINTABLE_STRING, "X520.SerialNumber");
      }

   der.end_cons();
   }
Exemple #19
0
ErrorCode ReadNC::get_variables()
{
  // First cache the number of time steps
  std::vector<std::string>::iterator vit = std::find(dimNames.begin(), dimNames.end(), "time");
  if (vit == dimNames.end())
    vit = std::find(dimNames.begin(), dimNames.end(), "t");

  int ntimes = 0;
  if (vit != dimNames.end())
    ntimes = dimLens[vit - dimNames.begin()];
  if (!ntimes)
    ntimes = 1;

  // Get the number of variables
  int num_vars;
  int success = NCFUNC(inq_nvars)(fileId, &num_vars);
  if (success)
    MB_SET_ERR(MB_FAILURE, "Trouble getting number of variables");

  if (num_vars > NC_MAX_VARS) {
    MB_SET_ERR(MB_FAILURE, "ReadNC: File contains " << num_vars << " vars but NetCDF library supports only " << NC_MAX_VARS);
  }

  char var_name[NC_MAX_NAME + 1];
  int var_ndims;

  for (int i = 0; i < num_vars; i++) {
    // Get the name first, so we can allocate a map iterate for this var
    success = NCFUNC(inq_varname )(fileId, i, var_name);
    if (success)
      MB_SET_ERR(MB_FAILURE, "Trouble getting variable name");
    VarData &data = varInfo[std::string(var_name)];
    data.varName = std::string(var_name);
    data.varId = i;
    data.varTags.resize(ntimes, 0);

    // Get the data type
    success = NCFUNC(inq_vartype)(fileId, i, &data.varDataType);
    if (success)
      MB_SET_ERR(MB_FAILURE, "Trouble getting data type for variable " << data.varName);

    // Get the number of dimensions, then the dimensions
    success = NCFUNC(inq_varndims)(fileId, i, &var_ndims);
    if (success)
      MB_SET_ERR(MB_FAILURE, "Trouble getting number of dims for variable " << data.varName);
    data.varDims.resize(var_ndims);

    success = NCFUNC(inq_vardimid)(fileId, i, &data.varDims[0]);
    if (success)
      MB_SET_ERR(MB_FAILURE, "Trouble getting dimensions for variable " << data.varName);

    // Finally, get the number of attributes, then the attributes
    success = NCFUNC(inq_varnatts)(fileId, i, &data.numAtts);
    if (success)
      MB_SET_ERR(MB_FAILURE, "Trouble getting number of dims for variable " << data.varName);

    // Print debug info here so attribute info comes afterwards
    dbgOut.tprintf(2, "Variable %s: Id=%d, numAtts=%d, datatype=%d, num_dims=%u\n", data.varName.c_str(), data.varId, data.numAtts,
        data.varDataType, (unsigned int) data.varDims.size());

    ErrorCode rval = get_attributes(i, data.numAtts, data.varAtts, "   ");MB_CHK_SET_ERR(rval, "Trouble getting attributes for variable " << data.varName);
  }

  return MB_SUCCESS;
}
Exemple #20
0
int 
call_modify (int argc, char **argv)
{
	struct ds_modifyentry_arg mod_arg;

	struct DSError  error;
	struct entrymod *emnew, *ems_append(), *modify_avs();
	Attr_Sequence   as,
#ifdef TURBO_DISK
					fget_attributes (),
#else
					get_attributes (),
#endif
					temp,
					trail = NULLATTR;
	AV_Sequence     avst = NULLAV;
	extern AttributeType at_objectclass;
	extern int	parse_status;
	Entry           entry_ptr;
	FILE           *fd;
	char            draft_flag = FALSE;
	char		noedit_flag = FALSE;
	int 		x;
	DN		moddn;
	char	       *home;
	RDN		new_rdn;

	struct  list_element   *start = 0 ;
	struct  list_element   *last ;
	struct  list_element   *l_temp ;

	/*	char	add = FALSE ;
		char	rem = FALSE ;
	 */
	if ((argc = service_control (OPT, argc, argv, &mod_arg.mea_common)) == -1)
		return;

	mod_arg.mea_changes = NULLMOD;
	new_draft = FALSE;

	if (home = getenv ("DISHDRAFT"))
		 strcpy (fname, home);
	else if (dad_flag) {
		 strcpy (fname, "/tmp/dishXXXXXX");
		 unlink (mktemp (fname));
	} else if (home = getenv ("HOME"))
		 sprintf (fname, "%s/.dishdraft", home);
	else
		 strcpy (fname, "./.dishdraft");

	for (x=1; x<argc; x++) {
		if (test_arg (argv[x], "-draft",1)) {
			draft_flag = 1;
			shuffle_up (argc--,argv,x);
			if (x == argc) {
				ps_printf (OPT, "Draft file name missing\n");
				Usage (argv[0]);
				return;
			}
			 strcpy (fname, argv[x]);
			shuffle_up (argc--,argv,x--);
		} else if (test_arg (argv[x], "-newdraft",2)) {
			new_draft = TRUE;
			shuffle_up (argc--,argv,x--);
		} else if (test_arg (argv[x], "-noedit",3)) {
			noedit_flag = TRUE;
			shuffle_up (argc--,argv,x--);
		} else if (move (argv[x]) == OK)
			shuffle_up (argc--,argv,x--);
		else if (test_arg(argv[x], "-remove", 3)) {
			shuffle_up (argc--, argv, x);
			if (x == argc) {
				ps_printf(OPT, "Attribute to remove missing\n") ;
				Usage(argv[0]) ;
				return ;
			}
			l_temp = (struct list_element *) malloc (sizeof(struct list_element)) ;
			l_temp->mod = (char *) malloc ((unsigned)(strlen(argv[x]) + 1));
			 strcpy (l_temp->mod, argv[x]) ;
			l_temp->add = 0 ;
			l_temp->next = 0 ;
			if (start == 0) {
				start = last = l_temp ;
			} else {
				last->next = l_temp ;
				last = l_temp ;
			}
			shuffle_up (argc--,argv,x--);
		} else if (test_arg(argv[x], "-add", 2)) {
			shuffle_up (argc--, argv, x);
			if (x == argc) {
				ps_printf(OPT, "Attribute to insert missing\n") ;
				Usage(argv[0]) ;
				return ;
			}
			l_temp = (struct list_element *) malloc (sizeof(struct list_element)) ;
			l_temp->mod = (char *) malloc ((unsigned)(strlen(argv[x]) + 1));
			 strcpy (l_temp->mod, argv[x]) ;
			l_temp->add = 1 ;
			l_temp->next = 0 ;
			if (start == 0) {
				start = last = l_temp ;
			} else {
				last->next = l_temp ;
				last = l_temp ;
			}
			shuffle_up (argc--,argv,x--);
		}
	}

	if (dad_flag && (draft_flag || noedit_flag)) {
		ps_printf (OPT,
				   "operation not allowed when using directory assistance server!\n");
		return;
	}

	/* read attributes we want to modify */
	if ((argc = read_cache_aux (argc, argv, FALSE, &mod_arg.mea_common)) <0 )
		return;

	if (argc != 1) {
		ps_printf (OPT,"Unknown option %s\n",argv[1]);
		Usage (argv[0]);
		return;
	}

	if (start != 0) {
		if (build_modify(start, &mod_arg) == NOTOK) {
			return ;
		}

		while (ds_modifyentry (&mod_arg, &error) != DS_OK) {
			if (dish_error (OPT, &error) == 0) {
				return ;
			}
			mod_arg.mea_object = error.ERR_REFERRAL.DSE_ref_candidates->cr_name ;
		}
		ps_print (RPS, "Modified ");
		dn_print (RPS, dn, EDBOUT);
		ps_print (RPS, "\n");
		delete_cache (dn);  /* re-cache when next read */
		return ;
	}

	if (!draft_flag) {
		if (mod_template (fname,noedit_flag) != OK)
			return;
		noedit_flag = FALSE;
	} else {
		new_draft = TRUE;	/* Ugh ! */
		 mod_template ("/dev/null",TRUE);
	}

	if (! noedit_flag)
		if (editentry (1, argv) != OK) {
			make_old (fname,draft_flag);
			return;
		}

	/* now parse the files */

	if ((fd = fopen (fname, "r")) == (FILE *) NULL) {
		ps_printf (OPT, "Can't open draft entry %s\n", fname);
		return;
	}

	entry_ptr = get_default_entry (NULLENTRY);
#ifdef TURBO_DISK
	entry_ptr->e_attributes = fget_attributes (fd);
#else
	entry_ptr->e_attributes = get_attributes (fd);
#endif

	 fclose (fd);
	if (parse_status != 0)
		return;

	mod_arg.mea_object = dn;
	for (moddn = dn ; moddn->dn_parent != NULLDN; moddn=moddn->dn_parent)
		;
	entry_ptr->e_name = rdn_cpy (moddn->dn_rdn);

	/* add rdn as attribute */
	for (new_rdn = entry_ptr->e_name; new_rdn != NULLRDN; new_rdn = new_rdn->rdn_next) {
		avst = avs_comp_new (AttrV_cpy (&new_rdn->rdn_av));
		temp = as_comp_new (AttrT_cpy (new_rdn->rdn_at), avst, NULLACL_INFO);
		entry_ptr->e_attributes = as_merge (entry_ptr->e_attributes, temp);
	}

	for (as = entry_ptr->e_attributes; as != NULLATTR; as = as->attr_link) {
		emnew = NULLMOD;
		trail = as->attr_link;
		as->attr_link = NULLATTR;

		temp = current_entry->e_attributes;
		for (; temp != NULLATTR; temp = temp->attr_link)
			if (AttrT_cmp (as->attr_type, temp->attr_type) == 0) {
				/* found it - does it need changing ? */
				if (avs_cmp (as->attr_value, temp->attr_value) != 0)
					emnew = modify_avs (as->attr_value, temp->attr_value,as->attr_type);
				break;
			}

		if (temp == NULLATTR) {
			emnew = em_alloc ();
			emnew->em_type = EM_ADDATTRIBUTE;
			emnew->em_what = as_cpy(as);
			emnew->em_next = NULLMOD;
		}

		if (emnew != NULLMOD)
			mod_arg.mea_changes = ems_append (mod_arg.mea_changes,emnew);

		as->attr_link = trail;
	}

	/* remove attribute missing in new entry */
	for (as = current_entry->e_attributes; as != NULLATTR; as = as->attr_link) {
		emnew = NULLMOD;

		temp = entry_ptr->e_attributes;
		for (; temp != NULLATTR; temp = temp->attr_link)
			if (AttrT_cmp (as->attr_type, temp->attr_type) == 0)
				break;

		if (temp == NULLATTR) {
			emnew = em_alloc ();
			emnew->em_type = EM_REMOVEATTRIBUTE;
			emnew->em_what = as_comp_new(as->attr_type,NULLAV,NULLACL_INFO);
			emnew->em_next = NULLMOD;
		}

		if (emnew != NULLMOD)
			mod_arg.mea_changes = ems_append (mod_arg.mea_changes,emnew);
	}


	if (mod_arg.mea_changes == NULLMOD) {
		ps_print (RPS, "The draft entry and the entry for ");
		dn_print (RPS, dn, EDBOUT);
		ps_print (RPS, "\nare exactly the same - no change made!!!\n");
		entry_free (entry_ptr);
		make_old (fname,draft_flag);
		return;
	}

	if (rebind () != OK) {
		entry_free (entry_ptr);
		return;
	}
	/*
	 * If this operation is time-stamped, it may have expired while the user
	 * was editing the entry. Re-calculate the time-stamp. Modify is the only
	 * dish command where this needs to be done.
	 */

	if ((mod_arg.mea_common.ca_security != (struct security_parms *) 0)
			&& (mod_arg.mea_common.ca_security->sp_time != NULLCP)) {
		char *new_version();

		free(mod_arg.mea_common.ca_security->sp_time);
		mod_arg.mea_common.ca_security->sp_time = new_version();
	}

	/* If security parameters are present, take this to mean that strong
	 * authentication is required. This disallows 'parms + no signature'
	 * (pointless) and 'signature + no parms' (security risk).
	 */
	if (mod_arg.mea_common.ca_security != (struct security_parms *) 0) {
		extern struct SecurityServices *dsap_security;

		mod_arg.mea_common.ca_sig =
			(dsap_security->serv_sign)((caddr_t)&mod_arg,
									   _ZModifyEntryArgumentDataDAS, &_ZDAS_mod);
	}

	while (ds_modifyentry (&mod_arg, &error) != DS_OK) {
		if (dish_error (OPT, &error) == 0) {
			entry_free (entry_ptr);
			return;
		}
		mod_arg.mea_object = error.ERR_REFERRAL.DSE_ref_candidates->cr_name;
	}
	ps_print (RPS, "Modified ");
	dn_print (RPS, dn, EDBOUT);
	ps_print (RPS, "\n");
	delete_cache (dn);	/* re-cache when next read */

	entry_free (entry_ptr);
	ems_part_free (mod_arg.mea_changes);

	make_old (fname,draft_flag);
}
CL_DomAttr CL_DomElement::set_attribute_node_ns(const CL_DomAttr &attr)
{
	if (impl)
		return get_attributes().set_named_item_ns(attr).to_attr();
	return CL_DomAttr();
}
// Writes the attributes for the file
void
GenericLevelObj::write_properties(FileWriter &fw)
{
  fw.begin_section(section_name.c_str());

  const unsigned attribs_ = get_attributes(section_name);

  if (attribs_ & HAS_TYPE)
    fw.write_string("type", object_type);

  if (attribs_ & HAS_GPTYPE)
    fw.write_string("type", ground_type);

  if (attribs_ & HAS_SPRITE)
  {
    fw.begin_section("surface");
    fw.write_string("image", desc.res_name);
    fw.write_string("modifier", ResourceModifier::to_string(desc.modifier));
    fw.end_section();   // surface
  }

  fw.write_vector("position", pos);

  if (attribs_ & HAS_SPEED)
    fw.write_int("speed", speed);
  if (attribs_ & HAS_PARALLAX)
    fw.write_float("parallax", parallax);
  if (attribs_ & HAS_REPEAT)
    fw.write_int("repeat", repeat);
  if (attribs_ & HAS_OWNER)
    fw.write_int("owner-id", owner_id);
  if (attribs_ & HAS_DIRECTION)
    fw.write_string("direction", direction);
  if (attribs_ & HAS_RELEASE_RATE)
    fw.write_int("release-rate", release_rate);
  if (attribs_ & HAS_COLOR)
    fw.write_colori("colori", color);
  if (attribs_ & HAS_STRETCH)
  {
    fw.write_bool("stretch-x", stretch_x);
    fw.write_bool("stretch-y", stretch_y);
    fw.write_bool("keep-aspect", keep_aspect);
  }
  if (attribs_ & HAS_SCROLL)
  {
    fw.write_float("scroll-x", scroll_x);
    fw.write_float("scroll-y", scroll_y);
  }
  if (attribs_ & HAS_PARA)
  {
    fw.write_float("para-x", para_x);
    fw.write_float("para-y", para_y);
  }

  if (attribs_ & HAS_STARFIELD)
  {
    fw.write_int("small-stars", small_stars);
    fw.write_int("middle-stars", middle_stars);
    fw.write_int("large-stars", large_stars);
  }

  if (attribs_ & HAS_ID)
  {
    fw.write_string("id", id);
  }

  if (attribs_ & HAS_TARGET_ID)
  {
    fw.write_string("target-id", target_id);
  }

  if (attribs_ & HAS_HEIGHT)
    fw.write_int("height", height);

  // Writes any extra properties that may be necessary (virtual function)
  write_extra_properties(fw);

  fw.end_section();     // object's section_name
}
Skybox::Skybox(size_t const size)
	: Object("skybox", get_attributes(size), std::set<Uniform>(), get_texture(size))
{}
Exemple #24
0
main()
{
	struct  passwd  *pw_entry ;
	struct  passwd  *getpwuid() ;
	struct	stat	buf ;

	int	i = 1 ;
	int     uid ;
	int	um ;
	char	pass1[LINESIZE] ;
	char	pass2[LINESIZE] ;
	char	Read_in_Stuff[LINESIZE] ;
	char	**vecptr ;
	char 	*tmpdraft ;
	char	home_dir[LINESIZE] ;
	char	*p, *part1, *part2 ;
	char	quipurc_file[100] ;
	char	tailor_file[100] ;
	char	user_name[9] ;
	char	*localptr = Local ;
	char	print_format = EDBOUT ;
	EntryInfo	*ptr ;
	static  CommonArgs ca = default_common_args;
	
	vecptr = (char **) malloc(100) ;
	vecptr[0] = malloc (LINESIZE) ;
	(void) strcpy(vecptr[0], "showentry") ;
	(void) strcpy(pass1, "x") ;
	(void) strcpy(pass2, "y") ;
	tmpdraft = malloc (LINESIZE) ;
	(void) strcpy(tmpdraft, "/tmp/dish-") ;

	if ((opt = ps_alloc (std_open)) == NULLPS)
		fatal (-62, "ps_alloc failed");
	if (std_setup (opt, stderr) == NOTOK)
		fatal (-63, "std_setup failed");
	if ((rps = ps_alloc (std_open)) == NULLPS)
		fatal (-64, "ps_alloc 2 failed");
	if (std_setup (rps, stdout) == NOTOK)
		fatal (-65, "std_setup 2 failed");
	(void) strcpy(filterstring, "userid=") ;

	/* Sort out files, userids etc. */
	uid=getuid() ;
	if ((pw_entry=getpwuid(uid)) == 0)
	{
		ps_printf(rps, "Who are you? (no name for your uid number)\n") ;
		exit(1) ;
	}
	(void) strcpy(user_name, pw_entry->pw_name) ;
	(void) strcat(tmpdraft, user_name) ;

	if (getenv("HOME") == 0) 
	{
		ps_printf(rps, "No home directory?!!") ;
		(void) strcpy(home_dir, pw_entry->pw_dir) ;
	}
	else
	{
		(void) strcpy(home_dir, getenv("HOME")) ;
	}

	(void) strcpy(quipurc_file, home_dir) ;
	(void) strcat(quipurc_file, "/.quipurc") ;

	(void) strcpy(tailor_file, isodefile ("dishinit", 1));

	Manager[0] = 0;
	Password[0] = 0;
	Local[0] = 0;

	(void) stat(tailor_file, &buf) ;
	(void) seteuid(buf.st_uid) ;	/* set effective to enable */
					/* us to read protected file */

	if ((fp_tailor = fopen(tailor_file, "r")) == 0)
	{
		ps_print(rps, "Can't open Tailor File. Abort.\n") ;
		exit(1) ;
	}

	while (fgets (Read_in_Stuff, LINESIZE, fp_tailor) != 0)
	{
		if (!strcmp(Read_in_Stuff, "##Anything after this line is copied into the users ~/.quipurc file\n"))
		{
			break ;
		}

		p = SkipSpace (Read_in_Stuff);
		if (( *p == '#') || (*p == '\0'))
			continue;  		/* ignore comments and blanks */

		part1 = p;
		if ((part2 = index (p,':')) == NULLCP) {
			ps_printf (opt,"Seperator missing '%s'. Ignoring..\n",p);
		}

		*part2++ = '\0';
		part2 = TidyString (part2);

		if (lexequ(part1, "manager") == 0)
		{
			(void) strcpy(Manager, part2) ;
		}
		else
		if (lexequ(part1, "password") == 0)
		{
			(void) strcpy(Password, part2) ;
		}
		else
		if (lexequ(part1, "local") == 0)
		{
			(void) strcpy(Local, part2) ;
		}
		else
		{
			ps_printf(rps, "Error in tailor. What's a %s?\n", part1) ;
		}

	}
	(void) setuid(uid) ;			/* Restore Userid to original user. */

/* create ~/.quipurc file. NB this does eradicate anything in there.
 * 			   (Theoretically nothing.) 
 */

	if (Manager[0] == 0) {
		ps_print(rps, "Can't find out the managers name\n") ;
		exit(1) ;
	}
	if (Password[0] == 0) {
		ps_print(rps, "Can't find out the managers password\n") ;
		exit(1) ;
	}
	if (Local[0] == 0) {
		ps_print(rps, "Can't find out where to search\n") ;
		exit(1) ;
	}

	um = umask(0177) ;
	if ((fp_quipurc = fopen(quipurc_file, "w")) == 0)
	{
		ps_printf(rps, "Can't open ~/.quipurc. Aborting..\n") ;
		exit(1) ;
	}
	(void) umask(um) ;	

	if ((fileps = ps_alloc(std_open)) == NULLPS)
	{
		fatal (-66, "ps_alloc 2 failed");
	}
	if (std_setup (fileps, fp_quipurc) == NOTOK)
	{
		fatal (-67, "std_setup 2 failed");
	}


	/* Sorting out the bind section */
	quipu_syntaxes() ;		/* set up the needed function pointers */
	dsap_init(&i, &vecptr) ;

	(void) strcpy(bindarg.dba_passwd, Password) ;
	bindarg.dba_version = DBA_VERSION_V1988;
	bindarg.dba_passwd_len = strlen(bindarg.dba_passwd) ;

	if ((bindarg.dba_dn = str2dn (Manager)) == NULLDN) 
	{
		ps_printf (opt,"Invalid Manager name %s (???!)\n",Manager) ;
		exit(1) ;
	}

	if (ds_bind (&bindarg, &binderr, &bindresult) != OK)
	{
		ps_printf(rps, "Can't bind as the manager.\n") ;
		exit(1);
	}
	/* Hopefully, should be successfully bound */

/*
 * We now call the search stuff with the right bits, to see if we can get a
 * match of uid='user_name'. Once there, we echo lots of information from
 * their entry out to the .quipurc file.
 * Hopefully there should only be one match. This assumes that ALL dir info
 * up to date, and that SG do not allow multiple users with the same login.
 */

/* set up the appropriate structures and defaults. */

	search_arg.sra_common = ca; /* struct copy */
	search_arg.sra_common.ca_servicecontrol.svc_sizelimit = 2 ;
	search_arg.sra_eis.eis_allattributes = FALSE ;
	search_arg.sra_searchaliases = FALSE;
	search_arg.sra_subset = SRA_ONELEVEL;
	search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES ;
	search_arg.sra_eis.eis_select = NULLATTR ;
	search_arg.sra_eis.eis_allattributes = TRUE ;
	search_arg.sra_filter = filter_alloc() ;
		/* Default filter. */
		search_arg.sra_filter->flt_next = NULLFILTER;
		search_arg.sra_filter->flt_type = FILTER_ITEM;
		search_arg.sra_filter->FUFILT = NULLFILTER;
		

	if (*localptr == '@')
	{
		localptr++;
	}
	if ((search_arg.sra_baseobject = str2dn(localptr)) == NULLDN)
	{
		ps_printf (opt,"Invalid sequence in username %s.\n", localptr);
		exit(1) ;
	}

	(void) strcat(filterstring, user_name) ;

	search_arg.sra_filter->flt_un.flt_un_item.fi_type = FILTERITEM_EQUALITY ;

	if ((search_arg.sra_filter->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type = AttrT_new ("userid")) == NULLAttrT)
	{
		ps_printf(rps, "Oops, userid is not a valid attr type. ABORT!!\n") ;
		exit(1) ;
	}
	if ((search_arg.sra_filter->flt_un.flt_un_item.fi_un.fi_un_ava.ava_value = str2AttrV (user_name, search_arg.sra_filter->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type->oa_syntax)) == NULLAttrV)
	{
		ps_printf(rps, "%s is not a valid attribute value.\n", user_name) ;
	}

/* call search */
/* We now ought to be in the right place, and with the search stuff set,
 * ready to call search, and receive one (or no) entry back, which then 
 * gets processed accordingly.
 */

	if (ds_search (&search_arg, &search_error, &search_result) != DS_OK)
	{
		ps_printf(rps, "Search failed...\n") ;
		exit (1) ;
		/* This is not the same as coming back with */
		/* message "search failed to find anything. */
	}

/* If the user does not exist in the DIT, print out the limited .quipurc
 * and the warning message, and allow the user to play DISH.
 */

	if (search_result.CSR_entries == NULLENTRYINFO)
	{
		ps_printf(opt, "Unfortunately, you seem to have no entry in\n") ;
		ps_printf(opt, "the directory. Contact '%s' who should be able to help.\n", Manager) ;
		ps_printf(opt, "In the mean time, you can read, but not write.\n") ;
	}
	else
	{
		ptr = search_result.CSR_entries ;
		dn = dn_cpy(ptr->ent_dn) ;	/* Essence of move user_name. */

		/* collect the info and put it into current_entry */

		/* Set up the desired attribute type to be read*/
		/* from read.c */
		if ((at = AttrT_new ("userPassword")) != NULLAttrT) 
		{
			as_flag = as_merge (as_flag, as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
		}
		else
		{
			ps_printf(rps, "Oops, Serious error. unknown attribute type 'userPassword'.\n") ;
			exit(1) ;
		}

		if ((current_entry = local_find_entry (dn, FALSE)) == NULLENTRY)
		{	
			read_arg.rda_common = ca; /* struct copy */
			read_arg.rda_object = dn;
			read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
			read_arg.rda_eis.eis_allattributes = TRUE ;
			read_arg.rda_eis.eis_select = NULLATTR ;

			if (ds_read (&read_arg, &read_error, &read_result) != DS_OK)
			{
				ps_printf(rps, "We even seem to be having problems reading\n" ) ;
				ps_printf(rps, "an entry we searched and found!! HELP!!\n") ;
				exit(1) ;
			}
			if (read_result.rdr_entry.ent_attr == NULLATTR)
			{
				ps_printf(rps, "No attributes present. Even though\n") ;
				ps_printf(rps, "we found you by userid attribute!!! HELP!!\n") ;
				exit (1) ;
			}
			cache_entry (&(read_result.rdr_entry), read_arg.rda_eis.eis_allattributes, TRUE) ;
		}

		if ((current_entry = local_find_entry (dn, FALSE)) == NULLENTRY)
		{
			ps_printf(rps, "We still have nothing.Even after reading? Abort.\n") ;
			exit(1) ;
		}

		ps_printf(fileps, "username: "******"\n") ;

		ps_printf(fileps, "me: ") ;
		dn_print(fileps, dn, EDBOUT) ;
		ps_printf(fileps, "\n") ;

		/* now showattribute -nokey to display it. */

		ps_printf(fileps, "password: "******"You need a password...\n") ;
				(void) strcpy(pass1, getpassword("Enter Password: "******"Re-enter password: "******"\nMismatch - Try again.\n") ;
				}
			}
			ps_printf(fileps, "%s\n", pass1) ;

			um = umask(0177) ;
			if ((fp_draft = fopen(tmpdraft, "w")) == 0)
			{
				ps_print(rps, "Can't open draft file... Abort.\n") ;
				exit(1) ;
			}
			(void) umask(um) ;

			(void) fprintf(fp_draft, "UserPassword = %s\n", pass1) ;
		 	(void) fprintf(fp_draft, "acl = self # write # attributes # acl $ userPassword\n") ;
			(void) fprintf(fp_draft, "acl = others # compare # attributes # acl $ userPassword\n\n") ;
			(void) fclose(fp_draft) ;

			if ((fp_draft = fopen (tmpdraft, "r")) == NULL) {
				ps_printf (opt, "Can't open draft entry %s\n", tmpdraft);
				exit(1) ;
			}

			entry_ptr = get_default_entry (NULLENTRY);
#ifdef TURBO_DISK
			entry_ptr->e_attributes = fget_attributes (fp_draft);
#else
			entry_ptr->e_attributes = get_attributes (fp_draft);
#endif

			(void) fclose (fp_draft);

			mod_arg.mea_common = ca; /* struct copy */
			mod_arg.mea_object = dn;
			for (moddn = dn ; moddn->dn_parent != NULLDN; moddn=moddn->dn_parent)
				;
			entry_ptr->e_name = rdn_cpy (moddn->dn_rdn);
	
			/* add rdn as attribute */
			avst = avs_comp_new (AttrV_cpy (&entry_ptr->e_name->rdn_av));
			temp = as_comp_new (AttrT_cpy (entry_ptr->e_name->rdn_at), avst, NULLACL_INFO);
			entry_ptr->e_attributes = as_merge (entry_ptr->e_attributes, temp);

			for (as = entry_ptr->e_attributes; as != NULLATTR; as = as->attr_link)
			{
				emnew = NULLMOD;
				trail = as->attr_link;
				as->attr_link = NULLATTR;
				temp = current_entry->e_attributes;
				for (; temp != NULLATTR; temp = temp->attr_link) 
					if (AttrT_cmp (as->attr_type, temp->attr_type) == 0)
					{
						/* found it - does it need changing ? */
						if (avs_cmp (as->attr_value, temp->attr_value) != 0) 
							emnew = modify_avs (as->attr_value, temp->attr_value,as->attr_type);
						break;
					}

				if (temp == NULLATTR) 
				{
					emnew = em_alloc ();
					emnew->em_type = EM_ADDATTRIBUTE;
					emnew->em_what = as_cpy(as);
					emnew->em_next = NULLMOD;
				}
				if (emnew != NULLMOD)
				{
					mod_arg.mea_changes = ems_append (mod_arg.mea_changes,emnew);
				}
				as->attr_link = trail;
			}

			while (ds_modifyentry (&mod_arg, &mod_error) != DS_OK)
			{
				if (dish_error (opt, &mod_error) == 0)
				{
					ps_printf(rps,"We have a dish error. Bye.\n") ;
					entry_free (entry_ptr);
					exit(1) ;
				}
				mod_arg.mea_object = mod_error.ERR_REFERRAL.DSE_ref_candidates->cr_name;
			}
			ps_print (rps, "Modified ");
			dn_print (rps, dn, EDBOUT);
			ps_print (rps, "\n");
			delete_cache (dn);	/* re-cache when next read */

			entry_free (entry_ptr);
			ems_part_free (mod_arg.mea_changes);
		}
	}

	while(fgets(Read_in_Stuff, LINESIZE, fp_tailor) != 0)
	{
		fputs(Read_in_Stuff, fp_quipurc) ;
	}
		
	(void) fclose(fp_quipurc) ;	
	(void) fclose(fp_tailor) ;

/*	(void) fprintf(fp_quipurc, "dsap: local_dit \"%s\"\n", Local) ;
	(void) fprintf(fp_quipurc, "notype: acl\n") ;
	(void) fprintf(fp_quipurc, "notype: treestructure\n") ;
	(void) fprintf(fp_quipurc, "notype: masterdsa\n") ;
	(void) fprintf(fp_quipurc, "notype: slavedsa\n") ;
	(void) fprintf(fp_quipurc, "notype: objectclass\n") ;
	(void) fprintf(fp_quipurc, "cache_time: 30\n") ;
	(void) fprintf(fp_quipurc, "connect_time: 2\n") ;
 */
	(void) ds_unbind() ;
	(void) unlink(tmpdraft) ;
}
Exemple #25
0
   void Tilemap::add_tileset(std::map<unsigned, Surface>& tiles, xml_node node)
   {
      int first_gid  = node.attribute("firstgid").as_int();
      int id_cnt     = 0;
      int tilewidth  = node.attribute("tilewidth").as_int();
      int tileheight = node.attribute("tileheight").as_int();

      pugi::xml_node image     = node.child("image");
      const char *source    = image.attribute("source").value();
      int width      = image.attribute("width").as_int();
      int height     = image.attribute("height").as_int();

#if 0
      std::cerr << "Adding tileset:" <<
         " Name: " << node.attribute("name").value() <<
         " Gid: " << first_gid <<
         " Tilewidth: " << tilewidth <<
         " Tileheight: " << tileheight <<
         " Source: " << source <<
         " Width: " << width <<
         " Height: " << height << std::endl;
#endif

      if (!width || !height || !tilewidth || !tileheight)
         throw std::logic_error("Tilemap is malformed.");

      SurfaceCache cache;
      Blit::Surface surf = cache.from_image(Utils::join(dir, "/", source));

      if (surf.rect().w != width || surf.rect().h != height)
         throw std::logic_error("Tilemap geometry does not correspond with image values.");

      std::map<std::basic_string<char>, std::basic_string<char> > global_attr = get_attributes(node.child("properties"), "property");

#if 0
      std::cerr << "Dumping attrs:" << std::endl;
      for (auto& attr : global_attr)
         std::cerr << "Found global attr (" << attr.first << " => " << attr.second << ")." << std::endl;
      std::cerr << "Dumped attrs." << std::endl;
#endif

      for (int y = 0; y < height; y += tileheight)
      {
         for (int x = 0; x < width; x += tilewidth, id_cnt++)
         {
            int id = first_gid + id_cnt;
            tiles[id] = surf.sub({{x, y}, tilewidth, tileheight});
            std::copy(global_attr.begin(), global_attr.end(), std::inserter(tiles[id].attr(), tiles[id].attr().begin())); 
         }
      }

      // Load all attributes for a tile into the surface.
      for (auto tile = node.child("tile"); tile; tile = tile.next_sibling("tile"))
      {
         int id = first_gid + tile.attribute("id").as_int();

         std::map<std::basic_string<char>, std::basic_string<char> > attrs = get_attributes(tile.child("properties"), "property");
         std::copy(global_attr.begin(), global_attr.end(), std::inserter(attrs, attrs.begin()));

         auto itr = attrs.find("sprite");

         if (itr != attrs.end())
            tiles[id] = cache.from_sprite(Utils::join(dir, "/", itr->second));

         tiles[id].attr() = std::move(attrs);
      }
   }
Exemple #26
0
	DomAttr DomElement::set_attribute_node(const DomAttr &attr)
	{
		if (impl)
			return get_attributes().set_named_item(attr).to_attr();
		return DomAttr();
	}
Exemple #27
0
 void BugzillaLink::set_bug_url(const std::string & value)
 {
   get_attributes()[URI_ATTRIBUTE_NAME] = value;
   make_image();
 }
static void
print_die_data(Dwarf_Debug dbg, Dwarf_Die print_me,int level,
    struct srcfilesdata *sf)
{
    char *name = 0;
    Dwarf_Error error = 0;
    Dwarf_Half tag = 0;
    const char *tagname = 0;
    int localname = 0;
    struct attributes attr;

    int res = dwarf_diename(print_me,&name,&error);

    if(res == DW_DLV_ERROR) {
        printf("Error in dwarf_diename , level %d \n",level);
        exit(1);
    }
    if(res == DW_DLV_NO_ENTRY) {
        name = "<no DW_AT_name attr>";
        localname = 1;
    }
    res = dwarf_tag(print_me,&tag,&error);
    if(res != DW_DLV_OK) {
        printf("Error in dwarf_tag , level %d \n",level);
        exit(1);
    }
    res = dwarf_get_TAG_name(tag,&tagname);
    if(res != DW_DLV_OK) {
        printf("Error in dwarf_get_TAG_name , level %d \n",level);
        exit(1);
    }
	if (level == 1) {
		if (tag == DW_TAG_structure_type || tag == DW_TAG_base_type ||(tag==DW_TAG_array_type)|| (tag == DW_TAG_pointer_type) || (tag == DW_TAG_typedef) || (tag==DW_TAG_variable)) {
			curr_top_tag = DW_TAG_structure_type;
		} else {
			curr_top_tag = 0;
		}
	}

	if (curr_top_tag != 0) {
		Dwarf_Off offset = 0;
		dwarf_dieoffset(print_me, &offset, &error);
		if (level > 1) {
			printf("    ");
		}
		count_data_types++;
		attr.size =0;
		attr.type_offset =0;
		attr.filename = 0;
		attr.member_location = 0;
		if (get_attributes(dbg, print_me, level, sf, &attr)==1){
			printf("<%d> tag: %d %s  name: \"%s\"  offset:%x ", level, tag, tagname,
					name, offset);
			if (attr.type_offset != 0){
				printf(" type offset: %x ",attr.type_offset);
			}
			if (attr.size != 0){
				printf("size : %d ",attr.size);
			}
			if (attr.filename != 0){
				printf(" filename: %s ",attr.filename);
			}
			printf("\n");
			db_entries[db_count].offset = offset;
			db_entries[db_count].type_offset = attr.type_offset;
			db_entries[db_count].tag = tag;
			db_entries[db_count].level = level;
			db_entries[db_count].size = attr.size;
			db_entries[db_count].member_location = attr.member_location;

			strncpy(db_entries[db_count].name,name,MAX_NAME-1);
			db_count++;
		}else{
		//	printf("Decleartion <%d> tag: %d %s  name: \"%s\"  offset:%x \n", level, tag, tagname,
		//						name, offset);
		}

	}
	if (!localname) {
		dwarf_dealloc(dbg, name, DW_DLA_STRING);
	}
}
Exemple #29
0
static int check_for_node_usability(const char *pathname)
{
    struct stat st;

    if(!access(pathname, F_OK))
    {
	ticables_info(_("    node %s: exists"), pathname);
    }
    else
    {
	ticables_info(_("    node %s: does not exist"), pathname);
	ticables_info(_("    => you will have to create the node."));

	return -1;
    }

    if(!stat(pathname, &st))
    {
	ticables_info(_("    permissions/user/group:%s%s %s"),
		      get_attributes(st.st_mode),
		      get_user_name(st.st_uid),
		      get_group_name(st.st_gid));
    }
    else
    {
	ticables_warning("can't stat '%s'.", pathname);
	return -1;
    }

    if(getuid() == st.st_uid)
    {
	ticables_info(_("    user can r/w on device: yes"));
	return 0;
    }
    else
    {
	ticables_info(_("    user can r/w on device: no"));
    }

    if((st.st_mode & S_IROTH) && (st.st_mode & S_IWOTH))
    {
	ticables_info(_("    others can r/w on device: yes"));
    }
    else
    {
	char *user, *group;

	ticables_info(_("    others can r/w on device: no"));

	user = strdup(get_user_name(getuid()));
	group = strdup(get_group_name(st.st_gid));

	if(!search_for_user_in_group(user, group))
	{
	    ticables_info(_("    is the user '%s' in the group '%s': yes"),
			  user, group);
	}
	else
	{
	    ticables_info(_("    is the user '%s' in the group '%s': no"), user, group);
	    ticables_info(_("    => you should add your username at the group '%s' in '/etc/group'"), group);
	    ticables_info(_("    => you will have to restart your session, too"), group);
	    free(user);
	    free(group);

	    return -1;
	}

	free(user);
	free(group);
    }

    return 0;
}
Exemple #30
0
// Load a sequence of nodes until the specified terminator is found
static ast_t* get_nodes(build_parser_t* builder, ast_token_id terminator)
{
  assert(builder != NULL);

  ast_t* ast = NULL;
  ast_t* last_child = NULL;

  while(true)
  {
    ast_token_id id = get_token(builder);
    ast_t* child = NULL;
    bool is_type = false;

    if(id == terminator)
    {
      if(ast == NULL)
        build_error(builder, "Syntax error");

      if(ast_id(ast) == TK_MINUS && ast_childcount(ast) == 1)
        ast_setid(ast, TK_UNARY_MINUS);

      return ast;
    }

    if(id == AT_ID)
      id = keyword_replace(builder);

    switch(id)
    {
      case AT_LPAREN:
        child = get_nodes(builder, AT_RPAREN);
        break;

      case AT_LSQUARE:
        child = get_type(builder, ast);
        is_type = true;
        break;

      case AT_ERROR:  // Propogate
        break;

      case AT_STRING:
      case AT_TOKEN:
        child = ast_token(builder->token);
        save_token(builder);
        get_attributes(builder, child);
        break;

      case AT_ID:
        if(strcmp("id", token_string(builder->token)) == 0)
          return get_id(builder, ast);

        build_error(builder, "Unrecognised identifier \"%s\"",
          token_string(builder->token));
        break;

      default:
        build_error(builder, "Syntax error");
        break;
    }

    if(child == NULL)
    {
      // An error occurred and should already have been reported
      ast_free(ast);
      return NULL;
    }

    if(ast == NULL)
    {
      ast = child;
      last_child = NULL;
    }
    else if(is_type)
    {
      ast_settype(ast, child);
    }
    else
    {
      if(last_child == NULL)
        ast_add(ast, child);
      else
        ast_add_sibling(last_child, child);

      last_child = child;
    }
  }
}