void *adreno_snapshot(struct kgsl_device *device, void *snapshot, int *remain,
		int hang)
{
	int i;
	uint32_t ptbase, ibbase, ibsize;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);

	/* Reset the list of objects */
	objbufptr = 0;

	/* Get the physical address of the MMU pagetable */
	ptbase = kgsl_mmu_get_current_ptbase(device);

	/* Dump the ringbuffer */
	snapshot = kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_RB,
		snapshot, remain, snapshot_rb, NULL);

	/*
	 * Make sure that the last IB1 that was being executed is dumped.
	 * Since this was the last IB1 that was processed, we should have
	 * already added it to the list during the ringbuffer parse but we
	 * want to be double plus sure.
	 */

	kgsl_regread(device, REG_CP_IB1_BASE, &ibbase);
	kgsl_regread(device, REG_CP_IB1_BUFSZ, &ibsize);

	/*
	 * The problem is that IB size from the register is the unprocessed size
	 * of the buffer not the original size, so if we didn't catch this
	 * buffer being directly used in the RB, then we might not be able to
	 * dump the whle thing. Print a warning message so we can try to
	 * figure how often this really happens.
	 */

	if (!find_object(SNAPSHOT_OBJ_TYPE_IB, ibbase, ptbase) && ibsize) {
		push_object(device, SNAPSHOT_OBJ_TYPE_IB, ptbase,
			ibbase, ibsize);
		KGSL_DRV_ERR(device, "CP_IB1_BASE not found in the ringbuffer. "
			"Dumping %x dwords of the buffer.\n", ibsize);
	}

	kgsl_regread(device, REG_CP_IB2_BASE, &ibbase);
	kgsl_regread(device, REG_CP_IB2_BUFSZ, &ibsize);

	/*
	 * Add the last parsed IB2 to the list. The IB2 should be found as we
	 * parse the objects below, but we try to add it to the list first, so
	 * it too can be parsed.  Don't print an error message in this case - if
	 * the IB2 is found during parsing, the list will be updated with the
	 * correct size.
	 */

	if (!find_object(SNAPSHOT_OBJ_TYPE_IB, ibbase, ptbase) && ibsize) {
		push_object(device, SNAPSHOT_OBJ_TYPE_IB, ptbase,
			ibbase, ibsize);
	}

	/*
	 * Go through the list of found objects and dump each one.  As the IBs
	 * are parsed, more objects might be found, and objbufptr will increase
	 */
	for (i = 0; i < objbufptr; i++)
		snapshot = dump_object(device, i, snapshot, remain);

	/*
	 * Only dump the istore on a hang - reading it on a running system
	 * has a non 0 chance of hanging the GPU
	 */

	if (hang) {
		snapshot = kgsl_snapshot_add_section(device,
			KGSL_SNAPSHOT_SECTION_ISTORE, snapshot, remain,
			snapshot_istore, NULL);
	}

	/* Add GPU specific sections - registers mainly, but other stuff too */
	if (adreno_dev->gpudev->snapshot)
		snapshot = adreno_dev->gpudev->snapshot(adreno_dev, snapshot,
			remain, hang);

	return snapshot;
}
Beispiel #2
0
static void create(varargs int clone) {
    object driver;
    object telnet_manager;
    object http_manager;
    object rsrc_manager;
    object objreg_manager;

    driver = find_object(DRIVER);

    if(!find_object(LOG_D)) {
      compile_object(LOG_D);
    }

    if(find_object(LOG_D)) {
      /* driver -> set_error_manager(find_object(LOG_D)); */
    }

    if(!find_object(TELNET_D)) {
        compile_object(TELNET_D);
    }

    telnet_manager = find_object(TELNET_D);
    "/kernel/sys/userd" -> set_telnet_manager(0, telnet_manager);

    if(!find_object(HTTP_D)) {
      compile_object(HTTP_D);
    }

    http_manager = find_object(HTTP_D);

    "/kernel/sys/userd" -> set_binary_manager(1, http_manager);

    if(!find_object(HTTP_SYSTEM_RESOURCE)) {
      compile_object(HTTP_SYSTEM_RESOURCE);
    }


    if(!find_object("/usr/System/obj/wiztool")) {
        compile_object("/usr/System/obj/wiztool");
    }

    if(!find_object(MAPPING_D)) compile_object(MAPPING_D);
    if(!find_object(STRING_D)) compile_object(STRING_D);
    if(!find_object(AUTH_D)) compile_object(AUTH_D);
    if(!find_object(COMMAND_D)) compile_object(COMMAND_D);

    rsrc::create();

    rsrc::add_owner("ToolLib");
    rsrc::add_owner("DevLib");
    rsrc::add_owner("IFLib");
    rsrc::add_owner("WorldLib");
    rsrc::add_owner("GameLib");

    if(!find_object(TOOLLIB_INIT)) compile_object(TOOLLIB_INIT);
    if(!find_object(DEVLIB_INIT)) compile_object(DEVLIB_INIT);
    if(!find_object(WORLDLIB_INIT)) compile_object(WORLDLIB_INIT);
    if(!find_object(IFLIB_INIT)) compile_object(IFLIB_INIT);
    if(!find_object(GAMELIB_INIT)) compile_object(GAMELIB_INIT);

    http_manager -> update_resource_handlers_from_config();
    find_object(COMMAND_D) -> hash_commands();
}
Beispiel #3
0
void string_list_draw(int x1,int y1,int x2,int y2,OBJREC *o)
  {
  STRING_LIST_DATA *p;
  int xs,ys,y;
  char savech[]=" ";
  int znh,i,j,max;
  TSTR_LIST ls;
  int savcolor=curcolor;

  xs=x2-x1;ys=y2-y1;
  p=o->userptr;
  ls=p->list;
  bar(x1,y1,x2,y2);
  y=y1;p->maxitems=str_count(ls);
  for(j=p->maxitems-1;j>=0;j--) if (ls[j]!=NULL) break;
  j++;
  if (ls)
  {
    do
    {
      i=get_to_topline(ls,p->topline,&max);
      p->maxview=0;
      y=y1;
      do
      {
        char *c;
        int x,j;

        c=ls[i];
        if (c!=NULL && y+(znh=text_height(c))<y2)
        {
          j=p->skipshow;
          while (j-- && *c) c++;
          if (i==*(int *)(o->data))
          {
            curcolor=p->selcolor;
            bar(x1,y,x2,y+znh-1);
          }
          position(x1,y);
          for(j=0,x=x1,savech[0]=c[j];
            c[j]!='\0' && x+text_width(savech)<x2;
            j++,x+=text_width(savech),savech[0]=c[j]
            )
              outtext(savech);
            y+=znh;
            p->maxview++;
        }
        else
          znh=0;
        i++;
      }
      while (y+znh<y2 && i<p->maxitems);
      if (p->topline && y+2*znh<y2 && znh) 
      {
        int dif=y2-(y+znh);
        p->topline-=(dif*2/3)/znh+1;
        curcolor=savcolor;
        bar(x1,y1,x2,y2);
      }
    }
    while (p->topline && y+2*znh<y2 && znh);
  }
  if (waktual->id==p->obj_win)
        {
        OBJREC *ob;

        ob=find_object(waktual,o->id+1);
        if (ob!=NULL)
           {
           send_message(E_GUI,o->id+1,E_CONTROL,0,max-p->maxview,p->maxview);
           ob->events[3]=string_list_change;
           }
        c_set_value(p->obj_win,o->id+1,p->topline);
        }
  }
