Пример #1
0
static void rTreeTraverseRange(struct rbTreeNode *n)
/* Recursively traverse tree applying doIt to items between minIt and maxIt. */
{
if (n != NULL)
   {
   rbmTreeCompareResult minCmp = compareIt(n->item, minIt);
   rbmTreeCompareResult maxCmp = compareIt(n->item, maxIt);
   if (minCmp != RBMT_LESS)
       rTreeTraverseRange(n->left);
   if (minCmp != RBMT_LESS && maxCmp != RBMT_GREATER)
       doIt(n->item);
   if (maxCmp != RBMT_GREATER)
       rTreeTraverseRange(n->right);
   }
}
Пример #2
0
int main(int argc, char** argv) {

	// Invalid arguments entered
	if (argc < 2) {	printf("Usage \"Fib fibCount\"\n"); exit(0); }

	// Drop first arg
	argv++;

    // Attempt to get the fib count
	int fibs = atoi(*argv);

	// Bad number of repititions
	if (!(fibs > 0)) { printf("Invalid number\n"); exit(0); }

	int rootPID = getpid(), fd[2];
	char *gotBack;

	if (pipe(fd) < 0) { perror("Failed to create pipe: "); exit(0); }

	doIt(2, fibs, 1, 1, fd[1]);

	close(fd[1]);

    // Only the parent prints out the results
	if (getpid() == rootPID) {

        // Wait until children return fib value
		read(fd[0], gotBack, 1024);

        // Print out total read back, then jump to
        // second value for fibCount + 1 value
		printf("Original parent read %s\n", gotBack);		
		while (*gotBack != ' ') { gotBack++; }
		printf("Fib(%d) =%s\n", ++fibs, gotBack);
	}

	close(fd[0]);

	return 0;
}
Пример #3
0
void CMenuBeginGame::update ()
{
	if ( event.keyboard->isPressed () == true && event.keyboard->pressed == false )
	{
		event.keyboard->pressed = true;

		switch ( event.keyboard->getEvent ()->key.keysym.sym )
		{
		case SDLK_UP:
			selectkUp ();
			break;
		case SDLK_DOWN:
			selectDown ();
			break;
		case SDLK_SPACE:
			doIt ();
			break;
		default:
			break;
		}
	}
	else
		event.keyboard->pressed = event.keyboard->isPressed ();
}
void specResizeSVGcommand::undoIt()
{
	doIt() ;
}
Пример #5
0
void ProofGraph::transfProof( )
{
  // Time left for transformation
  double leftTime = cpuTime( );

  size_t size=0;
  int numnodes=0;
  int numedges=0;
  int numleaves=0;
  int numvars=0;
  double avgdeg=0;
  int dia=0;
  int maxclasize=0;
  double avgclasize=0;
  int unsatcoredim=0;
  int numunary=0;
  double avgnumresunary=0;
  double avgnumres=0;
  int maxnumres=0;
  double varnumres=0;
  double varclasize=0;

  if ( verbose() )
  {
    getGraphInfo( );

    size = graph.size( );
    numnodes=num_nodes;
    numedges=num_edges;
    numleaves=num_leaves;
    numvars=numVars;
    avgdeg=(double)numedges / (double)numnodes;
    dia=diameter;
    maxclasize=max_cla_size;
    avgclasize=av_cla_size;
    unsatcoredim=dim_unsat_core;
    numunary=num_unary;
    avgnumresunary=avg_num_res_unary;
    avgnumres=avg_num_res;
    maxnumres=max_num_res;
    varnumres=var_num_res;
    varclasize=var_cla_size;
  }

  double time=0;

  if( produceProof() )
  {
    if ( reduceProof() > 0 )
    {
      time = doIt( leftTime );
    }
  }
  else if( produceInterpolants() > 0 )
  {
    //No need to transform proof if no AB-mixed predicate is present!
    assert(!lightVars.empty());

    if ( reorderPivots() > 0)
      time = doIt( leftTime );
    else
    {
      opensmt_error( "Cannot produce interpolants because of AB-mixed predicates. Please enable pivot reordering in config file" );
    }
  }

#ifndef OPTIMIZE
  checkProof();
  cleanProofGraph( );
  checkProof();
#endif
  if ( verbose() > 0 )
  {
    getGraphInfo( );

    double perc_nodes=(((double)num_nodes-(double)numnodes)/(double)numnodes)*100;
    double perc_edges=(((double)num_edges-(double)numedges)/(double)numedges)*100;
    double perc_leaves=(((double)num_leaves-(double)numleaves)/(double)numleaves)*100;
    double perc_unsatcore=(((double)dim_unsat_core-(double)unsatcoredim)/(double)unsatcoredim)*100;
    cerr << "#" << endl;
    cerr << "# ------------------------------------" << endl;
    cerr << "# PROOF GRAPH TRASFORMATION STATISTICS    " << endl;
    cerr << "# ------------------------------------" << endl;
    cerr << "# Structural properties" << endl;
    cerr << "# ---------------------" << endl;
    cerr << "# Light variables............: ";
    fprintf( stderr, "%-10ld\n", lightVars.size( ) );
    cerr << "# Nominal num proof variables: ";
    fprintf( stderr, "%-10ld\n", numVarsLimit );
    cerr << "# Actual num proof variables.: ";
    fprintf( stderr, "%-10d %-10d\n", numvars, numVars );
    cerr << "# Nodes......................: ";
    fprintf( stderr, "%-10d %-10d\n", numnodes, num_nodes );
    cerr << "# Nodes variation............: ";
    fprintf( stderr, "%-9.2f %%\n", perc_nodes );
    cerr << "# Leaves.....................: ";
    fprintf( stderr, "%-10d %-10d\n", numleaves, num_leaves );
    cerr << "# Leaves variation...........: ";
    fprintf( stderr, "%-9.2f %%\n", perc_leaves );
    cerr << "# Unsat core.................: ";
    fprintf( stderr, "%-10d %-10d\n", unsatcoredim, dim_unsat_core );
    cerr << "# Unsat core variation.......: ";
    fprintf( stderr, "%-9.2f %%\n", perc_unsatcore );
    cerr << "# Edges......................: ";
    fprintf( stderr, "%-10d %-10d\n", numedges, num_edges );
    cerr << "# Edges variation............: ";
    fprintf( stderr, "%-9.2f %%\n", perc_edges );
    cerr << "# Graph vector size..........: ";
    fprintf( stderr, "%-10ld %-10ld\n", size, graph.size( ) );
    cerr << "# Average degree.............: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", avgdeg, (double)num_edges / (double)num_nodes );
    cerr << "# Diameter...................: ";
    fprintf( stderr, "%-10d %-10d\n", dia, diameter );
    cerr << "# Unary clauses..............: ";
    fprintf( stderr, "%-10d %-10d\n", numunary, num_unary );
    cerr << "# Max clause size............: ";
    fprintf( stderr, "%-10d %-10d\n", maxclasize, max_cla_size );
    cerr << "# Average clause size........: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", avgclasize, av_cla_size );
    cerr << "# Variance clause size.......: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", varclasize, var_cla_size );
    cerr << "# Max num res................: ";
    fprintf( stderr, "%-10d %-10d\n", maxnumres, max_num_res );
    cerr << "# Average num res............: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", avgnumres, avg_num_res );
    cerr << "# Avg num res unary clauses..: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", avgnumresunary, avg_num_res_unary );
    cerr << "# Variance num res...........: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", varnumres, var_num_res );
    cerr << "# -------------------------" << endl;
    cerr << "# Transformation statistics" << endl;
    cerr << "# -------------------------" << endl;
    cerr << "# Graph building time........: " << building_time << " s" << endl;
    cerr << "# Transformation time........: " << time << " s" << endl;
    cerr << "# Duplications...............: " << num_dup << endl;
    cerr << "# Node additions due to A1...: " << num_node_add_A1 << endl;
    cerr << "# ---------------------------" << endl;
    cerr << "# Rules application statistics" << endl;
    cerr << "# ---------------------------" << endl;
    cerr << "# A1.........................: " << A1 << endl;
    cerr << "# A1 undo....................: " << A1Undo << endl;
    cerr << "# A1 to B....................: " << A1B << endl;
    cerr << "# A2.........................: " << A2 << endl;
    cerr << "# A2 to B....................: " << A2B << endl;
    cerr << "# A2 unary...................: " << A2U << endl;
    cerr << "# B1.........................: " << B1 << endl;
    cerr << "# B2.........................: " << B2 << endl;
    cerr << "# B2 killer..................: " << B2K << endl;
    cerr << "# B3.........................: " << B3 << endl;
    cerr << "# ---------------------------" << endl;
  }
}
Пример #6
0
 void help()           { doIt ("--help"); }
