diff options
author | deshevoy <deshevoy@yandex-team.ru> | 2022-02-10 16:46:56 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:56 +0300 |
commit | e988f30484abe5fdeedcc7a5d3c226c01a21800c (patch) | |
tree | 0a217b173aabb57b7e51f8a169989b1a3e0309fe /contrib/libs/curl/lib/netrc.c | |
parent | 33ee501c05d3f24036ae89766a858930ae66c548 (diff) | |
download | ydb-e988f30484abe5fdeedcc7a5d3c226c01a21800c.tar.gz |
Restoring authorship annotation for <deshevoy@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/curl/lib/netrc.c')
-rw-r--r-- | contrib/libs/curl/lib/netrc.c | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/contrib/libs/curl/lib/netrc.c b/contrib/libs/curl/lib/netrc.c index 13610bb070..49e3b2bf01 100644 --- a/contrib/libs/curl/lib/netrc.c +++ b/contrib/libs/curl/lib/netrc.c @@ -29,11 +29,11 @@ #include <curl/curl.h> #include "netrc.h" -#include "strtok.h" -#include "strcase.h" +#include "strtok.h" +#include "strcase.h" -/* The last 3 #include files should be in this order */ -#include "curl_printf.h" +/* The last 3 #include files should be in this order */ +#include "curl_printf.h" #include "curl_memory.h" #include "memdebug.h" @@ -61,105 +61,105 @@ static int parsenetrc(const char *host, { FILE *file; int retcode = NETRC_FILE_MISSING; - char *login = *loginp; - char *password = *passwordp; - bool specific_login = (login && *login != 0); - bool login_alloc = FALSE; - bool password_alloc = FALSE; - enum host_lookup_state state = NOTHING; + char *login = *loginp; + char *password = *passwordp; + bool specific_login = (login && *login != 0); + bool login_alloc = FALSE; + bool password_alloc = FALSE; + enum host_lookup_state state = NOTHING; - char state_login = 0; /* Found a login keyword */ - char state_password = 0; /* Found a password keyword */ - int state_our_login = FALSE; /* With specific_login, found *our* login - name */ + char state_login = 0; /* Found a login keyword */ + char state_password = 0; /* Found a password keyword */ + int state_our_login = FALSE; /* With specific_login, found *our* login + name */ DEBUGASSERT(netrcfile); - file = fopen(netrcfile, FOPEN_READTEXT); + file = fopen(netrcfile, FOPEN_READTEXT); if(file) { char *tok; char *tok_buf; - bool done = FALSE; - char netrcbuffer[4096]; + bool done = FALSE; + char netrcbuffer[4096]; int netrcbuffsize = (int)sizeof(netrcbuffer); while(!done && fgets(netrcbuffer, netrcbuffsize, file)) { - tok = strtok_r(netrcbuffer, " \t\n", &tok_buf); - if(tok && *tok == '#') - /* treat an initial hash as a comment line */ - continue; + tok = strtok_r(netrcbuffer, " \t\n", &tok_buf); + if(tok && *tok == '#') + /* treat an initial hash as a comment line */ + continue; while(tok) { - if((login && *login) && (password && *password)) { - done = TRUE; + if((login && *login) && (password && *password)) { + done = TRUE; break; } switch(state) { case NOTHING: - if(strcasecompare("machine", tok)) { + if(strcasecompare("machine", tok)) { /* the next tok is the machine name, this is in itself the delimiter that starts the stuff entered for this machine, after this we need to search for 'login' and 'password'. */ - state = HOSTFOUND; + state = HOSTFOUND; } - else if(strcasecompare("default", tok)) { - state = HOSTVALID; + else if(strcasecompare("default", tok)) { + state = HOSTVALID; retcode = NETRC_SUCCESS; /* we did find our host */ - } + } break; case HOSTFOUND: - if(strcasecompare(host, tok)) { + if(strcasecompare(host, tok)) { /* and yes, this is our host! */ - state = HOSTVALID; + state = HOSTVALID; retcode = NETRC_SUCCESS; /* we did find our host */ } else /* not our host */ - state = NOTHING; + state = NOTHING; break; case HOSTVALID: /* we are now parsing sub-keywords concerning "our" host */ if(state_login) { if(specific_login) { - state_our_login = strcasecompare(login, tok); + state_our_login = strcasecompare(login, tok); } - else if(!login || strcmp(login, tok)) { - if(login_alloc) { - free(login); - login_alloc = FALSE; - } - login = strdup(tok); - if(!login) { + else if(!login || strcmp(login, tok)) { + if(login_alloc) { + free(login); + login_alloc = FALSE; + } + login = strdup(tok); + if(!login) { retcode = NETRC_FAILED; /* allocation failed */ - goto out; - } - login_alloc = TRUE; + goto out; + } + login_alloc = TRUE; } - state_login = 0; + state_login = 0; } else if(state_password) { - if((state_our_login || !specific_login) - && (!password || strcmp(password, tok))) { - if(password_alloc) { - free(password); - password_alloc = FALSE; - } - password = strdup(tok); - if(!password) { + if((state_our_login || !specific_login) + && (!password || strcmp(password, tok))) { + if(password_alloc) { + free(password); + password_alloc = FALSE; + } + password = strdup(tok); + if(!password) { retcode = NETRC_FAILED; /* allocation failed */ - goto out; - } - password_alloc = TRUE; + goto out; + } + password_alloc = TRUE; } - state_password = 0; + state_password = 0; } - else if(strcasecompare("login", tok)) - state_login = 1; - else if(strcasecompare("password", tok)) - state_password = 1; - else if(strcasecompare("machine", tok)) { + else if(strcasecompare("login", tok)) + state_login = 1; + else if(strcasecompare("password", tok)) + state_password = 1; + else if(strcasecompare("machine", tok)) { /* ok, there's machine here go => */ state = HOSTFOUND; state_our_login = FALSE; @@ -171,30 +171,30 @@ static int parsenetrc(const char *host, } /* while(tok) */ } /* while fgets() */ - out: - if(!retcode) { + out: + if(!retcode) { /* success */ - *login_changed = FALSE; - *password_changed = FALSE; - if(login_alloc) { - if(*loginp) - free(*loginp); - *loginp = login; - *login_changed = TRUE; - } - if(password_alloc) { - if(*passwordp) - free(*passwordp); - *passwordp = password; - *password_changed = TRUE; - } - } - else { - if(login_alloc) - free(login); - if(password_alloc) - free(password); - } + *login_changed = FALSE; + *password_changed = FALSE; + if(login_alloc) { + if(*loginp) + free(*loginp); + *loginp = login; + *login_changed = TRUE; + } + if(password_alloc) { + if(*passwordp) + free(*passwordp); + *passwordp = password; + *password_changed = TRUE; + } + } + else { + if(login_alloc) + free(login); + if(password_alloc) + free(password); + } fclose(file); } |