~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to lib/netrc.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-04-02 23:35:45 UTC
  • mto: (1.2.1 upstream) (3.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20090402233545-geixkwhe3izccjt7
Tags: upstream-7.19.4
ImportĀ upstreamĀ versionĀ 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: netrc.c,v 1.38 2007-11-07 09:21:35 bagder Exp $
 
21
 * $Id: netrc.c,v 1.43 2008-10-23 11:49:19 bagder Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
43
43
#include "strequal.h"
44
44
#include "strtok.h"
45
45
#include "memory.h"
 
46
#include "rawstr.h"
46
47
 
47
48
#define _MPRINTF_REPLACE /* use our functions only */
48
49
#include <curl/mprintf.h>
72
73
#define PASSWORDSIZE 64
73
74
 
74
75
/* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */
75
 
int Curl_parsenetrc(char *host,
 
76
int Curl_parsenetrc(const char *host,
76
77
                    char *login,
77
78
                    char *password,
78
79
                    char *netrcfile)
117
118
      pw= getpwuid(geteuid());
118
119
      if(pw) {
119
120
#ifdef  VMS
120
 
        home = decc$translate_vms(pw->pw_dir);
 
121
        home = decc_translate_vms(pw->pw_dir);
121
122
#else
122
123
        home = pw->pw_dir;
123
124
#endif
155
156
 
156
157
        switch(state) {
157
158
        case NOTHING:
158
 
          if(strequal("machine", tok)) {
 
159
          if(Curl_raw_equal("machine", tok)) {
159
160
            /* the next tok is the machine name, this is in itself the
160
161
               delimiter that starts the stuff entered for this machine,
161
162
               after this we need to search for 'login' and
164
165
          }
165
166
          break;
166
167
        case HOSTFOUND:
167
 
          if(strequal(host, tok)) {
 
168
          if(Curl_raw_equal(host, tok)) {
168
169
            /* and yes, this is our host! */
169
170
            state=HOSTVALID;
170
171
#ifdef _NETRC_DEBUG
180
181
          /* we are now parsing sub-keywords concerning "our" host */
181
182
          if(state_login) {
182
183
            if(specific_login) {
183
 
              state_our_login = strequal(login, tok);
 
184
              state_our_login = Curl_raw_equal(login, tok);
184
185
            }
185
186
            else {
186
187
              strncpy(login, tok, LOGINSIZE-1);
199
200
            }
200
201
            state_password=0;
201
202
          }
202
 
          else if(strequal("login", tok))
 
203
          else if(Curl_raw_equal("login", tok))
203
204
            state_login=1;
204
 
          else if(strequal("password", tok))
 
205
          else if(Curl_raw_equal("password", tok))
205
206
            state_password=1;
206
 
          else if(strequal("machine", tok)) {
 
207
          else if(Curl_raw_equal("machine", tok)) {
207
208
            /* ok, there's machine here go => */
208
209
            state = HOSTFOUND;
209
210
            state_our_login = FALSE;