Пример #7
0
int doIt( int argc, char **argv )
{
    QString file = QDir::homeDirPath();
    file += "/.kde/share/apps/kfm/pid";
    file += displayName();
    
    FILE *f = fopen( file.data(), "rb" );
    if ( f == 0L )
    {
	printf("No PID file called '%s'\n",file.data());
	if ( flag == 0 )
	{
	    printf("No PID file !!!!!!! Running new KFM !!!!!!!!!!!!!!\n");
	    system( "kfm &" );
	    flag = 1;
	    sleep( 5 );
	    return doIt( argc, argv );
	}
	
	printf("ERROR: KFM is not running\n");
	exit(1);
    }
    
    char buffer[ 1024 ];
    buffer[0] = 0;
    fgets( buffer, 1023, f );
    int pid = atoi( buffer );
    if ( pid <= 0 )
    {
	printf("ERROR: Invalid PID\n");
	exit(1);
    }

    if ( kill( pid, 0 ) != 0 )
    {
	if ( flag == 0 )
	{
	    flag = 1;
	    printf("KFM seems to be crashed !!!!!!! Running new KFM !!!!!!!!!!!!!!\n");
	    system( "kfm &" );
	    sleep( 5 );
	    return doIt( argc, argv );
	}

	printf("ERROR: KFM crashed\n");
	exit(1);
    }

    buffer[0] = 0;
    fscanf( f, "%s", buffer );
    char * slot = strdup( buffer ); 
    if ( slot == (void *)0 )
    {
	printf("ERROR: Invalid Slot\n");
	exit(1);
    }
    
    KfmIpc kfm( slot );
    free( slot );

    // Read the password
    QString fn = getenv( "HOME" );
    fn += "/.kde/share/apps/kfm/magic";
    f = fopen( fn.data(), "rb" );
    if ( f == 0L )
    {
	QMessageBox::message( "KFM Error",
			      "You dont have the file ~/.kde/share/apps/kfm/magic\n\rCould not do Authorization" );
	exit(1);
    }
    char *p = fgets( buffer, 1023, f );
    fclose( f );
    if ( p == 0L )
    {
	QMessageBox::message( "KFM Error",
			      "The file ~/.kde/share/apps/kfm/magic is corrupted\n\rCould not do Authorization" );
	exit(1);
    }

    kfm.auth( buffer );
    
    if ( argc < 2 )
    {
	printf( "Syntax Error: Too few arguments\n" );
	exit(1);
    }
    
    if ( strcmp( argv[1], "refreshDesktop" ) == 0 )
    {
	if ( argc != 2 )
	{
	    printf( "Syntax Error: Too many arguments\n" );
	    exit(1);
	}
	kfm.refreshDesktop();
    }
    else if ( strcmp( argv[1], "sortDesktop" ) == 0 )
    {
	if ( argc != 2 )
	{
	    printf( "Syntax Error: Too many arguments\n" );
	    exit(1);
	}
	kfm.sortDesktop();
    }
    else if ( strcmp( argv[1], "configure" ) == 0 )
    {
	if ( argc != 2 )
	{
	    printf( "Syntax Error: Too many arguments\n" );
	    exit(1);
	}
	kfm.configure();
    }
    else if ( strcmp( argv[1], "openURL" ) == 0 )
    {
	if ( argc == 2 )
	{
	    kfm.openURL( "" );
	}
	else if ( argc == 3 )
	{
	    kfm.openURL( argv[2] );
	}
	else
	{
	    printf( "Syntax Error: Too many arguments\n" );
	    exit(1);
	}
    }
    else if ( strcmp( argv[1], "refreshDirectory" ) == 0 )
    {
	if ( argc == 2 )
	{
	    kfm.openURL( "" );
	}
	else if ( argc == 3 )
	{
	    kfm.refreshDirectory( argv[2] );
	}
	else
	{
	    printf( "Syntax Error: Too many arguments\n" );
	    exit(1);
	}
    }
    else if ( strcmp( argv[1], "openProperties" ) == 0 )
    {
	if ( argc == 3 )
	{
	    kfm.openProperties( argv[2] );
	}
	else
	{
	    printf( "Syntax Error: Too many/few arguments\n" );
	    exit(1);
	}
    }
    else if ( strcmp( argv[1], "exec" ) == 0 )
    {
	if ( argc == 3 )
	{
	    kfm.exec( argv[2], 0L );
	}
	else if ( argc == 4 )
	{
	    kfm.exec( argv[2], argv[3] );
	}
	else
	{
	    printf( "Syntax Error: Too many/few arguments\n" );
	    exit(1);
	}
    }
    else if ( strcmp( argv[1], "move" ) == 0 )
    {
	if ( argc <= 3 )
	{
	    printf( "Syntax Error: Too many/few arguments\n" );
	    exit(1);
	}
	QString src = "";
	int i = 2;
	while ( i <= argc - 2 )
	{
	    src += argv[i];
	    if ( i < argc - 2 )
		src += "\n";
	    i++;
	}
	
	kfm.moveClient( src.data(), argv[ argc - 1 ] );
    }
    else if ( strcmp( argv[1], "copy" ) == 0 )
    {
	if ( argc <= 3 )
	{
	    printf( "Syntax Error: Too many/few arguments\n" );
	    exit(1);
	}
	QString src = "";
	int i = 2;
	while ( i <= argc - 2 )
	{
	    src += argv[i];
	    if ( i < argc - 2 )
		src += "\n";
	    i++;
	}
	
	kfm.copy( src.data(), argv[ argc - 1 ] );
    }
    else if ( strcmp( argv[1], "folder" ) == 0 )
    {
	if ( argc <=2 )
	{
	    printf( "Syntax Error: Too many/few arguments\n" );
	    exit(1);
	}

	if (argc > 3) {
	  QString src = "";
	  int i = 2;
	  while ( i <= argc - 2 )
	    {
	      src += argv[i];
	    if ( i < argc - 2 )
	      src += "\n";
	    i++;
	    }
	
	  kfm.moveClient( src.data(), argv[ argc - 1 ] );
	}
	else
	{
	    kfm.openURL( argv[2] );
	}
    }
    else if ( strcmp( argv[1], "selectRootIcons" ) == 0 )
    {
	if ( argc == 7 )
	{
	  int x = atoi( argv[2] );
	  int y = atoi( argv[3] );	  
	  int w = atoi( argv[4] );
	  int h = atoi( argv[5] );
	  int add = atoi( argv[6] );
	  bool bAdd = (bool)add;
	  kfm.selectRootIcons( x, y, w, h, bAdd );
	}
	else
	{
	    printf( "Syntax Error: Too many/few arguments\n" );
	    exit(1);
	}
    }
    else
    {
	printf("Syntax Error: Unknown command '%s'\n",argv[1] );
	exit(1);
    }
    return 0; // Stephan: default return
}
Пример #8
0
void MMSImageWidgetThread::threadMain() {
    doIt();
    delete this;
}
Пример #9
0
 void singleTest()     { doIt (" SingleTestID"); }
