Esempio n. 1
0
/*
 * Discard all of the font information, e.g., we are resizing the font.
 * Keep the GC's so we can simply change them rather than creating new ones.
 */
void
clrCgsFonts(XtermWidget xw, VTwin *cgsWin, XTermFonts * font)
{
    CgsCache *me;
    int j, k;

    if (HaveFont(font)) {
        for_each_gc(j) {
            if ((me = myCache(xw, cgsWin, (CgsEnum) j)) != 0) {
                for (k = 0; k < DEPTH; ++k) {
                    if (SameFont(LIST(k).font, font)) {
                        TRACE2(("clrCgsFonts %s gc %p(%d) %s\n",
                                traceCgsEnum((CgsEnum) j),
                                LIST(k).gc,
                                k,
                                traceFont(font)));
                        LIST(k).font = 0;
                        LIST(k).cset = 0;
                    }
                }
                if (SameFont(NEXT(font), font)) {
                    TRACE2(("clrCgsFonts %s next %s\n",
                            traceCgsEnum((CgsEnum) j),
                            traceFont(font)));
                    NEXT(font) = 0;
                    NEXT(cset) = 0;
                    me->mask &= (unsigned) ~(GCFont | GC_CSet);
                }
            }
        }
    }
}
Esempio n. 2
0
void    font_drop_one(DviFontRef *ref)
{
    DviFont *font;
    
    font = ref->ref;
    mdvi_free(ref);
    /* drop all children */
    for(ref = font->subfonts; ref; ref = ref->next) {
        /* just adjust the reference counts */
        ref->ref->links--;
    }
    if(--font->links == 0) {
        /* 
         * this font doesn't have any more references, but
         * we still keep it around in case a virtual font
         * requests it.
         */
        if(font->in) {
            fclose(font->in);
            font->in = NULL;
        }
        if(LIST(font) != fontlist.tail) {
            /* move it to the end of the list */
            listh_remove(&fontlist, LIST(font));
            listh_append(&fontlist, LIST(font));
        }
    }
    DEBUG((DBG_FONTS, "%s: reference dropped, %d more left\n",
        font->fontname, font->links));
}
Esempio n. 3
0
/*
 * la_activity() caller.  Traverse through all audit libraries and call any
 * la_activity() entry points found.
 */
static void
_audit_activity(APlist *list, Rt_map *clmp, uint_t flags, Boolean client)
{
	Audit_list	*alp;
	Aliste		idx;
	Lm_list		*clml = LIST(clmp);

	for (APLIST_TRAVERSE(list, idx, alp)) {
		Audit_client	*acp;
		Rt_map		*almp = alp->al_lmp;
		Lm_list		*alml = LIST(almp);
		uintptr_t	*cookie;

		if (alp->al_activity == 0)
			continue;

		/*
		 * Determine what cookie is required.  Any auditing that
		 * originates from the object that heads the link-map list has
		 * its own cookie.  Local auditors must obtain the cookie that
		 * represents the object that heads the link-map list.
		 */
		if (client)
			acp = _audit_client(AUDINFO(clmp), almp);
		else
			acp = _audit_get_head_client(clml->lm_head, almp);

		if (acp == NULL)
			continue;
		cookie = &(acp->ac_cookie);

		/*
		 * Make sure the audit library only sees one addition/deletion
		 * at a time.  This ensures the library doesn't see numerous
		 * events from lazy loading a series of libraries.  Keep track
		 * of this caller having called an auditor, so that the
		 * appropriate "consistent" event can be supplied on leaving
		 * ld.so.1.
		 */
		if ((flags == LA_ACT_ADD) || (flags == LA_ACT_DELETE)) {
			if (alml->lm_flags & LML_FLG_AUDITNOTIFY)
				continue;

			alml->lm_flags |= LML_FLG_AUDITNOTIFY;
			clml->lm_flags |= LML_FLG_ACTAUDIT;
		} else {
			if ((alml->lm_flags & LML_FLG_AUDITNOTIFY) == 0)
				continue;

			alml->lm_flags &= ~LML_FLG_AUDITNOTIFY;
		}

		DBG_CALL(Dbg_audit_activity(clml, alp->al_libname,
		    NAME(clml->lm_head), flags));

		leave(alml, thr_flg_reenter);
		(*alp->al_activity)(cookie, flags);
		(void) enter(thr_flg_reenter);
	}
}
Esempio n. 4
0
/*
 * la_objopen() caller.  Create an audit information structure for the indicated
 * link-map, regardless of an la_objopen() entry point.  This structure is used
 * to supply information to various audit interfaces (see LML_MSK_AUDINFO).
 * Traverses through all audit library and calls any la_objopen() entry points
 * found.
 */
