mediadirs: display snapshots in the video widget
[vlc/asuraparaju-public.git] / bin / cachegen.c
blob8c96f08735fe2caf8fe9834254c83ff58ca5323b
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>
29 #ifdef HAVE_SETLOCALE
30 # include <locale.h>
31 #endif
33 #ifdef HAVE_GETOPT_H
34 # include <getopt.h>
35 #endif
37 static void version (void)
39 puts ("LibVLC plugins cache generation version "VERSION);
42 static void usage (const char *path)
44 printf ("Usage: %s <path>\n"
45 "Generate the LibVLC plugins cache "
46 "for the specified plugins directory.\n", path);
49 /* Explicit HACK */
50 extern void LocaleFree (const char *);
51 extern char *FromLocale (const char *);
53 int main (int argc, char *argv[])
55 static const struct option opts[] =
57 { "help", no_argument, NULL, 'h' },
58 { "version", no_argument, NULL, 'V' },
59 { NULL, no_argument, NULL, '\0'}
62 #ifdef HAVE_SETLOCALE
63 setlocale (LC_CTYPE, ""); /* needed by FromLocale() */
64 #endif
66 int c;
67 while ((c = getopt_long (argc, argv, "hV", opts, NULL)) != -1)
68 switch (c)
70 case 'h':
71 usage (argv[0]);
72 return 0;
73 case 'V':
74 version ();
75 return 0;
76 default:
77 usage (argv[0]);
78 return 1;
81 for (int i = optind; i < argc; i++)
83 /* Note that FromLocale() can be used before libvlc is initialized */
84 const char *path = FromLocale (argv[i]);
85 char *arg;
87 if (asprintf (&arg, "--plugin-path=%s", path) == -1)
88 abort ();
90 const char *const vlc_argv[] = {
91 "--ignore-config",
92 "--quiet",
93 "--no-media-library",
94 arg,
95 NULL,
97 size_t vlc_argc = sizeof (vlc_argv) / sizeof (vlc_argv[0]) - 1;
99 libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv);
100 if (vlc != NULL)
101 libvlc_release (vlc);
102 free (arg);
103 if (vlc == NULL)
104 fprintf (stderr, "No plugins in %s\n", path);
105 LocaleFree (path);
106 if (vlc == NULL)
107 return 1;
110 return 0;