Пример #10
0
int main( int argc, char **argv )
{
    if ( argc == 1 )
    {
        // Should all the following be i18n'ed ?
	printf("kfmclient is (c) Torben Weis, 1997\nPart of the KDE Project\n\n");
	printf("Syntax:\n");
	printf("  kfmclient openURL\n"
	       "            # Opens a dialog to ask you for the URL\n\n");
	printf("  kfmclient openURL 'url'\n"
	       "            # Opens a window showing 'url'. If such a window\n");
	printf("            #   exists, it is shown. 'url' may be \"trash:/\"\n"
	       "            #   to open the trash bin.\n\n");
	printf("  kfmclient refreshDesktop\n"
	       "            # Refreshes the desktop\n\n");
	printf("  kfmclient refreshDirectory 'url'\n"
	       "            # Tells KFM that an URL has changes. If KFM\n");
	printf("            #   is displaying that URL, it will be reloaded.\n\n");
	printf("  kfmclient openProperties 'url'\n"
	       "            # Opens a properties menu\n\n");
	printf("  kfmclient exec 'url' ['binding']\n"
	       "            # Tries to execute 'url'. 'url' may be a usual\n"
	       "            #   URL, this URL will be opened. You may omit\n"
	       "            #   'binding'. In this case the default binding\n");
	printf("            #   is tried. Of course URL may be the URL of a\n"
	       "            #   document, or it may be a *.kdelnk file.\n");
	printf("            #   This way you could for example mount a device\n"
	       "            #   by passing 'Mount default' as binding to \n"
	       "            #   'cdrom.kdelnk'\n\n");
	printf("  kfmclient move 'src' 'dest'\n"
	       "            # Copies the URL 'src' to 'dest'.\n"
	       "            #   'src' may be a list of URLs.\n");
	printf("            #   'dest' may be \"trash:/\" to move the files\n"
	       "            #   in the trash bin.\n\n");
	printf("  kfmclient folder 'src' 'dest'\n"
	       "            # Like move if 'src' is given,\n"
	       "            #   otherwise like openURL src \n\n");
	printf("  kfmclient sortDesktop\n"
	       "            # Rearranges all icons on the desktop.\n\n");
	printf("  kfmclient configure\n"
	       "            # Re-read KFM's configuration.\n\n");
	printf("*** Examples:\n"
	       "  kfmclient exec file:/usr/local/kde/bin/kdehelp Open\n"
	       "             // Starts kdehelp\n\n");
	printf("  kfmclient exec file:/root/Desktop/cdrom.kdelnk \"Mount default\"\n"
	       "             // Mounts the CDROM\n\n");	
	printf("  kfmclient exec file:/home/weis/data/test.html\n"
	       "             // Opens the file with default binding\n\n");
	printf("  kfmclient exec file:/home/weis/data/test.html Netscape\n"
	       "             // Opens the file with netscape\n\n");
	printf("  kfmclient exec ftp://localhost/ Open\n"
	       "             // Opens new window with URL\n\n");
	printf("  kfmclient exec file:/root/Desktop/emacs.kdelnk\n"
	       "             // Starts emacs\n\n");
	printf("  kfmclient exec file:/root/Desktop/cdrom.kdelnk\n"
	       "             // Opens the CD-ROM's mount directory\n\n");
	return 0;
    }
    
    QApplication a( argc, argv );

    return doIt( argc, argv );
}
Пример #11
0
CExpression& CExpression::optimization()
{
/*
Проводит беглый предрасчёт выражения. Не учитывает комутативность операци.
*/
    if (!fine)
    {
        return *this;
    }
    unsigned counter = 0;
    while(walkthroughArray[counter].lexeme != 127)
        ++counter;
    sintElem* temp = new sintElem[counter + 1];

    unsigned i = 0, j = 0;
    while(walkthroughArray[i].lexeme != 127)
    {
        if(!walkthroughArray[i].lexeme || walkthroughArray[i].lexeme == 'x' || walkthroughArray[i].lexeme == 'y')
            temp[j++] = walkthroughArray[i];
        else
            if(isUnary(walkthroughArray[i].lexeme))
                if( !temp[j - 1].lexeme )
                    temp[j - 1] = doIt(walkthroughArray[i].lexeme, temp[j - 1]);
                else
                    temp[j++] = walkthroughArray[i];
            else
                if( !temp[j - 1].lexeme && !temp[j - 2].lexeme ) {
                    --j;
                    temp[j - 1] = doIt(walkthroughArray[i].lexeme, temp[j - 1], temp[j]);
                } else
                    temp[j++] = walkthroughArray[i];
        ++i;
    }
    temp[j].lexeme = 127;
    /*Безсмысленные операции:
* 1, 0
+ 0
/ 1
- 0
^ 1

я вижу *, как я ищу операнды? все возможные операции находящиеся перед ним уже выполнены, т. е. может быть 1 x 3 ^ * это же 1*х^3, что должно быть x^3,
что значит что я должен собирать какой-то стек из переменных пока не найду в обоих сторонах x или не соберу все, тогда с одной из сторон должен остатся
только безсмысленный операнд, проверить обе стороны на его наличие, удалить требуемое.
*/

    i = j = 0;
    if(temp[1].lexeme != 127)
        ++(++i);//речь о бинарных операциях, нет смысла изучать что там раньше третьего знака.
    while(temp[i].lexeme != 127)
    {
        switch(temp[i].lexeme)
        {
        case '*':
            if(!temp[i - 1].lexeme && temp[i - 1].number == 1)//правый операнд мы можем проверить сразу
            {
                delElements(temp + i - 1, 2);//убираем 1 и *
                --(--i);
            }
            else if(!temp[i - 1].lexeme && temp[i - 1].number == 0)
            {
                temp[i].lexeme = 0;
                temp[i].number = 0;//Чтобы не вызывать два удаления записываем 0 вместо *
                j = operatorCount(temp + i - 1);//собираем второй операнд, удаляем его и *.
                delElements(temp + i - j - 1, j + 1);
                i -= j + 1;
            }
            else//иначе просто собираем всё что попадает в правый операнд
            {
                j = operatorCount(temp + i);
                if(!temp[i - j - 1].lexeme && temp[i - j - 1].number == 1)
                {//удаляем 1 и само умножение.
                    delElements(temp + i, 1);
                    delElements(temp + i - j - 1, 1);
                    --(--i);
                }
                else if(!temp[i - j - 1].lexeme && temp[i - j - 1].number == 0)
                {
                    delElements(temp + i - j, j + 1);//удаляем всё кроме нуля
                    i -= j + 1;
                }
            }
            break;
        case '+': case '-':
            if(!temp[i - 1].lexeme && temp[i - 1].number == 0)
            {
                delElements(temp + i - 1, 2);
                --(--i);
            }
            else
            {
                j = operatorCount(temp + i);
                if(!temp[i - j - 1].lexeme && temp[i - j - 1].number == 0)
                {
                    delElements(temp + i, 1);
                    delElements(temp + i - j - 1, 1);
                    --(--i);
                }
            }
            break;
        case '/':
            if(!temp[i - 1].lexeme && temp[i - 1].number == 1)
            {
                delElements(temp + i - 1, 2);
                --(--i);
            }
            if(!temp[i - 1].lexeme && temp[i - 1].number == 0)
            {
                temp[i].lexeme = 0;
                temp[i].number = 1;
                j = operatorCount(temp + i - 1);
                delElements(temp + i - j - 1, j + 1);
                i -= j + 1;
            }
            else
            {
                j = operatorCount(temp + i);
                if(!temp[i - j - 1].lexeme && temp[i - j - 1].number == 0)
                {
                    delElements(temp + i - j, j + 1);
                    i -= j + 1;
                }
            }
            break;
        case '^': case -121:
            if(!temp[i - 1].lexeme && temp[i - 1].number == 1)
            {
                delElements(temp + i - 1, 2);
                --(--i);
            }
            else
            {
                j = operatorCount(temp + i);
                if(!temp[i - j - 1].lexeme && ( temp[i - j - 1].number == 0 || temp[i - j - 1].number == 1 ) )
                {
                    delElements(temp + i - j, j + 1);
                    i -= j + 1;
                }
            }
            break;
        }
        ++i;
    }

    delete[] walkthroughArray;
    walkthroughArray = temp;

    /*
    std::cout << "Оптимизированная нотация:\n";
    for(i = 0; walkthroughArray[i].lexeme != 127; ++i)
        if(walkthroughArray[i].lexeme)
            std::cout << walkthroughArray[i].lexeme << std::endl;
        else
            std::cout << walkthroughArray[i].number << std::endl;
    //*/

    return *this;
}
Пример #12
0
 void run() {
     prep();
     ASSERT( !error() );
     doIt();
     ASSERT( error() );
 }
