예제 #1
0
파일: object.c 프로젝트: f1vefour/djmount
/*****************************************************************************
 * _Object_IsA
 *****************************************************************************/
bool
_Object_IsA (const void* const objptr, const Object_Class* searched_class)
{
	if (objptr && searched_class) {
		const Object* const obj = (const Object*) objptr;
		const Object_Class* const objclass = OBJECT_GET_CLASS(obj);

		if (objclass == NULL || objclass->magic != CLASS_MAGIC) {
			Log_Printf (LOG_ERROR, 
				    "Object_IsA : not an object ; "
				    "memory might be corrupted !!");
			return false; // ---------->
		}
    
#if 0
		Log_Printf (LOG_DEBUG, "Object_IsA : '%s' isa '%s' ?", 
			    NN(objclass->name), NN(searched_class->name));
#endif

		register const Object_Class* c = objclass;
		while (c) {
			if (c == searched_class)
				return true; // ---------->
			c = c->super;
		}  
		
		Log_Printf (LOG_ERROR, "Object_IsA : '%s' is not a '%s' ", 
			    NN(objclass->name), NN(searched_class->name));
	}
	return false;
}
예제 #2
0
파일: icontainer.c 프로젝트: jcupitt/nip2
static void 
icontainer_real_current( iContainer *parent, iContainer *child )
{
	iContainer *old_current;

	g_assert( IS_ICONTAINER( parent ) );
	g_assert( !child || IS_ICONTAINER( child ) );
	g_assert( !child || ICONTAINER_IS_CHILD( parent, child ) );

#ifdef DEBUG
	printf( "icontainer_real_current: parent %s \"%s\"; "
		"child %s \"%s\"\n", 
		G_OBJECT_TYPE_NAME( parent ), NN( IOBJECT( parent )->name ),
		child ? G_OBJECT_TYPE_NAME( child ) : "NULL", 
		child ? NN( IOBJECT( child )->name ) : "NULL" );
#endif /*DEBUG*/

	old_current = parent->current;
	parent->current = child;

	if( old_current != child ) {
		if( old_current )
			iobject_changed( IOBJECT( old_current ) );
		if( child )
			iobject_changed( IOBJECT( child ) );
		iobject_changed( IOBJECT( parent ) );
	}

	if( child )
		model_front( MODEL( child ) );
}
예제 #3
0
Cell *setsymtab(const char *n, const char *s, Awkfloat f, unsigned t, Array *tp)
{
	int h;
	Cell *p;

	if (n != NULL && (p = lookup(n, tp)) != NULL) {
		   dprintf( ("setsymtab found %p: n=%s s=\"%s\" f=%g t=%o\n",
			(void*)p, NN(p->nval), NN(p->sval), p->fval, p->tval) );
		return(p);
	}
	p = (Cell *) malloc(sizeof(Cell));
	if (p == NULL)
		FATAL("out of space for symbol table at %s", n);
	p->nval = tostring(n);
	p->sval = s ? tostring(s) : tostring("");
	p->fval = f;
	p->tval = t;
	p->csub = CUNK;
	p->ctype = OCELL;
	tp->nelem++;
	if (tp->nelem > FULLTAB * tp->size)
		rehash(tp);
	h = hash(n, tp->size);
	p->cnext = tp->tab[h];
	tp->tab[h] = p;
	   dprintf( ("setsymtab set %p: n=%s s=\"%s\" f=%g t=%o\n",
		(void*)p, p->nval, p->sval, p->fval, p->tval) );
	return(p);
}
예제 #4
0
void process_colors()
{
    for (int i = 0; metadata_attr_by_object_type[i] != NULL; ++i)
    {
        sai_object_type_t ot = (sai_object_type_t)i;

        bool is_source = source.find(ot) != source.end();
        bool is_target = target.find(ot) != target.end();


        if (is_source && is_target)
        {
            // node is target and source, so it's in the middle
            std::cout << NN(ot) << " [color=\"0.650 0.500 1.000\"];\n";
        }
        else if (is_target)
        {
            // this node is a leaf
            std::cout << NN(ot) << " [color=\"0.355 0.563 1.000\", shape = rect];\n";

        }
        else if (is_source)
        {
            std::cout << NN(ot) << " [color=\"0.650 0.200 1.000\"];\n";
        }
        else
        {
            if (ot == SAI_OBJECT_TYPE_NULL || ot == SAI_OBJECT_TYPE_MAX)
            {
                continue;
            }
            std::cout << NN(ot) << " [color=plum, shape = rect];\n";
        }
    }
}
예제 #5
0
char *setsval(Cell *vp, const char *s)	/* set string val of a Cell */
{
	char *t;
	int fldno;

	   dprintf( ("starting setsval %p: %s = \"%s\", t=%o, r,f=%d,%d\n", 
		(void*)vp, NN(vp->nval), s, vp->tval, donerec, donefld) );
	if ((vp->tval & (NUM | STR)) == 0)
		funnyvar(vp, "assign to");
	if (isfld(vp)) {
		donerec = 0;	/* mark $0 invalid */
		fldno = atoi(vp->nval);
		if (fldno > *NF)
			newfld(fldno);
		   dprintf( ("setting field %d to %s (%p)\n", fldno, s, s) );
	} else if (isrec(vp)) {
		donefld = 0;	/* mark $1... invalid */
		donerec = 1;
	}
	t = tostring(s);	/* in case it's self-assign */
	if (freeable(vp))
		xfree(vp->sval);
	vp->tval &= ~NUM;
	vp->tval |= STR;
	vp->tval &= ~DONTFREE;
	   dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n", 
		(void*)vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );
	return(vp->sval = t);
}
예제 #6
0
파일: icontainer.c 프로젝트: jcupitt/nip2
static void 
icontainer_real_child_remove( iContainer *parent, iContainer *child )
{
	iContainerClass *icontainer_child_class = ICONTAINER_GET_CLASS( child );

	g_assert( IS_ICONTAINER( parent ) && IS_ICONTAINER( child ) );

#ifdef DEBUG
	printf( "icontainer_real_child_remove: parent %s \"%s\"; "
		"child %s \"%s\"\n", 
		G_OBJECT_TYPE_NAME( parent ), NN( IOBJECT( parent )->name ),
		G_OBJECT_TYPE_NAME( child ), NN( IOBJECT( child )->name ) );
#endif /*DEBUG*/

	if( parent->current == child )
		icontainer_current( parent, NULL ); 

	/* We're about to break the link ... trigger the parent_remove() on 
	 * the child.
	 */
	icontainer_child_class->parent_remove( child );

	icontainer_unlink( child ); 

	UNREF( child );

	iobject_changed( IOBJECT( parent ) );
}
예제 #7
0
static void *
print_field_fn( IMAGE *im, const char *field, GValue *value )
{
	const char *extra;
	char *str_value;

	str_value = g_strdup_value_contents( value );
	printf( "%s: %s", field, str_value );
	g_free( str_value );

	/* Replace NULL static strings with "(null)".
	 */
#define NN( X ) ((X) ? (X) : "(null)")

	/* Look for known enums and decode them.
	 */
	extra = NULL;
	if( strcmp( field, "Coding" ) == 0 )
		extra = NN( im_Coding2char( g_value_get_int( value ) ) );
	else if( strcmp( field, "BandFmt" ) == 0 )
		extra = NN( im_BandFmt2char( g_value_get_int( value ) ) );
	else if( strcmp( field, "Type" ) == 0 )
		extra = NN( im_Type2char( g_value_get_int( value ) ) );
	else if( strcmp( field, "Compression" ) == 0 )
		extra = NN( im_Compression2char( g_value_get_int( value ) ) );

	if( extra )
		printf( " - %s", extra );

	printf( "\n" );

	return( NULL );
}
예제 #8
0
파일: gf_packet.c 프로젝트: bf4/pidgin-mac
GList *gfire_read_buddy_status(PurpleConnection *gc, int packet_len)
{
	int index = XFIRE_HEADER_LEN + 1;
	int itmp = 0;
	GList *btmp = NULL;
	gfire_buddy *gf_buddy = NULL;
	GList *ret = NULL;
	GList *sids = NULL;
	GList *msgs = NULL;
	GList *s, *m; 
	gfire_data *gfire = (gfire_data *)gc->proto_data;

	itmp = gfire_read_attrib(&sids, gfire->buff_in + index, packet_len - index, "sid", FALSE, TRUE, 0, 0, 
							XFIRE_SID_LEN);
	if (itmp < 1 ) {
//FIXME add mem cleanup code
FIXME("gfire_read_attrib returned < 1! sids");
		return NULL;
	}	
	index += itmp + 1;
	itmp = gfire_read_attrib(&msgs, gfire->buff_in + index, packet_len - index, "msg", TRUE, FALSE, 0, 0, 0);
	if (itmp < 1 ) {
//FIXME add mem cleanup code
FIXME("gfire_read_attrib returned < 1! msgs");
		return NULL;
	}	

	msgs = g_list_first(msgs); sids = g_list_first(sids);
	m = msgs; s = sids;
	
	while ( NULL != s ){
		btmp = gfire_find_buddy_in_list(gfire->buddies, s->data, GFFB_SIDBIN);
		if (NULL == btmp) {
			purple_debug(PURPLE_DEBUG_MISC, "gfire", "WARN: pkt 154: (away status) could not find sid in buddy list.\n");
		} else {
			gf_buddy = (gfire_buddy *)btmp->data;
			if (NULL != m->data) {
				/* got an away message */
				gf_buddy->away = TRUE;
				gf_buddy->away_msg = m->data;
			} else {
				/* no message, user is back */
				gf_buddy->away = FALSE;
				if (NULL != gf_buddy->away_msg) g_free(gf_buddy->away_msg);
				gf_buddy->away_msg = NULL;
			}
			ret = g_list_append(ret, (gpointer *)gf_buddy);

			purple_debug(PURPLE_DEBUG_MISC, "gfire","(away): %s, is away/back with msg %s\n",
						NN(gf_buddy->name), NN(gf_buddy->away_msg));
		}
		g_free(s->data);
		s->data = NULL;
		s = g_list_next(s); m = g_list_next(m);
	}
	g_list_free(msgs);
	g_list_free(sids);
	return ret;
}
예제 #9
0
void gfire_chat_proto_user_join(gfire_data *p_gfire, guint16 p_packet_len)
{
	if(!p_gfire)
		return;

	guint32 offset = XFIRE_HEADER_LEN;

	guint8 *chat_id = NULL;
	gfire_chat *chat = NULL;
	guint32 userid = 0;
	gchar *name = NULL;
	gchar *nick = NULL;
	guint32 perm = 0;
	gfire_buddy *gf_buddy = NULL;

	offset = gfire_proto_read_attr_chatid_bs(p_gfire->buff_in, &chat_id, 0x04, offset);
	if(offset == -1 || !chat_id)
		return;

	chat = gfire_find_chat(p_gfire, chat_id, GFFC_CID);
	if(!chat)
	{
		g_free(chat_id);
		purple_debug_error("gfire", "gfire_chat_proto_user_leave: Unknown chat id!\n");
		return;
	}

	g_free(chat_id);

	offset = gfire_proto_read_attr_int32_bs(p_gfire->buff_in, &userid, 0x01, offset);
	if(offset == -1)
		return;

	offset = gfire_proto_read_attr_string_bs(p_gfire->buff_in, &name, 0x02, offset);
	if(offset == -1 || !name)
	{
		return;
	}

	offset = gfire_proto_read_attr_string_bs(p_gfire->buff_in, &nick, 0x0D, offset);
	if(offset == -1 || !nick)
	{
		g_free(name);
		return;
	}

	offset = gfire_proto_read_attr_int32_bs(p_gfire->buff_in, &perm, 0x12, offset);
	if(offset == -1)
		return;

	gf_buddy = gfire_buddy_create(userid, name, nick, GFBT_GROUPCHAT);
	gfire_chat_add_user(chat, gf_buddy, perm, TRUE);

	purple_debug(PURPLE_DEBUG_MISC, "gfire", "groupchat join, userid: %u, username: %s, alias: %s\n",
				 userid, NN(name), NN(nick));

	g_free(name);
	g_free(nick);
}
예제 #10
0
파일: content_dir.c 프로젝트: Boxee/djmount
/*****************************************************************************
 * ContentDir_Search
 *****************************************************************************/
