Ejemplo n.º 1
0
		void RedBlackTree<Key, Data>::killAll(RedBlackNode<Key, Data> *rec)
		{
			if (!valid(rec)) {
				return;
			}

			/* First kill our subnodes: */
			if (valid(rec->left))
				killAll(rec->left);

			if (valid(rec->right))
				killAll(rec->right);

			if (valid(rec->parent)) {                /* We're not root. */
				if (rec->parent->left == rec)
					rec->parent->left = nullNode;
				else
					rec->parent->right = nullNode;
			}

			Dealloc(rec->id);
			rec->left = NULL;
			rec->right = NULL;
			delete rec;
		}
Ejemplo n.º 2
0
/*
 * This small program copies all of the source from files inside of the
 * src folder and puts them into one file that can then be loaded into
 * the html file to run SoBr.
 */
int main()
{
	extern FILE * output;
	extern FILE * files;

	char fileName[MAX_SIZE];

	system(FIND_COMMAND);
	files = fopen(FILES, "r");
	if(files == NULL)
		killAll("Error opening the list of files");
	output = fopen(OUTPUT_FILE, "w");
	if(output == NULL)
		killAll("Error creating the output file");
	// loop through all of the js files
	while(fgets(fileName, MAX_SIZE, files) != NULL)
	{
		// remove the '\n' from the fileName
		int i = strlen(fileName);
		fileName[i - 1] = '\0';

		processFile(fileName);
	}

	// close files
	fclose(files);
	fclose(output);

	printf("Done processing the files, output should now be in %s\n", OUTPUT_FILE);

	return 0;
}
Ejemplo n.º 3
0
//Executado quando o monitor recebe um sinal de alarme no final da execução
void alarmhandler(int signo){
	printf("-----------------------------------------------\n");
	printf("PROGRAMA TERMINOU: PASSARAM OS %d SEGUNDOS\n", tempo);
	printf("-----------------------------------------------\n");

	killAll();
}
Ejemplo n.º 4
0
//Executado quando o user prime Ctrl C para sair do programa
void inthandler(int signo){
	printf("\n");
	printf("-----------------------------------------------\n");
	printf("----------------PROGRAMA TERMINOU--------------\n");
	printf("-----------------------------------------------\n");

	killAll();
}
Ejemplo n.º 5
0
HexyTool::HexyTool(QWidget *parent)
	: QWidget(parent)
	, ui(new Ui::HexyTool)
	, serial(new HexySerial(this))
	, settings(nullptr)
{
	ui->setupUi(this);
	ui->tryToggleConnect->configure("Connect","Connecting","Connected", "#e1be4e");
	if(!connect(serial,SIGNAL(settingsChanged()), this, SLOT(onHexySettingsChanged()))) {
		qWarning()<<"ERROR: could not connect";
	}

	if(!connect(serial,SIGNAL(connectionChanged()), this, SLOT(onHexyConenctionChanged()))) {
		qWarning()<<"ERROR: could not connect";
	}
	if(!connect(ui->tryToggleConnect, SIGNAL(stateChanged(const TryToggleState, const TryToggleState)), this, SLOT(onConnectChanged(const TryToggleState, const TryToggleState)))) {
		qWarning()<<"ERROR: could not connect";
	}

	if(!connect(ui->widgetLimbIK, SIGNAL(IKUpadted()), this, SLOT(onLimbIKUpdated()))) {
		qWarning()<<"ERROR: could not connect";
	}


	for(quint32 i=0; i<HexySerial::SERVO_COUNT; ++i) {
		ServoInput *si=new ServoInput();
		if(0!=si) {
			si->configure(settings,i);
			if(!connect(si,SIGNAL(servoMoved(quint32, qreal)),this,SLOT(onServoMoved(quint32, qreal)),OC_CONTYPE)) {
				qWarning()<<"ERROR: could not connect";
			}
			if(!connect(si,SIGNAL(servoKilled(quint32)),this,SLOT(onServoKilled(quint32)),OC_CONTYPE)) {
				qWarning()<<"ERROR: could not connect";
			}
			ui->scrollAreaWidgetContents->layout()->addWidget(si);
		}
	}

	QSpacerItem *vs = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
	ui->verticalLayoutServos->addItem(vs);
	ui->scrollAreaServos->setEnabled(false);
	ui->widgetGait->setGait(gait);
	killAll();
	gaitTimer.setTimerType(Qt::PreciseTimer);
	gaitTimer.setInterval(40);
	if(!connect(&gaitTimer,SIGNAL(timeout()),this,SLOT(onUpdateGaitTimer()))) {
		qWarning()<<"ERROR: Could not connect";
	}
	gait.setDirection(0.5,0.5);
}
Ejemplo n.º 6
0
void HexyTool::onConnectChanged(const TryToggleState last, const TryToggleState current)
{
	ui->scrollAreaServos->setEnabled(ON==current);
	switch(current) {
	case(OFF): {
		killAll();
		if(0!=serial) {
			serial->closeSerialPort();
		}
	}
	break;
	case(TRYING): {
		setEnabled(false);
		serial->configure();
	}
	break;
	case(ON): {
		killAll();
	}
	break;
	}

}
Ejemplo n.º 7
0
int main(void) {
    printf(
        "Real      UID = %d\n"
        "Effective UID = %d\n"
        "Real      GID = %d\n"
        "Effective GID = %d\n",
        getuid (),
        geteuid(),
        getgid (),
        getegid()
    );
  killAll("pound");
  return 0;
}
Ejemplo n.º 8
0
/*
 *	Open the specified file and copy all of it's contents
 *	over to the output file. The file is given a header with
 *	the input files name.
 */
