예제 #1
0
파일: log.c 프로젝트: bschwab/acidblood
void init_log()
{
	if ((fp_log = fopen(LOG, "a")) == NULL) {
		fprintf(stderr, "Cannot open log file %s\n", LOG);
		acid_shutdown(-1);
	}
#ifdef DEBUG
	if ((fp_debug = fopen(DEBUGLOG, "a")) == NULL) {
		fprintf(stderr, "Cannot open debug file %s\n", DEBUGLOG);
		acid_shutdown(-1);
	}
#endif
}
예제 #2
0
파일: main.c 프로젝트: bschwab/acidblood
int main(int UNUSED(argc), char * UNUSED(argv[]))
{
	if ((botinfo = malloc(sizeof(struct botstruct))) == NULL) {
		fprintf(stderr, "main: Malloc error!\n");
		acid_shutdown(-1);
	}
	
	time(&currtime);
	time(&botinfo->starttime);

	startup();

	if(botinfo->ver == NULL) {
		botinfo->ver = malloc(50) ;
		snprintf(botinfo->ver, 50, "Acidblood %s\n",VERSION) ;
	}

	/* load user data */
	if ((read_user_data()) < 0) {
		fprintf(stderr, "Error reading in user file.\n");
		acid_shutdown(-1);
	}
	
	background() ;

	while (1) {
		
		time(&currtime);

		CheckConfServers() ;
	
		check_connections();
		
		CheckTimers() ;
		
		ReapUserList();

	}
}
예제 #3
0
파일: system.c 프로젝트: bschwab/acidblood
void background() 
{
	FILE *fp_pid;
	pid_t pid, sid ;
	
	if ((pid = fork())==-1) {
		printf("shutting down: unable to fork\n") ;
		info_log("shutting down: unable to fork\n") ;
		acid_shutdown(-1);
	}
	
	/* return if we are the parent */
	if(pid!=0) {
		exit(0) ;
	}
	
	if ((fp_pid = fopen(PIDFILE, "w")) == NULL) {
		info_log("Cannot open pid file.\n");
		fclose(fp_pid);
		acid_shutdown(-1);
	}	
	
	fprintf(fp_pid, "%d", getpid());
	fclose(fp_pid);	
	
	sid=setsid() ;
	
	if (sid == -1) {
		info_log("unable to set session id\n") ;
		acid_shutdown(-1);
	}
	
	close(STDIN_FILENO) ;
	close(STDOUT_FILENO) ;
        close(STDERR_FILENO) ; 
}
예제 #4
0
static int msg_shutdown(const char *replyto, struct userlist *user, const char * UNUSED(data))
{
	info_log("Shutdown by %s\n", user->userinfo->nick);
	msgreply(user, replyto, "Bacia il mio fondoschiena metallico!!!");

	//msgreply(user, replyto, "Shutting down");
	
	irc_sprintf(user->userinfo->server->sinfo, "QUIT :Shutdown requested by %s\n",user->userinfo->nick);

	sleep(3);
	acid_shutdown(0);
	
	/* needed to shut the compilor up */
	return(0);
}