static int
_audit_objopen(List *list, Rt_map *nlmp, Lmid_t lmid, Audit_info *aip,
    int *ndx)
{
	Audit_list	*alp;
	Listnode	*lnp;

	for (LIST_TRAVERSE(list, lnp, alp)) {
		uint_t		flags;
		Audit_client	*acp;

		/*
		 * Associate a cookie with the audit library, and assign the
		 * initial cookie as the present link-map.
		 */
		acp = &aip->ai_clients[(*ndx)++];
		acp->ac_lmp = alp->al_lmp;
		acp->ac_cookie = (uintptr_t)nlmp;

		if (alp->al_objopen == 0)
			continue;

		DBG_CALL(Dbg_audit_object(LIST(alp->al_lmp), alp->al_libname,
		    NAME(nlmp)));

		leave(LIST(alp->al_lmp));
		flags = (*alp->al_objopen)((Link_map *)nlmp, lmid,
			&(acp->ac_cookie));
		(void) enter();

		if (flags & LA_FLG_BINDTO)
			acp->ac_flags |= FLG_AC_BINDTO;

		if (flags & LA_FLG_BINDFROM) {
			ulong_t		pltcnt;

			acp->ac_flags |= FLG_AC_BINDFROM;
			/*
			 * We only need dynamic plt's if a pltenter and/or a
			 * pltexit() entry point exist in one of our auditing
			 * libraries.
			 */
			if (aip->ai_dynplts || (JMPREL(nlmp) == 0) ||
			    ((audit_flags & (AF_PLTENTER | AF_PLTEXIT)) == 0))
				continue;

			/*
			 * Create one dynplt for every 'PLT' that exists in the
			 * object.
			 */
			pltcnt = PLTRELSZ(nlmp) / RELENT(nlmp);
			if ((aip->ai_dynplts = calloc(pltcnt,
			    dyn_plt_ent_size)) == 0)
				return (0);
		}
	}
	return (1);
}
Esempio n. 5
0
//---------------------------------------------------------------------------
void File_Ibi::Data_Parse()
{
    #define LIS2(_ATOM, _NAME) \
        case Elements::_ATOM : \
                if (Level==Element_Level) \
                { \
                    Element_Name(_NAME); \
                    _ATOM(); \
                    Element_ThisIsAList(); \
                } \

    #define ATO2(_ATOM, _NAME) \
                case Elements::_ATOM : \
                        if (Level==Element_Level) \
                        { \
                            if (Element_IsComplete_Get()) \
                            { \
                                Element_Name(_NAME); \
                                _ATOM(); \
                            } \
                            else \
                            { \
                                Element_WaitForMoreData(); \
                                return; \
                            } \
                        } \
                        break; \

    #define ATOM_END_MK \
        ATOM(Zero) \
        ATOM(CRC32) \
        ATOM(Void) \
        ATOM_END

    //Parsing
    DATA_BEGIN
    LIST(Ebml)
        ATOM_BEGIN
        ATOM(Ebml_Version)
        ATOM(Ebml_ReadVersion)
        ATOM(Ebml_MaxIDLength)
        ATOM(Ebml_MaxSizeLength)
        ATOM(Ebml_DocType)
        ATOM(Ebml_DocTypeVersion)
        ATOM(Ebml_DocTypeReadVersion)
        ATOM_END_MK
    LIST(Stream)
        ATOM_BEGIN
            ATOM(Stream_Header)
            ATOM(Stream_ByteOffset)
            ATOM(Stream_FrameNumber)
            ATOM(Stream_Dts)
        ATOM_END_MK
    ATOM(CompressedIndex)
    DATA_DEFAULT
        Finish("Ibi");
    DATA_END_DEFAULT
}
//////////////////////////////////////////////////////////////////////////////
// Get all the ref constraints from this NATable, filter the ones that are to
// tables in this graph, and mark them on both tables. For example, use the
// RI on Orderes and Customers: O->C ( O is referencing C ). Because of the 
// semantics of the order of the tables in the join graph, in order for RI
// optimization to be utilized, C must appear in the graph solution AFTER O.
// The result is that C has an incoming bit for table O, and O has an 
// outgoing bit for table C.
// Other conditions that must be met for the RI to be usable:
// 1. C must have non-empty, insert only delta.
// 2. O must not be inner tables of left joins.
// 3. Each of the columns of the RI constraint must be covered by a predicate.
//    So if O(a,b) is referencing C(x,y) the join should use these two equal 
//    predicates: (O.a = C.x) AND (O.b = C.y).
// In this method, this table is O, and otherTable is C.
Lng32 MVJoinTable::markRiConstraints(BindWA *bindWA, MVInfo *mvInfo)
{
  LIST (MVUsedObjectInfo*)& usedObjects = mvInfo->getUsedObjectsList();
  if (usedObjects[tableIndex_]->isInnerTableOfLeftJoin())
    return 0;	// O must not be inner table of a left join.

  Lng32 howManyRIs=0;
  const AbstractRIConstraintList& refConstraints = 
    naTable_->getRefConstraints();

  for (CollIndex i=0; i<refConstraints.entries(); i++)
  {
    RefConstraint *const ref = (RefConstraint *const)(refConstraints[i]);
    CMPASSERT(ref->getOperatorType() == ITM_REF_CONSTRAINT);
    // Ignore self referencing RIs.
    if (ref->selfRef())
      continue;

    // Find the table the RI is referencing.
    const NAString& otherTableName = 
      ref->getOtherTableName().getQualifiedNameAsString();
    MVJoinTable *otherTable =
      mvInfo->getJoinGraph()->getTableObjectFor(&otherTableName);
    if (otherTable == NULL)
      continue;	 // The other table must be on the graph.

    if (otherTable->deltaType_ != INSERTONLY_DELTA)
      continue;  // C must be insert only.

    Lng32 otherTableIndex = otherTable->getTableIndex();

    // The RI must be covered by equal predicates on the same columns
    LIST(Lng32) myCols;
    LIST(Lng32) otherCols;
    ref->getMyKeyColumns(myCols);
    ref->getOtherTableKeyColumns(bindWA, otherCols);
    CMPASSERT(myCols.entries() == otherCols.entries());

    NABoolean matchingPredicatesExist=TRUE;
    for (CollIndex currentCol=0; currentCol<myCols.entries(); currentCol++)
    {
      if (!mvInfo->isEqPredicateBetween(naTable_->getTableName(),
					myCols[currentCol],
					ref->getOtherTableName(),
					otherCols[currentCol]))
	matchingPredicatesExist = FALSE;
    }
    if (!matchingPredicatesExist)
      continue;

    // OK - we found a qualifying RI that we can use for optimization.
    // Now mark the bits.
    markRiTo(otherTableIndex);
    otherTable->markRiFrom(getTableIndex());
    howManyRIs++;
  }
  return howManyRIs;
}	
// -----------------------------------------------------------------------
// For those templates that are just used in .C files or that are used
// in header files not sourced into this file, make a dummy variable and
// force the instantiation system to instantiate it here.
// NOTE: we expect this file to be compiled with the -ptf -pta flags.
// NOTE: this file is designed for cfront-based compilers; it may not
// work in other environments, like c89.
// -----------------------------------------------------------------------
static void dummy_proc_()
{

  LIST(ExprNode *)		dummy01_;  // see DisplayTree.C
  LIST(NAString)		dummy18_;  // see DisplayTree.C
  LIST(ItemExpr *)		dummy19_;  // see SimpleParser.y
  LIST(RelExpr *)               dummy20_;  // see memo.C
  LIST(CollIndex)               dummy21_;  // see ColStatDesc.C
  LIST(NAType *)                dummy22_;  // see generator/GenKey.C
  NAList<ControlTableOptions*>  dummy33_;
}
Esempio n. 8
0
TCOD_list_t TCOD_list_duplicate(TCOD_list_t l) {
	int i=0;
	void **t;
	TCOD_list_int_t *ret=(TCOD_list_int_t *)TCOD_list_new();
	while ( ret->allocSize < LIST(l)->allocSize ) TCOD_list_allocate_int((TCOD_list_t)ret);
	ret->fillSize=LIST(l)->fillSize;
	for (t=TCOD_list_begin(l); t != TCOD_list_end(l); t++) {
		ret->array[i++]=*t;
	}
	return (TCOD_list_t)ret;
}
Esempio n. 9
0
/* used from context: params and device */
DviFontRef *
font_reference(
    DviParams *params,     /* rendering parameters */
    Int32 id,         /* external id number */
    const char *name,     /* font name */
    Int32 sum,         /* checksum (from DVI of VF) */
    int hdpi,         /* resolution */
    int vdpi,
    Int32 scale)        /* scaling factor (from DVI or VF) */
{
    DviFont    *font;
    DviFontRef *ref;
    DviFontRef *subfont_ref;
    
    /* see if there is a font with the same characteristics */
    for(font = (DviFont *)fontlist.head; font; font = font->next) {
        if(strcmp(name, font->fontname) == 0
           && (!sum || !font->checksum || font->checksum == sum)
           && font->hdpi == hdpi
           && font->vdpi == vdpi
           && font->scale == scale)
               break;
    }
    /* try to load the font */
    if(font == NULL) {
        font = mdvi_add_font(name, sum, hdpi, vdpi, scale);
        if(font == NULL)
            return NULL;
        listh_append(&fontlist, LIST(font));
    }
    if(!font->links && !font->chars && load_font_file(params, font) < 0) {
        DEBUG((DBG_FONTS, "font_reference(%s) -> Error\n", name));
        return NULL;
    }
    ref = xalloc(DviFontRef);
    ref->ref = font;

    font->links++;
    for(subfont_ref = font->subfonts; subfont_ref; subfont_ref = subfont_ref->next) {
        /* just adjust the reference counts */
        subfont_ref->ref->links++;
    }

    ref->fontid = id;

    if(LIST(font) != fontlist.head) {
        listh_remove(&fontlist, LIST(font));
        listh_prepend(&fontlist, LIST(font));
    }

    DEBUG((DBG_FONTS, "font_reference(%s) -> %d links\n",
        font->fontname, font->links));
    return ref;
}
Esempio n. 10
0
void* SAC_list_push_front(SAC_List list, SAC_MPool mpool, void *obj) {
  struct _SAC_ListItem *item;

  item = SAC_list_item_alloc(mpool, obj);

  if (item == NULL) return NULL;

  item->next = LIST(list)->head->next;
  LIST(list)->head->next = item;
  ++LIST(list)->size;
  return obj;
}
Esempio n. 11
0
void* SAC_list_push_back(SAC_List list, SAC_MPool mpool, void *obj) {
  struct _SAC_ListItem *item;

  item = SAC_list_item_alloc(mpool, obj);
  
  if (item == NULL) return NULL;

  LIST(list)->tail->next = item;
  LIST(list)->tail = item;
  ++LIST(list)->size;
  return obj;
}
Esempio n. 12
0
void
echoListAdd(echoObject *list, echoObject *child) {
  int idx;
  
  if (!( list && child &&
         (echoTypeList == list->type ||
          echoTypeAABBox == list->type) ))
    return;
  
  idx = airArrayLenIncr(LIST(list)->objArr, 1);
  LIST(list)->obj[idx] = child;

  return;
}
Esempio n. 13
0
value compute_ldf(variable *v, value **data, size_t users, size_t days) {

	value w;

	if (list_size(LIST(v->agents)) == 1)
		w = 1;
	else {
		value *num_maxes = calloc(users, sizeof(value));
		value num_sum = 0;
		value den_sum;
		value den_max = 0;
		size_t id, t;

		for (t = 0; t < days * SLOTS_PER_DAY; t++) {

			den_sum = 0;

			agent_list *agents = v->agents;

			while (agents) {

				id = agents->a->id;

				if (data[id][t] > num_maxes[id]) {
					num_sum += data[id][t] - num_maxes[id];
					num_maxes[id] = data[id][t];
				}

				den_sum += data[id][t];
				agents = agents->n;
			}

			den_max = den_sum > den_max ? den_sum : den_max;
		}

		free(num_maxes);
		w = num_sum / den_max + list_size(LIST(v->agents)) - 1;
	}

#if WORTH_MESSAGES > 0
	char *str = variable_to_string(v);
	printf("\033[1;37m[INFO] W(%s) = %f\033[m\n", str, w);
	free(str);
#endif

	v->w = w;
	return w;
}
Esempio n. 14
0
void TCOD_list_clear_and_delete(TCOD_list_t l) {
	void **curElt;
	for ( curElt = TCOD_list_begin(l); curElt != TCOD_list_end(l); curElt ++ ) {
		free(*curElt);
	}
	LIST(l)->fillSize=0;
}
Esempio n. 15
0
GSList *
get_mdh4trg(	t_obj *	trg_obj,		 /* The trigger object	      */
                t_obj *	par_obj)		 /* The hook parent object    */