Beispiel #4
0
void vmtouch_crawl(char *path) {
  struct stat sb;
  DIR *dirp;
  struct dirent *de;
  char npath[PATH_MAX];
  int res;
  int tp_path_len = strlen(path);
  int i;

  if (path[tp_path_len-1] == '/') path[tp_path_len-1] = '\0'; // prevent ugly double slashes when printing path names

  res = o_followsymlinks ? stat(path, &sb) : lstat(path, &sb);

  if (res) {
    warning("unable to stat %s (%s)", path, strerror(errno));
    return;
  } else {
    if (S_ISLNK(sb.st_mode)) {
      warning("not following symbolic link %s", path);
      return;
    }

    if (!o_ignorehardlinkeduplictes && sb.st_nlink > 1) {
      /*
       * For files with more than one link to it, ignore it if we already know
       * inode.  Without this check files copied as hardlinks (cp -al) are
       * counted twice (which may lead to a cache usage of more than 100% of
       * RAM).
       */
      if (find_object(&sb)) {
        // we already saw the device and inode referenced by this file
        return;
      } else {
        add_object(&sb);
      }
    }

    if (S_ISDIR(sb.st_mode)) {
      for (i=0; i<curr_crawl_depth; i++) {
        if (crawl_inodes[i] == sb.st_ino) {
          warning("symbolic link loop detected: %s", path);
          return;
        }
      }

      if (curr_crawl_depth == MAX_CRAWL_DEPTH)
        fatal("maximum directory crawl depth reached: %s", path);

      total_dirs++;

      crawl_inodes[curr_crawl_depth] = sb.st_ino;

      retry_opendir:

      dirp = opendir(path);

      if (dirp == NULL) {
        if (errno == ENFILE || errno == EMFILE) {
          increment_nofile_rlimit();
          goto retry_opendir;
        }

        warning("unable to opendir %s (%s), skipping", path, strerror(errno));
        return;
      }

      while((de = readdir(dirp)) != NULL) {
        if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;

        if (snprintf(npath, sizeof(npath), "%s/%s", path, de->d_name) >= sizeof(npath)) {
          warning("path too long %s", path);
          goto bail;
        }

        curr_crawl_depth++;
        vmtouch_crawl(npath);
        curr_crawl_depth--;
      }

      bail:

      if (closedir(dirp)) {
        warning("unable to closedir %s (%s)", path, strerror(errno));
        return;
      }
    } else if (S_ISREG(sb.st_mode)) {
      total_files++;
      vmtouch_file(path);
    } else {
      warning("skipping non-regular file: %s", path);
    }
  }
}
Beispiel #5
0
 const T* find( object_id_type id )const
 {
    const object* obj = find_object( id );
    assert(  !obj || nullptr != dynamic_cast<const T*>(obj) );
    return static_cast<const T*>(obj);
 }
Beispiel #6
0
/**
 * Move an object and return success or failure.
 * 
 * @param  item          the item to move
 * @param  dest          the environment to move to
 * @return 0 for failure, 1 for success
 */
