Qt: adapt the UI for correct spatializer values
[vlc.git] / bin / cachegen.c
blob383b05e878e1295cf4de7090601add43033da47b
1 /*****************************************************************************
2 * cachegen.c: LibVLC plugins cache generator
3 *****************************************************************************
4 * Copyright (C) 2010 RĂ©mi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <vlc/vlc.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <stdbool.h>
30 #ifdef HAVE_GETOPT_H
31 # include <getopt.h>
32 #endif
34 static void version (void)
36 puts ("LibVLC plugins cache generation version "VERSION);
39 static void usage (const char *path)
41 printf (
42 "Usage: %s [-f] <path>\n"
43 "Generate the LibVLC plugins cache for the specified plugins directory.\n"
44 " -f, --force forcefully reset the plugin cache (if it exists)\n",
45 path);
48 int main (int argc, char *argv[])
50 static const struct option opts[] =
52 { "force", no_argument, NULL, 'f' },
53 { "help", no_argument, NULL, 'h' },
54 { "version", no_argument, NULL, 'V' },
55 { NULL, no_argument, NULL, '\0'}
58 int c;
59 bool force = false;
61 while ((c = getopt_long (argc, argv, "fhV", opts, NULL)) != -1)
62 switch (c)
64 case 'f':
65 force = true;
66 break;
67 case 'h':
68 usage (argv[0]);
69 return 0;
70 case 'V':
71 version ();
72 return 0;
73 default:
74 usage (argv[0]);
75 return 1;
78 for (int i = optind; i < argc; i++)
80 const char *path = argv[i];
82 if (setenv ("VLC_PLUGIN_PATH", path, 1))
83 abort ();
85 const char *vlc_argv[4];
86 int vlc_argc = 0;
88 vlc_argv[vlc_argc++] = "--quiet";
89 if (force)
90 vlc_argv[vlc_argc++] = "--reset-plugins-cache";
91 vlc_argv[vlc_argc++] = "--"; /* end of options */
92 vlc_argv[vlc_argc] = NULL;
94 libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv);
95 if (vlc != NULL)
96 libvlc_release (vlc);
97 if (vlc == NULL)
98 fprintf (stderr, "No plugins in %s\n", path);
99 if (vlc == NULL)
100 return 1;
103 return 0;