]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-no-neon.patch
- rel 49; rebuild with new libproxy
[packages/rpm.git] / rpm-no-neon.patch
CommitLineData
ace8a5cc
ER
1--- rpm-4.5/rpmio/rpmdav.c~ 2008-07-09 12:38:31.000000000 +0300
2+++ rpm-4.5/rpmio/rpmdav.c 2008-09-04 17:43:50.215697868 +0300
3@@ -9,58 +9,6 @@
aa9c264c
JR
4 #include <pthread.h>
5 #endif
6
ace8a5cc 7-#if USE_INTERNAL_NEON
17a083bf
JB
8-#include "ne_alloc.h"
9-#include "ne_auth.h"
10-#include "ne_basic.h"
11-#include "ne_dates.h"
12-#include "ne_locks.h"
ace8a5cc
ER
13-#else
14-#include "neon/ne_alloc.h"
15-#include "neon/ne_auth.h"
16-#include "neon/ne_basic.h"
17-#include "neon/ne_dates.h"
18-#include "neon/ne_locks.h"
19-#endif
17a083bf
JB
20-
21-#define NEONBLOWSCHUNKS
22-#ifndef NEONBLOWSCHUNKS
23-/* HACK: include ne_private.h to access sess->socket for now. */
24-#include "../neon/src/ne_private.h"
25-#endif
26-
ace8a5cc 27-#if USE_INTERNAL_NEON
17a083bf
JB
28-#include "ne_props.h"
29-#include "ne_request.h"
30-#include "ne_socket.h"
31-#include "ne_string.h"
32-#include "ne_utils.h"
ace8a5cc
ER
33-#include "ne_md5.h" /* for version detection only */
34-#else
35-#include "neon/ne_props.h"
36-#include "neon/ne_request.h"
37-#include "neon/ne_socket.h"
38-#include "neon/ne_string.h"
39-#include "neon/ne_utils.h"
40-#include "neon/ne_md5.h" /* for version detection only */
41-#endif
6efed78b 42-
ace8a5cc
ER
43-/* poor-man's NEON version determination */
44-#if defined(NE_MD5_H)
45-#define WITH_NEON_MIN_VERSION 0x002700
46-#elif defined(NE_FEATURE_I18N)
47-#define WITH_NEON_MIN_VERSION 0x002600
48-#else
49-#define WITH_NEON_MIN_VERSION 0x002500
50-#endif
51-
52-/* XXX API changes for NEON 0.26 */
53-#if WITH_NEON_MIN_VERSION >= 0x002600
6efed78b
JB
54-#define ne_set_persist(_sess, _flag)
55-#define ne_propfind_set_private(_pfh, _create_item, NULL) \
56- ne_propfind_set_private(_pfh, _create_item, NULL, NULL)
57-#endif
aa9c264c
JR
58-
59 #include <rpmio_internal.h>
60
61 #define _RPMDAV_INTERNAL
ace8a5cc
ER
62@@ -74,1469 +22,6 @@
63 /*@access FD_t @*/
64 /*@access urlinfo @*/
aa9c264c 65
ace8a5cc
ER
66-#if 0 /* HACK: reasonable value needed. */
67-#define TIMEOUT_SECS 60
68-#else
69-#define TIMEOUT_SECS 5
70-#endif
71-/*@unchecked@*/
72-static int httpTimeoutSecs = TIMEOUT_SECS;
73-
74-/* =============================================================== */
e9c15efc 75-int davFree(urlinfo u)
aa9c264c
JR
76- /*@globals internalState @*/
77- /*@modifies u, internalState @*/
78-{
e9c15efc
JB
79- if (u != NULL) {
80- if (u->sess != NULL) {
81- ne_session_destroy(u->sess);
82- u->sess = NULL;
83- }
84- switch (u->urltype) {
85- default:
86- /*@notreached@*/ break;
87- case URL_IS_HTTPS:
88- case URL_IS_HTTP:
89- case URL_IS_HKP:
90- u->capabilities = _free(u->capabilities);
91- if (u->lockstore != NULL)
92- ne_lockstore_destroy(u->lockstore);
93- u->lockstore = NULL;
94- ne_sock_exit();
95- break;
96- }
aa9c264c
JR
97- }
98- return 0;
99-}
100-
101-static void davProgress(void * userdata, off_t current, off_t total)
102- /*@*/
103-{
104- urlinfo u = userdata;
105- ne_session * sess;
106-
107-assert(u != NULL);
108- sess = u->sess;
109-assert(sess != NULL);
110-assert(u == ne_get_session_private(sess, "urlinfo"));
111-
112- u->current = current;
113- u->total = total;
114-
115-if (_dav_debug < 0)
116-fprintf(stderr, "*** davProgress(%p,0x%x:0x%x) sess %p u %p\n", userdata, (unsigned int)current, (unsigned int)total, sess, u);
117-}
118-
ace8a5cc
ER
119-#if WITH_NEON_MIN_VERSION >= 0x002700
120-static void davNotify(void * userdata,
121- ne_session_status connstatus, const ne_session_status_info *info)
122-#else
aa9c264c
JR
123-static void davNotify(void * userdata,
124- ne_conn_status connstatus, const char * info)
ace8a5cc 125-#endif
aa9c264c
JR
126- /*@*/
127-{
128- urlinfo u = userdata;
129- ne_session * sess;
130- /*@observer@*/
131- static const char * connstates[] = {
132- "namelookup",
133- "connecting",
134- "connected",
135- "secure",
136- "unknown"
137- };
138-
139-assert(u != NULL);
140- sess = u->sess;
141-assert(sess != NULL);
142-assert(u == ne_get_session_private(sess, "urlinfo"));
143-
144-#ifdef REFERENCE
145-typedef enum {
146- ne_conn_namelookup, /* lookup up hostname (info = hostname) */
147- ne_conn_connecting, /* connecting to host (info = hostname) */
148- ne_conn_connected, /* connected to host (info = hostname) */
149- ne_conn_secure /* connection now secure (info = crypto level) */
150-} ne_conn_status;
151-#endif
152-
ace8a5cc 153-#if WITH_NEON_MIN_VERSION < 0x002700
aa9c264c 154- u->connstatus = connstatus;
ace8a5cc 155-#endif
aa9c264c
JR
156-
157-/*@-boundsread@*/
158-if (_dav_debug < 0)
159-fprintf(stderr, "*** davNotify(%p,%d,%p) sess %p u %p %s\n", userdata, connstatus, info, sess, u, connstates[ (connstatus < 4 ? connstatus : 4)]);
160-/*@=boundsread@*/
161-
162-}
163-
164-static void davCreateRequest(ne_request * req, void * userdata,
165- const char * method, const char * uri)
166- /*@*/
167-{
168- urlinfo u = userdata;
169- ne_session * sess;
170- void * private = NULL;
171- const char * id = "urlinfo";
172-
173-assert(u != NULL);
174-assert(u->sess != NULL);
175-assert(req != NULL);
176- sess = ne_get_session(req);
177-assert(sess == u->sess);
178-assert(u == ne_get_session_private(sess, "urlinfo"));
179-
180-assert(sess != NULL);
181- private = ne_get_session_private(sess, id);
182-assert(u == private);
183-
184-if (_dav_debug < 0)
185-fprintf(stderr, "*** davCreateRequest(%p,%p,%s,%s) %s:%p\n", req, userdata, method, uri, id, private);
186-}
187-
188-static void davPreSend(ne_request * req, void * userdata, ne_buffer * buf)
189-{
190- urlinfo u = userdata;
191- ne_session * sess;
192- const char * id = "fd";
193- FD_t fd = NULL;
194-
195-assert(u != NULL);
196-assert(u->sess != NULL);
197-assert(req != NULL);
198- sess = ne_get_session(req);
199-assert(sess == u->sess);
200-assert(u == ne_get_session_private(sess, "urlinfo"));
201-
202- fd = ne_get_request_private(req, id);
203-
204-if (_dav_debug < 0)
205-fprintf(stderr, "*** davPreSend(%p,%p,%p) sess %p %s %p\n", req, userdata, buf, sess, id, fd);
206-if (_dav_debug)
207-fprintf(stderr, "-> %s\n", buf->data);
208-
209-}
210-
211-static int davPostSend(ne_request * req, void * userdata, const ne_status * status)
212- /*@*/
213-{
214- urlinfo u = userdata;
215- ne_session * sess;
216- const char * id = "fd";
217- FD_t fd = NULL;
218-
219-assert(u != NULL);
220-assert(u->sess != NULL);
221-assert(req != NULL);
222- sess = ne_get_session(req);
223-assert(sess == u->sess);
224-assert(u == ne_get_session_private(sess, "urlinfo"));
225-
226- fd = ne_get_request_private(req, id);
227-
228-/*@-evalorder@*/
229-if (_dav_debug < 0)
230-fprintf(stderr, "*** davPostSend(%p,%p,%p) sess %p %s %p %s\n", req, userdata, status, sess, id, fd, ne_get_error(sess));
231-/*@=evalorder@*/
232- return NE_OK;
233-}
234-
235-static void davDestroyRequest(ne_request * req, void * userdata)
236- /*@*/
237-{
238- urlinfo u = userdata;
239- ne_session * sess;
240- const char * id = "fd";
241- FD_t fd = NULL;
242-
243-assert(u != NULL);
244-assert(u->sess != NULL);
245-assert(req != NULL);
246- sess = ne_get_session(req);
247-assert(sess == u->sess);
248-assert(u == ne_get_session_private(sess, "urlinfo"));
249-
250- fd = ne_get_request_private(req, id);
251-
252-if (_dav_debug < 0)
253-fprintf(stderr, "*** davDestroyRequest(%p,%p) sess %p %s %p\n", req, userdata, sess, id, fd);
254-}
255-
256-static void davDestroySession(void * userdata)
257- /*@*/
258-{
259- urlinfo u = userdata;
260- ne_session * sess;
261- void * private = NULL;
262- const char * id = "urlinfo";
263-
264-assert(u != NULL);
265-assert(u->sess != NULL);
266- sess = u->sess;
267-assert(u == ne_get_session_private(sess, "urlinfo"));
268-
269-assert(sess != NULL);
270- private = ne_get_session_private(sess, id);
271-assert(u == private);
272-
273-if (_dav_debug < 0)
274-fprintf(stderr, "*** davDestroySession(%p) sess %p %s %p\n", userdata, sess, id, private);
275-}
276-
277-static int
278-davVerifyCert(void *userdata, int failures, const ne_ssl_certificate *cert)
279- /*@*/
280-{
281- const char *hostname = userdata;
282-
283-if (_dav_debug < 0)
284-fprintf(stderr, "*** davVerifyCert(%p,%d,%p) %s\n", userdata, failures, cert, hostname);
285-
286- return 0; /* HACK: trust all server certificates. */
287-}
288-
289-static int davConnect(urlinfo u)
290- /*@globals internalState @*/
291- /*@modifies u, internalState @*/
292-{
293- const char * path = NULL;
294- int rc;
295-
296- /* HACK: hkp:// has no steenkin' options */
297- if (!(u->urltype == URL_IS_HTTP || u->urltype == URL_IS_HTTPS))
298- return 0;
299-
300- /* HACK: where should server capabilities be read? */
301- (void) urlPath(u->url, &path);
302- /* HACK: perhaps capture Allow: tag, look for PUT permitted. */
e9c15efc 303- /* XXX [hdr] Allow: GET,HEAD,POST,OPTIONS,TRACE */
aa9c264c
JR
304- rc = ne_options(u->sess, path, u->capabilities);
305- switch (rc) {
306- case NE_OK:
e9c15efc
JB
307- { ne_server_capabilities *cap = u->capabilities;
308- if (cap->dav_class1)
309- u->allow |= RPMURL_SERVER_HASDAVCLASS1;
310- else
311- u->allow &= ~RPMURL_SERVER_HASDAVCLASS1;
312- if (cap->dav_class2)
313- u->allow |= RPMURL_SERVER_HASDAVCLASS2;
314- else
315- u->allow &= ~RPMURL_SERVER_HASDAVCLASS2;
316- if (cap->dav_executable)
317- u->allow |= RPMURL_SERVER_HASDAVEXEC;
318- else
319- u->allow &= ~RPMURL_SERVER_HASDAVEXEC;
320- } break;
aa9c264c
JR
321- case NE_ERROR:
322- /* HACK: "301 Moved Permanently" on empty subdir. */
323- if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
324- break;
e9c15efc
JB
325- errno = EIO; /* HACK: more precise errno. */
326- goto bottom;
aa9c264c 327- case NE_LOOKUP:
e9c15efc
JB
328- errno = ENOENT; /* HACK: errno same as non-existent path. */
329- goto bottom;
330- case NE_CONNECT: /* HACK: errno set already? */
aa9c264c 331- default:
e9c15efc 332-bottom:
aa9c264c
JR
333-if (_dav_debug)
334-fprintf(stderr, "*** Connect to %s:%d failed(%d):\n\t%s\n",
335- u->host, u->port, rc, ne_get_error(u->sess));
336- break;
337- }
338-
339- /* HACK: sensitive to error returns? */
340- u->httpVersion = (ne_version_pre_http11(u->sess) ? 0 : 1);
341-
342- return rc;
343-}
344-
345-static int davInit(const char * url, urlinfo * uret)
346- /*@globals internalState @*/
347- /*@modifies *uret, internalState @*/
348-{
349- urlinfo u = NULL;
350- int rc = 0;
351-
352-/*@-globs@*/ /* FIX: h_errno annoyance. */
353- if (urlSplit(url, &u))
354- return -1; /* XXX error returns needed. */
355-/*@=globs@*/
356-
357- if (u->url != NULL && u->sess == NULL)
358- switch (u->urltype) {
359- default:
360- assert(u->urltype != u->urltype);
361- /*@notreached@*/ break;
362- case URL_IS_HTTPS:
363- case URL_IS_HTTP:
364- case URL_IS_HKP:
365- { ne_server_capabilities * capabilities;
366-
367- /* HACK: oneshots should be done Somewhere Else Instead. */
368-/*@-noeffect@*/
369- rc = ((_dav_debug < 0) ? NE_DBG_HTTP : 0);
370- ne_debug_init(stderr, rc); /* XXX oneshot? */
371-/*@=noeffect@*/
372- rc = ne_sock_init(); /* XXX oneshot? */
373-
374- u->lockstore = ne_lockstore_create(); /* XXX oneshot? */
375-
376- u->capabilities = capabilities = xcalloc(1, sizeof(*capabilities));
377- u->sess = ne_session_create(u->scheme, u->host, u->port);
378-
379- ne_lockstore_register(u->lockstore, u->sess);
380-
381- if (u->proxyh != NULL)
382- ne_session_proxy(u->sess, u->proxyh, u->proxyp);
383-
384-#if 0
385- { const ne_inet_addr ** addrs;
386- unsigned int n;
387- ne_set_addrlist(u->sess, addrs, n);
388- }
389-#endif
390-
391- ne_set_progress(u->sess, davProgress, u);
ace8a5cc
ER
392-#if WITH_NEON_MIN_VERSION >= 0x002700
393- ne_set_notifier(u->sess, davNotify, u);
394-#else
aa9c264c 395- ne_set_status(u->sess, davNotify, u);
ace8a5cc 396-#endif
aa9c264c
JR
397-
398- ne_set_persist(u->sess, 1);
399- ne_set_read_timeout(u->sess, httpTimeoutSecs);
400- ne_set_useragent(u->sess, PACKAGE "/" PACKAGE_VERSION);
401-
402- /* XXX check that neon is ssl enabled. */
403- if (!strcasecmp(u->scheme, "https"))
404- ne_ssl_set_verify(u->sess, davVerifyCert, (char *)u->host);
dc6aae45 405-
aa9c264c
JR
406- ne_set_session_private(u->sess, "urlinfo", u);
407-
408- ne_hook_destroy_session(u->sess, davDestroySession, u);
409-
410- ne_hook_create_request(u->sess, davCreateRequest, u);
411- ne_hook_pre_send(u->sess, davPreSend, u);
412- ne_hook_post_send(u->sess, davPostSend, u);
413- ne_hook_destroy_request(u->sess, davDestroyRequest, u);
414-
415- /* HACK: where should server capabilities be read? */
416- rc = davConnect(u);
417- if (rc)
418- goto exit;
419- } break;
420- }
421-
422-exit:
423-/*@-boundswrite@*/
e9c15efc 424- if (uret != NULL)
ace8a5cc 425- *uret = urlLink(u, "davInit");
aa9c264c
JR
426-/*@=boundswrite@*/
427- u = urlFree(u, "urlSplit (davInit)");
428-
429- return rc;
430-}
431-
432-/* =============================================================== */
433-enum fetch_rtype_e {
434- resr_normal = 0,
435- resr_collection,
436- resr_reference,
437- resr_error
438-};
dc6aae45 439-
aa9c264c 440-struct fetch_resource_s {
dc6aae45 441-/*@dependent@*/
aa9c264c
JR
442- struct fetch_resource_s *next;
443- char *uri;
444-/*@unused@*/
445- char *displayname;
446- enum fetch_rtype_e type;
447- size_t size;
448- time_t modtime;
449- int is_executable;
450- int is_vcr; /* Is version resource. 0: no vcr, 1 checkin 2 checkout */
451- char *error_reason; /* error string returned for this resource */
452- int error_status; /* error status returned for this resource */
453-};
454-
455-/*@null@*/
456-static void *fetch_destroy_item(/*@only@*/ struct fetch_resource_s *res)
457- /*@modifies res @*/
458-{
6efed78b
JB
459- ne_free(res->uri);
460- ne_free(res->error_reason);
aa9c264c
JR
461- res = _free(res);
462- return NULL;
463-}
464-
465-#ifdef UNUSED
466-/*@null@*/
467-static void *fetch_destroy_list(/*@only@*/ struct fetch_resource_s *res)
468- /*@modifies res @*/
469-{
470- struct fetch_resource_s *next;
471-/*@-branchstate@*/
472- for (; res != NULL; res = next) {
473- next = res->next;
474- res = fetch_destroy_item(res);
475- }
476-/*@=branchstate@*/
477- return NULL;
478-}
479-#endif
480-
ace8a5cc
ER
481-#if WITH_NEON_MIN_VERSION >= 0x002600
482-static void *fetch_create_item(/*@unused@*/ void *userdata, /*@unused@*/ const ne_uri *uri)
483-#else
aa9c264c 484-static void *fetch_create_item(/*@unused@*/ void *userdata, /*@unused@*/ const char *uri)
ace8a5cc 485-#endif
aa9c264c
JR
486- /*@*/
487-{
488- struct fetch_resource_s * res = ne_calloc(sizeof(*res));
489- return res;
490-}
491-
492-/* =============================================================== */
493-struct fetch_context_s {
dc6aae45 494-/*@relnull@*/ /*@dependent@*/
aa9c264c
JR
495- struct fetch_resource_s **resrock;
496- const char *uri;
497- unsigned int include_target; /* Include resource at href */
498-/*@refcounted@*/
499- urlinfo u;
500- int ac;
501- int nalloced;
502- ARGV_t av;
e9c15efc
JB
503-/*@null@*/ /*@shared@*/
504- struct stat *st;
aa9c264c
JR
505- mode_t * modes;
506- size_t * sizes;
507- time_t * mtimes;
508-};
509-
510-/*@null@*/
511-static void *fetch_destroy_context(/*@only@*/ /*@null@*/ struct fetch_context_s *ctx)
512- /*@globals internalState @*/
513- /*@modifies ctx, internalState @*/
514-{
515- if (ctx == NULL)
516- return NULL;
517- if (ctx->av != NULL)
518- ctx->av = argvFree(ctx->av);
519- ctx->modes = _free(ctx->modes);
520- ctx->sizes = _free(ctx->sizes);
521- ctx->mtimes = _free(ctx->mtimes);
ace8a5cc 522- ctx->u = urlFree(ctx->u, "fetch_destroy_context");
aa9c264c
JR
523- ctx->uri = _free(ctx->uri);
524-/*@-boundswrite@*/
525- memset(ctx, 0, sizeof(*ctx));
526-/*@=boundswrite@*/
527- ctx = _free(ctx);
528- return NULL;
529-}
530-
531-/*@null@*/
e9c15efc 532-static void *fetch_create_context(const char *uri, /*@null@*/ struct stat *st)
aa9c264c
JR
533- /*@globals internalState @*/
534- /*@modifies internalState @*/
535-{
536- struct fetch_context_s * ctx;
537- urlinfo u;
538-
539-/*@-globs@*/ /* FIX: h_errno annoyance. */
540- if (urlSplit(uri, &u))
541- return NULL;
542-/*@=globs@*/
543-
544- ctx = ne_calloc(sizeof(*ctx));
545- ctx->uri = xstrdup(uri);
ace8a5cc 546- ctx->u = urlLink(u, "fetch_create_context");
e9c15efc
JB
547- if ((ctx->st = st) != NULL)
548- memset(ctx->st, 0, sizeof(*ctx->st));
aa9c264c
JR
549- return ctx;
550-}
551-
552-/*@unchecked@*/ /*@observer@*/
553-static const ne_propname fetch_props[] = {
554- { "DAV:", "getcontentlength" },
555- { "DAV:", "getlastmodified" },
556- { "http://apache.org/dav/props/", "executable" },
557- { "DAV:", "resourcetype" },
558- { "DAV:", "checked-in" },
559- { "DAV:", "checked-out" },
560- { NULL, NULL }
561-};
562-
563-#define ELM_resourcetype (NE_PROPS_STATE_TOP + 1)
564-#define ELM_collection (NE_PROPS_STATE_TOP + 2)
565-
566-/*@unchecked@*/ /*@observer@*/
567-static const struct ne_xml_idmap fetch_idmap[] = {
568- { "DAV:", "resourcetype", ELM_resourcetype },
569- { "DAV:", "collection", ELM_collection }
570-};
571-
dc6aae45 572-static int fetch_startelm(void *userdata, int parent,
aa9c264c
JR
573- const char *nspace, const char *name,
574- /*@unused@*/ const char **atts)
575- /*@*/
576-{
577- ne_propfind_handler *pfh = userdata;
578- struct fetch_resource_s *r = ne_propfind_current_private(pfh);
579- int state = ne_xml_mapid(fetch_idmap, NE_XML_MAPLEN(fetch_idmap),
580- nspace, name);
581-
dc6aae45 582- if (r == NULL ||
aa9c264c
JR
583- !((parent == NE_207_STATE_PROP && state == ELM_resourcetype) ||
584- (parent == ELM_resourcetype && state == ELM_collection)))
585- return NE_XML_DECLINE;
586-
587- if (state == ELM_collection) {
588- r->type = resr_collection;
589- }
590-
591- return state;
592-}
593-
dc6aae45 594-static int fetch_compare(const struct fetch_resource_s *r1,
aa9c264c
JR
595- const struct fetch_resource_s *r2)
596- /*@*/
597-{
598- /* Sort errors first, then collections, then alphabetically */
599- if (r1->type == resr_error) {
600- return -1;
601- } else if (r2->type == resr_error) {
602- return 1;
603- } else if (r1->type == resr_collection) {
604- if (r2->type != resr_collection) {
605- return -1;
606- } else {
607- return strcmp(r1->uri, r2->uri);
608- }
609- } else {
610- if (r2->type != resr_collection) {
611- return strcmp(r1->uri, r2->uri);
612- } else {
613- return 1;
614- }
615- }
616-}
617-
ace8a5cc
ER
618-#if WITH_NEON_MIN_VERSION >= 0x002600
619-static void fetch_results(void *userdata, const ne_uri *uarg,
620- const ne_prop_result_set *set)
621-#else
6efed78b 622-static void fetch_results(void *userdata, void *uarg,
aa9c264c 623- const ne_prop_result_set *set)
ace8a5cc 624-#endif
aa9c264c
JR
625- /*@*/
626-{
627- struct fetch_context_s *ctx = userdata;
628- struct fetch_resource_s *current, *previous, *newres;
629- const char *clength, *modtime, *isexec;
630- const char *checkin, *checkout;
631- const ne_status *status = NULL;
632- const char * path = NULL;
633-
ace8a5cc 634-#if WITH_NEON_MIN_VERSION >= 0x002600
6efed78b
JB
635- const ne_uri * uri = uarg;
636- (void) urlPath(uri->path, &path);
637-#else
638- const char * uri = uarg;
aa9c264c 639- (void) urlPath(uri, &path);
6efed78b 640-#endif
aa9c264c
JR
641- if (path == NULL)
642- return;
643-
644- newres = ne_propset_private(set);
645-
646-if (_dav_debug < 0)
647-fprintf(stderr, "==> %s in uri %s\n", path, ctx->uri);
dc6aae45 648-
aa9c264c
JR
649- if (ne_path_compare(ctx->uri, path) == 0 && !ctx->include_target) {
650- /* This is the target URI */
651-if (_dav_debug < 0)
652-fprintf(stderr, "==> %s skipping target resource.\n", path);
653- /* Free the private structure. */
dc6aae45 654-/*@-dependenttrans -exposetrans@*/
aa9c264c 655- free(newres);
dc6aae45 656-/*@=dependenttrans =exposetrans@*/
aa9c264c
JR
657- return;
658- }
659-
660- newres->uri = ne_strdup(path);
661-
662-/*@-boundsread@*/
dc6aae45 663- clength = ne_propset_value(set, &fetch_props[0]);
aa9c264c
JR
664- modtime = ne_propset_value(set, &fetch_props[1]);
665- isexec = ne_propset_value(set, &fetch_props[2]);
666- checkin = ne_propset_value(set, &fetch_props[4]);
667- checkout = ne_propset_value(set, &fetch_props[5]);
668-/*@=boundsread@*/
dc6aae45 669-
aa9c264c
JR
670-/*@-branchstate@*/
671- if (clength == NULL)
672- status = ne_propset_status(set, &fetch_props[0]);
673- if (modtime == NULL)
674- status = ne_propset_status(set, &fetch_props[1]);
675-/*@=branchstate@*/
676-
677- if (newres->type == resr_normal && status != NULL) {
678- /* It's an error! */
679- newres->error_status = status->code;
680-
681- /* Special hack for Apache 1.3/mod_dav */
682- if (strcmp(status->reason_phrase, "status text goes here") == 0) {
683- const char *desc;
684- if (status->code == 401) {
685- desc = _("Authorization Required");
686- } else if (status->klass == 3) {
687- desc = _("Redirect");
688- } else if (status->klass == 5) {
689- desc = _("Server Error");
690- } else {
691- desc = _("Unknown Error");
692- }
693- newres->error_reason = ne_strdup(desc);
694- } else {
695- newres->error_reason = ne_strdup(status->reason_phrase);
696- }
697- newres->type = resr_error;
698- }
699-
700- if (isexec && strcasecmp(isexec, "T") == 0) {
701- newres->is_executable = 1;
702- } else {
703- newres->is_executable = 0;
704- }
705-
706- if (modtime)
707- newres->modtime = ne_httpdate_parse(modtime);
708-
709- if (clength)
710- newres->size = atoi(clength);
711-
712- /* is vcr */
713- if (checkin) {
714- newres->is_vcr = 1;
715- } else if (checkout) {
716- newres->is_vcr = 2;
717- } else {
718- newres->is_vcr = 0;
719- }
720-
dc6aae45 721- for (current = *ctx->resrock, previous = NULL; current != NULL;
aa9c264c
JR
722- previous = current, current = current->next)
723- {
724- if (fetch_compare(current, newres) >= 0) {
725- break;
726- }
727- }
728- if (previous) {
729- previous->next = newres;
730- } else {
dc6aae45 731-/*@-boundswrite -dependenttrans @*/
aa9c264c 732- *ctx->resrock = newres;
dc6aae45 733-/*@=boundswrite =dependenttrans @*/
aa9c264c
JR
734- }
735- newres->next = current;
736-}
737-
738-static int davFetch(const urlinfo u, struct fetch_context_s * ctx)
739- /*@globals internalState @*/
740- /*@modifies ctx, internalState @*/
741-{
742- const char * path = NULL;
743- int depth = 1; /* XXX passed arg? */
744- unsigned int include_target = 0; /* XXX passed arg? */
745- struct fetch_resource_s * resitem = NULL;
746- struct fetch_resource_s ** resrock = &resitem; /* XXX passed arg? */
747- ne_propfind_handler *pfh;
748- struct fetch_resource_s *current, *next;
749- mode_t st_mode;
750- int rc = 0;
751- int xx;
752-
753- (void) urlPath(u->url, &path);
754- pfh = ne_propfind_create(u->sess, ctx->uri, depth);
755-
e9c15efc 756- /* HACK: need to set RPMURL_SERVER_HASRANGE in u->allow here. */
aa9c264c
JR
757-
758- ctx->resrock = resrock;
759- ctx->include_target = include_target;
760-
dc6aae45 761- ne_xml_push_handler(ne_propfind_get_parser(pfh),
aa9c264c
JR
762- fetch_startelm, NULL, NULL, pfh);
763-
764- ne_propfind_set_private(pfh, fetch_create_item, NULL);
765-
766- rc = ne_propfind_named(pfh, fetch_props, fetch_results, ctx);
767-
768- ne_propfind_destroy(pfh);
769-
770- for (current = resitem; current != NULL; current = next) {
771- const char *s, *se;
772- char * val;
773-
774- next = current->next;
775-
776- /* Collections have trailing '/' that needs trim. */
777- /* The top level collection is returned as well. */
778- se = current->uri + strlen(current->uri);
779- if (se[-1] == '/') {
780- if (strlen(current->uri) <= strlen(path)) {
781- current = fetch_destroy_item(current);
782- continue;
783- }
784- se--;
785- }
786- s = se;
787- while (s > current->uri && s[-1] != '/')
788- s--;
789-
790- val = ne_strndup(s, (se - s));
791-
792-/*@-nullpass@*/
793- val = ne_path_unescape(val);
794-/*@=nullpass@*/
795-
796- xx = argvAdd(&ctx->av, val);
797-if (_dav_debug < 0)
798-fprintf(stderr, "*** argvAdd(%p,\"%s\")\n", &ctx->av, val);
6efed78b 799- ne_free(val);
aa9c264c
JR
800-
801- while (ctx->ac >= ctx->nalloced) {
802- if (ctx->nalloced <= 0)
803- ctx->nalloced = 1;
804- ctx->nalloced *= 2;
805- ctx->modes = xrealloc(ctx->modes,
806- (sizeof(*ctx->modes) * ctx->nalloced));
807- ctx->sizes = xrealloc(ctx->sizes,
808- (sizeof(*ctx->sizes) * ctx->nalloced));
809- ctx->mtimes = xrealloc(ctx->mtimes,
810- (sizeof(*ctx->mtimes) * ctx->nalloced));
811- }
812-
813- switch (current->type) {
814- case resr_normal:
815- st_mode = S_IFREG;
816- /*@switchbreak@*/ break;
817- case resr_collection:
818- st_mode = S_IFDIR;
819- /*@switchbreak@*/ break;
820- case resr_reference:
821- case resr_error:
822- default:
823- st_mode = 0;
824- /*@switchbreak@*/ break;
825- }
826-/*@-boundswrite@*/
827- ctx->modes[ctx->ac] = st_mode;
828- ctx->sizes[ctx->ac] = current->size;
829- ctx->mtimes[ctx->ac] = current->modtime;
830-/*@=boundswrite@*/
831- ctx->ac++;
832-
833- current = fetch_destroy_item(current);
834- }
835- ctx->resrock = NULL; /* HACK: avoid leaving stack reference. */
e9c15efc
JB
836- /* HACK realloc to truncate modes/sizes/mtimes */
837-
838- return rc;
839-}
840-
841-/* HACK this should be rewritten to use davReq/davResp w callbacks. */
842-static int davHEAD(urlinfo u, struct stat *st)
843- /*@modifies *st @*/
844-{
845- ne_request *req;
846- const char *htag;
847- const char *value = NULL;
848- int rc;
849-
850- st->st_mode = S_IFREG;
851- st->st_blksize = 4 * 1024; /* HACK correct for linux ext */
852- st->st_size = -1;
853- st->st_atime = -1;
854- st->st_mtime = -1;
855- st->st_ctime = -1;
856-
857- req = ne_request_create(u->sess, "HEAD", u->url);
858-
859- rc = ne_request_dispatch(req);
860- switch (rc) {
861- default:
862- goto exit;
863- /*@notreached@*/
864- case NE_OK:
865- if (ne_get_status(req)->klass != 2) {
866- rc = NE_ERROR;
867- goto exit;
868- }
869- break;
870- }
aa9c264c 871-
e9c15efc
JB
872-#ifdef NOTYET
873- htag = "ETag";
874- value = ne_get_response_header(req, htag);
875- if (value) {
876- /* inode-size-mtime */
877- }
878-#endif
879-
880- htag = "Content-Length";
881-#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
882- value = ne_get_response_header(req, htag);
883-#endif
884- if (value) {
885- st->st_size = strtoll(value, NULL, 10);
886- st->st_blocks = (st->st_size + 511)/512;
887- }
888-
889- htag = "Last-Modified";
890-#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
891- value = ne_get_response_header(req, htag);
892-#endif
893- if (value) {
894- st->st_mtime = ne_httpdate_parse(value);
895- st->st_atime = st->st_ctime = st->st_mtime; /* HACK */
896- }
897-
898-exit:
899- ne_request_destroy(req);
aa9c264c
JR
900- return rc;
901-}
902-
903-static int davNLST(struct fetch_context_s * ctx)
904- /*@globals internalState @*/
905- /*@modifies ctx, internalState @*/
906-{
907- urlinfo u = NULL;
908- int rc;
909- int xx;
910-
911- rc = davInit(ctx->uri, &u);
912- if (rc || u == NULL)
913- goto exit;
914-
e9c15efc
JB
915-/* HACK do PROPFIND through davFetch iff enabled, otherwise HEAD Content-length/ETag/Last-Modified */
916- if (u->allow & RPMURL_SERVER_HASDAV)
917- rc = davFetch(u, ctx); /* use PROPFIND to get contentLength */
918- else
919- rc = davHEAD(u, ctx->st); /* use HEAD to get contentLength */
920-
aa9c264c
JR
921- switch (rc) {
922- case NE_OK:
923- break;
924- case NE_ERROR:
e9c15efc
JB
925- /* HACK: "405 Method Not Allowed" for PROPFIND on non-DAV servers. */
926- /* XXX #206066 OPTIONS is ok, but PROPFIND from Stat() fails. */
927- /* rpm -qp --rpmiodebug --davdebug http://people.freedesktop.org/~sandmann/metacity-2.16.0-2.fc6/i386/metacity-2.16.0-2.fc6.i386.rpm */
aa9c264c
JR
928- /* HACK: "301 Moved Permanently" on empty subdir. */
929- if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
930- break;
931- /*@fallthrough@*/
932- default:
933-if (_dav_debug)
934-fprintf(stderr, "*** Fetch from %s:%d failed:\n\t%s\n",
935- u->host, u->port, ne_get_error(u->sess));
936- break;
937- }
938-
939-exit:
e9c15efc 940- xx = davFree(u);
aa9c264c
JR
941- return rc;
942-}
943-
944-/* =============================================================== */
945-static int my_result(const char * msg, int ret, /*@null@*/ FILE * fp)
946- /*@modifies *fp @*/
947-{
948- /* HACK: don't print unless debugging. */
949- if (_dav_debug >= 0)
950- return ret;
951- if (fp == NULL)
952- fp = stderr;
953- if (msg != NULL)
954- fprintf(fp, "*** %s: ", msg);
955-
956- /* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */
957-#ifdef HACK
958- fprintf(fp, "%s: %s\n", ftpStrerror(-ret), ne_get_error(sess));
959-#else
960- fprintf(fp, "%s\n", ftpStrerror(-ret));
961-#endif
962- return ret;
963-}
964-
965-#ifdef DYING
966-static void hexdump(const unsigned char * buf, ssize_t len)
967- /*@*/
968-{
969- int i;
970- if (len <= 0)
971- return;
972- for (i = 0; i < len; i++) {
973- if (i != 0 && (i%16) == 0)
974- fprintf(stderr, "\n");
975- fprintf(stderr, " %02X", buf[i]);
976- }
977- fprintf(stderr, "\n");
978-}
979-#endif
980-
dc6aae45 981-/*@-mustmod@*/
aa9c264c
JR
982-static void davAcceptRanges(void * userdata, /*@null@*/ const char * value)
983- /*@modifies userdata @*/
984-{
985- urlinfo u = userdata;
986-
dc6aae45 987- if (!(u != NULL && value != NULL)) return;
aa9c264c
JR
988-if (_dav_debug < 0)
989-fprintf(stderr, "*** u %p Accept-Ranges: %s\n", u, value);
990- if (!strcmp(value, "bytes"))
e9c15efc 991- u->allow |= RPMURL_SERVER_HASRANGE;
aa9c264c 992- if (!strcmp(value, "none"))
e9c15efc 993- u->allow &= ~RPMURL_SERVER_HASRANGE;
aa9c264c 994-}
dc6aae45 995-/*@=mustmod@*/
aa9c264c
JR
996-
997-#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
998-static void davAllHeaders(void * userdata, const char * value)
999-{
1000- FD_t ctrl = userdata;
1001-
dc6aae45 1002- if (!(ctrl != NULL && value != NULL)) return;
aa9c264c
JR
1003-if (_dav_debug)
1004-fprintf(stderr, "<- %s\n", value);
1005-}
1006-#endif
1007-
dc6aae45 1008-/*@-mustmod@*/
aa9c264c
JR
1009-static void davContentLength(void * userdata, /*@null@*/ const char * value)
1010- /*@modifies userdata @*/
1011-{
1012- FD_t ctrl = userdata;
1013-
dc6aae45 1014- if (!(ctrl != NULL && value != NULL)) return;
aa9c264c
JR
1015-if (_dav_debug < 0)
1016-fprintf(stderr, "*** fd %p Content-Length: %s\n", ctrl, value);
1017-/*@-unrecog@*/
1018- ctrl->contentLength = strtoll(value, NULL, 10);
1019-/*@=unrecog@*/
1020-}
dc6aae45 1021-/*@=mustmod@*/
aa9c264c 1022-
dc6aae45 1023-/*@-mustmod@*/
aa9c264c
JR
1024-static void davConnection(void * userdata, /*@null@*/ const char * value)
1025- /*@modifies userdata @*/
1026-{
1027- FD_t ctrl = userdata;
1028-
dc6aae45 1029- if (!(ctrl != NULL && value != NULL)) return;
aa9c264c
JR
1030-if (_dav_debug < 0)
1031-fprintf(stderr, "*** fd %p Connection: %s\n", ctrl, value);
1032- if (!strcasecmp(value, "close"))
1033- ctrl->persist = 0;
1034- else if (!strcasecmp(value, "Keep-Alive"))
1035- ctrl->persist = 1;
1036-}
dc6aae45 1037-/*@=mustmod@*/
aa9c264c
JR
1038-
1039-/*@-mustmod@*/ /* HACK: stash error in *str. */
1040-int davResp(urlinfo u, FD_t ctrl, /*@unused@*/ char *const * str)
1041-{
1042- int rc = 0;
1043-
1044- rc = ne_begin_request(ctrl->req);
1045- rc = my_result("ne_begin_req(ctrl->req)", rc, NULL);
1046-
1047-if (_dav_debug < 0)
1048-fprintf(stderr, "*** davResp(%p,%p,%p) sess %p req %p rc %d\n", u, ctrl, str, u->sess, ctrl->req, rc);
1049-
1050- /* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */
1051-/*@-observertrans@*/
1052- if (rc)
1053- fdSetSyserrno(ctrl, errno, ftpStrerror(-rc));
1054-/*@=observertrans@*/
1055-
1056- return rc;
1057-}
1058-/*@=mustmod@*/
1059-
1060-int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg)
1061-{
1062- urlinfo u;
1063- int rc = 0;
1064-
1065-assert(ctrl != NULL);
1066- u = ctrl->url;
1067- URLSANE(u);
1068-
1069-if (_dav_debug < 0)
1070-fprintf(stderr, "*** davReq(%p,%s,\"%s\") entry sess %p req %p\n", ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req);
1071-
1072- ctrl->persist = (u->httpVersion > 0 ? 1 : 0);
1073- ctrl = fdLink(ctrl, "open ctrl (davReq)");
1074-
1075-assert(u->sess != NULL);
1076-assert(ctrl->req == NULL);
1077-/*@-nullpass@*/
1078- ctrl->req = ne_request_create(u->sess, httpCmd, httpArg);
1079-/*@=nullpass@*/
1080-assert(ctrl->req != NULL);
1081-
1082- ne_set_request_private(ctrl->req, "fd", ctrl);
1083-
1084-#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
1085- ne_add_response_header_catcher(ctrl->req, davAllHeaders, ctrl);
1086-
1087- ne_add_response_header_handler(ctrl->req, "Content-Length",
1088- davContentLength, ctrl);
1089- ne_add_response_header_handler(ctrl->req, "Connection",
1090- davConnection, ctrl);
1091-#endif
1092-
1093- if (!strcmp(httpCmd, "PUT")) {
17a083bf 1094-#if defined(HAVE_NEON_NE_SEND_REQUEST_CHUNK)
aa9c264c
JR
1095- ctrl->wr_chunked = 1;
1096- ne_add_request_header(ctrl->req, "Transfer-Encoding", "chunked");
1097- ne_set_request_chunked(ctrl->req, 1);
1098- /* HACK: no retries if/when chunking. */
1099- rc = davResp(u, ctrl, NULL);
1100-#else
1101- rc = FTPERR_SERVER_IO_ERROR;
1102-#endif
1103- } else {
1104- /* HACK: possible Last-Modified: Tue, 02 Nov 2004 14:29:36 GMT */
1105- /* HACK: possible ETag: "inode-size-mtime" */
1106-#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
1107- ne_add_response_header_handler(ctrl->req, "Accept-Ranges",
1108- davAcceptRanges, u);
1109-#endif
1110- /* HACK: possible Transfer-Encoding: on GET. */
1111-
1112- /* HACK: other errors may need retry too. */
1113- /* HACK: neon retries once, gud enuf. */
1114- /* HACK: retry counter? */
1115- do {
1116- rc = davResp(u, ctrl, NULL);
1117- } while (rc == NE_RETRY);
1118- }
1119- if (rc)
1120- goto errxit;
1121-
1122-if (_dav_debug < 0)
1123-fprintf(stderr, "*** davReq(%p,%s,\"%s\") exit sess %p req %p rc %d\n", ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req, rc);
1124-
1125-#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
1126- davContentLength(ctrl,
1127- ne_get_response_header(ctrl->req, "Content-Length"));
1128- davConnection(ctrl,
1129- ne_get_response_header(ctrl->req, "Connection"));
1130- if (strcmp(httpCmd, "PUT"))
1131- davAcceptRanges(u,
1132- ne_get_response_header(ctrl->req, "Accept-Ranges"));
1133-#endif
1134-
1135- ctrl = fdLink(ctrl, "open data (davReq)");
1136- return 0;
1137-
1138-errxit:
1139-/*@-observertrans@*/
1140- fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
1141-/*@=observertrans@*/
1142-
1143- /* HACK balance fd refs. ne_session_destroy to tear down non-keepalive? */
1144- ctrl = fdLink(ctrl, "error data (davReq)");
1145-
1146- return rc;
1147-}
1148-
1149-FD_t davOpen(const char * url, /*@unused@*/ int flags,
1150- /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
1151-{
1152- const char * path = NULL;
1153- urltype urlType = urlPath(url, &path);
1154- urlinfo u = NULL;
1155- FD_t fd = NULL;
1156- int rc;
1157-
1158-#if 0 /* XXX makeTempFile() heartburn */
1159- assert(!(flags & O_RDWR));
1160-#endif
1161-
1162-if (_dav_debug < 0)
1163-fprintf(stderr, "*** davOpen(%s,0x%x,0%o,%p)\n", url, flags, mode, uret);
1164- rc = davInit(url, &u);
1165- if (rc || u == NULL || u->sess == NULL)
1166- goto exit;
1167-
1168- if (u->ctrl == NULL)
1169- u->ctrl = fdNew("persist ctrl (davOpen)");
1170- if (u->ctrl->nrefs > 2 && u->data == NULL)
1171- u->data = fdNew("persist data (davOpen)");
1172-
1173- if (u->ctrl->url == NULL)
1174- fd = fdLink(u->ctrl, "grab ctrl (davOpen persist ctrl)");
1175- else if (u->data->url == NULL)
1176- fd = fdLink(u->data, "grab ctrl (davOpen persist data)");
1177- else
1178- fd = fdNew("grab ctrl (davOpen)");
1179-
1180- if (fd) {
dc6aae45 1181- fdSetOpen(fd, url, flags, mode);
aa9c264c 1182- fdSetIo(fd, ufdio);
dc6aae45 1183-
aa9c264c
JR
1184- fd->ftpFileDoneNeeded = 0;
1185- fd->rd_timeoutsecs = httpTimeoutSecs;
1186- fd->contentLength = fd->bytesRemain = -1;
1187- fd->url = urlLink(u, "url (davOpen)");
1188- fd = fdLink(fd, "grab data (davOpen)");
1189-assert(urlType == URL_IS_HTTPS || urlType == URL_IS_HTTP || urlType == URL_IS_HKP);
1190- fd->urlType = urlType;
1191- }
1192-
1193-exit:
1194-/*@-boundswrite@*/
1195- if (uret)
1196- *uret = u;
1197-/*@=boundswrite@*/
1198- /*@-refcounttrans@*/
1199- return fd;
1200- /*@=refcounttrans@*/
1201-}
1202-
1203-ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
1204-{
1205- FD_t fd = cookie;
1206- ssize_t rc;
1207-
1208-#if 0
1209-assert(count >= 128); /* HACK: see ne_request.h comment */
1210-#endif
1211- rc = ne_read_response_block(fd->req, buf, count);
1212-
1213-if (_dav_debug < 0) {
55217583 1214-fprintf(stderr, "*** davRead(%p,%p,0x%x) rc 0x%x\n", cookie, buf, (unsigned)count, (unsigned)rc);
aa9c264c
JR
1215-#ifdef DYING
1216-hexdump(buf, rc);
1217-#endif
1218- }
1219-
1220- return rc;
1221-}
1222-
1223-ssize_t davWrite(void * cookie, const char * buf, size_t count)
1224-{
ace8a5cc 1225-#if !defined(NEONBLOWSCHUNKS) || defined(HAVE_NEON_NE_SEND_REQUEST_CHUNK) || defined(__LCLINT__)
aa9c264c 1226- FD_t fd = cookie;
ace8a5cc 1227-#endif
aa9c264c 1228- ssize_t rc;
ace8a5cc 1229- int xx = -1;
aa9c264c 1230-
dc6aae45 1231-#if !defined(NEONBLOWSCHUNKS)
17a083bf
JB
1232- ne_session * sess;
1233-
1234-assert(fd->req != NULL);
1235- sess = ne_get_session(fd->req);
1236-assert(sess != NULL);
1237-
1238- /* HACK: include ne_private.h to access sess->socket for now. */
1239- xx = ne_sock_fullwrite(sess->socket, buf, count);
1240-#else
dc6aae45 1241-#if defined(HAVE_NEON_NE_SEND_REQUEST_CHUNK) || defined(__LCLINT__)
aa9c264c
JR
1242-assert(fd->req != NULL);
1243- xx = ne_send_request_chunk(fd->req, buf, count);
17a083bf
JB
1244-#else
1245- errno = EIO; /* HACK */
1246- return -1;
1247-#endif
1248-#endif
aa9c264c
JR
1249-
1250- /* HACK: stupid error impedence matching. */
1251- rc = (xx == 0 ? count : -1);
1252-
1253-if (_dav_debug < 0)
55217583 1254-fprintf(stderr, "*** davWrite(%p,%p,0x%x) rc 0x%x\n", cookie, buf, (unsigned)count, (unsigned)rc);
aa9c264c
JR
1255-#ifdef DYING
1256-if (count > 0)
1257-hexdump(buf, count);
1258-#endif
1259-
1260- return rc;
aa9c264c
JR
1261-}
1262-
1263-int davSeek(void * cookie, /*@unused@*/ _libio_pos_t pos, int whence)
1264-{
1265-if (_dav_debug < 0)
1266-fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence);
1267- return -1;
1268-}
1269-
1270-/*@-mustmod@*/ /* HACK: fd->req is modified. */
1271-int davClose(void * cookie)
1272-{
1273-/*@-onlytrans@*/
1274- FD_t fd = cookie;
1275-/*@=onlytrans@*/
1276- int rc;
1277-
1278-assert(fd->req != NULL);
1279- rc = ne_end_request(fd->req);
1280- rc = my_result("ne_end_request(req)", rc, NULL);
1281-
1282- ne_request_destroy(fd->req);
1283- fd->req = NULL;
1284-
1285-if (_dav_debug < 0)
1286-fprintf(stderr, "*** davClose(%p) rc %d\n", fd, rc);
1287- return rc;
1288-}
1289-/*@=mustmod@*/
1290-
1291-/* =============================================================== */
1292-int davMkdir(const char * path, mode_t mode)
1293-{
1294- urlinfo u = NULL;
1295- const char * src = NULL;
1296- int rc;
1297-
1298- rc = davInit(path, &u);
1299- if (rc)
1300- goto exit;
1301-
1302- (void) urlPath(path, &src);
1303-
1304- rc = ne_mkcol(u->sess, path);
1305-
1306- if (rc) rc = -1; /* XXX HACK: errno impedance match */
1307-
1308- /* XXX HACK: verify getrestype(remote) == resr_collection */
1309-
1310-exit:
1311-if (_dav_debug)
1312-fprintf(stderr, "*** davMkdir(%s,0%o) rc %d\n", path, mode, rc);
1313- return rc;
1314-}
1315-
1316-int davRmdir(const char * path)
1317-{
1318- urlinfo u = NULL;
1319- const char * src = NULL;
1320- int rc;
1321-
1322- rc = davInit(path, &u);
1323- if (rc)
1324- goto exit;
1325-
1326- (void) urlPath(path, &src);
1327-
1328- /* XXX HACK: only getrestype(remote) == resr_collection */
1329-
1330- rc = ne_delete(u->sess, path);
1331-
1332- if (rc) rc = -1; /* XXX HACK: errno impedance match */
1333-
1334-exit:
1335-if (_dav_debug)
1336-fprintf(stderr, "*** davRmdir(%s) rc %d\n", path, rc);
1337- return rc;
1338-}
1339-
1340-int davRename(const char * oldpath, const char * newpath)
1341-{
1342- urlinfo u = NULL;
1343- const char * src = NULL;
1344- const char * dst = NULL;
1345- int overwrite = 1; /* HACK: set this correctly. */
1346- int rc;
1347-
1348- rc = davInit(oldpath, &u);
1349- if (rc)
1350- goto exit;
1351-
1352- (void) urlPath(oldpath, &src);
1353- (void) urlPath(newpath, &dst);
1354-
1355- /* XXX HACK: only getrestype(remote) != resr_collection */
1356-
1357- rc = ne_move(u->sess, overwrite, src, dst);
1358-
1359- if (rc) rc = -1; /* XXX HACK: errno impedance match */
1360-
1361-exit:
1362-if (_dav_debug)
1363-fprintf(stderr, "*** davRename(%s,%s) rc %d\n", oldpath, newpath, rc);
1364- return rc;
1365-}
1366-
1367-int davUnlink(const char * path)
1368-{
1369- urlinfo u = NULL;
1370- const char * src = NULL;
1371- int rc;
1372-
1373- rc = davInit(path, &u);
1374- if (rc)
1375- goto exit;
1376-
1377- (void) urlPath(path, &src);
1378-
1379- /* XXX HACK: only getrestype(remote) != resr_collection */
1380-
1381- rc = ne_delete(u->sess, src);
1382-
1383-exit:
1384- if (rc) rc = -1; /* XXX HACK: errno impedance match */
1385-
1386-if (_dav_debug)
1387-fprintf(stderr, "*** davUnlink(%s) rc %d\n", path, rc);
1388- return rc;
1389-}
1390-
1391-#ifdef NOTYET
1392-static int davChdir(const char * path)
1393- /*@globals h_errno, fileSystem, internalState @*/
1394- /*@modifies fileSystem, internalState @*/
1395-{
1396- return davCommand("CWD", path, NULL);
1397-}
1398-#endif /* NOTYET */
1399-
1400-/* =============================================================== */
1401-
1402-static const char * statstr(const struct stat * st,
1403- /*@returned@*/ /*@out@*/ char * buf)
1404- /*@modifies *buf @*/
1405-{
1406- sprintf(buf,
1407- "*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n",
1408- (unsigned)st->st_dev,
1409- (unsigned)st->st_ino,
1410- st->st_mode,
1411- (unsigned)st->st_nlink,
1412- st->st_uid,
1413- st->st_gid,
1414- (unsigned)st->st_rdev,
1415- (unsigned)st->st_size);
1416- return buf;
1417-}
1418-
1419-/*@unchecked@*/
ace8a5cc 1420-static unsigned int dav_st_ino = 0xdead0000;
aa9c264c
JR
1421-
1422-/*@-boundswrite@*/
1423-int davStat(const char * path, /*@out@*/ struct stat *st)
1424- /*@globals dav_st_ino, fileSystem, internalState @*/
1425- /*@modifies *st, dav_st_ino, fileSystem, internalState @*/
1426-{
1427- struct fetch_context_s * ctx = NULL;
1428- char buf[1024];
1429- int rc = -1;
1430-
1431-/* HACK: neon really wants collections with trailing '/' */
e9c15efc 1432- ctx = fetch_create_context(path, st);
aa9c264c 1433- if (ctx == NULL) {
ace8a5cc 1434-fprintf(stderr, "==> %s fetch_create_context ctx %p\n", "davStat", ctx);
aa9c264c
JR
1435-/* HACK: errno = ??? */
1436- goto exit;
1437- }
1438- rc = davNLST(ctx);
1439- if (rc) {
1440-/* HACK: errno = ??? */
1441- goto exit;
1442- }
1443-
e9c15efc
JB
1444- if (st->st_mode == 0)
1445- st->st_mode = (ctx->ac > 1 ? S_IFDIR : S_IFREG);
1446- st->st_size = (ctx->sizes ? ctx->sizes[0] : st->st_size);
1447- st->st_mtime = (ctx->mtimes ? ctx->mtimes[0] : st->st_mtime);
1448- st->st_atime = st->st_ctime = st->st_mtime; /* HACK */
aa9c264c
JR
1449- if (S_ISDIR(st->st_mode)) {
1450- st->st_nlink = 2;
1451- st->st_mode |= 0755;
1452- } else
1453- if (S_ISREG(st->st_mode)) {
1454- st->st_nlink = 1;
1455- st->st_mode |= 0644;
dc6aae45 1456- }
aa9c264c
JR
1457-
1458- /* XXX fts(3) needs/uses st_ino, make something up for now. */
1459- if (st->st_ino == 0)
1460- st->st_ino = dav_st_ino++;
e9c15efc
JB
1461-
1462-exit:
aa9c264c
JR
1463-if (_dav_debug < 0)
1464-fprintf(stderr, "*** davStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
aa9c264c
JR
1465- ctx = fetch_destroy_context(ctx);
1466- return rc;
1467-}
1468-/*@=boundswrite@*/
1469-
1470-/*@-boundswrite@*/
1471-int davLstat(const char * path, /*@out@*/ struct stat *st)
1472- /*@globals dav_st_ino, fileSystem, internalState @*/
1473- /*@modifies *st, dav_st_ino, fileSystem, internalState @*/
1474-{
1475- struct fetch_context_s * ctx = NULL;
1476- char buf[1024];
1477- int rc = -1;
1478-
1479-/* HACK: neon really wants collections with trailing '/' */
e9c15efc 1480- ctx = fetch_create_context(path, st);
aa9c264c
JR
1481- if (ctx == NULL) {
1482-/* HACK: errno = ??? */
1483- goto exit;
1484- }
1485- rc = davNLST(ctx);
1486- if (rc) {
1487-/* HACK: errno = ??? */
1488- goto exit;
1489- }
1490-
e9c15efc
JB
1491- if (st->st_mode == 0)
1492- st->st_mode = (ctx->ac > 1 ? S_IFDIR : S_IFREG);
1493- st->st_size = (ctx->sizes ? ctx->sizes[0] : st->st_size);
1494- st->st_mtime = (ctx->mtimes ? ctx->mtimes[0] : st->st_mtime);
1495- st->st_atime = st->st_ctime = st->st_mtime; /* HACK */
aa9c264c
JR
1496- if (S_ISDIR(st->st_mode)) {
1497- st->st_nlink = 2;
1498- st->st_mode |= 0755;
1499- } else
1500- if (S_ISREG(st->st_mode)) {
1501- st->st_nlink = 1;
1502- st->st_mode |= 0644;
dc6aae45 1503- }
aa9c264c
JR
1504-
1505- /* XXX fts(3) needs/uses st_ino, make something up for now. */
1506- if (st->st_ino == 0)
1507- st->st_ino = dav_st_ino++;
1508-if (_dav_debug < 0)
1509-fprintf(stderr, "*** davLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
1510-exit:
1511- ctx = fetch_destroy_context(ctx);
1512- return rc;
1513-}
1514-/*@=boundswrite@*/
1515-
1516-#ifdef NOTYET
1517-static int davReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
1518- /*@globals h_errno, fileSystem, internalState @*/
1519- /*@modifies *buf, fileSystem, internalState @*/
1520-{
1521- int rc;
1522- rc = davNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
1523-if (_dav_debug < 0)
1524-fprintf(stderr, "*** davReadlink(%s) rc %d\n", path, rc);
1525- return rc;
1526-}
1527-#endif /* NOTYET */
1528-
ace8a5cc 1529 /* =============================================================== */
aa9c264c
JR
1530 /*@unchecked@*/
1531 int avmagicdir = 0x3607113;
ace8a5cc
ER
1532@@ -1660,179 +145,3 @@
1533 /*@=kepttrans@*/
aa9c264c
JR
1534 }
1535 /*@=boundswrite@*/
ace8a5cc 1536-
aa9c264c
JR
1537-/* =============================================================== */
1538-/*@unchecked@*/
1539-int davmagicdir = 0x8440291;
1540-
1541-int davClosedir(/*@only@*/ DIR * dir)
1542-{
1543- DAVDIR avdir = (DAVDIR)dir;
1544-
1545-if (_dav_debug < 0)
1546-fprintf(stderr, "*** davClosedir(%p)\n", avdir);
1547-
1548-#if defined(HAVE_PTHREAD_H)
1549-/*@-moduncon -noeffectuncon @*/
1550- (void) pthread_mutex_destroy(&avdir->lock);
1551-/*@=moduncon =noeffectuncon @*/
1552-#endif
1553-
1554- avdir = _free(avdir);
1555- return 0;
1556-}
1557-
1558-struct dirent * davReaddir(DIR * dir)
1559-{
1560- DAVDIR avdir = (DAVDIR)dir;
1561- struct dirent * dp;
1562- const char ** av;
1563- unsigned char * dt;
1564- int ac;
1565- int i;
1566-
1567- if (avdir == NULL || !ISDAVMAGIC(avdir) || avdir->data == NULL) {
1568- /* XXX TODO: EBADF errno. */
1569- return NULL;
1570- }
1571-
1572- dp = (struct dirent *) avdir->data;
1573- av = (const char **) (dp + 1);
1574- ac = avdir->size;
ace8a5cc 1575- dt = (unsigned char *) (av + (ac + 1));
aa9c264c
JR
1576- i = avdir->offset + 1;
1577-
1578-/*@-boundsread@*/
1579- if (i < 0 || i >= ac || av[i] == NULL)
1580- return NULL;
1581-/*@=boundsread@*/
1582-
1583- avdir->offset = i;
1584-
1585- /* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
1586-/*@-type@*/
1587- dp->d_ino = i + 1; /* W2DO? */
1588- dp->d_reclen = 0; /* W2DO? */
1589-
dc6aae45 1590-#if !(defined(hpux) || defined(__hpux) || defined(sun))
ace8a5cc 1591-#if !defined(__APPLE__) && !defined(__FreeBSD_kernel__) && !defined(__FreeBSD__)
aa9c264c
JR
1592- dp->d_off = 0; /* W2DO? */
1593-#endif
1594-/*@-boundsread@*/
1595- dp->d_type = dt[i];
1596-/*@=boundsread@*/
1597-#endif
1598-/*@=type@*/
1599-
1600- strncpy(dp->d_name, av[i], sizeof(dp->d_name));
1601-if (_dav_debug < 0)
1602-fprintf(stderr, "*** davReaddir(%p) %p \"%s\"\n", (void *)avdir, dp, dp->d_name);
dc6aae45 1603-
aa9c264c
JR
1604- return dp;
1605-}
1606-
1607-/*@-boundswrite@*/
1608-DIR * davOpendir(const char * path)
1609-{
1610- struct fetch_context_s * ctx;
1611- DAVDIR avdir;
1612- struct dirent * dp;
1613- size_t nb;
1614- const char ** av, ** nav;
1615- unsigned char * dt;
1616- char * t;
1617- int ac, nac;
1618- int rc;
e9c15efc 1619-
aa9c264c
JR
1620- /* HACK: glob does not pass dirs with trailing '/' */
1621- nb = strlen(path)+1;
1622-/*@-branchstate@*/
1623- if (path[nb-1] != '/') {
1624- char * npath = alloca(nb+1);
1625- *npath = '\0';
1626- (void) stpcpy( stpcpy(npath, path), "/");
1627- path = npath;
1628- }
1629-/*@=branchstate@*/
1630-
1631-if (_dav_debug < 0)
1632-fprintf(stderr, "*** davOpendir(%s)\n", path);
1633-
1634- /* Load DAV collection into argv. */
e9c15efc 1635- ctx = fetch_create_context(path, NULL);
aa9c264c
JR
1636- if (ctx == NULL) {
1637-/* HACK: errno = ??? */
1638- return NULL;
1639- }
1640- rc = davNLST(ctx);
1641- if (rc) {
1642-/* HACK: errno = ??? */
1643- return NULL;
1644- }
1645-
1646- nb = 0;
1647- ac = 0;
1648- av = ctx->av;
1649- if (av != NULL)
1650- while (av[ac] != NULL)
1651- nb += strlen(av[ac++]) + 1;
1652- ac += 2; /* for "." and ".." */
1653- nb += sizeof(".") + sizeof("..");
1654-
1655- nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
1656- avdir = xcalloc(1, nb);
1657- /*@-abstract@*/
1658- dp = (struct dirent *) (avdir + 1);
1659- nav = (const char **) (dp + 1);
ace8a5cc 1660- dt = (unsigned char *) (nav + (ac + 1));
aa9c264c
JR
1661- t = (char *) (dt + ac + 1);
1662- /*@=abstract@*/
1663-
1664- avdir->fd = davmagicdir;
1665-/*@-usereleased@*/
1666- avdir->data = (char *) dp;
1667-/*@=usereleased@*/
1668- avdir->allocation = nb;
1669- avdir->size = ac;
1670- avdir->offset = -1;
1671- avdir->filepos = 0;
1672-
1673-#if defined(HAVE_PTHREAD_H)
1674-/*@-moduncon -noeffectuncon -nullpass @*/
1675- (void) pthread_mutex_init(&avdir->lock, NULL);
1676-/*@=moduncon =noeffectuncon =nullpass @*/
1677-#endif
1678-
1679- nac = 0;
1680-/*@-dependenttrans -unrecog@*/
1681- dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, "."); t++;
1682- dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, ".."); t++;
1683-/*@=dependenttrans =unrecog@*/
1684-
1685- /* Copy DAV items into DIR elments. */
1686- ac = 0;
1687- if (av != NULL)
1688- while (av[ac] != NULL) {
1689- nav[nac] = t;
1690- dt[nac] = (S_ISDIR(ctx->modes[ac]) ? DT_DIR : DT_REG);
1691- t = stpcpy(t, av[ac]);
1692- ac++;
1693- t++;
1694- nac++;
1695- }
1696- nav[nac] = NULL;
1697-
1698- ctx = fetch_destroy_context(ctx);
1699-
1700-/*@-kepttrans@*/
1701- return (DIR *) avdir;
1702-/*@=kepttrans@*/
1703-}
1704-/*@=modfilesys@*/
ace8a5cc
ER
1705-
1706-char * davRealpath(const char * path, char * resolved_path)
1707-{
1708-assert(resolved_path == NULL); /* XXX no POSIXly broken realpath(3) here. */
1709- /* XXX TODO: handle redirects. For now, just dupe the path. */
1710- return xstrdup(path);
1711-}
1712--- rpm-4.5/rpmio/rpmdav.h 2007-05-25 20:36:36.000000000 +0300
1713+++ rpm-4.4.9/rpmio/rpmdav.h 2008-09-04 17:21:50.369579599 +0300
1714@@ -46,12 +46,6 @@
1c3816b7
AM
1715 extern int avmagicdir;
1716 #define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir)))
1717
1718-/**
1719- */
1720-/*@unchecked@*/
1721-extern int davmagicdir;
1722-#define ISDAVMAGIC(_dir) (!memcmp((_dir), &davmagicdir, sizeof(davmagicdir)))
1723-
1724 #ifdef __cplusplus
1725 extern "C" {
1726 #endif
ace8a5cc 1727@@ -85,133 +79,6 @@
aa9c264c
JR
1728 /*@globals fileSystem, internalState @*/
1729 /*@modifies fileSystem, internalState @*/;
1730
1731-/**
1732- * Send a http request.
1733- * @param ctrl
1734- * @param httpCmd http command
1735- * @param httpArg http command argument (NULL if none)
1736- * @returns 0 on success
1737- */
1738-int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg)
1739- /*@globals fileSystem, internalState @*/
1740- /*@modifies ctrl, fileSystem, internalState @*/;
1741-
1742-/**
1743- * Read a http response.
1744- * @param u
1745- * @param cntl
1746- * @retval *str error msg
1747- * @returns 0 on success
1748- */
dc6aae45 1749-/*@-exportlocal@*/
aa9c264c
JR
1750-int davResp(urlinfo u, FD_t ctrl, /*@out@*/ /*@null@*/ char *const * str)
1751- /*@globals fileSystem, internalState @*/
1752- /*@modifies ctrl, *str, fileSystem, internalState @*/;
dc6aae45 1753-/*@=exportlocal@*/
aa9c264c
JR
1754-
1755-/**
1756- */
1757-/*@null@*/
1758-FD_t davOpen(const char * url, /*@unused@*/ int flags,
1759- /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
1760- /*@globals internalState @*/
1761- /*@modifies *uret, internalState @*/;
1762-
1763-/**
1764- */
1765-/*@-incondefs@*/
1766-ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
1767- /*@globals fileSystem, internalState @*/
1768- /*@modifies buf, fileSystem, internalState @*/
1769- /*@requires maxSet(buf) >= (count - 1) @*/
1770- /*@ensures maxRead(buf) == result @*/;
1771-/*@=incondefs@*/
1772-
1773-/**
1774- */
1775-ssize_t davWrite(void * cookie, const char * buf, size_t count)
1776- /*@globals fileSystem, internalState @*/
1777- /*@modifies fileSystem, internalState @*/;
1778-
1779-/**
1780- */
1781-int davSeek(void * cookie, _libio_pos_t pos, int whence)
1782- /*@globals fileSystem, internalState @*/
1783- /*@modifies fileSystem, internalState @*/;
1784-
1785-/**
1786- */
1787-int davClose(void * cookie)
1788- /*@globals fileSystem, internalState @*/
1789- /*@modifies cookie, fileSystem, internalState @*/;
1790-
1791-/**
1792- */
1793-int davMkdir(const char * path, mode_t mode)
1794- /*@globals fileSystem, internalState @*/
1795- /*@modifies fileSystem, internalState @*/;
1796-
1797-/**
1798- */
1799-int davRmdir(const char * path)
1800- /*@globals fileSystem, internalState @*/
1801- /*@modifies fileSystem, internalState @*/;
1802-
1803-/**
1804- */
1805-int davRename(const char * oldpath, const char * newpath)
1806- /*@globals fileSystem, internalState @*/
1807- /*@modifies fileSystem, internalState @*/;
1808-
1809-/**
1810- */
1811-int davUnlink(const char * path)
1812- /*@globals fileSystem, internalState @*/
1813- /*@modifies fileSystem, internalState @*/;
1814-
1815-/**
1816- * Close a DAV collection.
1817- * @param dir argv DIR
1818- * @return 0 always
1819- */
1820-int davClosedir(/*@only@*/ DIR * dir)
1821- /*@globals fileSystem @*/
1822- /*@modifies dir, fileSystem @*/;
1823-
1824-/**
1825- * Return next entry from a DAV collection.
1826- * @param dir argv DIR
1827- * @return next entry
1828- */
1829-/*@dependent@*/ /*@null@*/
1830-struct dirent * davReaddir(DIR * dir)
1831- /*@globals fileSystem @*/
1832- /*@modifies fileSystem @*/;
1833-
1834-/**
1835- * Create an argv directory from DAV collection.
1836- * @param path URL for DAV collection path
1837- * @return argv DIR
1838- */
1839-/*@null@*/
1840-DIR * davOpendir(const char * path)
1841- /*@globals fileSystem, internalState @*/
1842- /*@modifies fileSystem, internalState @*/;
1843-
1844-/**
1845- * stat(2) clone.
1846- */
1847-int davStat(const char * path, /*@out@*/ struct stat * st)
1848- /*@globals fileSystem, internalState @*/
1849- /*@modifies *st, fileSystem, internalState @*/;
1850-
1851-/**
1852- * lstat(2) clone.
1853- */
1854-int davLstat(const char * path, /*@out@*/ struct stat * st)
1855- /*@globals fileSystem, internalState @*/
1856- /*@modifies *st, fileSystem, internalState @*/;
1857-
1858 #ifdef __cplusplus
1859 }
1860 #endif
a891c6eb
ER
1861--- rpm-4.5/rpmio/rpmio.c 2008-09-04 18:04:37.362241187 +0300
1862+++ rpm-4.5/rpmio/rpmio.c 2008-09-04 18:05:08.695569896 +0300
040cf008
ER
1863@@ -155,11 +155,6 @@
1864 /*@unchecked@*/
1865 int _ftp_debug = 0;
aa9c264c 1866
040cf008
ER
1867-/**
1868- */
1869-/*@unchecked@*/
1870-int _dav_debug = 0;
aa9c264c 1871-
040cf008 1872 /* =============================================================== */
aa9c264c 1873
040cf008 1874 /*@-boundswrite@*/
a891c6eb
ER
1875@@ -386,13 +381,6 @@
1876
1877 fdstat_enter(fd, FDSTAT_READ);
1878 /*@-boundswrite@*/
1879- /* HACK: flimsy wiring for davRead */
1880- if (fd->req != NULL) {
1881- rc = davRead(fd, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
1882- /* XXX Chunked davRead EOF. */
1883- if (rc == 0)
1884- fd->bytesRemain = 0;
1885- } else
1886 rc = read(fdFileno(fd), buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
1887 /*@=boundswrite@*/
1888 fdstat_exit(fd, FDSTAT_READ, rc);
1889@@ -420,10 +408,6 @@
1890
1891 fdstat_enter(fd, FDSTAT_WRITE);
1892 /*@-boundsread@*/
1893- /* HACK: flimsy wiring for davWrite */
1894- if (fd->req != NULL)
1895- rc = davWrite(fd, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
1896- else
1897 rc = write(fdno, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
1898 /*@=boundsread@*/
1899 fdstat_exit(fd, FDSTAT_WRITE, rc);
1900@@ -470,11 +454,6 @@
1901 fdSetFdno(fd, -1);
1902
1903 fdstat_enter(fd, FDSTAT_CLOSE);
1904- /* HACK: flimsy wiring for davClose */
1905-/*@-branchstate@*/
1906- if (fd->req != NULL)
1907- rc = davClose(fd);
1908- else
1909 rc = ((fdno >= 0) ? close(fdno) : -2);
1910 /*@=branchstate@*/
1911 fdstat_exit(fd, FDSTAT_CLOSE, rc);
1912@@ -544,10 +523,6 @@
1913 FD_ZERO(&wrfds);
1914 #endif
1915
1916- /* HACK: flimsy wiring for davWrite */
1917- if (fd->req != NULL)
1918- return 1;
1919-
1920 if ((fdno = fdFileno(fd)) < 0)
1921 return -1; /* XXX W2DO? */
1922
1923@@ -599,10 +574,6 @@
1924 FD_ZERO(&rdfds);
1925 #endif
1926
1927- /* HACK: flimsy wiring for davRead */
1928- if (fd->req != NULL)
1929- return 1;
1930-
1931 if ((fdno = fdFileno(fd)) < 0)
1932 return -1; /* XXX W2DO? */
1933
1934@@ -2265,29 +2236,6 @@
1935 fd->wr_chunked = 0;
1936 }
1937 break;
1938- case URL_IS_HTTPS:
1939- case URL_IS_HTTP:
1940- case URL_IS_HKP:
1941- fd = davOpen(url, flags, mode, &u);
1942- if (fd == NULL || u == NULL)
1943- break;
1944-
1945- cmd = ((flags & O_WRONLY)
1946- ? ((flags & O_APPEND) ? "PUT" :
1947- ((flags & O_CREAT) ? "PUT" : "PUT"))
1948- : "GET");
1949- u->openError = davReq(fd, cmd, path);
1950- if (u->openError < 0) {
1951- /* XXX make sure that we can exit through ufdClose */
1952- fd = fdLink(fd, "error ctrl (ufdOpen HTTP)");
1953- fd = fdLink(fd, "error data (ufdOpen HTTP)");
1954- } else {
1955- fd->bytesRemain = ((!strcmp(cmd, "GET"))
1956- ? fd->contentLength : -1);
1957- fd->wr_chunked = ((!strcmp(cmd, "PUT"))
1958- ? fd->wr_chunked : 0);
1959- }
1960- break;
1961 case URL_IS_DASH:
1962 assert(!(flags & O_RDWR));
1963 fd = fdDup( ((flags & O_WRONLY) ? STDOUT_FILENO : STDIN_FILENO) );
1964@@ -2911,10 +2859,8 @@
1965 if (fd->nfps > 0 && fpno == -1 &&
1966 fd->fps[fd->nfps-1].io == ufdio &&
1967 fd->fps[fd->nfps-1].fp == fp &&
1968- (fd->fps[fd->nfps-1].fdno >= 0 || fd->req != NULL))
1969+ (fd->fps[fd->nfps-1].fdno >= 0))
1970 {
1971- int hadreqpersist = (fd->req != NULL);
1972-
1973 if (fp)
1974 rc = fflush(fp);
1975 fd->nfps--;
1976@@ -2924,26 +2870,9 @@
1977 /*@-usereleased@*/
1978 if (fdGetFdno(fd) >= 0)
1979 break;
1980- if (!fd->persist)
1981- hadreqpersist = 0;
1982 fdSetFp(fd, NULL);
1983 fd->nfps++;
1984 if (fp) {
1985- /* HACK: flimsy Keepalive wiring. */
1986- if (hadreqpersist) {
1987- fd->nfps--;
1988-/*@-exposetrans@*/
1989- fdSetFp(fd, fp);
1990-/*@=exposetrans@*/
1991-/*@-refcounttrans@*/
1992- (void) fdClose(fd);
1993-/*@=refcounttrans@*/
1994- fdSetFp(fd, NULL);
1995- fd->nfps++;
1996-/*@-refcounttrans@*/
1997- (void) fdClose(fd);
1998-/*@=refcounttrans@*/
1999- } else
2000 rc = fclose(fp);
2001 }
2002 fdPop(fd);
2003@@ -3223,7 +3152,7 @@
2004 if (_rpmio_debug)
2005 fprintf(stderr, "*** Fopen ufdio path %s fmode %s\n", path, fmode);
2006 fd = ufdOpen(path, flags, perms);
2007- if (fd == NULL || !(fdFileno(fd) >= 0 || fd->req != NULL))
2008+ if (fd == NULL || !(fdFileno(fd) >= 0))
2009 return fd;
2010 break;
2011 default:
2012@@ -3234,7 +3163,7 @@
2013 }
2014
2015 /* XXX persistent HTTP/1.1 returns the previously opened fp */
2016- if (isHTTP && ((fp = fdGetFp(fd)) != NULL) && ((fdno = fdGetFdno(fd)) >= 0 || fd->req != NULL))
2017+ if (isHTTP && ((fp = fdGetFp(fd)) != NULL) && ((fdno = fdGetFdno(fd)) >= 0))
2018 {
2019 /*@+voidabstract@*/
2020 fdPush(fd, fpio, fp, fileno(fp)); /* Push fpio onto stack */
2021@@ -3276,10 +3205,6 @@
2022 int i, rc = 0;
2023
2024 if (fd == NULL) return -1;
2025- if (fd->req != NULL) {
2026- /* HACK: flimsy wiring for neon errors. */
2027- rc = (fd->syserrno || fd->errcookie != NULL) ? -1 : 0;
2028- } else
2029 for (i = fd->nfps; rc == 0 && i >= 0; i--) {
2030 /*@-boundsread@*/
2031 FDSTACK_t * fps = &fd->fps[i];
2032@@ -3317,9 +3242,6 @@
2033 {
2034 int i, rc = -1;
2035
2036- if (fd->req != NULL)
2037- rc = 123456789; /* HACK: https has no steenkin fileno. */
2038- else
2039 for (i = fd->nfps ; rc == -1 && i >= 0; i--) {
2040 /*@-boundsread@*/
2041 rc = fd->fps[i].fdno;
040cf008
ER
2042--- rpm-4.5/rpmio/librpmio.vers~ 2008-07-09 12:38:31.000000000 +0300
2043+++ rpm-4.5/rpmio/librpmio.vers 2008-09-04 17:52:56.158976430 +0300
2044@@ -29,25 +29,6 @@
2045 Chmod;
2046 Chown;
2047 Chroot;
2048- davClose;
2049- davClosedir;
2050- _dav_debug;
2051- davLstat;
2052- davmagicdir;
2053- davMkdir;
2054- davOpen;
2055- davOpendir;
2056- davRead;
2057- davReaddir;
2058- davRealpath;
2059- davRename;
2060- davReq;
2061- davResp;
2062- davRmdir;
2063- davSeek;
2064- davStat;
2065- davUnlink;
2066- davWrite;
2067 delMacro;
2068 expandMacros;
2069 Fclose;
2070--- rpm-4.5/lib/poptALL.c~ 2007-10-23 18:53:08.000000000 +0300
2071+++ rpm-4.5/lib/poptALL.c 2008-09-04 17:53:21.845642132 +0300
2072@@ -126,8 +126,6 @@
2073 extern int _ftp_debug;
2074 /*@unchecked@*/
2075 extern int _av_debug;
2076-/*@unchecked@*/
2077-extern int _dav_debug;
aa9c264c 2078
040cf008
ER
2079 /*@unchecked@*/
2080 extern int noLibio;
2081@@ -424,8 +422,6 @@
2082 N_("debug FTP/HTTP data stream"), NULL},
2083 { "avdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_av_debug, -1,
2084 N_("debug argv collections"), NULL},
2085- { "davdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_dav_debug, -1,
2086- N_("debug WebDAV data stream"), NULL},
2087 { "hdrdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_hdr_debug, -1,
2088 NULL, NULL},
2089 { "miredebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_mire_debug, -1,
a891c6eb
ER
2090--- rpm-4.5/rpmio/rpmrpc.c 2008-09-04 17:56:39.132287618 +0300
2091+++ rpm-4.5/rpmio/rpmrpc.c 2008-09-04 17:57:38.618948392 +0300
2092@@ -78,10 +78,6 @@
2093 case URL_IS_FTP:
2094 return ftpMkdir(path, mode);
2095 /*@notreached@*/ break;
2096- case URL_IS_HTTPS:
2097- case URL_IS_HTTP:
2098- return davMkdir(path, mode);
2099- /*@notreached@*/ break;
2100 case URL_IS_PATH:
2101 path = lpath;
2102 /*@fallthrough@*/
2103@@ -105,15 +101,6 @@
2104 case URL_IS_FTP:
2105 return ftpChdir(path);
2106 /*@notreached@*/ break;
2107- case URL_IS_HTTPS:
2108- case URL_IS_HTTP:
2109-#ifdef NOTYET
2110- return davChdir(path);
2111-#else
2112- errno = EINVAL; /* XXX W2DO? */
2113- return -2;
2114-#endif
2115- /*@notreached@*/ break;
2116 case URL_IS_PATH:
2117 path = lpath;
2118 /*@fallthrough@*/
2119@@ -138,10 +125,6 @@
2120 case URL_IS_FTP:
2121 return ftpRmdir(path);
2122 /*@notreached@*/ break;
2123- case URL_IS_HTTPS:
2124- case URL_IS_HTTP:
2125- return davRmdir(path);
2126- /*@notreached@*/ break;
2127 case URL_IS_PATH:
2128 path = lpath;
2129 /*@fallthrough@*/
2130@@ -245,10 +228,6 @@
2131
2132 oldut = urlPath(oldpath, &oe);
2133 switch (oldut) {
2134- case URL_IS_HTTPS:
2135- case URL_IS_HTTP:
2136- return davRename(oldpath, newpath);
2137- /*@notreached@*/ break;
2138 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
2139 case URL_IS_PATH:
2140 case URL_IS_UNKNOWN:
2141@@ -343,10 +322,6 @@
2142 case URL_IS_FTP:
2143 return ftpUnlink(path);
2144 /*@notreached@*/ break;
2145- case URL_IS_HTTPS:
2146- case URL_IS_HTTP:
2147- return davUnlink(path);
2148- /*@notreached@*/ break;
2149 case URL_IS_PATH:
2150 path = lpath;
2151 /*@fallthrough@*/
2152@@ -1354,10 +1329,6 @@
2153 case URL_IS_FTP:
2154 return ftpStat(path, st);
2155 /*@notreached@*/ break;
2156- case URL_IS_HTTPS:
2157- case URL_IS_HTTP:
2158- return davStat(path, st);
2159- /*@notreached@*/ break;
2160 case URL_IS_PATH:
2161 path = lpath;
2162 /*@fallthrough@*/
2163@@ -1384,10 +1355,6 @@
2164 case URL_IS_FTP:
2165 return ftpLstat(path, st);
2166 /*@notreached@*/ break;
2167- case URL_IS_HTTPS:
2168- case URL_IS_HTTP:
2169- return davLstat(path, st);
2170- /*@notreached@*/ break;
2171 case URL_IS_PATH:
2172 path = lpath;
2173 /*@fallthrough@*/
2174@@ -1630,14 +1597,6 @@
2175 case URL_IS_FTP:
2176 return ftpReadlink(path, buf, bufsiz);
2177 /*@notreached@*/ break;
2178- case URL_IS_HTTPS:
2179- case URL_IS_HTTP:
2180-#ifdef NOTYET
2181- return davReadlink(path, buf, bufsiz);
2182-#else
2183- return -2;
2184-#endif
2185- /*@notreached@*/ break;
2186 case URL_IS_PATH:
2187 path = lpath;
2188 /*@fallthrough@*/
2189@@ -1787,10 +1746,6 @@
2190 case URL_IS_FTP:
2191 return ftpOpendir(path);
2192 /*@notreached@*/ break;
2193- case URL_IS_HTTPS:
2194- case URL_IS_HTTP:
2195- return davOpendir(path);
2196- /*@notreached@*/ break;
2197 case URL_IS_PATH:
2198 path = lpath;
2199 /*@fallthrough@*/
2200@@ -1815,8 +1770,6 @@
2201 return NULL;
2202 if (ISAVMAGIC(dir))
2203 return avReaddir(dir);
2204- if (ISDAVMAGIC(dir))
2205- return davReaddir(dir);
2206 return readdir(dir);
2207 }
2208
2209@@ -1828,8 +1781,6 @@
2210 return 0;
2211 if (ISAVMAGIC(dir))
2212 return avClosedir(dir);
2213- if (ISDAVMAGIC(dir))
2214- return davClosedir(dir);
2215 return closedir(dir);
2216 }
2217
2218@@ -1852,14 +1803,6 @@
2219 case URL_IS_FTP:
2220 return ftpRealpath(path, resolved_path);
2221 /*@notreached@*/ break;
2222- case URL_IS_HTTPS:
2223- case URL_IS_HTTP:
2224- case URL_IS_HKP:
2225-#ifdef WITH_NEON
2226- return davRealpath(path, resolved_path);
2227- /*@notreached@*/ break;
2228-#endif
2229- /*@fallthrough@*/
2230 default:
2231 return xstrdup(path);
2232 /*@notreached@*/ break;
2233--- rpm-4.5/./rpmio/rpmio_internal.h~ 2008-06-10 02:19:26.000000000 +0300
2234+++ rpm-4.5/./rpmio/rpmio_internal.h 2008-09-04 18:00:31.015598325 +0300
2235@@ -182,7 +182,6 @@
2236 /*@dependent@*/
2237 void * url; /* ufdio: URL info */
2238 /*@relnull@*/
2239- void * req; /* ufdio: HTTP request */
2240
2241 int rd_timeoutsecs; /* ufdRead: per FD_t timer */
2242 ssize_t bytesRemain; /* ufdio: */
2243--- rpm-4.5/rpmio/rpmurl.h~ 2008-06-10 02:19:26.000000000 +0300
2244+++ rpm-4.5/rpmio/rpmurl.h 2008-09-04 18:14:00.546141703 +0300
2245@@ -54,15 +54,6 @@
2246 /*@relnull@*/
2247 FD_t data; /*!< per-xfer data channel */
2248
2249-/*@relnull@*/
2250- void * capabilities; /*!< neon: ne_server_capabilities ptr */
2251-/*@relnull@*/
2252- void * lockstore; /*!< neon: ne_lock_store ptr */
2253-/*@relnull@*/
2254- void * sess; /*!< neon: ne_session ptr */
2255- off_t current; /*!< neon: current body offset. */
2256- off_t total; /*!< neon: total body length. */
2257- int connstatus; /*!< neon: connection status. */
2258 #ifdef REFERENCE
2259 typedef enum {
2260 ne_conn_namelookup, /* lookup up hostname (info = hostname) */
eb54cc2a
ER
2261--- rpm-4.5/rpmio/url.c~ 2008-06-10 02:19:26.000000000 +0300
2262+++ rpm-4.5/rpmio/url.c 2008-09-04 20:05:19.011716915 +0300
2263@@ -134,7 +134,6 @@
2264 (u->scheme ? u->scheme : ""));
2265 /*@=usereleased@*/
2266 }
2267- xx = davFree(u);
2268 u->buf = _free(u->buf);
2269 u->url = _free(u->url);
2270 u->scheme = _free((void *)u->scheme);
60959c22
ER
2271--- rpm-4.5/perl/Makefile.PL.in~ 2008-10-05 01:31:09.000000000 +0300
2272+++ rpm-4.5/perl/Makefile.PL.in 2008-10-05 01:32:12.688278120 +0300
2273@@ -12,7 +12,7 @@
2274 'NAME' => 'RPM',
2275 'VERSION_FROM' => 'RPM.pm', # finds $VERSION
2276 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1
2277- 'LIBS' => [join(' ', @ldaddp) . ' ' . join(' ', @ldadd) . ' @LIBS@ @WITH_POPT_LIB@ @WITH_BEECRYPT_LIB@ -lneon'],
2278+ 'LIBS' => [join(' ', @ldaddp) . ' ' . join(' ', @ldadd) . ' @LIBS@ @WITH_POPT_LIB@ @WITH_BEECRYPT_LIB@'],
2279 'DEFINE' => join(" ", @defines), # e.g., '-DHAVE_SOMETHING'
2280 'INC' => join(' ', map { '-I@top_srcdir@/'. $_ } @libdir) . ' @CPPFLAGS@',
2281 'TYPEMAPS' => [ 'typemap' ],
This page took 0.462283 seconds and 4 git commands to generate.