예제 #1
0
파일: exception.c 프로젝트: vargaz/mono
void
mono_invoke_unhandled_exception_hook (MonoObject *exc)
{
	if (unhandled_exception_hook) {
		unhandled_exception_hook (exc, unhandled_exception_hook_data);
	} else {
		ERROR_DECL (inner_error);
		MonoObject *other = NULL;
		MonoString *str = mono_object_try_to_string (exc, &other, inner_error);
		char *msg = NULL;
		
		if (str && is_ok (inner_error)) {
			msg = mono_string_to_utf8_checked_internal (str, inner_error);
			if (!is_ok (inner_error)) {
				msg = g_strdup_printf ("Nested exception while formatting original exception");
				mono_error_cleanup (inner_error);
			}
		} else if (other) {
			char *original_backtrace = mono_exception_get_managed_backtrace ((MonoException*)exc);
			char *nested_backtrace = mono_exception_get_managed_backtrace ((MonoException*)other);

			msg = g_strdup_printf ("Nested exception detected.\nOriginal Exception: %s\nNested exception:%s\n",
				original_backtrace, nested_backtrace);

			g_free (original_backtrace);
			g_free (nested_backtrace);
		} else {
			msg = g_strdup ("Nested exception trying to figure out what went wrong");
		}
		mono_runtime_printf_err ("[ERROR] FATAL UNHANDLED EXCEPTION: %s", msg);
		g_free (msg);
#if defined(HOST_IOS)
		g_assertion_message ("Terminating runtime due to unhandled exception");
#else
		exit (mono_environment_exitcode_get ());
#endif
	}

	g_assert_not_reached ();
}
예제 #2
0
/* http://www.dotnet247.com/247reference/msgs/39/195403.aspx
// internal static string[] WindowsIdentity._GetRoles (IntPtr token)
*/
MonoArray*
ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token) 
{
	MonoError error;
	MonoArray *array = NULL;
	MonoDomain *domain = mono_domain_get (); 
#ifdef HOST_WIN32
	gint32 size = 0;

	GetTokenInformation (token, TokenGroups, NULL, size, (PDWORD)&size);
	if (size > 0) {
		TOKEN_GROUPS *tg = g_malloc0 (size);
		if (GetTokenInformation (token, TokenGroups, tg, size, (PDWORD)&size)) {
			int i=0;
			int num = tg->GroupCount;

			array = mono_array_new_checked (domain, mono_get_string_class (), num, &error);
			if (mono_error_set_pending_exception (&error)) {
				g_free (tg);
				return NULL;
			}

			for (i=0; i < num; i++) {
				gint32 size = 0;
				gunichar2 *uniname = GetSidName (NULL, tg->Groups [i].Sid, &size);

				if (uniname) {
					MonoString *str = mono_string_new_utf16_checked (domain, uniname, size, &error);
					if (!is_ok (&error)) {
						g_free (uniname);
						g_free (tg);
						mono_error_set_pending_exception (&error);
						return NULL;
					}
					mono_array_setref (array, i, str);
					g_free (uniname);
				}
			}
		}
		g_free (tg);
	}
#else
	/* POSIX-compliant systems should use IsMemberOfGroupId or IsMemberOfGroupName */
	g_warning ("WindowsIdentity._GetRoles should never be called on POSIX");
#endif
	if (!array) {
		/* return empty array of string, i.e. string [0] */
		array = mono_array_new_checked (domain, mono_get_string_class (), 0, &error);
		mono_error_set_pending_exception (&error);
	}
	return array;
}
예제 #3
0
파일: actions.cpp 프로젝트: CIB/wesnoth
void move_result::do_execute()
{
	LOG_AI_ACTIONS << "start of execution of: "<< *this << std::endl;
	assert(is_success());

	move_spectator_.set_unit(resources::units->find(from_));

	if (from_ != to_) {
		size_t num_steps = ::actions::move_unit_and_record(
			/*std::vector<map_location> steps*/ route_->steps,
			/*::actions::undo_list* undo_stack*/ NULL,
			/*bool continue_move*/ true, ///@todo 1.9 set to false after implemeting interrupt awareness
			/*bool show_move*/ preferences::show_ai_moves(),
			/*bool* interrupted*/ NULL,
			/*::actions::move_unit_spectator* move_spectator*/ &move_spectator_);

		if ( num_steps > 0 ) {
			set_gamestate_changed();
		} else if ( move_spectator_.get_ambusher().valid() ) {
			// Unlikely, but some types of strange WML (or bad pathfinding)
			// could cause an ambusher to be found without moving.
			set_gamestate_changed();
		}
	} else {
		assert(remove_movement_);
	}

	if (move_spectator_.get_unit().valid()){
		unit_location_ = move_spectator_.get_unit()->get_location();
		if (remove_movement_ && move_spectator_.get_unit()->movement_left() > 0 && unit_location_ == to_)
		{
			stopunit_result_ptr stopunit_res = actions::execute_stopunit_action(get_side(),true,unit_location_,true,false);
			if (!stopunit_res->is_ok()) {
				set_error(stopunit_res->get_status());
			}
			if (stopunit_res->is_gamestate_changed()) {
				set_gamestate_changed();
			}
		}
	} else {
		unit_location_ = map_location();
	}

	if (is_gamestate_changed()) {
		try {
			manager::raise_gamestate_changed();
		} catch (...) {
			is_ok(); //Silences "unchecked result" warning
			throw;
		}
	}
}
예제 #4
0
파일: c_.cpp 프로젝트: wintowanti/ICPC_fun
int binary(int l,int r){
    int tmin=-1;
    while(l<=r){
        int mid=(l+r)>>1;
//        printf("%d~~",mid);
        if(is_ok(mid)){
            tmin=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    return tmin;
}
예제 #5
0
파일: exception.c 프로젝트: vargaz/mono
/**
 * mono_get_exception_type_initialization:
 * \param type_name the name of the type that failed to initialize.
 * \param inner the inner exception.
 * \returns a new instance of the \c System.TypeInitializationException
 */
MonoException *
mono_get_exception_type_initialization (const gchar *type_name, MonoException* inner_raw)
{
	HANDLE_FUNCTION_ENTER ();
	MONO_HANDLE_DCL (MonoException, inner);
	ERROR_DECL (error);
	MonoExceptionHandle ret = mono_get_exception_type_initialization_handle (type_name, inner, error);
	if (!is_ok (error)) {
		ret = MONO_HANDLE_CAST (MonoException, mono_new_null ());
		mono_error_cleanup (error);
	}
	HANDLE_FUNCTION_RETURN_OBJ (ret);
}
예제 #6
0
파일: exception.c 프로젝트: vargaz/mono
/**
 * mono_get_exception_runtime_wrapped:
 */
MonoException *
mono_get_exception_runtime_wrapped (MonoObject *wrapped_exception_raw)
{
	HANDLE_FUNCTION_ENTER ();
	ERROR_DECL (error);
	MONO_HANDLE_DCL (MonoObject, wrapped_exception);
	MonoExceptionHandle ret = mono_get_exception_runtime_wrapped_handle (wrapped_exception, error);
	if (!is_ok (error)) {
		mono_error_cleanup (error);
		ret = MONO_HANDLE_CAST (MonoException, mono_new_null ());
	}
	HANDLE_FUNCTION_RETURN_OBJ (ret);
}
예제 #7
0
파일: exception.c 프로젝트: vargaz/mono
/**
 * mono_get_exception_reflection_type_load:
 * \param types an array of types that were defined in the moduled loaded.
 * \param exceptions an array of exceptions that were thrown during the type loading.
 * \returns a new instance of the \c System.Reflection.ReflectionTypeLoadException
 */
MonoException *
mono_get_exception_reflection_type_load (MonoArray *types_raw, MonoArray *exceptions_raw)
{
	HANDLE_FUNCTION_ENTER ();
	ERROR_DECL (error);
	MONO_HANDLE_DCL (MonoArray, types);
	MONO_HANDLE_DCL (MonoArray, exceptions);
	MonoExceptionHandle ret = mono_get_exception_reflection_type_load_checked (types, exceptions, error);
	if (!is_ok (error))
		ret = MONO_HANDLE_CAST (MonoException, mono_new_null ());
	mono_error_cleanup (error);
	HANDLE_FUNCTION_RETURN_OBJ (ret);
}
예제 #8
0
파일: shop.c 프로젝트: rparet/darkpawns
void
shopping_list(char *arg, struct char_data *ch,
          struct char_data * keeper, int shop_nr)
{
  char buf[MAX_STRING_LENGTH], name[MAX_INPUT_LENGTH];
  struct obj_data *obj, *last_obj = 0;
  int cnt = 0, index = 0;
  bool found = FALSE;

  if (!(is_ok(keeper, ch, shop_nr)))
    return;

  if (SHOP_SORT(shop_nr) < IS_CARRYING_N(keeper))
    sort_keeper_objs(keeper, shop_nr);

  one_argument(arg, name);
  strcpy(buf, " ##   Available   Item                                               Cost\n\r");
  strcat(buf, "-------------------------------------------------------------------------\n\r");
  if (keeper->carrying)
    for (obj = keeper->carrying; obj; obj = obj->next_content)
      if (CAN_SEE_OBJ(ch, obj) && (obj->obj_flags.cost > 0))
    {
      if (!last_obj)
        {
          last_obj = obj;
          cnt = 1;
        }
      else if (same_obj(last_obj, obj))
        cnt++;
      else {
        index++;
        if (!(*name) || isname(name, last_obj->name))
            {
          strcat(buf, list_object(ch, last_obj, cnt, index, shop_nr));
              found = TRUE;
            }
        cnt = 1;
        last_obj = obj;
      }
    }
  index++;
  if (!last_obj)
    stc("Currently, there is nothing for sale.\r\n", ch);
  else if (*name && !found)
    stc("Presently, none of those are for sale.\r\n", ch);
  else {
    if (!(*name) || isname(name, last_obj->name))
      strcat(buf, list_object(ch, last_obj, cnt, index, shop_nr));
   page_string(ch->desc, buf, 1);
  }
}
예제 #9
0
int process(char **args) {
    int return_val = 0;
    
    if (args[0] == NULL) {
        return_val = 0;
    } else if (is_control(args[0])) {
        return_val = do_control(args);
    } else if (is_ok()) {
        if (!internal(args, &return_val)) {
            return_val = execute(args);
        }
    }
    return return_val;
}
예제 #10
0
 bool dfs (vector <vector<char> >& maze, int r, int c){
     if (c == 9) return dfs (maze, r+1, 0);
     if (r == 9) return true;
     if (maze[r][c] != '.')  return dfs (maze, r,c +1);
     
     for (int i=1;i<=9;i++){
         if (is_ok (r,c,i)){
             maze[r][c] = i + '0';
             if (dfs (maze, r,c+1))  return true;
             er[r][i-1] = ec[c][i-1] = eb[r/3][c/3][i-1] = false;
         }
     }
     maze[r][c] = '.';
     return false;
 }
예제 #11
0
 virtual bool wait_ready()
 {
     bool rtn = is_ok();
     if ( rtn )
     {
         if ( !ready )
         {
             _error_code = pthread_mutex_lock( &ready_mutex );
             ready = true;
             rtn = ready;
             _error_code = pthread_mutex_unlock( &ready_mutex );
         }
     }
     return rtn;
 }
예제 #12
0
파일: exception.c 프로젝트: vargaz/mono
// For efficiency, call mono_error_set_pending_exception instead of mono_error_set_pending_exception_slow.
gboolean
mono_error_set_pending_exception_slow (MonoError *error)
{
	if (is_ok (error))
		return FALSE;

	HANDLE_FUNCTION_ENTER ();

	MonoExceptionHandle ex = mono_error_convert_to_exception_handle (error);
	gboolean const result = !MONO_HANDLE_IS_NULL (ex);
	if (result)
		mono_set_pending_exception_handle (ex);

	HANDLE_FUNCTION_RETURN_VAL (result);
}
예제 #13
0
파일: bus.hpp 프로젝트: GamovCoder/theCore
err generic_bus< PBus >::init()
{
    if (m_state & bus_inited) {
        return err::ok;
    }

    m_bus.set_handler(platform_handler);

    auto rc = m_bus.init();

    if (is_ok(rc)) {
        m_state |= bus_inited;
    }

    return rc;
}
예제 #14
0
파일: coil.c 프로젝트: whqcnn/learning
int up_1(int mm[][X], int x, int y, int k, const char *board)
{
    int i, j;
    int n = 0;
    int _mm[Y][X];
    for (i = 0; i < Y; i++)
    {
        for (j = 0; j < X; j++)
        {
            _mm[i][j] = mm[i][j];
        }
    }

    for (x = (x-1); is_ok(x, y, board) && _mm[x][y] != 1; --x)
    {
        _mm[x][y] = 1;
        ++k;
    }
    x++;

    if (k == sum)
    {
        strcat(path, "U");
        return 1;
    }

    if ((y-1) >= 0 && board[x][y-1] != 'X' && _mm[x][y-1] != 1)
    {
        n = (left(_mm, x, y, k));
        if (n == 1)
        {
            strcat(path, "U");
            return 1;
        }
    }
    if ((y+1) < X && board[x][y+1] != 'X' && _mm[x][y+1] != 1)
    {
        n = (right(_mm, x, y, k));
        if (n == 1)
        {
            strcat(path, "U");
            return 1;
        }
    }

    return 0;
}
예제 #15
0
/* This is an icall */
void *
mono_mmap_open_file (MonoString *path, int mode, MonoString *mapName, gint64 *capacity, int access, int options, int *ioerror)
{
	MonoError error;
	MmapHandle *handle = NULL;
	g_assert (path || mapName);

	if (!mapName) {
		char * c_path = mono_string_to_utf8_checked (path, &error);
		if (mono_error_set_pending_exception (&error))
			return NULL;
		handle = open_file_map (c_path, -1, mode, capacity, access, options, ioerror);
		g_free (c_path);
		return handle;
	}

	char *c_mapName = mono_string_to_utf8_checked (mapName, &error);
	if (mono_error_set_pending_exception (&error))
		return NULL;

	if (path) {
		named_regions_lock ();
		handle = (MmapHandle*)g_hash_table_lookup (named_regions, c_mapName);
		if (handle) {
			*ioerror = FILE_ALREADY_EXISTS;
			handle = NULL;
		} else {
			char *c_path = mono_string_to_utf8_checked (path, &error);
			if (is_ok (&error)) {
				handle = (MmapHandle *)open_file_map (c_path, -1, mode, capacity, access, options, ioerror);
				if (handle) {
					handle->name = g_strdup (c_mapName);
					g_hash_table_insert (named_regions, handle->name, handle);
				}
			} else {
				handle = NULL;
			}
			g_free (c_path);
		}
		named_regions_unlock ();
	} else
		handle = open_memory_map (c_mapName, mode, capacity, access, options, ioerror);

	g_free (c_mapName);
	return handle;
}
예제 #16
0
void action_result::execute()
{
	is_execution_ = true;
	init_for_execution();
	check_before();
	if (is_success()){
		try {
			do_execute();
		} catch (return_to_play_side_exception&) {
			if (!is_ok()) { DBG_AI_ACTIONS << "Return value of AI ACTION was not checked." << std::endl; } //Demotes to DBG "unchecked result" warning
			throw;
		}
	}
	if (is_success()){
		check_after();
	}
	is_execution_ = false;
}
void cps_db::response::dump() {
    std::cout << "Resp type is : " << static_cast<redisReply*>(_reply)->type << std::endl;

    if(is_int()) {
        std::cout << "Int : " << get_int() << std::endl;
    }
    if (is_ok()) std::cout << "OK Resp..." << std::endl;

    if (is_str()) {
        std::cout << get_str() << std::endl;
    }
    if (has_elements()) {
        for (size_t ix =0,mx=this->elements(); ix < mx ; ++ix ) {
            redisReply * data = (redisReply *)this->element_at(ix);
            std::cout << "IX:" << ix << " Type:" << data->type << " " << cps_string::tostring(data->str,data->len) << std::endl;
        }
    }
}
예제 #18
0
int main()
{
	int i;
	init();
	if(is_ok(st) == 0)
	{
		printf("unsolvable\n");
		return 0;
	}
	found = 0;
	while(found == 0)
	{
		top = 0;
		ida_star(st, 0, max_deep);
		max_deep++;
	}
	return 0;
}
예제 #19
0
void shopping_list( char *arg, struct char_data *ch,
	 struct char_data *keeper, int shop_nr)
{
	char buf[MAX_STRING_LENGTH], buf2[100],buf3[100];
	struct obj_data *temp1;
	extern char *drinks[];
	int found_obj;

	if(!(is_ok(keeper,ch,shop_nr)))
		return;

	strcpy(buf,"You can buy:\n\r");
	found_obj = FALSE;
		if(keeper->carrying)
	for(temp1=keeper->carrying;
		temp1; 
		temp1 = temp1->next_content)
			if((CAN_SEE_OBJ(ch,temp1)) && (temp1->obj_flags.cost>0))
		{
			found_obj = TRUE; 
			if(temp1->obj_flags.type_flag != ITEM_DRINKCON) 
				sprintf(buf2,"%s for %d gold coins.\n\r"
				,(temp1->short_description)
				,(int)(temp1->obj_flags.cost*
				shop_index[shop_nr].profit_buy));
			else {
				if (temp1->obj_flags.value[1])
					sprintf(buf3,"%s of %s",(temp1->short_description)
					,drinks[temp1->obj_flags.value[2]]);
				else
					sprintf(buf3,"%s",(temp1->short_description));
				sprintf(buf2,"%s for %d gold coins.\n\r",buf3,
				(int)(temp1->obj_flags.cost*shop_index[shop_nr].profit_buy));
			}
			strcat(buf,CAP(buf2));
		};

	if(!found_obj)
		strcat(buf,"Nothing!\n\r");

	send_to_char(buf,ch);
	return;
}
예제 #20
0
void shopping_value( char *arg, struct char_data *ch, 
	struct char_data *keeper, int shop_nr)
{
	char argm[100], buf[MAX_STRING_LENGTH];
	struct obj_data *temp1;

	if(!(is_ok(keeper,ch,shop_nr)))
		return;

	one_argument(arg, argm);

	if(!(*argm))
	{
		sprintf(buf,"%s What do you want me to valuate??",
			GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying)))
	{
		sprintf(buf,shop_index[shop_nr].no_such_item2,
			GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(!(trade_with(temp1,shop_nr)))
	{
		sprintf(buf,
		shop_index[shop_nr].do_not_buy,
		GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	sprintf(buf,"%s I'll give you %d gold coins for that!",
		GET_NAME(ch),(int) (temp1->obj_flags.cost*
			shop_index[shop_nr].profit_sell));
	do_tell(keeper,buf,19);

	return;
}
예제 #21
0
파일: actions.cpp 프로젝트: CIB/wesnoth
void attack_result::do_execute()
{
	LOG_AI_ACTIONS << "start of execution of: "<< *this << std::endl;
	// Stop the user from issuing any commands while the unit is attacking
	const events::command_disabler disable_commands;
	//@note: yes, this is a decision done here. It's that way because we want to allow a simpler attack 'with whatever weapon is considered best', and because we want to allow the defender to pick it's weapon. That's why aggression is needed. a cleaner solution is needed.
	battle_context bc(*resources::units, attacker_loc_,
		defender_loc_, attacker_weapon_, -1, aggression_);

	int attacker_weapon = bc.get_attacker_stats().attack_num;
	int defender_weapon = bc.get_defender_stats().attack_num;

	if(attacker_weapon < 0) {
		set_error(E_UNABLE_TO_CHOOSE_ATTACKER_WEAPON);
		return;
	}

	const unit_map::const_iterator a_ = resources::units->find(attacker_loc_);
	const unit_map::const_iterator d_ = resources::units->find(defender_loc_);
	//to get rid of an unused member varuiable warning, FIXME: find a way to 'ask' the ai wich advancement should be chosen from synced_commands.cpp .
	if(true) //RAII block for set_scontext_synced
	{
		//we don't use synced_context::run_in_synced_context because that wouldn't allow us to pass advancements_
		recorder.add_synced_command("attack", replay_helper::get_attack(attacker_loc_, defender_loc_, attacker_weapon, defender_weapon, a_->type_id(),
			d_->type_id(), a_->level(), d_->level(), resources::tod_manager->turn(),
			resources::tod_manager->get_time_of_day()));
		set_scontext_synced sync;
		attack_unit_and_advance(attacker_loc_, defender_loc_, attacker_weapon, defender_weapon, true, advancements_);
	}
	

	set_gamestate_changed();
	//start of ugly hack. @todo 1.9 rework that via extended event system
	//until event system is reworked, we note the attack this way
	get_info().recent_attacks.insert(defender_loc_);
	//end of ugly hack
	try {
		manager::raise_gamestate_changed();
	} catch (...) {
		is_ok(); //Silences "unchecked result" warning
		throw;
	}
}
예제 #22
0
void action_result::execute()
{
	is_execution_ = true;
	init_for_execution();
	check_before();
	if (is_success()){
		do_execute();
		try {
			resources::controller->check_victory();
		} catch (...) {
			is_ok(); //Silences "unchecked result" warning
			throw;
		}
	}
	if (is_success()){
		check_after();
	}
	is_execution_ = false;
}
예제 #23
0
void recall_result::do_execute()
{
	LOG_AI_ACTIONS << "start of execution of: " << *this << std::endl;
	assert(is_success());

	game_info& info = get_info();
	team& my_team = get_my_team(info);

	const events::command_disabler disable_commands;

	std::vector<unit>::iterator rec = std::find_if(my_team.recall_list().begin(), my_team.recall_list().end(), boost::bind(&unit::matches_id, _1, unit_id_));

	assert(rec != my_team.recall_list().end());

	const std::string &err = find_recruit_location(get_side(), recall_location_);
	if(!err.empty()) {
		set_error(AI_ACTION_FAILURE);
		return;
	} else {

		unit &un = *rec;
		recorder.add_recall(un.id(), recall_location_);
		un.set_game_context(&info.units);
		place_recruit(un, recall_location_, true, true);
		statistics::recall_unit(un);
		my_team.spend_gold(game_config::recall_cost);

		my_team.recall_list().erase(rec);
		if (resources::screen!=NULL) {
			resources::screen->invalidate_game_status();
			resources::screen->invalidate_all();
		}
		recorder.add_checksum_check(recall_location_);
		set_gamestate_changed();
		try {
			manager::raise_gamestate_changed();
		} catch (...) {
			is_ok(); //Silences "unchecked result" warning
			throw;
		}
	}

}
예제 #24
0
Error my_stack_dtor(Stack_t* stack)
{
    Error *err_temp = NULL;
    err_temp = my_error_ctor(err_temp);
    if (is_ok(stack) == 1)
    {
        err_temp->code = STACK_NOT_WORK;
        err_temp->message = "STACK NOT WORK\n";
        return *err_temp;
    }
    else
    {
        free(stack->data);
        stack->data = NULL;
        stack->len = 0;
        stack->pos = 0;
        my_error_dtor(err_temp);
        return *err_temp;
    }
}
예제 #25
0
파일: actions.cpp 프로젝트: CIB/wesnoth
void stopunit_result::do_execute()
{
	LOG_AI_ACTIONS << "start of execution of: " << *this << std::endl;
	assert(is_success());
	unit_map::iterator un = resources::units->find(unit_location_);
	try {
		if (remove_movement_){
			un->remove_movement_ai();
			set_gamestate_changed();
			manager::raise_gamestate_changed();
		}
		if (remove_attacks_){
			un->remove_attacks_ai();
			set_gamestate_changed();
			manager::raise_gamestate_changed();//to be on the safe side
		}
	} catch (...) {
		is_ok(); //Silences "unchecked result" warning
		throw;
	}
}
예제 #26
0
파일: actions.cpp 프로젝트: CIB/wesnoth
void synced_command_result::do_execute()
{
	LOG_AI_ACTIONS << "start of execution of: " << *this << std::endl;
	assert(is_success());

	std::stringstream s;
	if (location_ != map_location::null_location){
		s << "local x1 = " << location_.x << " local y1 = " << location_.y << " ";
	}
	s << lua_code_;
	
	synced_context::run_in_synced_context("lua_ai", replay_helper::get_lua_ai(s.str()));
	
	try {
		set_gamestate_changed();
		manager::raise_gamestate_changed();
	} catch (...) {
		is_ok(); //Silences "unchecked result" warning
		throw;
	}
}
예제 #27
0
static void
do_console_cancel_event (void)
{
	static MonoClassField *cancel_handler_field;
	MonoError error;
	MonoDomain *domain = mono_domain_get ();
	MonoClass *klass;
	MonoDelegate *load_value;
	MonoMethod *method;
	MonoVTable *vtable;

	/* FIXME: this should likely iterate all the domains, instead */
	if (!domain->domain)
		return;

	klass = mono_class_try_load_from_name (mono_defaults.corlib, "System", "Console");
	if (klass == NULL)
		return;

	if (cancel_handler_field == NULL) {
		cancel_handler_field = mono_class_get_field_from_name (klass, "cancel_handler");
		g_assert (cancel_handler_field);
	}

	vtable = mono_class_vtable_full (domain, klass, &error);
	if (vtable == NULL || !is_ok (&error)) {
		mono_error_cleanup (&error);
		return;
	}
	mono_field_static_get_value (vtable, cancel_handler_field, &load_value);
	if (load_value == NULL)
		return;

	klass = load_value->object.vtable->klass;
	method = mono_class_get_method_from_name (klass, "BeginInvoke", -1);
	g_assert (method != NULL);

	mono_threadpool_ms_begin_invoke (domain, (MonoObject*) load_value, method, NULL);
}
예제 #28
0
파일: protocol.c 프로젝트: rogerhil/chatc
void *receive_messages(void *threadarg) {
	/**
	 * Void que roda em paralelo para receber mensagens do servidor
	 */
	int sockfd;
	int ok;
	struct addrinfo *p;
   	struct thread_data_params *data;
   	Message recmsg;
   	
   	// extrai os parametros da estrutura da thread
   	data = (struct thread_data_params *) threadarg;
   	p = data->p;
    sockfd = data->sockfd;
	
	while (1) {
		recmsg = receive(sockfd, "Error ocurred while trying to receive messages!", 0);
		ok = is_ok(recmsg);
		ISOK = ok; // seta a variavel para 1 ou 0 dependendo se a mensagem recebida foi OK
	}
	pthread_exit(NULL);
}
예제 #29
0
파일: exception.c 프로젝트: vargaz/mono
static MonoExceptionHandle
create_exception_two_strings (MonoClass *klass, MonoStringHandle a1, MonoStringHandle a2, MonoError *error)
{
	HANDLE_FUNCTION_ENTER ();

	MonoMethod *method = NULL;
	int const count = 1 + !MONO_HANDLE_IS_NULL (a2);
	gpointer iter;
	MonoMethod *m;
	
	MonoObjectHandle o = mono_object_new_handle (mono_domain_get (), klass, error);
	mono_error_assert_ok (error);

	iter = NULL;
	while ((m = mono_class_get_methods (klass, &iter))) {
		MonoMethodSignature *sig;
		
		if (strcmp (".ctor", mono_method_get_name (m)))
			continue;
		sig = mono_method_signature_internal (m);
		if (sig->param_count != count)
			continue;

		if (sig->params [0]->type != MONO_TYPE_STRING)
			continue;
		if (count == 2 && sig->params [1]->type != MONO_TYPE_STRING)
			continue;
		method = m;
		break;
	}

	gpointer args [ ] = { MONO_HANDLE_RAW (a1), MONO_HANDLE_RAW (a2) };

	mono_runtime_invoke_handle (method, o, args, error);
	if (!is_ok (error))
		o = mono_new_null ();

	HANDLE_FUNCTION_RETURN_REF (MonoException, MONO_HANDLE_CAST (MonoException, o));
}
예제 #30
0
파일: solve.c 프로젝트: Xxdzs/42Projects
static int	back_track(t_tetab tetrimini, t_i const length,
						t_i const side, t_i const i)
{
	t_tet *const	current = tetrimini[i];

	if (i == length)
		return (1);
	current->pos.coord.y = 0;
	while (current->pos.coord.y <= side - current->dim.height)
	{
		current->pos.coord.x = 0;
		while (current->pos.coord.x <= side - current->dim.width)
		{
			if (is_ok(tetrimini, i)
				&& back_track(tetrimini, length, side, i + 1))
				return (1);
			current->pos.coord.x += 1;
		}
		current->pos.coord.y += 1;
	}
	return (0);
}