Example #1
0
File: acl.c Project: Tayyib/uludag
static void
set_nodes(struct acl_list *tables, unsigned int id, char *nodes)
{
	char *t;

	t = strchr(nodes, '\n');
	*t = '\0';
	++t;

	delete_node(tables->admins, id);
	if (nodes[0] != '\0')
		set_node(tables->admins, id, nodes);

	nodes = t;
	t = strchr(nodes, '\n');
	*t = '\0';
	++t;

	delete_node(tables->users, id);
	if (nodes[0] != '\0')
		set_node(tables->users, id, nodes);

	nodes = t;

	delete_node(tables->guests, id);
	if (nodes[0] != '\0')
		set_node(tables->guests, id, nodes);
}
struct node *check_node(struct bintree *root,struct node *node,short depth)
	{
	short cmp;

	cmp=bin_compare(root->node->square,node->square);

	if(cmp<0)
		{
		if(!root->lson)
			{
			root->lson=set_node(root,node,depth);
			return NULL;
			}
		else return check_node(root->lson,node,depth+1);
		}
	else if(cmp>0)
		{
		if(!root->rson)
			{
			root->rson=set_node(root,node,depth);
			return NULL;
			}
		else return check_node(root->rson,node,depth+1);
		}

	return root->node;
	}
Example #3
0
static void set_node(bs_tree_t* tree, bs_tree_node_t* node, void* key, void* value)
{
	int cmp = tree->compare(node->key, key);
	
	if(cmp <= 0)
	{
		if(node->left) set_node(tree, node->left, key, value);
		else node->left = create_node(node, key, value);
	}
	else
	{
		if(node->right) set_node(tree, node->right, key, value);
		else node->right = create_node(node, key, value);
	}
}
Example #4
0
File: ksm02.c Project: 1587/ltp
int main(int argc, char *argv[])
{
	int lc;
	int size = 128, num = 3, unit = 1;
	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
	unsigned int node;

	tst_parse_opts(argc, argv, ksm_options, ksm_usage);

	node = get_a_numa_node(tst_exit);
	set_node(nmask, node);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		tst_count = 0;
		check_ksm_options(&size, &num, &unit);

		if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1) {
			if (errno != ENOSYS)
				tst_brkm(TBROK | TERRNO, cleanup,
					 "set_mempolicy");
			else
				tst_brkm(TCONF, cleanup,
					 "set_mempolicy syscall is not "
					 "implemented on your system.");
		}
		create_same_memory(size, num, unit);

		write_cpusets(node);
		create_same_memory(size, num, unit);
	}
	cleanup();
	tst_exit();
}
Example #5
0
int bs_tree_set(bs_tree_t* tree, void* key, void* value)
{
	if(!tree->root)
		tree->root = create_node(NULL, key, value);
	else
		set_node(tree, tree->root, key, value);
}
Example #6
0
void create_node(node_p *node, int key, char *str)
{
    node_p temp;
    temp  = malloc(sizeof(node_p));
    set_node(temp, key, str);
    *node = temp;
}
Example #7
0
 // ----------------------------------------------------------------------
 void
     SimpleMovement::
     init( Node& v )
     throw()
 {
     set_node(v);
     movement_initial_boxes();
 }
Example #8
0
/* Add a node to the tree */
static void place_node(struct menu *menu, char **row)
{
	GtkTreeIter *parent = parents[indent - 1];
	GtkTreeIter *node = parents[indent];

	gtk_tree_store_append(tree, node, parent);
	set_node(node, menu, row);
}
Example #9
0
/////////////////////////////////
// 下面重载的这些是运算符是让deque
//从外界看上去维护的是一段连续空间的关键
////////////////////////////////
  self& operator++()
  {
    ++cur;       //切换到下一个元素
    if (cur == last) {    //如果达到了缓冲区尾端
      set_node(node + 1); //就切换至下一节点(也就是缓冲区)
      cur = first;        //的第一个元素
    }
    return *this;
  }
Example #10
0
 // 前缀自减, 处理方式类似于前缀自增
 // 如果当前迭代器指向元素是当前缓冲区的第一个元素
 // 则将迭代器状态调整为前一个缓冲区的最后一个元素
 self& operator--()
 {
   if (cur == first) {
     set_node(node - 1);
     cur = last;
   }
   --cur;
   return *this;
 }
Example #11
0
 // ----------------------------------------------------------------------
 void
     SimpleMovement::
     init_from( Node& v,
     NodeMovement& nm )
     throw()
 {
     set_node(v);
     movement_update_boxes();
 }
