/*****************************************************************************
 * vlc.c: the vlc player
 *****************************************************************************
 * Copyright (C) 1998-2001 VideoLAN
 * $Id: vlc.c,v 1.7 2002/07/23 00:39:17 sam Exp $
 *
 * Authors: Vincent Seguin <seguin@via.ecp.fr>
 *          Samuel Hocevar <sam@zoy.org>
 *          Gildas Bazin <gbazin@netcourrier.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/
#include <signal.h>                               /* SIGHUP, SIGINT, SIGKILL */
#include <stdio.h>                                              /* fprintf() */
#include <stdlib.h>                                  /* putenv(), strtol(),  */

#include <vlc/vlc.h>

/*****************************************************************************
 * main: parse command line, start interface and spawn threads
 *****************************************************************************/
int main(int i_argc, char *ppsz_argv[], char *ppsz_env[])
{
    vlc_error_t err;

#ifdef SYS_LINUX
#   ifdef DEBUG
    /* Activate malloc checking routines to detect heap corruptions. */
    putenv( "MALLOC_CHECK_=2" );

    /* Disable the ugly Gnome crash dialog so that we properly segfault */
    putenv( "GNOME_DISABLE_CRASH_DIALOG=1" );
#   endif
#endif

    /* Create the vlc structure */
    err = vlc_create();
    if( err != VLC_SUCCESS )
    {
        return err;
    }

    /* Initialize vlc */
    err = vlc_init( i_argc, ppsz_argv );
    if( err != VLC_SUCCESS )
    {
        vlc_destroy();
        return err;
    }

    /* Run vlc, in non-blocking mode */
    err = vlc_run();

    /* Add background interfaces */
    //{ int i; for( i=10; i--; ) vlc_add_intf( NULL, "dummy", 0 ); }
    //vlc_add_intf( NULL, "dummy", VLC_FALSE );
    //vlc_add_intf( NULL, "logger", VLC_FALSE );
    //vlc_add_intf( NULL, "xosd", VLC_FALSE );
    //vlc_add_intf( NULL, "gtk", VLC_FALSE );
    //vlc_add_intf( NULL, "kde", VLC_FALSE );
    //vlc_add_intf( "rc", VLC_FALSE );

    /* Add a blocking interface and keep the return value */
    err = vlc_add_intf( NULL, VLC_TRUE );

    /* Finish the interface */
    vlc_stop();

    /* Finish all threads */
    vlc_end();

    /* Destroy the vlc structure */
    vlc_destroy();

    return err;
}

