]> git.sesse.net Git - vlc/blob - src/config/core.c
Remove unused parameter
[vlc] / src / config / core.c
1 /*****************************************************************************
2  * core.c management of the modules configuration
3  *****************************************************************************
4  * Copyright (C) 2001-2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
27
28 #include <vlc/vlc.h>
29 #include "../libvlc.h"
30 #include "vlc_keys.h"
31 #include "vlc_charset.h"
32 #include "vlc_configuration.h"
33
34 #include <errno.h>                                                  /* errno */
35 #include <assert.h>
36 #include <limits.h>
37
38 #ifdef HAVE_UNISTD_H
39 #    include <unistd.h>                                          /* getuid() */
40 #endif
41
42 #if defined(HAVE_GETPWUID)
43 #   include <pwd.h>                                            /* getpwuid() */
44 #endif
45
46 #if defined( HAVE_SYS_STAT_H )
47 #   include <sys/stat.h>
48 #endif
49 #if defined( HAVE_SYS_TYPES_H )
50 #   include <sys/types.h>
51 #endif
52 #if defined( WIN32 )
53 #   if !defined( UNDER_CE )
54 #       include <direct.h>
55 #   endif
56 #include <tchar.h>
57 #endif
58
59 #include "configuration.h"
60 #include "modules/modules.h"
61
62 static inline char *strdupnull (const char *src)
63 {
64     return src ? strdup (src) : NULL;
65 }
66
67 /* Item types that use a string value (i.e. serialized in the module cache) */
68 int IsConfigStringType (int type)
69 {
70     static const unsigned char config_types[] =
71     {
72         CONFIG_ITEM_STRING, CONFIG_ITEM_FILE, CONFIG_ITEM_MODULE,
73         CONFIG_ITEM_DIRECTORY, CONFIG_ITEM_MODULE_CAT, CONFIG_ITEM_PASSWORD,
74         CONFIG_ITEM_MODULE_LIST, CONFIG_ITEM_MODULE_LIST_CAT
75     };
76
77     /* NOTE: this needs to be changed if we ever get more than 255 types */
78     return memchr (config_types, type, sizeof (config_types)) != NULL;
79 }
80
81
82 int IsConfigIntegerType (int type)
83 {
84     static const unsigned char config_types[] =
85     {
86         CONFIG_ITEM_INTEGER, CONFIG_ITEM_KEY, CONFIG_ITEM_BOOL,
87         CONFIG_CATEGORY, CONFIG_SUBCATEGORY
88     };
89
90     return memchr (config_types, type, sizeof (config_types)) != NULL;
91 }
92
93
94 /*****************************************************************************
95  * config_GetType: get the type of a variable (bool, int, float, string)
96  *****************************************************************************
97  * This function is used to get the type of a variable from its name.
98  * Beware, this is quite slow.
99  *****************************************************************************/
100 int __config_GetType( vlc_object_t *p_this, const char *psz_name )
101 {
102     module_config_t *p_config;
103     int i_type;
104
105     p_config = config_FindConfig( p_this, psz_name );
106
107     /* sanity checks */
108     if( !p_config )
109     {
110         return 0;
111     }
112
113     switch( p_config->i_type )
114     {
115     case CONFIG_ITEM_BOOL:
116         i_type = VLC_VAR_BOOL;
117         break;
118
119     case CONFIG_ITEM_INTEGER:
120     case CONFIG_ITEM_KEY:
121         i_type = VLC_VAR_INTEGER;
122         break;
123
124     case CONFIG_ITEM_FLOAT:
125         i_type = VLC_VAR_FLOAT;
126         break;
127
128     case CONFIG_ITEM_MODULE:
129     case CONFIG_ITEM_MODULE_CAT:
130     case CONFIG_ITEM_MODULE_LIST:
131     case CONFIG_ITEM_MODULE_LIST_CAT:
132         i_type = VLC_VAR_MODULE;
133         break;
134
135     case CONFIG_ITEM_STRING:
136         i_type = VLC_VAR_STRING;
137         break;
138
139     case CONFIG_ITEM_PASSWORD:
140         i_type = VLC_VAR_STRING;
141         break;
142
143     case CONFIG_ITEM_FILE:
144         i_type = VLC_VAR_FILE;
145         break;
146
147     case CONFIG_ITEM_DIRECTORY:
148         i_type = VLC_VAR_DIRECTORY;
149         break;
150
151     default:
152         i_type = 0;
153         break;
154     }
155
156     return i_type;
157 }
158
159 /*****************************************************************************
160  * config_GetInt: get the value of an int variable
161  *****************************************************************************
162  * This function is used to get the value of variables which are internally
163  * represented by an integer (CONFIG_ITEM_INTEGER and
164  * CONFIG_ITEM_BOOL).
165  *****************************************************************************/
166 int __config_GetInt( vlc_object_t *p_this, const char *psz_name )
167 {
168     module_config_t *p_config;
169
170     p_config = config_FindConfig( p_this, psz_name );
171
172     /* sanity checks */
173     if( !p_config )
174     {
175         msg_Err( p_this, "option %s does not exist", psz_name );
176         return -1;
177     }
178
179     if (!IsConfigIntegerType (p_config->i_type))
180     {
181         msg_Err( p_this, "option %s does not refer to an int", psz_name );
182         return -1;
183     }
184
185     return p_config->value.i;
186 }
187
188 /*****************************************************************************
189  * config_GetFloat: get the value of a float variable
190  *****************************************************************************
191  * This function is used to get the value of variables which are internally
192  * represented by a float (CONFIG_ITEM_FLOAT).
193  *****************************************************************************/
194 float __config_GetFloat( vlc_object_t *p_this, const char *psz_name )
195 {
196     module_config_t *p_config;
197
198     p_config = config_FindConfig( p_this, psz_name );
199
200     /* sanity checks */
201     if( !p_config )
202     {
203         msg_Err( p_this, "option %s does not exist", psz_name );
204         return -1;
205     }
206
207     if (!IsConfigFloatType (p_config->i_type))
208     {
209         msg_Err( p_this, "option %s does not refer to a float", psz_name );
210         return -1;
211     }
212
213     return p_config->value.f;
214 }
215
216 /*****************************************************************************
217  * config_GetPsz: get the string value of a string variable
218  *****************************************************************************
219  * This function is used to get the value of variables which are internally
220  * represented by a string (CONFIG_ITEM_STRING, CONFIG_ITEM_FILE,
221  * CONFIG_ITEM_DIRECTORY, CONFIG_ITEM_PASSWORD, and CONFIG_ITEM_MODULE).
222  *
223  * Important note: remember to free() the returned char* because it's a
224  *   duplicate of the actual value. It isn't safe to return a pointer to the
225  *   actual value as it can be modified at any time.
226  *****************************************************************************/
227 char * __config_GetPsz( vlc_object_t *p_this, const char *psz_name )
228 {
229     module_config_t *p_config;
230
231     p_config = config_FindConfig( p_this, psz_name );
232
233     /* sanity checks */
234     if( !p_config )
235     {
236         msg_Err( p_this, "option %s does not exist", psz_name );
237         return NULL;
238     }
239
240     if (!IsConfigStringType (p_config->i_type))
241     {
242         msg_Err( p_this, "option %s does not refer to a string", psz_name );
243         return NULL;
244     }
245
246     /* return a copy of the string */
247     vlc_mutex_lock( p_config->p_lock );
248     char *psz_value = strdupnull (p_config->value.psz);
249     vlc_mutex_unlock( p_config->p_lock );
250
251     return psz_value;
252 }
253
254 /*****************************************************************************
255  * config_PutPsz: set the string value of a string variable
256  *****************************************************************************
257  * This function is used to set the value of variables which are internally
258  * represented by a string (CONFIG_ITEM_STRING, CONFIG_ITEM_FILE,
259  * CONFIG_ITEM_DIRECTORY, CONFIG_ITEM_PASSWORD, and CONFIG_ITEM_MODULE).
260  *****************************************************************************/
261 void __config_PutPsz( vlc_object_t *p_this,
262                       const char *psz_name, const char *psz_value )
263 {
264     module_config_t *p_config;
265     vlc_value_t oldval, val;
266
267     p_config = config_FindConfig( p_this, psz_name );
268
269
270     /* sanity checks */
271     if( !p_config )
272     {
273         msg_Warn( p_this, "option %s does not exist", psz_name );
274         return;
275     }
276
277     if (!IsConfigStringType (p_config->i_type))
278     {
279         msg_Err( p_this, "option %s does not refer to a string", psz_name );
280         return;
281     }
282
283     vlc_mutex_lock( p_config->p_lock );
284
285     /* backup old value */
286     oldval.psz_string = (char *)p_config->value.psz;
287
288     if ((psz_value != NULL) && *psz_value)
289         p_config->value.psz = strdup (psz_value);
290     else
291         p_config->value.psz = NULL;
292
293     p_config->b_dirty = true;
294
295     val.psz_string = (char *)p_config->value.psz;
296
297     vlc_mutex_unlock( p_config->p_lock );
298
299     if( p_config->pf_callback )
300     {
301         p_config->pf_callback( p_this, psz_name, oldval, val,
302                                p_config->p_callback_data );
303     }
304
305     /* free old string */
306     free( oldval.psz_string );
307 }
308
309 /*****************************************************************************
310  * config_PutInt: set the integer value of an int variable
311  *****************************************************************************
312  * This function is used to set the value of variables which are internally
313  * represented by an integer (CONFIG_ITEM_INTEGER and
314  * CONFIG_ITEM_BOOL).
315  *****************************************************************************/
316 void __config_PutInt( vlc_object_t *p_this, const char *psz_name, int i_value )
317 {
318     module_config_t *p_config;
319     vlc_value_t oldval, val;
320
321     p_config = config_FindConfig( p_this, psz_name );
322
323     /* sanity checks */
324     if( !p_config )
325     {
326         msg_Warn( p_this, "option %s does not exist", psz_name );
327         return;
328     }
329
330     if (!IsConfigIntegerType (p_config->i_type))
331     {
332         msg_Err( p_this, "option %s does not refer to an int", psz_name );
333         return;
334     }
335
336     /* backup old value */
337     oldval.i_int = p_config->value.i;
338
339     /* if i_min == i_max == 0, then do not use them */
340     if ((p_config->min.i == 0) && (p_config->max.i == 0))
341     {
342         p_config->value.i = i_value;
343     }
344     else if (i_value < p_config->min.i)
345     {
346         p_config->value.i = p_config->min.i;
347     }
348     else if (i_value > p_config->max.i)
349     {
350         p_config->value.i = p_config->max.i;
351     }
352     else
353     {
354         p_config->value.i = i_value;
355     }
356
357     p_config->b_dirty = true;
358
359     val.i_int = p_config->value.i;
360
361     if( p_config->pf_callback )
362     {
363         p_config->pf_callback( p_this, psz_name, oldval, val,
364                                p_config->p_callback_data );
365     }
366 }
367
368 /*****************************************************************************
369  * config_PutFloat: set the value of a float variable
370  *****************************************************************************
371  * This function is used to set the value of variables which are internally
372  * represented by a float (CONFIG_ITEM_FLOAT).
373  *****************************************************************************/
374 void __config_PutFloat( vlc_object_t *p_this,
375                         const char *psz_name, float f_value )
376 {
377     module_config_t *p_config;
378     vlc_value_t oldval, val;
379
380     p_config = config_FindConfig( p_this, psz_name );
381
382     /* sanity checks */
383     if( !p_config )
384     {
385         msg_Warn( p_this, "option %s does not exist", psz_name );
386         return;
387     }
388
389     if (!IsConfigFloatType (p_config->i_type))
390     {
391         msg_Err( p_this, "option %s does not refer to a float", psz_name );
392         return;
393     }
394
395     /* backup old value */
396     oldval.f_float = p_config->value.f;
397
398     /* if f_min == f_max == 0, then do not use them */
399     if ((p_config->min.f == 0) && (p_config->max.f == 0))
400     {
401         p_config->value.f = f_value;
402     }
403     else if (f_value < p_config->min.f)
404     {
405         p_config->value.f = p_config->min.f;
406     }
407     else if (f_value > p_config->max.f)
408     {
409         p_config->value.f = p_config->max.f;
410     }
411     else
412     {
413         p_config->value.f = f_value;
414     }
415
416     p_config->b_dirty = true;
417
418     val.f_float = p_config->value.f;
419
420     if( p_config->pf_callback )
421     {
422         p_config->pf_callback( p_this, psz_name, oldval, val,
423                                p_config->p_callback_data );
424     }
425 }
426
427 /*****************************************************************************
428  * config_FindConfig: find the config structure associated with an option.
429  *****************************************************************************
430  * FIXME: This function really needs to be optimized.
431  * FIXME: And now even more.
432  *****************************************************************************/
433 module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name )
434 {
435     vlc_list_t *p_list;
436     int i_index;
437
438     if( !psz_name ) return NULL;
439
440     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
441
442     for( i_index = 0; i_index < p_list->i_count; i_index++ )
443     {
444         module_config_t *p_item, *p_end;
445         module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object;
446
447         if( !p_parser->i_config_items )
448             continue;
449
450         for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
451              p_item < p_end;
452              p_item++ )
453         {
454             if( p_item->i_type & CONFIG_HINT )
455                 /* ignore hints */
456                 continue;
457             if( !strcmp( psz_name, p_item->psz_name )
458              || ( p_item->psz_oldname
459               && !strcmp( psz_name, p_item->psz_oldname ) ) )
460             {
461                 vlc_list_release( p_list );
462                 return p_item;
463             }
464         }
465     }
466
467     vlc_list_release( p_list );
468
469     return NULL;
470 }
471
472 /*****************************************************************************
473  * config_Free: frees a duplicated module's configuration data.
474  *****************************************************************************
475  * This function frees all the data duplicated by config_Duplicate.
476  *****************************************************************************/
477 void config_Free( module_t *p_module )
478 {
479     int i;
480
481     for (size_t j = 0; j < p_module->confsize; j++)
482     {
483         module_config_t *p_item = p_module->p_config + j;
484
485         free( p_item->psz_type );
486         free( p_item->psz_name );
487         free( p_item->psz_text );
488         free( p_item->psz_longtext );
489         free( p_item->psz_oldname );
490
491         if (IsConfigStringType (p_item->i_type))
492         {
493             free (p_item->value.psz);
494             free (p_item->orig.psz);
495             free (p_item->saved.psz);
496         }
497
498         if( p_item->ppsz_list )
499             for( i = 0; i < p_item->i_list; i++ )
500                 free( p_item->ppsz_list[i] );
501         if( p_item->ppsz_list_text )
502             for( i = 0; i < p_item->i_list; i++ )
503                 free( p_item->ppsz_list_text[i] );
504         free( p_item->ppsz_list );
505         free( p_item->ppsz_list_text );
506         free( p_item->pi_list );
507
508         if( p_item->i_action )
509         {
510             for( i = 0; i < p_item->i_action; i++ )
511             {
512                 free( p_item->ppsz_action_text[i] );
513             }
514             free( p_item->ppf_action );
515             free( p_item->ppsz_action_text );
516         }
517     }
518
519     free (p_module->p_config);
520     p_module->p_config = NULL;
521 }
522
523 /*****************************************************************************
524  * config_SetCallbacks: sets callback functions in the duplicate p_config.
525  *****************************************************************************
526  * Unfortunatly we cannot work directly with the module's config data as
527  * this module might be unloaded from memory at any time (remember HideModule).
528  * This is why we need to duplicate callbacks each time we reload the module.
529  *****************************************************************************/
530 void config_SetCallbacks( module_config_t *p_new, module_config_t *p_orig,
531                           size_t n )
532 {
533     for (size_t i = 0; i < n; i++)
534     {
535         p_new->pf_callback = p_orig->pf_callback;
536         p_new++;
537         p_orig++;
538     }
539 }
540
541 /*****************************************************************************
542  * config_UnsetCallbacks: unsets callback functions in the duplicate p_config.
543  *****************************************************************************
544  * We simply undo what we did in config_SetCallbacks.
545  *****************************************************************************/
546 void config_UnsetCallbacks( module_config_t *p_new, size_t n )
547 {
548     for (size_t i = 0; i < n; i++)
549     {
550         p_new->pf_callback = NULL;
551         p_new++;
552     }
553 }
554
555 /*****************************************************************************
556  * config_ResetAll: reset the configuration data for all the modules.
557  *****************************************************************************/
558 void __config_ResetAll( vlc_object_t *p_this )
559 {
560     libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
561     int i_index;
562     vlc_list_t *p_list;
563     module_t *p_module;
564
565     /* Acquire config file lock */
566     vlc_mutex_lock( &priv->config_lock );
567
568     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
569
570     for( i_index = 0; i_index < p_list->i_count; i_index++ )
571     {
572         p_module = (module_t *)p_list->p_values[i_index].p_object ;
573         if( p_module->b_submodule ) continue;
574
575         for (size_t i = 0; i < p_module->confsize; i++ )
576         {
577             if (IsConfigIntegerType (p_module->p_config[i].i_type))
578                 p_module->p_config[i].value.i = p_module->p_config[i].orig.i;
579             else
580             if (IsConfigFloatType (p_module->p_config[i].i_type))
581                 p_module->p_config[i].value.f = p_module->p_config[i].orig.f;
582             else
583             if (IsConfigStringType (p_module->p_config[i].i_type))
584             {
585                 free ((char *)p_module->p_config[i].value.psz);
586                 p_module->p_config[i].value.psz =
587                         strdupnull (p_module->p_config[i].orig.psz);
588             }
589         }
590     }
591
592     vlc_list_release( p_list );
593     vlc_mutex_unlock( &priv->config_lock );
594 }
595
596 /**
597  * config_GetDataDir: find directory where shared data is installed
598  *
599  * @return a string (always succeeds).
600  */
601 const char *config_GetDataDir( void )
602 {
603 #if defined (WIN32) || defined (UNDER_CE)
604     return vlc_global()->psz_vlcpath;
605 #elif defined(__APPLE__) || defined (SYS_BEOS)
606     static char path[PATH_MAX] = "";
607
608     if( *path == '\0' )
609     {
610         snprintf( path, sizeof( path ), "%s/share",
611                   vlc_global()->psz_vlcpath );
612         path[sizeof( path ) - 1] = '\0';
613     }
614     return path;
615 #else
616     return DATA_PATH;
617 #endif
618 }
619
620 /*****************************************************************************
621  * config_GetHomeDir, config_GetUserDir: find the user's home directory.
622  *****************************************************************************
623  * This function will try by different ways to find the user's home path.
624  * Note that this function is not reentrant, it should be called only once
625  * at the beginning of main where the result will be stored for later use.
626  *****************************************************************************/
627 static char *GetDir( bool b_appdata )
628 {
629     const char *psz_localhome = NULL;
630
631 #if defined(WIN32) && !defined(UNDER_CE)
632     typedef HRESULT (WINAPI *SHGETFOLDERPATH)( HWND, int, HANDLE, DWORD,
633                                                LPWSTR );
634 #ifndef CSIDL_FLAG_CREATE
635 #   define CSIDL_FLAG_CREATE 0x8000
636 #endif
637 #ifndef CSIDL_APPDATA
638 #   define CSIDL_APPDATA 0x1A
639 #endif
640 #ifndef CSIDL_PROFILE
641 #   define CSIDL_PROFILE 0x28
642 #endif
643 #ifndef SHGFP_TYPE_CURRENT
644 #   define SHGFP_TYPE_CURRENT 0
645 #endif
646
647     HINSTANCE shfolder_dll;
648     SHGETFOLDERPATH SHGetFolderPath ;
649
650     /* load the shfolder dll to retrieve SHGetFolderPath */
651     if( ( shfolder_dll = LoadLibrary( _T("SHFolder.dll") ) ) != NULL )
652     {
653         SHGetFolderPath = (void *)GetProcAddress( shfolder_dll,
654                                                   _T("SHGetFolderPathW") );
655         if ( SHGetFolderPath != NULL )
656         {
657             wchar_t whomedir[MAX_PATH];
658
659             /* get the "Application Data" folder for the current user */
660             if( S_OK == SHGetFolderPath( NULL,
661                                          (b_appdata ? CSIDL_APPDATA :
662                                            CSIDL_PROFILE) | CSIDL_FLAG_CREATE,
663                                          NULL, SHGFP_TYPE_CURRENT,
664                                          whomedir ) )
665             {
666                 FreeLibrary( shfolder_dll );
667                 return FromWide( whomedir );
668             }
669         }
670         FreeLibrary( shfolder_dll );
671     }
672
673 #elif defined(UNDER_CE)
674
675 #ifndef CSIDL_APPDATA
676 #   define CSIDL_APPDATA 0x1A
677 #endif
678
679     wchar_t whomedir[MAX_PATH];
680
681     /* get the "Application Data" folder for the current user */
682     if( SHGetSpecialFolderPath( NULL, whomedir, CSIDL_APPDATA, 1 ) )
683         return FromWide( whomedir );
684 #endif
685
686     psz_localhome = getenv( "HOME" );
687     if( psz_localhome == NULL )
688     {
689 #if defined(HAVE_GETPWUID)
690         struct passwd *p_pw;
691         (void)b_appdata;
692
693         if( ( p_pw = getpwuid( getuid() ) ) != NULL )
694             psz_localhome = p_pw->pw_dir;
695         else
696 #endif
697         {
698             psz_localhome = getenv( "TMP" );
699             if( psz_localhome == NULL )
700                 psz_localhome = "/tmp";
701         }
702     }
703
704     return FromLocaleDup( psz_localhome );
705 }
706
707 /**
708  * Get the user's home directory
709  */
710 char *config_GetHomeDir( void )
711 {
712     return GetDir( false );
713 }
714
715 /**
716  * Get the user's main data and config directory:
717  *   - on windows that's the App Data directory;
718  *   - on other OSes it's the same as the home directory.
719  */
720 char *config_GetUserDir( void ); /* XXX why does gcc wants a declaration ?
721                                   * --funman */
722 char *config_GetUserDir( void )
723 {
724     return GetDir( true );
725 }
726
727 static char *config_GetFooDir (const char *xdg_name, const char *xdg_default)
728 {
729     char *psz_dir;
730 #if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS)
731     char *psz_parent = config_GetUserDir();
732
733     if( asprintf( &psz_dir, "%s" DIR_SEP CONFIG_DIR, psz_parent ) == -1 )
734         psz_dir = NULL;
735
736     free (psz_parent);
737     (void)xdg_name; (void)xdg_default;
738 #else
739     char var[sizeof ("XDG__HOME") + strlen (xdg_name)], *psz_env;
740
741     /* XDG Base Directory Specification - Version 0.6 */
742     snprintf (var, sizeof (var), "XDG_%s_HOME", xdg_name);
743     psz_env = FromLocaleDup (getenv (var));
744     if( psz_env )
745     {
746         if( asprintf( &psz_dir, "%s/vlc", psz_env ) == -1 )
747             psz_dir = NULL;
748         goto out;
749     }
750
751     psz_env = FromLocaleDup (getenv ("HOME"));
752     /* not part of XDG spec but we want a sensible fallback */
753     if( !psz_env )
754         psz_env = config_GetHomeDir();
755     if( asprintf( &psz_dir, "%s/%s/vlc", psz_env, xdg_default ) == -1 )
756         psz_dir = NULL;
757
758 out:
759     free (psz_env);
760 #endif
761     return psz_dir;
762 }
763
764 /**
765  * Get the user's VLC configuration directory
766  */
767 char *config_GetConfigDir( libvlc_int_t *p_libvlc )
768 {
769     return config_GetFooDir ("CONFIG", ".config");
770 }
771
772 /**
773  * Get the user's VLC data directory
774  * (used for stuff like the skins, custom lua modules, ...)
775  */
776 char *config_GetUserDataDir( libvlc_int_t *p_libvlc )
777 {
778     return config_GetFooDir ("DATA", ".local/share");
779 }
780
781 /**
782  * Get the user's VLC cache directory
783  * (used for stuff like the modules cache, the album art cache, ...)
784  */
785 char *config_GetCacheDir( libvlc_int_t *p_libvlc )
786 {
787     return config_GetFooDir ("CACHE", ".cache");
788 }