diff --git a/src/session.c b/src/session.c
index b4d66e0cd77cc2de1e4442dcbbabc9cf7675c2a2..ca5b89be3c34961eb90d76fb8dbd4b663b13dd93 100644 (file)
--- a/src/session.c
+++ b/src/session.c
-/* $Id$ */
-
/***
/***
- This file is part of fusedav.
-
- fusedav is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- fusedav is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with fusedav; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Copyright (c) 2004-2006 Lennart Poettering
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
***/
#ifdef HAVE_CONFIG_H
***/
#ifdef HAVE_CONFIG_H
}
}
}
}
}
}
-
+
fprintf(stderr, "%s: ", p);
r = fgets(q, sizeof(q), stdin);
l = strlen(q);
fprintf(stderr, "%s: ", p);
r = fgets(q, sizeof(q), stdin);
l = strlen(q);
tcsetattr(fileno(stdin), TCSANOW, &t);
fprintf(stderr, "\n");
}
tcsetattr(fileno(stdin), TCSANOW, &t);
fprintf(stderr, "\n");
}
-
+
return r ? strdup(r) : NULL;
}
return r ? strdup(r) : NULL;
}
static int ne_auth_creds_cb(__unused void *userdata, const char *realm, int attempt, char *u, char *p) {
int r = -1;
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) {
pthread_mutex_lock(&credential_mutex);
if (attempt) {
@@ -108,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 || !password)
fprintf(stderr, "Realm '%s' requires authentication.\n", realm);
-
+
if (!username)
username = ask_user("Username", 0);
if (!username)
username = ask_user("Username", 0);
-
+
if (username && !password)
password = ask_user("Password", 1);
if (username && !password)
password = ask_user("Password", 1);
return NULL;
scheme = uri.scheme ? uri.scheme : "http";
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;
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;
if (with_lock && lock_store)
ne_lockstore_register(lock_store, session);
if (with_lock && lock_store)
ne_lockstore_register(lock_store, session);
-
+
return session;
}
return session;
}
ne_session *session_get(int with_lock) {
ne_session *session;
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)))
pthread_once(&session_once, session_tsd_key_init);
if ((session = pthread_getspecific(session_tsd_key)))
int session_set_uri(const char *s, const char *u, const char *p) {
int l;
int session_set_uri(const char *s, const char *u, const char *p) {
int l;
-
+
assert(!b_uri);
assert(!username);
assert(!password);
assert(!b_uri);
assert(!username);
assert(!password);
password = strdup(p);
return 0;
password = strdup(p);
return 0;
-
+
finish:
finish:
-
+
if (b_uri) {
ne_uri_free(&uri);
b_uri = 0;
if (b_uri) {
ne_uri_free(&uri);
b_uri = 0;
strcmp(u->host, uri.host) == 0 &&
u->port == uri.port;
}
strcmp(u->host, uri.host) == 0 &&
u->port == uri.port;
}
-