/*
 * This is effectively a reverse lookup, called by a trigger to find the
 * hook for the trigger and parent object. It's used for output triggers -
 * internal routines that want to call a hook to output something.
 */
{
    GSList *	list = NULL;		 /* List of MIDI hooks	      */
    GSList *	node;			 /* Node in triggers list     */

    if(!midihooks)
        return NULL;

    for(	node = LIST(midihooks);		 /* Start of triggers list    */
            node;
            node = node->next)
    {
        if(	(MDH(node->data)->par_obj == par_obj) &&
                (trg_obj == MDH(node->data)->trg_obj) &&
                (MDH(node->data)->dis & HOOK_OP_ENABLED))
            list = g_slist_append(list, node->data);
    }

    return list;
}						 /* get_mdh4trg()	      */
Esempio n. 16
0
GSList *
get_mdh4obj(	t_obj *	par_obj,		 /* The hook parent object    */
                gchar *	trg_id)			 /* Trigger ID (or NULL)      */
/*
 * Given an object and (optionally) a trigger ID, get all of the MIDI
 * hooks for this. Returned in a newly created GSList which must be freed
 * by the caller
 */
{
    GSList *	list = NULL;		 /* List of MIDI hooks	      */
    GSList *	node;			 /* Node in triggers list     */

    if(!midihooks)
        return NULL;

    for(	node = LIST(midihooks);		 /* Start of triggers list    */
            node;
            node = node->next)
    {
        if((MDH(node->data)->par_obj == par_obj) &&
                (!trg_id || (trg_id == MDH(node->data)->trg_id)))
            list = g_slist_append(list, node->data);
    }

    return list;
}						 /* get_mdh4obj()	      */
Esempio n. 17
0
Addr
audit_pltexit(uintptr_t retval, Rt_map *rlmp, Rt_map *dlmp, Sym *sym,
    uint_t ndx)
{
	uintptr_t	_retval = retval;
	int		_appl = 0;

	/*
	 * We're effectively entering ld.so.1 from user (glue) code.
	 */
	(void) enter();
	if ((rtld_flags & RT_FL_APPLIC) == 0)
		_appl = rtld_flags |= RT_FL_APPLIC;

	if (auditors && (auditors->ad_flags & LML_TFLG_AUD_PLTEXIT))
		_retval = _audit_pltexit(&(auditors->ad_list), _retval,
			rlmp, dlmp, sym, ndx);
	if (AUDITORS(rlmp) && (AUDITORS(rlmp)->ad_flags & LML_TFLG_AUD_PLTEXIT))
		_retval = _audit_pltexit(&(AUDITORS(rlmp)->ad_list), _retval,
			rlmp, dlmp, sym, ndx);

	if (_appl)
		rtld_flags &= ~RT_FL_APPLIC;
	leave(LIST(rlmp));

	return (_retval);
}
Esempio n. 18
0
ret_t
cherokee_request_header_init (cherokee_request_header_t *request)
{
	ret_t ret;

	/* Init the node list information
	 */
	INIT_LIST_HEAD (LIST(&request->list_node));

	/* Set default values
	 */
	request->method    = http_get;
	request->version   = http_version_11;
	request->auth      = http_auth_nothing;
	request->proxy     = false;
	request->keepalive = true;
	request->pipeline  = 1;
	request->post_len  = 0;

	ret = cherokee_url_init (&request->url);
	if (unlikely(ret < ret_ok)) return ret;

	cherokee_buffer_init (&request->extra_headers);
	cherokee_buffer_init (&request->user);
	cherokee_buffer_init (&request->password);

	return ret_ok;
}
Esempio n. 19
0
Lng32 ExpHbaseInterface::checkAndDeleteRow(
					   HbaseStr &tblName,
					   HbaseStr &rowID, 
					   const Text& columnToCheck,
					   const Text& colValToCheck,
                                           NABoolean noXn,
					   const int64_t timestamp)
{
  Lng32 retcode = 0;

  retcode = rowExists(tblName, rowID);
  if (retcode < 0)
    return retcode;

  if (retcode == 0) // row does not exist
    {
      // return warning
      return HBASE_ROW_NOTFOUND_ERROR;
    }

  LIST(HbaseStr) columns(heap_);
  // row exists, delete it
  retcode = deleteRow(tblName,
		      rowID,
		      columns,
                      noXn,
		      timestamp);

  
  return retcode;
}
Esempio n. 20
0
/*
 * Apply a relocation to an image being built from an input file.  Use the
 * runtime linkers routines to do the necessary magic.
 */
