示例#1
0
int main ( int argc, char ** argv ) {
	char * in_word, * out_word, * temp_word, * i, * t;
	int state, c;
	FILE * in_file, * out_file;
	
	if ( argc != 5 ) {
		fprintf ( stderr, "Error: Missing arguments\n");
		fprintf ( stderr, "Usage: ./a.out <in_file> <out_file> <in_word> <out_word>\n" );
		exit ( 1 );
	}
	if ( !( strcmp ( argv[1], argv[2] ) ) ) {
		fprintf ( stderr, "Error: <in_file> and <out_file> should be different\n" );
		exit ( 2 );
	}
	if ( ( in_file = fopen ( argv[1], "r" ) ) == NULL ) {
		perror ( argv[1] );
		exit ( 3 );
	}
	if ( ( out_file = fopen ( argv[2], "w" ) ) == NULL ) {
		perror ( argv[2] );
		exit ( 4 );
	}

	i = in_word = argv[3];
	out_word = argv[4];
	t = temp_word = malloc ( strlen ( in_word ) + 1 );
	state = OUT;
	
	while ( ( c = fgetc ( in_file ) ) != EOF ) {
		if ( *i == '\0' ) {
			i = in_word;
			t = temp_word;
			if ( state == IN && WHITE ( c ) )
					fputs ( out_word, out_file );
			else
				fputs ( temp_word, out_file );
			fputc ( c, out_file );
			*t = '\0';
		} else if ( c == *i++ ) {
			*t++ = c;
			*t = '\0';
		} else {
			i = in_word;
			t = temp_word;
			fputs ( temp_word, out_file );
			fputc ( c, out_file );
			*t = '\0';
			if ( WHITE ( c ) )
				state = IN;
			else
				state = OUT;
		}
	}
	
	fclose ( in_file );
	fclose ( out_file );
	free ( temp_word );

	return 0;
}
示例#2
0
文件: Counter.cpp 项目: G-11/G11_Tool
//=============================================================================
//生成
//=============================================================================
Counter* Counter::Create(const D3DXVECTOR3& pos,const D3DXVECTOR2& size,int CountPlace,bool camma)
{
	if(CountPlace > 20)
	{
		return nullptr;
	}

	Counter* Score = new Counter;

	if(Score == nullptr)
	{
		return nullptr;
	}
	Score->MaxScore = 1;
	Score->_Pos = Score->DestPos = pos;
	Score->CurrentScore = 0;
	Score->CountPlace = CountPlace;
	Score->Size = size;
	Score->MoveFrame = 1.0f;
	Score->_Color = WHITE(1.0f);
	float PosX = pos.x + (size.x*(CountPlace -1));
	for(int cnt = CountPlace - 1,Loop = 0; cnt >= 0; cnt--,Loop++)
	{
		Score->number[Loop] = Number::Create(D3DXVECTOR3(PosX,pos.y,0),size,0,Sprite::LAYER_INTERFACE);
		PosX -= size.x;
		Score->MaxScore *= 10;//桁数に合わせて最大値を計算する
	}
	return Score;

}
示例#3
0
static void EiC_stringliteral(void)
{
    unsigned size, lastsize = 0, c;
    char *p=NULL;

    lex_str_start_pos = lex_lastpos = lex_curpos; //maks
    do {

	for (size = 0; ((c = charliteral(EiC_nextchar())) != '\0' || WASLITERAL) &&
	     !(c == '"' && !WASLITERAL)  && size < BSIZE; size++) 
	    EiC_LEXEM[size] = c;
    

	if (lastsize)
	    p = (char *) xrealloc(p, lastsize + size + 1);
	else
	    p = (char *) xcalloc(size + 1, sizeof(char));

	memcpy(&p[lastsize], EiC_LEXEM, size);
	lastsize += size;

	if(((c != '"') || (c == '"' && WASLITERAL)) && size == BSIZE) {
	    p[lastsize++] = c;
	    continue;
	}
	
	if (c != '"')
	    EiC_error("String literal error");

	do {
	    c = EiC_nextchar();
	    if (c == '\n')
		lex_lastpos++, lex_lineno++;
	} while (WHITE(c) || c == '\n');

	lex_lastpos = lex_curpos;
	if (!c)
	    do
		c = EiC_nextchar();
	    while (WHITE(c));
    } while (c == '"' || size == BSIZE);
    retract(c);
    p[lastsize] = '\0';
    token->Val.p.sp = token->Val.p.p = p;
    token->Val.p.ep = p + lastsize + 1;
}
示例#4
0
void StartDevice::Update(void)
{
	//プレイヤーとの当たり判定を見て_Activeをtrueにする
	bool buffActive;

	if (Collision::Circle(_Player->Pos(), _Player->Size().x*0.5f, _Pos, _Size.x*0.5f))
	{
		buffActive = true;
		if (TriggerType != SWITCH)
		{
			_Active = true;
		}
		if (TriggerType == TIMER)
		{
			frame = TimeLimit;
		}
	}
	else
	{
		buffActive = false;
		
		if (TriggerType == ON)
		{
			_Active = false;
		}
	}
	if (TriggerType == SWITCH)
	{
		if ((OldActive^buffActive)& buffActive)
		{
			(_Active)?_Active = false: _Active = true;
		}
	}
	if (TriggerType == TIMER && _Active)
	{
		if (frame > 0)
		{
			frame--;
		}
		if (frame <= 0)
		{
			_Active = false;
		}
	}

	if (_Active)//アクティブ状態を仮置き
	{
		_Color = RED(1.0f);
	}
	else
	{
		_Color = WHITE(1.0f);
	}

	OldActive = buffActive;
}
示例#5
0
/*	Find next Field
**	---------------
**
** On entry,
**	*pstr	points to a string containig white space separated
**		field, optionlly quoted.
**
** On exit,
**	*pstr	has been moved to the first delimiter past the
**		field
**		THE STRING HAS BEEN MUTILATED by a 0 terminator
**
**	returns	a pointer to the first field
*/
PUBLIC char * HTNextField ARGS1(char **, pstr)
{
    char * p = *pstr;
    char * start;			/* start of field */
    
    while(*p && WHITE(*p)) p++;		/* Strip white space */
    if (!*p) {
	*pstr = p;
        return NULL;		/* No first field */
    }
    if (*p == '"') {			/* quoted field */
        p++;
	start = p;
	for(;*p && *p!='"'; p++) {
	    if (*p == '\\' && p[1]) p++;	/* Skip escaped chars */
	}
    } else {
	start = p;
	while(*p && !WHITE(*p)) p++;	/* Skip first field */
    }
    if (*p) *p++ = 0;
    *pstr = p;
    return start;
}
示例#6
0
文件: Sprite.cpp 项目: G-11/G11_Tool
//=============================================================================
//コンストラクタ
//=============================================================================
Sprite::Sprite(int priority)
{

	//ステータスの初期化
	_Color =
	_MaskColor = WHITE(1.0f);
	_Pos	= D3DXVECTOR3(0,0,0);
	_Offset = D3DXVECTOR2(0,0);
	_Size	= D3DXVECTOR3(1.0f,1.0f,1.0f);
	_Speed	= D3DXVECTOR3(0,0,0);
	_Rot		= D3DXVECTOR3(0,0,0);
	uv		= 
	MaskUV	= D3DXVECTOR4(0,0,1.0f,1.0f);
	Texture = 
	Mask = GetTexture(TEX_NONE);
	ReleaseFlag = false;
	Priority = priority;
	_Pass = CShader2D::NORMAL;
	memcpy(_Quad,QuadBase,sizeof(D3DXVECTOR3)*4);
	PolygonNum++;
	LinkList();
}
示例#7
0
extern int EiC_lexan(void)
{
    int t=0, loop; char c=0, EiC_nextchar();

#ifdef ILOOKAHEAD

    token = &EiC_TokenArray[EiC_TokenP];

    if(EiC_TokenR > 0) {
	EiC_TokenR--;
	EiC_TokenI++;
	EiC_TokenP=(EiC_TokenP+1)%MAX_TOKENS;
	return token->Tok;
    }


#else

    if (STOKEN != NOTOKEN) {
	STOKEN = NOTOKEN;
	return token->Tok;
    }

#endif
    
    loop  = 1;
    state = 0;
    while (loop) {
	switch (state) {
	  case 0: lex_lastpos = lex_curpos; c = EiC_nextchar();
	    state = (WHITE(c) ? 0 :
		    (c == '\n' ? lex_lineno++, 0 :
		    (c == '<' ? t = LT, 1 :
		    (c == '>' ? t = GT, 2 :
		    (c == '+' ? t = '+', 3 :
		    (c == '-' ? t = '-', 4 :
		    (c == '|' ? t = BOR, 5 :
		    (c == '&' ? t = AND, 6 :
		    (c == '\''? 7 :
		    (c == '"' ? 8 :
		    (c == '.' ? 9 :  
		    (c == '/' ? t = '/', c = EiC_nextchar(), 50 :
		    (c == '%' ? t = '%', c = EiC_nextchar(), 50 :
		    (c == '*' ? t = '*', c = EiC_nextchar(), 50 :
		    (c == '=' ? t = ASS, c = EiC_nextchar(), 50 :
		    (c == '!' ? t = NOT, c = EiC_nextchar(), 50 :
		    (c == '^' ? t = XOR, c = EiC_nextchar(), 50 :
			//(c == '~' ? t = NOTB, c = EiC_nextchar(), 50 : //maks: ~
		     fail(RELOP, c))))))))))))))))));
	    break;
	  case 1: /* get <,  <= and << */
	    if ((c = EiC_nextchar()) == '<') t = LSHT;
	    else state = 50;
	    break;
	  case 2: /* get >, >= and >> */
	    if ((c = EiC_nextchar()) == '>') t = RSHT;
	    else state = 50;
	    break;
	  case 3: c = EiC_nextchar();                         /* get +, += or ++ */
	    if (c == '+') t = INC, state = 60;
	    else state = 50;
	    break;
	  case 4: c = EiC_nextchar();                            /* get -, -= -- */
	    state = 60;
	    if (c == '-') t = DEC;
	    else if (c == '>') t = RARROW;
	    else state = 50;
	    break;
	  case 5: c = EiC_nextchar();                         /* get |, |= or || */
	    if (c == '|') t = LOR, state = 60;
	    else state = 50;
	    break;
	  case 6: c = EiC_nextchar();                         /* get &, &= or && */
	    if (c == '&') t = LAND, state = 60;
	    else state = 50;
	    break;
	  case 7:token->Val.ival = charliteral(EiC_nextchar()); /* char_constants */
	    t = TOKEN_CHAR;
	    if (EiC_nextchar() != '\'')
		EiC_error("Missing single quote '");
	    state = 60;
	    break;
	  case 8: EiC_stringliteral();                        /* string literals */
	    token->Tok = STR;
	    /*return STR;*/ loop = 0; break;
	  case 9: c = EiC_nextchar();
	    t = '.';
	    if(DIGIT(c)) 
		state = 22;
	    else
		state = 60;
	    retract(c);
	    break;
	  case 10: c = EiC_nextchar();              /* identifiers and  keywords */
	    state = (LETTER(c) ? 11 :
		    (c == '_' ? 11 : fail(ID, c)));
	    break;
	  case 11: c = EiC_nextchar();
	    state = (LETTER(c) ? 11 :
		    (DIGIT(c) ? 11 :
		    (c == '_' ? 11 : 12)));
	    break;
	  case 12: retract(c); success(ID); /*return (token->Tok);*/ loop = 0; break;

	  case 20: c = EiC_nextchar();                     /* integers and reals */
	    state = (c == '0' ? 30 :
		    (DIGIT(c) ? 21 : fail(TOKEN_INT, c)));
	    break;
	  case 21: c = EiC_nextchar();
	    state = (DIGIT(c) ? 21 :
		    (c == '.' ? 22 :
		    (c == 'e' ? 23 :
		    (c == 'E' ? 23 : 25))));
	    break;
	  case 22: c = EiC_nextchar();
	    state = (DIGIT(c) ? 22 :
		    (c == 'e' ? 23 :
		    (c == 'E' ? 23 : 26)));
	    break;
	  case 23: c = EiC_nextchar();
	    state = (c == '+' ? 24 :
		    (c == '-' ? 24 :
		    (DIGIT(c) ? 24 : fail(TOKEN_FLOAT, c) /* ??? */ )));
	    break;
	  case 24: c = EiC_nextchar();
	    state = (DIGIT(c) ? 24 : 26);
	    break;
	  case 25: checkExt(c); success(TOKEN_INT); /*return (token->Tok);*/ loop = 0; break;
	  case 26: checkExt(c); success(TOKEN_FLOAT); /*return (token->Tok);*/ loop = 0; break;
	  case 27: checkExt(c); success(HEX);   /*return (token->Tok);*/ loop = 0; break;
	  case 28: checkExt(c); success(OCTAL); /*return (token->Tok);*/ loop = 0; break;
	  case 30:			  /* check for octal and hex numbers */
	    if ((c = EiC_nextchar()) == 'x' || c == 'X') {
		while (gethex((c = EiC_nextchar())) > -1);
		state = 27;
		break;
	    }
	    if (c != '.' && c != 'e' && c != 'E') {
		while (getoct(c) > -1)
		    c = EiC_nextchar();
		state = 28;
		break;
	    }
	    retract(c); state = 21; break;
	  case 50:                                      /* mix with equal's  */
	    if (c == '=')
		switch (t) {
		  case '+': t = ADDEQ;  break;		/* += */
		  case '-': t = SUBEQ;  break;		/* -= */
		  case '/': t = DIVEQ;  break;		/* /= */
		  case '*': t = MULEQ;  break;		/* *= */
		  case '%': t = MODEQ;  break;		/* %= */
		  case ASS: t = EQ;     break;		/* == */
		  case GT:  t = GE;     break;		/* >= */
		  case LT:  t = LE;     break;		/* <= */
		  case NOT: t = NE;     break;		/* != */
		  case RSHT:t = RSHTEQ; break;		/* >>= */
		  case LSHT:t = LSHTEQ; break;		/* <<= */
		  case AND: t = ANDEQ;  break;		/* &= */
		  case BOR: t = BOREQ;  break;		/* |= */
		  case XOR: t = XOREQ;  break;		/* ^= */
		  //case NOTB: t = NOTBEQ;  break;		/* maks ~= */
		  default: retract(c);
	    }
		else if(c == '/' && t == '/') //maks
		{
			//C++ comment
			//Only for colorize
			//Comments are removed by preprocessor before parser

			do 
			{
				c = EiC_nextchar();
				
			} while(c && c != '\n');

			retract(c);

			success(MISC); 
			token->Tok = TOKEN_COMMENT;
			loop = 0;
			break;
		}
		else retract(c);
	    state = 60;
	    break;
	  case 60: success(MISC); token->Tok = t; /*return (token->Tok);*/ loop = 0; break;
	  case 100: token->Tok = EiC_nextchar(); /*return (token->Tok);*/ loop = 0; break;
	}
    }

#ifdef ILOOKAHEAD

    if(EiC_TokenI<MAX_TOKENS)
	EiC_TokenI++;

    EiC_TokenP = (EiC_TokenP +1)%MAX_TOKENS;

#endif

    return token->Tok;


}
示例#8
0
//=============================================================================
//初期化
//=============================================================================
bool CircleGauge::Init(void)
{
	//頂点バッファを作成
	Mutex::Instance()->Enter();
	if (FAILED(Window::Instance()->Device()->CreateVertexBuffer(sizeof(VERTEX_2D) * (Divide + 1),D3DUSAGE_WRITEONLY,FVF_CUSTOM,D3DPOOL_MANAGED,&VtxBuff,NULL)))
	{
		Mutex::Instance()->Leave();
		return false;
	}
	Mutex::Instance()->Leave();

	//情報をセット
	VERTEX_2D* vtx;
	VtxBuff->Lock(0,0,(void**)&vtx,0);

	vtx[0].vtx = D3DXVECTOR3(0,0,0);
	vtx[0].tex = D3DXVECTOR2(0,1.0f);

	BaseAngle = (-360.0f)*(Current/Max);
	float angle = BaseAngle / (Divide-1);

	if (_Point)
	{
		Point[0] = Sprite::Create(D3DXVECTOR3(0,0,0),D3DXVECTOR2(70.0f,70.0f),WHITE(0.5f),Priority);
		Point[1] = Sprite::Create(D3DXVECTOR3(0,0,0),D3DXVECTOR2(70.0f,70.0f),WHITE(0.5f),Priority);

		Point[0]->SetTexture(GetTexture(TEX_GAGE_POINT));
		Point[1]->SetTexture(GetTexture(TEX_GAGE_POINT));

		Point[0]->SetPass(CShader2D::ADD);
		Point[1]->SetPass(CShader2D::ADD);
	}

	for (int cnt = 1;cnt < Divide + 1;cnt++)
	{
		vtx[cnt].vtx.x = sinf(DEG2RAD(angle*(cnt - 1) + 180.0f))*r;
		vtx[cnt].vtx.y = cosf(DEG2RAD(angle*(cnt - 1) + 180.0f))*r;
		vtx[cnt].vtx.z = 0;
		vtx[cnt].tex = D3DXVECTOR2(0,0);

		if (_Point)
		{
			if (cnt == 1)
			{
				Point[0]->SetPos(vtx[cnt].vtx);
			}
			else if (cnt == Divide)
			{
				Point[1]->SetPos(vtx[cnt].vtx);
			}
		}
	}

	VtxBuff->Unlock();

	Texture = GetTexture(TEX_GAGE);
	_Color = WHITE(1.0f);

	return true;
	
}
示例#9
0
文件: scanw.c 项目: EvilTeach/Github
static int _pdc_vsscanf(const char *buf, const char *fmt, va_list arg_ptr)
{
    int count, chars, c, width, radix, d, i;
    int *int_ptr;
    long *long_ptr;
    short *short_ptr;
    char *char_ptr;
    unsigned char f;
    char neg, assign, ok, size;
    long n;
    char map[256], end;
    double dx, dd, *dbl_ptr;
    float *flt_ptr;
    int exp;
    char eneg;

    count = 0;
    chars = 0;
    c = 0;
    while ((f = *fmt) != 0)
    {
        if (WHITE(f))
        {
            do
            {
                ++fmt;
                f = *fmt;
            }
            while (WHITE(f));
            do
            {
                c = *buf++;
                if (!c)
                {
                    if (!f || count)
                        return count;
                    else
                        return EOF;
                } else
                    ++chars;
            }
            while (WHITE(c));
            UNGETC();
        } else if (f != '%')
        {
            NEXT(c);
            if (c != f)
                return count;
            ++fmt;
        } else
        {
            assign = TRUE;
            width = INT_MAX;
            char_ptr = NULL;
            ++fmt;
            if (*fmt == '*')
            {
                assign = FALSE;
                ++fmt;
            }
            if (isdigit(*fmt))
            {
                width = 0;
                while (isdigit(*fmt))
                    width = width * 10 + (*fmt++ - '0');
                if (!width)
                    width = INT_MAX;
            }
            size = 0;
            if (*fmt == 'h' || *fmt == 'l')
                size = *fmt++;
            f = *fmt;
            switch (f)
            {
            case 'c':
                if (width == INT_MAX)
                    width = 1;
                if (assign)
                    char_ptr = va_arg(arg_ptr, char *);
                while (width > 0)
                {
                    --width;
                    NEXT(c);
                    if (assign)
                    {
                        *char_ptr++ = (char) c;
                        ++count;
                    }
                }
                break;
            case '[':
                memset(map, 0, 256);
                end = 0;
                ++fmt;
                if (*fmt == '^')
                {
                    ++fmt;
                    end = 1;
                }
                i = 0;
                for (;;)
                {
                    f = (unsigned char) *fmt;
                    switch (f)
                    {
                    case 0:
                        /* avoid skipping past 0 */
                        --fmt;
                        NEXT(c);
                        goto string;
                    case ']':
                        if (i > 0)
                        {
                            NEXT(c);
                            goto string;
                        }
                        /* no break */
                    default:
                        if (fmt[1] == '-' && fmt[2]
                            && f < (unsigned char)fmt[2])
                        {
                            memset(map + f, 1, (unsigned char)fmt[2] - f);
                            fmt += 2;
                        }
                        else
                            map[f] = 1;
                        break;
                    }
                    ++fmt;
                    ++i;
                }
            case 's':
                memset(map, 0, 256);
                map[' '] = 1;
                map['\n'] = 1;
                map['\r'] = 1;
                map['\t'] = 1;
                end = 1;
                do
                {
                    NEXT(c);
                }
                while (WHITE(c));
            string:
                if (assign)
                    char_ptr = va_arg(arg_ptr, char *);
                while (width > 0 && map[(unsigned char) c] != end)
                {
                    --width;
                    if (assign)
                        *char_ptr++ = (char) c;
                    c = *buf++;
                    if (!c)
                        break;
                    else
                        ++chars;
                }
                if (assign)
                {
                    *char_ptr = 0;
                    ++count;
                }
                if (!c)
                    return count;
                else
                    UNGETC();
                break;
            case 'f':
            case 'e':
            case 'E':
            case 'g':
            case 'G':
                neg = ok = FALSE;
                dx = 0.0;
                do
                {
                    NEXT(c);
                }
                while (WHITE(c));
                if (c == '+')
                {
                    NEXT(c);
                    --width;
                } else if (c == '-')
                {
                    neg = TRUE;
                    NEXT(c);
                    --width;
                }
                while (width > 0 && isdigit(c))
                {
                    --width;
                    dx = dx * 10.0 + (double) (c - '0');
                    ok = TRUE;
                    c = *buf++;
                    if (!c)
                        break;
                    else
                        ++chars;
                }
                if (width > 0 && c == '.')
                {
                    --width;
                    dd = 10.0;
                    NEXT(c);
                    while (width > 0 && isdigit(c))
                    {
                        --width;
                        dx += (double) (c - '0') / dd;
                        dd *= 10.0;
                        ok = TRUE;
                        c = *buf++;
                        if (!c)
                            break;
                        else
                            ++chars;
                    }
                }
                if (!ok)
                    return count;
                if (width > 0 && (c == 'e' || c == 'E'))
                {
                    eneg = FALSE;
                    exp = 0;
                    NEXT(c);
                    --width;
                    if (width > 0 && c == '+')
                    {
                        NEXT(c);
                        --width;
                    } else if (width > 0 && c == '-')
                    {
                        eneg = TRUE;
                        NEXT(c);
                        --width;
                    }
                    if (!(width > 0 && isdigit(c)))
                    {
                        UNGETC();
                        return count;
                    }
                    while (width > 0 && isdigit(c))
                    {
                        --width;
                        exp = exp * 10 + (c - '0');
                        c = *buf++;
                        if (!c)
                            break;
                        else
                            ++chars;
                    }
                    if (eneg)
                        exp = -exp;
                    while (exp > 0)
                    {
                        dx *= 10.0;
                        --exp;
                    }
                    while (exp < 0)
                    {
                        dx /= 10.0;
                        ++exp;
                    }
                }
                if (assign)
                {
                    if (neg)
                        dx = -dx;
                    if (size == 'l')
                    {
                        dbl_ptr = va_arg(arg_ptr, double *);
                        *dbl_ptr = dx;
                    }
                    else
                    {
                        flt_ptr = va_arg(arg_ptr, float *);
                        *flt_ptr = (float)dx;
                    }
                    ++count;
                }
                if (!c)
                    return count;
                else
                    UNGETC();
                break;
            case 'i':
                neg = FALSE;
                radix = 10;
                do
                {
                    NEXT(c);
                }
                while (WHITE(c));
                if (!(width > 0 && c == '0'))
                    goto scan_complete_number;
                NEXT(c);
                --width;
                if (width > 0 && (c == 'x' || c == 'X'))
                {
                    NEXT(c);
                    radix = 16;
                    --width;
                }
                else if (width > 0 && (c >= '0' && c <= '7'))
                    radix = 8;
                goto scan_unsigned_number;
            case 'd':
            case 'u':
            case 'o':
            case 'x':
            case 'X':
                do
                {
                    NEXT(c);
                }
                while (WHITE(c));
                switch (f)
                {
                case 'o':
                    radix = 8;
                    break;
                case 'x':
                case 'X':
                    radix = 16;
                    break;
                default:
                    radix = 10;
                    break;
                }
            scan_complete_number:
                neg = FALSE;
                if (width > 0 && c == '+')
                {
                    NEXT(c);
                    --width;
                }
                else if (width > 0 && c == '-' && radix == 10)
                {
                    neg = TRUE;
                    NEXT(c);
                    --width;
                }
            scan_unsigned_number:
                n = 0;
                ok = FALSE;
                while (width > 0)
                {
                    --width;
                    if (isdigit(c))
                        d = c - '0';
                    else if (isupper(c))
                        d = c - 'A' + 10;
                    else if (islower(c))
                        d = c - 'a' + 10;
                    else
                        break;
                    if (d < 0 || d >= radix)
                        break;
                    ok = TRUE;
                    n = n * radix + d;
                    c = *buf++;
                    if (!c)
                        break;
                    else
                        ++chars;
                }
                if (!ok)
                    return count;
                if (assign)
                {
                    if (neg)
                        n = -n;
                    switch (size)
                    {
                    case 'h':
                        short_ptr = va_arg(arg_ptr, short *);
                        *short_ptr = (short) n;
                        break;
                    case 'l':
                        long_ptr = va_arg(arg_ptr, long *);
                        *long_ptr = (long) n;
                        break;
                    default:
                        int_ptr = va_arg(arg_ptr, int *);
                        *int_ptr = (int) n;
                    }
                    ++count;
                }
                if (!c)
                    return count;
                else
                    UNGETC();
                break;
            case 'n':
                if (assign)
                {
                    int_ptr = va_arg(arg_ptr, int *);
                    *int_ptr = chars;
                    ++count;
                }
                break;
            default:
                if (!f) /* % at end of string */
                    return count;
                NEXT(c);
                if (c != f)
                    return count;
                break;
            }
            ++fmt;
        }
示例#10
0
//------------------------------------------------------------------------------
// ゲームの初期化
//------------------------------------------------------------------------------
// 引数
//  なし
// 戻り値
//  なし
//------------------------------------------------------------------------------
void CGame::Init(void)
{
	gamePhase = PHASE_3;
	gamePhaseCnt = 0;
	gameEndCount = 0;


	CSoundAL::Play(CSoundAL::BGM_GAME);
	//地形生成
	Ground = nullptr;
	Ground = CMeshGround::Create(VECTOR3(0.0f,0.0f,0.0f),VECTOR2(FIELD_PANEL_SIZE,FIELD_PANEL_SIZE),VECTOR2(0,0),1.5f);
	Ground->SetTex(CTexture::Texture(TEX_FIELD));

	// 空生成
	Sky = nullptr;
	Sky = CMeshSphere::Create(VECTOR3(0.0f,0.0f,0.0f),VECTOR2(16.0f,8.0f),RADIUS_SKY);
	Sky->SetTex(CTexture::Texture(TEX_SKY));

	// 境界線生成
	CylinderArea = nullptr;
	CylinderArea = CBattleAreaCylinder::Create(VECTOR3(0.0f,0.0f,0.0f),HEIGHT_WALL,VECTOR2(64.0f,1.0f),RADIUS_AREA_BATTLE,VECTOR2(1,-0.5f));
	CylinderArea->SetTex(CTexture::Texture(TEX_WALL));
	CylinderArea->SetAlpha(0.5f);

	Player = new CPlayer*[PLAYER_MAX];
	// プレイヤー生成
	for (int i = 0; i < PLAYER_MAX; i++)
	{
		if (i % 2 == 1)
			Player[i] = CPlayer::Create(CModel::RINCHAN,PLAYER_POSITION_LIST[i],i);
		else
			Player[i] = CPlayer::Create(CModel::YOUJO,PLAYER_POSITION_LIST[i],i);

		Player[i]->SetTex(CTexture::Texture(TEX_YOUJO_RED + i));
  Player[i]->SetDestRot(PLAYER_ROTATION_LIST[i]);
  Player[i]->SetRot(PLAYER_ROTATION_LIST[i]);
		Player[i]->setBarrelTex(TEX_YOUJO_RED + i);

		if (i == CManager::netData.charNum)
		{
			Player[i]->SetPlayerFlag(true);
			Player[i]->CreateBallistic();
		}
	}
		//プレイヤーカメラ生成
	CPlayerCamera::Create(Player[CManager::netData.charNum],35.0f);

	// 【テスト】各プレイヤーの色をセット
	for(int i = 0; i < PLAYER_MAX; i++)
	{
		switch(i)
		{
			// 赤
			case 0:
				Player[i]->SetPlayerColor(RED(0.5f));
				break;

			// 青
			case 1:
				Player[i]->SetPlayerColor(BLUE(0.5f));
				break;

			// 水
			case 2:
				Player[i]->SetPlayerColor(CYAN(0.5f));
				break;

			// 橙
			case 3:
				Player[i]->SetPlayerColor(COLOR(1.0f, 0.7f, 0.0f, 0.5f));
				break;
		
			// 白
			case 4:
				Player[i]->SetPlayerColor(WHITE(0.5f));
				break;

			// P
			case 5:
				Player[i]->SetPlayerColor(YELLOW(0.5f));
				break;

			default:
				break;
		}
	}

	// プレイヤーの入力を止める
	for (int i = 0; i < PLAYER_MAX; i++){
		Player[i]->SetInputFlag(false);
	}

	// UI初期化
	UI = new CUI;
	UI->Init();
	UI->setMyID(CManager::netData.charNum);
	UI->SetPlayer(Player);
	UI->MiniMap()->SetFieldSize(VECTOR3(RADIUS_AREA_BATTLE*2.25f,0,RADIUS_AREA_BATTLE*2.25f));

	// 岩の生成
	ppRock_ = new CModel*[MAX_ROCK];

	for (int cntRock = 0; cntRock < MAX_ROCK; ++cntRock)
	{
		ppRock_[cntRock] = CModel::Create(CModel::ROCK,ROCK_POSITION_LIST[cntRock]);
		ppRock_[cntRock]->SetRot(ROCK_ROTATION_LIST[cntRock]);
		ppRock_[cntRock]->SetScl(1,1,1);
		ppRock_[cntRock]->SetTex(CTexture::Texture(TEX_ROCK));
		PushBackObjectByField(ppRock_[cntRock], 10.0f);
	}

	// 影生成
	Shadow = new CShadow*[2 * PLAYER_MAX];
	for (int cntShadow = 0; cntShadow < 2 * PLAYER_MAX; ++cntShadow)
	{
		Shadow[cntShadow] = nullptr;
		Shadow[cntShadow] = CShadow::Create(VECTOR3(0.0f, 0.0f, 0.0f), VECTOR2(1.0f, 1.0f));
		if (cntShadow < PLAYER_MAX)
		{
			Shadow[cntShadow]->SetScl(30, 30, 30);
		}
		else
		{
			Shadow[cntShadow]->SetScl(20, 20, 20);
		}
		Shadow[cntShadow]->SetTex(CTexture::Texture(TEX_SHADOW));
	}

	CManager::gameStartFlag = true;

	CManager::sendGameStart();
}
示例#11
0
/*
 *time: level: process[pid]: [tid] tag: message
 *             [verbose          ]
 */
static int _log_print(int lvl, const char *tag,
                      const char *file, int line,
                      const char *func, const char *msg)
{
    int ret = 0, i = 0;
    struct iovec vec[LOG_IOVEC_MAX];
    char s_time[LOG_TIME_SIZE];
    char s_lvl[LOG_LEVEL_SIZE];
    char s_tag[LOG_TAG_SIZE];
    char s_pname[LOG_PNAME_SIZE];
    char s_pid[LOG_PNAME_SIZE];
    char s_tid[LOG_PNAME_SIZE];
    char s_file[LOG_TEXT_SIZE];
    char s_msg[LOG_BUF_SIZE];

    pthread_mutex_lock(&_log_mutex);
    log_get_time(s_time, sizeof(s_time), 0);

    if (_log_fp == stderr || _log_fd == STDERR_FILENO) {
        switch(lvl) {
        case LOG_EMERG:
        case LOG_ALERT:
        case LOG_CRIT:
        case LOG_ERR:
            snprintf(s_lvl, sizeof(s_lvl),
                    B_RED("[%7s]"), _log_level_str[lvl]);
            snprintf(s_msg, sizeof(s_msg), RED("%s"), msg);
            break;
        case LOG_WARNING:
            snprintf(s_lvl, sizeof(s_lvl),
                    B_YELLOW("[%7s]"), _log_level_str[lvl]);
            snprintf(s_msg, sizeof(s_msg), YELLOW("%s"), msg);
            break;
        case LOG_INFO:
            snprintf(s_lvl, sizeof(s_lvl),
                    B_GREEN("[%7s]"), _log_level_str[lvl]);
            snprintf(s_msg, sizeof(s_msg), GREEN("%s"), msg);
            break;
        case LOG_DEBUG:
            snprintf(s_lvl, sizeof(s_lvl),
                    B_WHITE("[%7s]"), _log_level_str[lvl]);
            snprintf(s_msg, sizeof(s_msg), WHITE("%s"), msg);
            break;
        default:
            snprintf(s_lvl, sizeof(s_lvl),
                    "[%7s]", _log_level_str[lvl]);
            snprintf(s_msg, sizeof(s_msg), "%s", msg);
            break;
        }
    } else {
        snprintf(s_lvl, sizeof(s_lvl),
                "[%7s]", _log_level_str[lvl]);
        snprintf(s_msg, sizeof(s_msg), "%s", msg);
    }
    if (CHECK_LOG_PREFIX(_log_prefix, LOG_PIDTID_BIT)) {
        snprintf(s_pname, sizeof(s_pname), "[%s ", _proc_name);
        snprintf(s_pid, sizeof(s_pid), "pid:%d ", getpid());
        snprintf(s_tid, sizeof(s_tid), "tid:%d]", _gettid());
        snprintf(s_tag, sizeof(s_tag), "[%s]", tag);
        snprintf(s_file, sizeof(s_file), "[%s:%d: %s] ", file, line, func);
    }
    if (CHECK_LOG_PREFIX(_log_prefix, LOG_FUNCLINE_BIT)) {
        snprintf(s_file, sizeof(s_file), "[%s:%d: %s] ", file, line, func);
    }

    i = -1;
    if (CHECK_LOG_PREFIX(_log_prefix, LOG_TIMESTAMP_BIT)) {
        vec[++i].iov_base = (void *)s_time;
        vec[i].iov_len = strlen(s_time);
    }
    if (CHECK_LOG_PREFIX(_log_prefix, LOG_PIDTID_BIT)) {
        vec[++i].iov_base = (void *)s_pname;
        vec[i].iov_len = strlen(s_pname);
        vec[++i].iov_base = (void *)s_pid;
        vec[i].iov_len = strlen(s_pid);
        vec[++i].iov_base = (void *)s_tid;
        vec[i].iov_len = strlen(s_tid);
    }
    vec[++i].iov_base = (void *)s_lvl;
    vec[i].iov_len = strlen(s_lvl);
    if (CHECK_LOG_PREFIX(_log_prefix, LOG_TAG_BIT)) {
        vec[++i].iov_base = (void *)s_tag;
        vec[i].iov_len = strlen(s_tag);
    }
    if (CHECK_LOG_PREFIX(_log_prefix, LOG_FUNCLINE_BIT)) {
        vec[++i].iov_base = (void *)s_file;
        vec[i].iov_len = strlen(s_file);
    }
    vec[++i].iov_base = (void *)s_msg;
    vec[i].iov_len = strlen(s_msg);

    if (UNLIKELY(!_log_syslog)) {
        ret = _log_handle->write(vec, i+1);
    }
    pthread_mutex_unlock(&_log_mutex);
    return ret;
}
示例#12
0
/*		Treat One Character
**		-------------------
*/
PRIVATE void WSRCParser_put_character ARGS2(HTStream*, me, char, c)
{
    switch (me->state) {
    case beginning:
	if (c=='(') me->state = before_tag;
	break;

    case before_tag:
	if (c==')') {
	    me->state = done;
	    return;			/* Done with input file */
	} else if (c==':') {
	    me->param_count = 0;
	    me->state = colon;
	}				/* Ignore other text */
	break;

    case colon:
	if (WHITE(c)) {
	    me->param[me->param_count++] = 0;	/* Terminate */
	    for(me->param_number = 0; par_name[me->param_number]; me->param_number++) {
		if (0==strcmp(par_name[me->param_number], me->param)) {
		    break;
		}
	    }
	    if (!par_name[me->param_number]) {	/* Unknown field */
		CTRACE((tfp, "HTWSRC: Unknown field `%s' in source file\n",
			    me->param));
		me->param_number = PAR_UNKNOWN;
		me->state = before_value;	/* Could be better ignore */
		return;
	    }
	    me->state = before_value;
	} else {
	    if (me->param_count < PARAM_MAX)  me->param[me->param_count++] = c;
	}
	break;

    case before_value:
	if (c==')') {
	    me->state = done;
	    return;			/* Done with input file */
	}
	if (WHITE(c)) return;		/* Skip white space */
	me->param_count = 0;
	if (c=='"') {
	    me->state = quoted_value;
	    break;
	}
	me->state = (c=='"') ? quoted_value :
		    (c=='(') ? bracketed_value : value;
	me->param[me->param_count++] = c;	/* Don't miss first character */
	break;

    case value:
	if (WHITE(c)) {
	    me->param[me->param_count] = 0;
	    StrAllocCopy(me->par_value[me->param_number], me->param);
	    me->state = before_tag;
	} else {
	    if (me->param_count < PARAM_MAX)  me->param[me->param_count++] = c;
	}
	break;

    case bracketed_value:
	if (c==')') {
	    me->param[me->param_count] = 0;
	    StrAllocCopy(me->par_value[me->param_number], me->param);
	    me->state = before_tag;
	    break;
	}
	if (me->param_count < PARAM_MAX)  me->param[me->param_count++] = c;
	break;

    case quoted_value:
	if (c=='"') {
	    me->param[me->param_count] = 0;
	    StrAllocCopy(me->par_value[me->param_number], me->param);
	    me->state = before_tag;
	    break;
	}

	if (c=='\\') {		/* Ignore escape but switch state */
	    me->state = escape_in_quoted;
	    break;
	}
	/* Fall through! */

    case escape_in_quoted:
	if (me->param_count < PARAM_MAX)  me->param[me->param_count++] = c;
	me->state = quoted_value;
	break;

    case done:				/* Ignore anything after EOF */
	return;

    } /* switch me->state */
}
示例#13
0
/**
 * Parses the argument string passed in as pszSrc.
 *
 * @returns size of the processed arguments.
 * @param   pszSrc  Pointer to the commandline that's to be parsed.
 * @param   argv    Pointer to argument vector to put argument pointers in. NULL allowed.
 * @param   pchPool Pointer to memory pchPool to put the arguments into. NULL allowed.
 */
static int parse_args(const char *pszSrc, char **argv, char *pchPool)
{
    int   bs;
    char  chQuote;
    char *pfFlags;
    int   cbArgs;

#define PUTC(c) do { ++cbArgs; if (pchPool != NULL) *pchPool++ = (c); } while (0)
#define PUTV    do { ++g_cArgs; if (argv != NULL) *argv++ = pchPool; } while (0)
#define WHITE(c) ((c) == ' ' || (c) == '\t')

#define _ARG_DQUOTE   0x01          /* Argument quoted (")                  */
#define _ARG_RESPONSE 0x02          /* Argument read from response file     */
#define _ARG_WILDCARD 0x04          /* Argument expanded from wildcard      */
#define _ARG_ENV      0x08          /* Argument from environment            */
#define _ARG_NONZERO  0x80          /* Always set, to avoid end of string   */

    g_cArgs = 0; cbArgs = 0;

#if 0
    /* argv[0] */
    PUTC((char)_ARG_NONZERO);
    PUTV;
    for (;;)
    {
        PUTC(*pszSrc);
        if (*pszSrc == 0)
            break;
        ++pszSrc;
    }
    ++pszSrc;
#endif

    for (;;)
    {
        while (WHITE(*pszSrc))
            ++pszSrc;
        if (*pszSrc == 0)
            break;
        pfFlags = pchPool;
        PUTC((char)_ARG_NONZERO);
        PUTV;
        bs = 0; chQuote = 0;
        for (;;)
        {
            if (!chQuote ? (*pszSrc == '"' || *pszSrc == '\'') : *pszSrc == chQuote)
            {
                while (bs >= 2)
                {
                    PUTC('\\');
                    bs -= 2;
                }
                if (bs & 1)
                    PUTC(*pszSrc);
                else
                {
                    chQuote = chQuote ? 0 : *pszSrc;
                    if (pfFlags != NULL)
                        *pfFlags |= _ARG_DQUOTE;
                }
                bs = 0;
            }
            else if (*pszSrc == '\\')
                ++bs;
            else
            {
                while (bs != 0)
                {
                    PUTC('\\');
                    --bs;
                }
                if (*pszSrc == 0 || (WHITE(*pszSrc) && !chQuote))
                    break;
                PUTC(*pszSrc);
            }
            ++pszSrc;
        }
        PUTC(0);
    }
    return cbArgs;
}
示例#14
0
PRIVATE void HTMIME_put_character ARGS2(HTStream *, me, char, c)
{
    if (me->state == MIME_TRANSPARENT) {
    	(*me->targetClass.put_character)(me->target, c);/* MUST BE FAST */
	return;
    }
    
    /* This slightly simple conversion just strips CR and turns LF to
    ** newline. On unix LF is \n but on Mac \n is CR for example.
    ** See NetToText for an implementation which preserves single CR or LF.
    */
    if (me->net_ascii) {
        c = FROMASCII(c);
	if (c == CR) return;
	else if (c == LF) c = '\n';
    }
    
    switch(me->state) {

    case MIME_IGNORE:
    	return;

    case MIME_TRANSPARENT:		/* Not reached see above */
    	(*me->targetClass.put_character)(me->target, c);
	return;
	
    case MIME_NET_ASCII:
    	(*me->targetClass.put_character)(me->target, c); /* MUST BE FAST */
	return;

    case NEWLINE:
	if (c != '\n' && WHITE(c)) {		/* Folded line */
	    me->state = me->fold_state;	/* pop state before newline */
	    break;
	}
	
	/*	else Falls through */
	
    case BEGINNING_OF_LINE:
        switch(c) {
	case 'c':
	case 'C':
	    me->check_pointer = "ontent-t";
	    me->if_ok = CONTENT_T;
	    me->state = CHECK;
	    break;
	case '\n':			/* Blank line: End of Header! */
	    {
	        if (TRACE) fprintf(stderr,
			"HTMIME: MIME content type is %s, converting to %s\n",
			HTAtom_name(me->format), HTAtom_name(me->targetRep));
		me->target = HTStreamStack(me->format, me->request, NO);
		if (!me->target) {
		    if (TRACE) fprintf(stderr, "MIME: Can't translate! ** \n");
		    me->target = me->sink;	/* Cheat */
		}
		if (me->target) {
		    me->targetClass = *me->target->isa;
		/* Check for encoding and select state from there @@ */
		
		    me->state = MIME_TRANSPARENT; /* From now push straigh through */
		} else {
		    me->state = MIME_IGNORE;		/* What else to do? */
		}
	    }
	    break;
	    
	default:
	   goto bad_field_name;
	   break;
	   
	} /* switch on character */
        break;
	
    case CHECK:				/* Check against string */
        if (TOLOWER(c) == *(me->check_pointer)++) {
	    if (!*me->check_pointer) me->state = me->if_ok;
	} else {		/* Error */
	    if (TRACE) fprintf(stderr,
	    	"HTMIME: Bad character `%c' found where `%s' expected\n",
		c, me->check_pointer - 1);
	    goto bad_field_name;
	}
	break;
	
    case CONTENT_T:
        switch(c) {
	case 'r':
	case 'R':
	    me->check_pointer = "ansfer-encoding:";
	    me->if_ok = CONTENT_TRANSFER_ENCODING;
	    me->state = CHECK;
	    break;
	    
	case 'y':
	case 'Y':
	    me->check_pointer = "pe:";
	    me->if_ok = CONTENT_TYPE;
	    me->state = CHECK;
	    break;
	    
	default:
	    goto bad_field_name;
	    
	} /* switch on character */
	break;
	
    case CONTENT_TYPE:
    case CONTENT_TRANSFER_ENCODING:
        me->field = me->state;		/* remember it */
	me->state = SKIP_GET_VALUE;
				/* Fall through! */
    case SKIP_GET_VALUE:
    	if (c == '\n') {
	   me->fold_state = me->state;
	   me->state = NEWLINE;
	   break;
	}
	if (WHITE(c)) break;	/* Skip white space */
	
	me->value_pointer = me->value;
	me->state = GET_VALUE;   
	/* Fall through to store first character */
	
    case GET_VALUE:
    	if (WHITE(c)) {			/* End of field */
	    *me->value_pointer = 0;
	    switch (me->field) {
	    case CONTENT_TYPE:
	        me->format = HTAtom_for(me->value);
		break;
	    case CONTENT_TRANSFER_ENCODING:
	        me->encoding = HTAtom_for(me->value);
		break;
	    default:		/* Should never get here */
	    	break;
	    }
	} else {
	    if (me->value_pointer < me->value + VALUE_SIZE - 1) {
	        *me->value_pointer++ = c;
		break;
	    } else {
	        goto value_too_long;
	    }
	}
	/* Fall through */
	
    case JUNK_LINE:
        if (c == '\n') {
	    me->state = NEWLINE;
	    me->fold_state = me->state;
	}
	break;
	
	
    } /* switch on state*/
    
    return;
    
value_too_long:
    if (TRACE) fprintf(stderr,
    	"HTMIME: *** Syntax error. (string too long)\n");
    
bad_field_name:				/* Ignore it */
    me->state = JUNK_LINE;
    return;
    
}