summaryrefslogtreecommitdiffstats
path: root/src/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/session.c b/src/session.c
index acf4a58..d1224b1 100644
--- a/src/session.c
+++ b/src/session.c
@@ -80,7 +80,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 +92,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 +102,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 +114,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 +141,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 +153,7 @@ static ne_session *session_open(int with_lock) {
if (with_lock && lock_store)
ne_lockstore_register(lock_store, session);
-
+
return session;
}
@@ -169,7 +169,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 +183,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 +212,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 +246,3 @@ int session_is_local(const ne_uri *u) {
strcmp(u->host, uri.host) == 0 &&
u->port == uri.port;
}
-