예제 #1
0
cell Call_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, cell *params)
{
	SETUP(7);

	Vector v3;
	Vector v4;

	float *fl3=(float *)MF_GetAmxAddr(amx, params[3]);
	float *fl4=(float *)MF_GetAmxAddr(amx, params[4]);

	v3.x=fl3[0];
	v3.y=fl3[1];
	v3.z=fl3[2];

	v4.x=fl4[0];
	v4.y=fl4[1];
	v4.z=fl4[2];

	float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));

	int id6=*MF_GetAmxAddr(amx, params[6]);
	CHECK_ENTITY(id6);
	void *p6 = TypeConversion.id_to_cbase(id6);

	Vector v7;
	float *fl7=(float *)MF_GetAmxAddr(amx, params[7]);

	v7.x=fl7[0];
	v7.y=fl7[1];
	v7.z=fl7[2];

	Vector v8;
	float *fl8=(float *)MF_GetAmxAddr(amx, params[8]);

	v8.x=fl8[0];
	v8.y=fl8[1];
	v8.z=fl8[2];

	bool b9=*MF_GetAmxAddr(amx, params[9]) > 0;

#if defined(_WIN32)
	int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector*, Vector*, float, void*, Vector*, Vector*, bool)>(__func)(pv, 0, &v3, &v4, f5, p6, &v7, &v8, b9);
#elif defined(__linux__) || defined(__APPLE__)
	int ret=reinterpret_cast<int (*)(void *, Vector*, Vector*, float, void*, Vector*, Vector*, bool)>(__func)(pv, &v3, &v4, f5, p6, &v7, &v8, b9);
#endif

	fl3[0]=v3.x;
	fl3[1]=v3.y;
	fl3[2]=v3.z;

	fl4[0]=v4.x;
	fl4[1]=v4.y;
	fl4[2]=v4.z;

	fl7[0]=v7.x;
	fl7[1]=v7.y;
	fl7[2]=v7.z;

	fl8[0]=v8.x;
	fl8[1]=v8.y;
	fl8[2]=v8.z;

	return ret;
}
예제 #2
0
파일: engine.c 프로젝트: JinSeok/GIT_Test
/*
 - matcher - the actual matching engine
 */