int move_resolved(mixed item, mixed dest) {
  move_object(item, dest);
  if (!objectp(item)) { item = find_object(item); }
  if (!objectp(dest)) { dest = find_object(dest); }
  return (item && dest && (environment(item) == dest));
}
Beispiel #7
0
int main(object me, string file)
{
        int i;
        object obj, *inv;
        string err;

        seteuid( geteuid(me) );

        if (!file) file = me->query("cwf");
        if (!file)
                return notify_fail("你要重新编译什么档案?\n");

        if( (obj = present(file, environment(me))) && interactive(obj) ) {
            if(wizardp(obj) && wiz_level(me) < wiz_level(obj))
                return notify_fail("你不能更新等级比你高的巫师状态。\n");
                return update_player(obj);
    }
                  
        if( file == "me" )
                return update_player(me);
        else {
                file = resolve_path(me->query("cwd"), file);
                if( !sscanf(file, "%*s.c") ) file += ".c"; 
        }

        if( file_size(file)==-1 )
                return notify_fail("没有这个档案。\n");

        me->set("cwf", file);

        if (obj = find_object(file)) {
                if( obj==environment(me) ) {
                        if( file_name(obj)==VOID_OB )
                                return notify_fail("你不能在 VOID_OB 里重新编译 VOID_OB。\n");
                        inv = all_inventory(obj);
                        i = sizeof(inv);
                        while(i--)
                                if( userp(inv[i]) ) inv[i]->move(VOID_OB, 1);
                                else inv[i] = 0;
                }
                destruct(obj);
        }

        if (obj) return notify_fail("无法清除旧程式码。\n");

    write("重新编译 " + file + ":");
        err = catch( call_other(file, "???") );
        if (err)
                printf( "发生错误:\n%s\n", err );
        else {
                write("成功!\n");
                log_file("/static/update",
			sprintf("%s(%s) update %s on %s\n",
				me->name(1), geteuid(me), file,
				ctime(time()) ) );
                if( (i=sizeof(inv)) && (obj = find_object(file))) {
                        while(i--)
                                if( inv[i] && userp(inv[i]) ) inv[i]->move(obj, 1);
                }
        }
                
        return 1;
}
Beispiel #8
0
static void create (varargs int clone){
    if (!find_object (SYSTEM_USER))
	compile_object (SYSTEM_USER);
    USERD->set_binary_manager (0, this_object ());
}
Beispiel #9
0
int main(object me, string arg)
{
        int goto_inventory = 0;
        object obj, ridee;
        string msg, ridemsg;

        if( !arg ) return notify_fail("你要去哪里?\n");

        if( me->over_encumbranced() )
                   return notify_fail("你负载太重了!\n");

        if( sscanf(arg, "-i %s", arg) ) goto_inventory = 1;

        if( !arg ) return notify_fail("你要去哪里?\n");

        obj = find_player(arg);
        if(!obj) obj = find_living(arg);
       
	if(!obj) obj = LOGIN_D->find_body(arg);
	/* added by mon. 2/23/97 */
	if(!obj) obj = find_object(arg);

	if(!obj || !me->visible(obj)) {
                arg = resolve_path(me->query("cwd"), arg);
                if( !sscanf(arg, "%*s.c") ) arg += ".c";
                if( !(obj = find_object(arg)) ) {
                        if( file_size(arg)>=0 )
                                return me->move(arg);
                        return notify_fail("没有这个玩家、生物、或地方。\n");
                }
        }

        if(!goto_inventory && environment(obj))
                obj = environment(obj);

        if( !obj ) return notify_fail("这个物件没有环境可以 goto。\n");

      if(!me->query("env/invisibility")) {
        if( stringp(msg = me->query("env/msg_mout")) ) {
           msg = replace_string(msg, "$BLK$", BLK);
           msg = replace_string(msg, "$RED$", RED);
           msg = replace_string(msg, "$GRN$", GRN);
           msg = replace_string(msg, "$YEL$", YEL);
           msg = replace_string(msg, "$BLU$", BLU);
           msg = replace_string(msg, "$MAG$", MAG);
           msg = replace_string(msg, "$CYN$", CYN);
           msg = replace_string(msg, "$WHT$", WHT);
           msg = replace_string(msg, "$HIR$", HIR);
           msg = replace_string(msg, "$HIG$", HIG);
           msg = replace_string(msg, "$HIY$", HIY);
           msg = replace_string(msg, "$HIB$", HIB);
           msg = replace_string(msg, "$HIM$", HIM);
           msg = replace_string(msg, "$HIC$", HIC);
           msg = replace_string(msg, "$HIW$", HIW);
           msg = replace_string(msg, "$NOR$", NOR);
           if (msg != "") message_vision(msg+NOR+"\n", me);
        }
        else
                message_vision("只见一阵烟雾过后,$N的身影已经不见了。\n", me);
      }

	if (ridee = me->ride())
        {
          ridemsg = ridee->query("ride/msg")+"着"+ridee->name();
	  ridee->move(obj);
	}  
	else
	  ridemsg = "";
        me->move(obj);

      if(!me->query("env/invisibility")) {
        if( stringp(msg = me->query("env/msg_min")) )
        {
           msg = replace_string(msg, "$BLK$", BLK);
           msg = replace_string(msg, "$RED$", RED);
           msg = replace_string(msg, "$GRN$", GRN);
           msg = replace_string(msg, "$YEL$", YEL);
           msg = replace_string(msg, "$BLU$", BLU);
           msg = replace_string(msg, "$MAG$", MAG);
           msg = replace_string(msg, "$CYN$", CYN);
           msg = replace_string(msg, "$WHT$", WHT);
           msg = replace_string(msg, "$HIR$", HIR);
           msg = replace_string(msg, "$HIG$", HIG);
           msg = replace_string(msg, "$HIY$", HIY);
           msg = replace_string(msg, "$HIB$", HIB);
           msg = replace_string(msg, "$HIM$", HIM);
           msg = replace_string(msg, "$HIC$", HIC);
           msg = replace_string(msg, "$HIW$", HIW);
           msg = replace_string(msg, "$NOR$", NOR);
           if (msg != "") message_vision(msg+NOR+"\n", me);
        }
        else
                message_vision("$N"+ridemsg+"突然出现在一阵烟雾之中。\n", me);
      }

        return 1;
}
Beispiel #10
0
void create()
{
    i3 = find_object(I3_CHDMOD);
    i3->add_service("error", "req_handler");
}
Beispiel #11
0
nomask void _F_sys_destruct()
{
	string oname;
	string creator;

	object this;
	object programd;

	int clone;
	int oindex;

	ACCESS_CHECK(KERNEL() || SYSTEM());

	this = this_object();
	oname = object_name(this);

	clone = !!sscanf(oname, "%*s#");

	if (!sscanf(oname, "%s#%d", oname, oindex)) {
		oindex = status(this, O_INDEX);
	}

	if (sscanf(oname, "%*s" + CLONABLE_SUBDIR) == 0 &&
		sscanf(oname, "%*s" + LIGHTWEIGHT_SUBDIR) == 0) {
		destruct();
	} else {
		destruct(clone);
	}

	creator = DRIVER->creator(oname);

	programd = find_object(PROGRAMD);

	if (programd) {
		object pinfo;
		string *dtors;
		string dtor;
		int i, sz;

		pinfo = PROGRAMD->query_program_info(
			status(this, O_INDEX)
		);

		if (pinfo) {
			dtor = pinfo->query_destructor();

			if (dtor) {
				call_other(this, dtor);
			}

			dtors = pinfo->query_inherited_destructors();

			for (sz = sizeof(dtors) - 1; sz >= 0; --sz) {
				call_other(this, dtors[i]);
			}
		}
	}

	set_object_name(nil);
	clear_list();
	TOUCHD->clear_patches(oindex);
}
Beispiel #12
0
		me->set("宿命B/黄山_佛光", 1+random(10));
		me->start_busy(4);
		call_out("bird", 2, me);
		return 1;
	}
	return 0;
}

