Exemplo n.º 1
0
int settings_handler(lion_t *handle, void *user_data,
					 int status, int size, char *line)
{

	switch(status) {

	case LION_FILE_OPEN:
		debugf("settings: reading settings file...\n");
		break;


	case LION_FILE_FAILED:
	case LION_FILE_CLOSED:
		debugf("settings: finished reading settings.\n");
		settings_initialising = 0;
		break;

	case LION_INPUT:
		//debugf("settings: read '%s'\n", line);

		parser_command(settings_command_list, line, NULL);

		break;

	}

	return 0;

}
Exemplo n.º 2
0
int conf_file_handler(lion_t *handle, void *user_data,
					  int status, int size, char *line)
{

	switch(status) {

	case LION_FILE_OPEN:
		break;


	case LION_FILE_FAILED:
	case LION_FILE_CLOSED:
		do_exit = 1;
		break;

	case LION_INPUT:
		//printf("settings: read '%s'\n", line);

		parser_command(conf_command_list, line, user_data);

		break;

	}

	return 0;

}
Exemplo n.º 3
0
int sites_handler(lion_t *handle, void *user_data,
				  int status, int size, char *line)
{

	switch(status) {

	case LION_FILE_OPEN:
		debugf("sites: reading sites file...\n");
		break;


	case LION_FILE_FAILED:
	case LION_FILE_CLOSED:
		debugf("sites: finished reading sites.\n");
		sites_file = NULL;
		break;

	case LION_INPUT: // un-encrypted
		//debugf("sites: read '%s'\n", line);
		parser_command(sites_command_list, line, NULL);

		break;

	case LION_BINARY: // Shouldn't happen
		break;


	}

	return 0;

}
Exemplo n.º 4
0
int site_handler(lion_t *handle, void *user_data,
				 int status, int size, char *line)
{
	fxpone_t *fxpone = (fxpone_t *)user_data;

	switch(status) {

	case LION_CONNECTION_CONNECTED:
		debugf("connected to FXP.One\n");
        connected = 1;
		break;

	case LION_CONNECTION_LOST:
		printf("Failed to connect to FXP.One: %d\n", size);
		//do_exit=1;
        connected = 0;
		if (fxpone)
			fxpone->handle = NULL;
		break;

	case LION_CONNECTION_CLOSED:
		printf("Connection closed to FXP.One\n");
        // We attempt reconnects with clomps-irc
		//do_exit=1;
        connected = 0;
		if (fxpone)
			fxpone->handle = NULL;
		break;

	case LION_CONNECTION_SECURE_ENABLED:
		debugf("successfully negotiated SSL\n");
		send_auth(fxpone);
		break;

	case LION_CONNECTION_SECURE_FAILED:
		printf("SSL negotiation failed\n");
		do_exit=1;
		if (fxpone)
			fxpone->handle = NULL;
		break;

	case LION_INPUT:
		//debugf("FXP.One: %s\n", line);
		parser_command(site_command_list, line, (void *)fxpone);
	}

	return 0;

}
Exemplo n.º 5
0
void writing_command(int fds,char* name_prog){
	if(!fork()){
  		creat("res/tmp.txt",0666);
  		int fdout = open("res/tmp.txt",O_WRONLY);
  		dup2(fdout,1);
    	execlp("strace","strace","-f","-e",TRACE_FORK,"-o","res/lala",name_prog, NULL);
  	}
  	else{
    	FILE* buffer = fopen("res/lala", "r");
    	char* buf=NULL;
    	char *line = malloc(MAX_LINE*sizeof(char));
    	action *action;
    	size_t len=0;
    	int got = 0;
    	creat("res/resultat.txt",0666);
    	creat("res/CLE1.txt",0666);
    	int fd = open("res/resultat.txt",O_WRONLY);
    	int fd1 = open("res/CLE1.txt",O_WRONLY);
    	while((got=getline(&buf, &len, buffer))!=-1){
			printf("Nouvelle ecriture niveau 1\n");
			write(fd,buf,got);
			action = parser_command(buf);
			sprintf(line,"%d/%d/%s/%d/%d/%d/%d/%s\n",action->begin,action->pid_father,action->call,action->wait,action->pid_son,action->end,action->fd,action->message);
			write(fd1,line,strlen(line));
			write(fds,line,strlen(line));
			free_action(action);
			if(global_data->state == RUN)
				usleep((MAX_SPEED-global_data->speed)*10000);
		}
		
    	printf("Fin niveau 1\n");
    	free(line);
    	free(buf);
    	close(fd);
  	}
  	//wait(NULL);
}