Exemple #1
0
object get_proxy(string user)
{
	object proxy;
	int firstchar;

	string creator;

	ACCESS_CHECK(PRIVILEGED() || INTERFACE());

	creator = DRIVER->creator(previous_program());

	CHECKARG(user && user != "" &&
		STRINGD->is_valid_username(user), 1, "get_proxy");

	check_security(user, creator);

	proxy = new_object("~/lwo/proxy", user);

	/* only the object who requested a proxy is allowed to use it */
	proxy->set_client(previous_object());

	if (audit) {
		INITD->message("User access proxy being issued to " +
			creator + " for " + user + ", assigned to " +
			object_name(previous_object()));
	}

	return proxy;
}
void testObjectd()
{
	/*
	 * This is really a bad unit-test now, but I want to ignore this test
	 * if, for some reason, __HAVE_OBJECTD__ was set and it does not exist.
	 * This is to simplify packaging.
	 */
	if(objectd == nil) {
		SYSLOG(	"Ignoring Unit-Test for objectd (could not find it), " + 
				"remove __HAVE_OBJECTD__ in your glue to get rid of " + 
				"this warning and the [possible] error above.\n");
		return;
	}
	assert_notnil(objectd->report_on_object( object_name(this_object()) ));
	assert_notnil(objectd->od_status( object_name(this_object()) )[6] );
	assert_notnil(objectd->destroyed_obj_list());
}
Exemple #3
0
nomask int _F_sys_create(int clone)
{
	string oname;
	string creator;

	object this;
	object programd;

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

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

	sscanf(oname, "%s#%*d", oname);

	creator = DRIVER->creator(oname);

	programd = find_object(PROGRAMD);

	if (programd) {
		object pinfo;
		string *ctors;
		string ctor;
		int i, sz;

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

		if (pinfo) {
			ctors = pinfo->query_inherited_constructors();

			sz = sizeof(ctors);

			for (i = 0; i < sz; i++) {
				call_other(this, ctors[i]);
			}

			ctor = pinfo->query_constructor();

			if (ctor) {
				call_other(this, ctor);
			}
		}
	} else {
		ASSERT(creator == "System" || creator == "Bigstruct");
	}

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

	return 1;
}
Exemple #4
0
void windy::app::compositable_map_menu() {

	auto animations =
		this->_environment->project()->assets()->collection()->get(layer::groupable);

	if (animations.empty()) {
		nana::msgbox mb(*this, L"Error!");
		mb << L"Create an animation first.";
		mb.show();
	}
	else {
		nana::inputbox::text name(L"<bold blue>Name</>");

		std::vector<std::wstring> nana_vector;

		for (auto& animation : animations) {
			auto name = animation->name();
			nana_vector.push_back(std::wstring(name.begin(), name.end()));
		}

		nana::inputbox::text options(L"Animation", nana_vector);

		nana::inputbox inbox(*this,
			L"Please input the <bold>creation parameters</> for the mapping.",
			L"Map");

		inbox.verify([this, &name](nana::window handle) {

			auto object_buffer_name = name.value();
			std::string object_name(object_buffer_name.begin(), object_buffer_name.end());

			if (object_name.empty())
			{
				nana::msgbox mb(handle, L"Invalid input");
				mb << L"Name should not be empty, please input the mapping name.";
				mb.show();
				return false; //verification failed
			}

			return true; //verified successfully
		});

		if (inbox.show_modal(name, options/*, file,*/)) {

			auto mapping_buffer_name = name.value();
			auto animation_buffer_name = options.value();

			auto mapping_name =
				std::string(mapping_buffer_name.begin(), mapping_buffer_name.end());

			auto animation_name =
				std::string(animation_buffer_name.begin(), animation_buffer_name.end());
			
		}
	}
}
void ActionGenerateReport::alter_schema_name(db_mysql_SchemaRef schema, grt::StringRef value) {
  if (current_schema_dictionary == NULL) {
    current_schema_dictionary = dictionary->addSectionDictionary(kbtr_ALTER_SCHEMA);
    current_schema_dictionary->setValue(kbtr_ALTER_SCHEMA_NAME, object_name(schema));
  }

  mtemplate::DictionaryInterface *c2 = current_schema_dictionary->addSectionDictionary(kbtr_ALTER_SCHEMA_NAME);
  c2->setValue(kbtr_OLD_SCHEMA_NAME, (std::string)schema->name());
  c2->setValue(kbtr_NEW_SCHEMA_NAME, (std::string)value);
}
Exemple #6
0
void cmex_object_list(int nlhs, mxArray *plhs[], /**< entlist */
					  int nrhs, const mxArray *prhs[] ) /**< () */
{
	OBJECT *obj;
	char criteria[1024]="(undefined)";
	FINDPGM *search = NULL;
	char *fields[] = {"name","class","parent","flags","location","service","rank","clock","handle"};
	FINDLIST *list = NULL;
	if (nrhs>0 && mxGetString(prhs[0],criteria,sizeof(criteria))!=0)
		output_error("gl('list',type='object'): unable to read search criteria (arg 2)");
	else if (nrhs>0 && (search=find_mkpgm(criteria))==NULL)
		output_error("gl('list',type='object'): unable to run search '%s'",criteria);
	else if (search==NULL && (list=find_objects(NULL,NULL))==NULL)
		output_error("gl('list',type='object'): unable to obtain default list");
	else if (list==NULL && (list=find_runpgm(NULL,search))==NULL)
		output_error("gl('list',type='object'): unable search failed");
	else if ((plhs[0] = mxCreateStructMatrix(list->hit_count,1,sizeof(fields)/sizeof(fields[0]),fields))==NULL)
		output_error("gl('list',type='object'): unable to allocate memory for result list");
	else
	{
		unsigned int n;
		for (n=0, obj=find_first(list); obj!=NULL; n++, obj=find_next(list,obj))
		{
			char tmp[1024];
			mxArray *data;
			double *pDouble;
			unsigned int *pInt;
			mxSetFieldByNumber(plhs[0], n, 0, mxCreateString(object_name(obj)));
			mxSetFieldByNumber(plhs[0], n, 1, mxCreateString(obj->oclass->name));
			mxSetFieldByNumber(plhs[0], n, 2, mxCreateString(obj->parent?object_name(obj->parent):NONE));
			mxSetFieldByNumber(plhs[0], n, 3, mxCreateString(convert_from_set(tmp,sizeof(tmp),&(obj->flags),object_flag_property())?tmp:ERROR));
			pDouble = mxGetPr(data=mxCreateDoubleMatrix(1,2,mxREAL)); pDouble[0] = obj->longitude; pDouble[1] = obj->latitude;
			mxSetFieldByNumber(plhs[0], n, 4, data);
			pDouble = mxGetPr(data=mxCreateDoubleMatrix(1,2,mxREAL)); pDouble[0] = (double)obj->in_svc/TS_SECOND; pDouble[1] = (double)obj->out_svc/TS_SECOND;
			mxSetFieldByNumber(plhs[0], n, 5, data);
			pInt = (unsigned int*)mxGetPr(data=mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL)); pInt[0] = obj->rank;
			mxSetFieldByNumber(plhs[0], n, 6, data);
			pDouble = mxGetPr(data=mxCreateDoubleMatrix(1,1,mxREAL)); pDouble[0] = (double)obj->clock/TS_SECOND; 
			mxSetFieldByNumber(plhs[0], n, 7, data);
			mxSetFieldByNumber(plhs[0], n, 8, make_handle(MH_OBJECT,obj));
		}
	}
}
void ActionGenerateReport::alter_schema_default_collate(db_mysql_SchemaRef schema, grt::StringRef value) {
  if (current_schema_dictionary == NULL) {
    current_schema_dictionary = dictionary->addSectionDictionary(kbtr_ALTER_SCHEMA);
    current_schema_dictionary->setValue(kbtr_ALTER_SCHEMA_NAME, object_name(schema));
  }

  // schema_altered= true;
  mtemplate::DictionaryInterface *c2 = current_schema_dictionary->addSectionDictionary(kbtr_ALTER_SCHEMA_CHARSET);
  c2->setValue(kbtr_OLD_SCHEMA_COLLATE, (std::string)schema->defaultCollationName());
  c2->setValue(kbtr_NEW_SCHEMA_COLLATE, (std::string)value);
}
Exemple #8
0
/*
 * NAME:	normalize_path()
 * DESCRIPTION:	reduce a path to its minimal absolute form
 */