const ContentDir_BrowseResult*
ContentDir_Search (ContentDir* cds, void* result_context, 
		   const char* objectId, const char* criteria)
{
	Log_Printf (LOG_DEBUG, "ContentDir_Search objectId='%s' criteria='%s'",
		    NN(objectId), NN(criteria));
	return BrowseOrSearchWithCache (cds, result_context, 
					objectId, criteria);
}
예제 #11
0
void tfree(Cell *a)	/* free a tempcell */
{
	if (freeable(a)) {
		   dprintf( ("freeing %s %s %o\n", NN(a->nval), NN(a->sval), a->tval) );
		xfree(a->sval);
	}
	if (a == tmps)
		FATAL("tempcell list is curdled");
	a->cnext = tmps;
	tmps = a;
}
예제 #12
0
파일: icontainer.c 프로젝트: jcupitt/nip2
static void
icontainer_real_parent_add( iContainer *child )
{
#ifdef DEBUG
	printf( "icontainer_real_parent_add: child %s \"%s\"; " 
		"parent %s \"%s\"\n", 
		G_OBJECT_TYPE_NAME( child ), 
		NN( IOBJECT( child )->name ),
		G_OBJECT_TYPE_NAME( child->parent ), 
		NN( IOBJECT( child->parent )->name ) );
#endif /*DEBUG*/
}
예제 #13
0
파일: icontainer.c 프로젝트: jcupitt/nip2
static void
icontainer_real_parent_remove( iContainer *child )
{
#ifdef DEBUG
{
	iContainer *parent = child->parent;

	printf( "icontainer_real_parent_remove: child %s \"%s\"; "
		"parent %s \"%s\"\n", 
		G_OBJECT_TYPE_NAME( child ), NN( IOBJECT( child )->name ),
		G_OBJECT_TYPE_NAME( parent ), NN( IOBJECT( parent )->name ) );
}
#endif /*DEBUG*/
}
예제 #14
0
파일: content_dir.c 프로젝트: Boxee/djmount
/*****************************************************************************
 * ContentDir_GetSearchCapabilities
 *****************************************************************************/
