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