void processFile(char * fileName)
{
	extern FILE * input;
	extern FILE * output;

	char line[MAX_SIZE];

	input = fopen(fileName, "r");
	if(input == NULL)
		killAll("Error opening input file");
	fprintf(output, "//---------------- starting %s -----------------------//\n", fileName);
	while(fgets(line, MAX_SIZE, input) != NULL)
		fprintf(output, "%s", line);

	fclose(input);
}
Ejemplo n.º 9
0
void handleKeyboard(entity **men, baseEntity **corpses, soldiers *army, SDL_Event *events, int *success, options *opt, Mix_Chunk **deathsounds, soldiers *bullets, entity *shell, entity *gas, Mix_Chunk **explosionSounds,int *points)
{
	switch(events->key.keysym.sym)
	{
		case SDLK_1:
		if(*points > men[LANDWEHRSPR]->cost)
		{
			newSquad(army,opt,men[LANDWEHRSPR], corpses,success, deathsounds);
			*points -= men[LANDWEHRSPR]->cost;
		}
			break;
		case SDLK_2:
		if(*points > men[STURMTRUPPENSPR]->cost)
		{
			newSquad(army,opt,men[STURMTRUPPENSPR], corpses,success, deathsounds);
			*points -= men[STURMTRUPPENSPR]->cost;
		}
			break;
		case SDLK_3:
		if(*points > shell->cost)
		{
			newShells(bullets, opt, shell, success, explosionSounds, GERMAN);
			*points -= shell->cost;
		}
			break;
		case SDLK_4:
		if(*points > men[LANDWEHRSPR]->cost)
		{
			newShells(bullets, opt, gas, success, explosionSounds, GERMAN);
			*points -= gas->cost;
		}
			break;
		case SDLK_ESCAPE:
			*success = FAIL;
			break;
		case SDLK_p:
			killAll(army);
			break;
		
	
	}





}
Ejemplo n.º 10
0
/*!
  \internal
  */
void ApplicationShutdownTask::timeout()
{
    switch(m_state) {
        case NoShutdown:
        case Shutdown:
        default:
            Q_ASSERT(!"Unknown");
            break;
        case WaitingForShutdown:
            // Issue kill
            killAll();
            m_timer.start();
            m_state = KilledApps;
            break;
        case KilledApps:
            // Failed - proceed anyway
            m_state = Shutdown;
            qWarning("Applications failed to exit at system shutdown");
            emit proceed();
            break;
    }
}
Ejemplo n.º 11
0
int main(int argc, char *argv[]) {


	int runtime, alive_procs=(argc-3), status;
	sizeof_pgrids=alive_procs;
	__pid_t pid;

	struct sigaction action;
	action.sa_handler = sig_handler;
	sigemptyset(&action.sa_mask);
	//action.sa_flags = SA_NOCLDWAIT; //v1
	action.sa_flags = 0; //v2

	if (sigaction(SIGCHLD, &action, NULL) < 0)
	{
		fprintf(stderr,"Unable to install SIGNAL handler\n");
		exit(1);
	}
	status = 3;
	for(; status<argc; status++){
		int fd= open(argv[status], O_RDONLY);
		if(fd==-1){
			fprintf(stderr, "One or more files given not found\n");
			exit(1);
		}
		close(fd);
	}
	pgrids=malloc(sizeof(__pid_t) * alive_procs);


	if(argc<4)
	{
		puts("Invalid input.\nInput example: ./monitor time word filename1 filename2 ... filenameN\n");
		return -1;
	}

	runtime = atoi(argv[1]);
	int i = 3;
	for(; i<argc; i++)
	{
		int tmp = i -3;

		if((pid= fork()) == 0)
		{
			//word control
			monitorWord(argv[2], argv[i]);
			return 0;
		}
		else
		{
			pgrids[tmp]= pid;
			setpgid(pid, pid); //child pgrid is the same as his pid
		}

	}



	//creating monitor_aux for the file and process
	if((pid = fork())==0)
	{
		monitorExistence(argv, pgrids, argc);
		return 0;
	}
	if(DEBUG)
		printf("alive processes:%d\n", alive_procs);
	while(alive_procs>0)
	{	//v2
		__pid_t pid_tmp= waitpid(-1, &status, WNOHANG);

		runtime=sleep(runtime);
		if(runtime==0)
			break;

		if(pid_tmp>0){
			printf("pid_tmp:%d\n", pid_tmp);
			alive_procs--;
			doNotFollow(pid_tmp, pgrids, sizeof_pgrids);
		}
	}
	killAll(pgrids, &sizeof_pgrids, pid); //v2
	return 0;
}
void PyrobarFireController::reset() {
  _nextNoteIndex = 0;
  _startTime = NULL;
  _sequence->reset();
  killAll();
}
Ejemplo n.º 13
0
void HexyTool::on_pushButtonDisableAll_clicked()
{
	killAll();
}
Ejemplo n.º 14
0
		void RedBlackTree<Key, Data>::killAll()
		{
			killAll(rootNode);
			rootNode = nullNode;
			m_cachedSize = 0;
		}
Ejemplo n.º 15
0
		RedBlackTree<Key, Data>::~RedBlackTree()
		{
			killAll();
			nullNode->right = nullNode->left = NULL;
			delete nullNode;
		}