void
apply_reloc(void *vrel, Reloc *reloc, const char *name, uchar_t *oaddr,
    Rt_map *lmp)
{
	Rela	*rel = vrel;
	Xword	type = ELF_R_TYPE(rel->r_info, M_MACH);
	Xword	value = reloc->r_value + rel->r_addend;

	if (type == R_AMD64_JUMP_SLOT) {
		uintptr_t	addr, vaddr;

		if (FLAGS(lmp) & FLG_RT_FIXED)
			vaddr = 0;
		else
			vaddr = ADDR(lmp);

		addr = (uintptr_t)oaddr - rel->r_offset;
		/* LINTED */
		(void) elf_plt_write((uintptr_t)addr, vaddr, rel,
		    (uintptr_t)value, reloc->r_pltndx);

	} else if (type == R_AMD64_COPY) {
		(void) memcpy((void *)oaddr, (void *)value,
		    (size_t)reloc->r_size);
	} else {
		(void) do_reloc_rtld(type, oaddr, &value, reloc->r_name, name,
		    LIST(lmp));
	}
}
Esempio n. 21
0
void *realloc(void *oldp, size_t size) {
    void *newp = malloc(size);

    if(oldp && newp) {
        size_t olds;
        if(size > LIST(oldp)->size)
            olds = LIST(oldp)->size;
        else
            olds = size;

        memcpy(newp, oldp, olds);
        free(oldp);
    }

    return newp;
}
Esempio n. 22
0
/*
 * la_filter() caller.  Traverses through all audit libraries and call any
 * la_filter() entry points found.  A zero return from an auditor indicates
 * that the filtee should be ignored.
 */
