Exemplo n.º 1
0
/* it called when the PPPoE session was closed */
void
pppoed_pppoe_session_close_notify(pppoed *_this, pppoe_session *session)
{
	slist_add(&_this->session_free_list,
	    (void *)(intptr_t)session->session_id);

	if (_this->acookie_hash != NULL)
		hash_delete(_this->acookie_hash,
		    (void *)(intptr_t)session->acookie, 0);
	if (_this->session_hash != NULL)
		hash_delete(_this->session_hash,
		    (void *)(intptr_t)session->session_id, 0);

	pppoe_session_fini(session);
	free(session);
}
Exemplo n.º 2
0
int save_addr_port(struct netscan_result *result, unsigned int addr, unsigned short port)
{
	struct addr_port *save = NULL;

	save = (struct addr_port *)malloc(sizeof(struct addr_port));
	if(!save)
		return -1;
	save->addr = addr;
	save->port = port;
	INIT_SLIST_NODE(&save->slist);
	pthread_mutex_lock(&(result->list_lock));
	slist_add(&result->addr_port_list, &save->slist);
	++result->num;
	pthread_mutex_unlock(&(result->list_lock));
	return 0;
}
Exemplo n.º 3
0
Symbol *AggregateDeclaration::toInitializer()
{
    if (!sinit)
    {
        Classsym *stag = fake_classsym(Id::ClassInfo);
        Symbol *s = toSymbolX("__init", SCextern, stag->Stype, "Z");
        s->Sfl = FLextern;
        s->Sflags |= SFLnodebug;
        StructDeclaration *sd = isStructDeclaration();
        if (sd)
            s->Salignment = sd->alignment;
        slist_add(s);
        sinit = s;
    }
    return sinit;
}
Exemplo n.º 4
0
        void visit(ClassDeclaration *cd)
        {
            if (!cd->csym)
            {

                if (!scc)
                    scc = fake_classsym(Id::ClassInfo);

                Symbol *s = cd->toSymbolX("__Class", SCextern, scc->Stype, "Z");
                s->Sfl = FLextern;
                s->Sflags |= SFLnodebug;
                cd->csym = s;
                slist_add(s);
            }
            result = cd->csym;
        }
Exemplo n.º 5
0
Symbol *TypedefDeclaration::toInitializer()
{
    Symbol *s;
    Classsym *stag;

    if (!sinit)
    {
        stag = fake_classsym(Id::ClassInfo);
        s = toSymbolX("__init", SCextern, stag->Stype, "Z");
        s->Sfl = FLextern;
        s->Sflags |= SFLnodebug;
        slist_add(s);
        sinit = s;
    }
    return sinit;
}
Exemplo n.º 6
0
        void visit(InterfaceDeclaration *id)
        {
            if (!id->csym)
            {

                if (!scc)
                    scc = fake_classsym(Id::ClassInfo);

                Symbol *s = toSymbolX(id, "__Interface", SCextern, scc->Stype, "Z");
                s->Sfl = FLextern;
                s->Sflags |= SFLnodebug;
                id->csym = s;
                slist_add(s);
            }
            result = id->csym;
        }