Example #12
0
static void set_global_mempolicy(int mempolicy)
{
#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
	&& HAVE_MPOL_CONSTANTS
	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
	int num_nodes, *nodes;
	int ret;

	if (mempolicy) {
		ret = get_allowed_nodes_arr(NH_MEMS|NH_CPUS, &num_nodes, &nodes);
		if (ret != 0)
			tst_brkm(TBROK|TERRNO, cleanup,
				 "get_allowed_nodes_arr");
		if (num_nodes < 2) {
			tst_resm(TINFO, "mempolicy need NUMA system support");
			free(nodes);
			return;
		}
		switch(mempolicy) {
		case MPOL_BIND:
			/* bind the second node */
			set_node(nmask, nodes[1]);
			break;
		case MPOL_INTERLEAVE:
		case MPOL_PREFERRED:
			if (num_nodes == 2) {
				tst_resm(TINFO, "The mempolicy need "
					 "more than 2 numa nodes");
				free(nodes);
				return;
			} else {
				/* Using the 2nd,3rd node */
				set_node(nmask, nodes[1]);
				set_node(nmask, nodes[2]);
			}
			break;
		default:
			tst_brkm(TBROK|TERRNO, cleanup, "Bad mempolicy mode");
		}
		if (set_mempolicy(mempolicy, nmask, MAXNODES) == -1)
			tst_brkm(TBROK|TERRNO, cleanup, "set_mempolicy");
	}
#endif
}
   // ----------------------------------------------------------------------
   void
   ExtIfaceProcessor::
   boot()
      throw()
   {
#ifdef ENABLE_TESTBEDSERVICE
      set_node( owner_w() );
      testbedservice_proc_boot();
#endif
   }
Example #14
0
File: zdd.c Project: blynn/zddfun
uint32_t zdd_add_node(uint32_t v, int offlo, int offhi) {
  int n = freenode;
  uint32_t adjust(int off) {
    if (!off) return 0;
    if (-1 == off) return 1;
    return n + off;
  }
  set_node(n, v, adjust(offlo), adjust(offhi));
  return freenode++;
}
   // ----------------------------------------------------------------------
   void
   ExampleTestbedServiceProcessor::
   boot()
      throw()
   {
      // important to call boot of parent!
      set_node( owner_w() );
      TestbedServiceProcessor::testbedservice_proc_boot();

      std::cout << "ExampleTestbedServiceProcessor::boot" << std::endl;
   }
Example #16
0
static int fuse_exfat_open(const char* path, struct fuse_file_info* fi)
{
	struct exfat_node* node;
	int rc;

	exfat_debug("[%s] %s", __func__, path);

	rc = exfat_lookup(&ef, &node, path);
	if (rc != 0)
		return rc;
	set_node(fi, node);
	return 0;
}
Example #17
0
//-------------------------------------------------------------
// Model::open_node() parse a node string
//-------------------------------------------------------------
NodeIF *Model::open_node(NodeIF *parent,char *fn)
{
	set_node(0);

 	FILE *fp = fopen(fn, "rb");
 	if(fp != NULL){
		int ok=parse(fn);
		fclose(fp);
		if(!ok)
			return 0;
		return get_node();
	}
	return 0;
}
Example #18
0
//实现随机存取,迭代器可以直接跳跃n个距离
  self& operator+=(difference_type n)
  {
    difference_type offset = n + (cur - first);
    if (offset >= 0 && offset < difference_type(buffer_size()))
      cur += n; //目标位置在同一缓冲区内
    else {  //目标位置不在同一缓冲区内
      difference_type node_offset =
        offset > 0 ? offset / difference_type(buffer_size())
                   : -difference_type((-offset - 1) / buffer_size()) - 1;
      set_node(node + node_offset);  //切换到正确的节点(缓冲区)
	  //切换到正确的元素
      cur = first + (offset - node_offset * difference_type(buffer_size()));
    }
    return *this;
  }
Example #19
0
File: main.c Project: PyHDI/PyCoRAM
//------------------------------------------------------------------------------
Node* add_node(Uint id)
{
  Node* ret = get_node(id);
  if(ret == NULL){
    node_array[node_index].parent_node = 0;
    node_array[node_index].current_cost = MAX_INT;
    node_array[node_index].visited = 0;
    node_array[node_index].page_addr = NULL;
    id_table[node_index] = id;
    set_node(id, &node_array[node_index]);
    ret = &node_array[node_index];
    node_index++;
    return ret;
  }
  return ret;
}
Example #20
0
static int fuse_exfat_create(const char* path, mode_t mode,
		struct fuse_file_info* fi)
{
	struct exfat_node* node;
	int rc;

	exfat_debug("[%s] %s 0%ho", __func__, path, mode);

