Пример #1
0
fint stringTableEntry::length() {
  if (is_string()) return 1;
  if (!get_link()) return 0;
  fint count = 0;
  for (stringTableLink* l = get_link(); l; l = l->next) count ++;
  return count;
}
Пример #2
0
int symbolTableEntry::length() {
  if (is_symbol()) return 1;
  if (!get_link()) return 0;
  int count = 0;
  for (symbolTableLink* l = get_link(); l; l = l->next) count ++;
  return count;
}
Пример #3
0
void g1_path_object_class::editor_draw(g1_draw_context_class * context)
{
	int i;

	for (i=0; i<total_links(G1_ALLY); i++)
	{
		g1_object_class * o = get_link(G1_ALLY,i);
		if (o)
		{
			g1_render.render_3d_line(i4_3d_point_class(x,y,h+0.1f),
									 i4_3d_point_class(o->x, o->y, o->h+0.1f),
									 0xffffff, 0, context->transform);
		}
	}

	for (i=0; i<total_links(G1_ENEMY); i++)
	{
		g1_object_class * o = get_link(G1_ENEMY,i);
		if (o)
		{
			g1_render.render_3d_line(i4_3d_point_class(o->x, o->y, o->h+0.1f),
									 i4_3d_point_class(x,y,h+0.1f),
									 0xffffff, 0, context->transform);
		}
	}
	li_g1_ref_list::get(vars->get(controlled_objects),0)->draw(this, 0xff0000, context);
}
Пример #4
0
 std::weak_ptr<vertex> get_up() {
     if (up.lock().get() == NULL) {
         if (get_link().lock()->leaf) {
             up = get_link();
         } else
             if ((get_link().lock())->parent.lock().get() != NULL)
                  up = get_link().lock()->get_up();
     }
     return up;
 }