static int			/* 0 success, REG_NOMATCH failure */
matcher(struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[],
    int eflags)
{
	char *endp;
	int i;
	struct match mv;
	struct match *m = &mv;
	char *dp;
	const sopno gf = g->firststate+1;	/* +1 for OEND */
	const sopno gl = g->laststate;
	char *start;
	char *stop;

	/* simplify the situation where possible */
	if (g->cflags&REG_NOSUB)
		nmatch = 0;
	if (eflags&REG_STARTEND) {
		start = string + pmatch[0].rm_so;
		stop = string + pmatch[0].rm_eo;
	} else {
		start = string;
		stop = start + strlen(start);
	}
	if (stop < start)
		return(REG_INVARG);

	/* prescreening; this does wonders for this rather slow code */
	if (g->must != NULL) {
		for (dp = start; dp < stop; dp++)
			if (*dp == g->must[0] && stop - dp >= g->mlen &&
				memcmp(dp, g->must, (size_t)g->mlen) == 0)
				break;
		if (dp == stop)		/* we didn't find g->must */
			return(REG_NOMATCH);
	}

	/* match struct setup */
	m->g = g;
	m->eflags = eflags;
	m->pmatch = NULL;
	m->lastpos = NULL;
	m->offp = string;
	m->beginp = start;
	m->endp = stop;
	STATESETUP(m, 4);
	SETUP(m->st);
	SETUP(m->fresh);
	SETUP(m->tmp);
	SETUP(m->empty);
	CLEAR(m->empty);

	/* this loop does only one repetition except for backrefs */
	for (;;) {
		endp = fast(m, start, stop, gf, gl);
		if (endp == NULL) {		/* a miss */
			free(m->pmatch);
			free(m->lastpos);
			STATETEARDOWN(m);
			return(REG_NOMATCH);
		}
		if (nmatch == 0 && !g->backrefs)
			break;		/* no further info needed */

		/* where? */
		assert(m->coldp != NULL);
		for (;;) {
			NOTE("finding start");
			endp = slow(m, m->coldp, stop, gf, gl);
			if (endp != NULL)
				break;
			assert(m->coldp < m->endp);
			m->coldp++;
		}
		if (nmatch == 1 && !g->backrefs)
			break;		/* no further info needed */

		/* oh my, he wants the subexpressions... */
		if (m->pmatch == NULL)
			m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
							sizeof(regmatch_t));
		if (m->pmatch == NULL) {
			STATETEARDOWN(m);
			return(REG_ESPACE);
		}
		for (i = 1; i <= (int)m->g->nsub; i++)
			m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
		if (!g->backrefs && !(m->eflags&REG_BACKR)) {
			NOTE("dissecting");
			dp = dissect(m, m->coldp, endp, gf, gl);
		} else {
			if (g->nplus > 0 && m->lastpos == NULL)
				m->lastpos = (char **)malloc((g->nplus+1) *
							sizeof(char *));
			if (g->nplus > 0 && m->lastpos == NULL) {
				free(m->pmatch);
				STATETEARDOWN(m);
				return(REG_ESPACE);
			}
			NOTE("backref dissect");
			dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0);
		}
		if (dp != NULL)
			break;

		/* uh-oh... we couldn't find a subexpression-level match */
		assert(g->backrefs);	/* must be back references doing it */
		assert(g->nplus == 0 || m->lastpos != NULL);
		for (;;) {
			if (dp != NULL || endp <= m->coldp)
				break;		/* defeat */
			NOTE("backoff");
			endp = slow(m, m->coldp, endp-1, gf, gl);
			if (endp == NULL)
				break;		/* defeat */
			/* try it on a shorter possibility */
#ifndef NDEBUG
			for (i = 1; i <= m->g->nsub; i++) {
				assert(m->pmatch[i].rm_so == -1);
				assert(m->pmatch[i].rm_eo == -1);
			}
#endif
			NOTE("backoff dissect");
			dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0);
		}
		assert(dp == NULL || dp == endp);
		if (dp != NULL)		/* found a shorter one */
			break;

		/* despite initial appearances, there is no match here */
		NOTE("false alarm");
		if (m->coldp == stop)
			break;
		start = m->coldp + 1;	/* recycle starting later */
	}

	/* fill in the details if requested */
	if (nmatch > 0) {
		pmatch[0].rm_so = m->coldp - m->offp;
		pmatch[0].rm_eo = endp - m->offp;
	}
	if (nmatch > 1) {
		assert(m->pmatch != NULL);
		for (i = 1; i < (ssize_t)nmatch; i++)
			if (i <= (int)m->g->nsub)
				pmatch[i] = m->pmatch[i];
			else {
				pmatch[i].rm_so = -1;
				pmatch[i].rm_eo = -1;
			}
	}

	if (m->pmatch != NULL)
		free((char *)m->pmatch);
	if (m->lastpos != NULL)
		free((char *)m->lastpos);
	STATETEARDOWN(m);
	return(0);
}
예제 #3
0
static inline int rt_setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs)
{
	int err = 0;

#define SETUP(x) err |= __put_user(regs->x, &sc->sc_##x)

	SETUP(r0); SETUP(r1); SETUP(r2); SETUP(r3);
	SETUP(r4); SETUP(r5); SETUP(r6); SETUP(r7);
	SETUP(p0); SETUP(p1); SETUP(p2); SETUP(p3);
	SETUP(p4); SETUP(p5);
	err |= __put_user(rdusp(), &sc->sc_usp);
	SETUP(a0w); SETUP(a1w);
	SETUP(a0x); SETUP(a1x);
	SETUP(astat);
	SETUP(rets);
	SETUP(pc);
	SETUP(retx);
	SETUP(fp);
	SETUP(i0); SETUP(i1); SETUP(i2); SETUP(i3);
	SETUP(m0); SETUP(m1); SETUP(m2); SETUP(m3);
	SETUP(l0); SETUP(l1); SETUP(l2); SETUP(l3);
	SETUP(b0); SETUP(b1); SETUP(b2); SETUP(b3);
	SETUP(lc0); SETUP(lc1);
	SETUP(lt0); SETUP(lt1);
	SETUP(lb0); SETUP(lb1);
	SETUP(seqstat);

	return err;
}
예제 #4
0
int
ftpparse_mlsx (struct ftpparse *fp, char *x, int ll, int is_mlst)
{
  int i;
  uint64 size;
  struct tai mtime;
  int flagtryretr=0;
  int flagtrycwd=0;
  char *id=0;
  int idlen=0;
  int mtimetype=FTPPARSE_MTIME_UNKNOWN;
  int sizetype=FTPPARSE_SIZE_UNKNOWN;
  int flagbrokenmlsx=0;
  SETUP();
  if (is_mlst)
    if (ll>1) {
      ll--;
      x++;
    }
  if (ll<2) /* empty facts, space, one-byte-filename */
    return 0;

  for (i=0; i<ll;i++) {
    int j=0,k=0;
    if (x[i]==' ')
      break; /* end of facts */
    while (i+j<ll && x[i+j]!=';' && x[i+j]!=' ' && x[i+j]!='=')
      j++;
    if (i+j==ll)
      return 0;
    if (x[i+j]==' ')
      return 0;
    if (x[i+j]==';')
      return 0;
    /* x[i+j] is now '=' */
    while (i+j+k<ll && x[i+j+k]!=';' && x[i+j+k]!=' ')
      k++;
    if (i+j+k==ll)
      return 0;
    /* x[i+j+k] is space or semicolon, so use of getlong is safe */
#define ISFACT(name) (j==sizeof(name)-1 && case_startb(x+i,j,name))
    if (ISFACT ("size")) {
      get_uint64 (x + i + j + 1, k - 1,&size);
      sizetype=FTPPARSE_SIZE_BINARY;
    } else if (ISFACT ("modify")) {
      getmod(&mtime,x + i + j + 1, k - 1);
      mtimetype = FTPPARSE_MTIME_LOCAL;
    } else if (ISFACT ("type")) {
      if (k==5 && case_startb (x + i + j + 1, 4, "file"))
	flagtryretr = 1;
      else if (case_startb (x + i + j + 1, 3, "dir")) /* "current" */
	flagtrycwd = 1;
      else if (case_startb (x + i + j + 1, 4, "pdir")) /* "parent" */
	flagtrycwd = 1;
      else if (case_startb (x + i + j + 1, 4, "cdir"))
	flagtrycwd = 1;
      else {
        flagtryretr = 1;
        flagtrycwd = 1;
      }
    } else if (ISFACT ("unique")) {
      id = x + i + j + 1;
      idlen = k - 1;
    }
    i+=j+k;
    if (x[i]==' ') {
      flagbrokenmlsx=1;
      break;
    }
  }
  if (ll==i) return 0;
  i++;
  if (ll==i) return 0;
  fp->name = x + i;
  fp->namelen = ll - i;
  fp->sizetype = sizetype;
  fp->size=size;
  fp->mtimetype = mtimetype;
  fp->mtime=mtime;
  fp->flagtrycwd=flagtrycwd;
  fp->flagtryretr=flagtryretr;
  if (id) {
    fp->idtype = FTPPARSE_ID_FULL;
    fp->id=id;
    fp->idlen=idlen;
  }
  fp->flagbrokenmlsx=flagbrokenmlsx;
  fp->format=FTPPARSE_FORMAT_MLSX;
  return 1;
}
예제 #5
0
/*
 - matcher - the actual matching engine
 == static int matcher(struct re_guts *g, const char *string, \
 ==	size_t nmatch, regmatch_t pmatch[], int eflags);
 */