Пример #13
0
 void additionalCmd2() { doIt ("\t\tSingleTestID spam --group TestGroupID    \t --eggs"); }
Пример #14
0
void main(int argc, char *argv[]){
	doIt(argv[1]);
	//doIt("025a67ca0b4cbd544a7f12bcae8a5365.dat");

	return;
}
Пример #15
0
 void additionalCmd()  { doIt (" --group TestGroupID SingleTestID spam eggs"); }
Пример #16
0
 void groupFilter2()   { doIt (" --group TestGroupID SingleTestID "); }
Пример #17
0
 void groupFilter1()   { doIt (" SingleTestID --group TestGroupID"); }
Пример #18
0
void specUndoCommand::redo()
{
	if(pO) doIt() ;
}
Пример #19
0
 void noOptions()      { doIt (""); }
Пример #20
0
int main(int argc, char* argv[])
{
    char thisfile[_MAX_PATH];
    char homepath[_MAX_PATH];
    char magic_envvar[_MAX_PATH + 12];
    char ldlib_envvar[_MAX_PATH * 4 + 12];
    char archivefile[_MAX_PATH + 5];
    char *oldldlib;
    TOC *ptoc = NULL;
    int rc = 0;
    char *workpath = NULL;
    /* atexit(cleanUp); */
#ifdef FREEZE_EXCEPTIONS
    PyImport_FrozenModules = _PyImport_FrozenModules;
#endif
    // fill in thisfile
#ifdef __CYGWIN__
    if (strncasecmp(&argv[0][strlen(argv[0])-4], ".exe", 4)) {
        strcpy(thisfile, argv[0]);
        strcat(thisfile, ".exe");
        Py_SetProgramName(thisfile);
    }
    else 
#endif
        Py_SetProgramName(argv[0]);
    strcpy(thisfile, Py_GetProgramFullPath());
    VS(thisfile);
    VS(" is thisfile\n");
    
    workpath = getenv( "_MEIPASS2" );
    if (workpath) {
        VS(workpath);
        VS(" is _MEIPASS2 (workpath)\n");
    }

    // fill in here (directory of thisfile)
    strcpy(homepath, Py_GetPrefix());
    strcat(homepath, "/");
    VS(homepath);
    VS(" is homepath\n");

    if (init(homepath, &thisfile[strlen(homepath)], workpath)) {
        /* no pkg there, so try the nonelf configuration */
        strcpy(archivefile, thisfile);
        strcat(archivefile, ".pkg");
        if (init(homepath, &archivefile[strlen(homepath)], workpath)) {
            FATALERROR("Cannot open self ");
            FATALERROR(thisfile);
            FATALERROR(" or archive ");
            FATALERROR(archivefile);
            FATALERROR("\n");
            return -1;
        }
    }

    if (workpath) {
        // we're the "child" process
        VS("Already have a workpath - running!\n");
        rc = doIt(argc, argv);
        if (strcmp(workpath, homepath)!=0)
            clear(workpath);
    }
    else {
        if (extractBinaries(&workpath)) {
            VS("Error extracting binaries\n");
            return -1;
        }
        if (workpath == NULL) {
            /* now look for the "force LD_LIBRARY" flag */
            ptoc = getFirstTocEntry();
            while (ptoc) {
                if ((ptoc->typcd == 'o') && (ptoc->name[0] == 'f')) {
                    strcat(homepath, "support/");
                    workpath = homepath;
                }
                ptoc = getNextTocEntry(ptoc);
            }
        }
        if (workpath) {
            VS("Executing self as child with ");
            // run the "child" process, then clean up
            strcpy(magic_envvar, "_MEIPASS2=");
            strcat(magic_envvar, workpath);
            putenv(magic_envvar);
            // now LD_LIBRARY_PATH
            strcpy(ldlib_envvar, "LD_LIBRARY_PATH=");
            strcat(ldlib_envvar, workpath);
            ldlib_envvar[strlen(ldlib_envvar)-1] = '\0';
            oldldlib = getenv("LD_LIBRARY_PATH");
            if (oldldlib) {
                strcat(ldlib_envvar, ":");
                strcat(ldlib_envvar, oldldlib);
            }
            putenv(ldlib_envvar);
            VS(ldlib_envvar);
            VS("\n");
            rc = execvp(thisfile, argv);
            VS("Back to parent...\n");
        }
        else
            // no "child" process necessary
            rc = doIt(argc, argv);
    }
    return rc;
}
Пример #21
0
 void groupID()        { doIt ("--group TestGroupID"); }