	rc = exfat_mknod(&ef, path);
	if (rc != 0)
		return rc;
	rc = exfat_lookup(&ef, &node, path);
	if (rc != 0)
		return rc;
	set_node(fi, node);
	return 0;
}
// construct tree nodes for an sexp, adding them to the list and returning first node
int campaign_sexp_tree::load_sub_tree(int index)
{
	int cur;

	if (index < 0) {
		cur = allocate_node(-1);
		set_node(cur, (SEXPT_OPERATOR  | SEXPT_VALID), "do-nothing");  // setup a default tree if none
		return cur;
	}

	// assumption: first token is an operator.  I require this because it would cause problems
	// with child/parent relations otherwise, and it should be this way anyway, since the
	// return type of the whole sexp is boolean, and only operators can satisfy this.
	Assert(Sexp_nodes[index].subtype == SEXP_ATOM_OPERATOR);
	cur = get_new_node_position();
	load_branch(index, -1);
	return cur;
}
Example #22
0
    // ----------------------------------------------------------------------
    void
        JumpMovement::
        init_from( Node& v,
        NodeMovement& nm )
        throw()
    {
        set_node(v);
        set_position(nm.position());

        if ( update_mask_[JumpMovement::X] )
            pos_ = Vec( update_pos_[JumpMovement::X], pos_.y(), pos_.z() );
        if ( update_mask_[JumpMovement::Y] )
            pos_ = Vec( pos_.x(), update_pos_[JumpMovement::Y], pos_.z() );
        if ( update_mask_[JumpMovement::Z] )
            pos_ = Vec( pos_.x(), pos_.y(), update_pos_[JumpMovement::Z] );
        
        movement_initial_boxes();
    }
Example #23
0
int insert_content_node(c_list *list, char *index, char *content, unsigned int len){
	if(!list)
		return -1;
	
	c_node *tmp = Malloc(sizeof(*tmp));
	init_node(tmp);
	set_node(tmp, index, len);
	
	if(!tmp)
		return -1;
		
	tmp->content = Malloc(sizeof(char)*len);
	memcpy(tmp->content, content,len);

	pthread_rwlock_wrlock((list->lock));
	add_node(tmp, list);
	pthread_rwlock_unlock((list->lock));
	return 0;
}
Example #24
0
tree_t *build_synthetic_topology_old(int *synt_tab,int id,int depth,int nb_levels){
  tree_t *res,**child;
  int arity=synt_tab[0];
  int val,i; 

  res=(tree_t*)malloc(sizeof(tree_t));
  val=0;
  if(depth>=nb_levels)
    child=NULL;
  else{
    child=(tree_t**)malloc(sizeof(tree_t*)*arity);
    for(i=0;i<arity;i++){
      child[i]=build_synthetic_topology_old(synt_tab+1,i,depth+1,nb_levels);
    child[i]->parent=res;
    val+=child[i]->val;
    }
  }
  set_node(res,child,arity,NULL,id,val+speed(depth),child[0]);
  return res;
}
Example #25
0
/* Build ring of nodes and edges around the current hex
 */
