Exemple #1
0
void conf_time(char *timefile)
{
	lion_t *conf_file = NULL;
    char *tmp, *r;

    if (!timefile) {
        tmp = misc_strjoin(conf_file_name, "timestamp");
        if ((r = strrchr(tmp, '/'))) *r = '.';
        conf_file = lion_open(tmp, O_RDONLY, 0600,
                              LION_FLAG_NONE, NULL);
        SAFE_FREE(tmp);
    } else {
        conf_file = lion_open(timefile, O_RDONLY, 0600,
                              LION_FLAG_NONE, NULL);
    }

    // Not having a timestamp file is OK
	if (!conf_file) {
        return;
	}

	lion_set_handler(conf_file, conf_file_handler);

	do_exit = 0;
	while(!do_exit)
		lion_poll(0,1);
	do_exit = 0;

}
Exemple #2
0
void conf_read(void)
{
	lion_t *conf_file;

	conf_file = lion_open(conf_file_name, O_RDONLY, 0600,
						  LION_FLAG_NONE, NULL);

	if (!conf_file) {
		perror("open:");
		exit(1);
	}

	lion_set_handler(conf_file, conf_file_handler);

	do_exit = 0;
	while(!do_exit)
		lion_poll(0,1);
	do_exit = 0;

}
Exemple #3
0
int main(int argc, char **argv)
{
	void *listen = NULL;


	signal(SIGINT, exit_interrupt);
#ifndef WIN32
	signal(SIGHUP, exit_interrupt);
#endif



	printf("Initialising Network...\n");

	lion_init();
	lion_compress_level( 0 );

	printf("Network Initialised.\n");



	// Create an initial game
		
	printf("Initialising Socket...\n");


	listen = lion_listen(&server_port, 0, 0, NULL);


	if (!listen) {
		
		printf("Socket Failed...\n");
		master_switch = 1;
		
	}
	
	
	printf("Listening on port %d...\n", server_port);


	printf("Initialising libdirlist...\n");

	if (dirlist_init(1)) {

		printf("libdirlist failed...\n");
		master_switch = 1;

	}



	while( !master_switch ) {

		// If you are using rate calls, you should sleep for 1s or less.
		lion_poll(0, 1);     // This blocks. (by choice, FYI).
		//printf("main\n");
	}
	printf("\n");

	
	printf("Releasing libdirlist...\n");

	dirlist_free();


	printf("Releasing Socket...\n");
	if (listen) {
		lion_disconnect(listen);
		listen = NULL;
	}
	printf("Socket Released.\n");


	lion_free();

	printf("Network Released.\n");

	printf("Done\n");

	return 0; // Avoid warning

}
Exemple #4
0
int main( int argc, char **argv )
{

	// Read any command line arguments from our friend the user.
	arguments(argc, argv);

	// Catch some signals so can exit cleanly

	signal(SIGINT, exit_interrupt);
#ifndef WIN32
	signal(SIGHUP,  exit_interrupt);
	signal(SIGTERM, exit_interrupt);
	signal(SIGPIPE, SIG_IGN);
    if (debug_on)
        setvbuf(stdout, NULL, _IONBF, 0);
#endif

	printf("%s - Jorgen Lundman v%s %s %s\n\n",
		argv ? argv[0] : "llink",
		   VERSION,
		   VERSION_STRING,
#if WITH_DVDREAD
		   "(libdvdread)"
#else

#if HAVE_CLINKC
		   "(libdvdnav, ClinkC)"
#else
		   "(libdvdnav)"
#endif
#endif
		   );


	lion_buffersize(conf_buffersize);
	//lion_buffersize(2352);

	if (lion_init()) {
		printf("Failed to initialize lion/networking\n");
		exit(-1);
	}

	debugf("\n");

	// Read configuration file, if any
	// Warning, calls lion_poll until done.
	conf_init();

	debugf("[main] initialising...\n");

	// Warning, calls lion_poll until done.
	mime_init();

	// Warning, calls lion_poll until done.
	skin_init();

	ssdp_init();

	httpd_init();

	request_init();

	root_init();

	llrar_init();

	visited_init();

	cgicmd_init();

#ifdef EXTERNAL
	external_init();
#endif

	printf("[main] ready!\n");

	// Background?
#ifndef WIN32
	if (!foreground) {
		if (fork()) exit(0);
		setsid();

        if (conf_pidfile) {
            FILE *fd;
            if ((fd = fopen(conf_pidfile, "w"))) {
                fprintf(fd, "%u\r\n", getpid());
                fclose(fd);
            }
        }
	}
#endif

    cupnp_init();


	// Scan for media
	if (conf_xmlscan) {
		signal(SIGINT, SIG_DFL);
		xmlscan_run();
		do_exit = 1;
	}


	query_init();

#ifdef WIN32
	SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
#endif

	// The main loop
	while ( !do_exit ) {

        // Was 250,0 - we should probably let users control this in
        // conf settings.
		if (lion_poll(0, 1)<0) do_exit=1;

		request_events();

#ifdef EXTERNAL
		external_resume();
#endif

	}

	printf("\n[main] releasing resources...\n");

	query_free();

    cupnp_free();

#ifdef EXTERNAL
	external_free();
#endif

	root_free();

	cgicmd_free();

	visited_free();

	llrar_free();

	request_free();

	httpd_free();

	ssdp_free();

	skin_free();

	mime_free();

	conf_free();

#ifndef WIN32  // Crashed when releasing spawned processes, until i can fix:
	lion_free();
#endif

	debugf("[main] done.\n");

	return 0;

}
Exemple #5
0
int main(int argc, char **argv)
{

	signal(SIGINT, exit_interrupt);
#ifndef WIN32
	signal(SIGHUP, exit_interrupt);
#endif



	printf("Initialising Network...\n");

	lion_init();
	lion_compress_level( 0 );

	printf("Network Initialised.\n");



	// Create an initial game
		
	printf("Initialising Socket...\n");



	listenx = lion_listen(&server_port, 0, 0, NULL);


	if (!listenx) {
		
		printf("Socket Failed...\n");
		master_switch = 1;
		
	}
	
	
	printf("Listening on port %d...\n", server_port);



	while( !master_switch ) {

		lion_poll(0, 1);     // This blocks. (by choice, FYI).

	}
	printf("\n");


	printf("Releasing Socket...\n");
	if (listenx) {
		lion_disconnect(listenx);
		listenx = NULL;
	}
	printf("Socket Released.\n");


	lion_free();

	printf("Network Released.\n");

	printf("Done\n");

	return 0; // Avoid warning

}