Пример #22
0
// REGULAR: warning: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
// PROMOTE: error: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
// IGNORE-NOT: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
void stackSizeWarning() {
  char buffer[80];
  doIt(buffer);
}
Пример #23
0
int main(int argc, char* argv[])
{
    char thisfile[_MAX_PATH];
    char homepath[_MAX_PATH];
    char archivefile[_MAX_PATH + 5];
    TOC *ptoc = NULL;
    int rc = 0;
    int pid;
    char *workpath = NULL;
    /* atexit(cleanUp); */
#ifdef FREEZE_EXCEPTIONS
    PyImport_FrozenModules = _PyImport_FrozenModules;
#endif
    /* fill in thisfile */
#ifdef __CYGWIN__
    if (strncasecmp(&argv[0][strlen(argv[0])-4], ".exe", 4)) {
        strcpy(thisfile, argv[0]);
        strcat(thisfile, ".exe");
        PI_SetProgramName(thisfile);
    }
    else
#endif
        PI_SetProgramName(argv[0]);
    strcpy(thisfile, PI_GetProgramFullPath());
    VS("thisfile is %s\n", thisfile);

    workpath = getenv( "_MEIPASS2" );
    VS("_MEIPASS2 (workpath) is %s\n", (workpath ? workpath : "NULL"));

    /* fill in here (directory of thisfile) */
    strcpy(homepath, PI_GetPrefix());
    strcat(homepath, "/");
    VS("homepath is %s\n", homepath);

    if (init(homepath, &thisfile[strlen(homepath)], workpath)) {
        /* no pkg there, so try the nonelf configuration */
        strcpy(archivefile, thisfile);
        strcat(archivefile, ".pkg");
        if (init(homepath, &archivefile[strlen(homepath)], workpath)) {
            FATALERROR("Cannot open self %s or archive %s\n",
                       thisfile, archivefile);
            return -1;
        }
    }

    if (workpath) {
        /* we're the "child" process */
        VS("Already have a workpath - running!\n");
        rc = doIt(argc, argv);
    }
    else {
        if (extractBinaries(&workpath)) {
            VS("Error extracting binaries\n");
            return -1;
        }

        if (workpath == NULL)
            workpath = homepath;

        VS("Executing self as child with ");
        /* run the "child" process, then clean up */
        setenv("_MEIPASS2", workpath, 1);

        /* add workpath to LD_LIBRARY_PATH */
        exportWorkpath(workpath, "LD_LIBRARY_PATH");
#ifdef __APPLE__
        /* add workpath to DYLD_LIBRARY_PATH */
        exportWorkpath(workpath, "DYLD_LIBRARY_PATH");
#endif
        pid = fork();
        if (pid == 0)
            execvp(thisfile, argv);
        /*
            wait(&rc);
            rc = WEXITSTATUS(rc);

            VS("Back to parent...\n");
            if (strcmp(workpath, homepath) != 0)
                clear(workpath);
        */
    }
    return rc;
}
Пример #24
0
cv::Mat IProcess::copy(icref im)       
{
	cv::Mat out(im);
	doIt(out);
	return out;
} 
Пример #25
0
void DES::setKey(const unsigned char* k)

