]> git.sesse.net Git - vlc/blob - src/config/file.c
config_GetConfigFile: remove unused parameter
[vlc] / src / config / file.c
1 /*****************************************************************************
2  * file.c: configuration file handling
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_charset.h"
31 #include "vlc_keys.h"
32
33 #include <errno.h>                                                  /* errno */
34 #include <assert.h>
35 #include <limits.h>
36
37 #include "configuration.h"
38 #include "modules/modules.h"
39
40 static char *ConfigKeyToString( int );
41
42 static inline char *strdupnull (const char *src)
43 {
44     return src ? strdup (src) : NULL;
45 }
46
47 /**
48  * Get the user's configuration file
49  */
50 static char *config_GetConfigFile( void )
51 {
52     char *psz_dir = config_GetUserConfDir();
53     char *psz_configfile;
54
55     if( asprintf( &psz_configfile, "%s" DIR_SEP CONFIG_FILE, psz_dir ) == -1 )
56         psz_configfile = NULL;
57     free( psz_dir );
58     return psz_configfile;
59 }
60
61 static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
62 {
63     char *psz_filename = libvlc_priv (p_obj->p_libvlc)->psz_configfile;
64     FILE *p_stream;
65
66     if( !psz_filename )
67     {
68         psz_filename = config_GetConfigFile();
69     }
70
71     msg_Dbg( p_obj, "opening config file (%s)", psz_filename );
72
73     p_stream = utf8_fopen( psz_filename, mode );
74     if( p_stream == NULL && errno != ENOENT )
75     {
76         msg_Err( p_obj, "cannot open config file (%s): %m",
77                  psz_filename );
78
79     }
80 #if !( defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS) )
81     else if( p_stream == NULL && errno == ENOENT && mode[0] == 'r' )
82     {
83         /* This is the fallback for pre XDG Base Directory
84          * Specification configs */
85         char *psz_old;
86         if( asprintf( &psz_old, "%s" DIR_SEP CONFIG_DIR DIR_SEP CONFIG_FILE,
87                   p_obj->p_libvlc->psz_homedir ) != -1 )
88         {
89             p_stream = utf8_fopen( psz_old, mode );
90             if( p_stream )
91             {
92                 /* Old config file found. We want to write it at the
93                  * new location now. */
94                 msg_Info( p_obj->p_libvlc, "Found old config file at %s. "
95                           "VLC will now use %s.", psz_old, psz_filename );
96                 char *psz_readme;
97                 if( asprintf(&psz_readme,"%s"DIR_SEP CONFIG_DIR DIR_SEP"README",
98                               p_obj->p_libvlc->psz_homedir ) != -1 )
99                 {
100                     FILE *p_readme = utf8_fopen( psz_readme, "wt" );
101                     if( p_readme )
102                     {
103                         fprintf( p_readme, "The VLC media player "
104                                  "configuration folder has moved to comply\n"
105                                  "with the XDG Base Directory Specification "
106                                  "version 0.6. Your\nconfiguration has been "
107                                  "copied to the new location:\n%s\nYou can "
108                                  "delete this directory and all its contents.",
109                                   psz_filename);
110                         fclose( p_readme );
111                     }
112                     free( psz_readme );
113                 }
114             }
115             free( psz_old );
116         }
117     }
118 #endif
119     else if( p_stream != NULL )
120     {
121         libvlc_priv (p_obj->p_libvlc)->psz_configfile = psz_filename;
122     }
123
124     return p_stream;
125 }
126
127
128 static int strtoi (const char *str)
129 {
130     char *end;
131     long l;
132
133     errno = 0;
134     l = strtol (str, &end, 0);
135
136     if (!errno)
137     {
138         if ((l > INT_MAX) || (l < INT_MIN))
139             errno = ERANGE;
140         if (*end)
141             errno = EINVAL;
142     }
143     return (int)l;
144 }
145
146
147 /*****************************************************************************
148  * config_LoadConfigFile: loads the configuration file.
149  *****************************************************************************
150  * This function is called to load the config options stored in the config
151  * file.
152  *****************************************************************************/
153 int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
154 {
155     libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
156     vlc_list_t *p_list;
157     FILE *file;
158
159     file = config_OpenConfigFile (p_this, "rt");
160     if (file == NULL)
161         return VLC_EGENERIC;
162
163     /* Acquire config file lock */
164     vlc_mutex_lock( &priv->config_lock );
165
166     /* Look for the selected module, if NULL then save everything */
167     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
168
169     /* Look for UTF-8 Byte Order Mark */
170     char * (*convert) (const char *) = strdupnull;
171     char bom[3];
172
173     if ((fread (bom, 1, 3, file) != 3)
174      || memcmp (bom, "\xEF\xBB\xBF", 3))
175     {
176         convert = FromLocaleDup;
177         rewind (file); /* no BOM, rewind */
178     }
179
180     module_t *module = NULL;
181     char line[1024], section[1022];
182     section[0] = '\0';
183
184     while (fgets (line, 1024, file) != NULL)
185     {
186         /* Ignore comments and empty lines */
187         switch (line[0])
188         {
189             case '#':
190             case '\n':
191             case '\0':
192                 continue;
193         }
194
195         if (line[0] == '[')
196         {
197             char *ptr = strchr (line, ']');
198             if (ptr == NULL)
199                 continue; /* syntax error; */
200             *ptr = '\0';
201
202             /* New section ( = a given module) */
203             strcpy (section, line + 1);
204             module = NULL;
205
206             if ((psz_module_name == NULL)
207              || (strcmp (psz_module_name, section) == 0))
208             {
209                 for (int i = 0; i < p_list->i_count; i++)
210                 {
211                     module_t *m = (module_t *)p_list->p_values[i].p_object;
212
213                     if ((strcmp (section, m->psz_object_name) == 0)
214                      && (m->i_config_items > 0)) /* ignore config-less modules */
215                     {
216                         module = m;
217                         if (psz_module_name != NULL)
218                             msg_Dbg (p_this,
219                                      "loading config for module \"%s\"",
220                                      section);
221                         break;
222                     }
223                 }
224             }
225
226             continue;
227         }
228
229         if (module == NULL)
230             continue; /* no need to parse if there is no matching module */
231
232         char *ptr = strchr (line, '\n');
233         if (ptr != NULL)
234             *ptr = '\0';
235
236         /* look for option name */
237         const char *psz_option_name = line;
238
239         ptr = strchr (line, '=');
240         if (ptr == NULL)
241             continue; /* syntax error */
242
243         *ptr = '\0';
244         const char *psz_option_value = ptr + 1;
245
246         /* try to match this option with one of the module's options */
247         for (size_t i = 0; i < module->confsize; i++)
248         {
249             module_config_t *p_item = module->p_config + i;
250
251             if ((p_item->i_type & CONFIG_HINT)
252              || strcmp (p_item->psz_name, psz_option_name))
253                 continue;
254
255             /* We found it */
256             errno = 0;
257
258             switch( p_item->i_type )
259             {
260                 case CONFIG_ITEM_BOOL:
261                 case CONFIG_ITEM_INTEGER:
262                 {
263                     long l = strtoi (psz_option_value);
264                     if (errno)
265                         msg_Warn (p_this, "Integer value (%s) for %s: %m",
266                                   psz_option_value, psz_option_name);
267                     else
268                         p_item->saved.i = p_item->value.i = (int)l;
269                     break;
270                 }
271
272                 case CONFIG_ITEM_FLOAT:
273                     if( !*psz_option_value )
274                         break;                    /* ignore empty option */
275                     p_item->value.f = (float)i18n_atof( psz_option_value);
276                     p_item->saved.f = p_item->value.f;
277                     break;
278
279                 case CONFIG_ITEM_KEY:
280                     if( !*psz_option_value )
281                         break;                    /* ignore empty option */
282                     p_item->value.i = ConfigStringToKey(psz_option_value);
283                     p_item->saved.i = p_item->value.i;
284                     break;
285
286                 default:
287                     vlc_mutex_lock( p_item->p_lock );
288
289                     /* free old string */
290                     free( (char*) p_item->value.psz );
291                     free( (char*) p_item->saved.psz );
292
293                     p_item->value.psz = convert (psz_option_value);
294                     p_item->saved.psz = strdupnull (p_item->value.psz);
295
296                     vlc_mutex_unlock( p_item->p_lock );
297                     break;
298             }
299
300             break;
301         }
302     }
303
304     if (ferror (file))
305     {
306         msg_Err (p_this, "error reading configuration: %m");
307         clearerr (file);
308     }
309     fclose (file);
310
311     vlc_list_release( p_list );
312
313     vlc_mutex_unlock( &priv->config_lock );
314     return 0;
315 }
316
317 /*****************************************************************************
318  * config_CreateDir: Create configuration directory if it doesn't exist.
319  *****************************************************************************/
320 int config_CreateDir( vlc_object_t *p_this, const char *psz_dirname )
321 {
322     if( !psz_dirname && !*psz_dirname ) return -1;
323
324     if( utf8_mkdir( psz_dirname, 0700 ) == 0 )
325         return 0;
326
327     switch( errno )
328     {
329         case EEXIST:
330             return 0;
331
332         case ENOENT:
333         {
334             /* Let's try to create the parent directory */
335             char psz_parent[strlen( psz_dirname ) + 1], *psz_end;
336             strcpy( psz_parent, psz_dirname );
337
338             psz_end = strrchr( psz_parent, DIR_SEP_CHAR );
339             if( psz_end && psz_end != psz_parent )
340             {
341                 *psz_end = '\0';
342                 if( config_CreateDir( p_this, psz_parent ) == 0 )
343                 {
344                     if( !utf8_mkdir( psz_dirname, 0700 ) )
345                         return 0;
346                 }
347             }
348         }
349     }
350
351     msg_Err( p_this, "could not create %s: %m", psz_dirname );
352     return -1;
353 }
354
355 static int
356 config_Write (FILE *file, const char *type, const char *desc,
357               bool comment, const char *name, const char *fmt, ...)
358 {
359     va_list ap;
360     int ret;
361
362     if (desc == NULL)
363         desc = "?";
364
365     if (fprintf (file, "# %s (%s)\n%s%s=", desc, _(type),
366                  comment ? "#" : "", name) < 0)
367         return -1;
368
369     va_start (ap, fmt);
370     ret = vfprintf (file, fmt, ap);
371     va_end (ap);
372     if (ret < 0)
373         return -1;
374
375     if (fputs ("\n\n", file) == EOF)
376         return -1;
377     return 0;
378 }
379
380
381 /*****************************************************************************
382  * config_SaveConfigFile: Save a module's config options.
383  *****************************************************************************
384  * This will save the specified module's config options to the config file.
385  * If psz_module_name is NULL then we save all the modules config options.
386  * It's no use to save the config options that kept their default values, so
387  * we'll try to be a bit clever here.
388  *
389  * When we save we mustn't delete the config options of the modules that
390  * haven't been loaded. So we cannot just create a new config file with the
391  * config structures we've got in memory.
392  * I don't really know how to deal with this nicely, so I will use a completly
393  * dumb method ;-)
394  * I will load the config file in memory, but skipping all the sections of the
395  * modules we want to save. Then I will create a brand new file, dump the file
396  * loaded in memory and then append the sections of the modules we want to
397  * save.
398  * Really stupid no ?
399  *****************************************************************************/
400 static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
401                            bool b_autosave )
402 {
403     libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
404     module_t *p_parser;
405     vlc_list_t *p_list;
406     FILE *file;
407     char p_line[1024], *p_index2;
408     int i_sizebuf = 0;
409     char *p_bigbuffer, *p_index;
410     bool b_backup;
411     int i_index;
412
413     /* Acquire config file lock */
414     vlc_mutex_lock( &priv->config_lock );
415
416     if( libvlc_priv (p_this->p_libvlc)->psz_configfile == NULL )
417     {
418         char *psz_configdir = config_GetUserConfDir();
419         if( !psz_configdir ) /* XXX: This should never happen */
420         {
421             msg_Err( p_this, "no configuration directory defined" );
422             vlc_mutex_unlock( &priv->config_lock );
423             return -1;
424         }
425
426         config_CreateDir( p_this, psz_configdir );
427         free( psz_configdir );
428     }
429
430     file = config_OpenConfigFile( p_this, "rt" );
431     if( file != NULL )
432     {
433         /* look for file size */
434         fseek( file, 0L, SEEK_END );
435         i_sizebuf = ftell( file );
436         fseek( file, 0L, SEEK_SET );
437     }
438
439     p_bigbuffer = p_index = malloc( i_sizebuf+1 );
440     if( !p_bigbuffer )
441     {
442         if( file ) fclose( file );
443         vlc_mutex_unlock( &priv->config_lock );
444         return -1;
445     }
446     p_bigbuffer[0] = 0;
447
448     /* List all available modules */
449     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
450
451     /* backup file into memory, we only need to backup the sections we won't
452      * save later on */
453     b_backup = 0;
454     while( file && fgets( p_line, 1024, file ) )
455     {
456         if( (p_line[0] == '[') && (p_index2 = strchr(p_line,']')))
457         {
458
459             /* we found a section, check if we need to do a backup */
460             for( i_index = 0; i_index < p_list->i_count; i_index++ )
461             {
462                 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
463
464                 if( ((p_index2 - &p_line[1])
465                        == (int)strlen(p_parser->psz_object_name) )
466                     && !memcmp( &p_line[1], p_parser->psz_object_name,
467                                 strlen(p_parser->psz_object_name) ) )
468                 {
469                     if( !psz_module_name )
470                         break;
471                     else if( !strcmp( psz_module_name,
472                                       p_parser->psz_object_name ) )
473                         break;
474                 }
475             }
476
477             if( i_index == p_list->i_count )
478             {
479                 /* we don't have this section in our list so we need to back
480                  * it up */
481                 *p_index2 = 0;
482 #if 0
483                 msg_Dbg( p_this, "backing up config for unknown module \"%s\"",
484                                  &p_line[1] );
485 #endif
486                 *p_index2 = ']';
487
488                 b_backup = 1;
489             }
490             else
491             {
492                 b_backup = 0;
493             }
494         }
495
496         /* save line if requested and line is valid (doesn't begin with a
497          * space, tab, or eol) */
498         if( b_backup && (p_line[0] != '\n') && (p_line[0] != ' ')
499             && (p_line[0] != '\t') )
500         {
501             strcpy( p_index, p_line );
502             p_index += strlen( p_line );
503         }
504     }
505     if( file ) fclose( file );
506
507
508     /*
509      * Save module config in file
510      */
511
512     file = config_OpenConfigFile (p_this, "wt");
513     if( !file )
514     {
515         vlc_list_release( p_list );
516         free( p_bigbuffer );
517         vlc_mutex_unlock( &priv->config_lock );
518         return -1;
519     }
520
521     fprintf( file, "\xEF\xBB\xBF###\n###  " COPYRIGHT_MESSAGE "\n###\n\n"
522        "###\n### lines beginning with a '#' character are comments\n###\n\n" );
523
524     /* Look for the selected module, if NULL then save everything */
525     for( i_index = 0; i_index < p_list->i_count; i_index++ )
526     {
527         module_config_t *p_item, *p_end;
528         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
529
530         if( psz_module_name && strcmp( psz_module_name,
531                                        p_parser->psz_object_name ) )
532             continue;
533
534         if( !p_parser->i_config_items )
535             continue;
536
537         if( psz_module_name )
538             msg_Dbg( p_this, "saving config for module \"%s\"",
539                      p_parser->psz_object_name );
540
541         fprintf( file, "[%s]", p_parser->psz_object_name );
542         if( p_parser->psz_longname )
543             fprintf( file, " # %s\n\n", p_parser->psz_longname );
544         else
545             fprintf( file, "\n\n" );
546
547         for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
548              p_item < p_end;
549              p_item++ )
550         {
551             /* Do not save the new value in the configuration file
552              * if doing an autosave, and the item is not an "autosaved" one. */
553             bool b_retain = b_autosave && !p_item->b_autosave;
554
555             if ((p_item->i_type & CONFIG_HINT) /* ignore hint */
556              || p_item->b_removed              /* ignore deprecated option */
557              || p_item->b_unsaveable)          /* ignore volatile option */
558                 continue;
559
560             if (IsConfigIntegerType (p_item->i_type))
561             {
562                 int val = b_retain ? p_item->saved.i : p_item->value.i;
563                 if (p_item->i_type == CONFIG_ITEM_KEY)
564                 {
565                     char *psz_key = ConfigKeyToString (val);
566                     config_Write (file, p_item->psz_text, N_("key"),
567                                   val == p_item->orig.i,
568                                   p_item->psz_name, "%s",
569                                   psz_key ? psz_key : "");
570                     free (psz_key);
571                 }
572                 else
573                     config_Write (file, p_item->psz_text,
574                                   (p_item->i_type == CONFIG_ITEM_BOOL)
575                                       ? N_("boolean") : N_("integer"),
576                                   val == p_item->orig.i,
577                                   p_item->psz_name, "%d", val);
578                 p_item->saved.i = val;
579             }
580             else
581             if (IsConfigFloatType (p_item->i_type))
582             {
583                 float val = b_retain ? p_item->saved.f : p_item->value.f;
584                 config_Write (file, p_item->psz_text, N_("float"),
585                               val == p_item->orig.f,
586                               p_item->psz_name, "%f", val);
587                 p_item->saved.f = val;
588             }
589             else
590             {
591                 const char *psz_value = b_retain ? p_item->saved.psz
592                                                  : p_item->value.psz;
593                 bool modified;
594
595                 assert (IsConfigStringType (p_item->i_type));
596
597                 if (b_retain && (psz_value == NULL)) /* FIXME: hack */
598                     psz_value = p_item->orig.psz;
599
600                 modified =
601                     (psz_value != NULL)
602                         ? ((p_item->orig.psz != NULL)
603                             ? (strcmp (psz_value, p_item->orig.psz) != 0)
604                             : true)
605                         : (p_item->orig.psz != NULL);
606
607                 config_Write (file, p_item->psz_text, N_("string"),
608                               !modified, p_item->psz_name, "%s",
609                               psz_value ? psz_value : "");
610
611                 if ( !b_retain )
612                 {
613
614                     free ((char *)p_item->saved.psz);
615                     if( (psz_value && p_item->orig.psz &&
616                          strcmp( psz_value, p_item->orig.psz )) ||
617                         !psz_value || !p_item->orig.psz)
618                         p_item->saved.psz = strdupnull (psz_value);
619                     else
620                         p_item->saved.psz = NULL;
621                 }
622             }
623
624             if (!b_retain)
625                 p_item->b_dirty = false;
626         }
627     }
628
629     vlc_list_release( p_list );
630
631     /*
632      * Restore old settings from the config in file
633      */
634     fputs( p_bigbuffer, file );
635     free( p_bigbuffer );
636
637     fclose( file );
638     vlc_mutex_unlock( &priv->config_lock );
639
640     return 0;
641 }
642
643 int config_AutoSaveConfigFile( vlc_object_t *p_this )
644 {
645     libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
646     vlc_list_t *p_list;
647     int i_index, i_count;
648
649     assert( p_this );
650
651     /* Check if there's anything to save */
652     vlc_mutex_lock( &priv->config_lock );
653     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
654     i_count = p_list->i_count;
655     for( i_index = 0; i_index < i_count; i_index++ )
656     {
657         module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object ;
658         module_config_t *p_item, *p_end;
659
660         if( !p_parser->i_config_items ) continue;
661
662         for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
663              p_item < p_end;
664              p_item++ )
665         {
666             if( p_item->b_autosave && p_item->b_dirty ) break;
667         }
668         if( p_item < p_end ) break;
669     }
670     vlc_list_release( p_list );
671     vlc_mutex_unlock( &priv->config_lock );
672
673     if( i_index == i_count ) return VLC_SUCCESS;
674     return SaveConfigFile( p_this, 0, true );
675 }
676
677 int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name )
678 {
679     return SaveConfigFile( p_this, psz_module_name, false );
680 }
681
682 /**
683  * Get the user's configuration file when given with the --config option
684  */
685 char *config_GetCustomConfigFile( libvlc_int_t *p_libvlc )
686 {
687     char *psz_configfile = config_GetPsz( p_libvlc, "config" );
688     if( psz_configfile != NULL )
689     {
690         if( psz_configfile[0] == '~' && psz_configfile[1] == '/' )
691         {
692             /* This is incomplete: we should also support the ~cmassiot/ syntax */
693             char *psz_buf;
694             if( asprintf( &psz_buf, "%s/%s", p_libvlc->psz_homedir,
695                           psz_configfile + 2 ) == -1 )
696             {
697                 free( psz_configfile );
698                 return NULL;
699             }
700             free( psz_configfile );
701             psz_configfile = psz_buf;
702         }
703     }
704     return psz_configfile;
705 }
706
707 int ConfigStringToKey( const char *psz_key )
708 {
709     int i_key = 0;
710     unsigned int i;
711     const char *psz_parser = strchr( psz_key, '-' );
712     while( psz_parser && psz_parser != psz_key )
713     {
714         for( i = 0; i < sizeof(vlc_modifiers) / sizeof(key_descriptor_t); i++ )
715         {
716             if( !strncasecmp( vlc_modifiers[i].psz_key_string, psz_key,
717                               strlen( vlc_modifiers[i].psz_key_string ) ) )
718             {
719                 i_key |= vlc_modifiers[i].i_key_code;
720             }
721         }
722         psz_key = psz_parser + 1;
723         psz_parser = strchr( psz_key, '-' );
724     }
725     for( i = 0; i < sizeof(vlc_keys) / sizeof( key_descriptor_t ); i++ )
726     {
727         if( !strcasecmp( vlc_keys[i].psz_key_string, psz_key ) )
728         {
729             i_key |= vlc_keys[i].i_key_code;
730             break;
731         }
732     }
733     return i_key;
734 }
735
736 char *ConfigKeyToString( int i_key )
737 {
738     char *psz_key = malloc( 100 );
739     char *p;
740     size_t index;
741
742     if ( !psz_key )
743     {
744         return NULL;
745     }
746     *psz_key = '\0';
747     p = psz_key;
748
749     for( index = 0; index < (sizeof(vlc_modifiers) / sizeof(key_descriptor_t));
750          index++ )
751     {
752         if( i_key & vlc_modifiers[index].i_key_code )
753         {
754             p += sprintf( p, "%s-", vlc_modifiers[index].psz_key_string );
755         }
756     }
757     for( index = 0; index < (sizeof(vlc_keys) / sizeof( key_descriptor_t));
758          index++)
759     {
760         if( (int)( i_key & ~KEY_MODIFIER ) == vlc_keys[index].i_key_code )
761         {
762             p += sprintf( p, "%s", vlc_keys[index].psz_key_string );
763             break;
764         }
765     }
766     return psz_key;
767 }
768