X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsession.c;h=ca5b89be3c34961eb90d76fb8dbd4b663b13dd93;hb=f8835b143558f38cfb7a01a71adc525598f12d05;hp=acf4a581c1c6bb6d58af4b4f650e2c9ce7ad2566;hpb=0c82f84ef5b8a0a7a773fdb14028bf07a05b3e89;p=fusedav.git diff --git a/src/session.c b/src/session.c index acf4a58..ca5b89b 100644 --- a/src/session.c +++ b/src/session.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /*** Copyright (c) 2004-2006 Lennart Poettering @@ -80,7 +78,7 @@ static char* ask_user(const char *p, int hidden) { } } } - + fprintf(stderr, "%s: ", p); r = fgets(q, sizeof(q), stdin); l = strlen(q); @@ -92,7 +90,7 @@ static char* ask_user(const char *p, int hidden) { tcsetattr(fileno(stdin), TCSANOW, &t); fprintf(stderr, "\n"); } - + return r ? strdup(r) : NULL; } @@ -102,7 +100,7 @@ static int ssl_verify_cb(__unused void *userdata, __unused int failures, __unuse static int ne_auth_creds_cb(__unused void *userdata, const char *realm, int attempt, char *u, char *p) { int r = -1; - + pthread_mutex_lock(&credential_mutex); if (attempt) { @@ -114,10 +112,10 @@ static int ne_auth_creds_cb(__unused void *userdata, const char *realm, int atte if (!username || !password) fprintf(stderr, "Realm '%s' requires authentication.\n", realm); - + if (!username) username = ask_user("Username", 0); - + if (username && !password) password = ask_user("Password", 1); @@ -141,7 +139,7 @@ static ne_session *session_open(int with_lock) { return NULL; scheme = uri.scheme ? uri.scheme : "http"; - + if (!(session = ne_session_create(scheme, uri.host, uri.port ? uri.port : ne_uri_defaultport(scheme)))) { fprintf(stderr, "Failed to create session\n"); return NULL; @@ -153,7 +151,7 @@ static ne_session *session_open(int with_lock) { if (with_lock && lock_store) ne_lockstore_register(lock_store, session); - + return session; } @@ -169,7 +167,7 @@ static void session_tsd_key_init(void) { ne_session *session_get(int with_lock) { ne_session *session; - + pthread_once(&session_once, session_tsd_key_init); if ((session = pthread_getspecific(session_tsd_key))) @@ -183,7 +181,7 @@ ne_session *session_get(int with_lock) { int session_set_uri(const char *s, const char *u, const char *p) { int l; - + assert(!b_uri); assert(!username); assert(!password); @@ -212,9 +210,9 @@ int session_set_uri(const char *s, const char *u, const char *p) { password = strdup(p); return 0; - + finish: - + if (b_uri) { ne_uri_free(&uri); b_uri = 0; @@ -246,4 +244,3 @@ int session_is_local(const ne_uri *u) { strcmp(u->host, uri.host) == 0 && u->port == uri.port; } -