Exemplo n.º 1
0
static void rename_ind(Term t, Label from, Label to)
	{
	if(is_list(t))
		{
		List l;
		l=t;
		while(!is_empty_list(l))
			{
			Term u;
			u=ListFirst(l);
			if(u==from)
				ChangeList(l,to);
			else
				rename_ind(u,from,to);
			l=ListTail(l);
			}
		return;
		}
	if(is_compound(t))
		{
		int i,ac;
		ac=CompoundArity(t);
		for(i=1;i<=ac;i++)
			{
			Term u;
			u=CompoundArgN(t,i);
			if(u==from)
				SetCompoundArg(t,i,to);
			else
				rename_ind(u,from,to);
			}
		}
	return;
	}
Exemplo n.º 2
0
static void chlabs(Term t)
{
	if(is_list(t))
	{
		List l;
		for(l=t;l;l=ListTail(l))
		{
			Term m=ListFirst(l);
			if(is_label(m))
				ChangeList(l,ListNth(labm,ListMember(labl,m)));
			else
				chlabs(m);
		}
	}
	if(is_compound(t))
	{
		int i;
		for(i=1;i<=CompoundArity(t);i++)
		{
			Term m=CompoundArgN(t,i);
			if(is_label(m))
				SetCompoundArg(t,i,ListNth(labm,ListMember(labl,m)));
			else
				chlabs(m);
		}
	}
}
Exemplo n.º 3
0
void ClingoPropagatorInit::unfreeze(SharedContext&) {
	if (history_) {
		for (ChangeList::const_iterator it = changes_.begin(), end = changes_.end(); it != end; ++it) {
			history_->add(*it);
		}
	}
	ChangeList().swap(changes_);
	++step_;
}
Exemplo n.º 4
0
List SetLets(List l)
	{
	List l1,lr, lre=0;
	lr=NewList();
	slrl++;
	l1=l;
	while(!is_empty_list(l1))
		{
		List nl=s_l_1(ListFirst(l1));
		if(nl==0)
			{l1=ListTail(l1);continue;}
		if(lr==0)
			{lr=nl;lre=lr;}
		else
			ConcatList(lre,nl);
		while(ListTail(lre)) lre=ListTail(lre);
		/*lr=ConcatList(lr,);*/
		l1=ListTail(l1);
		}
	RemoveList(l);
	
	slrl--;
	if(slrl==0)
	{
		for(l1=lr;l1;l1=ListTail(l1))
		{
			List l2,sl=ConsumeCompoundArg(ListFirst(l1),3);
			int ch=0;
			for(l2=sl;l2;l2=ListTail(l2))
				if(CompoundName(ListFirst(l2))==A_INFINITESIMAL)
				{
					FreeAtomic(ListFirst(l2));
					ChangeList(l2,0);
					ch++;
				}
			if(ch)
			do
			{
				for(l2=sl;l2;l2=ListTail(l2))
				if(ListFirst(l2)==0)
				{
					sl=CutFromList(sl,l2);
					break;
				}
			} while(l2);
			SetCompoundArg(ListFirst(l1),3,sl);
		}
	}
						
		
	lr=a1l_rem_inf(lr);
	return lr;
	}
Exemplo n.º 5
0
GUItable::GUItable(int x1, int y1, int w1, int h1, const vector<string>* contents, Functor3<GUItable*, int,int>clicked):GUIpane(x1,y1,w1,h1), click(clicked), data()
{
	rowHeight=(int)guifont->GetHeight();
	length=data.size()*rowHeight;
	position=0;
	selected=0;
	numLines=h/rowHeight-1;
	
	width=w1;

	ChangeList(contents);
	name="table";
}
Exemplo n.º 6
0
Term ProcDelVertex(Term t, List ind)
{
	List l, pl;
	
	if(lagr_hash==NULL)
	{
		ErrorInfo(107);
		puts("DelVertex: no vertices");
		return 0;
	}
	
	
	if(!is_compound(t)||CompoundArity(t)!=1)
	{
		ErrorInfo(107);
		puts("wrong call to DelVertex");
		return 0;
	}
	
	pl=CompoundArg1(t);
	if(!is_list(pl))
	{
		ErrorInfo(107);
		puts("wrong call to DelVertex");
		return 0;
	}
	
	for(l=pl;l;l=ListTail(l))
		if(is_function(ListFirst(l),0))
			ChangeList(l,CallFunction(ListFirst(l),0));
	
	pl=SortedList(pl,acmp);
	
	l=finda2(pl,1);
	
	if(is_empty_list(l))
	{
	WarningInfo(108);printf("DelVertex: vertex ");
	WriteTerm(pl); puts(" not found");
	return 0;
	}
	
	
	return 0;
}
Exemplo n.º 7
0
static List alg1_w_ind(Term m1, List wf)
	{
	List l1,l2,wi,wn;
	wi=wn=NewList();
	
		l2=CompoundArgN(m1,3);
		while(!is_empty_list(l2))
			{
			List l3;
			l3=CompoundArg1(ListFirst(l2));
			while(!is_empty_list(l3))
				{
				Atomic t1,t2;
				t1=ListFirst(l3);
				t2=CompoundArg2(t1);
				if(CompoundName(t1)==OPR_WILD && 
					!ListMember(wf,t2) && !ListMember(wi,t2))
						{
						wi=AppendLast(wi,t2);
						wn=AppendLast(wn,CompoundArgN(t1,3));
						}
				l3=ListTail(l3);
				}
			l2=ListTail(l2);
			}
	l1=wi;
	l2=wn;
	while(!is_empty_list(l1))
		{
		ChangeList(l1,MakeCompound2(OPR_DIV,ListFirst(l1),ListFirst(l2)));
		l1=ListTail(l1);
		l2=ListTail(l2);
		}
	RemoveList(wn);
	return wi;
	}
