コード例 #1
0
//-----------------------------------------------------------------------
CAnimatedPanelDecorator::CAnimatedPanelDecorator(QWidget* pDecoratedWidget,
                                                 QGraphicsItem* pItem,
                                                 EnumPlacement ePlacement,
                                                 int iScreenOffset,
                                                 QWidget* pOpenPanelButton,
                                                 int iButtonOffset,
                                                 const QString& openIcon /*= ""*/,
                                                 const QString& closeIcon /*= ""*/)
    : m_pOpenPanelButton(0)
    , m_pDecoratedWidget(pDecoratedWidget)
{
    m_pPanelAnimator = new PanelAnimator(pItem, pDecoratedWidget, ePlacement, iScreenOffset, pOpenPanelButton, false, iButtonOffset, openIcon, closeIcon);

    if (pOpenPanelButton)
    {
        connect(pOpenPanelButton, SIGNAL(clicked()), m_pPanelAnimator, SLOT(animate()));
    }

    pItem->setFlags(QGraphicsItem::ItemClipsChildrenToShape);

    connect(m_pPanelAnimator, SIGNAL(opened()),		this, SIGNAL(opened()));
    connect(m_pPanelAnimator, SIGNAL(closed()),		this, SIGNAL(closed()));
    connect(m_pPanelAnimator, SIGNAL(opening()),	this, SIGNAL(opening()));
    connect(m_pPanelAnimator, SIGNAL(closing()),	this, SIGNAL(closing()));
}
コード例 #2
0
//-----------------------------------------------------------------------
CAnimatedPanelDecorator::CAnimatedPanelDecorator(QWidget* pDecoratedWidget,
                                                 QGraphicsItem* pItem,
                                                 EnumPlacement ePlacement,
                                                 int iScreenOffset,
                                                 const QString& openPanelIconFileName,
                                                 const QString& openPanelText,
                                                 int iButtonOffset,
                                                 const QString& openIcon /*= ""*/,
                                                 const QString& closeIcon /*= ""*/)
    : m_pOpenPanelButton(0)
    , m_pDecoratedWidget(pDecoratedWidget)
{
    m_pOpenPanelButton = new QPushButton();
    if (!openPanelIconFileName.isEmpty())
        m_pOpenPanelButton->setIcon(QIcon(openPanelIconFileName));
    m_pOpenPanelButton->setText(openPanelText);

    m_pPanelAnimator = new PanelAnimator(pItem, pDecoratedWidget, ePlacement, iScreenOffset, m_pOpenPanelButton, true, iButtonOffset, openIcon, closeIcon);

    pItem->setFlags(QGraphicsItem::ItemClipsChildrenToShape);


    connect(m_pPanelAnimator, SIGNAL(opened()),		this, SIGNAL(opened()));
    connect(m_pPanelAnimator, SIGNAL(closed()),		this, SIGNAL(closed()));
    connect(m_pPanelAnimator, SIGNAL(opening()),	this, SIGNAL(opening()));
    connect(m_pPanelAnimator, SIGNAL(closing()),	this, SIGNAL(closing()));
}
コード例 #3
0
ファイル: upnp_xml.c プロジェクト: DoomHammer/leiads
/* Get information (name, value, next attribute) about the given attribute */
static gboolean xml_get_attribute_info( const char *xml, struct xml_info *info )
{
	if ( xml == NULL || *xml == '\0' || *xml == '/' || *xml == '>' ) return FALSE;

	/* Parse name */
	info->name = (char*)xml;
	while ( !xml_is_space( *xml ) && *xml != '=' && *xml != '>' && *xml != '\0' )
		xml++;
	info->end_of_name = (char*)xml;
	if ( info->end_of_name == info->name )
	{
		upnp_warning(( "xml_get_attribute_info(): Invalid Name: %s\n", opening( info->name ) ));
		return FALSE;
	}

	while ( xml_is_space( *xml ) ) xml++;

	if ( *xml == '=' )
	{
		char quote;

		do xml++;
		while ( xml_is_space( *xml ) );

		/* Parse value */
		quote = *xml++;
		if ( quote != '\"' && quote != '\'' )
		{
			upnp_warning(( "xml_get_attribute_info(): Not Well-Formed AttValue: %s\n", opening( --xml ) ));
			return FALSE;
		}

		info->content = (char*)xml;
		xml = strchr( xml, quote );
		if ( xml == NULL )
		{
			upnp_warning(( "xml_get_attribute_info(): Not Well-Formed AttValue: %c%s\n", quote, opening( info->content ) ));
			return FALSE;
		}

		info->end_of_content = (char*)xml++;

		while ( xml_is_space( *xml ) ) xml++;
	}
	else
	{
		info->end_of_content = info->content = (char*)xml;
	}

	info->next = (char*)xml;
	return TRUE;
}
コード例 #4
0
void FramelessMainWindow::reconnectMediaPlayer()
{
    VlcMediaPlayer *player = VLC::_player;
    if ( !player ) return;

    connect( m_closeButton, SIGNAL( clicked() ), player, SLOT( stop() ) );

    connect( player, SIGNAL( opening() ), this, SLOT( playbackStarted() ) );
    connect( player, SIGNAL( opening() ), m_control, SLOT( onPlaying() ) );
    connect( player, SIGNAL( stopped() ), this, SLOT( playbackStopped() ) );
    connect( player, SIGNAL( stopped() ), m_hostApp, SLOT( cancelTorrent() ) );
    connect( player, SIGNAL( stopped() ), m_control, SLOT( resetPlayback() ) );
    connect( player, SIGNAL( stopped() ), m_control, SLOT( resetPlayback() ) );
}
コード例 #5
0
//-----------------------------------------------------------------------
void PanelAnimator::animate()
{
    if (m_eCurrentAction == eClosed)
    {
        if (!m_CloseIcon.isNull())
        {
            if (QPushButton* pBtn = dynamic_cast<QPushButton*>(m_pBorderWidget))
            {
                pBtn->setIcon(m_CloseIcon);
            }
        }

        m_iTotalDelta = 0;
        emit opening();
        animateOpen();
    }
    else if (m_eCurrentAction == eOpened)
    {
        if (!m_OpenIcon.isNull())
        {
            if (QPushButton* pBtn = dynamic_cast<QPushButton*>(m_pBorderWidget))
            {
                pBtn->setIcon(m_OpenIcon);
            }
        }

        m_iTotalDelta = 0;
        emit closing();
        animateClose();
    }
}
コード例 #6
0
ファイル: openclose.c プロジェクト: BelfordZ/cpsc3200
void solve_case(void)
{
  char C[MAX_MN][MAX_MN+1];

  opening(A, B, C);
  print_image(C);
  fprintf(out, "\n");
  closing(A, B, C);
  print_image(C);
}
コード例 #7
0
ファイル: 1.c プロジェクト: surakshya1/lab3
int main()
{
	char a[MAX],w,d;
	stack s;
	s.top=-1;
	int i,valid=1;
	
	printf("Enter the equation:\n");
	scanf("%s",&a);
	
	for(i=0;i<strlen(a);i++)
	{
		printf("%d\n",i);
		if(a[i]=='(' || a[i]=='{' || a[i]=='[')
		{
			push(&s,a[i]);
		}
		if (a[i]==')' || a[i]=='}' || a[i]==']')
		{	
			if(s.top==-1)
			{
			valid=0;
			}
			
			else
			{
			w=pop(&s);
			d=opening(a[i]);
			
			
			if(w!=d)
			{
			valid=0;
			}
			}
		
		}
		
	}
	
if(!(s.top==-1))
{
	valid=0;
}

if(valid==1)
{
	printf("The mathematical expression you entered is VALID.");
}

else
{
	printf("The mathematical expression you entered is INVALID.");
}
}
コード例 #8
0
int main()
{
	char a[max],w,d;
	stack s;
	s.top=-1;
	int i,valid=1;
	
	printf("Enter the equation:\n");
	scanf("%s",&a);
	
	for(i=0;i<strlen(a);i++)
	{
		printf("%d\n",i);
		if(a[i]=='(' || a[i]=='{' || a[i]=='[')
		{
			push(&s,a[i]);
		}
		if (a[i]==')' || a[i]=='}' || a[i]==']')
		{	
			if(s.top==-1)
			{
			valid=0;
			}
			
			else
			{
			w=pop(&s);
			d=opening(a[i]);
			
			
			if(w!=d)
			{
			valid=0;
			}
			}
		
		}
		
	}
	
if(!(s.top==-1))
{
	valid=0;
}

if(valid==1)
{
	printf("valid");
}

else
{
	printf("invalid");
}
}
コード例 #9
0
//-----------------------------------------------------------------------
void PanelAnimator::open()
{
    if (!m_CloseIcon.isNull())
    {
        if (QPushButton* pBtn = dynamic_cast<QPushButton*>(m_pBorderWidget))
        {
            pBtn->setIcon(m_CloseIcon);
        }
    }

    m_iTotalDelta = 0;
    emit opening();
    animateOpen();
}
コード例 #10
0
//-----------------------------------------------------------------------
CAnimatedPanelDecorator::CAnimatedPanelDecorator(QWidget* pDecoratedWidget,
                                                 QGraphicsScene* pScene,
                                                 EnumPlacement ePlacement,
                                                 int iScreenOffset,
                                                 QWidget* pOpenPanelButton,
                                                 int iButtonOffset,
                                                 const QString& openIcon /*= ""*/,
                                                 const QString& closeIcon /*= ""*/)
    : m_pOpenPanelButton(0)
    , m_pDecoratedWidget(pDecoratedWidget)
{
    m_pPanelAnimator = new PanelAnimator(pScene, pDecoratedWidget, ePlacement, iScreenOffset, pOpenPanelButton, false, iButtonOffset, openIcon, closeIcon);

    if (pOpenPanelButton)
    {
        connect(pOpenPanelButton, SIGNAL(clicked()), m_pPanelAnimator, SLOT(animate()));
    }

    connect(m_pPanelAnimator, SIGNAL(opened()),		this, SIGNAL(opened()));
    connect(m_pPanelAnimator, SIGNAL(closed()),		this, SIGNAL(closed()));
    connect(m_pPanelAnimator, SIGNAL(opening()),	this, SIGNAL(opening()));
    connect(m_pPanelAnimator, SIGNAL(closing()),	this, SIGNAL(closing()));
}
コード例 #11
0
ファイル: main.c プロジェクト: Osyx/mr2d
int main(void) {

	hardware_init();
	display_init();
	start();
	start_select();
	settings_select();
	opening();
	run_game();
	you_died();
	score_screen();
	main();

	return 0;
}
コード例 #12
0
int main()
{	/* KAMUS */
	/* ALGORITMA */
	opening();
	CreateEmptyQ(&Suggest);
	CreateEmptyUser(&LU);
	board_used = 1;
	BacaUser(&LU);
	BacaStatistic();
	BacaDict(&DicT);
	SelectMenu();
	TulisUser(&LU);
	TulisStatistic();
	DeleteTree(&DicT);
	return 0;
}
コード例 #13
0
ファイル: upnp_xml.c プロジェクト: DoomHammer/leiads
char *xml_unwrap_delimiters_in_place( char *buf )
{
	char *src = buf, *dest = buf;

	for (;;)
	{
		char c = *src++;
		if ( c == '&' )
		{
			if ( strncmp( src, _amp + 1, 4 ) == 0 )
			{
				src += 4;
				c = '&';
			}
			else if ( strncmp( src, _lt + 1, 3 ) == 0 )
			{
				src += 3;
				c = '<';
			}
			else if ( strncmp( src, _gt + 1, 3 ) == 0 )
			{
				src += 3;
				c = '>';
			}
			else if ( strncmp( src, _apos + 1, 5 ) == 0 )
			{
				src += 5;
				c = '\'';
			}
			else if ( strncmp( src, _quot + 1, 5 ) == 0 )
			{
				src += 5;
				c = '\"';
			}
			else
			{
				upnp_warning(( "xml_unwrap_delimiters(): unexpected &%s\n", opening( src ) ));
			}
		}

		*dest++ = c;
		if ( c == '\0' ) break;
	}

	return buf;
}
コード例 #14
0
ファイル: utils.cpp プロジェクト: kipu44/Fortran-IV-parser
//----------------------------------------------------------------
string lewyArgument(const string & text)
{
	if(text.empty())
	{
		return "";
	}

	if(text[text.size() - 1] == ')')
	{
		size_t pozycja = opening(text, text.size() - 1);
		return text.substr(pozycja);
	}
	else
	{
		size_t pozycja = text.find_last_of("*/+-()");
		return text.substr(pozycja + 1);
	}
}
コード例 #15
0
ファイル: HtmlNode.cpp プロジェクト: vhotspur/otterdict
/**
 * Creates new opening text from current attributes. This function scans
 * all parsed attributes (that includes newly added ones created through
 * setAttribute() call) and creates new opening text (including the tag
 * name and braces, of course); attributes are separated by single
 * space and all values are double-qouted.
 * 
 */
