]> git.sesse.net Git - vlc/blobdiff - src/control/core.c
Revert "Remove libvlc_free"
[vlc] / src / control / core.c
index 5131ab3c0b67f72737b4e22bf97cbf3e0caf3562..745c85af64a27b39ec8986d25912684ba8a73cff 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * core.c: Core libvlc new API functions : initialization, exceptions handling
+ * core.c: Core libvlc new API functions : initialization
  *****************************************************************************
  * Copyright (C) 2005 the VideoLAN team
  * $Id$
 
 static const char nomemstr[] = "Insufficient memory";
 
-/*************************************************************************
- * Exceptions handling
- *************************************************************************/
-void libvlc_exception_init( libvlc_exception_t *p_exception )
-{
-    p_exception->b_raised = 0;
-}
-
-void libvlc_exception_clear( libvlc_exception_t *p_exception )
-{
-    if( NULL == p_exception )
-        return;
-    p_exception->b_raised = 0;
-    libvlc_clearerr ();
-}
-
-int libvlc_exception_raised( const libvlc_exception_t *p_exception )
-{
-    return (NULL != p_exception) && p_exception->b_raised;
-}
-
-static void libvlc_exception_not_handled( const char *psz )
-{
-    fprintf( stderr, "*** LibVLC Exception not handled: %s\nSet a breakpoint in '%s' to debug.\n",
-             psz, __func__ );
-    abort();
-}
-
-void libvlc_exception_raise( libvlc_exception_t *p_exception )
-{
-    /* Does caller care about exceptions ? */
-    if( p_exception == NULL ) {
-        /* Print something, so that lazy third-parties can easily
-         * notice that something may have gone unnoticedly wrong */
-        libvlc_exception_not_handled( libvlc_errmsg() );
-        return;
-    }
-
-    p_exception->b_raised = 1;
-}
-
 libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
 {
     libvlc_instance_t *p_new = malloc (sizeof (*p_new));
@@ -110,6 +69,8 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
     p_new->verbosity = 1;
     p_new->p_callback_list = NULL;
     vlc_mutex_init(&p_new->instance_lock);
+    var_Create( p_libvlc_int, "http-user-agent",
+                VLC_VAR_STRING|VLC_VAR_DOINHERIT );
     return p_new;
 
 error:
@@ -155,12 +116,34 @@ int libvlc_add_intf( libvlc_instance_t *p_i, const char *name )
     return libvlc_InternalAddIntf( p_i->p_libvlc_int, name ) ? -1 : 0;
 }
 
+void libvlc_set_exit_handler( libvlc_instance_t *p_i, void (*cb) (void *),
+                              void *data )
+{
+    libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
+    libvlc_SetExitHandler( p_libvlc, cb, data );
+}
+
 void libvlc_wait( libvlc_instance_t *p_i )
 {
     libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
     libvlc_InternalWait( p_libvlc );
 }
 
+void libvlc_set_user_agent (libvlc_instance_t *p_i,
+                            const char *name, const char *http)
+{
+    libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
+    char *str;
+
+    var_SetString (p_libvlc, "user-agent", name);
+    if ((http != NULL)
+     && (asprintf (&str, "%s LibVLC/"PACKAGE_VERSION, http) != -1))
+    {
+        var_SetString (p_libvlc, "http-user-agent", str);
+        free (str);
+    }
+}
+
 const char * libvlc_get_version(void)
 {
     return VLC_Version();