8d1294d033055210b02679097b27f5115192b470
2 * miracle.c -- A DV over IEEE 1394 TCP Server
4 * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
6 * Dan Dennedy <dan@dennedy.org>
7 * Charles Yates <charles.yates@pandora.be>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 /* System header files */
28 #include <sys/types.h>
32 #include <framework/mlt.h>
34 /* Application header files */
35 #include "miracle_server.h"
36 #include "miracle_log.h"
41 static miracle_server server
= NULL
;
43 /** atexit shutdown handler for the server.
46 static void main_cleanup( )
48 miracle_server_shutdown( server
);
52 /** Report usage and exit.
55 void usage( char *app
)
57 fprintf( stderr
, "Usage: %s [-test] [-port NNNN]\n", app
);
61 /** The main function.
64 int main( int argc
, char **argv
)
69 struct timespec tm
= { 5, 0 };
71 // Construct the factory
72 mlt_factory_init( getenv( "MLT_REPOSITORY" ) );
74 server
= miracle_server_init( argv
[ 0 ] );
76 for ( index
= 1; index
< argc
; index
++ )
78 if ( !strcmp( argv
[ index
], "-port" ) )
79 miracle_server_set_port( server
, atoi( argv
[ ++ index
] ) );
80 else if ( !strcmp( argv
[ index
], "-proxy" ) )
81 miracle_server_set_proxy( server
, argv
[ ++ index
] );
82 else if ( !strcmp( argv
[ index
], "-test" ) )
88 /* Optionally detatch ourselves from the controlling tty */
95 miracle_log_init( log_syslog
, LOG_INFO
);
99 miracle_log_init( log_stderr
, LOG_DEBUG
);
102 atexit( main_cleanup
);
104 /* Execute the server */
105 error
= miracle_server_execute( server
);
107 /* We need to wait until we're exited.. */
108 while ( !server
->shutdown
)
109 nanosleep( &tm
, NULL
);