const char*
ContentDir_GetSearchCapabilities (ContentDir* self, void* unused)
{
	if (self == NULL)
		return NULL; // ---------->
	
	// Send Action if result not already cached
	if (self->search_caps == NULL) {

		IXML_Document* doc = NULL;
		int rc = Service_SendActionVa
			(OBJECT_SUPER_CAST(self), &doc,
			 "GetSearchCapabilities",
			 NULL, NULL);
		if (rc == UPNP_E_SUCCESS && doc != NULL) {
			self->search_caps = talloc_strdup 
				(self, XMLUtil_FindFirstElementValue
				 (XML_D2N (doc), "SearchCaps", true, true));
			
			Log_Printf (LOG_DEBUG, 
				    "ContentDir_GetSearchCapabilities = '%s'",
				    NN(self->search_caps));
		}
		ixmlDocument_free (doc);
	}
	
	return self->search_caps;
}
예제 #15
0
static char *get_str_val(Cell *vp, char **fmt)        /* get string val of a Cell */
{
	char s[100];	/* BUG: unchecked */
	double dtemp;

	if ((vp->tval & (NUM | STR)) == 0)
		funnyvar(vp, "read value of");
	if (isfld(vp) && donefld == 0)
		fldbld();
	else if (isrec(vp) && donerec == 0)
		recbld();
	if (isstr(vp) == 0) {
		if (freeable(vp))
			xfree(vp->sval);
		if (modf(vp->fval, &dtemp) == 0)	/* it's integral */
			sprintf(s, "%.30g", vp->fval);
		else
			sprintf(s, *fmt, vp->fval);
		vp->sval = tostring(s);
		vp->tval &= ~DONTFREE;
		vp->tval |= STR;
	}
	   dprintf( ("getsval %p: %s = \"%s (%p)\", t=%o\n",
		(void*)vp, NN(vp->nval), vp->sval, vp->sval, vp->tval) );
	return(vp->sval);
}
예제 #16
0
파일: workspace.c 프로젝트: imclab/nip2
void
workspace_set_needs_layout( Workspace *ws, gboolean needs_layout )
{
#ifdef DEBUG
	printf( "workspace_set_needs_layout: %p %s %d\n", 
		ws, NN( IOBJECT( ws )->name ), needs_layout );
#endif /*DEBUG*/

	if( !ws->needs_layout && 
		needs_layout &&
		!ws->in_dispose ) { 
		g_assert( !g_slist_find( workspace_needs_layout, ws ) ); 

		ws->needs_layout = TRUE;
		workspace_needs_layout = g_slist_prepend( 
			workspace_needs_layout, ws ); 
	}

	if( ws->needs_layout && !needs_layout ) { 
		g_assert( g_slist_find( workspace_needs_layout, ws ) ); 

		ws->needs_layout = FALSE;
		workspace_needs_layout = g_slist_remove( 
			workspace_needs_layout, ws ); 
	}
}
예제 #17
0
파일: icontainer.c 프로젝트: jcupitt/nip2
void 
icontainer_current( iContainer *parent, iContainer *child )
{
	g_assert( parent );
	g_assert( !child || ICONTAINER_IS_CHILD( parent, child ) );

	if( parent->current == child )
		return; 

#ifdef DEBUG
	printf( "icontainer_current: (child %p)\n", child );
	printf( "\tchild: %s \"%s\"\n",
		G_OBJECT_TYPE_NAME( child ), 
		NN( IOBJECT( child )->name ) );
#endif /*DEBUG*/

#ifdef DEBUG_SANITY
	icontainer_sanity( parent );
	if( child )
		icontainer_sanity( child );
#endif /*DEBUG_SANITY*/

	g_signal_emit( G_OBJECT( parent ), 
		icontainer_signals[SIG_CURRENT], 0, child );

#ifdef DEBUG_SANITY
	icontainer_sanity( parent );
	if( child )
		icontainer_sanity( child );
#endif /*DEBUG_SANITY*/
}
예제 #18
0
//TSP -> NN -> Generations( g, ForkJoin ( n, SA -> 2-OPT ) ) -> TSP'
void Pipeline1(tsp_class& tsp_instance, unsigned int number_of_tasks, unsigned int number_of_generations)
{
	#pragma region "PipelineConfiguration"
	auto a = Args<General_args_type>(make_General_args(number_of_generations, number_of_tasks));
	auto sa = Args<SA_args_type>(make_SA_args(1000.0, 0.00001, 0.999, 400));
	auto aco = Args<ACO_args_type>();
	auto ga = Args<GA_args_type>();

	const char* pipeline_description = "TSP -> NN -> Generations( g, ForkJoin ( n, SA -> 2-OPT ) ) -> TSP'";
	display_args(pipeline_description, a, sa, aco, ga);
	
	auto g = a[0].number_of_iterations_or_generations;
	auto n = a[0].number_of_tasks_in_parallel;
	auto _TSP = TSP(just(tsp_instance));
	auto _DisplayInput = Display("TSP INPUT", DisplayFlags::All);
	auto _NN = Measure(NN(), Display("NEAREST NEIGHBOUR", DisplayFlags::EmitMathematicaGraphPlot));	
	auto _SA_2OPT = Chain(SA(sa[0].initial_temperature, sa[0].stopping_criteria_temperature, 
							 sa[0].decreasing_factor, sa[0].monte_carlo_steps), _2OPT());
	auto _ForkJoin = [](unsigned int n, TSP::transformer_type map_fun){ return Measure(ForkJoin(n, map_fun)); };
	auto _DisplayOutput = Display("TSP OUTPUT", DisplayFlags::EmitMathematicaGraphPlot); 
	#pragma endregion

	//TSP -> NN -> Generations( g, ForkJoin ( n, SA -> 2-OPT ) ) -> TSP'
	auto result = _TSP
					.map(_DisplayInput)
					.map(_NN)
					.map(Generations(g, _ForkJoin(n, _SA_2OPT)))
					.map(_DisplayOutput);
}
예제 #19
0
Awkfloat setfval(Cell *vp, Awkfloat f)	/* set float val of a Cell */
{
	int fldno;

	if ((vp->tval & (NUM | STR)) == 0) 
		funnyvar(vp, "assign to");
	if (isfld(vp)) {
		donerec = 0;	/* mark $0 invalid */
		fldno = atoi(vp->nval);
		if (fldno > *NF)
			newfld(fldno);
		   dprintf( ("setting field %d to %g\n", fldno, f) );
	} else if (isrec(vp)) {
		donefld = 0;	/* mark $1... invalid */
		donerec = 1;
	}
	if (freeable(vp))
		xfree(vp->sval); /* free any previous string */
	vp->tval &= ~STR;	/* mark string invalid */
	vp->tval |= NUM;	/* mark number ok */
	if (f == -0)  /* who would have thought this possible? */
		f = 0;
	   dprintf( ("setfval %p: %s = %g, t=%o\n", (void*)vp, NN(vp->nval), f, vp->tval) );
	return vp->fval = f;
}
예제 #20
0
//TSP -> NN -> Generations( g, ForkJoin ( n, GA -> 2-OPT ) ) -> TSP'
void Pipeline2(tsp_class& tsp_instance, unsigned int number_of_tasks, 
			                            unsigned int number_of_generations)
{
	#pragma region "PipelineConfiguration"
	auto a = Args<General_args_type>(make_General_args(number_of_generations, number_of_tasks));
	auto sa = Args<SA_args_type>();
	auto aco = Args<ACO_args_type>();
	auto ga = Args<GA_args_type>(make_GA_args(1000, 10, 5, 50000, 10, 0.9));

	const char* pipeline_description = "TSP -> NN -> Generations( g, ForkJoin ( n, GA -> 2-OPT ) ) -> TSP'";
	display_args(pipeline_description, a, sa, aco, ga);
	
	auto g = a[0].number_of_iterations_or_generations;
	auto n = a[0].number_of_tasks_in_parallel;
	auto _TSP = TSP(just(tsp_instance));
	auto _DisplayInput = Display("TSP INPUT", DisplayFlags::All);
	auto _NN = Measure(NN(), Display("NEAREST NEIGHBOUR", DisplayFlags::EmitMathematicaGraphPlot));	
	auto _GA_2OPT = Chain(GA(ga[0].population_size, ga[0].mutation_percentage, ga[0].group_size, 
							 ga[0].number_of_generations, ga[0].nearby_cities, ga[0].nearby_cities_percentage), _2OPT());
	auto _ForkJoin = [](unsigned int n, TSP::transformer_type map_fun){ return Measure(ForkJoin(n, map_fun)); };
	auto _DisplayOutput = Display("TSP OUTPUT", DisplayFlags::EmitMathematicaGraphPlot); 
	#pragma endregion

	//TSP -> NN -> Generations( g, ForkJoin ( n, GA -> 2-OPT ) ) -> TSP'
	auto result = _TSP
					.map(_DisplayInput)
					.map(_NN)
					.map(Generations(g, _ForkJoin(n, _GA_2OPT)))
					.map(_DisplayOutput);
}
예제 #21
0
파일: icontainer.c 프로젝트: jcupitt/nip2
void *
icontainer_child_remove( iContainer *child )
{
	iContainer *parent;

	if( (parent = child->parent) ) {
		g_assert( ICONTAINER_IS_CHILD( parent, child ) );

#ifdef DEBUG
		printf( "icontainer_child_remove: (child %p)\n", child );
		printf( "\tchild: %s \"%s\"\n",
			G_OBJECT_TYPE_NAME( child ), 
			NN( IOBJECT( child )->name ) );
#endif /*DEBUG*/

#ifdef DEBUG_SANITY
		icontainer_sanity( parent );
		icontainer_sanity( child );
#endif /*DEBUG_SANITY*/

		g_signal_emit( G_OBJECT( parent ), 
			icontainer_signals[SIG_CHILD_REMOVE], 0, child );

#ifdef DEBUG_SANITY
		icontainer_sanity( parent );
#endif /*DEBUG_SANITY*/
	}

	return( NULL );
}
예제 #22
0
파일: tran.c 프로젝트: mluszczyk/so-minix
Awkfloat setfval(Cell *vp, Awkfloat f)	/* set float val of a Cell */
{
    int fldno;

    f += 0.0;		/* normalise negative zero to positive zero */
    if ((vp->tval & (NUM | STR)) == 0)
        funnyvar(vp, "assign to");
    if (isfld(vp)) {
        donerec = 0;	/* mark $0 invalid */
        fldno = atoi(vp->nval);
        if (fldno > *NF)
            newfld(fldno);
        dprintf( ("setting field %d to %g\n", fldno, f) );
    } else if (&vp->fval == NF) {
        donerec = 0;	/* mark $0 invalid */
        setlastfld(f);
        dprintf( ("setting NF to %g\n", f) );
    } else if (isrec(vp)) {
        donefld = 0;	/* mark $1... invalid */
        donerec = 1;
    }
    if (freeable(vp))
        xfree(vp->sval); /* free any previous string */
    vp->tval &= ~STR;	/* mark string invalid */
    vp->tval |= NUM;	/* mark number ok */
    dprintf( ("setfval %p: %s = %g, t=%o\n", vp, NN(vp->nval), f, vp->tval) );
    return vp->fval = f;
}
예제 #23
0
int main()
{
    std::cout << "digraph \"SAI Object Dependency Graph\" {\n";
    std::cout << "size=\"20,10\"; ratio = fill;\n";
    std::cout << "node [style=filled];\n";

    process_object_types();

    process_manual_connections();

    process_colors();

    std::cout << NN(SAI_OBJECT_TYPE_SWITCH) << " [color=orange, shape = parallelogram, peripheries = 2];\n";
    std::cout << NN(SAI_OBJECT_TYPE_PORT) << " [color=gold, shape = diamond, peripheries=2];\n";

    std::cout << "}\n";
    return 0;
}
예제 #24
0
static void computeLevelset(GModel *gm, cartesianBox<double> &box)
{
  // tolerance for desambiguation
  const double tol = box.getLC() * 1.e-12;
  std::vector<SPoint3> nodes;
  std::vector<int> indices;
  for (cartesianBox<double>::valIter it = box.nodalValuesBegin();
       it != box.nodalValuesEnd(); ++it){
    nodes.push_back(box.getNodeCoordinates(it->first));
    indices.push_back(it->first);
  }
  Msg::Info("  %d nodes in the grid at level %d", (int)nodes.size(), box.getLevel());
  std::vector<double> dist, localdist;
  std::vector<SPoint3> dummy;
  for (GModel::fiter fit = gm->firstFace(); fit != gm->lastFace(); fit++){
    for (int i = 0; i < (*fit)->stl_triangles.size(); i += 3){
      int i1 = (*fit)->stl_triangles[i];
      int i2 = (*fit)->stl_triangles[i + 1];
      int i3 = (*fit)->stl_triangles[i + 2];
      GPoint p1 = (*fit)->point((*fit)->stl_vertices[i1]);
      GPoint p2 = (*fit)->point((*fit)->stl_vertices[i2]);
      GPoint p3 = (*fit)->point((*fit)->stl_vertices[i3]);
      SPoint2 p = ((*fit)->stl_vertices[i1] + (*fit)->stl_vertices[i2] +
                   (*fit)->stl_vertices[i3]) * 0.33333333;
      SVector3 N = (*fit)->normal(p);
      SPoint3 P1(p1.x(), p1.y(), p1.z());
      SPoint3 P2(p2.x(), p2.y(), p2.z());
      SPoint3 P3(p3.x(), p3.y(), p3.z());
      SVector3 NN(crossprod(P2 - P1, P3 - P1));
      if (dot(NN, N) > 0)
	signedDistancesPointsTriangle(localdist, dummy, nodes, P1, P2, P3);
      else
	signedDistancesPointsTriangle(localdist, dummy, nodes, P2, P1, P3);
      if(dist.empty())
        dist = localdist;
      else{
        for (unsigned int j = 0; j < localdist.size(); j++){
          // FIXME: if there is an ambiguity assume we are inside (to
          // avoid holes in the structure). This is definitely just a
          // hack, as it could create pockets of matter outside the
          // structure...
          if(dist[j] * localdist[j] < 0 &&
             fabs(fabs(dist[j]) - fabs(localdist[j])) < tol){
            dist[j] = std::max(dist[j], localdist[j]);
          }
          else{
            dist[j] = (fabs(dist[j]) < fabs(localdist[j])) ? dist[j] : localdist[j];
          }
        }
      }
    }
  }
  for (unsigned int j = 0; j < dist.size(); j++)
    box.setNodalValue(indices[j], dist[j]);

  if(box.getChildBox()) computeLevelset(gm, *box.getChildBox());
}
예제 #25
0
void *routeAnt(void *id) {
	int j, i = (int)id;
	for(j=1;j<ins.dimension;j++){
		if(hasCandidatesLeft(i,ant[i].tour[j-1]))
			moveAntTo(i,j,argMax(i,ant[i].tour[j-1]));
		else
			moveAntTo(i,j,NN(i,j-1));
	}
}
예제 #26
0
파일: midlc.c 프로젝트: OpenSharp/NDceRpc
int
sprint_sym(char *buf, struct sym *sym, int indent, int spacer)
{
	char *bp = buf, *key;
	int i, fill = spacer * 2;
	iter_t iter;

	bp += sprintf(bp, "%3d ", sym->id);

	for (i = 0; i < 15; i++) {
		if ((sym->flags & (1 << i))) {
			*bp++ = FLAGS[i];
		}
	}
	FILL(buf, bp, 9 + indent);
	bp += sprintf(bp, "%s", NN(sym->idl_type));
	FILL(buf, bp, fill); fill += spacer;
	bp += sprintf(bp, "%d ", sym->ptr);
	bp += sprintf(bp, "%c ", PTR_TYPES[sym->ptr_type]);
	bp += sprintf(bp, "%s", NN(sym->name));
	FILL(buf, bp, fill); fill += spacer;
	bp += sprintf(bp, "%s", NN(sym->out_type));
	FILL(buf, bp, fill); fill += spacer / 2;
	bp += sprintf(bp, "%s", NN(sym->ndr_type));
	FILL(buf, bp, fill); fill += spacer;
	bp += sprintf(bp, "%3d %3d %3d ", sym->ndr_size, sym->align, sym->offset);
	bp += sprintf(bp, "(%s) %d ", NN(sym->interface), IS_IMPORTED(sym));

	i = 0;
	hashmap_iterate(&sym->attrs, &iter);
	while ((key = hashmap_next(&sym->attrs, &iter))) {
		const char *val = hashmap_get(&sym->attrs, key);
		if (i++) {
			*bp++ = ',';
		}
		if (key == val) {
			bp += sprintf(bp, "%s", key);
		} else {
			bp += sprintf(bp, "%s=%s", key, val);
		}
	}

	return bp - buf;
}
예제 #27
0
파일: upnp_util.c 프로젝트: Boxee/djmount
/******************************************************************************
 * UpnpUtil_ResolveURL
 *****************************************************************************/
