1 diff -ur rpm-4.4.7.org/configure.ac rpm-4.4.7/configure.ac
2 --- rpm-4.4.7.org/configure.ac 2006-10-17 22:12:03.110624000 +0200
3 +++ rpm-4.4.7/configure.ac 2006-10-17 22:12:43.117124500 +0200
5 AC_SUBST(WITH_BEECRYPT_INCLUDE)
6 AC_SUBST(WITH_BEECRYPT_LIB)
9 -# Check for neon library. Prefer external, otherwise internal.
13 -AC_CHECK_HEADER([neon/ne_session.h], [
14 - AC_CHECK_LIB(neon, ne_session_create, [
15 - AC_DEFINE(HAVE_LIBNEON, 1, [Define to 1 if you have the 'neon' library (-lneon).])
16 - AC_CHECK_LIB(neon, ne_get_response_header, [
17 - AC_DEFINE(HAVE_NEON_NE_GET_RESPONSE_HEADER, 1, [Define to 1 if you have ne_get_response_header() in libneon.])
19 - AC_CHECK_LIB(neon, ne_send_request_chunk, [
20 - AC_DEFINE(HAVE_NEON_NE_SEND_REQUEST_CHUNK, 1, [Define to 1 if you have ne_send_request_chunk() in libneon.])
22 - WITH_NEON_INCLUDE="-I${includedir}/neon"
23 - WITH_NEON_LIB="-lneon"
26 - if test -d neon ; then
27 - AC_DEFINE(HAVE_LIBNEON, 1, [Define to 1 if you have the 'neon' library (-lneon).])
28 -# XXX HAVE_NEON_NE_GET_RESPONSE_HEADER assumes libneon-0.25 devel internal
29 - AC_DEFINE(HAVE_NEON_NE_GET_RESPONSE_HEADER, 1, [Define to 1 if you have ne_get_response_header() in libneon.])
30 - WITH_NEON_SUBDIR=neon
31 - WITH_NEON_INCLUDE="-I\${top_srcdir}/${WITH_NEON_SUBDIR}/src"
32 - WITH_NEON_LIB="\${top_builddir}/${WITH_NEON_SUBDIR}/src/libneon.la"
35 AC_SUBST(WITH_NEON_SUBDIR)
36 AC_SUBST(WITH_NEON_INCLUDE)
37 AC_SUBST(WITH_NEON_LIB)
38 diff -ur rpm-4.4.7.org/rpmio/rpmdav.c rpm-4.4.7/rpmio/rpmdav.c
39 --- rpm-4.4.7.org/rpmio/rpmdav.c 2006-04-17 17:23:29.000000000 +0200
40 +++ rpm-4.4.7/rpmio/rpmdav.c 2006-10-17 22:14:01.150001250 +0200
45 -#include "ne_alloc.h"
47 -#include "ne_basic.h"
48 -#include "ne_dates.h"
49 -#include "ne_locks.h"
51 -#define NEONBLOWSCHUNKS
52 -#ifndef NEONBLOWSCHUNKS
53 -/* HACK: include ne_private.h to access sess->socket for now. */
54 -#include "../neon/src/ne_private.h"
57 -#include "ne_props.h"
58 -#include "ne_request.h"
59 -#include "ne_socket.h"
60 -#include "ne_string.h"
61 -#include "ne_utils.h"
63 -/* XXX API changes for neon-0.26.0 */
64 -#if !defined(NE_FREE)
65 -#define ne_set_persist(_sess, _flag)
66 -#define ne_propfind_set_private(_pfh, _create_item, NULL) \
67 - ne_propfind_set_private(_pfh, _create_item, NULL, NULL)
70 #include <rpmio_internal.h>
72 #define _RPMDAV_INTERNAL
76 /* =============================================================== */
77 -static int davFree(urlinfo u)
78 - /*@globals internalState @*/
79 - /*@modifies u, internalState @*/
81 - if (u != NULL && u->sess != NULL) {
82 - u->capabilities = _free(u->capabilities);
83 - if (u->lockstore != NULL)
84 - ne_lockstore_destroy(u->lockstore);
85 - u->lockstore = NULL;
86 - ne_session_destroy(u->sess);
92 -static void davProgress(void * userdata, off_t current, off_t total)
95 - urlinfo u = userdata;
100 -assert(sess != NULL);
101 -assert(u == ne_get_session_private(sess, "urlinfo"));
103 - u->current = current;
107 -fprintf(stderr, "*** davProgress(%p,0x%x:0x%x) sess %p u %p\n", userdata, (unsigned int)current, (unsigned int)total, sess, u);
110 -static void davNotify(void * userdata,
111 - ne_conn_status connstatus, const char * info)
114 - urlinfo u = userdata;
117 - static const char * connstates[] = {
127 -assert(sess != NULL);
128 -assert(u == ne_get_session_private(sess, "urlinfo"));
132 - ne_conn_namelookup, /* lookup up hostname (info = hostname) */
133 - ne_conn_connecting, /* connecting to host (info = hostname) */
134 - ne_conn_connected, /* connected to host (info = hostname) */
135 - ne_conn_secure /* connection now secure (info = crypto level) */
139 - u->connstatus = connstatus;
143 -fprintf(stderr, "*** davNotify(%p,%d,%p) sess %p u %p %s\n", userdata, connstatus, info, sess, u, connstates[ (connstatus < 4 ? connstatus : 4)]);
148 -static void davCreateRequest(ne_request * req, void * userdata,
149 - const char * method, const char * uri)
152 - urlinfo u = userdata;
154 - void * private = NULL;
155 - const char * id = "urlinfo";
158 -assert(u->sess != NULL);
159 -assert(req != NULL);
160 - sess = ne_get_session(req);
161 -assert(sess == u->sess);
162 -assert(u == ne_get_session_private(sess, "urlinfo"));
164 -assert(sess != NULL);
165 - private = ne_get_session_private(sess, id);
166 -assert(u == private);
169 -fprintf(stderr, "*** davCreateRequest(%p,%p,%s,%s) %s:%p\n", req, userdata, method, uri, id, private);
172 -static void davPreSend(ne_request * req, void * userdata, ne_buffer * buf)
174 - urlinfo u = userdata;
176 - const char * id = "fd";
180 -assert(u->sess != NULL);
181 -assert(req != NULL);
182 - sess = ne_get_session(req);
183 -assert(sess == u->sess);
184 -assert(u == ne_get_session_private(sess, "urlinfo"));
186 - fd = ne_get_request_private(req, id);
189 -fprintf(stderr, "*** davPreSend(%p,%p,%p) sess %p %s %p\n", req, userdata, buf, sess, id, fd);
191 -fprintf(stderr, "-> %s\n", buf->data);
195 -static int davPostSend(ne_request * req, void * userdata, const ne_status * status)
198 - urlinfo u = userdata;
200 - const char * id = "fd";
204 -assert(u->sess != NULL);
205 -assert(req != NULL);
206 - sess = ne_get_session(req);
207 -assert(sess == u->sess);
208 -assert(u == ne_get_session_private(sess, "urlinfo"));
210 - fd = ne_get_request_private(req, id);
214 -fprintf(stderr, "*** davPostSend(%p,%p,%p) sess %p %s %p %s\n", req, userdata, status, sess, id, fd, ne_get_error(sess));
219 -static void davDestroyRequest(ne_request * req, void * userdata)
222 - urlinfo u = userdata;
224 - const char * id = "fd";
228 -assert(u->sess != NULL);
229 -assert(req != NULL);
230 - sess = ne_get_session(req);
231 -assert(sess == u->sess);
232 -assert(u == ne_get_session_private(sess, "urlinfo"));
234 - fd = ne_get_request_private(req, id);
237 -fprintf(stderr, "*** davDestroyRequest(%p,%p) sess %p %s %p\n", req, userdata, sess, id, fd);
240 -static void davDestroySession(void * userdata)
243 - urlinfo u = userdata;
245 - void * private = NULL;
246 - const char * id = "urlinfo";
249 -assert(u->sess != NULL);
251 -assert(u == ne_get_session_private(sess, "urlinfo"));
253 -assert(sess != NULL);
254 - private = ne_get_session_private(sess, id);
255 -assert(u == private);
258 -fprintf(stderr, "*** davDestroySession(%p) sess %p %s %p\n", userdata, sess, id, private);
262 -davVerifyCert(void *userdata, int failures, const ne_ssl_certificate *cert)
265 - const char *hostname = userdata;
268 -fprintf(stderr, "*** davVerifyCert(%p,%d,%p) %s\n", userdata, failures, cert, hostname);
270 - return 0; /* HACK: trust all server certificates. */
273 -static int davConnect(urlinfo u)
274 - /*@globals internalState @*/
275 - /*@modifies u, internalState @*/
277 - const char * path = NULL;
280 - /* HACK: hkp:// has no steenkin' options */
281 - if (!(u->urltype == URL_IS_HTTP || u->urltype == URL_IS_HTTPS))
284 - /* HACK: where should server capabilities be read? */
285 - (void) urlPath(u->url, &path);
286 - /* HACK: perhaps capture Allow: tag, look for PUT permitted. */
287 - rc = ne_options(u->sess, path, u->capabilities);
292 - /* HACK: "301 Moved Permanently" on empty subdir. */
293 - if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
300 -fprintf(stderr, "*** Connect to %s:%d failed(%d):\n\t%s\n",
301 - u->host, u->port, rc, ne_get_error(u->sess));
305 - /* HACK: sensitive to error returns? */
306 - u->httpVersion = (ne_version_pre_http11(u->sess) ? 0 : 1);
311 -static int davInit(const char * url, urlinfo * uret)
312 - /*@globals internalState @*/
313 - /*@modifies *uret, internalState @*/
318 -/*@-globs@*/ /* FIX: h_errno annoyance. */
319 - if (urlSplit(url, &u))
320 - return -1; /* XXX error returns needed. */
323 - if (u->url != NULL && u->sess == NULL)
324 - switch (u->urltype) {
326 - assert(u->urltype != u->urltype);
327 - /*@notreached@*/ break;
331 - { ne_server_capabilities * capabilities;
333 - /* HACK: oneshots should be done Somewhere Else Instead. */
335 - rc = ((_dav_debug < 0) ? NE_DBG_HTTP : 0);
336 - ne_debug_init(stderr, rc); /* XXX oneshot? */
338 - rc = ne_sock_init(); /* XXX oneshot? */
340 - u->lockstore = ne_lockstore_create(); /* XXX oneshot? */
342 - u->capabilities = capabilities = xcalloc(1, sizeof(*capabilities));
343 - u->sess = ne_session_create(u->scheme, u->host, u->port);
345 - ne_lockstore_register(u->lockstore, u->sess);
347 - if (u->proxyh != NULL)
348 - ne_session_proxy(u->sess, u->proxyh, u->proxyp);
351 - { const ne_inet_addr ** addrs;
353 - ne_set_addrlist(u->sess, addrs, n);
357 - ne_set_progress(u->sess, davProgress, u);
358 - ne_set_status(u->sess, davNotify, u);
360 - ne_set_persist(u->sess, 1);
361 - ne_set_read_timeout(u->sess, httpTimeoutSecs);
362 - ne_set_useragent(u->sess, PACKAGE "/" PACKAGE_VERSION);
364 - /* XXX check that neon is ssl enabled. */
365 - if (!strcasecmp(u->scheme, "https"))
366 - ne_ssl_set_verify(u->sess, davVerifyCert, (char *)u->host);
368 - ne_set_session_private(u->sess, "urlinfo", u);
370 - ne_hook_destroy_session(u->sess, davDestroySession, u);
372 - ne_hook_create_request(u->sess, davCreateRequest, u);
373 - ne_hook_pre_send(u->sess, davPreSend, u);
374 - ne_hook_post_send(u->sess, davPostSend, u);
375 - ne_hook_destroy_request(u->sess, davDestroyRequest, u);
377 - /* HACK: where should server capabilities be read? */
378 - rc = davConnect(u);
386 - if (rc == 0 && uret != NULL)
387 - *uret = urlLink(u, __FUNCTION__);
389 - u = urlFree(u, "urlSplit (davInit)");
394 -/* =============================================================== */
395 -enum fetch_rtype_e {
402 -struct fetch_resource_s {
404 - struct fetch_resource_s *next;
408 - enum fetch_rtype_e type;
412 - int is_vcr; /* Is version resource. 0: no vcr, 1 checkin 2 checkout */
413 - char *error_reason; /* error string returned for this resource */
414 - int error_status; /* error status returned for this resource */
418 -static void *fetch_destroy_item(/*@only@*/ struct fetch_resource_s *res)
419 - /*@modifies res @*/
422 - ne_free(res->error_reason);
429 -static void *fetch_destroy_list(/*@only@*/ struct fetch_resource_s *res)
430 - /*@modifies res @*/
432 - struct fetch_resource_s *next;
434 - for (; res != NULL; res = next) {
436 - res = fetch_destroy_item(res);
443 -static void *fetch_create_item(/*@unused@*/ void *userdata, /*@unused@*/ const char *uri)
446 - struct fetch_resource_s * res = ne_calloc(sizeof(*res));
450 -/* =============================================================== */
451 -struct fetch_context_s {
452 -/*@relnull@*/ /*@dependent@*/
453 - struct fetch_resource_s **resrock;
455 - unsigned int include_target; /* Include resource at href */
467 -static void *fetch_destroy_context(/*@only@*/ /*@null@*/ struct fetch_context_s *ctx)
468 - /*@globals internalState @*/
469 - /*@modifies ctx, internalState @*/
473 - if (ctx->av != NULL)
474 - ctx->av = argvFree(ctx->av);
475 - ctx->modes = _free(ctx->modes);
476 - ctx->sizes = _free(ctx->sizes);
477 - ctx->mtimes = _free(ctx->mtimes);
478 - ctx->u = urlFree(ctx->u, __FUNCTION__);
479 - ctx->uri = _free(ctx->uri);
481 - memset(ctx, 0, sizeof(*ctx));
488 -static void *fetch_create_context(const char *uri)
489 - /*@globals internalState @*/
490 - /*@modifies internalState @*/
492 - struct fetch_context_s * ctx;
495 -/*@-globs@*/ /* FIX: h_errno annoyance. */
496 - if (urlSplit(uri, &u))
500 - ctx = ne_calloc(sizeof(*ctx));
501 - ctx->uri = xstrdup(uri);
502 - ctx->u = urlLink(u, __FUNCTION__);
506 -/*@unchecked@*/ /*@observer@*/
507 -static const ne_propname fetch_props[] = {
508 - { "DAV:", "getcontentlength" },
509 - { "DAV:", "getlastmodified" },
510 - { "http://apache.org/dav/props/", "executable" },
511 - { "DAV:", "resourcetype" },
512 - { "DAV:", "checked-in" },
513 - { "DAV:", "checked-out" },
517 -#define ELM_resourcetype (NE_PROPS_STATE_TOP + 1)
518 -#define ELM_collection (NE_PROPS_STATE_TOP + 2)
520 -/*@unchecked@*/ /*@observer@*/
521 -static const struct ne_xml_idmap fetch_idmap[] = {
522 - { "DAV:", "resourcetype", ELM_resourcetype },
523 - { "DAV:", "collection", ELM_collection }
526 -static int fetch_startelm(void *userdata, int parent,
527 - const char *nspace, const char *name,
528 - /*@unused@*/ const char **atts)
531 - ne_propfind_handler *pfh = userdata;
532 - struct fetch_resource_s *r = ne_propfind_current_private(pfh);
533 - int state = ne_xml_mapid(fetch_idmap, NE_XML_MAPLEN(fetch_idmap),
537 - !((parent == NE_207_STATE_PROP && state == ELM_resourcetype) ||
538 - (parent == ELM_resourcetype && state == ELM_collection)))
539 - return NE_XML_DECLINE;
541 - if (state == ELM_collection) {
542 - r->type = resr_collection;
548 -static int fetch_compare(const struct fetch_resource_s *r1,
549 - const struct fetch_resource_s *r2)
552 - /* Sort errors first, then collections, then alphabetically */
553 - if (r1->type == resr_error) {
555 - } else if (r2->type == resr_error) {
557 - } else if (r1->type == resr_collection) {
558 - if (r2->type != resr_collection) {
561 - return strcmp(r1->uri, r2->uri);
564 - if (r2->type != resr_collection) {
565 - return strcmp(r1->uri, r2->uri);
572 -static void fetch_results(void *userdata, void *uarg,
573 - const ne_prop_result_set *set)
576 - struct fetch_context_s *ctx = userdata;
577 - struct fetch_resource_s *current, *previous, *newres;
578 - const char *clength, *modtime, *isexec;
579 - const char *checkin, *checkout;
580 - const ne_status *status = NULL;
581 - const char * path = NULL;
583 -#if !defined(NE_FREE)
584 - const ne_uri * uri = uarg;
585 - (void) urlPath(uri->path, &path);
587 - const char * uri = uarg;
588 - (void) urlPath(uri, &path);
593 - newres = ne_propset_private(set);
596 -fprintf(stderr, "==> %s in uri %s\n", path, ctx->uri);
598 - if (ne_path_compare(ctx->uri, path) == 0 && !ctx->include_target) {
599 - /* This is the target URI */
601 -fprintf(stderr, "==> %s skipping target resource.\n", path);
602 - /* Free the private structure. */
603 -/*@-dependenttrans -exposetrans@*/
605 -/*@=dependenttrans =exposetrans@*/
609 - newres->uri = ne_strdup(path);
612 - clength = ne_propset_value(set, &fetch_props[0]);
613 - modtime = ne_propset_value(set, &fetch_props[1]);
614 - isexec = ne_propset_value(set, &fetch_props[2]);
615 - checkin = ne_propset_value(set, &fetch_props[4]);
616 - checkout = ne_propset_value(set, &fetch_props[5]);
620 - if (clength == NULL)
621 - status = ne_propset_status(set, &fetch_props[0]);
622 - if (modtime == NULL)
623 - status = ne_propset_status(set, &fetch_props[1]);
626 - if (newres->type == resr_normal && status != NULL) {
627 - /* It's an error! */
628 - newres->error_status = status->code;
630 - /* Special hack for Apache 1.3/mod_dav */
631 - if (strcmp(status->reason_phrase, "status text goes here") == 0) {
633 - if (status->code == 401) {
634 - desc = _("Authorization Required");
635 - } else if (status->klass == 3) {
636 - desc = _("Redirect");
637 - } else if (status->klass == 5) {
638 - desc = _("Server Error");
640 - desc = _("Unknown Error");
642 - newres->error_reason = ne_strdup(desc);
644 - newres->error_reason = ne_strdup(status->reason_phrase);
646 - newres->type = resr_error;
649 - if (isexec && strcasecmp(isexec, "T") == 0) {
650 - newres->is_executable = 1;
652 - newres->is_executable = 0;
656 - newres->modtime = ne_httpdate_parse(modtime);
659 - newres->size = atoi(clength);
663 - newres->is_vcr = 1;
664 - } else if (checkout) {
665 - newres->is_vcr = 2;
667 - newres->is_vcr = 0;
670 - for (current = *ctx->resrock, previous = NULL; current != NULL;
671 - previous = current, current = current->next)
673 - if (fetch_compare(current, newres) >= 0) {
678 - previous->next = newres;
680 -/*@-boundswrite -dependenttrans @*/
681 - *ctx->resrock = newres;
682 -/*@=boundswrite =dependenttrans @*/
684 - newres->next = current;
687 -static int davFetch(const urlinfo u, struct fetch_context_s * ctx)
688 - /*@globals internalState @*/
689 - /*@modifies ctx, internalState @*/
691 - const char * path = NULL;
692 - int depth = 1; /* XXX passed arg? */
693 - unsigned int include_target = 0; /* XXX passed arg? */
694 - struct fetch_resource_s * resitem = NULL;
695 - struct fetch_resource_s ** resrock = &resitem; /* XXX passed arg? */
696 - ne_propfind_handler *pfh;
697 - struct fetch_resource_s *current, *next;
702 - (void) urlPath(u->url, &path);
703 - pfh = ne_propfind_create(u->sess, ctx->uri, depth);
705 - /* HACK: need to set u->httpHasRange here. */
707 - ctx->resrock = resrock;
708 - ctx->include_target = include_target;
710 - ne_xml_push_handler(ne_propfind_get_parser(pfh),
711 - fetch_startelm, NULL, NULL, pfh);
713 - ne_propfind_set_private(pfh, fetch_create_item, NULL);
715 - rc = ne_propfind_named(pfh, fetch_props, fetch_results, ctx);
717 - ne_propfind_destroy(pfh);
719 - for (current = resitem; current != NULL; current = next) {
720 - const char *s, *se;
723 - next = current->next;
725 - /* Collections have trailing '/' that needs trim. */
726 - /* The top level collection is returned as well. */
727 - se = current->uri + strlen(current->uri);
728 - if (se[-1] == '/') {
729 - if (strlen(current->uri) <= strlen(path)) {
730 - current = fetch_destroy_item(current);
736 - while (s > current->uri && s[-1] != '/')
739 - val = ne_strndup(s, (se - s));
742 - val = ne_path_unescape(val);
745 - xx = argvAdd(&ctx->av, val);
747 -fprintf(stderr, "*** argvAdd(%p,\"%s\")\n", &ctx->av, val);
750 - while (ctx->ac >= ctx->nalloced) {
751 - if (ctx->nalloced <= 0)
753 - ctx->nalloced *= 2;
754 - ctx->modes = xrealloc(ctx->modes,
755 - (sizeof(*ctx->modes) * ctx->nalloced));
756 - ctx->sizes = xrealloc(ctx->sizes,
757 - (sizeof(*ctx->sizes) * ctx->nalloced));
758 - ctx->mtimes = xrealloc(ctx->mtimes,
759 - (sizeof(*ctx->mtimes) * ctx->nalloced));
762 - switch (current->type) {
765 - /*@switchbreak@*/ break;
766 - case resr_collection:
768 - /*@switchbreak@*/ break;
769 - case resr_reference:
773 - /*@switchbreak@*/ break;
776 - ctx->modes[ctx->ac] = st_mode;
777 - ctx->sizes[ctx->ac] = current->size;
778 - ctx->mtimes[ctx->ac] = current->modtime;
782 - current = fetch_destroy_item(current);
784 - ctx->resrock = NULL; /* HACK: avoid leaving stack reference. */
789 -static int davNLST(struct fetch_context_s * ctx)
790 - /*@globals internalState @*/
791 - /*@modifies ctx, internalState @*/
797 - rc = davInit(ctx->uri, &u);
798 - if (rc || u == NULL)
801 - rc = davFetch(u, ctx);
806 - /* HACK: "301 Moved Permanently" on empty subdir. */
807 - if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
812 -fprintf(stderr, "*** Fetch from %s:%d failed:\n\t%s\n",
813 - u->host, u->port, ne_get_error(u->sess));
823 -/* =============================================================== */
824 -static int my_result(const char * msg, int ret, /*@null@*/ FILE * fp)
825 - /*@modifies *fp @*/
827 - /* HACK: don't print unless debugging. */
828 - if (_dav_debug >= 0)
833 - fprintf(fp, "*** %s: ", msg);
835 - /* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */
837 - fprintf(fp, "%s: %s\n", ftpStrerror(-ret), ne_get_error(sess));
839 - fprintf(fp, "%s\n", ftpStrerror(-ret));
845 -static void hexdump(const unsigned char * buf, ssize_t len)
851 - for (i = 0; i < len; i++) {
852 - if (i != 0 && (i%16) == 0)
853 - fprintf(stderr, "\n");
854 - fprintf(stderr, " %02X", buf[i]);
856 - fprintf(stderr, "\n");
861 -static void davAcceptRanges(void * userdata, /*@null@*/ const char * value)
862 - /*@modifies userdata @*/
864 - urlinfo u = userdata;
866 - if (!(u != NULL && value != NULL)) return;
868 -fprintf(stderr, "*** u %p Accept-Ranges: %s\n", u, value);
869 - if (!strcmp(value, "bytes"))
870 - u->httpHasRange = 1;
871 - if (!strcmp(value, "none"))
872 - u->httpHasRange = 0;
876 -#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
877 -static void davAllHeaders(void * userdata, const char * value)
879 - FD_t ctrl = userdata;
881 - if (!(ctrl != NULL && value != NULL)) return;
883 -fprintf(stderr, "<- %s\n", value);
888 -static void davContentLength(void * userdata, /*@null@*/ const char * value)
889 - /*@modifies userdata @*/
891 - FD_t ctrl = userdata;
893 - if (!(ctrl != NULL && value != NULL)) return;
895 -fprintf(stderr, "*** fd %p Content-Length: %s\n", ctrl, value);
897 - ctrl->contentLength = strtoll(value, NULL, 10);
903 -static void davConnection(void * userdata, /*@null@*/ const char * value)
904 - /*@modifies userdata @*/
906 - FD_t ctrl = userdata;
908 - if (!(ctrl != NULL && value != NULL)) return;
910 -fprintf(stderr, "*** fd %p Connection: %s\n", ctrl, value);
911 - if (!strcasecmp(value, "close"))
913 - else if (!strcasecmp(value, "Keep-Alive"))
918 -/*@-mustmod@*/ /* HACK: stash error in *str. */
919 -int davResp(urlinfo u, FD_t ctrl, /*@unused@*/ char *const * str)
923 - rc = ne_begin_request(ctrl->req);
924 - rc = my_result("ne_begin_req(ctrl->req)", rc, NULL);
927 -fprintf(stderr, "*** davResp(%p,%p,%p) sess %p req %p rc %d\n", u, ctrl, str, u->sess, ctrl->req, rc);
929 - /* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */
930 -/*@-observertrans@*/
932 - fdSetSyserrno(ctrl, errno, ftpStrerror(-rc));
933 -/*@=observertrans@*/
939 -int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg)
944 -assert(ctrl != NULL);
949 -fprintf(stderr, "*** davReq(%p,%s,\"%s\") entry sess %p req %p\n", ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req);
951 - ctrl->persist = (u->httpVersion > 0 ? 1 : 0);
952 - ctrl = fdLink(ctrl, "open ctrl (davReq)");
954 -assert(u->sess != NULL);
955 -assert(ctrl->req == NULL);
957 - ctrl->req = ne_request_create(u->sess, httpCmd, httpArg);
959 -assert(ctrl->req != NULL);
961 - ne_set_request_private(ctrl->req, "fd", ctrl);
963 -#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
964 - ne_add_response_header_catcher(ctrl->req, davAllHeaders, ctrl);
966 - ne_add_response_header_handler(ctrl->req, "Content-Length",
967 - davContentLength, ctrl);
968 - ne_add_response_header_handler(ctrl->req, "Connection",
969 - davConnection, ctrl);
972 - if (!strcmp(httpCmd, "PUT")) {
973 -#if defined(HAVE_NEON_NE_SEND_REQUEST_CHUNK)
974 - ctrl->wr_chunked = 1;
975 - ne_add_request_header(ctrl->req, "Transfer-Encoding", "chunked");
976 - ne_set_request_chunked(ctrl->req, 1);
977 - /* HACK: no retries if/when chunking. */
978 - rc = davResp(u, ctrl, NULL);
980 - rc = FTPERR_SERVER_IO_ERROR;
983 - /* HACK: possible Last-Modified: Tue, 02 Nov 2004 14:29:36 GMT */
984 - /* HACK: possible ETag: "inode-size-mtime" */
985 -#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
986 - ne_add_response_header_handler(ctrl->req, "Accept-Ranges",
987 - davAcceptRanges, u);
989 - /* HACK: possible Transfer-Encoding: on GET. */
991 - /* HACK: other errors may need retry too. */
992 - /* HACK: neon retries once, gud enuf. */
993 - /* HACK: retry counter? */
995 - rc = davResp(u, ctrl, NULL);
996 - } while (rc == NE_RETRY);
1001 -if (_dav_debug < 0)
1002 -fprintf(stderr, "*** davReq(%p,%s,\"%s\") exit sess %p req %p rc %d\n", ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req, rc);
1004 -#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
1005 - davContentLength(ctrl,
1006 - ne_get_response_header(ctrl->req, "Content-Length"));
1007 - davConnection(ctrl,
1008 - ne_get_response_header(ctrl->req, "Connection"));
1009 - if (strcmp(httpCmd, "PUT"))
1010 - davAcceptRanges(u,
1011 - ne_get_response_header(ctrl->req, "Accept-Ranges"));
1014 - ctrl = fdLink(ctrl, "open data (davReq)");
1018 -/*@-observertrans@*/
1019 - fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
1020 -/*@=observertrans@*/
1022 - /* HACK balance fd refs. ne_session_destroy to tear down non-keepalive? */
1023 - ctrl = fdLink(ctrl, "error data (davReq)");
1028 -FD_t davOpen(const char * url, /*@unused@*/ int flags,
1029 - /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
1031 - const char * path = NULL;
1032 - urltype urlType = urlPath(url, &path);
1037 -#if 0 /* XXX makeTempFile() heartburn */
1038 - assert(!(flags & O_RDWR));
1041 -if (_dav_debug < 0)
1042 -fprintf(stderr, "*** davOpen(%s,0x%x,0%o,%p)\n", url, flags, mode, uret);
1043 - rc = davInit(url, &u);
1044 - if (rc || u == NULL || u->sess == NULL)
1047 - if (u->ctrl == NULL)
1048 - u->ctrl = fdNew("persist ctrl (davOpen)");
1049 - if (u->ctrl->nrefs > 2 && u->data == NULL)
1050 - u->data = fdNew("persist data (davOpen)");
1052 - if (u->ctrl->url == NULL)
1053 - fd = fdLink(u->ctrl, "grab ctrl (davOpen persist ctrl)");
1054 - else if (u->data->url == NULL)
1055 - fd = fdLink(u->data, "grab ctrl (davOpen persist data)");
1057 - fd = fdNew("grab ctrl (davOpen)");
1060 - fdSetOpen(fd, url, flags, mode);
1061 - fdSetIo(fd, ufdio);
1063 - fd->ftpFileDoneNeeded = 0;
1064 - fd->rd_timeoutsecs = httpTimeoutSecs;
1065 - fd->contentLength = fd->bytesRemain = -1;
1066 - fd->url = urlLink(u, "url (davOpen)");
1067 - fd = fdLink(fd, "grab data (davOpen)");
1068 -assert(urlType == URL_IS_HTTPS || urlType == URL_IS_HTTP || urlType == URL_IS_HKP);
1069 - fd->urlType = urlType;
1077 - /*@-refcounttrans@*/
1079 - /*@=refcounttrans@*/
1082 -ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
1088 -assert(count >= 128); /* HACK: see ne_request.h comment */
1090 - rc = ne_read_response_block(fd->req, buf, count);
1092 -if (_dav_debug < 0) {
1093 -fprintf(stderr, "*** davRead(%p,%p,0x%x) rc 0x%x\n", cookie, buf, (unsigned)count, (unsigned)rc);
1102 -ssize_t davWrite(void * cookie, const char * buf, size_t count)
1108 -#if !defined(NEONBLOWSCHUNKS)
1109 - ne_session * sess;
1111 -assert(fd->req != NULL);
1112 - sess = ne_get_session(fd->req);
1113 -assert(sess != NULL);
1115 - /* HACK: include ne_private.h to access sess->socket for now. */
1116 - xx = ne_sock_fullwrite(sess->socket, buf, count);
1118 -#if defined(HAVE_NEON_NE_SEND_REQUEST_CHUNK) || defined(__LCLINT__)
1119 -assert(fd->req != NULL);
1120 - xx = ne_send_request_chunk(fd->req, buf, count);
1122 - errno = EIO; /* HACK */
1127 - /* HACK: stupid error impedence matching. */
1128 - rc = (xx == 0 ? count : -1);
1130 -if (_dav_debug < 0)
1131 -fprintf(stderr, "*** davWrite(%p,%p,0x%x) rc 0x%x\n", cookie, buf, (unsigned)count, (unsigned)rc);
1134 -hexdump(buf, count);
1140 -int davSeek(void * cookie, /*@unused@*/ _libio_pos_t pos, int whence)
1142 -if (_dav_debug < 0)
1143 -fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence);
1147 -/*@-mustmod@*/ /* HACK: fd->req is modified. */
1148 -int davClose(void * cookie)
1155 -assert(fd->req != NULL);
1156 - rc = ne_end_request(fd->req);
1157 - rc = my_result("ne_end_request(req)", rc, NULL);
1159 - ne_request_destroy(fd->req);
1162 -if (_dav_debug < 0)
1163 -fprintf(stderr, "*** davClose(%p) rc %d\n", fd, rc);
1168 -/* =============================================================== */
1169 -int davMkdir(const char * path, mode_t mode)
1172 - const char * src = NULL;
1175 - rc = davInit(path, &u);
1179 - (void) urlPath(path, &src);
1181 - rc = ne_mkcol(u->sess, path);
1183 - if (rc) rc = -1; /* XXX HACK: errno impedance match */
1185 - /* XXX HACK: verify getrestype(remote) == resr_collection */
1189 -fprintf(stderr, "*** davMkdir(%s,0%o) rc %d\n", path, mode, rc);
1193 -int davRmdir(const char * path)
1196 - const char * src = NULL;
1199 - rc = davInit(path, &u);
1203 - (void) urlPath(path, &src);
1205 - /* XXX HACK: only getrestype(remote) == resr_collection */
1207 - rc = ne_delete(u->sess, path);
1209 - if (rc) rc = -1; /* XXX HACK: errno impedance match */
1213 -fprintf(stderr, "*** davRmdir(%s) rc %d\n", path, rc);
1217 -int davRename(const char * oldpath, const char * newpath)
1220 - const char * src = NULL;
1221 - const char * dst = NULL;
1222 - int overwrite = 1; /* HACK: set this correctly. */
1225 - rc = davInit(oldpath, &u);
1229 - (void) urlPath(oldpath, &src);
1230 - (void) urlPath(newpath, &dst);
1232 - /* XXX HACK: only getrestype(remote) != resr_collection */
1234 - rc = ne_move(u->sess, overwrite, src, dst);
1236 - if (rc) rc = -1; /* XXX HACK: errno impedance match */
1240 -fprintf(stderr, "*** davRename(%s,%s) rc %d\n", oldpath, newpath, rc);
1244 -int davUnlink(const char * path)
1247 - const char * src = NULL;
1250 - rc = davInit(path, &u);
1254 - (void) urlPath(path, &src);
1256 - /* XXX HACK: only getrestype(remote) != resr_collection */
1258 - rc = ne_delete(u->sess, src);
1261 - if (rc) rc = -1; /* XXX HACK: errno impedance match */
1264 -fprintf(stderr, "*** davUnlink(%s) rc %d\n", path, rc);
1269 -static int davChdir(const char * path)
1270 - /*@globals h_errno, fileSystem, internalState @*/
1271 - /*@modifies fileSystem, internalState @*/
1273 - return davCommand("CWD", path, NULL);
1275 -#endif /* NOTYET */
1277 -/* =============================================================== */
1279 -static const char * statstr(const struct stat * st,
1280 - /*@returned@*/ /*@out@*/ char * buf)
1281 - /*@modifies *buf @*/
1284 - "*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n",
1285 - (unsigned)st->st_dev,
1286 - (unsigned)st->st_ino,
1288 - (unsigned)st->st_nlink,
1291 - (unsigned)st->st_rdev,
1292 - (unsigned)st->st_size);
1297 -static int dav_st_ino = 0xdead0000;
1300 -int davStat(const char * path, /*@out@*/ struct stat *st)
1301 - /*@globals dav_st_ino, fileSystem, internalState @*/
1302 - /*@modifies *st, dav_st_ino, fileSystem, internalState @*/
1304 - struct fetch_context_s * ctx = NULL;
1308 -/* HACK: neon really wants collections with trailing '/' */
1309 - ctx = fetch_create_context(path);
1310 - if (ctx == NULL) {
1311 -/* HACK: errno = ??? */
1314 - rc = davNLST(ctx);
1316 -/* HACK: errno = ??? */
1320 - memset(st, 0, sizeof(*st));
1321 - st->st_mode = ctx->modes[0];
1322 - st->st_size = ctx->sizes[0];
1323 - st->st_mtime = ctx->mtimes[0];
1324 - if (S_ISDIR(st->st_mode)) {
1326 - st->st_mode |= 0755;
1328 - if (S_ISREG(st->st_mode)) {
1330 - st->st_mode |= 0644;
1333 - /* XXX fts(3) needs/uses st_ino, make something up for now. */
1334 - if (st->st_ino == 0)
1335 - st->st_ino = dav_st_ino++;
1336 -if (_dav_debug < 0)
1337 -fprintf(stderr, "*** davStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
1339 - ctx = fetch_destroy_context(ctx);
1345 -int davLstat(const char * path, /*@out@*/ struct stat *st)
1346 - /*@globals dav_st_ino, fileSystem, internalState @*/
1347 - /*@modifies *st, dav_st_ino, fileSystem, internalState @*/
1349 - struct fetch_context_s * ctx = NULL;
1353 -/* HACK: neon really wants collections with trailing '/' */
1354 - ctx = fetch_create_context(path);
1355 - if (ctx == NULL) {
1356 -/* HACK: errno = ??? */
1359 - rc = davNLST(ctx);
1361 -/* HACK: errno = ??? */
1365 - memset(st, 0, sizeof(*st));
1366 - st->st_mode = ctx->modes[0];
1367 - st->st_size = ctx->sizes[0];
1368 - st->st_mtime = ctx->mtimes[0];
1369 - if (S_ISDIR(st->st_mode)) {
1371 - st->st_mode |= 0755;
1373 - if (S_ISREG(st->st_mode)) {
1375 - st->st_mode |= 0644;
1378 - /* XXX fts(3) needs/uses st_ino, make something up for now. */
1379 - if (st->st_ino == 0)
1380 - st->st_ino = dav_st_ino++;
1381 -if (_dav_debug < 0)
1382 -fprintf(stderr, "*** davLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
1384 - ctx = fetch_destroy_context(ctx);
1390 -static int davReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
1391 - /*@globals h_errno, fileSystem, internalState @*/
1392 - /*@modifies *buf, fileSystem, internalState @*/
1395 - rc = davNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
1396 -if (_dav_debug < 0)
1397 -fprintf(stderr, "*** davReadlink(%s) rc %d\n", path, rc);
1400 -#endif /* NOTYET */
1402 -/* =============================================================== */
1404 int avmagicdir = 0x3607113;
1406 @@ -1518,171 +167,4 @@
1410 -/* =============================================================== */
1412 -int davmagicdir = 0x8440291;
1414 -int davClosedir(/*@only@*/ DIR * dir)
1416 - DAVDIR avdir = (DAVDIR)dir;
1418 -if (_dav_debug < 0)
1419 -fprintf(stderr, "*** davClosedir(%p)\n", avdir);
1421 -#if defined(HAVE_PTHREAD_H)
1422 -/*@-moduncon -noeffectuncon @*/
1423 - (void) pthread_mutex_destroy(&avdir->lock);
1424 -/*@=moduncon =noeffectuncon @*/
1427 - avdir = _free(avdir);
1431 -struct dirent * davReaddir(DIR * dir)
1433 - DAVDIR avdir = (DAVDIR)dir;
1434 - struct dirent * dp;
1436 - unsigned char * dt;
1440 - if (avdir == NULL || !ISDAVMAGIC(avdir) || avdir->data == NULL) {
1441 - /* XXX TODO: EBADF errno. */
1445 - dp = (struct dirent *) avdir->data;
1446 - av = (const char **) (dp + 1);
1448 - dt = (char *) (av + (ac + 1));
1449 - i = avdir->offset + 1;
1452 - if (i < 0 || i >= ac || av[i] == NULL)
1456 - avdir->offset = i;
1458 - /* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
1460 - dp->d_ino = i + 1; /* W2DO? */
1461 - dp->d_reclen = 0; /* W2DO? */
1463 -#if !(defined(hpux) || defined(__hpux) || defined(sun))
1464 -#if !defined(__APPLE__)
1465 - dp->d_off = 0; /* W2DO? */
1468 - dp->d_type = dt[i];
1473 - strncpy(dp->d_name, av[i], sizeof(dp->d_name));
1474 -if (_dav_debug < 0)
1475 -fprintf(stderr, "*** davReaddir(%p) %p \"%s\"\n", (void *)avdir, dp, dp->d_name);
1481 -DIR * davOpendir(const char * path)
1483 - struct fetch_context_s * ctx;
1485 - struct dirent * dp;
1487 - const char ** av, ** nav;
1488 - unsigned char * dt;
1493 - /* HACK: glob does not pass dirs with trailing '/' */
1494 - nb = strlen(path)+1;
1496 - if (path[nb-1] != '/') {
1497 - char * npath = alloca(nb+1);
1499 - (void) stpcpy( stpcpy(npath, path), "/");
1504 -if (_dav_debug < 0)
1505 -fprintf(stderr, "*** davOpendir(%s)\n", path);
1507 - /* Load DAV collection into argv. */
1508 - ctx = fetch_create_context(path);
1509 - if (ctx == NULL) {
1510 -/* HACK: errno = ??? */
1513 - rc = davNLST(ctx);
1515 -/* HACK: errno = ??? */
1523 - while (av[ac] != NULL)
1524 - nb += strlen(av[ac++]) + 1;
1525 - ac += 2; /* for "." and ".." */
1526 - nb += sizeof(".") + sizeof("..");
1528 - nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
1529 - avdir = xcalloc(1, nb);
1531 - dp = (struct dirent *) (avdir + 1);
1532 - nav = (const char **) (dp + 1);
1533 - dt = (char *) (nav + (ac + 1));
1534 - t = (char *) (dt + ac + 1);
1537 - avdir->fd = davmagicdir;
1539 - avdir->data = (char *) dp;
1541 - avdir->allocation = nb;
1543 - avdir->offset = -1;
1544 - avdir->filepos = 0;
1546 -#if defined(HAVE_PTHREAD_H)
1547 -/*@-moduncon -noeffectuncon -nullpass @*/
1548 - (void) pthread_mutex_init(&avdir->lock, NULL);
1549 -/*@=moduncon =noeffectuncon =nullpass @*/
1553 -/*@-dependenttrans -unrecog@*/
1554 - dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, "."); t++;
1555 - dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, ".."); t++;
1556 -/*@=dependenttrans =unrecog@*/
1558 - /* Copy DAV items into DIR elments. */
1561 - while (av[ac] != NULL) {
1563 - dt[nac] = (S_ISDIR(ctx->modes[ac]) ? DT_DIR : DT_REG);
1564 - t = stpcpy(t, av[ac]);
1571 - ctx = fetch_destroy_context(ctx);
1574 - return (DIR *) avdir;
1578 diff -ur rpm-4.4.7.org/rpmio/rpmdav.h rpm-4.4.7/rpmio/rpmdav.h
1579 --- rpm-4.4.7.org/rpmio/rpmdav.h 2005-10-11 21:13:59.000000000 +0200
1580 +++ rpm-4.4.7/rpmio/rpmdav.h 2006-10-17 22:14:25.659533000 +0200
1582 /*@globals fileSystem, internalState @*/
1583 /*@modifies fileSystem, internalState @*/;
1586 - * Send a http request.
1588 - * @param httpCmd http command
1589 - * @param httpArg http command argument (NULL if none)
1590 - * @returns 0 on success
1592 -int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg)
1593 - /*@globals fileSystem, internalState @*/
1594 - /*@modifies ctrl, fileSystem, internalState @*/;
1597 - * Read a http response.
1600 - * @retval *str error msg
1601 - * @returns 0 on success
1604 -int davResp(urlinfo u, FD_t ctrl, /*@out@*/ /*@null@*/ char *const * str)
1605 - /*@globals fileSystem, internalState @*/
1606 - /*@modifies ctrl, *str, fileSystem, internalState @*/;
1612 -FD_t davOpen(const char * url, /*@unused@*/ int flags,
1613 - /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
1614 - /*@globals internalState @*/
1615 - /*@modifies *uret, internalState @*/;
1620 -ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
1621 - /*@globals fileSystem, internalState @*/
1622 - /*@modifies buf, fileSystem, internalState @*/
1623 - /*@requires maxSet(buf) >= (count - 1) @*/
1624 - /*@ensures maxRead(buf) == result @*/;
1629 -ssize_t davWrite(void * cookie, const char * buf, size_t count)
1630 - /*@globals fileSystem, internalState @*/
1631 - /*@modifies fileSystem, internalState @*/;
1635 -int davSeek(void * cookie, _libio_pos_t pos, int whence)
1636 - /*@globals fileSystem, internalState @*/
1637 - /*@modifies fileSystem, internalState @*/;
1641 -int davClose(void * cookie)
1642 - /*@globals fileSystem, internalState @*/
1643 - /*@modifies cookie, fileSystem, internalState @*/;
1647 -int davMkdir(const char * path, mode_t mode)
1648 - /*@globals fileSystem, internalState @*/
1649 - /*@modifies fileSystem, internalState @*/;
1653 -int davRmdir(const char * path)
1654 - /*@globals fileSystem, internalState @*/
1655 - /*@modifies fileSystem, internalState @*/;
1659 -int davRename(const char * oldpath, const char * newpath)
1660 - /*@globals fileSystem, internalState @*/
1661 - /*@modifies fileSystem, internalState @*/;
1665 -int davUnlink(const char * path)
1666 - /*@globals fileSystem, internalState @*/
1667 - /*@modifies fileSystem, internalState @*/;
1670 - * Close a DAV collection.
1671 - * @param dir argv DIR
1672 - * @return 0 always
1674 -int davClosedir(/*@only@*/ DIR * dir)
1675 - /*@globals fileSystem @*/
1676 - /*@modifies dir, fileSystem @*/;
1679 - * Return next entry from a DAV collection.
1680 - * @param dir argv DIR
1681 - * @return next entry
1683 -/*@dependent@*/ /*@null@*/
1684 -struct dirent * davReaddir(DIR * dir)
1685 - /*@globals fileSystem @*/
1686 - /*@modifies fileSystem @*/;
1689 - * Create an argv directory from DAV collection.
1690 - * @param path URL for DAV collection path
1691 - * @return argv DIR
1694 -DIR * davOpendir(const char * path)
1695 - /*@globals fileSystem, internalState @*/
1696 - /*@modifies fileSystem, internalState @*/;
1701 -int davStat(const char * path, /*@out@*/ struct stat * st)
1702 - /*@globals fileSystem, internalState @*/
1703 - /*@modifies *st, fileSystem, internalState @*/;
1708 -int davLstat(const char * path, /*@out@*/ struct stat * st)
1709 - /*@globals fileSystem, internalState @*/
1710 - /*@modifies *st, fileSystem, internalState @*/;
1715 diff -ur rpm-4.4.7.org/rpmio/rpmio.c rpm-4.4.7/rpmio/rpmio.c
1716 --- rpm-4.4.7.org/rpmio/rpmio.c 2006-08-08 08:55:01.000000000 +0200
1717 +++ rpm-4.4.7/rpmio/rpmio.c 2006-10-17 22:18:38.135311750 +0200
1718 @@ -406,13 +406,6 @@
1720 fdstat_enter(fd, FDSTAT_READ);
1722 - /* HACK: flimsy wiring for davRead */
1723 - if (fd->req != NULL) {
1724 - rc = davRead(fd, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
1725 - /* XXX Chunked davRead EOF. */
1727 - fd->bytesRemain = 0;
1729 rc = read(fdFileno(fd), buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
1731 fdstat_exit(fd, FDSTAT_READ, rc);
1732 @@ -440,10 +433,6 @@
1734 fdstat_enter(fd, FDSTAT_WRITE);
1736 - /* HACK: flimsy wiring for davWrite */
1737 - if (fd->req != NULL)
1738 - rc = davWrite(fd, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
1740 rc = write(fdno, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
1742 fdstat_exit(fd, FDSTAT_WRITE, rc);
1743 @@ -490,11 +479,6 @@
1746 fdstat_enter(fd, FDSTAT_CLOSE);
1747 - /* HACK: flimsy wiring for davClose */
1749 - if (fd->req != NULL)
1750 - rc = davClose(fd);
1752 rc = ((fdno >= 0) ? close(fdno) : -2);
1754 fdstat_exit(fd, FDSTAT_CLOSE, rc);
1755 @@ -547,10 +531,6 @@
1759 - /* HACK: flimsy wiring for davWrite */
1760 - if (fd->req != NULL)
1763 if ((fdno = fdFileno(fd)) < 0)
1764 return -1; /* XXX W2DO? */
1766 @@ -602,10 +582,6 @@
1770 - /* HACK: flimsy wiring for davRead */
1771 - if (fd->req != NULL)
1774 if ((fdno = fdFileno(fd)) < 0)
1775 return -1; /* XXX W2DO? */
1777 @@ -1758,159 +1734,6 @@
1782 -static int httpResp(urlinfo u, FD_t ctrl, /*@out@*/ char ** str)
1783 - /*@globals fileSystem @*/
1784 - /*@modifies ctrl, *str, fileSystem @*/
1790 - rc = checkResponse(u, ctrl, &ec, str);
1792 -if (_ftp_debug && !(rc == 0 && (ec == 200 || ec == 201)))
1793 -fprintf(stderr, "*** httpResp: rc %d ec %d\n", rc, ec);
1797 - case 201: /* 201 Created. */
1799 - case 204: /* HACK: if overwriting, 204 No Content. */
1800 - case 403: /* 403 Forbidden. */
1801 - ctrl->syserrno = EACCES; /* HACK */
1802 - rc = FTPERR_UNKNOWN;
1805 - rc = FTPERR_FILE_NOT_FOUND;
1811 -static int httpReq(FD_t ctrl, const char * httpCmd, const char * httpArg)
1812 - /*@globals h_errno, fileSystem, internalState @*/
1813 - /*@modifies ctrl, fileSystem, internalState @*/
1816 - const char * host;
1817 - const char * path;
1818 - char hthost[NI_MAXHOST];
1825 -assert(ctrl != NULL);
1829 - if (((host = (u->proxyh ? u->proxyh : u->host)) == NULL))
1830 - return FTPERR_BAD_HOSTNAME;
1831 - if (strchr(host, ':'))
1832 - sprintf(hthost, "[%s]", host);
1834 - strcpy(hthost, host);
1836 - if ((port = (u->proxyp > 0 ? u->proxyp : u->port)) < 0) port = 80;
1837 - path = (u->proxyh || u->proxyp > 0) ? u->url : httpArg;
1838 - /*@-branchstate@*/
1839 - if (path == NULL) path = "";
1840 - /*@=branchstate@*/
1843 - /*@-branchstate@*/
1844 - if (fdFileno(ctrl) >= 0 && (rc = fdWritable(ctrl, 0)) < 1) {
1845 - /*@-refcounttrans@*/ (void) fdClose(ctrl); /*@=refcounttrans@*/
1847 - /*@=branchstate@*/
1850 - if (fdFileno(ctrl) < 0) {
1851 - rc = tcpConnect(ctrl, host, port);
1854 - ctrl = fdLink(ctrl, "open ctrl (httpReq)");
1858 -req x HTTP/1.0\r\n\
1859 -User-Agent: rpm/3.0.4\r\n\
1861 -Accept: text/plain\r\n\
1862 -Transfer-Encoding: chunked\r\n\
1864 -") + strlen(httpCmd) + strlen(path) + sizeof(VERSION) + strlen(hthost) + 20;
1867 - req = alloca(len);
1870 - if (!strcmp(httpCmd, "PUT")) {
1872 -%s %s HTTP/1.%d\r\n\
1873 -User-Agent: rpm/%s\r\n\
1875 -Accept: text/plain\r\n\
1876 -Transfer-Encoding: chunked\r\n\
1878 -", httpCmd, path, (u->httpVersion ? 1 : 0), VERSION, hthost, port);
1881 -%s %s HTTP/1.%d\r\n\
1882 -User-Agent: rpm/%s\r\n\
1884 -Accept: text/plain\r\n\
1886 -", httpCmd, path, (u->httpVersion ? 1 : 0), VERSION, hthost, port);
1891 -fprintf(stderr, "-> %s", req);
1893 - len = strlen(req);
1894 - if (fdWrite(ctrl, req, len) != len) {
1895 - rc = FTPERR_SERVER_IO_ERROR;
1899 - /*@-branchstate@*/
1900 - if (!strcmp(httpCmd, "PUT")) {
1901 - ctrl->wr_chunked = 1;
1904 - rc = httpResp(u, ctrl, NULL);
1907 - if (!retrying) { /* not HTTP_OK */
1909 - /*@-refcounttrans@*/ (void) fdClose(ctrl); /*@=refcounttrans@*/
1915 - /*@=branchstate@*/
1917 - ctrl = fdLink(ctrl, "open data (httpReq)");
1921 - /*@-observertrans@*/
1922 - fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
1923 - /*@=observertrans@*/
1925 - /*@-branchstate@*/
1926 - if (fdFileno(ctrl) >= 0)
1927 - /*@-refcounttrans@*/ (void) fdClose(ctrl); /*@=refcounttrans@*/
1928 - /*@=branchstate@*/
1934 /* XXX DYING: unused */
1935 void * ufdGetUrlinfo(FD_t fd)
1937 @@ -2268,29 +2091,6 @@
1941 - case URL_IS_HTTPS:
1944 - fd = davOpen(url, flags, mode, &u);
1945 - if (fd == NULL || u == NULL)
1948 - cmd = ((flags & O_WRONLY)
1949 - ? ((flags & O_APPEND) ? "PUT" :
1950 - ((flags & O_CREAT) ? "PUT" : "PUT"))
1952 - u->openError = davReq(fd, cmd, path);
1953 - if (u->openError < 0) {
1954 - /* XXX make sure that we can exit through ufdClose */
1955 - fd = fdLink(fd, "error ctrl (ufdOpen HTTP)");
1956 - fd = fdLink(fd, "error data (ufdOpen HTTP)");
1958 - fd->bytesRemain = ((!strcmp(cmd, "GET"))
1959 - ? fd->contentLength : -1);
1960 - fd->wr_chunked = ((!strcmp(cmd, "PUT"))
1961 - ? fd->wr_chunked : 0);
1965 assert(!(flags & O_RDWR));
1966 fd = fdDup( ((flags & O_WRONLY) ? STDOUT_FILENO : STDIN_FILENO) );
1967 @@ -2908,10 +2708,8 @@
1968 if (fd->nfps > 0 && fpno == -1 &&
1969 fd->fps[fd->nfps-1].io == ufdio &&
1970 fd->fps[fd->nfps-1].fp == fp &&
1971 - (fd->fps[fd->nfps-1].fdno >= 0 || fd->req != NULL))
1972 + (fd->fps[fd->nfps-1].fdno >= 0))
1974 - int hadreqpersist = (fd->req != NULL);
1979 @@ -2921,26 +2719,9 @@
1981 if (fdGetFdno(fd) >= 0)
1984 - hadreqpersist = 0;
1988 - /* HACK: flimsy Keepalive wiring. */
1989 - if (hadreqpersist) {
1994 -/*@-refcounttrans@*/
1995 - (void) fdClose(fd);
1996 -/*@=refcounttrans@*/
1997 - fdSetFp(fd, NULL);
1999 -/*@-refcounttrans@*/
2000 - (void) fdClose(fd);
2001 -/*@=refcounttrans@*/
2006 @@ -3195,18 +2976,9 @@
2014 /* XXX gzdio and bzdio here too */
2016 switch (urlIsURL(path)) {
2017 - case URL_IS_HTTPS:
2025 @@ -3214,7 +2986,7 @@
2027 fprintf(stderr, "*** Fopen ufdio path %s fmode %s\n", path, fmode);
2028 fd = ufdOpen(path, flags, perms);
2029 - if (fd == NULL || !(fdFileno(fd) >= 0 || fd->req != NULL))
2030 + if (fd == NULL || !(fdFileno(fd) >= 0))
2034 @@ -3223,15 +2995,6 @@
2036 /*@notreached@*/ break;
2039 - /* XXX persistent HTTP/1.1 returns the previously opened fp */
2040 - if (isHTTP && ((fp = fdGetFp(fd)) != NULL) && ((fdno = fdGetFdno(fd)) >= 0 || fd->req != NULL))
2042 - /*@+voidabstract@*/
2043 - fdPush(fd, fpio, fp, fileno(fp)); /* Push fpio onto stack */
2044 - /*@=voidabstract@*/
2050 @@ -3267,10 +3030,6 @@
2053 if (fd == NULL) return -1;
2054 - if (fd->req != NULL) {
2055 - /* HACK: flimsy wiring for neon errors. */
2056 - rc = (fd->syserrno || fd->errcookie != NULL) ? -1 : 0;
2058 for (i = fd->nfps; rc == 0 && i >= 0; i--) {
2060 FDSTACK_t * fps = &fd->fps[i];
2061 @@ -3305,9 +3064,6 @@
2065 - if (fd->req != NULL)
2066 - rc = 123456789; /* HACK: https has no steenkin fileno. */
2068 for (i = fd->nfps ; rc == -1 && i >= 0; i--) {
2070 rc = fd->fps[i].fdno;
2071 diff -ur rpm-4.4.7.org/rpmio/rpmio_internal.h rpm-4.4.7/rpmio/rpmio_internal.h
2072 --- rpm-4.4.7.org/rpmio/rpmio_internal.h 2006-06-18 20:54:59.000000000 +0200
2073 +++ rpm-4.4.7/rpmio/rpmio_internal.h 2006-10-17 22:18:51.308135000 +0200
2076 void * url; /* ufdio: URL info */
2078 - void * req; /* ufdio: HTTP request */
2080 int rd_timeoutsecs; /* ufdRead: per FD_t timer */
2081 ssize_t bytesRemain; /* ufdio: */
2082 diff -ur rpm-4.4.7.org/rpmio/rpmrpc.c rpm-4.4.7/rpmio/rpmrpc.c
2083 --- rpm-4.4.7.org/rpmio/rpmrpc.c 2006-10-03 06:38:01.000000000 +0200
2084 +++ rpm-4.4.7/rpmio/rpmrpc.c 2006-10-17 22:20:28.658219000 +0200
2087 return ftpMkdir(path, mode);
2088 /*@notreached@*/ break;
2089 - case URL_IS_HTTPS:
2091 - return davMkdir(path, mode);
2092 - /*@notreached@*/ break;
2096 @@ -118,15 +114,6 @@
2098 return ftpChdir(path);
2099 /*@notreached@*/ break;
2100 - case URL_IS_HTTPS:
2103 - return davChdir(path);
2105 - errno = EINVAL; /* XXX W2DO? */
2108 - /*@notreached@*/ break;
2112 @@ -151,10 +138,6 @@
2114 return ftpRmdir(path);
2115 /*@notreached@*/ break;
2116 - case URL_IS_HTTPS:
2118 - return davRmdir(path);
2119 - /*@notreached@*/ break;
2126 case URL_IS_FTP: /* XXX TODO: implement. */
2127 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2128 - case URL_IS_HTTP: /* XXX TODO: implement. */
2130 errno = EINVAL; /* XXX W2DO? */
2132 @@ -208,10 +189,6 @@
2134 oldut = urlPath(oldpath, &oe);
2136 - case URL_IS_HTTPS:
2138 - return davRename(oldpath, newpath);
2139 - /*@notreached@*/ break;
2140 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
2142 case URL_IS_UNKNOWN:
2145 return ftpRename(oldpath, newpath);
2146 /*@notreached@*/ break;
2147 - case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
2148 - case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
2154 oldut = urlPath(oldpath, &oe);
2156 - case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
2157 - case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
2158 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
2160 case URL_IS_UNKNOWN:
2163 newut = urlPath(newpath, &ne);
2165 - case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
2166 - case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
2167 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
2170 @@ -306,10 +277,6 @@
2172 return ftpUnlink(path);
2173 /*@notreached@*/ break;
2174 - case URL_IS_HTTPS:
2176 - return davUnlink(path);
2177 - /*@notreached@*/ break;
2181 @@ -1308,10 +1275,6 @@
2183 return ftpStat(path, st);
2184 /*@notreached@*/ break;
2185 - case URL_IS_HTTPS:
2187 - return davStat(path, st);
2188 - /*@notreached@*/ break;
2192 @@ -1338,10 +1301,6 @@
2194 return ftpLstat(path, st);
2195 /*@notreached@*/ break;
2196 - case URL_IS_HTTPS:
2198 - return davLstat(path, st);
2199 - /*@notreached@*/ break;
2203 @@ -1373,8 +1332,6 @@
2206 case URL_IS_FTP: /* XXX TODO: implement. */
2207 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2208 - case URL_IS_HTTP: /* XXX TODO: implement. */
2210 errno = EINVAL; /* XXX W2DO? */
2212 @@ -1399,8 +1356,6 @@
2215 case URL_IS_FTP: /* XXX TODO: implement. */
2216 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2217 - case URL_IS_HTTP: /* XXX TODO: implement. */
2219 errno = EINVAL; /* XXX W2DO? */
2221 @@ -1425,8 +1380,6 @@
2224 case URL_IS_FTP: /* XXX TODO: implement. */
2225 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2226 - case URL_IS_HTTP: /* XXX TODO: implement. */
2228 errno = EINVAL; /* XXX W2DO? */
2230 @@ -1451,8 +1404,6 @@
2233 case URL_IS_FTP: /* XXX TODO: implement. */
2234 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2235 - case URL_IS_HTTP: /* XXX TODO: implement. */
2237 errno = EINVAL; /* XXX W2DO? */
2239 @@ -1477,8 +1428,6 @@
2242 case URL_IS_FTP: /* XXX TODO: implement. */
2243 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2244 - case URL_IS_HTTP: /* XXX TODO: implement. */
2246 errno = EINVAL; /* XXX W2DO? */
2248 @@ -1503,8 +1452,6 @@
2251 case URL_IS_FTP: /* XXX TODO: implement. */
2252 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2253 - case URL_IS_HTTP: /* XXX TODO: implement. */
2255 errno = EINVAL; /* XXX W2DO? */
2257 @@ -1529,8 +1476,6 @@
2260 case URL_IS_FTP: /* XXX TODO: implement. */
2261 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2262 - case URL_IS_HTTP: /* XXX TODO: implement. */
2264 errno = EINVAL; /* XXX W2DO? */
2266 @@ -1558,8 +1503,6 @@
2269 case URL_IS_FTP: /* XXX TODO: implement. */
2270 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2271 - case URL_IS_HTTP: /* XXX TODO: implement. */
2273 errno = EINVAL; /* XXX W2DO? */
2275 @@ -1577,14 +1520,6 @@
2277 return ftpReadlink(path, buf, bufsiz);
2278 /*@notreached@*/ break;
2279 - case URL_IS_HTTPS:
2282 - return davReadlink(path, buf, bufsiz);
2286 - /*@notreached@*/ break;
2290 @@ -1617,8 +1552,6 @@
2294 - case URL_IS_HTTPS: /* XXX TODO: implement. */
2295 - case URL_IS_HTTP: /* XXX TODO: implement. */
2296 case URL_IS_FTP: /* XXX TODO: implement. */
2298 errno = EINVAL; /* XXX W2DO? */
2299 @@ -1685,8 +1618,6 @@
2300 fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob);
2303 - case URL_IS_HTTPS:
2307 pglob->gl_closedir = Closedir;
2308 @@ -1730,10 +1661,6 @@
2310 return ftpOpendir(path);
2311 /*@notreached@*/ break;
2312 - case URL_IS_HTTPS:
2314 - return davOpendir(path);
2315 - /*@notreached@*/ break;
2319 diff -ur rpm-4.4.7.org/rpmio/tget.c rpm-4.4.7/rpmio/tget.c
2320 --- rpm-4.4.7.org/rpmio/tget.c 2004-11-19 17:52:58.000000000 +0100
2321 +++ rpm-4.4.7/rpmio/tget.c 2006-10-17 22:20:47.995427500 +0200
2324 static int _debug = 0;
2328 #define HTTPSPATH "https://localhost/test.txt"
2329 #define HTTPPATH "http://localhost/test.txt"
2330 #define FTPPATH "ftp://localhost/test.txt"
2332 { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
2333 { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
2334 N_("debug protocol data stream"), NULL},
2335 - { "noneon", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noNeon, 1,
2336 - N_("disable use of libneon for HTTP"), NULL},
2337 { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
2338 N_("debug rpmio I/O"), NULL},
2339 { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
2340 diff -ur rpm-4.4.7.org/rpmio/tglob.c rpm-4.4.7/rpmio/tglob.c
2341 --- rpm-4.4.7.org/rpmio/tglob.c 2004-11-19 17:53:05.000000000 +0100
2342 +++ rpm-4.4.7/rpmio/tglob.c 2006-10-17 22:21:01.712284750 +0200
2345 static int _debug = 0;
2349 #define HTTPSPATH "https://localhost/rawhide/test/*.rpm"
2351 #define HTTPPATH "http://localhost/rawhide/test/*.rpm"
2353 { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
2354 { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
2355 N_("debug protocol data stream"), NULL},
2356 - { "noneon", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noNeon, 1,
2357 - N_("disable use of libneon for HTTP"), NULL},
2358 { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
2359 N_("debug rpmio I/O"), NULL},
2360 { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
2361 diff -ur rpm-4.4.7.org/rpmio/thkp.c rpm-4.4.7/rpmio/thkp.c
2362 --- rpm-4.4.7.org/rpmio/thkp.c 2005-01-04 17:35:12.000000000 +0100
2363 +++ rpm-4.4.7/rpmio/thkp.c 2006-10-17 22:21:10.696846250 +0200
2365 static int _debug = 0;
2366 static int _printing = 0;
2371 #define HKPPATH "hkp://pgp.mit.edu:11371/pks/lookup?op=get&search=0xF5C75256"
2374 N_("debug protocol data stream"), NULL},
2375 { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
2376 N_("debug protocol data stream"), NULL},
2377 - { "noneon", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noNeon, 1,
2378 - N_("disable use of libneon for HTTP"), NULL},
2379 { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
2380 N_("debug rpmio I/O"), NULL},
2381 { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
2382 diff -ur rpm-4.4.7.org/rpmio/tput.c rpm-4.4.7/rpmio/tput.c
2383 --- rpm-4.4.7.org/rpmio/tput.c 2004-11-19 17:53:11.000000000 +0100
2384 +++ rpm-4.4.7/rpmio/tput.c 2006-10-17 22:21:25.841792750 +0200
2387 static int _debug = 0;
2391 #define HTTPSPATH "https://localhost/rawhide/toad/tput.txt"
2392 #define HTTPPATH "http://localhost/rawhide/toad/tput.txt"
2393 #define FTPPATH "ftp://localhost/home/test/tput.txt"
2395 { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
2396 { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
2397 N_("debug protocol data stream"), NULL},
2398 - { "noneon", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noNeon, 1,
2399 - N_("disable use of libneon for HTTP"), NULL},
2400 { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
2401 N_("debug rpmio I/O"), NULL},
2402 { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
2403 diff -ur rpm-4.4.7.org/rpmio/url.c rpm-4.4.7/rpmio/url.c
2404 --- rpm-4.4.7.org/rpmio/url.c 2006-08-06 02:31:18.000000000 +0200
2405 +++ rpm-4.4.7/rpmio/url.c 2006-10-17 22:21:51.747411750 +0200
2408 if (u->sess != NULL) {
2409 /* HACK: neon include has prototype. */
2410 - ne_session_destroy(u->sess);
2413 u->buf = _free(u->buf);
2416 { "file://", URL_IS_PATH },
2417 { "ftp://", URL_IS_FTP },
2418 - { "hkp://", URL_IS_HKP },
2419 - { "http://", URL_IS_HTTP },
2420 - { "https://", URL_IS_HTTPS },
2421 { "-", URL_IS_DASH },
2422 { NULL, URL_IS_UNKNOWN }