void bird(object me) {
	object room;
	string target;
	int i;
	string *rooms = ({  AREA_HUANGSHAN"jiyu",
//	                    AREA_XINJIANG"sichou2",
//	                    AREA_QUICKSAND"desert3",
//	                    AREA_QUICKSAND"quicksand4",
	});
	message("vision", "\n穿过五彩光环,你向下坠去,耳边是呼呼的风声,眼前一片白雾,你什么都看不到。\n", me);
	message("vision", "你脑子里一片空白。\n", me);
	message("vision", "突然间,你的头顶传来急速的羽毛鼓动的声音,接着肩膀上传来一阵剧痛,\n", me);
	message("vision", "你感到下坠的趋势顿了一下。\n\n", me);
	i=sizeof(rooms);
	target = rooms[random(i)];
	room = find_object(target);
	if(!objectp(room))
		room= load_object(target);
	me->move(room);
    	me->unconcious();
	message("vision", "\n一只巨鸟从你掠过,一团黑乎乎的东西从空中落下。\n", environment(me),me);
}
Beispiel #13
0
static void create(varargs int clone) {
/* Initialise the reference to INTERMUD3_D. */
  intermud3_d = find_object(INTERMUD3_D);
}
Beispiel #14
0
  ret = "";

  if (!strlen(str))
  {
    tell_object(me, "Sintaxis: stats <nombre o id> <filtro-1 filtro-2 filtro-n>\n" + 
      "  Para mostrar todos los stats de un objeto\n" + 
      "  (o sólo aquellos cuyo nombre contenga algunas de las palabras de 'filtros')\n");
    return 1;
  }

  params = explode(str, " ");
  str = params[0];
  params -= ({ str });

  ob = find_object(str);

  if (!ob)
    ob = find_living(str);

  if (!ob && sizeof(find_match(str, me)))
    ob = find_match(str, me)[0];

  if (!ob && sizeof(find_match(str, environment(me))))
    ob = find_match(str, environment(me))[0];

  if (!ob)
  {
    tell_object(me, "No se ha podido encontrar el objeto o jugador '" + str + "'.\n");
    return 1;
  }
Beispiel #15
0
static void create()
{
    objectd_ = find_object(OBJECTD);
}
Beispiel #16
0
/*
 * NAME:	create()
 * DESCRIPTION:	initialize API
 */