void HtmlNode::unparseAttributes() {
	if (!isTag()) {
		return;
	}
	
	std::string opening("<");
	opening.append(getTagName());
	
	
	Attributes::iterator e = attributes_.end();
	for (Attributes::iterator it = attributes_.begin(); it != e; ++it) {
		// FIXME - this shall be done nicer (somehow)
		opening.append(" ");
		opening.append(it->first);
		opening.append("=\"");
		opening.append(it->second);
		opening.append("\"");
    }
	
	//FIXME - add /> on empty tags
	opening.append(">");
	openingText_ = opening;
}
コード例 #16
0
ファイル: tp2.c プロジェクト: smdarry/rdefaut2010
void playLoop(IplImage* frameBuffer[], int frameCount)
{
    Blob* pBlobs = NULL;
    int pBlobCount = 0;

    CvMemStorage* storage = cvCreateMemStorage(0);

    /////////////////////////////////////////// 
    // Etape 1: construction du modele de fond
    MedianModel medianModel;

    // Apprentissage du modele
    learnMedianModel(&medianModel, "../View_008", "%s/frame_%04d.jpg", frameCount, 0.95);
    
    char filename[255];
    int i, pb, b;
    IplImage* frame = NULL, *segFrame = NULL;
    for(i = 0; i < frameCount; i++)
    {
        frame = frameBuffer[i];
        
        ////////////////////////////////////////////
        // Etape 2: segmentation utilisant un modele
         
        segFrame = segmentMedianStdDev(frame, 2.0, &medianModel);
        
        opening(segFrame, segFrame, 3);
        closing(segFrame, segFrame, 3);
        

        ///////////////////////////////////////////////////////////
        // Etape 3: extraction des blobs et de leur caracteristiques
        
        Blob* blobs;
        DistMetrics m;

        // Extraction des blobs
        int blobCount = extractBlobs(segFrame, frame, &blobs, storage);
    
        if(pBlobs != NULL)
        {
            // Matrice des combinaisons de recouvrements spatiaux
            m.mSpatial = cvCreateMat(blobCount, pBlobCount, CV_32FC1);

            // Matrices des differences d'histogramme
            m.mHist5 = cvCreateMat(blobCount, pBlobCount, CV_32FC3);
            m.mHist10 = cvCreateMat(blobCount, pBlobCount, CV_32FC3);
            m.mHist15 = cvCreateMat(blobCount, pBlobCount, CV_32FC3);

            float coverage, absDiff;
            Blob *b1, *b2;
            int step = m.mSpatial->step, hstep = m.mHist5->step;
            for(b = 0; b < blobCount; b++)
            {
                for(pb = 0; pb < pBlobCount; pb++)
                {
                    b1 = &blobs[b];
                    b2 = &pBlobs[pb];

                    coverage = percentOverlap(b1, b2);
                    ((float*)(m.mSpatial->data.ptr + b*step))[pb] = coverage;

                    absDiff = absDiffHistograms(&b1->h5, &b2->h5, 0);
                    ((float*)(m.mHist5->data.ptr + b*hstep))[pb*3] = absDiff;

                    absDiff = absDiffHistograms(&b1->h10, &b2->h10, 0);
                    ((float*)(m.mHist10->data.ptr + b*hstep))[pb*3] = absDiff;

                    absDiff = absDiffHistograms(&b1->h15, &b2->h15, 0);
                    ((float*)(m.mHist15->data.ptr + b*hstep))[pb*3] = absDiff;

                    // TODO: Faire les autres canaux
                }
            }


            //////////////////////////////////////////////////////////
            // Etape 4: association temporelle avec le frame precedent
            int assocMatrix[blobCount];
            association(blobs, pBlobs, &m, assocMatrix);

            // Transfer des identites (etiquettes) aux nouveaux blobs
            for(b = 0; b < blobCount; b++)
            {
                int index = assocMatrix[b];
                if(index != -1)
                    blobs[b].label = pBlobs[index].label;
                else
                    blobs[b].label = generateLabel();
            }
        }
        else
        {
            // Attribution d'une premiere etiquette a chaque blob
            for(b = 0; b < blobCount; b++)
                blobs[b].label = generateLabel();
        }

        // Images binaires
        drawBoundingRects(segFrame, blobs, blobCount);
        drawLabels(segFrame, blobs, blobCount);
        sprintf(filename, "bbox_%04d.jpg", i);
        cvSaveImage(filename, segFrame);

        // Image originales
        drawBoundingRects(frame, blobs, blobCount);
        drawLabels(frame, blobs, blobCount);
        sprintf(filename, "suivi_%04d.jpg", i);
        cvSaveImage(filename, frame);

        pBlobCount = blobCount;
        pBlobs = blobs;
    }
    cvReleaseMemStorage(&storage);
}
コード例 #17
0
ファイル: findpatn.c プロジェクト: 5432935/crossbridge
int findpatn(int *i, int *j, int *val)
/* find pattern to match for next move */
{
 int m, n;
 int ti, tj, tval;
 static int cnd, mtype;  /* game tree node number, move type */
/* mtype = 0, basic; 1, inverted; 2, reflected; 3, inverted & reflected */

/* open game then occupy corners */
 if (opn[4])   /* continue last move */
   {
    opn[4] = 0;  /* clear flag */
    if (opening(i, j, &cnd, mtype)) opn[4] = 1; /* more move then reset flag */
    if (p[*i][*j] == EMPTY)  /* valid move */
      {
       *val = 80;
       return 1;
     }
    else
      opn[4] = 0;
  }

 if (opn[0])   /* Northwest corner */
   {
    opn[0] = 0;  /* clear flag */
    if (openregion(0, 0, 5, 5))
      {
       cnd = 0;
       mtype = 0;
       opening(i, j, &cnd, mtype);  /* get new node for next move */
       if (opening(i, j, &cnd, mtype)) opn[4] = 1;
       *val = 80;
       return 1;
     }
 }

 if (opn[1])   /* Southwest corner */
   {
    opn[1] = 0;
    if (openregion(13, 0, 18, 5))
      {
       cnd = 0;
       mtype = 1;
       opening(i, j, &cnd, mtype);  /* get new node for next move */
       if (opening(i, j, &cnd, mtype)) opn[4] = 1;
       *val = 80;
       return 1;
     }
  }

 if (opn[2])   /* Northeast corner */
   {
    opn[2] = 0;
    if (openregion(0, 13, 5, 18))
      {
       cnd = 0;
       mtype = 2;
       opening(i, j, &cnd, mtype);  /* get new node for next move */
       if (opening(i, j, &cnd, mtype)) opn[4] = 1;
       *val = 80;
       return 1;
     }
  }

 if (opn[3])   /* Northeast corner */
   {
    opn[3] = 0;
    if (openregion(13, 13, 18, 18))
      {
       cnd = 0;
       mtype = 3;
       opening(i, j, &cnd, mtype);  /* get new node for next move */
       if (opening(i, j, &cnd, mtype)) opn[4] = 1;
       *val = 80;
       return 1;
     }
  }

/* occupy edges */
 if (opn[5])   /* North edge */
   {
    opn[5] = 0;
    if (openregion(0, 6, 4, 11))
      {
       *i = 3;
       *j = 9;
       *val = 80;
       return 1;
     }
  }

 if (opn[6])   /* South edge */
   {
    opn[6] = 0;
    if (openregion(18, 6, 14, 11))
      {
       *i = 15;
       *j = 9;
       *val = 80;
       return 1;
     }
  }

 if (opn[7])   /* West edge */
   {
    opn[7] = 0;
    if (openregion(6, 0, 11, 4))
      {
       *i = 9;
       *j = 3;
       *val = 80;
       return 1;
     }
  }

 if (opn[8])   /* East edge */
   {
    opn[8] = 0;
    if (openregion(6, 18, 11, 14))
      {
       *i = 9;
       *j = 15;
       *val = 80;
       return 1;
     }
  }

 *i = -1;
 *j = -1;
 *val = -1;

/* find local pattern */
 for (m = 0; m < 19; m++)
   for (n = 0; n < 19; n++)
     if ((p[m][n] == mymove) &&
         (matchpat(m, n, &ti, &tj, &tval) && (tval > *val)))
       {
        *val = tval;
        *i = ti;
        *j = tj;
      }
 if (*val > 0)  /* pattern found */
    return 1;
 else  /* no match found */
    return 0;
}  /* end findpatn */
コード例 #18
0
ファイル: main.c プロジェクト: OS2World/MM-SOUND-GOGO
int
main(int argc, char *argv[])
{
	MERET ret;
	int getOptSuccessed;

#if defined(_MSC_VER) && !defined(NDEBUG)
	/* 厳密な演算チェックのため */
	_controlfp(~_MCW_EM | _EM_INEXACT, _MCW_EM);
#endif
#if	defined(__FreeBSD__)
	{	/* デフォルト動作が他のOSと違う。*/
		struct sigaction new_sig;
        	memset(&new_sig, 0, sizeof(struct sigaction));
        	new_sig.sa_handler = SIG_IGN;
        	sigaction(SIGFPE, &new_sig, NULL);
	}
#endif
	if(MPGE_initializeWork() == ME_NOFPU) return ERR;

	getOptSuccessed = 1 < argc && getOpt(argc, argv) == NOERR;
	opening();
	if(!getOptSuccessed){
		usage();
		MPGE_endCoder();
		return ERR;
	}

	ret = MPGE_detectConfigure();
	if(ret != ME_NOERR){
		if(!silent) fprintf(stderr, "%s\n", getErrMsg(ret));
		return ERR;
	}

	putConfig();

	reportInit();	/* report progress */

#if defined(USE_ITIMER) || (defined(_CONSOLE) && defined(WIN32) && defined( USE_TTIMER ))
	ret = MPGE_processTrack();
	if(ret != ME_NOERR){
		if(!silent) fprintf(stderr, "%s\n", getErrMsg(ret));
	}
#else
	for(;;){
		ret = MPGE_processFrame();
		if(ret == ME_EMPTYSTREAM) break;
		if(ret != ME_NOERR){
			if(!silent) fprintf(stderr, "%s\n", getErrMsg(ret));
			break;
		}
		reportDsp(0);
	} /* main loop */
#endif
	ret = MPGE_closeCoder();
	if(ret != ME_NOERR) if(!silent) fprintf(stderr, "%s\n", getErrMsg(ret));

	reportTerm();

	MPGE_endCoder();
	clkput();
	return NOERR;
} /* main */
コード例 #19
0
ファイル: main.c プロジェクト: RodrigoCastiel/Portalsnake
int main()
{
    int field[25][50];
    int python[1000][2];
    int fd[2];
    int k,i,j,n=1,counter=0, over,t2;
    char directory[] = "Music/x.mid";

    allegro_init();
    install_keyboard();
    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 600, 272, 0, 0);
    install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,NULL);

    BITMAP *buffer = create_bitmap(600,272);
    MIDI *music;
    while(n>0)
    {
        dir = r;
        length = 4;
        score = 0;
        t = 100;
        sp = 1;
        over = 0;
        look = 'r';
        t2 = 1;
        python[0][0] = 15;
        python[0][1] = 10;
        python[1][0] = 15;
        python[1][1] = 9;
        python[2][0] = 15;
        python[2][1] = 8;
        python[3][0] = 15;
        python[3][1] = 7;

        srand(time(NULL));
        directory[6] = intchar(rand()%9 + 1);

        music = load_midi(directory);
        play_midi(music,0);

        clear_to_color(screen,0x000000);
        opening();
        menu_mode(field);
        init(field);

        position(field,python);  // position the snake
        food(field,fd);
        guardi = python[length-1][0];
        guardj = python[length-1][1];
        display(field,python,fd,t2);

        while(over!=1)
        {
            if(t2<10) {
                t2++;
            }
            guardi = python[length-1][0];
            guardj = python[length-1][1];
            save = dir;
            python[length][0] = i;
            python[length][1] = j;
            rest(10);
            if(keypressed()) {
                dir = readkey();
            }
            else if ((dir & 0xff) == 'w') dir =u;
            else if ((dir & 0xff) == 's') dir =d;
            else if ((dir & 0xff) == 'a') dir =l;
            else if ((dir & 0xff) == 'd') dir =r;

            if((dir==u)||(dir==d)||(dir==l)||(dir==r)) {
                over = analysis(field,python,fd);
                rest(t-10);
            }
            else if(dir==esc) {
                over=1;
                n=0;
            }
            else {
                dir = save;
                over = analysis(field,python,fd);
                rest(t-10);
            };
            display(field,python,fd,t2);



        }
        portal1[0] = 50;
        portal1[1] = 50;
        portal2[0] = 50;
        portal2[1] = 50;
        clear_to_color(screen,0xFFFFFF);
        textout_ex(screen,font,"Score: ",225,160,0x02094A,0xF7FF0B);
        outnumber(265,160,score);
        saverec(field,python,fd);
        destroy_midi(music);
        rest(100);
        if(readkey()==esc) {
            n=0;
        }

    }

    destroy_bitmap(buffer);
    return 0;
}
コード例 #20
0
ファイル: upnp_xml.c プロジェクト: DoomHammer/leiads
static gboolean xml_get_element_info( const char *xml, struct xml_info *info, enum xml_stop stop )
{
	upnp_assert( /*xml != NULL &&*/ info != NULL );

	if ( xml == NULL || *xml == '\0' ) return FALSE;

	/* No idea what this is, but since the QNAP version of Twonky 5.1 uses it we skip it anyway */
	while ( *xml == '#' )
	{
		upnp_warning(( "xml_get_element_info(): Garbage detected (Twonky5!?): %s\n", opening( xml ) ));

		xml = strchr( ++xml, '#' );
		if ( xml == NULL )
		{
			upnp_warning(( "xml_get_element_info(): Missing # delimiter\n" ));
			return FALSE;
		}

		xml++;
		while ( xml_is_space( *xml ) ) xml++;
	}

	for (;;)
	{
		if ( *xml++ != '<' )
		{
			upnp_warning(( "xml_get_element_info(): STag expected: %s\n", opening( --xml ) ));
			return FALSE;
		}
		if ( *xml == '/' )
		{
			upnp_warning(( "xml_get_element_info(): ETag detected: %s\n", opening( --xml ) ));
			return FALSE;
		}

		/* Comments (2.5) */
		if ( xml[0] == '!' && xml[1] == '-' && xml[2] == '-' )
		{
			/* Skip comment */
			xml = strstr( xml + 3, "-->" );
			if ( xml == NULL )
			{
				upnp_warning(( "xml_get_element_info(): Incomplete Comment\n" ));
				return FALSE;
			}

			xml += 3;
		}

		/* Processing Instructions (2.6) */
		else if ( xml[0] == '?' )
		{
			xml = strstr( xml + 1, "?>" );
			if ( xml == NULL )
			{
				upnp_warning(( "xml_get_element_info(): Incomplete PI\n" ));
				return FALSE;
			}

			xml += 2;
		}

		else break;

		while ( xml_is_space( *xml ) ) xml++;
	}

	/* Parse name */
	info->name = (char*)xml;
	while ( !xml_is_space( *xml ) && *xml != '/' && *xml != '>' )
	{
		if ( *xml == '\0' )
		{
			upnp_warning(( "xml_get_element_info(): Invalid Name: %s\n", opening( info->name ) ));
			return FALSE;  /* no valid XML */
		}

		xml++;
	}
	info->end_of_name = (char*)xml;
	if ( info->end_of_name == info->name )
	{
		upnp_warning(( "xml_get_element_info(): Invalid Name: %s\n", opening( info->name ) ));
		return FALSE;
	}

	if ( stop == STOP_AFTER_NAME ) return TRUE;

	while ( xml_is_space( *xml ) ) xml++;

	/* Parse attributes (if any) */
	info->attributes = (char*)xml;
	if ( *xml != '/' && *xml != '>' )
	{
		do
		{
			char ch = *xml++;
			if ( ch == '\0' )
			{
				upnp_warning(( "xml_get_element_info(): Incomplete Attributes: %s\n", opening( info->attributes ) ));
				return FALSE;
			}

			if ( ch == '\"' || ch == '\'' )
			{
				xml = strchr( xml, ch );
				if ( xml == NULL )
				{
					upnp_warning(( "xml_get_element_info(): Incomplete Attributes: %s\n", opening( info->attributes ) ));
					return FALSE;
				}

				xml++;
			}
		}
		while ( *xml != '/' && *xml != '>' );
	}
	info->end_of_attributes = (char*)xml;

	if ( stop == STOP_AFTER_ATTRIBUTES ) return TRUE;

	if ( *xml++ == '/' )  /* empty element */
	{
		info->end_of_content = info->content = (char*)xml;

		if ( *xml != '>' )
		{
			upnp_warning(( "xml_get_element_info(): Incomplete EmptyElemTag: %s\n", opening( --xml ) ));
			return FALSE;
		}
	}
	else  /* == '>' */  /* Parse content */
	{
		size_t name_len = info->end_of_name - info->name;

		/* Discard white space at the start of the content */
		while ( xml_is_space( *xml ) ) xml++;
		info->content = (char*)xml;

		/* Search corresponding end-tag */
		for (;;)
		{
			xml = strchr( xml, '<' );
			if ( xml == NULL )
			{
				upnp_warning(( "xml_get_element_info(): ETag expected\n" ));
				return FALSE;
			}

			if ( xml[1] == '/' && strncmp( xml + 2, info->name, name_len ) == 0 )
			{
				const char *s = xml + 2 + name_len;
				if ( xml_is_space( *s ) || *s == '>' )  /* end-tag found */
				{
					info->end_of_content = (char*)xml;
					xml = s;
					break;
				}
			}
			else if ( strncmp( xml + 1, info->name, name_len ) == 0 )
			{
				const char *s = xml + 1 + name_len;
				if ( xml_is_space( *s ) || *s == '/' || *s == '>' )  /* start-tag found */
				{
					struct xml_info info;
					if ( !xml_get_element_info( xml, &info, COMPLETE ) )
					{
						upnp_warning(( "xml_get_element_info(): Not Well-Formed Content: %s\n", opening( xml ) ));
						return FALSE;
					}

					xml = info.next;
					continue;
				}
			}

			xml++;
		}

		/* Discard white space at the end of the content */
		do info->end_of_content--;
		while ( info->end_of_content >= info->content && xml_is_space( *info->end_of_content ) );
		info->end_of_content++;
	}

	if ( stop == STOP_AFTER_CONTENT ) return TRUE;

	while ( xml_is_space( *xml ) ) xml++;

	if ( *xml++ != '>' )
	{
		upnp_warning(( "xml_get_element_info(): Incomplete ETag: %s\n", opening( --xml ) ));
		return FALSE;
	}

	while ( xml_is_space( *xml ) ) xml++;

	info->next = (char*)xml;
	return TRUE;
}