Exemplo n.º 7
0
/* all jobs must have successors except the end job, and all jobs must have predeccessors except the start job */
int check_dependencies(struct rcps_problem *p) {
	int result = RCPS_CHECK_OK;
	int end_count = 0;
	int i, k;
	struct rcps_job *start_job;
	struct slist *visited;
	struct slist *has_predecessor = slist_new(job_compare);

	for (i = 0; i < p->job_count; ++i) {
		struct rcps_job *j = p->jobs[ i ];
		//printf("check_dependencies: job %s successors: %i\n", j->name, j->successor_count);
		if (j->successor_count == 0) {
			++end_count;
		} else {
			for (k = 0; k < j->successor_count; ++k) {
				//printf("check_dependencies: job %s successor[%i] = %s\n", j->name, k, j->successors[k]->name);
				slist_add(has_predecessor, slist_node_new(j->successors[k]));
			}
		}
	}
	if (end_count > 1) {
		result += RCPS_CHECK_MULTIPLE_END_JOBS;
	} else if (end_count == 0) {
		result += RCPS_CHECK_END_JOB_MISSING;
	}
	if (result == RCPS_CHECK_OK) {
		start_job = 0;
		for (i = 0; i < p->job_count; ++i) {
			if (!slist_find(has_predecessor, p->jobs[i])) {
				start_job = p->jobs[i];
			}
		}
		if (start_job) {
			/* All other jobs should be successors of the start job */
			//printf("check_dependencies: check circular\n");
			visited = slist_new(job_compare);
			result += check_circulardependencies(start_job, visited);
			slist_free(visited, NULL);
		} else {
			result += RCPS_CHECK_START_JOB_MISSING;
		}

	}
	slist_free(has_predecessor, NULL);
	//printf("check_dependencies: result=%i\n", result);
	return result;
}
Exemplo n.º 8
0
Symbol *toInitializer(EnumDeclaration *ed)
{
    if (!ed->sinit)
    {
        Classsym *stag = fake_classsym(Id::ClassInfo);
        Identifier *ident_save = ed->ident;
        if (!ed->ident)
            ed->ident = Identifier::generateId("__enum");
        Symbol *s = toSymbolX(ed, "__init", SCextern, stag->Stype, "Z");
        ed->ident = ident_save;
        s->Sfl = FLextern;
        s->Sflags |= SFLnodebug;
        slist_add(s);
        ed->sinit = s;
    }
    return ed->sinit;
}
Exemplo n.º 9
0
Symbol *ClassDeclaration::toSymbol()
{
    if (!csym)
    {
        Symbol *s;

        if (!scc)
            scc = fake_classsym(Id::ClassInfo);

        s = toSymbolX("__Class", SCextern, scc->Stype, "Z");
        s->Sfl = FLextern;
        s->Sflags |= SFLnodebug;
        csym = s;
        slist_add(s);
    }
    return csym;
}
Exemplo n.º 10
0
Symbol *EnumDeclaration::toInitializer()
{
    if (!sinit)
    {
        Classsym *stag = fake_classsym(Id::ClassInfo);
        Identifier *ident_save = ident;
        if (!ident)
            ident = Lexer::uniqueId("__enum");
        Symbol *s = toSymbolX("__init", SCextern, stag->Stype, "Z");
        ident = ident_save;
        s->Sfl = FLextern;
        s->Sflags |= SFLnodebug;
        slist_add(s);
        sinit = s;
    }
    return sinit;
}
Exemplo n.º 11
0
Symbol *toVtblSymbol(ClassDeclaration *cd)
{
    if (!cd->vtblsym)
    {
        if (!cd->csym)
            toSymbol(cd);

        TYPE *t = type_allocn(TYnptr | mTYconst, tsvoid);
        t->Tmangle = mTYman_d;
        Symbol *s = toSymbolX(cd, "__vtbl", SCextern, t, "Z");
        s->Sflags |= SFLnodebug;
        s->Sfl = FLextern;
        cd->vtblsym = s;
        slist_add(s);
    }
    return cd->vtblsym;
}
Exemplo n.º 12
0
Symbol *InterfaceDeclaration::toSymbol()
{
    if (!csym)
    {
	Symbol *s;

	if (!scc)
	    scc = fake_classsym("ClassInfo");

	s = toSymbolX("_Interface_", SCextern, scc->Stype);
	s->Sfl = FLextern;
	s->Sflags |= SFLnodebug;
	csym = s;
	slist_add(s);
    }
    return csym;
}
Exemplo n.º 13
0
type *TypeClass::toCtype()
{   type *t;
    Symbol *s;

    //printf("TypeClass::toCtype() %s\n", toChars());
    if (ctype)
        return ctype;

    /* Need this symbol to do C++ name mangling
     */
    const char *name = sym->isCPPinterface() ? sym->ident->toChars()
                                             : sym->toPrettyChars();
    s = symbol_calloc(name);
    s->Sclass = SCstruct;
    s->Sstruct = struct_calloc();
    s->Sstruct->Sflags |= STRclass;
    s->Sstruct->Salignsize = sym->alignsize;
    s->Sstruct->Sstructalign = sym->structalign;
    s->Sstruct->Sstructsize = sym->structsize;

    t = type_alloc(TYstruct);
    t->Ttag = (Classsym *)s;            // structure tag name
    t->Tcount++;
    s->Stype = t;
    slist_add(s);

    t = type_allocn(TYnptr, t);

    t->Tcount++;
    ctype = t;

    /* Add in fields of the class
     * (after setting ctype to avoid infinite recursion)
     */
    if (global.params.symdebug)
        for (int i = 0; i < sym->fields.dim; i++)
        {   VarDeclaration *v = sym->fields.tdata()[i];

            Symbol *s2 = symbol_name(v->ident->toChars(), SCmember, v->type->toCtype());
            s2->Smemoff = v->offset;
            list_append(&s->Sstruct->Sfldlst, s2);
        }

    return t;
}
Exemplo n.º 14
0
Symbol* ClassReferenceExp::toSymbol()
{
    if (value->sym) return value->sym;
    TYPE *t = type_alloc(TYint);
    t->Tcount++;
    Symbol *s = symbol_calloc("internal");
    s->Sclass = SCstatic;
    s->Sfl = FLextern;
    s->Sflags |= SFLnodebug;
    s->Stype = t;
    value->sym = s;
    dt_t *d = NULL;
    toInstanceDt(&d);
    s->Sdt = d;
    slist_add(s);
    outdata(s);
    return value->sym;
}
Exemplo n.º 15
0
Symbol *Module::toSymbol()
{
    if (!csym)
    {
	Symbol *s;
	static Classsym *scc;

	if (!scc)
	    scc = fake_classsym("ModuleInfo");

	s = toSymbolX("_ModuleInfo_", SCextern, scc->Stype);
	s->Sfl = FLextern;
	s->Sflags |= SFLnodebug;
	csym = s;
	slist_add(s);
    }
    return csym;
}
Exemplo n.º 16
0
Arquivo: freq.c Projeto: ftnapps/qico
int freq_recv(char *fn)
{
    FILE *f;
    char s[MAX_PATH],*p;
    slist_t *reqs=NULL;
    f=fopen(fn,"rt");
    if(!f){write_log("can't open '%s' for reading: %s",fn,strerror(errno));return 0;}
    while(fgets(s,MAX_PATH-1,f)) {
        p=s+strlen(s)-1;
        while(*p=='\r'||*p=='\n')*p--=0;
        slist_add(&reqs,s);
    }
    fclose(f);
    freq_ifextrp(reqs);
    slist_kill(&reqs);
    got_req=1;
    return 1;
}
Exemplo n.º 17
0
Symbol *static_sym()
{
    Symbol *s;
    type *t;

    t = type_alloc(TYint);
    t->Tcount++;
    s = symbol_calloc("internal");
    s->Sclass = SCstatic;
    s->Sfl = FLextern;
    s->Sflags |= SFLnodebug;
    s->Stype = t;
#if ELFOBJ // Burton
    s->Sseg = DATA;
#endif /* ELFOBJ */
    slist_add(s);
    return s;
}
Exemplo n.º 18
0
Symbol* StructLiteralExp::toSymbol()
{
    if (sym) return sym;
    TYPE *t = type_alloc(TYint);
    t->Tcount++;
    Symbol *s = symbol_calloc("internal");
    s->Sclass = SCstatic;
    s->Sfl = FLextern;
    s->Sflags |= SFLnodebug;
    s->Stype = t;
    sym = s;
    dt_t *d = NULL;
    toDt(&d);
    s->Sdt = d;
    slist_add(s);
    outdata(s);
    return sym;
}
Exemplo n.º 19
0
Symbol *Module::toModuleArray()
{
    if (!marray)
    {
	type *t;

	t = type_alloc(TYjfunc);
	t->Tflags |= TFprototype | TFfixed;
	t->Tmangle = mTYman_d;
	t->Tnext = tsvoid;
	tsvoid->Tcount++;

	marray = toSymbolX("_array_", SCextern, t);
	marray->Sfl = FLextern;
	marray->Sflags |= SFLnodebug;
	slist_add(marray);
    }
    return marray;
}
Exemplo n.º 20
0
Symbol *Module::toModuleUnittest()
{
    if (!munittest)
    {
        type *t;

        t = type_alloc(TYjfunc);
        t->Tflags |= TFprototype | TFfixed;
        t->Tmangle = mTYman_d;
        t->Tnext = tsvoid;
        tsvoid->Tcount++;

        munittest = toSymbolX("__unittest_fail", SCextern, t, "FiZv");
        munittest->Sfl = FLextern;
        munittest->Sflags |= SFLnodebug;
        slist_add(munittest);
    }
    return munittest;
}
Exemplo n.º 21
0
Symbol *aaGetSymbol(TypeAArray *taa, const char *func, int flags)
{
#ifdef DEBUG
        assert((flags & ~1) == 0);
#endif

        // Dumb linear symbol table - should use associative array!
        static Symbols *sarray = NULL;

        //printf("aaGetSymbol(func = '%s', flags = %d, key = %p)\n", func, flags, key);
        char *id = (char *)alloca(3 + strlen(func) + 1);
        sprintf(id, "_aa%s", func);
        if (!sarray)
            sarray = Symbols_create();

        // See if symbol is already in sarray
        for (size_t i = 0; i < sarray->dim; i++)
        {
            Symbol *s = (*sarray)[i];
            if (strcmp(id, s->Sident) == 0)
            {
#ifdef DEBUG
                assert(s);
#endif
                return s;                       // use existing Symbol
            }
        }

        // Create new Symbol

        Symbol *s = symbol_calloc(id);
        slist_add(s);
        s->Sclass = SCextern;
        s->Ssymnum = -1;
        symbol_func(s);

        type *t = type_function(TYnfunc, NULL, 0, false, Type_toCtype(taa->next));
        t->Tmangle = mTYman_c;
        s->Stype = t;

        sarray->push(s);                        // remember it
        return s;
}
Exemplo n.º 22
0
int main()
{
	struct node_info *phead = NULL;
	
	struct node_info s[] = {
		{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8},
	};

	int i;
	for (i = 0; i < N_ELEMT(s); ++i) {
		slist_add( &phead, s + i);
	}


	slist_for_each(phead);


	return 0;
}
Exemplo n.º 23
0
Symbol *Module::toModuleAssert()
{
    if (!massert)
    {
        type *t;

        t = type_alloc(TYjfunc);
        t->Tflags |= TFprototype | TFfixed;
        t->Tmangle = mTYman_d;
        t->Tnext = tsvoid;
        tsvoid->Tcount++;

        massert = toSymbolX("__assert", SCextern, t, "FiZv");
        massert->Sfl = FLextern;
        massert->Sflags |= SFLnodebug;
        slist_add(massert);
    }
    return massert;
}
Exemplo n.º 24
0
NickAlias *makenick(const char *nick)
{
    NickAlias *na;
    NickCore *nc;

    /* First make the core */
    nc = scalloc(1, sizeof(NickCore));
    nc->display = sstrdup(nick);
    slist_init(&nc->aliases);
    insert_core(nc);
    alog("%s: group %s has been created", s_NickServ, nc->display);

    /* Then make the alias */
    na = scalloc(1, sizeof(NickAlias));
    na->nick = sstrdup(nick);
    na->nc = nc;
    slist_add(&nc->aliases, na);
    alpha_insert_alias(na);
    return na;
}
Exemplo n.º 25
0
Symbol *ClassDeclaration::toVtblSymbol()
{
    if (!vtblsym)
    {
        Symbol *s;
        TYPE *t;

        if (!csym)
            toSymbol();

        t = type_allocn(TYnptr | mTYconst, tsvoid);
        t->Tmangle = mTYman_d;
        s = toSymbolX("__vtbl", SCextern, t, "Z");
        s->Sflags |= SFLnodebug;
        s->Sfl = FLextern;
        vtblsym = s;
        slist_add(s);
    }
    return vtblsym;
}
Exemplo n.º 26
0
Classsym *fake_classsym(char *name)
{   TYPE *t;
    Classsym *scc;

    scc = (Classsym *)symbol_calloc("ClassInfo");
    scc->Sclass = SCstruct;
    scc->Sstruct = struct_calloc();
    scc->Sstruct->Sstructalign = 8;
    //scc->Sstruct->ptrtype = TYnptr;
    scc->Sstruct->Sflags = STRglobal;

    t = type_alloc(TYstruct);
    t->Tflags |= TFsizeunknown | TFforward;
    t->Ttag = scc;		// structure tag name
    assert(t->Tmangle == 0);
    t->Tmangle = mTYman_c;
    t->Tcount++;
    scc->Stype = t;
    slist_add(scc);
    return scc;
}
Exemplo n.º 27
0
Symbol *ClassDeclaration::toVtblSymbol()
{
    if (!vtblsym)
    {
	Symbol *s;
	TYPE *t;

	if (!csym)
	    toSymbol();

	t = type_alloc(TYnptr | mTYconst);
	t->Tnext = tsvoid;
	t->Tnext->Tcount++;
	t->Tmangle = mTYman_c;
	s = toSymbolX("_vtbl_", SCextern, t);
	s->Sflags |= SFLnodebug;
	s->Sfl = FLextern;
	vtblsym = s;
	slist_add(s);
    }
    return vtblsym;
}
Exemplo n.º 28
0
static void
test_04()
{
	int i;
	slist sl;
	slist *l = &sl;

	slist_init(&sl);
	for (i = 0; i < 255; i++)
		slist_add(&sl, (void *)(i + 1));

	test_itr_subr_01(&sl);

	for (i = 0; i < 256; i++) {
		/* Verify any physical placements are OK by rotating. */
		sl.first_idx = i;
		sl.last_idx = sl.first_idx + 255;
		sl.last_idx %= sl.list_size;
		ASSERT(slist_length(&sl) == 255);
		test_itr_subr_01(&sl);
	}
}
Exemplo n.º 29
0
void add_individual(struct rcps_individual *ind, struct rcps_population *pop) {
	struct slist_node *n;
	struct rcps_individual *i;

	n = slist_node_new(ind);
	slist_add(pop->individuals, n);
	++pop->size;
	// what is this? (da)
	while (slist_count(pop->individuals) > pop->size) {
		n = slist_last(pop->individuals);
		if (!n) {
			// XXX what the f**k is that?
			fprintf(stderr, "uhu, no one there?\n");
		}
		slist_unlink(pop->individuals, n);
		i = (struct rcps_individual*)slist_node_getdata(n);
		slist_node_free(n, NULL);
		free(i->genome.schedule);
		free(i->genome.modes);
		free(i->genome.alternatives);
		free(i);
	}
}
Exemplo n.º 30
0
int check_circulardependencies(struct rcps_job *job, struct slist *visited) {
	int result = RCPS_CHECK_OK;
	int i;
	struct slist_node *n;
	//printf("check_circulardependencies: %s visited: %i\n", job->name, slist_count(visited));
	if ( slist_find(visited, job)) {
		result = RCPS_CHECK_CIRCULAR_DEPENDENCY;
		//printf("check_circulardependencies: %s already visited\n", job->name);
	} else {
		n = slist_node_new(job);
		slist_add(visited, n);
		for (i = 0; i < job->successor_count; ++i) {
			result = check_circulardependencies( job->successors[ i ], visited );
			if ( result != RCPS_CHECK_OK ) {
				break;
			}
		}
		// remove this job from the visited to avoid false positive
		slist_unlink(visited, n);
		slist_node_free(n, NULL);
	}
	return result;
}