static void create()
{
    accessd = find_object(ACCESSD);
}
Beispiel #17
0
void database::clear_expired_orders()
{
   detail::with_skip_flags( *this,
      get_node_properties().skip_flags | skip_authority_check, [&](){
         transaction_evaluation_state cancel_context(this);

         //Cancel expired limit orders
         auto& limit_index = get_index_type<limit_order_index>().indices().get<by_expiration>();
         while( !limit_index.empty() && limit_index.begin()->expiration <= head_block_time() )
         {
            limit_order_cancel_operation canceler;
            const limit_order_object& order = *limit_index.begin();
            canceler.fee_paying_account = order.seller;
            canceler.order = order.id;
            apply_operation(cancel_context, canceler);
         }
     });

   //Process expired force settlement orders
   auto& settlement_index = get_index_type<force_settlement_index>().indices().get<by_expiration>();
   if( !settlement_index.empty() )
   {
      asset_id_type current_asset = settlement_index.begin()->settlement_asset_id();
      asset max_settlement_volume;

      auto next_asset = [&current_asset, &settlement_index] {
         auto bound = settlement_index.upper_bound(current_asset);
         if( bound == settlement_index.end() )
            return false;
         current_asset = bound->settlement_asset_id();
         return true;
      };

      // At each iteration, we either consume the current order and remove it, or we move to the next asset
      for( auto itr = settlement_index.lower_bound(current_asset);
           itr != settlement_index.end();
           itr = settlement_index.lower_bound(current_asset) )
      {
         const force_settlement_object& order = *itr;
         auto order_id = order.id;
         current_asset = order.settlement_asset_id();
         const asset_object& mia_object = get(current_asset);
         const asset_bitasset_data_object mia = mia_object.bitasset_data(*this);

         // Has this order not reached its settlement date?
         if( order.settlement_date > head_block_time() )
         {
            if( next_asset() )
               continue;
            break;
         }
         // Can we still settle in this asset?
         if( mia.current_feed.settlement_price.is_null() )
         {
            ilog("Canceling a force settlement in ${asset} because settlement price is null",
                 ("asset", mia_object.symbol));
            cancel_order(order);
            continue;
         }
         if( max_settlement_volume.asset_id != current_asset )
            max_settlement_volume = mia_object.amount(mia.max_force_settlement_volume(mia_object.dynamic_data(*this).current_supply));
         if( mia.force_settled_volume >= max_settlement_volume.amount )
         {
            /*
            ilog("Skipping force settlement in ${asset}; settled ${settled_volume} / ${max_volume}",
                 ("asset", mia_object.symbol)("settlement_price_null",mia.current_feed.settlement_price.is_null())
                 ("settled_volume", mia.force_settled_volume)("max_volume", max_settlement_volume));
                 */
            if( next_asset() )
               continue;
            break;
         }

         auto& pays = order.balance;
         auto receives = (order.balance * mia.current_feed.settlement_price);
         receives.amount = (fc::uint128_t(receives.amount.value) *
                            (GRAPHENE_100_PERCENT - mia.options.force_settlement_offset_percent) / GRAPHENE_100_PERCENT).to_uint64();
         assert(receives <= order.balance * mia.current_feed.settlement_price);

         price settlement_price = pays / receives;

         auto& call_index = get_index_type<call_order_index>().indices().get<by_collateral>();
         asset settled = mia_object.amount(mia.force_settled_volume);
         // Match against the least collateralized short until the settlement is finished or we reach max settlements
         while( settled < max_settlement_volume && find_object(order_id) )
         {
            auto itr = call_index.lower_bound(boost::make_tuple(price::min(mia_object.bitasset_data(*this).options.short_backing_asset,
                                                                           mia_object.get_id())));
            // There should always be a call order, since asset exists!
            assert(itr != call_index.end() && itr->debt_type() == mia_object.get_id());
            asset max_settlement = max_settlement_volume - settled;
            settled += match(*itr, order, settlement_price, max_settlement);
         }
         modify(mia, [settled](asset_bitasset_data_object& b) {
            b.force_settled_volume = settled.amount;
         });
      }
   }
}
bool avsfilter::SetParameters(avsfilter_config *newparam)
{
  bool full_exact = false;
  DEBUG_PRINTF("avsfilter : SetParameters\n");

  // find corresponding loader/script
  WINE_LOADER *loader = find_object(order,
                                    (char*)newparam->avs_loader,
                                    (char*)newparam->avs_script,
                                    newparam->script_ctime, newparam->script_mtime,
                                    &info,
                                    &full_exact);
  // if loader not found
  if (!loader)
  {
    DEBUG_PRINTF("avsfilter : SetParameters no loader found\n");
    loader = new (WINE_LOADER);
    loader->avs_pipes[0].flags = O_RDONLY;
    loader->avs_pipes[1].flags = O_WRONLY;
    loader->avs_pipes[2].flags = O_WRONLY;
    loader->RefCounter = 0;
    loader->param.avs_script = NULL;
    loader->param.avs_loader = NULL;

    if (!wine_start((char*)newparam->wine_app, (char*)newparam->avs_loader, loader->avs_pipes, newparam->pipe_timeout))
    {
      DEBUG_PRINTF_RED("avsfilter : wine_start unsuccessful start!\n");
      delete loader;
      deref_wine_loader:
      if (wine_loader)
      {
        wine_loader->RefCounter--;
        wine_loader = NULL;
      }
      return false;
    }

    DEBUG_PRINTF("avsfilter : SetParameters success start wine\n");
    loader->order = order;
    add_object(loader);
  }

  // all parameters are NOT matched [order only]
  if (!full_exact)
  {
    DEBUG_PRINTF("avsfilter : SetParameters !full_exact\n");

    // matched only order (need reload with new script/geometry/etc)
    if (!avs_start(&info, &loader->output_info, (char*)newparam->avs_script, loader->avs_pipes))
    {
      DEBUG_PRINTF_RED("avsfilter : SetParameters fail avs_start\n");
      delete_object(loader);
      goto deref_wine_loader;
    }

    DEBUG_PRINTF("avsfilter : SetParameters avs_start ok\n");
    loader->RefCounter = 0;
    memcpy(&loader->input_info, &info, sizeof(info));
    loader->param.avs_loader = ADM_strdup ((char*)newparam->avs_loader);
    loader->param.avs_script = ADM_strdup ((char*)newparam->avs_script);
    loader->param.script_ctime = newparam->script_ctime; // store timestamp
    loader->param.script_mtime = newparam->script_mtime;
  }

  if (wine_loader && wine_loader != loader) wine_loader->RefCounter--;
  wine_loader = loader;
  wine_loader->RefCounter++;
  out_frame_sz = ((loader->output_info.width * loader->output_info.height) * 3) >>1;
  // 22.11 fix size of output filter with fullexact found loader
  info.width = loader->output_info.width;
  info.height = loader->output_info.height;
  info.frameIncrement = loader->output_info.frameIncrement;
  info.totalDuration = loader->output_info.totalDuration;
  /*  info.fps1000 = loader->output_info.fps1000;
  info.nb_frames = loader->output_info.nb_frames;
  info.orgFrame = loader->output_info.orgFrame;*/

/*   DEBUG_PRINTF("avsfilter : clip info : geom %d:%d fps1000 %d num_frames %d\n",
 info.width, info.height, info.fps1000, info.nb_frames);*/
  DEBUG_PRINTF("avsfilter : clip info : geom %d:%d frameIncrement %lu totalDuration %llu\n",
               info.width, info.height, info.frameIncrement, info.totalDuration);

  DEBUG_PRINTF("avsfilter : SetParameters return Ok\n");
  return true;
}
Beispiel #19
0
static void create()
{
    ::create();
    set_race(find_object(DWARF_RACE));
}
Beispiel #20
0
bool contains_object(const char *name) {
    return (find_object(name) != -1);
}
Beispiel #21
0
/*
 * NAME:	create()
 * DESCRIPTION:	initialize API
 */