Exemplo n.º 8
0
FPlayList::FPlayList (const char *path)
{
	ChangeList (path);
}
Exemplo n.º 9
0
Term ProcChVertex(Term t, List ind)
{
	List l, pl, ml;
	Term rpl;
	Atom a1, a2;
	int pli;
	int ii;
	
	if(lagr_hash==NULL)
	{
		ErrorInfo(107);
		puts("ChVertex: no vertices");
		return 0;
	}
	
	
	if(!is_compound(t)||CompoundArity(t)!=2)
	{
		ErrorInfo(107);
		puts("wrong call to ChVertex");
		return 0;
	}
	
	pl=CompoundArg1(t);
	for(l=pl;l;l=ListTail(l))
		if(is_function(ListFirst(l),0))
			ChangeList(l,CallFunction(ListFirst(l),0));
	
	rpl=CompoundArg2(t);
	if(!is_list(pl)|| !is_compound(rpl) || CompoundArity(rpl)!=2)
	{
		ErrorInfo(107);
		puts("wrong call to ChVertex");
		return 0;
	}
	a1=CompoundArg1(rpl);a2=CompoundArg2(rpl);
	if(!is_parameter(a1)||!is_parameter(a2))
	{
		ErrorInfo(107);
		puts("wrong call to ChVertex");
		return 0;
	}

	pl=SortedList(pl,acmp);
	
	l=finda2(pl,0);
	
	if(is_empty_list(l))
	{
	WarningInfo(108);printf("ChVertex: vertex ");
	WriteTerm(pl); puts(" not found");
	return 0;
	}
	
	ml=CompoundArgN(ListFirst(l),5);
	ii=0;
		
	for(l=ml;l;l=ListTail(l))
	{
		List l1;
		for(l1=CompoundArg2(ListFirst(l));l1;l1=ListTail(l1))
			if(CompoundArg1(ListFirst(l1))==a1)
			{
				SetCompoundArg(ListFirst(l1),1,a2);ii++;
			}
	}
	
	
	if(ii==0)
	{
	WarningInfo(107);printf("ChVertex: vertex ");WriteTerm(pl);
			printf("has no '%s' within.\n",AtomValue(a1));
	}	
	
	return 0;
}
Exemplo n.º 10
0
Term ProcCoefVrt(Term t, List ind)
{
	List l,pl,ml;
	int  ii;
	Term a2;
	int g=0, g5=0, re=0, im=0, abbr=0, cmplx=0;
	
	if(!is_compound(t) || CompoundArity(t)>2 || !is_list(CompoundArg1(t)))
	{
		ErrorInfo(0);
		puts("wrong parameters of CoefVrt function.");
		return 0;
	}
	
	if(lagr_hash==NULL)
	{
		ErrorInfo(107);
		puts("CoefVrt: no vertices");
		return 0;
	}
	
	mmm=0;
	if(CompoundArity(t)==2)
	{
		List ol=CompoundArg2(t);
		if(!is_list(ol))
		{
		ErrorInfo(107);
		puts("CoefVrt: second argument is not a list.");
		return 0;
		}
		for(;ol;ol=ListTail(ol))
		{
			Term o=ListFirst(ol);
			if(is_compound(o))
			{
				o=CompoundArg1(o);
				if(!is_atom(o) || !is_particle(o,0))
				{
					ErrorInfo(0);
					printf("CoefVrt: ");WriteTerm(o);
					puts(" is not a particle.\n");
					return 0;
				}
				mmm=o;
				continue;
			}
			if(!is_atom(o))
			{
				ErrorInfo(0);
				printf("CoefVrt: ");WriteTerm(o);
				puts(" is not an option.\n");
				return 0;
			}
			if(strcmp("gamma",AtomValue(o))==0)
			{
				g++;
				continue;
			}
			if(strcmp("gamma5",AtomValue(o))==0)
			{
				g5++;
				continue;
			}
			if(strcmp("re",AtomValue(o))==0)
			{
				re++;
				continue;
			}
			if(strcmp("im",AtomValue(o))==0)
			{
				im++;
				continue;
			}
			if(strcmp("abbr",AtomValue(o))==0)
			{
				abbr++;
				continue;
			}
			{
				ErrorInfo(0);
				printf("CoefVrt: ");WriteTerm(o);
				puts(" is not an option.\n");
				return 0;
			}
		}
	}
			
	if(re&&im)
		re=im=0;
			
	pl=ConsumeCompoundArg(t,1);
	for(l=pl;l;l=ListTail(l))
		if(is_function(ListFirst(l),0))
			ChangeList(l,CallFunction(ListFirst(l),0));

/*	for(l=pl;l;l=ListTail(l))
	{
		Term aa=ListFirst(l);
		if(is_compound(aa)&&CompoundName(aa)==A_ANTI)
			ChangeList(l,GetAtomProperty(CompoundArg1(aa),A_ANTI));
	}*/
	pl=SortedList(pl,acmp);
	
	l=finda2(pl,0);
	
	if(mmm && !mmmpos)
	{
		ErrorInfo(0);
		printf("CoefVrt: particle ");
		WriteTerm(mmm);
		puts(" not found in the vertex");
		return 0;
	}
	
		
	
	
	if(is_empty_list(l))
	{
	ErrorInfo(108);
	printf("CoefVrt: vertex ");
	WriteTerm(pl);
	puts(" not found");
	return NewInteger(0);
	}
	
	a2=CopyTerm(ListFirst(l));
	
	
	alg2_symmetrize(a2);
	alg2_common_n(a2);
	{
		int sv=kill_gamma_pm;
		kill_gamma_pm=1;
		alg2_red_1pm5(a2);
		kill_gamma_pm=sv;
	}
	alg2_recommon_n(a2);
		
	ml=ConsumeCompoundArg(a2,5);
	for(l=ml;l;l=ListTail(l))
	{
		List l1,ll;
		int tg=0, tg5=0, tm=0;
		for(l1=CompoundArgN(ListFirst(l),3);l1;l1=ListTail(l1))
		{
			Term tt=ListFirst(l1);
			if(CompoundName(tt)==OPR_SPECIAL && CompoundArg1(tt)==A_GAMMA)
				tg++;
			if(CompoundName(tt)==OPR_SPECIAL && CompoundArg1(tt)==A_GAMMA5)
				tg5++;
			if(CompoundName(tt)==A_MOMENT && CompoundArg1(tt)==
						NewInteger(mmmpos))
				tm++;
		}
		if(g!=tg || g5!=tg5 || (mmm && !tm))
		{
			SetCompoundArg(ListFirst(l),1,0);
			continue;
		}
		if(!re && !im)
			continue;
		for(l1=CompoundArg2(ListFirst(l));l1;l1=ListTail(l1))
			if(GetAtomProperty(CompoundArg1(ListFirst(l1)),A_ANTI))
				cmplx++;
	}

	if( (re||im) && !cmplx)
		for(l=ml;l;l=ListTail(l))
		{
		List ll,l1;
		if(CompoundArg1(ListFirst(l))==0)
			continue;
		ll=ConsumeCompoundArg(ListFirst(l),2);
		for(l1=ll;l1;l1=ListTail(l1))
			if(CompoundArg1(ListFirst(l1))==A_I)
				break;
		if( (re && l1) || (im && !l1) )
			SetCompoundArg(ListFirst(l),1,0);
		if(im && l1)
			ll=CutFromList(ll,l1);
		SetCompoundArg(ListFirst(l),2,ll);
		}

		
rpt:
	for(l=ml;l;l=ListTail(l))
		if(CompoundArg1(ListFirst(l))==0)
		{
			ml=CutFromList(ml,l);
			break;
		}
	if(l)
		goto rpt;
	
	SetCompoundArg(a2,5,ml);
	alg2_recommon_n(a2);
	alg2_common_s(a2);
	alg2_red_cos(a2);
	alg2_red_orth(a2);
	alg2_red_sico(a2);
	alg2_red_comsico(a2);
	alg2_recommon_n(a2);
	if(abbr)
	{
		int trisv=opTriHeu;
		alg2_eval_vrt(a2);
		doing_abbr=0;
		opTriHeu=trisv;
	}
	
	{
	int n,d;
	Term cf;
	Term res;
	n=IntegerValue(CompoundArg1(CompoundArg2(a2)));
	d=IntegerValue(CompoundArg2(CompoundArg2(a2)));
	cf=l2expr(CompoundArgN(a2,3),n);
	ml=CompoundArgN(a2,5);
	if(ml==0)
		return NewInteger(0);
	res=l2expr(CompoundArg2(ListFirst(ml)),
			IntegerValue(CompoundArg1(ListFirst(ml))));
	for(l=ListTail(ml);l;l=ListTail(l))
	{
		Term ccc;
		n=IntegerValue(CompoundArg1(ListFirst(l)));
		ccc=l2expr(CompoundArg2(ListFirst(l)),n>0?n:-n);
		if(n>0)
			res=MakeCompound2(OPR_PLUS,res,ccc);
		else
			res=MakeCompound2(OPR_MINUS,res,ccc);
	}
	if(res==NewInteger(1))
		res=cf;
	else
		res=MakeCompound2(OPR_MLT,cf,res);
	if(d!=1)
		res=MakeCompound2(OPR_DIV,res,NewInteger(d));
	if( (im||re) && cmplx)
		res=MakeCompound1(NewAtom(re?"creal":"cimag",0),res);
		
	return res;
	}
	return a2;
	
}
Exemplo n.º 11
0
afs_int32
uss_acl_SetAccess(char *a_access, int a_clear, int a_negative)
{   /*uss_acl_SetAccess */

    afs_int32 code;
#ifdef USS_ACL_DB
    static char rn[] = "uss_acl_SetAccess";
#endif
    struct Acl *ta;
    char *externalizedACL;
    int plusp;
    afs_int32 rights;
    char tmp_str[AFS_PIOCTL_MAXSIZE];
    char path_field[AFS_PIOCTL_MAXSIZE], user_field[64], rights_field[64], *tp;
    int overflow;

    plusp = !a_negative;

    /*
     * Pull out the pathname from our argument.
     */
    tp = uss_common_FieldCp(path_field, a_access, ' ', sizeof(path_field),
                            &overflow);
    if (overflow) {
        fprintf(stderr, "%s: * Pathname field too long (max is %" AFS_SIZET_FMT " chars)\n",
                uss_whoami, sizeof(path_field));
        return (-1);
    }

    /*
     * Ask the Cache Manager to give us the externalized ACL for the
     * given directory.
     */
    code = uss_fs_GetACL(path_field, tmp_str, AFS_PIOCTL_MAXSIZE);
    if (code) {
        afs_com_err(uss_whoami, code, "while getting access list for %s",
                    path_field);
#ifdef USS_ACL_DB
        printf("%s: Error code from uss_fs_GetACL %d, errno %d\n", rn, code,
               errno);
#endif /* USS_ACL_DB */
        return (code);
    }
#ifdef USS_ACL_DB
    else
        printf("%s: ACL for pathname '%s' is: '%s'\n", rn, path_field,
               tmp_str);
#endif /* USS_ACL_DB */

    /*
     * Generate the proper internalized ACL.
     */
    if (a_clear)
        ta = EmptyAcl();
    else
        ta = ParseAcl(tmp_str);

    /*
     * For each given entry, pull out the information and alter the
     * internalized ACL to reflect it.
     */
    while (*tp != '\0') {
        tp = uss_common_FieldCp(user_field, tp, ' ', 64, &overflow);
        if (overflow) {
            fprintf(stderr, "%s: * User field too long (max is 64 chars)\n",
                    uss_whoami);
            return (-1);
        }
        if (*tp == '\0') {
            printf("%s: Missing second half of user/access pair.\n",
                   uss_whoami);
            return (1);
        }
        tp = uss_common_FieldCp(rights_field, tp, ' ', 64, &overflow);
        if (overflow) {
            fprintf(stderr, "%s: * Rights field too long (max is 64 chars)\n",
                    uss_whoami);
            return (-1);
        }
        rights = Convert(rights_field);
        ChangeList(ta, plusp, user_field, rights);
    }

    /*
     * Externalize the fully-processed internal ACL, then pass it back
     * to the Cache Manager.
     */
    externalizedACL = AclToString(ta);
    code =
        uss_fs_SetACL(path_field, externalizedACL,
                      strlen(externalizedACL) + 1);
    if (code) {
#ifdef USS_ACL_DB
        printf("%s: uss_fs_SetACL() failed, code is %d, errno is %d\n", rn,
               code, errno);
#endif /* USS_ACL_DB */
        if (errno == EINVAL) {
            printf("Can't set ACL for directory '%s' to '%s'\n", path_field,
                   externalizedACL);
            printf("Invalid argument, possible reasons include:\n");
            printf("\t1. File not in AFS, or\n");
            printf("\t2. Too many users on the ACL, or\n");
            printf("\t3. Non-existent user or group on ACL.\n");
            return (code);
        } else {
            afs_com_err(uss_whoami, code, "while setting the access list");
            return (code);
        }
    }
    return (0);

}				/*uss_acl_SetAccess */
Exemplo n.º 12
0
void alg1_opt_let(Term a1)
{
	List l,l1,l2,lm=ConsumeCompoundArg(a1,1);
	List nl=0;
	Label mylbl=NewLabel();
	
	/*printf("%d -> ",ListLength(lm));*/
	
	for(l=lm;l;l=ListTail(l))
	{
		Term m1=ListFirst(l);
		int n,d,g;
		List ln=ConsumeCompoundArg(m1,3);
		List ld=ConsumeCompoundArg(m1,4);
		Term f1=0, f2=0, w=0;
		n=IntegerValue(CompoundArg1(m1));
		d=IntegerValue(CompoundArg2(m1));
				
	rpt1:
		for(l1=ld;l1;l1=ListTail(l1))
		{
			int n=ListMember(ln,ListFirst(l1));
			if(n)
			{
				ld=CutFromList(ld,l1);
				l1=ListNthList(ln,n);
				ln=CutFromList(ln,l1);
				goto rpt1;
			}
			if(CompoundArg2(ListFirst(l1))==A_SQRT2)
			{
				Term t=ListFirst(l1);
				ChangeList(l1,0);
				ld=CutFromList(ld,l1);
				ln=AppendFirst(ln,t);
				d*=2;
				goto rpt1;
			}
		}
	rpt2:
		for(l1=ln;l1;l1=ListTail(l1))
			if(CompoundArg2(ListFirst(l1))==A_SQRT2)
			{
				List l2;
				for(l2=ListTail(l1);l2;l2=ListTail(l2))
					if(CompoundArg2(ListFirst(l2))==A_SQRT2)
					{
						ln=CutFromList(ln,l1);
						ln=CutFromList(ln,l2);
						n*=2;
						goto rpt2;
					}
				}
		g=gcf(n,d);
		n/=g;
		d/=g;
		
		for(l1=ln;l1;l1=l1?ListTail(l1):0)
		{
			Term sp=ListFirst(l1);
			if(CompoundName(sp)==OPR_PARAMETER)
				continue;
			if(CompoundName(sp)==OPR_FIELD)
			{
				if(f1==0)
					f1=l1;
				else if(f2==0)
					f2=l1;
				else
				{
					ErrorInfo(1280);
					puts("bad let-sub: >2 prtc");
					return;
				}
				continue;
			}
			if(CompoundName(sp)==OPR_WILD)
			{
				if(w)
				{
					ErrorInfo(1281);
					puts("bad let-sub: unk spec");
					return;
				}
				w=l1;
				continue;
			}
			ErrorInfo(110);
			WriteTerm(sp);puts(" : bad let: unk stuff");
			return;
		}
		
		if(f2==0)
		{
			ErrorInfo(112);
			puts("bad let-subs: not 2 prtc");
			return;
		}
		
		l1=f1;f1=ListFirst(f1);ChangeList(l1,0);ln=CutFromList(ln,l1);
		l1=f2;f2=ListFirst(f2);ChangeList(l1,0);ln=CutFromList(ln,l1);
		if(w)
		{l1=w;w=ListFirst(w);ChangeList(l1,0);ln=CutFromList(ln,l1);}
		
		ln=SortedList(ln,prmcmp);
		ld=SortedList(ld,prmcmp);
		
		if((GetAtomProperty(CompoundArg2(f1),A_ANTI)==CompoundArg2(f1) ||
				GetAtomProperty(CompoundArg2(f2),A_ANTI)==CompoundArg2(f2))
			&& strcmp(AtomValue(CompoundArg2(f1)),AtomValue(CompoundArg2(f2)))>0)
		{
			Term tmp=f1;
			f1=f2;
			f2=tmp;
		}
		
		if(ListLength(CompoundArg1(f1))==1 && ListLength(CompoundArg1(f1))==1)
		{
			Term i1=ListFirst(CompoundArg1(f1));
			Term i2=ListFirst(CompoundArg1(f2));
			if(CompoundName(CompoundArg1(i1))!=A_COLOR ||
				CompoundName(CompoundArg1(i2))!=A_COLOR ||
					CompoundArg2(i1)!=CompoundArg2(i2))
			{
				ErrorInfo(233);
				puts("bad color stru in let-sub.");
				return;
			}
			SetCompoundArg(i1,2,mylbl);
			SetCompoundArg(i2,2,mylbl);
		}
		
		ln=AppendLast(ln,f1);
		ln=AppendLast(ln,f2);
		if(w) ln=AppendLast(ln,w);
		
		SetCompoundArg(m1,1,NewInteger(n));
		SetCompoundArg(m1,2,NewInteger(d));
		SetCompoundArg(m1,3,ln);
		SetCompoundArg(m1,4,ld);
		
		for(l1=nl;l1;l1=ListTail(l1))
		{
			if(EqualTerms(CompoundArgN(ListFirst(l1),3),ln) &&
					EqualTerms(CompoundArgN(ListFirst(l1),4),ld) &&
					IntegerValue(CompoundArg2(ListFirst(l1)))*d>0)
			{
				Term om1=ListFirst(l1);
				int n1=IntegerValue(CompoundArg1(om1));
				int d1=IntegerValue(CompoundArg2(om1));
				int rn,rd,cc=0;
				if(d1<0)
				{
					d=-d;d1=-d1;cc=1;
				}
				rn=n*d1+n1*d;
				rd=d*d1;
				if(rn==0)
				{
					nl=CutFromList(nl,l1);
					break;
				}
				g=gcf(rn,rd);
				rn/=g; rd/=g;
				if(cc) rd=-rd;
				SetCompoundArg(om1,1,NewInteger(rn));
				SetCompoundArg(om1,2,NewInteger(rd));
				FreeAtomic(m1);
				break;
			}
		}
		
		if(l1==0)
			nl=AppendLast(nl,m1);
		
	}
	
	RemoveList(lm);
	/*DumpList(nl);*/
	
	/*printf("%d\n",ListLength(nl));*/
	SetCompoundArg(a1,1,nl);
}
Exemplo n.º 13
0
static List s_l_1(Term m1)
	{
	List l,l1;
	
	l=CompoundArgN(m1,3);
	while(!is_empty_list(l))
		{
		Term t1;
		t1=ListFirst(l);
		if(CompoundName(t1)==OPR_LET)
			{
			Term sub,a1,ila,ill;
			a1=sub=ConsumeCompoundArg(t1,2);
			ill=ConsumeCompoundArg(t1,1);
			FreeAtomic(t1);
			ChangeList(l,0);
			
			sub=CopyTerm(GetAtomProperty(a1,OPR_LET));
			if(sub==0 || !is_compound(sub) || CompoundName(sub)!=OPR_LET)
				{
				sub=CopyTerm(GetAtomProperty(a1,PROP_TYPE));
				if(sub==0 || !is_compound(sub) || CompoundName(sub)!=OPR_LET)
					{
					printf("Internal error: inconsistent substitution '");
					WriteTerm(CompoundArg2(a1));
					puts("'");
					longjmp(alg1_jmp_buf,1);
					}
				}
			renewlab(sub);
				
			a1=ConsumeCompoundArg(sub,1);
			ila=ConsumeCompoundArg(sub,2);
			FreeAtomic(sub);
			repl_ind(a1,ila,ill);
			
			return SetLets(mk_let(m1,l,a1));
			
			}
		l=ListTail(l);
		}
	
	
	l=CompoundArgN(m1,4);
	while(!is_empty_list(l))
		{
		Term t1;
		t1=ListFirst(l);
		if(CompoundName(t1)==OPR_LET)
			{
			Term sub,a1,ila,ill;
			a1=sub=ConsumeCompoundArg(t1,2);
			ill=ConsumeCompoundArg(t1,1);
			if(ill)
				{
				puts("Integnal error (iinld)");
				longjmp(alg1_jmp_buf,1);
				}
			
			l1=ConsumeCompoundArg(m1,4);
			l1=CutFromList(l1,l);
			SetCompoundArg(m1,4,l1);
			sub=CopyTerm(GetAtomProperty(a1,OPR_LET));
			if(sub==0 || !is_compound(sub) || CompoundName(sub)!=OPR_LET)
				{
				sub=CopyTerm(GetAtomProperty(a1,PROP_TYPE));
				if(sub==0 || !is_compound(sub) || CompoundName(sub)!=OPR_LET)
					{
					printf("Internal error: inconsistent substitution '");
					WriteTerm(CompoundArg2(a1));
					puts("'");
					longjmp(alg1_jmp_buf,1);
					}
				}
			renewlab(sub);
				
			if(CompoundArgN(sub,3)==0)
				{
				ErrorInfo(378);
				printf("symbol '%s' can not be in denominator\n",AtomValue(a1));
				longjmp(alg1_jmp_buf,1);
				}

			a1=ConsumeCompoundArg(sub,3);
			ila=ConsumeCompoundArg(sub,2);
			FreeAtomic(sub);
			if(ila)
				{
				puts("Internal error (iidl1)");
				longjmp(alg1_jmp_buf,1);
				}
				
			
			return SetLets(mk_let_d(m1,a1));
			
			}
		l=ListTail(l);
		}
		
	

	
	return AppendFirst(NewList(),m1);
	}
