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
12
12
* are also available at http://curl.haxx.se/docs/copyright.html.
14
14
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
15
15
* copies of the Software, and permit persons to whom the Software is
16
16
* furnished to do so, under the terms of the COPYING file.
18
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
* KIND, either express or implied.
21
* $Id: netrc.c,v 1.31 2004/03/23 15:30:12 bagder Exp $
21
* $Id: netrc.c,v 1.33 2004/10/06 07:50:18 bagder Exp $
22
22
***************************************************************************/
162
if(strequal("machine", tok)) {
163
/* the next tok is the machine name, this is in itself the
164
delimiter that starts the stuff entered for this machine,
165
after this we need to search for 'login' and
171
if(strequal(host, tok)) {
172
/* and yes, this is our host! */
161
if(strequal("machine", tok)) {
162
/* the next tok is the machine name, this is in itself the
163
delimiter that starts the stuff entered for this machine,
164
after this we need to search for 'login' and
170
if(strequal(host, tok)) {
171
/* and yes, this is our host! */
174
173
#ifdef _NETRC_DEBUG
175
printf("HOST: %s\n", tok);
174
printf("HOST: %s\n", tok);
177
retcode=0; /* we did find our host */
184
/* we are now parsing sub-keywords concerning "our" host */
176
retcode=0; /* we did find our host */
183
/* we are now parsing sub-keywords concerning "our" host */
186
185
if (specific_login) {
187
186
state_our_login = strequal(login, tok);
190
189
strncpy(login, tok, LOGINSIZE-1);
191
190
#ifdef _NETRC_DEBUG
192
printf("LOGIN: %s\n", login);
191
printf("LOGIN: %s\n", login);
197
else if(state_password) {
196
else if(state_password) {
198
197
if (state_our_login || !specific_login) {
199
198
strncpy(password, tok, PASSWORDSIZE-1);
200
199
#ifdef _NETRC_DEBUG
201
200
printf("PASSWORD: %s\n", password);
206
else if(strequal("login", tok))
208
else if(strequal("password", tok))
210
else if(strequal("machine", tok)) {
211
/* ok, there's machine here go => */
205
else if(strequal("login", tok))
207
else if(strequal("password", tok))
209
else if(strequal("machine", tok)) {
210
/* ok, there's machine here go => */
213
212
state_our_login = FALSE;
216
} /* switch (state) */
215
} /* switch (state) */
218
tok = strtok_r(NULL, " \t\n", &tok_buf);
217
tok = strtok_r(NULL, " \t\n", &tok_buf);
219
218
} /* while (tok) */
220
219
} /* while fgets() */
242
241
if(0 == ParseNetrc(argv[1], login, password)) {
243
242
printf("HOST: %s LOGIN: %s PASSWORD: %s\n",
244
argv[1], login, password);
243
argv[1], login, password);