]> git.sesse.net Git - vlc/blobdiff - bin/cachegen.c
direct3d11: support more pixel formats
[vlc] / bin / cachegen.c
index b10270b64e8ae21c148280df95d293b2cbd81ba0..8e72bf40b27d9638ee9284b49506e2e81788ce21 100644 (file)
 #include <vlc/vlc.h>
 #include <stdio.h>
 #include <stdlib.h>
-
-#ifdef HAVE_SETLOCALE
-# include <locale.h>
-#endif
-
+#include <stdbool.h>
 #ifdef HAVE_GETOPT_H
 # include <getopt.h>
 #endif
+#ifdef WIN32
+# include <windows.h>
+#endif
 
 static void version (void)
 {
@@ -41,32 +40,35 @@ static void version (void)
 
 static void usage (const char *path)
 {
-    printf ("Usage: %s <path>\n"
-            "Generate the LibVLC plugins cache "
-            "for the specified plugins directory.\n", path);
+    printf (
+"Usage: %s [-f] <path>\n"
+"Generate the LibVLC plugins cache for the specified plugins directory.\n"
+" -f, --force  forcefully reset the plugin cache (if it exists)\n",
+            path);
 }
 
-/* Explicit HACK */
-extern void LocaleFree (const char *);
-extern char *FromLocale (const char *);
-
 int main (int argc, char *argv[])
 {
+#ifdef WIN32
+    SetErrorMode(SEM_FAILCRITICALERRORS);
+#endif
     static const struct option opts[] =
     {
+        { "force",      no_argument,       NULL, 'f' },
         { "help",       no_argument,       NULL, 'h' },
         { "version",    no_argument,       NULL, 'V' },
         { NULL,         no_argument,       NULL, '\0'}
     };
 
-#ifdef HAVE_SETLOCALE
-    setlocale (LC_CTYPE, ""); /* needed by FromLocale() */
-#endif
-
     int c;
-    while ((c = getopt_long (argc, argv, "hV", opts, NULL)) != -1)
+    bool force = false;
+
+    while ((c = getopt_long (argc, argv, "fhV", opts, NULL)) != -1)
         switch (c)
         {
+            case 'f':
+                force = true;
+                break;
             case 'h':
                 usage (argv[0]);
                 return 0;
@@ -80,32 +82,25 @@ int main (int argc, char *argv[])
 
     for (int i = optind; i < argc; i++)
     {
-        /* Note that FromLocale() can be used before libvlc is initialized */
-        const char *path = FromLocale (argv[i]);
-        char *arg;
+        const char *path = argv[i];
 
-        if (asprintf (&arg, "--plugin-path=%s", path) == -1)
+        if (setenv ("VLC_PLUGIN_PATH", path, 1))
             abort ();
 
-        const char *const vlc_argv[] = {
-            "--ignore-config",
-            "--quiet",
-            "--no-media-library",
-            arg,
-            NULL,
-        };
-        size_t vlc_argc = sizeof (vlc_argv) / sizeof (vlc_argv[0]) - 1;
+        const char *vlc_argv[4];
+        int vlc_argc = 0;
 
-        libvlc_exception_t ex;
-        libvlc_exception_init (&ex);
+        vlc_argv[vlc_argc++] = "--quiet";
+        if (force)
+            vlc_argv[vlc_argc++] = "--reset-plugins-cache";
+        vlc_argv[vlc_argc++] = "--"; /* end of options */
+        vlc_argv[vlc_argc] = NULL;
 
-        libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv, &ex);
+        libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv);
         if (vlc != NULL)
             libvlc_release (vlc);
-        free (arg);
         if (vlc == NULL)
             fprintf (stderr, "No plugins in %s\n", path);
-        LocaleFree (path);
         if (vlc == NULL)
             return 1;
     }