Exemplo n.º 14
0
static List mk_let_d(Term m1,  Term a1)
	{
	List l,l2;
	List lb;
	List sd;
	int num1,den1;
	int io1=0,io2=0,rmn=0;
	
	for(l=CompoundArgN(m1,3);l;l=ListTail(l))
	{
		Term prp=0;
		if(CompoundName(ListFirst(l))==OPR_PARAMETER)
				prp=GetAtomProperty(CompoundArg2(ListFirst(l)),A_INFINITESIMAL);
		if(prp && IntegerValue(CompoundArg1(prp))>0)
				io1+=IntegerValue(CompoundArg1(prp));
		if(CompoundName(ListFirst(l))==A_INFINITESIMAL)
				io1+=IntegerValue(CompoundArg2(ListFirst(l)));
	}


	l=ConsumeCompoundArg(a1,1);
	FreeAtomic(a1);
	a1=l;


	for(l2=a1;l2;l2=ListTail(l2))
	{
		Term m11=ListFirst(l2);
		io2=0;
		for(l=CompoundArgN(m11,3);l;l=ListTail(l))
		{
			Term prp=0;
			if(CompoundName(ListFirst(l))==OPR_PARAMETER)
					prp=GetAtomProperty(CompoundArg2(ListFirst(l)),A_INFINITESIMAL);
			if(prp && IntegerValue(CompoundArg1(prp))>0)
					io2+=IntegerValue(CompoundArg1(prp));
			if(CompoundName(ListFirst(l))==A_INFINITESIMAL)
					io2+=IntegerValue(CompoundArg2(ListFirst(l)));
		}
		if(io1+io2>infi_order)
		{
			FreeAtomic(ListFirst(l2));
			ChangeList(l2,0);
			rmn++;
		}
	}
	
	if(rmn)
		do
		{
			for(l=a1;l;l=ListTail(l))
				if(ListFirst(l)==0)
				{
					a1=CutFromList(a1,l);
					break;
				}
		}
		while(l);

	
	num1=IntegerValue(ConsumeCompoundArg(m1,1));
	den1=IntegerValue(ConsumeCompoundArg(m1,2));
	l=ConsumeCompoundArg(m1,3);
	sd=ConsumeCompoundArg(m1,4);
	lb=l;
	FreeAtomic(m1);
	
	l=a1;
	while(!is_empty_list(l))
		{
		int n1,n2,d1,d2,num,den,cf;
		List lb1,lm;
		m1=ListFirst(l);
		lm=ConsumeCompoundArg(m1,3);
		lb1=CopyTerm(lb);
		lb1=ConcatList(lb1,lm);
		SetCompoundArg(m1,3,lb1);
		
		lm=ConsumeCompoundArg(m1,4);
		lm=ConcatList(lm,CopyTerm(sd));
		SetCompoundArg(m1,4,lm);
		
		n1=num1;
		d1=den1;
		n2=IntegerValue(CompoundArg1(m1));
		d2=IntegerValue(CompoundArg2(m1));
		num=n1*n2;
		den=d1*d2;
		if(den<0) den=-den;
		cf=gcf(num,den);
		num/=cf;
		den/=cf;
		if(d1<0 && d2<0)
			{
			num=-num;
			}
		else
			if((d1<0 && d2>0) || (d1>0 && d2<0))
				{
				den=-den;
				}
		SetCompoundArg(m1,1,NewInteger(num));
		SetCompoundArg(m1,2,NewInteger(den));
		l=ListTail(l);
		}
	FreeAtomic(lb);
	FreeAtomic(sd);
	return a1;
	}