static int			/* 0 success, REG_NOMATCH failure */
matcher(struct re_guts *g,
	const char *string,
	size_t nmatch,
	regmatch_t pmatch[],
	int eflags)
{
	const char *endp;
	int i;
	struct match mv;
	struct match *m = &mv;
	const char *dp;
	const sopno gf = g->firststate+1;	/* +1 for OEND */
	const sopno gl = g->laststate;
	const char *start;
	const char *stop;
	/* Boyer-Moore algorithms variables */
	const char *pp;
	int cj, mj;
	const char *mustfirst;
	const char *mustlast;
	int *matchjump;
	int *charjump;

	/* simplify the situation where possible */
	if (g->cflags&REG_NOSUB)
		nmatch = 0;
	if (eflags&REG_STARTEND) {
		start = string + pmatch[0].rm_so;
		stop = string + pmatch[0].rm_eo;
	} else {
		start = string;
		stop = start + strlen(start);
	}
	if (stop < start)
		return(REG_INVARG);

	/* prescreening; this does wonders for this rather slow code */
	if (g->must != NULL) {
		if (g->charjump != NULL && g->matchjump != NULL) {
			mustfirst = g->must;
			mustlast = g->must + g->mlen - 1;
			charjump = g->charjump;
			matchjump = g->matchjump;
			pp = mustlast;
			for (dp = start+g->mlen-1; dp < stop;) {
				/* Fast skip non-matches */
				while (dp < stop && charjump[(int)*dp])
					dp += charjump[(int)*dp];

				if (dp >= stop)
					break;

				/* Greedy matcher */
				/* We depend on not being used for
				 * for strings of length 1
				 */
				while (*--dp == *--pp && pp != mustfirst);

				if (*dp == *pp)
					break;

				/* Jump to next possible match */
				mj = matchjump[pp - mustfirst];
				cj = charjump[(int)*dp];
				dp += (cj < mj ? mj : cj);
				pp = mustlast;
			}
			if (pp != mustfirst)
				return(REG_NOMATCH);
		} else {
			for (dp = start; dp < stop; dp++)
				if (*dp == g->must[0] &&
				    stop - dp >= g->mlen &&
				    memcmp(dp, g->must, (size_t)g->mlen) == 0)
					break;
			if (dp == stop)		/* we didn't find g->must */
				return(REG_NOMATCH);
		}
	}

	/* match struct setup */
	m->g = g;
	m->eflags = eflags;
	m->pmatch = NULL;
	m->lastpos = NULL;
	m->offp = string;
	m->beginp = start;
	m->endp = stop;
	STATESETUP(m, 4);
	SETUP(m->st);
	SETUP(m->fresh);
	SETUP(m->tmp);
	SETUP(m->empty);
	CLEAR(m->empty);
	ZAPSTATE(&m->mbs);

	/* Adjust start according to moffset, to speed things up */
	if (g->moffset > -1)
		start = ((dp - g->moffset) < start) ? start : dp - g->moffset;

	/* this loop does only one repetition except for backrefs */
	for (;;) {
		endp = fast(m, start, stop, gf, gl);
		if (endp == NULL) {		/* a miss */
			if (m->pmatch != NULL)
				free((char *)m->pmatch);
			if (m->lastpos != NULL)
				free((char *)m->lastpos);
			STATETEARDOWN(m);
			return(REG_NOMATCH);
		}
		if (nmatch == 0 && !g->backrefs)
			break;		/* no further info needed */

		/* where? */
		assert(m->coldp != NULL);
		for (;;) {
			NOTE("finding start");
			endp = slow(m, m->coldp, stop, gf, gl);
			if (endp != NULL)
				break;
			assert(m->coldp < m->endp);
			m->coldp += XMBRTOWC(NULL, m->coldp,
			    m->endp - m->coldp, &m->mbs, 0);
		}
		if (nmatch == 1 && !g->backrefs)
			break;		/* no further info needed */

		/* oh my, he wants the subexpressions... */
		if (m->pmatch == NULL)
			m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
							sizeof(regmatch_t));
		if (m->pmatch == NULL) {
			STATETEARDOWN(m);
			return(REG_ESPACE);
		}
		for (i = 1; i <= m->g->nsub; i++)
			m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
		if (!g->backrefs && !(m->eflags&REG_BACKR)) {
			NOTE("dissecting");
			dp = dissect(m, m->coldp, endp, gf, gl);
		} else {
			if (g->nplus > 0 && m->lastpos == NULL)
				m->lastpos = malloc((g->nplus+1) *
						sizeof(const char *));
			if (g->nplus > 0 && m->lastpos == NULL) {
				free(m->pmatch);
				STATETEARDOWN(m);
				return(REG_ESPACE);
			}
			NOTE("backref dissect");
			dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0);
		}
		if (dp != NULL)
			break;

		/* uh-oh... we couldn't find a subexpression-level match */
		assert(g->backrefs);	/* must be back references doing it */
		assert(g->nplus == 0 || m->lastpos != NULL);
		for (;;) {
			if (dp != NULL || endp <= m->coldp)
				break;		/* defeat */
			NOTE("backoff");
			endp = slow(m, m->coldp, endp-1, gf, gl);
			if (endp == NULL)
				break;		/* defeat */
			/* try it on a shorter possibility */
#ifndef NDEBUG
			for (i = 1; i <= m->g->nsub; i++) {
				assert(m->pmatch[i].rm_so == -1);
				assert(m->pmatch[i].rm_eo == -1);
			}
#endif
			NOTE("backoff dissect");
			dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0);
		}
		assert(dp == NULL || dp == endp);
		if (dp != NULL)		/* found a shorter one */
			break;

		/* despite initial appearances, there is no match here */
		NOTE("false alarm");
		/* recycle starting later */
		start = m->coldp + XMBRTOWC(NULL, m->coldp,
		    stop - m->coldp, &m->mbs, 0);
		assert(start <= stop);
	}

	/* fill in the details if requested */
	if (nmatch > 0) {
		pmatch[0].rm_so = m->coldp - m->offp;
		pmatch[0].rm_eo = endp - m->offp;
	}
	if (nmatch > 1) {
		assert(m->pmatch != NULL);
		for (i = 1; i < nmatch; i++)
			if (i <= m->g->nsub)
				pmatch[i] = m->pmatch[i];
			else {
				pmatch[i].rm_so = -1;
				pmatch[i].rm_eo = -1;
			}
	}

	if (m->pmatch != NULL)
		free((char *)m->pmatch);
	if (m->lastpos != NULL)
		free((char *)m->lastpos);
	STATETEARDOWN(m);
	return(0);
}
예제 #6
0
파일: lgn_armia.cpp 프로젝트: boskee/lamos
void _ARMIA(aint A) {
	//	Procedure ARMIA[A]

	aint AX=0,AY=0,PL=0,KONIEC=0,TEREN=0,I=0,DANE=0;
	aint STREFA=0,KONIEC2=0,STREFA2=0,TER2=0;

	_rysuj_armia_nr = A;

	AX=ARMIA[A][0][TX];											//	   AX=ARMIA(A,0,TX)
	AY=ARMIA[A][0][TY];											//	   AY=ARMIA(A,0,TY)
	PL=ARMIA[A][0][TMAG];										//	   PL=ARMIA(A,0,TMAG)
	if( PREFS[5]==1 ) {
		WJAZD(AX,AY,80,80,150,100,4);					//	   If PREFS(5)=1 : WJAZD[AX,AY,80,80,150,100,4] : End If
	}

	if( A<20 ) {
		DANE=-1;
	} else {
		if( ARMIA[A][0][TMAGMA]==0 || ARMIA[A][0][TMAGMA]==100 ) {
			DANE=-1;
		}
	}

	if( DANE!=0 ) {
		TEREN=ARMIA[A][0][TNOGI];
		AX=ARMIA[A][0][TX];
		AY=ARMIA[A][0][TY];
	}

	rysuj();
	_ARMIA_RYSUJ_INFO(A);

	void *sb=0, *sb2=0;
	sb = StoreBuffer(OKX-1,OKY-1,150+2,100+2);

	do {																		//	   Repeat
		rysuj();
		RestoreBuffer(sb);
		WaitVbl();
		if( MouseClick() ) {									//	      If Mouse Click=1
			STREFA=MouseZone();									//	         STREFA=Mouse Zone
			if( STREFA==1 || STREFA==0 ) {			//	         If STREFA=1 or STREFA=0
				KONIEC=-1;												//	            KONIEC=True
				ZOKNO();													//	            ZOKNO
			}																		//	         End If
			if( STREFA==11 ) {									//	         If STREFA=11
				//WPISZ(OKX+50,OKY+15,1,30,14,0);			//	            WPISZ[OKX+50,OKY+15,1,30,14]

				_rysuj_tlo_armia = rysuj_ekran_ptr;
				rysuj_ekran_ptr = _rysuj_armia;
				WPISZ_PC(OKX+50,OKY+15-TextBase(),100,10,14,ARMIA_S[A][0],2);	//rysuj tylko tlo i kursor
				rysuj_ekran_ptr = _rysuj_tlo_armia;
				sb = StoreBuffer(OKX-1,OKY-1,150+2,100+2);

				ARMIA_S[A][0]=WPI_S;							//	            ARMIA$(A,0)=WPI$
			}																		//	         End If
			if( STREFA==10 && A<20 ) {					//	         If STREFA=10 and A<20
				ZOKNO();													//	            ZOKNO
				KONIEC=-1;												//	            KONIEC=True
				rysuj();
				_ARMIA_RYSUJ_ROZKAZY(A);					//	            Gosub RYSUJ_ROZKAZY
				sb2 = StoreBuffer(OKX-1,OKY-1,80+2,150+2);
				KONIEC2=0;												//	            KONIEC2=False
				do {															//	            Repeat
					rysuj();
					RestoreBuffer(sb2);
					WaitVbl();
					if( MouseClick() ) {						//	               If Mouse Click=1
						STREFA2=MouseZone();					//	                  STREFA2=Mouse Zone
						if( STREFA2>0 && STREFA2<4 ) {//	                  If STREFA2>0 and STREFA2<4
							ZOKNO();										//	                     ZOKNO
							M_RUCH(A,STREFA2);					//	                     M_RUCH[A,STREFA2]
							KONIEC2=-1; KONIEC=-1;			//	                     KONIEC2=True : KONIEC=True
						}															//	                  End If
						if( STREFA2==4 && TEREN<70 ) {//	                  If STREFA2=4 and TEREN<70
							ZOKNO();										//	                     ZOKNO
							ARMIA[A][0][TTRYB]=4;				//	                     ARMIA(A,0,TTRYB)=4
							KONIEC2=-1; KONIEC=-1;			//	                     KONIEC=True : KONIEC2=True
						}															//	                  End If
						if( STREFA2==4 && TEREN>69 ) {//	                  If STREFA2=4 and TEREN>69
							if( MIASTA[TEREN-70][0][M_CZYJE]==1 ) {//	                     If MIASTA(TEREN-70,0,M_CZYJE)=1
								ZOKNO();									//	                        ZOKNO
								ARMIA[A][0][TTRYB]=0;			//	                        ARMIA(A,0,TTRYB)=0
								REKRUTACJA(10,TEREN-70,A);//	                        REKRUTACJA[10,TEREN-70,A]
								_ARMIA_RYSUJ_ROZKAZY(A);		//	                        Gosub RYSUJ_ROZKAZY
							}														//	                     End If
						}															//	                  End If
																					//
						if( STREFA2==6 ) {						//	                  If STREFA2=6
							ZOKNO();										//	                     ZOKNO
							SpriteOnOff(2,false);				//	                     Sprite Off 2
																					//	                     'Auto View Off
							_LOAD(KAT_S+"dane/gad","dane:gad","Dane",1);	//	                     _LOAD[KAT$+"dane/gad","dane:gad","Dane",1]
							ScreenOpen(1,320,160,32,LOWRES);//	                     Screen Open 1,320,160,32,Lowres
							Screen(1);									//	                     Screen 1
																					//	                     Curs Off : Flash Off
							ReserveZone(60);						//	                     Reserve Zone 60 : Get Bob Palette : Set Font FON1
							SetFont(FON1);
							GOBY=44;										//	                     GOBY=44
																					//	                     'Auto View On
							ARM=A;											//	                     ARM=A
							for(I=1;I<=10;++I) {				//	                     For I=1 To 10
								if( ARMIA[A][I][TE]>0 ) {	//	                        If ARMIA(A,I,TE)>0
									NUMER=I;								//	                           NUMER=I
									I=10;										//	                           I=10
								}													//	                        End If
							}														//	                     Next
							WYBOR(1);										//	                     WYBOR[1]
							ScreenClose(1);							//	                     Screen Close 1
							for(I=1;I<=50;++I) {				//	                     For I=1 To 50
								DelBob(GOBY+1);						//	                        Del Bob GOBY+1
							}														//	                     Next
							Screen(0);									//	                     Screen 0
							Sprite(2,SPX,SPY,1);				//	                     Sprite 2,SPX,SPY,1
							_ARMIA_RYSUJ_ROZKAZY(A);			//	                     Gosub RYSUJ_ROZKAZY
						}															//	                  End If
																					//
						if( STREFA2==8 ) {						//	                  If STREFA2=8
							KONIEC=-1;KONIEC2=-1;				//	                     KONIEC=True : KONIEC2=True
							ARMIA[A][0][TWAGA]=1;				//	                     ARMIA(A,0,TWAGA)=1
							ARM=A; WRG=40;							//	                     ARM=A : WRG=40
							SpriteOnOff(2,false);				//	                     Sprite Off 2
							SETUP(GS("070"),GS("071"),GS("072"));			//	                     SETUP["","Action",""]
							if( TEREN>69 ) {						//	                     If TEREN>69
								TER2=MIASTA[TEREN-70][1][M_X];//	                        TER2=MIASTA(TEREN-70,1,M_X)
								RYSUJ_SCENERIE(TER2,TEREN-70);//	                        RYSUJ_SCENERIE[TER2,TEREN-70]
								WRG=40;										//	                        WRG=40
																					//	                        'ustaw wieôniaków
								for(I=1;I<=7;++I) {				//	                        For I=1 To 7 : NOWA_POSTAC[40,I,9] : Next I
									NOWA_POSTAC(40,I,9);
								}
								for(I=8;I<=10;++I) {			//	                        For I=8 To 10 : NOWA_POSTAC[40,I,Rnd(8)] : Next I
									NOWA_POSTAC(40,I,Rnd(8));
								}
								for(I=1;I<=7;++I) {				//	                        For I=1 To 7 : ARMIA(40,I,TKORP)=20 : Next I
									ARMIA[40][I][TKORP]=20;
								}
								for(I=8;I<=10;++I) {			//	                        For I=8 To 10 : ARMIA(WRG,I,TKORP)=40 : Next I
									ARMIA[WRG][I][TKORP]=40;
								}
								ARMIA[40][0][TE]=10;			//	                        ARMIA(40,0,TE)=10
								USTAW_WOJSKO(WRG,1,1,1);	//	                        USTAW_WOJSKO[WRG,1,1,1]
							} else {										//	                     Else
								ARMIA[WRG][0][TE]=0;			//	                        ARMIA(WRG,0,TE)=0
								RYSUJ_SCENERIE(TEREN,-1);	//	                        RYSUJ_SCENERIE[TEREN,-1]
							}														//	                     End If
							USTAW_WOJSKO(ARM,1,1,0);		//	                     USTAW_WOJSKO[ARM,1,1,0]
							MAIN_ACTION();							//	                     MAIN_ACTION
																					//	                     'skasuj wieôniaków
							for(I=0;I<=10;++I) {				//	                     For I=0 To 10 : ARMIA(40,I,TE)=0 : Next I
								ARMIA[40][I][TE]=0;
							}
							SETUP0();										//	                     SETUP0
							VISUAL_OBJECTS();						//	                     VISUAL_OBJECTS
							CENTER(AX,AY,0);						//	                     CENTER[AX,AY,0]
							Sprite(2,SPX,SPY,1);				//	                     Sprite 2,SPX,SPY,1
						}															//	                  End If
																					//
						if( STREFA2==5 ) {						//	                  If STREFA2=5
							ZOKNO();										//	                     ZOKNO
							ARMIA[A][0][TTRYB]=0;				//	                     ARMIA(A,0,TTRYB)=0
							KONIEC=-1;KONIEC2=-1;				//	                     KONIEC=True : KONIEC2=True
						}															//	                  End If
						if( STREFA2==7 ) {						//	                  If STREFA2=7
							ZOKNO();										//	                     ZOKNO
							KONIEC2=-1;									//	                     KONIEC2=True
						}															//	                  End If
					}																//	               End If
				} while( 0==KONIEC2 );						//	            Until KONIEC2
			}																		//	         End If
			if( STREFA==10 && A>19 ) {					//	         If STREFA=10 and A>19
				if( ARMIA[A][0][TMAGMA]==0 ) {		//	            If ARMIA(A,0,TMAGMA)=0
					gad_text(1.0);									//	               Ink 31,6 : Text OKX+48,OKY+89,"@"
					Text(OKX+48,OKY+89,"@");
					ARMIA[A][0][TMAGMA]=100;				//	               ARMIA(A,0,TMAGMA)=100
					goto SKIP;											//	               Goto SKIP
				}																	//	            End If
				if( ARMIA[A][0][TMAGMA]==100 ) {	//	            If ARMIA(A,0,TMAGMA)=100
					gad_text(1.0);									//	               Gr Writing 1 : Ink 6,6
					Text(OKX+47,OKY+89,"  ");				//	               Text OKX+47,OKY+89,"  "
					ARMIA[A][0][TMAGMA]=0;					//	               ARMIA(A,0,TMAGMA)=0
				}																	//	            End If
				if( ARMIA[A][0][TMAGMA]>0 && ARMIA[A][0][TMAGMA]<100 ) {//	            If ARMIA(A,0,TMAGMA)>0 and ARMIA(A,0,TMAGMA)<100
					ZOKNO();												//	               ZOKNO
					KONIEC=-1;											//	               KONIEC=True
					SZPIEGUJ(A,1);									//	               SZPIEGUJ[A,1]
				}																	//	            End If
				SKIP:															//	            SKIP:
					;
			}																		//	         End If
		}																			//	      End If
	} while( KONIEC==0 );										//	   Until KONIEC

	FreeBuffer(sb);
	FreeBuffer(sb2);
																					//	   Goto OVER
																					//	   OVER:
																					//	End Proc
}
예제 #7
0
파일: ruleswidget.cpp 프로젝트: KDE/kwin
RulesWidget::RulesWidget(QWidget* parent)
    : detect_dlg(nullptr)
{
    Q_UNUSED(parent);
    setupUi(this);
    QRegularExpressionValidator* validator = new QRegularExpressionValidator(QRegularExpression("[0-9\\-+,xX:]*"), this);
    maxsize->setValidator(validator);
    minsize->setValidator(validator);
    position->setValidator(validator);
    Ui::RulesWidgetBase::size->setValidator(validator);

    QString enableDesc =
        i18n("Enable this checkbox to alter this window property for the specified window(s).");
    QString setRuleDesc =
        i18n("Specify how the window property should be affected:<ul>"
             "<li><em>Do Not Affect:</em> The window property will not be affected and therefore"
             " the default handling for it will be used. Specifying this will block more generic"
             " window settings from taking effect.</li>"
             "<li><em>Apply Initially:</em> The window property will be only set to the given value"
             " after the window is created. No further changes will be affected.</li>"
             "<li><em>Remember:</em> The value of the window property will be remembered and every"
             " time the window is created, the last remembered value will be applied.</li>"
             "<li><em>Force:</em> The window property will be always forced to the given value.</li>"
             "<li><em>Apply Now:</em> The window property will be set to the given value immediately"
             " and will not be affected later (this action will be deleted afterwards).</li>"
             "<li><em>Force temporarily:</em> The window property will be forced to the given value"
             " until it is hidden (this action will be deleted after the window is hidden).</li>"
             "</ul>");
    QString forceRuleDesc =
        i18n("Specify how the window property should be affected:<ul>"
             "<li><em>Do Not Affect:</em> The window property will not be affected and therefore"
             " the default handling for it will be used. Specifying this will block more generic"
             " window settings from taking effect.</li>"
             "<li><em>Force:</em> The window property will be always forced to the given value.</li>"
             "<li><em>Force temporarily:</em> The window property will be forced to the given value"
             " until it is hidden (this action will be deleted after the window is hidden).</li>"
             "</ul>");
    // window tabs have enable signals done in designer
    // geometry tab
    SETUP(position, set);
    SETUP(size, set);
    SETUP(desktop, set);
    SETUP(screen, set);
#ifdef KWIN_BUILD_ACTIVITIES
    SETUP(activity, set);
#endif
    SETUP(maximizehoriz, set);
    SETUP(maximizevert, set);
    SETUP(minimize, set);
    SETUP(shade, set);
    SETUP(fullscreen, set);
    SETUP(placement, force);
    // preferences tab
    SETUP(above, set);
    SETUP(below, set);
    SETUP(noborder, set);
    SETUP(decocolor, force);
    SETUP(skiptaskbar, set);
    SETUP(skippager, set);
    SETUP(skipswitcher, set);
    SETUP(acceptfocus, force);
    SETUP(closeable, force);
    SETUP(autogroup, force);
    SETUP(autogroupfg, force);
    SETUP(autogroupid, force);
    SETUP(opacityactive, force);
    SETUP(opacityinactive, force);
    SETUP(shortcut, force);
    // workarounds tab
    SETUP(fsplevel, force);
    SETUP(fpplevel, force);
    SETUP(type, force);
    SETUP(ignoregeometry, set);
    SETUP(minsize, force);
    SETUP(maxsize, force);
    SETUP(strictgeometry, force);
    SETUP(disableglobalshortcuts, force);
    SETUP(blockcompositing, force);

    connect (shortcut_edit, SIGNAL(clicked()), SLOT(shortcutEditClicked()));

    edit_reg_wmclass->hide();
    edit_reg_role->hide();
    edit_reg_title->hide();
    edit_reg_machine->hide();

#ifndef KWIN_BUILD_ACTIVITIES
    rule_activity->hide();
    enable_activity->hide();
    activity->hide();
#endif
    int i;
    for (i = 1;
            i <= KWindowSystem::numberOfDesktops();
            ++i)
        desktop->addItem(QString::number(i).rightJustified(2) + ':' + KWindowSystem::desktopName(i));
    desktop->addItem(i18n("All Desktops"));

#ifdef KWIN_BUILD_ACTIVITIES
    m_activities = new KActivities::Consumer(this);
    connect(m_activities, &KActivities::Consumer::activitiesChanged,
            this, [this] { updateActivitiesList(); });
    connect(m_activities, &KActivities::Consumer::serviceStatusChanged,
            this, [this] { updateActivitiesList(); });
    updateActivitiesList();
#endif

    KColorSchemeManager *schemes = new KColorSchemeManager(this);
    decocolor->setModel(schemes->model());

    // hide autogrouping as it's currently not supported
    // BUG 370301
    line_11->hide();
    enable_autogroup->hide();
    autogroup->hide();
    rule_autogroup->hide();
    enable_autogroupid->hide();
    autogroupid->hide();
    rule_autogroupid->hide();
    enable_autogroupfg->hide();
    autogroupfg->hide();
    rule_autogroupfg->hide();
}
예제 #8
0
int main(int argc, char *argv[]) 
{
 
        int number_of_chairs; 
        int maximum_number_customers;
        pid_t customer;
        srand(time(NULL));

        if (argc < 3) 
        {
                printf("You forgot to pass the number of chairs and maximum number of customers (in that order) in the terminal.\nProgram terminated.\n");
                exit(1);
        } 
        else 
        {
                number_of_chairs = strtol(argv[1], NULL, 0);
                maximum_number_customers = strtol(argv[2], NULL, 0);
        }
 
 
        SETUP(); 
 
        int theBarber = SEMAPHORE(SEM_BIN, 1);
        int waitingRoomSeats = SEMAPHORE(SEM_CNT, number_of_chairs); 
 
        customerCount = SHARED_MEMORY(20); 
        *customerCount = 0;
        customerHair = SHARED_MEMORY(20); 
        *customerHair = 0;
        numHaircuts = SHARED_MEMORY(20); 
        *numHaircuts = 1;
 
        pid_t barber = fork(); 
 
        if (barber == 0) 
        {
 
                while(*customerCount < maximum_number_customers) 
                {
 
                        *customerCount+=1; 
                        customer = fork(); 
 
 
                        if (customer == 0) 
                        {
 
                                if (SHOW(waitingRoomSeats) == 0)
                                {
                                        printf("********Customer %d arrived, but leaves because there are %d seats available.\n", *customerCount, SHOW(waitingRoomSeats));
                                }
                                else 
                                {
                                        printf("\nCustomer %d arrived. There are %d seats available.\n", *customerCount, SHOW(waitingRoomSeats));
                                        P(waitingRoomSeats); 
                                        *customerHair+=1; 
                                }
 
 
                                if (*customerCount == maximum_number_customers) 
                                {
                                        printf("######## Reached maximum customers: %d\n", *customerCount);
                                }
 
                                exit(1);
                        }
 
                        sleep(1);
                }
 
        } 
        else 
        { 
 
                printf("Barber process pid is: %d\n", barber);
                printf("Number of Chairs: %d\nMaximum number of Customers: %d\n\n", number_of_chairs, maximum_number_customers);
 
             	sleep(1);
 
                while(1) 
                {
 
                        if (*customerHair < maximum_number_customers) 
                        {
                                printf("Barber awakened, or there was a customer waiting there.\n");
                                P(theBarber); //Decrement barber
                                V(waitingRoomSeats); //Increment waitRM seats after barber is done cutting
                                hairCut(); //Barber does a haircut
                                V(theBarber);
                        }
 
                        if ((*customerCount) == maximum_number_customers)
                        {
                                break;
                        }
                }

                printf("Barber awakened, or there was a customer waiting there.\n");
                while(number_of_chairs-SHOW(waitingRoomSeats) != 0) 
                {
                        hairCut();
                        V(waitingRoomSeats);
                }
                printf("\n\n******************************************************************************\n");
                printf("In total, there were %d customers today, with %d leaving because the shop ran out of space.\nThat means the barber gave %d haircuts today before closing the shop and going home.\nDay well spent!\n", *customerCount, *customerCount-(*numHaircuts-1), *numHaircuts-1);
        }
 
 
        return 0;
 
}