~ubuntu-branches/ubuntu/trusty/wget/trusty-updates

« back to all changes in this revision

Viewing changes to src/netrc.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2009-12-12 08:15:59 UTC
  • mfrom: (2.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091212081559-mvccl4kzdqb138y3
Tags: 1.12-1.1ubuntu1
* Merge from debian testing, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.
* Keep build dependencies in main:
  - debian/control: remove info2man build-dep
  - debian/patches/00list: disable wget-infopod_generated_manpage.dpatch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Read and parse the .netrc file to get hosts, accounts, and passwords.
2
 
   Copyright (C) 1996, 2007, 2008 Free Software Foundation, Inc.
 
2
   Copyright (C) 1996, 2007, 2008, 2009 Free Software Foundation, Inc.
3
3
 
4
4
This file is part of GNU Wget.
5
5
 
30
30
/* This file used to be kept in synch with the code in Fetchmail, but
31
31
   the latter has diverged since.  */
32
32
 
33
 
#ifdef HAVE_CONFIG_H
34
 
# include <config.h>
35
 
#endif
 
33
#include "wget.h"
36
34
 
37
35
#include <stdio.h>
38
36
#include <stdlib.h>
39
37
#include <string.h>
40
38
#include <errno.h>
41
39
 
42
 
#include "wget.h"
43
40
#include "utils.h"
44
41
#include "netrc.h"
45
42
#include "init.h"
68
65
  /* Find ~/.netrc.  */
69
66
  if (!processed_netrc)
70
67
    {
 
68
#ifdef __VMS
 
69
 
 
70
      int err;
 
71
      struct_stat buf;
 
72
      char *path = "SYS$LOGIN:.netrc";
 
73
 
 
74
      netrc_list = NULL;
 
75
      processed_netrc = 1;
 
76
 
 
77
      err = stat (path, &buf);
 
78
      if (err == 0)
 
79
        netrc_list = parse_netrc (path);
 
80
 
 
81
#else /* def __VMS */
 
82
 
71
83
      char *home = home_dir ();
72
84
 
73
85
      netrc_list = NULL;
84
96
          if (err == 0)
85
97
            netrc_list = parse_netrc (path);
86
98
        }
 
99
 
 
100
#endif /* def __VMS [else] */
87
101
    }
88
102
  /* If nothing to do...  */
89
103
  if (!netrc_list)
239
253
shift_left(char *string)
240
254
{
241
255
  char *p;
242
 
  
 
256
 
243
257
  for (p=string; *p; ++p)
244
258
    *p = *(p+1);
245
259
}
252
266
  char *line, *p, *tok;
253
267
  const char *premature_token;
254
268
  acc_t *current, *retval;
255
 
  int ln, quote;
 
269
  int ln, qmark;
256
270
 
257
271
  /* The latest token we've seen in the file.  */
258
272
  enum
281
295
 
282
296
      /* Parse the line.  */
283
297
      p = line;
284
 
      quote = 0;
 
298
      qmark = 0;
285
299
 
286
300
      /* Skip leading whitespace.  */
287
 
      while (*p && ISSPACE (*p))
 
301
      while (*p && c_isspace (*p))
288
302
        p ++;
289
303
 
290
304
      /* If the line is empty, then end any macro definition.  */
296
310
      while (*p && last_token != tok_macdef)
297
311
        {
298
312
          /* Skip any whitespace.  */
299
 
          while (*p && ISSPACE (*p))
 
313
          while (*p && c_isspace (*p))
300
314
            p ++;
301
315
 
302
316
          /* Discard end-of-line comments; also, stop processing if
307
321
          /* If the token starts with quotation mark, note this fact,
308
322
             and squash the quotation character */
309
323
          if (*p == '"'){
310
 
            quote = 1;
 
324
            qmark = 1;
311
325
            shift_left (p);
312
326
          }
313
327
 
314
328
          tok = p;
315
329
 
316
330
          /* Find the end of the token, handling quotes and escapes.  */
317
 
          while (*p && (quote ? *p != '"' : !ISSPACE (*p))){
 
331
          while (*p && (qmark ? *p != '"' : !c_isspace (*p))){
318
332
            if (*p == '\\')
319
333
              shift_left (p);
320
334
            p ++;
321
335
          }
322
336
 
323
337
          /* If field was quoted, squash the trailing quotation mark
324
 
             and reset quote flag.  */
325
 
          if (quote)
 
338
             and reset qmark flag.  */
 
339
          if (qmark)
326
340
            {
327
341
              shift_left (p);
328
 
              quote = 0;
 
342
              qmark = 0;
329
343
            }
330
344
 
331
345
          /* Null-terminate the token, if it isn't already.  */
374
388
          if (premature_token)
375
389
            {
376
390
              fprintf (stderr, _("\
377
 
%s: %s:%d: warning: \"%s\" token appears before any machine name\n"),
378
 
                       exec_name, path, ln, premature_token);
 
391
%s: %s:%d: warning: %s token appears before any machine name\n"),
 
392
                       exec_name, path, ln, quote (premature_token));
379
393
              premature_token = NULL;
380
394
            }
381
395