110 if(!sn) { |
110 if(!sn) { |
111 return NULL; |
111 return NULL; |
112 } |
112 } |
113 dav_session_set_auth(sn, user, password); |
113 dav_session_set_auth(sn, user, password); |
114 return sn; |
114 return sn; |
|
115 } |
|
116 |
|
117 DavSession* dav_session_clone(DavSession *sn) { |
|
118 CURL *newhandle = curl_easy_duphandle(sn->handle); |
|
119 |
|
120 DavSession *newsn = malloc(sizeof(DavSession)); |
|
121 memset(newsn, 0, sizeof(DavSession)); |
|
122 newsn->mp = cxBasicMempoolCreate(DAV_SESSION_MEMPOOL_SIZE); |
|
123 newsn->pathcache = cxHashMapCreate(sn->mp->allocator, CX_STORE_POINTERS, DAV_PATH_CACHE_SIZE); |
|
124 newsn->key = sn->key; |
|
125 newsn->errorstr = NULL; |
|
126 newsn->error = DAV_OK; |
|
127 newsn->flags = 0; |
|
128 |
|
129 newsn->handle = newhandle; |
|
130 |
|
131 newsn->base_url = cx_strdup_a(newsn->mp->allocator, cx_str(sn->base_url)).ptr; |
|
132 newsn->auth_prompt = sn->auth_prompt; |
|
133 newsn->authprompt_userdata = sn->authprompt_userdata; |
|
134 newsn->logfunc = sn->logfunc; |
|
135 newsn->get_progress = sn->get_progress; |
|
136 newsn->put_progress = sn->put_progress; |
|
137 newsn->progress_userdata = sn->progress_userdata; |
|
138 |
|
139 // add to context |
|
140 dav_context_add_session(sn->context, newsn); |
|
141 newsn->context = sn->context; |
|
142 |
|
143 return newsn; |
115 } |
144 } |
116 |
145 |
117 void dav_session_set_auth(DavSession *sn, const char *user, const char *password) { |
146 void dav_session_set_auth(DavSession *sn, const char *user, const char *password) { |
118 if(user && password) { |
147 if(user && password) { |
119 dav_session_set_auth_s(sn, cx_str(user), cx_str(password)); |
148 dav_session_set_auth_s(sn, cx_str(user), cx_str(password)); |