string normalize_path(string file, varargs string dir, string creator)
{
    string *path;
    int i, j, sz;

    if (strlen(file) == 0) {
	if (!dir) {
	    dir = object_name(previous_object()) + "/..";
	}
	file = dir;
    }
    switch (file[0]) {
    case '~':
	/* ~path */
	if (!creator) {
	    creator = creator(object_name(previous_object()));
	}
	if (creator && (strlen(file) == 1 || file[1] == '/')) {
	    file = "/usr/" + creator + file[1 ..];
	} else {
Exemple #9
0
nomask string base_name( varargs object obj ) {

  string str;
  string obname;
  int clone;
  if(!obj)
    obj = this_object();
  obname = object_name(obj);
  if( sscanf( obname, "%s#%d", str, clone ) ==2 )
    return str;
  return obname;
}
Exemple #10
0
static void reset_limits()
{
	string creator;
	int sz;
	string *resources;

	creator = DRIVER->creator(object_name(this_object()));
	resources = KERNELD->query_resources();

	for (sz = sizeof(resources); --sz >= 0; ) {
		KERNELD->rsrc_set_limit(creator, resources[sz], -1);
	}
}
Exemple #11
0
void maybe_replace_program()
{
  string *list, first;
  object first_ob;

  if (object_name(this_object())=="/std/room" ||
      !(first_ob=find_object(first=(list=inherit_list(this_object()))[1])) ||
      (sizeof(list)!=1+sizeof(inherit_list(first_ob))) ||
      (1!=sizeof(list=functionlist(this_object(),
           RETURN_FUNCTION_NAME|NAME_INHERITED))) ||
      list[0]!="create")
    return;
  replace_program(first);
}
STATUS test_init(void)
{
	OBJECT *obj;
	output_verbose("initializing objects...");
	for (obj=object_get_first(); obj!=NULL; obj=object_get_next(obj))
	{
		if (object_init(obj)==FAILED)
		{
			output_error("object %s initialization failed", object_name(obj));
			return FAILED;
		}
	}
	return SUCCESS;
}
Exemple #13
0
void create()
{
  if (!clonep(this_object()) && object_name(this_object())==(PATH+"raum0")) {
    set_next_reset(-1);
    return;
  }
  ::create();

  Set(H_REPORT, 0);
  Set(H_REPORT, SAVE, F_MODE);

  AddCmd( "erlaube", "erlauben" );
  AddCmd( "verbiete", "verbieten" );
  AddCmd( "oeffne", "oeffne" );
  AddCmd( ({ "schliess", "schliesse" }), "schliesse" );
Exemple #14
0
const struct ICACHE_FLASH_ATTR object* object_find_by_name(const char* name)
{
	const struct object* object;

	if(name != NULL)
	{
		for(object=global_objects; object != NULL; ++object)
		{
			if(strcmp(object_name(object), name) == 0)
				return object;
		}
	}

	return NULL;
}
/*______________________________________________________________________________

  CommentaryZone::constructor
______________________________________________________________________________*/
CommentaryZone::CommentaryZone(const QString & splitter_name,
                               const DipyDoc * _dipydoc,
                               bool & _blocked_commentaries,
                               QWidget* _parent) : QFrame(_parent),
                                                   dipydoc(_dipydoc),
                                                   blocked_commentaries(_blocked_commentaries) {
  // DEBUG1 DebugMsg() << "CommentaryZone::CommentaryZone : entry point";

  QString object_name(splitter_name + "::commentary_zone");
  this->setObjectName(object_name);

  // DEBUG1 DebugMsg() << "CommentaryZone::CommentaryZone : creating CommentaryEditor object";
  this->editor = new CommentaryEditor(splitter_name,
                                      this->dipydoc,
                                      this->blocked_commentaries,
                                      this);

  // DEBUG1 DebugMsg() << "CommentaryZone::CommentaryZone : creating CommentaryToolBar object";
  this->toolbar = new CommentaryToolBar(splitter_name,
                                        this);

  this->layout = new QHBoxLayout(this);
  this->layout->addWidget(this->editor);
  this->layout->addWidget(this->toolbar);

  this->setLayout(this->layout);

  /*
    (2) signals : signals between the editors and the toolbars :
  */
  this->textminusAct = new QAction(QIcon(":resources/images/icons/textminus.png"),
                                   tr("reduce the font size"), this);
  this->textplusAct  = new QAction(QIcon(":resources/images/icons/textplus.png"),
                                   tr("enlarge the font size"), this);

  this->toolbar->addAction(this->textplusAct);
  this->toolbar->addAction(this->textminusAct);

  // connection #C026 (confer documentation)
  QObject::connect(this->textminusAct, &QAction::triggered,
                   this->editor,       &CommentaryEditor::zoom_out);

  // connection #C027 (confer documentation)
  QObject::connect(this->textplusAct,  &QAction::triggered,
                   this->editor,       &CommentaryEditor::zoom_in);

  // DEBUG1 DebugMsg() << "CommentaryZone::CommentaryZone : exit point";
}
Exemple #16
0
MStatus Pick::doIt( const MArgList& args )
{
	MStatus res = MS::kSuccess;

	unsigned len = args.length();
	if ( len > 0 ) {
		MString object_name( args.asString(0) );

		if ( MS::kSuccess != MGlobal::selectByName( object_name ) )
			cerr << "Object " << object_name.asChar() << " not found\n";
	} else {
		cerr << "No Object name specified\n";
	}

	return res;
}
Exemple #17
0
static object clone_object( string path ) {
  object ob, ed;
  string trace;
  string cloner;

  argcheck( path, 1, "string" );

  ed = find_object(ERROR_D);

  /*
   * yeah.. calling the error_d to get a formatted runtime trace.. no, we aren't
   * reporting an error here, just using one of its nice utility functions to get
   * a nicely formatted trace
   *
   */
  if(ed) trace = ed->format_runtime_error("Clone calltrace",::call_trace(),0,0,0);
  else trace = "No clone calltrace available\n";

  if(this_object()->is_player() && this_object()->query_name()) {
    cloner = this_object()->query_name();
  } else if(sscanf(object_name(this_object()),"/cmds/wiz/%*s") == 1 && this_user()) {
    cloner = this_user()->query_name();
  } else {
    cloner = _owner;
  }

  if( strlen(path) > 2 ) {
    if( path[strlen(path)-2] == '.' && path[strlen(path)-1] == 'c' )
      path = path[..strlen(path)-3];
  }

  if(find_object(COMPILER_D)) {
    path = COMPILER_D->allow_object( path );
  }

  if( !(ob = find_object( path ) ) ) {
    ob = compile_object( path );
    call_other(ob,"???");
  }

  ob = ::clone_object( ob );
  ob->_F_set_cloner(cloner,trace);
  ob->_F_create();
  return ob;
}
static nomask object clone_object(mixed what) 
{
  if (stringp(what))
  {
    object blueprint;
    
    stderr(" - clone_object from \"" + what + "\"\n");
    blueprint = load_object(what);

    if (blueprint)
      return ::clone_object(blueprint);
    return nil;
  }

  if (objectp(what))
    stderr(" - clone_object from <" + object_name(what) + ">\n");

  return ::clone_object(what);
}
Exemple #19
0
void initialise(object o, string prompt, string func, int type,
    int hide_input, mixed args) {
/* This function initialises the input handler with the provided values after
 * ensuring the return function is valid. */
  return_object = o;
  return_function = func;

  if(!function_object(return_function, return_object)) {
    error("Specified function '" + return_function +
        "' does not exist in object '" + object_name(return_object));
  }

  set_prompt(prompt);
  if(hide_input) {
    set_mode(MODE_NOECHO);
  }
  input_type = type;
  opt_args = args;
}
void write(mixed arg)
{
	switch(typeof(arg)) {
	case T_NIL :
		arg = "[nil]";
		break;
	case T_INT :
	case T_FLOAT :
		arg = "" + arg;
		break;
	case T_OBJECT :
		arg = "[OBJECT]" + object_name(arg);
		break;
	case T_ARRAY :
		error("arg is array\n");
	case T_MAPPING :
		error("arg is mapping\n");
	}
	response->add_content(arg);
}
Exemple #21
0
atomic string to_mudmode(mixed data) {
  string *keys;
  string *vals;
  string pref, post, result;
  int i, n;

  switch(typeof(data)) {
    case T_INT:
    case T_FLOAT: return ""+data;
    case T_STRING:
      if(strlen(data) == 0) return "";

      if(data[0..0] == "\\") {
        pref = "\\\\";
      }
      else if(data[0..0] == "\"") {
        pref = "\\\"";
      }
      else {
        pref = "";
      }

      if(data[strlen(data)-1] == '\\') {
        post = "\\\\";
      }
      else if(data[strlen(data)-1] == '"') {
        post = "\\\"";
      }
      else {
        post = "";
      }

      result = implode(explode(data, "\\"), "\\\\");
      result = implode(explode(result, "\""), "\\\"");
      return "\"" + pref + result + post + "\"";
      
    case T_OBJECT: return object_name(data);
    case T_ARRAY:
      vals = ({ });
      for(i = 0, n = sizeof(data); i < n; i++)
        vals += ({ to_mudmode(data[i]) });
STATUS original_test_end(int argc, char *argv[])
{
	FINDLIST *find = find_objects(FL_GROUP,"class=node;");
	OBJECT *obj;
	AGGREGATION *aggr;
	char *exp = "class=node";
	char *agg = "max(V.ang)";

	for (obj=find_first(find); obj!=NULL; obj=find_next(find,obj))
		output_message("object %s found", object_name(obj));
	free(find);

	output_message("Aggregation of %s over %s...", agg,exp);
	aggr = aggregate_mkgroup(agg,exp);
	if (aggr)
		output_message("Result is %lf", aggregate_value(aggr));
	else
		output_message("Aggregation failed!");

	if (!saveall("-"))
		perror("save failed");

	return SUCCESS;
}
Exemple #23
0
int main(int argc, char *argv[])
{
	int ret;
	time_t t;
	double jd;
	struct tm tm;
	const struct object *obj;

	/* Default options */
	double horizon = LN_SOLAR_STANDART_HORIZON; /* 50 Bogenminuten; no twilight, normal sunset/rise */
	int tz = INT_MAX;

	char *obj_str = basename(argv[0]);
	char *format = "%H:%M %d.%m.%Y";
	//char *format = "time: %Y-%m-%d %H:%M:%S (%Z) az: §a (§s) alt: §h";
	char tzid[32];
	char *query = NULL;

	bool horizon_set = false;
	bool next = false;
	bool local_tz = false;
	
	time(&t);
	localtime_r(&t, &tm);

	enum {
		MOMENT_NOW,
		MOMENT_RISE,
		MOMENT_SET,
		MOMENT_TRANSIT
	} moment = MOMENT_NOW;

	struct ln_lnlat_posn obs = { DBL_MAX, DBL_MAX };
	struct object_details result;

	/* set tzid as empty (without repointing the buffer) */
	strcpy(tzid, "");
	/* parse command line arguments */
	while (1) {
		int c = getopt_long(argc, argv, "+hvnult:d:f:a:o:q:z:p:m:H:", long_options, NULL);

		/* detect the end of the options. */
		if (c == -1)
			break;

		switch (c) {
			case 'H':
				if      (strcmp(optarg, "civil") == 0)
					horizon = LN_SOLAR_CIVIL_HORIZON;
				else if (strcmp(optarg, "nautic") == 0)
					horizon = LN_SOLAR_NAUTIC_HORIZON;
				else if (strcmp(optarg, "astronomical") == 0)
					horizon = LN_SOLAR_ASTRONOMICAL_HORIZON;
				else {
					char *endptr;
					horizon = strtod(optarg, &endptr);

					if (endptr == optarg)
						usage_error("invalid horizon / twilight parameter");
				}
				
				horizon_set = true;
				break;

			case 't':
				tm.tm_isdst = -1; /* update dst */
				if (strchr(optarg, '_')) {
					if (!strptime(optarg, "%Y-%m-%d_%H:%M:%S", &tm))
						usage_error("invalid time/date parameter");
				}
				else {
					if (!strptime(optarg, "%Y-%m-%d", &tm))
						usage_error("invalid time/date parameter");
				}
				break;

			case 'm':
				if      (strcmp(optarg, "rise") == 0)
					moment = MOMENT_RISE;
				else if (strcmp(optarg, "set") == 0)
					moment = MOMENT_SET;
				else if (strcmp(optarg, "transit") == 0)
					moment = MOMENT_TRANSIT;
				else
					usage_error("invalid moment");
				break;

			case 'n':
				next = true;
				break;

			case 'f':
				format = strdup(optarg);
				break;

			case 'a':
				obs.lat = strtod(optarg, NULL);
				break;

			case 'o':
				obs.lng = strtod(optarg, NULL);
				break;
#ifdef GEONAMES_SUPPORT
			case 'q':
				query = strdup(optarg);
				break;

			case 'l':
				local_tz = true;
				break;
#endif
			case 'p':
				obj_str = optarg;
				break;

			case 'z':
				strncpy(tzid, optarg, sizeof(tzid));
				break;

			case 'u':
				strncpy(tzid, "UTC", sizeof(tzid));
				break;

			case 'v':
				print_version();
				return 0;

			case 'h':
				print_usage();
				return 0;

			case '?':
			default:
				usage_error("unrecognized option");
		}
	}
	
	/* Parse planet/obj */
	obj = object_lookup(obj_str);
	if (!obj)
		usage_error("invalid or missing object, use --object");

#ifdef GEONAMES_SUPPORT
	/* Lookup place at http://geonames.org */
	if (query) {
		ret =  geonames_lookup_latlng(query, &obs, NULL, 0);
		if (ret)
			usage_error("failed to lookup location");
	}
	
	if (local_tz) {
		int gmt_offset;
		ret =  geonames_lookup_tz(obs, &gmt_offset, tzid, sizeof(tzid));
		if (ret)
			usage_error("failed to lookup location");
	}
#endif

	if(strlen(tzid) > 0)	/* set TZ variable only when we have a value - otherwise rely on /etc/localtime or whatever other system fallbacks */
		setenv("TZ", tzid, 1);
	tzset();

	/* Validate observer coordinates */
	if (fabs(obs.lat) > 90)
		usage_error("invalid latitude, use --lat");
	if (fabs(obs.lng) > 180)
		usage_error("invalid longitude, use --lon");
	
	if (horizon_set && strcmp(object_name(obj), "sun"))
		usage_error("the twilight parameter can only be used for the sun");

	/* Calculate julian date */
	t = mktime(&tm);
	jd = ln_get_julian_from_timet(&t);

	result.obs = obs;

#ifdef DEBUG
	printf("Debug: calculate for jd: %f\n", jd);
	printf("Debug: calculate for ts: %ld\n", t);
	printf("Debug: for position: N %f, E %f\n", obs.lat, obs.lng);
	printf("Debug: for object: %s\n", object_name(obj));
	printf("Debug: with horizon: %f\n", horizon);
	printf("Debug: with timezone: %s\n", tzid);
#endif

	/* calc rst date */
rst:	if (object_rst(obj, jd - .5, horizon, &result.obs, &result.rst) == 1)  {
		if (moment != MOMENT_NOW) {
			fprintf(stderr, "object is circumpolar\n");
			return 2;
		}
	}
	else {
		switch (moment) {
			case MOMENT_NOW:	result.jd = jd; break;
			case MOMENT_RISE:	result.jd = result.rst.rise; break;
			case MOMENT_SET:	result.jd = result.rst.set; break;
			case MOMENT_TRANSIT:	result.jd = result.rst.transit; break;
		}

		if (next && result.jd < jd) {
			jd++;
			next = false;
			goto rst;
		}
	}
	
	ln_get_timet_from_julian(result.jd, &t);
	localtime_r(&t, &result.tm);

	object_pos(obj, jd, &result);

	format_result(format, &result);

	return 0;
}
Exemple #24
0
void
FE_Utils::create_uses_multiple_stuff (AST_Component *c,
                                      AST_Uses *u,
                                      const char *prefix)
{
  ACE_CString struct_name (prefix);

  if (!struct_name.empty ())
    {
      struct_name += '_';
    }

  struct_name += u->local_name ()->get_string ();
  struct_name += "Connection";
  Identifier struct_id (struct_name.c_str ());
  UTL_ScopedName sn (&struct_id, 0);

  // In case this call comes from the backend. We
  // will pop the scope before returning.
  idl_global->scopes ().push (c);

  AST_Structure *connection =
    idl_global->gen ()->create_structure (&sn, 0, 0);

  struct_id.destroy ();

  /// If the field type is a param holder, we want
  /// to use the lookup to create a fresh one,
  /// since the field will own it and destroy it.
  UTL_ScopedName *fn = u->uses_type ()->name ();
  AST_Decl *d =
    idl_global->root ()->lookup_by_name (fn, true, false);
  AST_Type *ft = AST_Type::narrow_from_decl (d);

  Identifier object_id ("objref");
  UTL_ScopedName object_name (&object_id,
                              0);
  AST_Field *object_field =
    idl_global->gen ()->create_field (ft,
                                      &object_name,
                                      AST_Field::vis_NA);
  (void) DeclAsScope (connection)->fe_add_field (object_field);
  object_id.destroy ();

  Identifier local_id ("Cookie");
  UTL_ScopedName local_name (&local_id,
                             0);
  Identifier module_id ("Components");
  UTL_ScopedName scoped_name (&module_id,
                              &local_name);

  d = c->lookup_by_name (&scoped_name, true);
  local_id.destroy ();
  module_id.destroy ();

  if (d == 0)
    {
      // This would happen if we haven't included Components.idl.
      idl_global->err ()->lookup_error (&scoped_name);
      return;
    }

  AST_ValueType *cookie = AST_ValueType::narrow_from_decl (d);

  Identifier cookie_id ("ck");
  UTL_ScopedName cookie_name (&cookie_id,
                              0);
  AST_Field *cookie_field =
    idl_global->gen ()->create_field (cookie,
                                      &cookie_name,
                                      AST_Field::vis_NA);
  (void) DeclAsScope (connection)->fe_add_field (cookie_field);
  cookie_id.destroy ();

  (void) c->fe_add_structure (connection);

  ACE_CDR::ULong bound = 0;
  AST_Expression *bound_expr =
    idl_global->gen ()->create_expr (bound,
                                     AST_Expression::EV_ulong);
  AST_Sequence *sequence =
    idl_global->gen ()->create_sequence (bound_expr,
                                         connection,
                                         0,
                                         0,
                                         0);

  ACE_CString seq_string (struct_name);
  seq_string += 's';
  Identifier seq_id (seq_string.c_str ());
  UTL_ScopedName seq_name (&seq_id,
                           0);
  AST_Typedef *connections =
    idl_global->gen ()->create_typedef (sequence,
                                        &seq_name,
                                        0,
                                        0);
  seq_id.destroy ();

  (void) c->fe_add_typedef (connections);

  // In case this call comes from the backend.
  idl_global->scopes ().pop ();
}
void ShipGoalsDlg::update_item(int item, int multi)
{
	char *docker, *dockee, *subsys;
	int mode;
	char buf[512], save[80];
	waypoint_list *wp_list;

	if (item >= MAX_AI_GOALS)
		return;

	if (!multi || m_priority[item] >= 0)
		goalp[item].priority = m_priority[item];

	if (m_behavior[item] < 0) {
		if (multi)
			return;
		else
			m_behavior[item] = 0;
	}

	mode = (int)m_behavior_box[item] -> GetItemData(m_behavior[item]);
	switch (mode) {
		case AI_GOAL_NONE:
		case AI_GOAL_CHASE_ANY:
		case AI_GOAL_UNDOCK:
		case AI_GOAL_KEEP_SAFE_DISTANCE:
		case AI_GOAL_PLAY_DEAD:
		case AI_GOAL_PLAY_DEAD_PERSISTENT:
		case AI_GOAL_WARP:
			// these goals do not have a target in the dialog box, so let's set the goal and return immediately
			// so that we don't run afoul of the "doesn't have a valid target" code at the bottom of the function
			MODIFY(goalp[item].ai_mode, mode);
			return;

		case AI_GOAL_WAYPOINTS:
		case AI_GOAL_WAYPOINTS_ONCE:
		case AI_GOAL_DISABLE_SHIP:
		case AI_GOAL_DISARM_SHIP:
		case AI_GOAL_IGNORE:
		case AI_GOAL_IGNORE_NEW:
		case AI_GOAL_EVADE_SHIP:
		case AI_GOAL_STAY_NEAR_SHIP:
		case AI_GOAL_STAY_STILL:
		case AI_GOAL_CHASE_SHIP_CLASS:
			break;

		case AI_GOAL_DESTROY_SUBSYSTEM:
			subsys = NULL;
			if (!multi || (m_data[item] && (m_subsys[item] >= 0)))
				subsys = (char *) m_subsys_box[item]->GetItemDataPtr(m_subsys[item]);
				//MODIFY(goalp[item].ai_submode, m_subsys[item] + 1);

			if (!subsys) {
				sprintf(buf, "Order #%d doesn't have valid subsystem name.  Order will be removed", item + 1);
				MessageBox(buf, "Notice");
				MODIFY(goalp[item].ai_mode, AI_GOAL_NONE);
				return;

			} else {
				if (!goalp[item].docker.name || (goalp[item].docker.name && !stricmp(goalp[item].docker.name, subsys)))
					set_modified();

				goalp[item].docker.name = subsys;
			}

			break;

		case AI_GOAL_CHASE | AI_GOAL_CHASE_WING:
			switch (m_data[item] & TYPE_MASK) {
				case TYPE_SHIP:
				case TYPE_PLAYER:
					mode = AI_GOAL_CHASE;
					break;

				case TYPE_WING:
					mode = AI_GOAL_CHASE_WING;
					break;
			}

			break;

		case AI_GOAL_DOCK:
			docker = NULL;
			if (!multi || (m_data[item] && (m_subsys[item] >= 0)))
				docker = (char *) m_subsys_box[item] -> GetItemDataPtr(m_subsys[item]);

			dockee = NULL;
			if (!multi || (m_data[item] && (m_dock2[item] >= 0)))
				dockee = (char *) m_dock2_box[item] -> GetItemDataPtr(m_dock2[item]);

			if (docker == (char *) SIZE_T_MAX)
				docker = NULL;
			if (dockee == (char *) SIZE_T_MAX)
				dockee = NULL;

			if (!docker || !dockee) {
				sprintf(buf, "Order #%d doesn't have valid docking points.  Order will be removed", item + 1);
				MessageBox(buf, "Notice");
				MODIFY(goalp[item].ai_mode, AI_GOAL_NONE);
				return;

			} else {
				if (!goalp[item].docker.name)
					set_modified();
				else if (!stricmp(goalp[item].docker.name, docker))
					set_modified();

				if (!goalp[item].dockee.name)
					set_modified();
				else if (!stricmp(goalp[item].dockee.name, dockee))
					set_modified();

				goalp[item].docker.name = docker;
				goalp[item].dockee.name = dockee;
			}

			break;

		case AI_GOAL_GUARD | AI_GOAL_GUARD_WING:
			switch (m_data[item] & TYPE_MASK) {
				case TYPE_SHIP:
				case TYPE_PLAYER:
					mode = AI_GOAL_GUARD;
					break;

				case TYPE_WING:
					mode = AI_GOAL_GUARD_WING;
					break;
			}

			break;

		default:
			Warning(LOCATION, "Unknown AI_GOAL type 0x%x", mode);
			MODIFY(goalp[item].ai_mode, AI_GOAL_NONE);
			return;
	}

	MODIFY(goalp[item].ai_mode, mode);

	*save = 0;
	if (goalp[item].target_name)
		strcpy_s(save, goalp[item].target_name);

	switch (m_data[item] & TYPE_MASK) {
		int not_used;

		case TYPE_SHIP:
		case TYPE_PLAYER:
			goalp[item].target_name = ai_get_goal_target_name(Ships[m_data[item] & DATA_MASK].ship_name, &not_used);
			break;

		case TYPE_WING:
			goalp[item].target_name = ai_get_goal_target_name(Wings[m_data[item] & DATA_MASK].name, &not_used);
			break;

		case TYPE_PATH:
			wp_list = find_waypoint_list_at_index(m_data[item] & DATA_MASK);
			Assert(wp_list != NULL);
			goalp[item].target_name = ai_get_goal_target_name(wp_list->get_name(), &not_used);
			break;

		case TYPE_WAYPOINT:
			goalp[item].target_name = ai_get_goal_target_name(object_name(m_data[item] & DATA_MASK), &not_used);
			break;

		case TYPE_SHIP_CLASS:
			goalp[item].target_name = ai_get_goal_target_name(Ship_info[m_data[item] & DATA_MASK].name, &not_used);
			break;

		case 0:
		case -1:
		case (-1 & TYPE_MASK):
			if (multi)
				return;

			sprintf(buf, "Order #%d doesn't have a valid target.  Order will be removed", item + 1);
			MessageBox(buf, "Notice");
			MODIFY(goalp[item].ai_mode, AI_GOAL_NONE);
			return;

		default:
			Error(LOCATION, "Unhandled TYPE_X #define %d in ship goals dialog box", m_data[item] & TYPE_MASK);
	}

	if (stricmp(save, goalp[item].target_name))
		set_modified();
}
void ShipGoalsDlg::set_item(int item, int init)
{
	SCP_list<waypoint_list>::iterator ii;
	int i, t, z, num, inst;
	object *ptr;

	if (init)
		m_object[item] = -1;

	if (item >= MAX_AI_GOALS)
		m_behavior_box[item] -> EnableWindow(FALSE);
	
	Assert(item >= 0 && item < ED_MAX_GOALS);
	m_object_box[item] -> ResetContent();
	if (m_behavior[item] < 1) {
		m_object_box[item] -> EnableWindow(FALSE);
		m_subsys_box[item] -> EnableWindow(FALSE);
		m_dock2_box[item] -> EnableWindow(FALSE);
		m_priority_box[item] -> EnableWindow(FALSE);
		m_subsys[item] = -1;
		m_dock2[item] = -1;
		return;
	}

	auto mode = m_behavior_box[item] -> GetItemData(m_behavior[item]);
	m_priority_box[item] -> EnableWindow(TRUE);
	if ((mode == AI_GOAL_CHASE_ANY) || (mode == AI_GOAL_UNDOCK) || (mode == AI_GOAL_KEEP_SAFE_DISTANCE) || (mode == AI_GOAL_PLAY_DEAD) || (mode == AI_GOAL_PLAY_DEAD_PERSISTENT) || (mode == AI_GOAL_WARP) ) {
		m_object_box[item] -> EnableWindow(FALSE);
		m_subsys_box[item] -> EnableWindow(FALSE);
		m_dock2_box[item] -> EnableWindow(FALSE);
		m_subsys[item] = -1;
		m_dock2[item] = -1;
		return;
	}

	m_object_box[item] -> EnableWindow(TRUE);

	// for goals that deal with waypoint paths or individual waypoints
	switch (mode) {
		case AI_GOAL_WAYPOINTS:
		case AI_GOAL_WAYPOINTS_ONCE:
		//case AI_GOAL_WARP:
			for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii) {
				z = m_object_box[item] -> AddString(ii->get_name());
				m_object_box[item] -> SetItemData(z, i | TYPE_PATH);
				if (init && (m_data[item] == (i | TYPE_PATH)))
					m_object[item] = z;
			}
			break;

		case AI_GOAL_STAY_STILL:
			ptr = GET_FIRST(&obj_used_list);
			while (ptr != END_OF_LIST(&obj_used_list)) {
				if (ptr->type == OBJ_WAYPOINT) {
					z = m_object_box[item] -> AddString(object_name(OBJ_INDEX(ptr)));
					m_object_box[item] -> SetItemData(z, OBJ_INDEX(ptr) | TYPE_WAYPOINT);
					if (init && (m_data[item] == (OBJ_INDEX(ptr) | TYPE_WAYPOINT)))
						m_object[item] = z;
				}

				ptr = GET_NEXT(ptr);
			}
			break;
	}

	// for goals that deal with ship classes
	switch (mode) {
		case AI_GOAL_CHASE_SHIP_CLASS:
			for (i = 0; i < static_cast<int>(Ship_info.size()); i++) {
				z = m_object_box[item] -> AddString(Ship_info[i].name);
				m_object_box[item] -> SetItemData(z, i | TYPE_SHIP_CLASS);
				if (init && (m_data[item] == (i | TYPE_SHIP_CLASS)))
					m_object[item] = z;
			}
			break;
	}

	// for goals that deal with individual ships
	switch (mode) {
		case AI_GOAL_DESTROY_SUBSYSTEM:
		case AI_GOAL_CHASE | AI_GOAL_CHASE_WING:
		case AI_GOAL_DOCK:
		case AI_GOAL_GUARD | AI_GOAL_GUARD_WING:
		case AI_GOAL_DISABLE_SHIP:
		case AI_GOAL_DISARM_SHIP:
		case AI_GOAL_EVADE_SHIP:
		case AI_GOAL_IGNORE:
		case AI_GOAL_IGNORE_NEW:
		case AI_GOAL_STAY_NEAR_SHIP:
		case AI_GOAL_STAY_STILL:
			ptr = GET_FIRST(&obj_used_list);
			while (ptr != END_OF_LIST(&obj_used_list)) {
				if ((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) {
					inst = ptr->instance;
					if (ptr->type == OBJ_SHIP)
						t = TYPE_SHIP;
					else
						t = TYPE_PLAYER;

					Assert(inst >= 0 && inst < MAX_SHIPS);
					// remove all marked ships from list
					if (!goalp && (ptr->flags[Object::Object_Flags::Marked]))
						inst = -1;

					// when docking, remove invalid dock targets
					else if (mode == AI_GOAL_DOCK) {
						if (self_ship < 0 || !ship_docking_valid(self_ship, inst))
							inst = -1;
					}

					// disallow ship being its own target
					if (inst >= 0 && inst != self_ship) {
						z = m_object_box[item] -> AddString(Ships[inst].ship_name);
						m_object_box[item] -> SetItemData(z, inst | t);
						if (init && (m_data[item] == (inst | t)))
							m_object[item] = z;
					}
				}

				ptr = GET_NEXT(ptr);
			}
			break;
	}

	// for goals that deal with wings
	switch (mode) {
		case AI_GOAL_CHASE | AI_GOAL_CHASE_WING:
		case AI_GOAL_GUARD | AI_GOAL_GUARD_WING:
			for (i=0; i<MAX_WINGS; i++) {
				if (Wings[i].wave_count && i != self_wing) {
					z = m_object_box[item] -> AddString(Wings[i].name);
					m_object_box[item] -> SetItemData(z, i | TYPE_WING);
					if (init && (m_data[item] == (i | TYPE_WING)))
						m_object[item] = z;
				}
			}
			break;
	}

	// special cases depending on the target: subsystems and docking points
	if (mode == AI_GOAL_DESTROY_SUBSYSTEM) {
		m_subsys_box[item] -> EnableWindow(TRUE);
		m_dock2_box[item] -> EnableWindow(FALSE);
		m_dock2[item] = -1;
		set_object(item);
		if (!m_behavior[item])
			set_item(item, init);

	} else if (mode == AI_GOAL_DOCK) {
		num = get_docking_list(Ship_info[Ships[cur_ship].ship_info_index].model_num);
		m_subsys_box[item] -> EnableWindow(TRUE);
		m_subsys_box[item] -> ResetContent();
		for (i=0; i<num; i++) {
			Assert(Docking_bay_list[i]);
			z = m_subsys_box[item] -> AddString(Docking_bay_list[i]);
			m_subsys_box[item] -> SetItemDataPtr(z, Docking_bay_list[i]);
		}

		set_object(item);
		if (!m_behavior[item])
			set_item(item, init);

	} else {
		m_subsys_box[item] -> EnableWindow(FALSE);
		m_dock2_box[item] -> EnableWindow(FALSE);
		m_subsys[item] = -1;
		m_dock2[item] = -1;
	}
}
void CGldEditorView::LoadObject(OBJECT *obj)
{
	CListCtrl &list = GetListCtrl();
	
	int nColumns = list.GetHeaderCtrl()?list.GetHeaderCtrl()->GetItemCount():0;
	for (int i=0; i<nColumns; i++)
		list.DeleteColumn(0);

	CRect wr;
	list.GetClientRect(&wr);
	int nCol=0;
	int nWid=0;
	#define W(X) (nWid+=X,X)
	int Name = list.InsertColumn(nCol++,"Name",LVCFMT_LEFT,W(150),nCol);
	int Type = list.InsertColumn(nCol++,"Type",LVCFMT_LEFT,W(100),nCol);
	int Class = list.InsertColumn(nCol++,"Class",LVCFMT_LEFT,W(150),nCol);
	int Access = list.InsertColumn(nCol++,"Access",LVCFMT_LEFT,W(100),nCol);
	int Data = list.InsertColumn(nCol++,"Data",LVCFMT_RIGHT,W(100),nCol);
	int Description = list.InsertColumn(nCol++,"Description",LVCFMT_LEFT,wr.Width()-nWid,nCol);
	#undef W

	int nItem;
	char buffer[1024]="";
	CLASS *oclass;
	PROPERTY *prop;

	nItem = list.InsertItem(list.GetItemCount(),"clock");
	list.SetItemText(nItem,Type,"TIMESTAMP");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PROTECTED");
	list.SetItemText(nItem,Data,convert_from_timestamp(obj->clock,buffer,sizeof(buffer))?buffer:"");

	nItem = list.InsertItem(list.GetItemCount(),"name");
	list.SetItemText(nItem,Type,"OBJECTNAME");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PUBLIC");
	list.SetItemText(nItem,Data,object_name(obj));

	nItem = list.InsertItem(list.GetItemCount(),"id");
	list.SetItemText(nItem,Type,"OBJECTNUM");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"REFERENCE");
	sprintf(buffer,"%d",obj->id);
	list.SetItemText(nItem,Data,buffer);

	nItem = list.InsertItem(list.GetItemCount(),"class");
	list.SetItemText(nItem,Type,"CLASSNAME");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"REFERENCE");
	list.SetItemText(nItem,Data,obj->oclass->name);

	nItem = list.InsertItem(list.GetItemCount(),"size");
	list.SetItemText(nItem,Type,"OBJECTRANK");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"REFERENCE");
	sprintf(buffer,"%d",obj->oclass->size);
	list.SetItemText(nItem,Data,buffer);

	nItem = list.InsertItem(list.GetItemCount(),"parent");
	list.SetItemText(nItem,Type,"OBJECTNAME");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PUBLIC");
	list.SetItemText(nItem,Data,object_name(obj->parent));

	nItem = list.InsertItem(list.GetItemCount(),"rank");
	list.SetItemText(nItem,Type,"OBJECTRANK");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PUBLIC");
	sprintf(buffer,"%d",obj->rank);
	list.SetItemText(nItem,Data,buffer);

	nItem = list.InsertItem(list.GetItemCount(),"in_svc");
	list.SetItemText(nItem,Type,"TIMESTAMP");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PUBLIC");
	list.SetItemText(nItem,Data,convert_from_timestamp(obj->in_svc,buffer,sizeof(buffer))?buffer:"");

	nItem = list.InsertItem(list.GetItemCount(),"out_svc");
	list.SetItemText(nItem,Type,"TIMESTAMP");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PUBLIC");
	list.SetItemText(nItem,Data,convert_from_timestamp(obj->out_svc,buffer,sizeof(buffer))?buffer:"");

	nItem = list.InsertItem(list.GetItemCount(),"latitude");
	list.SetItemText(nItem,Type,"double");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PUBLIC");
	list.SetItemText(nItem,Data,convert_from_latitude(obj->latitude,buffer,sizeof(buffer))?buffer:"");

	nItem = list.InsertItem(list.GetItemCount(),"longitude");
	list.SetItemText(nItem,Type,"double");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PUBLIC");
	list.SetItemText(nItem,Data,convert_from_latitude(obj->longitude,buffer,sizeof(buffer))?buffer:"");

	nItem = list.InsertItem(list.GetItemCount(),"flags");
	list.SetItemText(nItem,Type,"set");
	list.SetItemText(nItem,Class,"OBJECTHDR");
	list.SetItemText(nItem,Access,"PROTECTED");
	list.SetItemText(nItem,Data,convert_from_set(buffer,sizeof(buffer),&(obj->flags),object_flag_property())?buffer:"");

	for (oclass=obj->oclass; oclass!=NULL; oclass=oclass->parent)
	{
		list.InsertItem(list.GetItemCount(),"");
		for (prop=class_get_first_property(oclass); prop!=NULL; prop=class_get_next_property(prop))
		{
			nItem = list.InsertItem(list.GetItemCount(),prop->name);
			list.SetItemText(nItem,Type,class_get_property_typename(prop->ptype));
			list.SetItemText(nItem,Class,oclass->name);
			list.SetItemText(nItem,Access,convert_from_enumeration(buffer,sizeof(buffer),&(prop->access),object_access_property())?buffer:"");
			list.SetItemText(nItem,Data,object_get_value_by_name(obj,prop->name,buffer,sizeof(buffer))?buffer:"(error)");
			list.SetItemText(nItem,Description,prop->description);
		}
	};
}
Exemple #28
0
static string dump_object(object obj)
{
    return "<" + object_name(obj) + ">";
}
Exemple #29
0
static void print_item(int n, int fg, int bg)
{
	_text->print_text(object_name(intobj[n]), 0, n % 2 ? 39 - strlen(object_name(intobj[n])) : 1,
			(n / 2) + 2, 40, fg, bg);
}
sn_coap_hdr_s* M2MResource::handle_post_request(nsdl_s *nsdl,
                                                sn_coap_hdr_s *received_coap_header,
                                                M2MObservationHandler */*observation_handler*/,
                                                bool &/*execute_value_updated*/)
{
    tr_debug("M2MResource::handle_post_request()");
    sn_coap_msg_code_e msg_code = COAP_MSG_CODE_RESPONSE_CHANGED; // 2.04
    sn_coap_hdr_s * coap_response = sn_nsdl_build_response(nsdl,
                                                           received_coap_header,
                                                           msg_code);
    // process the POST if we have registered a callback for it
    if(received_coap_header) {
        if ((operation() & SN_GRS_POST_ALLOWED) != 0) {
            M2MResource::M2MExecuteParameter *exec_params = new M2MResource::M2MExecuteParameter();
            if (exec_params) {
                exec_params->_object_name = object_name();
                exec_params->_resource_name = name();
                exec_params->_object_instance_id = object_instance_id();
            }
            uint16_t coap_content_type = 0;
            if(received_coap_header->payload_ptr) {
                if(received_coap_header->content_type_ptr) {
                    for(uint8_t i = 0; i < received_coap_header->content_type_len; i++) {
                        coap_content_type = (coap_content_type << 8) + (received_coap_header->content_type_ptr[i] & 0xFF);
                    }
                }
                if(coap_content_type == 0) {
                    if (exec_params){
                        exec_params->_value = alloc_string_copy(received_coap_header->payload_ptr,
                                                                received_coap_header->payload_len);
                        if (exec_params->_value) {
                            exec_params->_value_length = received_coap_header->payload_len;
                        }
                    }
                } else {
                    msg_code = COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT;
                }
            }
            if(COAP_MSG_CODE_RESPONSE_CHANGED == msg_code) {
                tr_debug("M2MResource::handle_post_request - Execute resource function");
                execute(exec_params);
                if(_delayed_response) {
                    coap_response->msg_type = COAP_MSG_TYPE_ACKNOWLEDGEMENT;
                    coap_response->msg_code = COAP_MSG_CODE_EMPTY;
                    coap_response->msg_id = received_coap_header->msg_id;
                    if(received_coap_header->token_len) {
                        free(_delayed_token);
                        _delayed_token_len = 0;

                        _delayed_token = alloc_copy(received_coap_header->token_ptr, _delayed_token_len);
                        if(_delayed_token) {
                            _delayed_token_len = received_coap_header->token_len;
                        }
                    }
                } else {
                    uint32_t length = 0;
                    get_value(coap_response->payload_ptr, length);
                    coap_response->payload_len = length;
                }
            }
            delete exec_params;
        } else { // if ((object->operation() & SN_GRS_POST_ALLOWED) != 0)
            tr_error("M2MResource::handle_post_request - COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED");
            msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; // 4.05
        }
    } else { //if(object && received_coap_header)
        tr_error("M2MResource::handle_post_request - COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED");
        msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; // 4.01
    }
    if(coap_response) {
        coap_response->msg_code = msg_code;
    }
    return coap_response;
}