{

	if (!k) return;

	unsigned char *ptr=key;

	int hole=0;

	for (int i=0; i<7; i++) {

		unsigned char c=k[i];

		*(ptr++)=(c&0x80)>>7;

		if ((++hole) % 7 == 0) *(ptr++)=0;

		*(ptr++)=(c&0x40)>>6;

		if ((++hole) % 7 == 0) *(ptr++)=0;

		*(ptr++)=(c&0x20)>>5;

		if ((++hole) % 7 == 0) *(ptr++)=0;

		*(ptr++)=(c&0x10)>>4;

		if ((++hole) % 7 == 0) *(ptr++)=0;

		*(ptr++)=(c&0x08)>>3;

		if ((++hole) % 7 == 0) *(ptr++)=0;

		*(ptr++)=(c&0x04)>>2;

		if ((++hole) % 7 == 0) *(ptr++)=0;

		*(ptr++)=(c&0x02)>>1;

		if ((++hole) % 7 == 0) *(ptr++)=0;

		*(ptr++)=c&0x01;

		if ((++hole) % 7 == 0) *(ptr++)=0;

	}



	unsigned char C[28]; // one bit by byte, simpler algorithm...

	unsigned char D[28]; // one bit by byte, simpler algorithm...

	// Initial permutation of the key

#ifdef _WIN32

	for (i=0; i<28; i++) {

#else

	for (int i=0; i<28; i++) {

#endif

		C[i]=key[PC1[i]];

		D[i]=key[PC1[i+28]];

	}



	unsigned char concat[56];

	// calculate the 16 keys

#ifdef _WIN32

	for (i=0; i<16; i++) {

#else

	for (int i=0; i<16; i++) {

#endif

		// do LSHIFT[i] shifts

		for (int j=0; j<LSHIFT[i]; j++) {

			// do the shift

			unsigned char savC = C[0];

			unsigned char savD = D[0];

			for (int l=0; l<27; l++) {

				C[l]=C[l+1];

				D[l]=D[l+1];

				concat[l]=C[l];

				concat[l+28]=D[l];

			}

			C[27]=savC;

			D[27]=savD;

			concat[27]=savC;

			concat[55]=savD;

		}

		// new permutation => give key

#ifdef _WIN32

		for (j=0; j<48; j++) {

#else

		for (int j=0; j<48; j++) {

#endif

			K[i][j]=concat[PC2[j]];

		}



	}

}





// Encrypt (encdec=0) or decrypt (encdec=1)

void DES::doIt(unsigned char* data, const unsigned long length, int encdec)

{

	unsigned char plain[64];

	unsigned char L[32];

	unsigned char R[32];

	unsigned char ER[48]; // expanded R xored with key

	unsigned char* dataIndex=data;

	int i,j;



	int len=length;

	while (len>=8) {

		// generate 64 bit "plain text" bloc

		unsigned char *ptr=plain;

		for (i=0; i<8; i++) {

			unsigned char c=*(dataIndex+i);

			*(ptr++)=(c&0x80)>>7;

			*(ptr++)=(c&0x40)>>6;

			*(ptr++)=(c&0x20)>>5;

			*(ptr++)=(c&0x10)>>4;

			*(ptr++)=(c&0x08)>>3;

			*(ptr++)=(c&0x04)>>2;

			*(ptr++)=(c&0x02)>>1;

			*(ptr++)=c&0x01;

		}



		// Initial permutation of the data block

		for (i=0; i<32; i++) {

			L[i]=plain[IP[i]];

			R[i]=plain[IP[i+32]];

		}

		

		// Apply the 16 keys

		for (i=0; i<16; i++) {

			// expand R and xor with key number i

			for (j=0; j<48; j++) {

				ER[j] = R[E[j]] ^ K[encdec?15-i:i][j];

			}

			unsigned char* ERIndex=ER;  // where to get the values

			unsigned char* ERIndexS=ER; // where to substitute (4 bits wide only)

			// apply the substitutions

			for (j=0; j<8; j++) {

				unsigned char c = S[j]

					[((*ERIndex)<<1)|(*(ERIndex+5))]

					[((*(ERIndex+1))<<3)|((*(ERIndex+2))<<2)|((*(ERIndex+3))<<1)|(*(ERIndex+4))];

				*(ERIndexS++)=(c&0x08)>>3;

				*(ERIndexS++)=(c&0x04)>>2;

				*(ERIndexS++)=(c&0x02)>>1;

				*(ERIndexS++)=c&0x01;

				ERIndex+=6;

			}

			// permute again and xor with L

			// assign new values for R and L

			for (j=0; j<32; j++) {

				unsigned char tmp = ER[P[j]] ^ L[j];

				L[j] = R[j];

				R[j] = tmp;

			}

		} // end of apply all keys



		// append R, L => plain (no need to declare another 64 bytes array)

		for (i=0; i<32; i++) {

			plain[i]=R[i];

			plain[i+32]=L[i];

		}

		// Final permutation, put result back into "data"

		for (i=0; i<8; i++) {

			j=i<<3;

			*(dataIndex++) = plain[FP[j+7]]

				| (plain[FP[j+6]] << 1)

				| (plain[FP[j+5]] << 2)

				| (plain[FP[j+4]] << 3)

				| (plain[FP[j+3]] << 4)

				| (plain[FP[j+2]] << 5)

				| (plain[FP[j+1]] << 6)

				| (plain[FP[j]] << 7);

		}



		len-=8;

	} // of while len>=8

}



// Data should always be aligned to a 64 bit multiple

// If not, discard the junk (hence force the caller to paddle...)

void DES::encrypt(unsigned char* data, const unsigned long length)

{

	doIt(data,length,0);

}



void DES::decrypt(unsigned char* data, const unsigned long length)

{

	doIt(data,length,1);

}