char*
UpnpUtil_ResolveURL (void* talloc_context, 
		     const char* base, const char* rel)
{
	// Warning : must add +2 (and not +1) to have a large enough buffer,
	// to be consistent with resolve_rel_url() in 
	// libupnp/upnp/src/genlib/net/uri/uri.c !
	char resolved [(base ? strlen(base):0) + (rel ? strlen(rel):0) + 2];

	resolved[0] = '\0';
	if (rel && *rel) {
		int rc = UpnpResolveURL (base, rel, resolved);
		if (rc != UPNP_E_SUCCESS) {
			Log_Printf (LOG_ERROR, 
				    "Error generating URL from '%s' + '%s'",
				    NN(base), NN(rel));
			resolved[0] = '\0';
		}
	}
	return talloc_strdup (talloc_context, resolved);
}
예제 #28
0
파일: tran.c 프로젝트: mluszczyk/so-minix
Awkfloat getfval(Cell *vp)	/* get float val of a Cell */
{
    if ((vp->tval & (NUM | STR)) == 0)
        funnyvar(vp, "read value of");
    if (isfld(vp) && donefld == 0)
        fldbld();
    else if (isrec(vp) && donerec == 0)
        recbld();
    if (!isnum(vp)) {	/* not a number */
        vp->fval = atof(vp->sval);	/* best guess */
        if (is_number(vp->sval) && !(vp->tval&CON))
            vp->tval |= NUM;	/* make NUM only sparingly */
    }
    dprintf( ("getfval %p: %s = %g, t=%o\n", vp, NN(vp->nval), vp->fval, vp->tval) );
    return(vp->fval);
}
예제 #29
0
//TSP -> NN -> Generations( g, ForkJoin ( n, ACO -> 2-OPT ) ) -> TSP'
void Pipeline3(tsp_class& tsp_instance, unsigned int number_of_tasks, 
			                            unsigned int number_of_generations)
{
	#pragma region "PipelineConfiguration"
	auto a = Args<General_args_type>(make_General_args(number_of_generations, number_of_tasks));
	auto sa = Args<SA_args_type>();
	auto ga = Args<GA_args_type>();

	const int aco_iterations = static_cast<int>(tsp_instance.cities.size() * 100);
	const ants_type::size_type number_of_ants = tsp_instance.cities.size();
	const double BASE_PHEROMONE = 1.0f / static_cast<double>(tsp_instance.cities.size());
	const double ALPHA = 1.0;
	const double BETA  = 1.0;
	const double RHO   = 0.9;
	const double QVAL  = 70;
	auto aco = Args<ACO_args_type>(make_ACO_args(aco_iterations, number_of_ants, 
								   BASE_PHEROMONE, ALPHA, BETA, RHO, QVAL));	

	const char* pipeline_description = "TSP -> NN -> Generations( g, ForkJoin ( n, ACO -> 2-OPT ) ) -> TSP'";
	display_args(pipeline_description, a, sa, aco, ga);
	
	auto g = a[0].number_of_iterations_or_generations;
	auto n = a[0].number_of_tasks_in_parallel;
	auto _TSP = TSP(just(tsp_instance));
	auto _DisplayInput = Display("TSP INPUT", DisplayFlags::All);
	auto _NN = Measure(NN(), Display("NEAREST NEIGHBOUR", DisplayFlags::EmitMathematicaGraphPlot));	
	auto _ACO_2OPT = Chain(ACO(aco[0].aco_iterations, aco[0].number_of_ants, aco[0].base_pheromone, 
								aco[0].favor_pheromone_level_over_distance, 
								aco[0].favor_distance_over_pheromone_level, 
								aco[0].value_for_intensification_and_evaporation, 
								aco[0].pheronome_distribution), _2OPT());
	auto _ForkJoin = [](unsigned int n, TSP::transformer_type map_fun){ return Measure(ForkJoin(n, map_fun)); };
	auto _DisplayOutput = Display("TSP OUTPUT", DisplayFlags::EmitMathematicaGraphPlot); 
	#pragma endregion

	//TSP -> NN -> Generations( g, ForkJoin ( n, ACO -> 2-OPT ) ) -> TSP'
	auto result = _TSP
					.map(_DisplayInput)
					.map(_NN)
					.map(Generations(g, _ForkJoin(n, _ACO_2OPT)))
					.map(_DisplayOutput);
}
예제 #30
0
파일: gf_packet.c 프로젝트: bf4/pidgin-mac
/* reads session information from intial login grabs our info */
void gfire_packet_130(PurpleConnection *gc, int packet_len)
{
	gfire_data *gfire = NULL;
	int index = XFIRE_HEADER_LEN + 1;
	char tmp[100] = "";
	guint16 slen = 0;


	if (!gc || !(gfire = (gfire_data *)gc->proto_data)) return;
	memcpy(tmp, gfire->buff_in + index, strlen("userid"));
	tmp[strlen("userid")] = 0x00;
	index += strlen("userid") + 1;
	if (0 == g_ascii_strcasecmp("userid", tmp)) {
		if (!gfire->userid) g_free(gfire->userid);
		gfire->userid = g_malloc0(XFIRE_USERID_LEN);
		memcpy(gfire->userid, gfire->buff_in + index, XFIRE_USERID_LEN);
		index += XFIRE_USERID_LEN + 1;
	} else {
		purple_debug(PURPLE_DEBUG_MISC, "gfire", "ERROR: pkt 130: userid not in correct position.\n");
		return;
	}
	index += 4;
	if (!gfire->sid) g_free(gfire->sid);
	gfire->sid = g_malloc0(XFIRE_SID_LEN);
	memcpy(gfire->sid, gfire->buff_in + index, XFIRE_SID_LEN);
	index += XFIRE_SID_LEN +6;

	memcpy(&slen, gfire->buff_in + index, sizeof(slen));
	index += sizeof(slen);
	slen = GUINT16_FROM_LE(slen);
	if (NULL != gfire->alias) g_free(gfire->alias);
	gfire->alias = g_malloc0(slen + 1);
	memcpy(gfire->alias, gfire->buff_in + index, slen);
	if (slen > 0) gfire->alias[slen] = 0x00;

	purple_debug(PURPLE_DEBUG_MISC, "gfire", "(session): Our userid = %02x%02x%02x%02x, Our Alias = %s\n",
			NNA(gfire->userid, gfire->userid[0]), NNA(gfire->userid, gfire->userid[1]),
			NNA(gfire->userid, gfire->userid[2]), NNA(gfire->userid, gfire->userid[3]), NN(gfire->alias) );
// FIXME("gfire_packet_130");
}