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 *****************************************************************************/
38 static void version (void)
40 puts ("LibVLC plugins cache generation version "VERSION
);
43 static void usage (const char *path
)
46 "Usage: %s [-f] <path>\n"
47 "Generate the LibVLC plugins cache for the specified plugins directory.\n"
48 " -f, --force forcefully reset the plugin cache (if it exists)\n",
53 extern void LocaleFree (const char *);
54 extern char *FromLocale (const char *);
56 int main (int argc
, char *argv
[])
58 static const struct option opts
[] =
60 { "force", no_argument
, NULL
, 'f' },
61 { "help", no_argument
, NULL
, 'h' },
62 { "version", no_argument
, NULL
, 'V' },
63 { NULL
, no_argument
, NULL
, '\0'}
67 setlocale (LC_CTYPE
, ""); /* needed by FromLocale() */
73 while ((c
= getopt_long (argc
, argv
, "fhV", opts
, NULL
)) != -1)
90 for (int i
= optind
; i
< argc
; i
++)
92 /* Note that FromLocale() can be used before libvlc is initialized */
93 const char *path
= FromLocale (argv
[i
]);
95 if (setenv ("VLC_PLUGIN_PATH", path
, 1))
98 const char *vlc_argv
[4];
101 vlc_argv
[vlc_argc
++] = "--quiet";
103 vlc_argv
[vlc_argc
++] = "--reset-plugins-cache";
104 vlc_argv
[vlc_argc
++] = "--"; /* end of options */
105 vlc_argv
[vlc_argc
] = NULL
;
107 libvlc_instance_t
*vlc
= libvlc_new (vlc_argc
, vlc_argv
);
109 libvlc_release (vlc
);
111 fprintf (stderr
, "No plugins in %s\n", path
);