Exemple #1
0
static void image_ilbm___decode(INT32 args)
{
   unsigned char *s;
   ptrdiff_t len;
   struct pike_string *str;
   struct mapping *m;
   int n;
   extern void parse_iff(char *, unsigned char *, ptrdiff_t,
			 struct mapping *, char *);

   get_all_args("__decode", args, "%S", &str);

   s = (unsigned char *)str->str;
   len = str->len;
   pop_n_elems(args-1);

   for(n=0; n<5; n++)
     push_int(0);
   push_mapping(m = allocate_mapping(4));

   parse_iff("ILBM", s, len, m, "BODY");

   mapping_index_no_free(sp-5, m, &string_[string_BMHD]);
   mapping_index_no_free(sp-4, m, &string_[string_CMAP]);
   mapping_index_no_free(sp-3, m, &string_[string_CAMG]);
   mapping_index_no_free(sp-2, m, &string_[string_BODY]);

   map_delete(m, &string_[string_BMHD]);
   map_delete(m, &string_[string_CMAP]);
   map_delete(m, &string_[string_CAMG]);
   map_delete(m, &string_[string_BODY]);

   if(sp[-5].type != T_STRING)
     Pike_error("Missing BMHD chunk\n");
   if(sp[-2].type != T_STRING)
     Pike_error("Missing BODY chunk\n");

   /* Extract image size from BMHD */
   s = (unsigned char *)STR0(sp[-5].u.string);
   len = sp[-5].u.string->len;

   if(len<20)
     Pike_error("Short BMHD chunk\n");

   free_svalue(sp-7);

   sp[-7].u.integer = (s[0]<<8)|s[1];
   sp[-7].type = T_INT;
   sp[-7].subtype = NUMBER_NUMBER;
   sp[-6].u.integer = (s[2]<<8)|s[3];
   sp[-6].type = T_INT;
   sp[-6].subtype = NUMBER_NUMBER;

   f_aggregate(7);
}
Exemple #2
0
nomask int update_condition()
{
	mixed *cnd, err;
	int i, flag, update_flag;
	object cnd_d;

	if( !mapp(conditions) || !(i=sizeof(conditions)) ) return 0;
	cnd = keys(conditions);
	update_flag = 0;
	while(i--) {

		// In order to not casue player lost heart beat occasionally while
		// calling external condition daemons, we take careful calling
		// convention here.

		cnd_d = find_object(CONDITION_D(cnd[i]));
		if( !cnd_d ) {
//        err = catch(call_other(CONDITION_D(cnd[i]), "???"));
			cnd_d = find_object(CONDITION_D(cnd[i]));

			// If we failed to load the external condition daemon, remove
			// it before we stuff log files with error messages.

			if( err || !cnd_d ) {
				log_file("condition.err",
					sprintf("Failed to load condition daemon %s, removed from %O\nError: %s\n",
						CONDITION_D(cnd[i]), this_object(), err)
				);
				map_delete(conditions, cnd[i]);
				continue;
			}
		}

		// We assume since the condition daemon is loaded successfully, the
		// calling on its update_condition() should success as well. Because
		// catch() is somewhat costly, so we don't attempt to catch possible
		// error from the call_other. It is condition daemon's reponsibility
		// that don't cause error in users's heart beat.
		// If condition daemon returns 0 (or update_condition() not defined),
		// we can just assume the condition expired and remove it.
		
		flag = call_other(cnd_d, "update_condition", this_object(), conditions[cnd[i]]);
		if( !( flag & CND_CONTINUE ) ) {
		    // 3/31/99 check again whether has condition.
		    if(conditions) map_delete(conditions, cnd[i]);
		    else break;
		}

		update_flag |= flag;
	}
	if( !sizeof(conditions) ) conditions = 0;

	return update_flag;
}
Exemple #3
0
static obj_ptr _map_delete(obj_ptr arg1, obj_ptr arg2, obj_ptr env)
{
    if (NMAPP(arg1))
        return MKERROR(MKSTRING("Expected a map in map-delete"), arg1);

    return MKBOOL(map_delete(&MAP(arg1), arg2));
}
Exemple #4
0
int
main() {
	struct map * m = map_new(MAX);
	test(m);
	map_delete(m);
	return 0;
}
Exemple #5
0
int remove_high_lord(string str) {
  if (high_programmer(geteuid(previous_object())) &&
    positions[str] == HIGH_LORD) {
    map_delete(positions, str);
    save_object("/secure/master");
    return 1;
  }
  return 0;
} /* remove_high_lord() */
Exemple #6
0
// delete() uses delete_access(entry) rather than set_access(entry,0) because
// that is The Right Thing (tm) to do.
nomask int delete_access(string entry)
{
    string eff_user;

    eff_user = ( previous_object() ? geteuid( previous_object() ) : geteuid() );
    if( eff_user != geteuid() && eff_user != ROOT_UID ) return 0; // Fail.

    map_delete( perms, entry );
}
Exemple #7
0
// by gslxz@mhsj 1/7/2001
void delete_target(object npc,string name)
{
    mapping data;
    if(! objectp(npc))	return;
    data=npc->query_temp("oldsix/target");
    if(! mapp(data))	return;
    map_delete(data,name);
    npc->set_temp("oldsix/target",data);
}
Exemple #8
0
void map_remove(struct map_ent **mapp, char *devnm)
{
	if (devnm[0] == 0)
		return;

	map_delete(mapp, devnm);
	map_write(*mapp);
	map_free(*mapp);
}
Exemple #9
0
static nomask int _delete( mapping map, string *parts )
{
	if( sizeof( parts ) == 1 ) {
		map_delete( map, parts[0] );
		return 1;
	}
	if( !map[parts[0]] || !mapp( map[parts[0]] ) )
		return 0;
	return _delete( map[parts[0]], parts[1..sizeof(parts)-1] );
}
Exemple #10
0
scalar map_is_correct( struct map_t *map)
{
    scalar is_correct = 1;
    struct map_t *search_map = map_new_clone( map);
    scalar found_ships[ Max_ship_size+1] = { 0, 0, 0, 0, 0};
    for( int i = 0; i < search_map->x_size; i++)
    {
        for( int j = 0; j < search_map->y_size; j++)
        {
            scalar current = map_get( search_map, i, j);
            if( current == Search_mark )
            { 
                continue;
            }
            if( is_ship( current))
            {
                scalar size = map_get_ship_size( search_map, i, j);
                if( size == Bad_map)
                {
                    map_delete( search_map);
                    return 0;
                }
                if( 0 < size && size <= Max_ship_size)
                {
                    found_ships[ size]++;
                }
            }
            map_set( search_map, i, j, Search_mark);
        }
    }
    map_delete( search_map);
    for( int i = 0; i <= Max_ship_size; i++)
    {
        if( found_ships[ i] != Ship_sizes[ i])
        {
            printf( "Warning: ships with length %d expected %d, but found %d\n",
                    i, Ship_sizes[ i], found_ships[ i]);
            is_correct = 0;
        }
    }
    return is_correct;
}
Exemple #11
0
void 
aoi_release(struct aoi_space *space) {
	map_foreach(space->object, delete_object, space);
	map_delete(space, space->object);
	delete_pair_list(space);
	delete_set(space,space->watcher_static);
	delete_set(space,space->marker_static);
	delete_set(space,space->watcher_move);
	delete_set(space,space->marker_move);
	space->alloc(space->alloc_ud, space, sizeof(*space));
}
int remove_student(string name) {
 
   if(!adminp(geteuid(previous_object())) &&
      geteuid(previous_object()) != ROOT_UID)  return 0;
 
   // 	If no name is given, or the name is not in the student
   //	mapping, then return 0 to the calling object.
 
   if(!name || !students[name])  return 0;

   //	Remove the user from the student mapping.

   map_delete(students, name);
   map_delete(sponsors, name) ;
 
   //	Save the student mapping for future use.

   save_students();

return 1; }
Exemple #13
0
int set_alias(string verb, string replace)
{
	if( !replace ) {
		if( mapp(alias) ) map_delete(alias, verb);
		return 1;
	} else {
		if( !mapp(alias) ) alias = ([ verb:replace ]);
		else if( sizeof(alias) > MAX_ALIASES )
			return notify_fail("您设定的 alias 太多了,请先删掉一些不常用的。\n");
		else alias[verb] = replace;
		return 1;
	}
Exemple #14
0
void catch_anything(string who) {
    int bait, classs;

    if(!who) return;        /* how in hell did this happen? */
    if(!present(who)) map_delete(fishing, who);
    if(!fishing[who]) return;
    bait = (int)fishing[who]->query_bait();
    classs = (int)fishing[who]->query_pole_class();
    if( (caught == max_catch) || (random(101) > chance+classs+bait) ) 
	still_fishing(who);
    else caught_something(who);
}
Exemple #15
0
int push_mail( mapping outmsg ) {
  mixed *list;
  int i;
  
  outmsg["SUBJECT"] = outmsg["subject"];
  outmsg["CC"] = outmsg["cc"];
  outmsg["DATE"] = ( outmsg["date"] );
  outmsg["MSG"] = outmsg["message"];
  outmsg["WIZFROM"] = outmsg["from"] + "@" + Mud_name();
  outmsg["WIZTO"] = outmsg["to"];
  
  // Used only for housekeeping on our end.
  outmsg["TIME"] = time();
 
  map_delete( outmsg, "subject" );
  map_delete( outmsg, "cc" );
  map_delete( outmsg, "to" );
  map_delete( outmsg, "from" );
  map_delete( outmsg, "date" );
  map_delete( outmsg, "message" );
  
  
// from, to, subject, msg, cc, date
// First, make sure CC and WIZTO have proper format.
  list = outmsg["WIZTO"];
  
  i = sizeof( list );
  while( i-- ) {
    if( strsrch( list[i], "@" ) < 0 )
      list[i] += "@" + Mud_name();
  }
  
  if( !pointerp( list ) ) list = ({ list });
Exemple #16
0
int get_msg_myself(string msg, mapping emote, string pattern, int n)
{
	msg = replace_string(msg, "\\n", "\n");
	if (msg == "." || msg == "x")
        {
                if (msg == "x")
                        map_delete(emote, "myself");
                else
		if (! n) write("忽略该项描述。\n");
		write("不指定对象使用这个 emote 时,其他人看到的讯息:\n->");
		input_to("get_msg_others", emote, pattern);
		return 1;
	}

	if (! n) map_delete(emote, "myself");
	if (! undefinedp(emote["myself"]))
		emote["myself"] += msg + "\n";
	else emote["myself"] = msg + "\n";
	write("->");
	input_to("get_msg_myself", emote, pattern, n + 1);
	return 1;
}
Exemple #17
0
void resolve_callback(string name, string number, int key){
    string cle;
    object ob;
    if(NamesMap[number]) cle = number;
    else if(NamesMap[name]) cle = name;
    ob = NamesMap[cle];

    map_delete(NamesMap, cle);

    if(ob){
        ob->eventPrint(number+" resolves to: "+name);
    }
}
Exemple #18
0
int get_msg_target(string msg, mapping emote, string pattern, int n)
{
	msg = replace_string(msg, "\\n", "\n");
	if (msg == "." || msg == "x")
        {
                if (msg == "x")
                        map_delete(emote, "target");
                else
		if (! n) write("忽略该项描述。\n");
		write("对别人使用这个 emote 时,除你自己和使用对象外,其他人看到的讯息:\n->");
		input_to("get_msg_others_target", emote, pattern);
		return 1;
	}

	if (! n) map_delete(emote, "target");
	if (! undefinedp(emote["target"]))
		emote["target"] += msg + "\n";
	else emote["target"] = msg + "\n";
	write("->");
	input_to("get_msg_target", emote, pattern, n + 1);
	return 1;
}
Exemple #19
0
int auth_delete(char *user)
{
	struct auth_profile *p=get_profile_by_name(user);

	if (p!=0)
	{
		map_delete(user);

		//struct auth_profile need to be free
		return p->uid;
	}
	return S_NO_USER;
}
Exemple #20
0
void remove_eternal_fate(mixed ob)
{
    string keyword;
    
    if (stringp(ob)) keyword = ob;
    else if (objectp(ob)) {
        keyword = ob->query("fate_keyword");
        if (!keyword)
            keyword = file_name(ob);
    } else
        return;

    map_delete(eternal_fates, keyword);
}
Exemple #21
0
int get_msg_others_target(string msg, mapping emote, string pattern, int n)
{
	msg = replace_string(msg, "\\n", "\n");
	if (msg == "." || msg == "x")
        {
                if (msg == "x")
                        map_delete(emote, "others_target");
                else
		if (! n) write("忽略该项描述。\n");
                emote["time"] = time();
		EMOTE_D->set_emote(pattern, emote);
		write("Emote 编辑结束。\n");
		return 1;
	}

	if (! n) map_delete(emote, "others_target");
	if (! undefinedp(emote["others_target"]))
		emote["others_target"] += msg + "\n";
	else emote["others_target"] = msg + "\n";
	write("->");
	input_to("get_msg_others_target", emote, pattern, n + 1);
	return 1;
}
Exemple #22
0
int main()
{
	int i;

	map_init();

	map_insert("nihao",1);
	map_insert("nishi",2);
	map_insert("nishi",3);
	map_delete("nishi");
	printf("%d %d\n",map_find("nishi"),map_find("nihao"));
	printf("\n");
	return 0;
}
Exemple #23
0
int main(object me, string arg)
{
        mapping map;
        string *types, *skill, ski, map_to;
        int i, modify;
        string check;

	seteuid(getuid());
	if (arg) 
		sscanf(arg, "-%s %s", check, arg); 
	if (check=="check" && wizardp(me) && arg) {
		me = find_player(arg);
		if (!me) me = LOGIN_D->find_body(arg);
		if (!me) return notify_fail("没有这个人。\n");
		}

	if( !arg || check=="check" ) {
		map = me->query_skill_map();
		if( !mapp(map) || sizeof(map)==0 )
			return notify_fail(HIR"你现在没有使用任何特殊技能。\n"NOR);

		skill = keys(valid_types);
		write( CYN "以下是你目前使用中的特殊技能。\n" NOR );
		for (i=0; i<sizeof(skill); i++) {
			if( undefinedp(valid_types[skill[i]]) ) {
				map_delete(map, skill[i]);
				continue;
                        }
			if( !me->query_skill(skill[i]) ) continue;
			modify = me->query_temp("apply/" + skill[i]);
			printf( HIC "  %-20s "NOR+HIY" :"NOR+WHT" %-30s "NOR+RED"有效等级:%s%4d\n"NOR, 
				valid_types[skill[i]] + "(" + skill[i] + ")",
				undefinedp(map[skill[i]]) ? 
			             "无" : to_chinese(map[skill[i]]),
				(modify==0 ? HIW"+"NOR+YEL"" : (modify>0 ? HIC : HIR)),
				me->query_skill(skill[i]));
                }
                return 1;
        }

        if( arg=="?" ) {
                write(CYN"以下是可以使用特殊技能的种类:\n"NOR);
                skill = sort_array(keys(valid_types), (: strcmp :) );
                for(i=0; i<sizeof(skill); i++) {
                        printf("  %s (%s)\n", valid_types[skill[i]], skill[i] );
                }
                return 1;
        }
Exemple #24
0
int stop_fishing(string str) {
    if(!str || str != "fishing") return 0;
    if(!fishing) {
	notify_fail("You are not fishing!\n");
	return 0;
    }
    if(!fishing[(string)this_player()->query_name()]) {
	notify_fail("You are not fishing!\n");
	return 0;
    }
    map_delete(fishing, (string)this_player()->query_name());
    write("You stand up and pull in your line.");
    say(this_player()->query_cap_name()+" gives up on fishing for now.", this_player());
    remove_call_out("catch_anything");
    return 1;
}
Exemple #25
0
int VISIBLE
kqueue(void)
{
	struct kqueue *kq;
    struct kqueue *tmp;

#ifdef _WIN32
    if (InterlockedCompareExchange(&kq_init_begin, 0, 1) == 0) {
        libkqueue_init();
    } else {
        while (kq_init_complete == 0) {
            sleep(1);
        }
    }
#else
    (void) pthread_mutex_lock(&kq_mtx);
    (void) pthread_once(&kq_is_initialized, libkqueue_init);
    (void) pthread_mutex_unlock(&kq_mtx);
#endif

    kq = calloc(1, sizeof(*kq));
    if (kq == NULL)
        return (-1);

	tracing_mutex_init(&kq->kq_mtx, NULL);

    if (kqops.kqueue_init(kq) < 0) {
        free(kq);
        return (-1);
    }

    dbg_printf("created kqueue, fd=%d", kq->kq_id);

    tmp = map_delete(kqmap, kq->kq_id);
    if (tmp != NULL) {
        dbg_puts("FIXME -- memory leak here");
        // TODO: kqops.kqueue_free(tmp), or (better yet) decrease it's refcount
    }
    if (map_insert(kqmap, kq->kq_id, kq) < 0) {
        dbg_puts("map insertion failed");
        kqops.kqueue_free(kq);
        return (-1);
    }

    return (kq->kq_id);
}
Exemple #26
0
void
mread_close(struct mread_pool *self) {
	if (self == NULL)
		return;
	int i;
	struct socket * s = self->sockets;
	for (i=0;i<self->max_connection;i++) {
		if (s[i].status != SOCKET_INVALID) {
			close(s[i].fd);
		}
	}
	free(s);
	if (self->listen_fd >= 0) {
		close(self->listen_fd);
	}
	close(self->epoll_fd);	
	_release_rb(self->rb);
	map_delete(self->socket_hash);
	free(self);
}
Exemple #27
0
int abstain(string s) {
   if(s != "vote") return notify_fail("Abstain what?\n");
   if(!vote[this_player()->query_name()]) return notify_fail("You have not yet
voted.\n");
   switch(vote[this_player()->query_name()]) {
      case "a":
        a--;
        break;
      case "b":
        b--;
        break;
      default:
        write("Unknown execution.\n");
        return 1;
        break;
   }
   map_delete(vote, this_player()->query_name());
   write("You vote has been removed.\n");
   return 1;
}
Exemple #28
0
Tree generate(unsigned int depth) {
    if (depth == 0) {
        return plain_item(item());
    } else {
        Tree node = malloc(sizeof(TreeItem));
        node->map = map_new();

        unsigned int twidth = width();
        unsigned int i;
        for (i = 0; i < twidth; i++) {
            char c = item();
            Tree old = map_get(node->map, c);
            if (old) {
                tree_free(old);
                map_delete(node->map, c);
            }
            map_insert(node->map, c, generate(depth - 1));
        }
        return node;
    }
}
Exemple #29
0
int main (void){
  int a=10, b=6, c=13, d=19, e=14, g=11;
  map m = map_create(f);
 
  map_insert(m, &a);
  map_insert(m, &b);
  map_insert(m, &c);
  map_insert(m, &d);
  map_insert(m, &e);
  map_insert(m, &g);

  map_dump(m);
  //printf("height: %d\n", map_height(m));
  void * fb = map_find(m, g);
  //printf("find %d: %s\n", g, (fb != NULL)?"true":"false");

  map_delete(m, e);
  printf("deleting 14/////////////////////////////////////////////////////\n");
  map_dump(m);
  map_destroy(m);
  return 0;
}
Exemple #30
0
int main(object me, string arg)
{
	mapping map;
	string *types, *skill, ski, map_to;
	int i, modify;

	seteuid(getuid());

	if( !arg ) {
		map = me->query_skill_map();
		if( !mapp(map) || sizeof(map)==0 )
			return notify_fail("你现在没有使用任何特殊技能。\n");

		skill = keys(valid_types);
		write("以下是你目前使用中的特殊技能。\n");
		for (i=0; i<sizeof(skill); i++) {
			if( undefinedp(valid_types[skill[i]]) ) {
				map_delete(map, skill[i]);
				continue;
			}
			if( !me->query_skill(skill[i]) ) continue;
			modify = me->query_temp("apply/" + skill[i]);
			printf("  %-20s: %-20s  有效等级:%s%3d\n" NOR,
				valid_types[skill[i]] + " (" + skill[i] + ")",
				undefinedp(map[skill[i]]) ? "无" : to_chinese(map[skill[i]]),
				(modify==0 ? "" : (modify>0 ? HIC : HIR)),
				me->query_skill(skill[i]));
		}
		return 1;
	}

	if( arg=="?" ) {
		write("以下是可以使用特殊技能的种类:\n");
		skill = sort_array(keys(valid_types), (: strcmp :) );
		for(i=0; i<sizeof(skill); i++) {
			printf("  %s (%s)\n", valid_types[skill[i]], skill[i] );
		}
		return 1;
	}