Пример #5
0
bool stringTableEntry::verify(fint i) {
  bool flag = true;
  if (is_string()) {
    if (!get_string()->is_string()) {
      error1("entry 0x%lx in string table isn't a string", get_string());
      flag = false;
    }
  } else {
    if (get_link()) flag = get_link()->verify(i);
  }
  return flag;
}
Пример #6
0
bool symbolTableEntry::verify(int i) {
  bool flag = true;
  if (is_symbol()) {
    if (!get_symbol()->is_symbol()) {
      error("entry %#lx in symbol table isn't a symbol", get_symbol());
      flag = false;
    }
  } else {
    if (get_link()) flag = get_link()->verify(i);
  }
  return flag;
}
Пример #7
0
void dlist::remove(void *item)
{
   void *xitem;
   dlink *ilink = get_link(item);   /* item's link */
   if (item == head) {
      head = ilink->next;
      if (head) {
         set_prev(head, NULL);
      }
      if (item == tail) {
         tail = ilink->prev;
      }
   } else if (item == tail) {
      tail = ilink->prev;
      if (tail) {
         set_next(tail, NULL);
      }
   } else {
      xitem = ilink->next;
      set_prev(xitem, ilink->prev);
      xitem = ilink->prev;
      set_next(xitem, ilink->next);
   }
   num_items--;
   if (num_items == 0) {
      head = tail = NULL;
   }
}
Пример #8
0
void loop(char *data)
{
	char c;

	c = get_char(data);
	
	while ( c != '\0')
	{
		data++;
	
		//html format flag "<"	
		if (c =='<')
		{
			//"<a" link flag 
			if (!strncmp(data,"a ",2))
			{	
				data += 2;
				get_link(data);
			}
			else if (!strncmp(data,"img ",4))
			{
				//"<img" image flag 
				data += 4;
				get_image(data);
			}
		}
		// search next "<"
		c = get_char(data);
	}


}
Пример #9
0
static void	send_plyr_lvl(const int x, const int y, const int lvl)
{
  uint		i;
  t_users	*plyr;
  t_link	*plyr_lnk;
  char		lvlup_msg[END_LEVELUP_MSG_SZ];

  i = 0;
  snprintf(lvlup_msg, sizeof(lvlup_msg), "niveau actuel : %d\n", lvl);
  while (i < g_info.users->size)
    {
      if ((plyr_lnk = get_link(g_info.users, i)))
	{
	  plyr = (t_users*)plyr_lnk->ptr;
	  if (plyr->x == x && plyr->y == y && plyr->lvl == lvl &&
	      (plyr->type == TPLAYER || plyr->type == TFORMER_GHOST))
	    {
	      push_back(plyr->messages,
			new_link_by_param(lvlup_msg, strlen(lvlup_msg) + 1));
	      lookup(g_info.users, graphics_plv(plyr), &notify_graphic);
	    }
	}
      ++i;
    }
}
Пример #10
0
void
link_dialog_run(GtkWindow *win, JamDoc *doc) {
	STACK(LinkDialog, ld);
	GtkTextBuffer *buffer;
	GtkTextIter start, end;
	char *sel = NULL;
	char *link;

	JamAccount *acc = jam_doc_get_account(doc);
	make_link_dialog(ld, win, JAM_ACCOUNT_IS_LJ(acc));

	buffer = jam_doc_get_text_buffer(doc);
	if (gtk_text_buffer_get_selection_bounds(buffer, &start, &end))
		sel = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
	prepopulate_fields(ld, sel);
	g_free(sel);

	if (gtk_dialog_run(GTK_DIALOG(ld->dlg)) != GTK_RESPONSE_OK) {
		gtk_widget_destroy(ld->dlg);
		return;
	}

	link = get_link(ld, acc);

	gtk_widget_destroy(ld->dlg);

	if (link) {
		gtk_text_buffer_begin_user_action(buffer);
		gtk_text_buffer_delete(buffer, &start, &end);
		gtk_text_buffer_insert(buffer, &start, link, -1);
		gtk_text_buffer_end_user_action(buffer);
		g_free(link);
	}
}
Пример #11
0
void	extract_data(t_env *env, t_data **room)
{
	char	*line;
	int		type;
	t_data	*temp;

	get_ant_numbers(env);
	temp = *room;
	while (get_next_line(0, &line) && ft_printf("%s\n", line))
	{
		type = what_type(line);
		if (type == 1)
			get_link(line, temp);
		else if (type == 2)
			get_room(line, &temp, env);
		else if (type == 3)
			;
		else if (type == 4)
			env->type = check_special(line, env);
		else
		{
			ft_putstr("error: invalid line\n");
			exit(0);
		}
		free(line);
	}
	*room = temp;
}
Пример #12
0
void Stack<E, F>::pop_segment()
{
  assert(this->_cur_seg_size == 0, "current segment is not empty");
  E* const prev = get_link(_cur_seg);
  if (this->_cache_size < this->_max_cache_size) {
    // Add the current segment to the cache.
    DEBUG_ONLY(zap_segment(_cur_seg, false);)
Пример #13
0
int go(int v, int c) {
  if (!t[v].go[c]) {
    if (t[v].next[c])
      t[v].go[c] = t[v].next[c];
    else
      t[v].go[c] = v==0 ? 0 : go(get_link(v), c);
  }
  return t[v].go[c];
}
Пример #14
0
int get_link(int v) {
  if (!t[v].link) {
    if (v == 0 || t[v].p == 0)
      t[v].link = 0;
    else
      t[v].link = go(get_link (t[v].p), t[v].pch);
  }
  return t[v].link;
}
Пример #15
0
 /*!
     Adds a left child or right child depending on direction, and
     returns a pointer to that child.
  */
  inline node_ptr_t add_child(const_reference element, Direction dir)    {
     switch (dir)    {
         case Direction::LEFT:   {
             avl_node *newNode = new avl_node(element);
             left = newNode;
             newNode->parent = this;
             return get_link(left);
         }
         case Direction::RIGHT:  {
             avl_node *newNode = new avl_node(element);
             right = newNode;
             newNode->parent = this;
             return get_link(right);
         }
         default:
             return nullptr;
     }
  }
Пример #16
0
vertex* go(vertex* v, int c) {
  if (!v->go[c]) {
    if (v->next[c])
      v->go[c] = v->next[c];
    else
      v->go[c] = v->p ? go(get_link(v), c) : v;
  }
  return v->go[c];
}
Пример #17
0
void dbg_test_dir(const char *dir) {
	if (arg_debug) {
		if (is_dir(dir))
			printf("%s is a directory\n", dir);
		if (is_link(dir)) {
			char *lnk = get_link(dir);
			if (lnk) {
				printf("%s is a symbolic link to %s\n", dir, lnk);
				free(lnk);
			}
		}
	}
}
Пример #18
0
 std::weak_ptr<vertex> go (char c) {
     std::weak_ptr<vertex> next;
     auto itr = children.find(c);
     if (itr != children.end()) {
         next = itr->second;
     } else {
         if (parent.lock().get() == NULL) {
                 next = root;
             }
             else next = get_link().lock()->go(c);
     }
     return next;
 }
Пример #19
0
bool AdminNetLinkDelete::commit(AdminState* admin) throw (admin_error)
{
	AdminNetLinkBase::commit(admin);

	AdminState::WriteLockRecord net_rec = get_net_write();
	NetStatePtr net = boost::dynamic_pointer_cast<NetState>(net_rec.first);

	NetEdge e;
	if (!net->get_edge(get_link(), e, *net_rec.second))
		return false;

	net->remove_edge(e, *net_rec.second);
	return true;
}
Пример #20
0
link_id g1_path_object_class::link_to(g1_team_type team, g1_path_object_class * obj)
{
	//link_id ret=0;
	int t=total_links(); //we actually ignore the team

	//g1_path_object_class *c;
	for (int i=0; i<t; i++)
	{
		if (obj==get_link(i))
		{
			return get_link_id(i);
		}
	}
	return 0;
}
Пример #21
0
void dlist::insert_before(void *item, void *where)
{
   dlink *where_link = get_link(where);

   set_next(item, where);
   set_prev(item, where_link->prev);

   if (where_link->prev) {
      set_next(where_link->prev, item);
   }
   where_link->prev = item;
   if (head == where) {
      head = item;
   }
   num_items++;
}
Пример #22
0
void dlist::insert_after(void *item, void *where)
{
   dlink *where_link = get_link(where);

   set_next(item, where_link->next);
   set_prev(item, where);

   if (where_link->next) {
      set_prev(where_link->next, item);
   }
   where_link->next = item;
   if (tail == where) {
      tail = item;
   }
   num_items++;
}
Пример #23
0
void fs_dev_shm(void) {
	uid_t uid = getuid(); // set a new shm only if we started as root
	if (uid)
		return;

	if (is_dir("/dev/shm")) {
		if (arg_debug)
			printf("Mounting tmpfs on /dev/shm\n");
		if (mount("tmpfs", "/dev/shm", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC,  "mode=777,gid=0") < 0)
			errExit("mounting /dev/shm");
	}
	else {
		char *lnk = get_link("/dev/shm");
		if (lnk) {
			// convert a link such as "../shm" into "/shm"
			char *lnk2 = lnk;
			int cnt = 0;
			while (strncmp(lnk2, "../", 3) == 0) {
				cnt++;
				lnk2 = lnk2 + 3;
			}
			if (cnt != 0)
				lnk2 = lnk + (cnt - 1) * 3 + 2;

			if (!is_dir(lnk2)) {
				// create directory
				if (mkdir(lnk2, S_IRWXU|S_IRWXG|S_IRWXO))
					errExit("mkdir");
				if (chown(lnk2, 0, 0))
					errExit("chown");
				if (chmod(lnk2, S_IRWXU|S_IRWXG|S_IRWXO))
					errExit("chmod");
			}
			if (arg_debug)
				printf("Mounting tmpfs on %s on behalf of /dev/shm\n", lnk2);
			if (mount("tmpfs", lnk2, "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC,  "mode=777,gid=0") < 0)
				errExit("mounting /var/tmp");
			free(lnk);
		}
		else {
			fprintf(stderr, "Warning: /dev/shm not mounted\n");
			dbg_test_dir("/dev/shm");
		}
			
	}
}
Пример #24
0
void mininode_group::update_dirty()
   {
   miniv3d center;
   double radius;

   unsigned int s=get_links();

   // clear bounding sphere
   bound_center=miniv3d(0,0,0);
   bound_radius=0.0;

   // get bounding sphere
   get_bsphere(center,radius);

   // merge bounding sphere with children
   for (unsigned int i=0; i<s; i++)
      {
      mininode *link=get_link(i);

      // get child group
      mininode_group *child_group=dynamic_cast<mininode_group *>(link);

      if (child_group)
         {
         miniv3d child_center;
         double child_radius;

         child_group->get_bsphere(child_center,child_radius);

         // merge with child bounding sphere
         if (child_radius>0.0)
            if (radius>0.0)
               merge_spheres(center,radius,
                             child_center,child_radius);
            else
               {
               center=child_center;
               radius=child_radius;
               }
         }
      }

   bound_center=center;
   bound_radius=radius;
   }
Пример #25
0
void tree_extend (int pos) {
	for(;;) {
		state nptr = go (ptr, pos, pos+1);
		if (nptr.v != -1) {
			ptr = nptr;
			return;
		}
 
		int mid = split (ptr);
		int leaf = sz++;
		t[leaf] = node (pos, n, mid);
		t[mid].get( s[pos] ) = leaf;
 
		ptr.v = get_link (mid);
		ptr.pos = t[ptr.v].len();
		if (!mid)  break;
	}
}
Пример #26
0
static t_list	*mk_link(char *arg, char *d_name)
{
	char			*path;
	t_list			*lst;
	struct stat		buff_stat;

	if (!(path = path_builder(arg, d_name)))
		return (NULL);
	if (lstat(path, &buff_stat) == -1)
	{
		puterror(path);
		return (NULL);
	}
	if (!(lst = get_link(d_name, &buff_stat, path)))
		return (NULL);
	free(path);
	return (lst);
}
Пример #27
0
void Stack<E, F>::push_segment()
{
  assert(this->_cur_seg_size == this->_seg_size, "current segment is not full");
  E* next;
  if (this->_cache_size > 0) {
    // Use a cached segment.
    next = _cache;
    _cache = get_link(_cache);
    --this->_cache_size;
  } else {
    next = alloc(segment_bytes());
    DEBUG_ONLY(zap_segment(next, true);)
  }
  const bool at_empty_transition = is_empty();
  this->_cur_seg = set_link(next, _cur_seg);
  this->_cur_seg_size = 0;
  this->_full_seg_size += at_empty_transition ? 0 : this->_seg_size;
  DEBUG_ONLY(verify(at_empty_transition);)
}
Пример #28
0
char		*graphics_tna(void)
{
  uint		i;
  int		idx;
  t_link	*team;
  char		*msg;

  msg = get_graphics_buf();
  i = 0;
  idx = 0;
  while (i < g_info.world.teams_names->size)
    {
      if ((team = get_link(g_info.world.teams_names, i)))
	idx += snprintf(msg + idx, GRAPHICS_MSG_SZ - idx, "tna %s\n",
			((t_team*)team->ptr)->name);
      ++i;
    }
  return (msg);
}
Пример #29
0
g1_path_object_class * g1_path_object_class::get_recent_link(g1_team_type team,
															 g1_path_object_class * last_used)
{
	g1_path_object_class * best=0;
	//Fixed bug in the following line, Maximum was 0xffffffff casted to signed...
	w32 max_allowed=last_used ? last_used->last_selected_tick[team] : 0x7fffffff-1;

	w32 t=total_links(team);
	w32 best_tick=0;
	int past_it=0;

	for (int i=0; i<(int)t; i++)
	{
		g1_path_object_class * p=get_link(team,i);
		if (p)
		{
			int tick=p->last_selected_tick[team];

			if (tick<=(int)max_allowed)
			{
				if (tick<(int)max_allowed && tick>(int)best_tick)
				{
					best=p;
					best_tick=tick;
				}
				else if (tick==(int)max_allowed && past_it && best_tick!=max_allowed)
				{
					best=p;
					best_tick=tick;
				}
			}

			if (p==last_used)
			{
				past_it=1;
			}
		}
	}

	return best;
}
Пример #30
0
void	ft_add_file2(t_mem *s, t_fil *file, struct stat buf, t_fil **list)
{
	if (file->typ == 'l')
	{
		if (get_link(file, file->path) == 0)
		{
			ft_error(file->path);
			return ;
		}
	}
	get_usgr(file, s, buf);
	file->bloc = buf.st_blocks;
	file->hide = 0;
	if (file->name[0] == '.')
		file->hide = 1;
	file->links = buf.st_nlink;
	file->next = NULL;
	if (*list == NULL)
		*list = file;
	else
		s->f_sort(list, file);
}