~ubuntu-branches/ubuntu/intrepid/weechat/intrepid-security

« back to all changes in this revision

Viewing changes to src/plugins/plugins-config.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Louis
  • Date: 2007-01-12 09:01:46 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070112090146-x9bx8v5956mj7fmn
Tags: 0.2.3-1
* New upstream release
* Bump lua build-dependency to liblua5.1-0-dev
* Add pkg-config to Build-Depends
* Remove some duplited changelog entries.
* Improve weechat-plugins description

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
 
2
 * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
3
3
 * See README for License detail, AUTHORS for developers list.
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
188
188
                return 1;
189
189
            }
190
190
        }
 
191
        else
 
192
            return 1;
191
193
    }
192
194
    
193
195
    /* failed to set plugin option */
230
232
    char *filename;
231
233
    FILE *file;
232
234
    int line_number;
233
 
    char line[1024], *ptr_line, *pos, *pos2;
 
235
    char line[1024], *ptr_line, *ptr_line2, *pos, *pos2;
234
236
 
235
237
    filename_length = strlen (weechat_home) +
236
238
        strlen (WEECHAT_PLUGINS_CONFIG_NAME) + 2;
240
242
        return;
241
243
    snprintf (filename, filename_length, "%s%s" WEECHAT_PLUGINS_CONFIG_NAME,
242
244
              weechat_home, DIR_SEPARATOR);
243
 
    if ((file = fopen (filename, "rt")) == NULL)
 
245
    if ((file = fopen (filename, "r")) == NULL)
244
246
        return;
245
247
    
246
248
    line_number = 0;
250
252
        line_number++;
251
253
        if (ptr_line)
252
254
        {
 
255
            /* encode line to internal charset */
 
256
            ptr_line2 = weechat_iconv_to_internal (NULL, ptr_line);
 
257
            if (ptr_line2)
 
258
            {
 
259
                snprintf (line, sizeof (line) - 1, "%s", ptr_line2);
 
260
                free (ptr_line2);
 
261
            }
 
262
            
253
263
            /* skip spaces */
254
264
            while (ptr_line[0] == ' ')
255
265
                ptr_line++;
347
357
    snprintf (filename, filename_length, "%s%s" WEECHAT_PLUGINS_CONFIG_NAME,
348
358
              weechat_home, DIR_SEPARATOR);
349
359
    
350
 
    if ((file = fopen (filename, "wt")) == NULL)
 
360
    if ((file = fopen (filename, "w")) == NULL)
351
361
    {
352
362
        irc_display_prefix (NULL, NULL, PREFIX_ERROR);
353
363
        gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
357
367
    }
358
368
    
359
369
    current_time = time (NULL);
360
 
    fprintf (file, _("#\n# %s plugins configuration file, created by "
361
 
             "%s v%s on %s"),
362
 
             PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
363
 
             ctime (&current_time));
364
 
    fprintf (file, _("# WARNING! Be careful when editing this file, "
365
 
                     "WeeChat writes this file when options are updated.\n#\n"));
 
370
    weechat_iconv_fprintf (file, _("#\n# %s plugins configuration file, created by "
 
371
                                   "%s v%s on %s"),
 
372
                           PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
 
373
                           ctime (&current_time));
 
374
    weechat_iconv_fprintf (file, _("# WARNING! Be careful when editing this file, "
 
375
                                   "WeeChat writes this file when options are updated.\n#\n"));
366
376
    
367
377
    for (ptr_plugin_option = plugin_options; ptr_plugin_option;
368
378
         ptr_plugin_option = ptr_plugin_option->next_option)
369
379
    {
370
 
        fprintf (file, "%s = \"%s\"\n",
371
 
                 ptr_plugin_option->name,
372
 
                 ptr_plugin_option->value);
 
380
        weechat_iconv_fprintf (file, "%s = \"%s\"\n",
 
381
                               ptr_plugin_option->name,
 
382
                               ptr_plugin_option->value);
373
383
    }
374
384
    
375
385
    fclose (file);