static void create()
{
    driver = find_object(DRIVER);
}
Beispiel #22
0
static void create(void) {
  string mob_file;

  LOGD->write_syslog("**** Starting Test Game, "
		     + GAME_VERSION + " ****");

  /* GAME_PATH_SPECIAL should be compiled before any other object.  It
     changes the behavior of other objects because it sets their AUTO
     objects.  Rather than messing with all that nasty complexity,
     just compile this first so other objects in /usr/game always
     inherit from the same AUTO object(s). */
  if(!find_object(GAME_PATH_SPECIAL))
    compile_object(GAME_PATH_SPECIAL);
  CONFIGD->set_path_special_object(find_object(GAME_PATH_SPECIAL));

  /* Build game driver and set it */
  if(!find_object(GAME_DRIVER))
    compile_object(GAME_DRIVER);
  CONFIGD->set_game_driver(find_object(GAME_DRIVER));

  /* Find and compile the room registry *before* the first room is
     loaded.  Otherwise things will crash. */
  if(!find_object(GAME_ROOM_REGISTRY))
    compile_object(GAME_ROOM_REGISTRY);

  /* Load configuration for game driver */
  config_unq_file();

  /* Set up TagD */
  load_tagd();

  /* Tests a simple script */
  set_up_scripting();

  /* Register a help directory for the HelpD to use */
  HELPD->new_help_directory("/usr/game/help");

  /* Load the SoulD with social commands */
  load_sould();

  /* We have to load the custom room types before we read all the
     rooms into MAPD.  That way, rooms of custom types will
     successfully find the binder code that they need. */
  load_custom_rooms();

  compile_object(GAME_ROOM_BINDER);
  MAPD->set_binding_handler(find_object(GAME_ROOM_BINDER));

  /* Load stuff into MAPD and EXITD */
  if(read_object_dir(ROOM_DIR) >= 0) {
    EXITD->add_deferred_exits();
    MAPD->do_room_resolution(1);
  } else {
    LOGD->write_syslog("Can't read object files!  Starting incomplete!",
		       LOG_ERROR);
  }

  /* Load the mobilefile into MOBILED */
  mob_file = read_file(MOB_FILE);
  if(mob_file) {
    MOBILED->add_unq_text_mobiles(mob_file, MOB_FILE);
  } else {
    LOGD->write_syslog("Can't read mobile file!  Starting w/o mobiles!",
		       LOG_ERROR);
  }

  /* Set up heart_beat functions */
  if(!find_object(HEART_BEAT))
    compile_object(HEART_BEAT);
  HEART_BEAT->set_up_heart_beat();

  /* Support particular MUDclient protocols */
  MUDCLIENTD->protocol_allow("FIRECLIENT", 1);

  LOGD->write_syslog("Configured Phantasmal from /usr/game!");
}
Beispiel #23
0
int try_to_learn_ds()
{
    object me;
    object sob;
    int i;
    int flag;
    string *sub_skills;

    me = this_player();

    if (me->query("family/family_name") == query("family/family_name")
            && me->query("party/level") < 9)
    {
        command("say 你要学降龙十八掌?等你升到本帮长老再说吧!");
        return 1;
    }

    if (me->query("family/family_name") != query("family/family_name")
            && ! me->query("can_learn/hong/sub-xianglong-zhang"))
    {
        command("say 你是哪里来的?一边呆着去。");
        return 1;
    }

    if (me->query("shen") < 80000)
    {
        command("say 你的侠义正事还做得不够,我可不放心传你绝技。");
        return 1;
    }

    sob = find_object(SKILL_D("xianglong-zhang"));

    if (! sob)
        sob = load_object(SKILL_D("xianglong-zhang"));

//       if (! sob->valid_learn(me))
//               return 0;

    if (me->query_skill("xianglong-zhang", 1))
    {
        command("say 你不是已经会了么?自己好好练吧。");
        return 1;
    }

    if ((int)me->query("max_neili") < 3000)
    {
        command("say 你的内力太弱,还无法练降龙十八掌。");
        return 1;
    }
    if ((int)me->query("str") < 25)
    {
        command("say 你的先天膂力孱弱,难以修炼降龙十八掌。");
        return 1;
    }
    if ((int)me->query("con") < 20)
    {
        command("say 你的先天根骨孱弱,难以修炼降龙十八掌。");
        return 1;
    }
    if ((int)me->query_skill("strike", 1) < 180)
    {
        command("say 你的基本掌法火候不够,难以修炼降龙十八掌。");
        return 1;
    }

    sub_skills = keys(sob->query_sub_skills());

    flag = 0;
    for (i = 0; i < sizeof(sub_skills); i++)
    {
        if (me->query_skill(sub_skills[i], 1) >= 10)
            continue;

        me->set_skill(sub_skills[i], 10);

        if (! flag)
        {
            flag = 1;
            command("nod");
            command("say 我将十八路掌法传授与你,假以时"
                    "日,必能融会贯通。");
        }
        write(HIC "你对" + to_chinese(sub_skills[i]) + "有了"
              "一些领悟。\n" NOR);
    }

    if (! flag)
    {
        command("say 不是说了待到你融会贯通再来向我讨教吗?");
        return 1;
    }

    me->set("can_learn/hong/sub-xianglong-zhang",1);
    command("say 你先将这十八路掌法融会贯通,合而为一再说吧。");
    notify_fail("你自己下去好好练习吧。\n");
    return 1;
}
Beispiel #24
0
int main(void) {
    int errcode;
    size_t size;

    /* single module test */
    HilbertModule * module = hilbert_module_create(HILBERT_INTERFACE_MODULE);
    if (module == NULL) {
        fputs("Unable to create Hilbert interface module\n", stderr);
        exit(EXIT_FAILURE);
    }
    HilbertHandle kind = hilbert_kind_create(module, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to create kind1 (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    HilbertHandle vkind = hilbert_vkind_create(module, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to create kind2 (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    HilbertHandle var1 = hilbert_var_create(module, kind, &errcode);
    assert (errcode == 0);
    HilbertHandle var2 = hilbert_var_create(module, vkind, &errcode);
    assert (errcode == 0);
    HilbertHandle functor = hilbert_functor_create(module, kind, 0, NULL, &errcode);
    assert (errcode == 0);
    // FIXME: other types of objects...
    HilbertHandle * objects = hilbert_module_getobjects(module, &size, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to obtain module objects (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    if (size != 5) {
        fprintf(stderr, "Expected 5 objects in module, got %zu\n", size);
        exit(EXIT_FAILURE);
    }
    find_object(objects, 0, kind);
    find_object(objects, 1, vkind);
    find_object(objects, 2, var1);
    find_object(objects, 3, var2);
    find_object(objects, 4, functor);
    hilbert_harray_free(objects);
    hilbert_module_free(module);

    /* two module test */
    HilbertModule * module1 = hilbert_module_create(HILBERT_INTERFACE_MODULE);
    HilbertModule * module2 = hilbert_module_create(HILBERT_INTERFACE_MODULE);
    if ((module1 == NULL) || (module2 == NULL)) {
        fputs("Unable to create Hilbert interface modules\n", stderr);
        exit(EXIT_FAILURE);
    }
    HilbertHandle kind1 = hilbert_kind_create(module1, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to create kind1 in module1 (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    var1 = hilbert_var_create(module1, kind1, &errcode);
    assert (errcode == 0);
    HilbertHandle kind2 = hilbert_kind_create(module2, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to create kind2 in module2 (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    var2 = hilbert_var_create(module2, kind2, &errcode);
    assert (errcode == 0);
    errcode = hilbert_module_makeimmutable(module1);
    if (errcode != 0) {
        fprintf(stderr, "Unable to make module1 immutable (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    HilbertHandle param = hilbert_module_param(module2, module1, 0, NULL, NULL, NULL, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to parameterise module2 with module1 (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    HilbertHandle kind3 = hilbert_kind_create(module2, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to create kind3 in module2 (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    objects = hilbert_module_getobjects(module2, &size, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to obtain object array from module2 (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    if (size != 5) {
        fprintf(stderr, "Expected 5 objects in module2, got %zu\n", size);
        exit(EXIT_FAILURE);
    }
    find_object(objects, 0, kind2);
    find_object(objects, 1, var2);
    find_object(objects, 4, kind3);
    HilbertHandle destkind;
    if (objects[2] == param) {
        destkind = objects[3];
    } else if (objects[3] == param) {
        destkind = objects[2];
    } else {
        fprintf(stderr, "Parameter %u not found in {%u, %u}\n", (unsigned int) param,
                (unsigned int) objects[2], (unsigned int) objects[3]);
        exit(EXIT_FAILURE);
    }
    HilbertHandle srckind = hilbert_object_getsourcehandle(module2, destkind, &errcode);
    if (errcode != 0) {
        fprintf(stderr, "Unable to obtain source kind handle for kind1 (errcode=%d)\n", errcode);
        exit(EXIT_FAILURE);
    }
    if (srckind != kind1) {
        fprintf(stderr, "Got wrong source kind (expected=%u, got=%u)\n",
                (unsigned int) kind1, (unsigned int) srckind);
        exit(EXIT_FAILURE);
    }
    hilbert_harray_free(objects);
    hilbert_module_free(module1);
    hilbert_module_free(module2);
}
Beispiel #25
0
    std::shared_ptr<Instantiation<Impl>>
    Module_scanner<Impl>::create_instantiation(ast::Module_instantiation const& node) {
      std::shared_ptr<Instantiation<Impl>> inst(new Instantiation<Impl>);
      std::string module_name;

      inst->name = dynamic_cast<ast::Identifier const&>(node.instance_name()).identifier();
      if( m_mod.instantiations.count(inst->name) > 0 )
        throw std::runtime_error(std::string("Instantiation with name ")
            + inst->name
            + std::string(" already exists"));

      if( node.is_template_instantiation() ) {
        LOG4CXX_TRACE(Namespace_scanner<Impl>::m_logger, "instantiating module template");
        // extract name
        auto tmpl_id = node.template_identifier();
        std::vector<Label> qname = tmpl_id.name();
        std::string qname_join = boost::algorithm::join(qname, "::");

        // find template
        std::shared_ptr<Module_template<Impl>> tmpl;
        if( qname.size() > 1 ) {
          tmpl = find_by_path(m_mod,
              &Module<Impl>::module_templates,
              qname);
        } else {
          tmpl = find_module_template(m_mod, qname[0]);
        }

        if( !tmpl ) {
          std::stringstream strm;
          strm << "Can not find module template with name '"
            << qname_join
            << "'";
          throw std::runtime_error(strm.str());
        }

        // determine module name and type overrides
        module_name = qname_join + '<';
        auto type_names = tmpl_id.arg_type_names();
        std::map<Label,std::shared_ptr<Type<Impl>>> types;
        auto it_placeholder = tmpl->type_names.begin();
        for(auto it=type_names.begin();
            (it != type_names.end()) && (it_placeholder != tmpl->type_names.end()); ) {
          // find type
          auto ty = find_type(m_mod, *it);
          if( !ty ) {
            std::stringstream strm;
            strm << node.location() << ": "
              << "failed to find type '"
              << *it
              << "' in instantiation of template '"
              << qname_join
              << "'";
            throw std::runtime_error(strm.str());
          }
          types[*it_placeholder] = ty;

          // append name
          module_name += *it;
          if( ++it != type_names.end() )
            module_name += ',';
          ++it_placeholder;
        }
        module_name += '>';

        // run Module_scanner
        inst->module = this->instantiate_module_template(module_name,
            tmpl->module_node,
          types);
    } else {
      if( typeid(node.module_name()) == typeid(ast::Qualified_name) ) {
        auto const& qn = dynamic_cast<ast::Qualified_name const&>(node.module_name()).name();
        if( qn.size() > 1 ) {
          inst->module = find_by_path(m_mod,
              &Module<Impl>::modules,
              qn);
        } else {
          inst->module = find_module(m_mod, qn[0]);
        }
      } else {
        std::stringstream strm;
        strm << node.location()
          << "Expecting a qualified name as module for now ("
          << __func__
          << ")";
        throw std::runtime_error(strm.str());
      }
    }

    if( !inst->module ) {
      std::stringstream strm;
      strm << node.location();
      strm << ": module '" << module_name << "' not found.";
      throw std::runtime_error(strm.str());
    }

    std::set<Label> matched_ports;
    for(auto& i : node.connection_items()) {
      if( typeid(*i) == typeid(ast::Connection_item) ) {
        auto& con_item = dynamic_cast<ast::Connection_item const&>(*i);
        auto port_name = con_item.port_name().identifier();
        //auto signal_name = con_item.signal_name().identifier();

        if( matched_ports.count(port_name) > 0 ) {
          std::stringstream strm;
          strm << con_item.port_name().location();
          strm << ": Port already connected";
          throw std::runtime_error(strm.str());
        }

        std::shared_ptr<Port_assignment<Impl>> port_assign(new Port_assignment<Impl>());
        port_assign->port = find_port(*(inst->module), port_name);
        if( !port_assign->port ) {
          std::stringstream strm;
          strm << con_item.port_name().location();
          strm << ": port '" << port_name << "' not found.";
          throw std::runtime_error(strm.str());
        }

        //port_assign->object = find_object(m_mod, signal_name);
        //if( !port_assign->object ) {
          //std::stringstream strm;
          //strm << con_item.signal_name().location();
          //strm << ": assigned object '" << signal_name << "' not found.";
          //throw std::runtime_error(strm.str());
        //}

        //if( !type_compatible(*(port_assign->port->type), *(port_assign->object->type)) ) {
          //std::stringstream strm;
          //strm << con_item.location();
          //strm << ": incompatible types in port assignment: expected type '"
            //<< *(port_assign->port->type)
            //<< "' got '"
            //<< *(port_assign->object->type) << "'";
          //throw std::runtime_error(strm.str());
        //}

        inst->connection.push_back(port_assign);
        matched_ports.insert(port_name);
      } else if( typeid(*i) == typeid(ast::Identifier) ) {
        auto& obj_name = dynamic_cast<ast::Identifier const&>(*i).identifier();
        auto assignee = find_object(m_mod, obj_name);

        if( !assignee ) {
          std::stringstream strm;
          strm << i->location()
            << ": object '" << obj_name << "' not found";
          throw std::runtime_error(strm.str());
        }

        auto assignee_socket = find_socket(m_mod, assignee->type->name);
        if( !assignee_socket ) {
          std::stringstream strm;
          strm << i->location()
            << ": object '" << obj_name << "' of type '" << assignee->type->name
            << "' is not a socket";
          throw std::runtime_error(strm.str());
        }

        for(auto assignee_port_pair : assignee_socket->elements) {
          auto port_name = assignee_port_pair.first;
          auto assignee_port = assignee_port_pair.second;
          auto searchit = assignee->type->elements.find(port_name);
          if( searchit != assignee->type->elements.end() ) {
            auto it = searchit->second;
            if( !type_compatible(*(it->type), *(assignee_port->type)) ) {
              std::stringstream strm;
              strm << i->location()
                << ": name match for port '" << port_name << "'"
                << " but no type match (expected: "
                << *(it->type)
                << ", got: "
                << *(assignee_port->type)
                << ")";
              throw std::runtime_error(strm.str());
            }

            if( matched_ports.count(assignee_port->name) > 0 ) {
              std::stringstream strm;
              strm << i->location()
                << ": port '" << assignee_port->name << "' already matched";
              throw std::runtime_error(strm.str());
            }

            std::shared_ptr<Port_assignment<Impl>> port_assign(new Port_assignment<Impl>);
            port_assign->port = it;
            // XXX assign object to element of composite type socket
            inst->connection.push_back(port_assign);
            matched_ports.insert(assignee_port->name);
          }
        }
      } else
        throw std::runtime_error("connection items should be either a list or a single identifier");
    }
    m_mod.instantiations[inst->name] = inst;

    auto obj = std::make_shared<Object<Impl>>();
    obj->name = inst->name;
    obj->type = inst->module->socket;

    m_mod.objects[obj->name] = obj;

    return inst;
  }
Beispiel #26
0
/** A highly unusual function that lets you generate and execute a snippet of code
 * that will execute. Just pass in the snippet. Warning: This can't handle recursive
 * calls; the old call will be trashed by the new.
 *
 * \return The return value of the call, converted to a string.
 */
string exec_call(string code) {
   string buf;
   string obj, func, func_name, err;
   mixed param, ret;
   string fname;

   if( !this_player() )
      raise_error("exec_call must have a valid this_player() using it");

   fname = this_player()->make_path_absolute( EXEC_OBJ );

   if( ret = find_object(fname) ) destruct(ret);
   if( file_exists(fname + ".c") && !rm( fname + ".c" ) )
      return "Unable to clear out the old "+fname+" to execute the call (uid="+getuid(this_object())+").";

   buf = HEADER + EXEC_MACROS + "\ndo_call() {\n";

   if( sscanf(code, "%s->%s", obj, func) == 2 ) {
      func_name = func;
      if( sscanf(func, "%~s(%~s)") != 2 ) {
         code = func;
         if( sscanf( code, "%s %d", func, param) == 2)
            func = (func_name = func) + "( " + param + " );";
         else
         if( sscanf( code, "%s %s", func, param) == 2)
            func = (func_name = func) + "( \"" + param + "\" );";
         else
            func = (func_name = code) + "();";
      }
      else sscanf( func_name, "%s(%~s)", func_name );
   }
   else if( sscanf(code, "%s %s(%s)%~s", obj, func, param) == 4 && member(func, ' ') < 0 )
      func = (func_name = func) + "( " + param +" );";
   else if( sscanf(code, "%s %s %d", obj, func, param) == 3 )
      func = (func_name = func) + "( " + param + " );";
   else if( sscanf(code, "%s %s %s", obj, func, param) == 3 )
      func = (func_name = func) + "( \"" + param + "\" );";
   else if( sscanf(code, "%s %s", obj, func) == 2 )
      func = (func_name = func) + "();";
   else raise_error("Ill formatted exec_call");

   if( !find_thing(obj) ) return "No such object: "+obj;
   if( !function_exists(func_name, find_thing(obj)) && !function_exists("catch_call", find_thing(obj)) )
      return "No such function: "+obj+"->"+func_name+"()";

//   if( sscanf(func, "%s(%s)%s", ret, ret, ret) != 3 ) func += "();";

   if( func[<1] != ';' ) func += ";";
   buf += "   object ob;\n";
   buf += "   ob = find_thing(\""+obj+"\");\n";
   buf += "   if( !ob ) return \"Could not find object "+obj+"!\";\n";
   buf += "   return ob->"+func+"\n}\n";

   write_file( fname + ".c", buf );
   err = catch(ret = load_object( fname ));
   if( err ) {
      msg("==> [Call Error] "+err);
      return "<Invalid>";
   }

   seteuid( getuid(this_player()) );
   export_uid( ret );
   seteuid( getuid(this_object()) );
   err = catch(ret = fname->do_call());
   if( err ) {
      msg("==> [Call Runtime Error] "+err);
      return "<Invalid>";
   }

   return as_lpc(ret);
}