static int
_audit_objfilter(List *list, Rt_map *frlmp, const char *ref, Rt_map *felmp,
    uint_t flags)
{
	Audit_list	*alp;
	Listnode	*lnp;

	for (LIST_TRAVERSE(list, lnp, alp)) {
		Audit_client	*fracp, *feacp;

		if (alp->al_objfilter == 0)
			continue;
		if ((fracp = _audit_client(AUDINFO(frlmp), alp->al_lmp)) == 0)
			continue;
		if ((feacp = _audit_client(AUDINFO(felmp), alp->al_lmp)) == 0)
			continue;

		leave(LIST(alp->al_lmp));
		if ((*alp->al_objfilter)(&(fracp->ac_cookie), ref,
		    &(feacp->ac_cookie), flags) == 0)
			return (0);
		(void) enter();
	}
	return (1);
}
Esempio n. 23
0
value compute_worth(variable *v, value **data, size_t users, size_t days) {

	size_t t;
	value w = 0, cur, min = INFINITY;

	for (t = 0; t < days * SLOTS_PER_DAY; t++) {

		cur = data[v->agents->a->id][t];
		agent_list *agents = v->agents->n;

		while (agents) {

			cur += data[agents->a->id][t];
			agents = agents->n;
		}

		if (cur < min) min = cur;
		w += cur * DAY_AHEAD_MARKET_COST;
	}

	w += min * (FORWARD_MARKET_COST - DAY_AHEAD_MARKET_COST) * SLOTS_PER_DAY * days;
	w += (double)(list_size(LIST(v->agents)) - 1) * FORWARD_MARKET_COST / users;
	w = -w;

#if WORTH_MESSAGES > 0
	char *str = variable_to_string(v);
	printf("\033[1;37m[INFO] W(%s) = %f (min = %f, malus = %f)\033[m\n", str, w, min, (double)(list_size(LIST(v->agents)) - 1) * FORWARD_MARKET_COST / users);
	free(str);
#endif

	v->w = w;
	return w;
}
Esempio n. 24
0
File: eval.c Progetto: samsonjs/lake
static LakeVal *_lambda(LakeCtx *ctx, Env *env, LakeList *expr)
{
    /* (lambda (a b c) ...) */
  if (LIST_N(expr) >= 3 && lake_is_type(TYPE_LIST, LIST_VAL(expr, 1))) {
    list_shift(expr); /* drop the "lambda" symbol */
    LakeList *params = LIST(list_shift(expr));
    LakeList *body = expr;
    return VAL(fn_make(params, NULL, body, env));
  }
  else if (LIST_N(expr) >= 3 && lake_is_type(TYPE_DLIST, LIST_VAL(expr, 1))) {
    list_shift(expr); /* drop the "lambda" symbol */
    LakeDottedList *def = DLIST(list_shift(expr));
    LakeList *params = dlist_head(def);
    LakeSym *varargs = SYM(dlist_tail(def));
    LakeList *body = expr;
    return VAL(fn_make(params, varargs, body, env));
  }
  else if (LIST_N(expr) >= 3 && lake_is_type(TYPE_SYM, LIST_VAL(expr, 1))) {
    list_shift(expr); /* drop the "lambda" symbol */
    LakeSym *varargs = SYM(list_shift(expr));
    LakeList *body = expr;
    return VAL(fn_make(list_make(), varargs, body, env));
  }
  else {
    invalid_special_form(expr, "lambda requires at least 2 parameters");
    return NULL;
  }
}
Esempio n. 25
0
void
Dbg_audit_lib(Rt_map *clmp, const char *lib, int type)
{
	Lm_list		*clml = LIST(clmp);
	const char	*str;

	if (DBG_NOTCLASS(DBG_C_AUDITING))
		return;

	Dbg_util_nl(clml, DBG_NL_STD);
	switch (type) {
	case DBG_AUD_PRELOAD:
		str = MSG_ORIG(MSG_AUD_PRELOAD);
		break;
	case DBG_AUD_GLOBAL:
		str = MSG_ORIG(MSG_AUD_GLOBAL);
		break;
	case DBG_AUD_LOCAL:
		/* FALLTHROUGH */
	default:
		str = MSG_ORIG(MSG_STR_EMPTY);
	}

	dbg_print(clml, MSG_INTL(MSG_AUD_LIB), lib, NAME(clmp), str);
}
Esempio n. 26
0
/*
 * la_pltexit() caller.  Traverses through all audit library and calls any
 * la_pltexit() entry points found.  See notes above (_audit_pltenter) for
 * discussion on st_name.
 */