static gboolean build_network(Hex * hex, G_GNUC_UNUSED gpointer closure)
{
	gint idx;

	for (idx = 0; idx < 6; idx++) {
		Node *node = NULL;
		Edge *edge = NULL;

		if (get_cc_hex(hex, idx) != NULL)
			node = get_cc_hex_node(hex, idx);
		if (node == NULL && get_cw_hex(hex, idx) != NULL)
			node = get_cw_hex_node(hex, idx);
		if (node == NULL) {
			node = g_malloc0(sizeof(*node));
			node->map = hex->map;
			node->owner = -1;
			node->x = hex->x;
			node->y = hex->y;
			node->pos = idx;
		}
		set_node(hex, idx, node);
		set_node_hex(hex, idx, hex);

		if (get_op_hex(hex, idx) != NULL)
			edge = get_op_hex_edge(hex, idx);
		if (edge == NULL) {
			edge = g_malloc0(sizeof(*edge));
			edge->map = hex->map;
			edge->owner = -1;
			edge->x = hex->x;
			edge->y = hex->y;
			edge->pos = idx;
		}
		set_edge(hex, idx, edge);
		set_edge_hex(hex, idx, hex);
	}

	return FALSE;
}
Example #26
0
static void testcpuset(void)
{
	int lc;
	int child, i, status;
	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
	char mems[BUFSIZ], buf[BUFSIZ];

	read_cpuset_files(CPATH, "cpus", buf);
	write_cpuset_files(CPATH_NEW, "cpus", buf);
	read_cpuset_files(CPATH, "mems", mems);
	write_cpuset_files(CPATH_NEW, "mems", mems);
	SAFE_FILE_PRINTF(cleanup, CPATH_NEW "/tasks", "%d", getpid());

	switch (child = fork()) {
	case -1:
		tst_brkm(TBROK | TERRNO, cleanup, "fork");
	case 0:
		for (i = 0; i < nnodes; i++) {
			if (nodes[i] >= MAXNODES)
				continue;
			set_node(nmask, nodes[i]);
		}
		if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1)
			tst_brkm(TBROK | TERRNO, cleanup, "set_mempolicy");
		exit(mem_hog_cpuset(ncpus > 1 ? ncpus : 1));
	}
	for (lc = 0; TEST_LOOPING(lc); lc++) {
		tst_count = 0;
		snprintf(buf, BUFSIZ, "%d", nodes[0]);
		write_cpuset_files(CPATH_NEW, "mems", buf);
		snprintf(buf, BUFSIZ, "%d", nodes[1]);
		write_cpuset_files(CPATH_NEW, "mems", buf);
	}

	if (waitpid(child, &status, WUNTRACED | WCONTINUED) == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
	if (WEXITSTATUS(status) != 0)
		tst_resm(TFAIL, "child exit status is %d", WEXITSTATUS(status));
}
Example #27
0
//-------------------------------------------------------------
// Model::parse_node() parse a node string
//-------------------------------------------------------------
NodeIF *Model::parse_node(NodeIF *parent,char *s){
    FILE *fp = File.writeFile(File.system, (char*)"node.spx");
	if(!fp)
	    return 0;
	fprintf(fp,s);
	fclose(fp);
    char path[256];

    File.getBaseDirectory(path);
    File.addToPath(path,File.system);
    File.addToPath(path,"node.spx");

	fp=fopen(path,"rb");
	if(!fp)
	    return 0;
	set_node(0);
	int ok=parse(path);
	fclose(fp);
	if(ok)
		return get_node();
	return 0;
}
Example #28
0
void AutoThrottleWidget::on_at_button_clicked()
{
	emit set_node("/instrumentation/flightdirector/at-on", buttATEnabled->isChecked() ? "1" : "0");
}
Example #29
0
void AutoThrottleWidget::on_val_changed(int val)
{
	emit set_node("/autopilot/settings/target-speed-kt", QString::number(val));
}
Example #30
0
/*
 * Update the tree by adding/removing entries
 * Does not change other nodes
 */
static void update_tree(struct menu *src, GtkTreeIter * dst)
{
	struct menu *child1;
	GtkTreeIter iter, tmp;
	GtkTreeIter *child2 = &iter;
	gboolean valid;
	GtkTreeIter *sibling;
	struct symbol *sym;
	struct property *prop;
	struct menu *menu1, *menu2;

	if (src == &rootmenu)
		indent = 1;

	valid = gtk_tree_model_iter_children(model2, child2, dst);
	for (child1 = src->list; child1; child1 = child1->next) {

		prop = child1->prompt;
		sym = child1->sym;

	      reparse:
		menu1 = child1;
		if (valid)
			gtk_tree_model_get(model2, child2, COL_MENU,
					   &menu2, -1);
		else
			menu2 = NULL;	// force adding of a first child

#ifdef DEBUG
		printf("%*c%s | %s\n", indent, ' ',
		       menu1 ? menu_get_prompt(menu1) : "nil",
		       menu2 ? menu_get_prompt(menu2) : "nil");
#endif

		if (!menu_is_visible(child1) && !show_all) {	// remove node
			if (gtktree_iter_find_node(dst, menu1) != NULL) {
				memcpy(&tmp, child2, sizeof(GtkTreeIter));
				valid = gtk_tree_model_iter_next(model2,
								 child2);
				gtk_tree_store_remove(tree2, &tmp);
				if (!valid)
					return;	// next parent 
				else
					goto reparse;	// next child
			} else
				continue;
		}

		if (menu1 != menu2) {
			if (gtktree_iter_find_node(dst, menu1) == NULL) {	// add node
				if (!valid && !menu2)
					sibling = NULL;
				else
					sibling = child2;
				gtk_tree_store_insert_before(tree2,
							     child2,
							     dst, sibling);
				set_node(child2, menu1, fill_row(menu1));
				if (menu2 == NULL)
					valid = TRUE;
			} else {	// remove node
				memcpy(&tmp, child2, sizeof(GtkTreeIter));
				valid = gtk_tree_model_iter_next(model2,
								 child2);
				gtk_tree_store_remove(tree2, &tmp);
				if (!valid)
					return;	// next parent 
				else
					goto reparse;	// next child
			}
		} else if (sym && (sym->flags & SYMBOL_CHANGED)) {
			set_node(child2, menu1, fill_row(menu1));
		}

		indent++;
		update_tree(child1, child2);
		indent--;

		valid = gtk_tree_model_iter_next(model2, child2);
	}
}