Exemplo n.º 15
0
//=====================================================================================
//
//	* Function : RightSpoof()
//	* Description 
//		이 함수는 위의 ChildRightProc콜백함수의 WM_SPOOF메시지에 대응하는 메시지 처리 함수
//		이다. wParam로 SM_INIT, SM_CHANGE, SM_ADD등 종류의 메시지를 보내어 탐지모듈들과
//		데이터를 주도받을 수 있다.
//
//=====================================================================================
LRESULT RightSpoof(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	static PSPOOF_L HEAD=NULL;
	PSPOOF_L __ARP_LIST=(PSPOOF_L)lParam;
	INT LIST_index;
	ARPDATA* arpnode;
	char hostStr[17];
	
	switch(wParam)
		{
		//List View를 초기화할 때 쓰는 메시지이다.
		case SM_INIT:
			HEAD=__ARP_LIST;
			ListView_DeleteAllItems(hWnd);
			while(__ARP_LIST!=NULL){
				AddList(hWnd,__ARP_LIST);
				__ARP_LIST=__ARP_LIST->next;
			}
			ChangeState();
			SendMessage(hC2,WM_PAINT,0,0);
			break;
		//List View의 해당 인덱스를 변경할 때 쓰는 메시지이다.
		case SM_CHANGE:
			LIST_index=ChatchChange(hWnd,__ARP_LIST,HEAD);
			ChangeList(LIST_index);
			/* 의심이나 공격상황에 트레이 발생*/
			if(__ARP_LIST->flag==SUSPICIOUS || __ARP_LIST->flag==ATTACK){
				nid.cbSize = sizeof(NOTIFYICONDATA);
				nid.hWnd = hWndMain;
				nid.uID = 0;
				nid.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE|NIF_INFO;
				nid.dwInfoFlags = 0x0006;
				nid.uTimeout = 500;
				nid.hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON1));
				lstrcpy(nid.szInfoTitle, TEXT("주의상황"));
				wsprintf(nid.szTip, TEXT("의심스러운 %d.%d.%d.%d"),
					__ARP_LIST->ipAddr[0],__ARP_LIST->ipAddr[1],__ARP_LIST->ipAddr[2],__ARP_LIST->ipAddr[3]);
				wsprintf(nid.szInfo, TEXT("의심스러운 %d.%d.%d.%d가 프로그램에 포착되었습니다."),
					__ARP_LIST->ipAddr[0],__ARP_LIST->ipAddr[1],__ARP_LIST->ipAddr[2],__ARP_LIST->ipAddr[3]);
				Shell_NotifyIcon(NIM_MODIFY, &nid);
			}
			break;
		//List View를 더할 때 쓰는 메시지이다.
		case SM_ADD:
			get_hostname(__ARP_LIST->ipAddr, hostStr);
			add_hostname(ARP_LIST,__ARP_LIST->ipAddr,hostStr);
			AddList(hWnd,__ARP_LIST);
			break;
		case SM_NODEVICE:
			MessageBox(hWnd,TEXT("인터페이스를 찾을수 없습니다.\nWinpcap이 설치 되었는지 확인해 주시기 바랍니다."),TEXT("알림"),MB_OK);
			break;
		case SM_STOP_THREAD:
			SuspendThread(hThread);
			break;
		case SM_RESUME_THREAD:
			ResumeThread(hThread);
			break;
		case SM_UPDATE_HOSTNAME:
			LIST_index=ChatchChange(hWnd,__ARP_LIST,HEAD);
			ChangeList(LIST_index);
			break;
		case SM_UPDATE_LIST_NOMAL:
			arpnode = (ARPDATA*)lParam;
			updateState(ARP_LIST,NOMAL,arpnode->ipAddr,arpnode->macAddr, arpnode->vendor,arpnode->timestr," ");
			break;
		case SM_UPDATE_LIST_SUSP:
			arpnode = (ARPDATA*)lParam;
			updateState(ARP_LIST,SUSPICIOUS,arpnode->ipAddr,arpnode->macAddr, arpnode->vendor,arpnode->timestr," ");
			break;
		case SM_UPDATE_LIST_ATTACK:
			arpnode = (ARPDATA*)lParam;
			updateState(ARP_LIST,ATTACK,arpnode->ipAddr,arpnode->macAddr, arpnode->vendor,arpnode->timestr," ");
			break;
		case SM_UPDATE_LIST_STATIC:
			arpnode = (ARPDATA*)lParam;
			updateState(ARP_LIST,STATIC,arpnode->ipAddr,arpnode->macAddr, arpnode->vendor,arpnode->timestr," ");
	}
		return 0;
}
Exemplo n.º 16
0
void alg2_common_n(Term a2)
	{
	List m2l,l,l1,nl,dl;
	int cnum,cden,ti;
	m2l=CompoundArgN(a2,5);
	nl=dl=NewList();
	l=m2l;
	if(is_empty_list(l))
		return;


	while(!is_empty_list(l))
		{
		Term t;
		t=ConsumeCompoundArg(ListFirst(l),1);
		nl=AppendLast(nl,CompoundArg1(t));
		dl=AppendLast(dl,CompoundArg2(t));
		FreeAtomic(t);
		l=ListTail(l);
		}

	cnum=gcf_list(nl);
	cden=gcf_list(dl);
	if(IntegerValue(ListFirst(nl))<0)
		cnum*=-1;
	
	l=nl;
	l1=dl;
	while(!is_empty_list(l))
		{
		ChangeList(l,NewInteger(IntegerValue(ListFirst(l))/cnum));
		ChangeList(l1,NewInteger(IntegerValue(ListFirst(l1))/cden));
		l=ListTail(l);
		l1=ListTail(l1);
		}

	ti=mlt_list1(dl);

	l=nl;
	l1=dl;
	while(!is_empty_list(l))
		{
		ChangeList(l,
			NewInteger(IntegerValue(ListFirst(l))*ti/IntegerValue(ListFirst(l1))));
		l=ListTail(l);
		l1=ListTail(l1);
		}

	cden*=ti;
	ti=gcf_list(nl);
	cnum*=ti;

	l=nl;
	while(!is_empty_list(l))
		{
		ChangeList(l,NewInteger(IntegerValue(ListFirst(l))/ti));
		l=ListTail(l);
		}

	ti=gcf(cnum,cden);
	cnum/=ti;
	cden/=ti;
	RemoveList(dl);

	SetCompoundArg(a2,2,MakeCompound2(OPR_DIV,NewInteger(cnum),NewInteger(cden)));
	l=m2l;
	l1=nl;

	while(!is_empty_list(l))
		{
		SetCompoundArg(ListFirst(l),1,ListFirst(l1));
		l1=ListTail(l1);
		l=ListTail(l);
		}
	RemoveList(nl);

	return ;
	}