static Addr
_audit_pltexit(List *list, uintptr_t retval, Rt_map *rlmp, Rt_map *dlmp,
    Sym *sym, uint_t ndx)
{
	Audit_list	*alp;
	Listnode	*lnp;
#if	defined(_ELF64)
	const char	*name = (const char *)(sym->st_name + STRTAB(dlmp));
#endif

	for (LIST_TRAVERSE(list, lnp, alp)) {
		Audit_client	*racp, *dacp;

		if (alp->al_pltexit == 0)
			continue;
		if ((racp = _audit_client(AUDINFO(rlmp), alp->al_lmp)) == 0)
			continue;
		if ((dacp = _audit_client(AUDINFO(dlmp), alp->al_lmp)) == 0)
			continue;
		if (((racp->ac_flags & FLG_AC_BINDFROM) == 0) ||
		    ((dacp->ac_flags & FLG_AC_BINDTO) == 0))
			continue;

		leave(LIST(alp->al_lmp));
		retval = (*alp->al_pltexit)(sym, ndx,
		    &(racp->ac_cookie), &(dacp->ac_cookie),
#if	defined(_ELF64)
		    retval, name);
#else
		    retval);
#endif
		(void) enter();
	}
	return (retval);
}
Esempio n. 27
0
Addr
audit_pltenter(Rt_map *rlmp, Rt_map *dlmp, Sym *sym, uint_t ndx,
    void *regs, uint_t *flags)
{
	Sym	_sym = *sym;
	int	_appl = 0;

	/*
	 * We're effectively entering ld.so.1 from user (glue) code.
	 */
	(void) enter();
	if ((rtld_flags & RT_FL_APPLIC) == 0)
		_appl = rtld_flags |= RT_FL_APPLIC;

	if (auditors && (auditors->ad_flags & LML_TFLG_AUD_PLTENTER))
		_audit_pltenter(&(auditors->ad_list), rlmp, dlmp, &_sym,
		    ndx, regs, flags);
	if (AUDITORS(rlmp) &&
	    (AUDITORS(rlmp)->ad_flags & LML_TFLG_AUD_PLTENTER))
		_audit_pltenter(&(AUDITORS(rlmp)->ad_list), rlmp, dlmp, &_sym,
		    ndx, regs, flags);

	if (_appl)
		rtld_flags &= ~RT_FL_APPLIC;
	leave(LIST(rlmp));

	return (_sym.st_value);
}
Esempio n. 28
0
audit_symget(Audit_list * alp, int info)
{
	Rt_map		*_lmp, *lmp = alp->al_lmp;
	const char	*sname = MSG_ORIG(aud_info[info].sname);
	uint_t		alflag = aud_info[info].alflag;
	uint_t		auflag = aud_info[info].auflag;
	uint_t		binfo;
	Sym		*sym;
	Slookup		sl;

	sl.sl_name = sname;
	sl.sl_cmap = lml_rtld.lm_head;
	sl.sl_imap = lmp;
	sl.sl_hash = 0;
	sl.sl_rsymndx = 0;
	sl.sl_flags = LKUP_FIRST;

	if (sym = LM_LOOKUP_SYM(lmp)(&sl, &_lmp, &binfo)) {
		Addr	addr = sym->st_value;

		if (!(FLAGS(lmp) & FLG_RT_FIXED))
			addr += ADDR(lmp);

		if (alflag)
			alp->al_flags |= alflag;
		if (auflag)
			audit_flags |= auflag;

		DBG_CALL(Dbg_audit_interface(LIST(alp->al_lmp),
		    alp->al_libname, sname));
		return (addr);
	} else
		return (0);
}
Esempio n. 29
0
static ret_t
file_match_add_cb (char *entry, void *data)
{
    ret_t            ret;
    file_match_t    *new_match = NULL;
    cherokee_list_t *list      = LIST(data);

    ret = file_match_new (&new_match);
    if (unlikely ((ret != ret_ok) || (new_match == NULL)))
        return ret_error;

    if ((strchr (entry, '*')) || (strchr (entry, '?')))
    {
        new_match->is_wildcard = true;
    }

    cherokee_buffer_add (&new_match->filename, entry, strlen(entry));

    TRACE(ENTRIES, "Match file entry: '%s' (wildcard: %s)\n",
          new_match->filename.buf,
          new_match->is_wildcard ? "yes" : "no");

    cherokee_list_add_tail (&new_match->list_node, list);
    return ret_ok;
}
Esempio n. 30
0
/*------------------------------- random   ----------------------------------*/
struct c_route_entry *
c_rnd_lookup(const rimeaddr_t *dest, struct pipe* p)
{
  LIST(temp_list);
  list_init(temp_list);
  struct c_route_entry *e;
  int num;

  list_copy(temp_list, p->route_table);
  for(e = list_head(temp_list); e != NULL; e = list_item_next(e)) {
	  if(!rimeaddr_cmp(dest, &e->dest)) {
		  list_remove(temp_list, e);
	  }
  }

  /* Find a random route to destination. */
  if (list_length(temp_list) > 0) {
	  num = random_rand() % list_length(temp_list);
	  printf("%d\n", num);
	  int i = 0;
	  for(e = list_head(temp_list); e != NULL && i != num; e = list_item_next(e)) {
	      ++i;
	  }
	  if(e != NULL) {
	      PRINTF("%d.%d: Forwarding packet to %d.%d (%d in list)\n",
	     	     rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
	     	     e->nexthop.u8[0], e->nexthop.u8[1], num);
	           return e;
	  }
	  PRINTF("%d.%d: did not find a neighbor to foward to\n",
	         rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
	  return NULL;
  }
  return e;
}