Remove NEON and related hacks
This commit is contained in:
parent
6b780c2772
commit
d36716c25c
35
configure.ac
35
configure.ac
|
@ -422,41 +422,6 @@ AC_CHECK_HEADERS([beecrypt/beecrypt.h], [
|
||||||
AC_SUBST(WITH_BEECRYPT_INCLUDE)
|
AC_SUBST(WITH_BEECRYPT_INCLUDE)
|
||||||
AC_SUBST(WITH_BEECRYPT_LIB)
|
AC_SUBST(WITH_BEECRYPT_LIB)
|
||||||
|
|
||||||
#=================
|
|
||||||
# Check for neon library. Prefer external, otherwise none.
|
|
||||||
AC_ARG_WITH(neon, [ --with-neon enable neon support],
|
|
||||||
[case "$with_neon" in
|
|
||||||
yes|no) ;;
|
|
||||||
*) AC_MSG_ERROR([invalid argument to --with-neon])
|
|
||||||
;;
|
|
||||||
esac],
|
|
||||||
[with_neon=no])
|
|
||||||
|
|
||||||
WITH_NEON_INCLUDE=
|
|
||||||
WITH_NEON_LIB=
|
|
||||||
AS_IF([test "$with_neon" = yes],[
|
|
||||||
AC_CHECK_HEADER([neon/ne_session.h], [
|
|
||||||
AC_CHECK_LIB(neon, ne_session_create, [
|
|
||||||
AC_DEFINE(HAVE_LIBNEON, 1, [Define to 1 if you have the 'neon' library (-lneon).])
|
|
||||||
AC_CHECK_LIB(neon, ne_get_response_header, [
|
|
||||||
AC_DEFINE(HAVE_NEON_NE_GET_RESPONSE_HEADER, 1, [Define to 1 if you have ne_get_response_header() in libneon.])
|
|
||||||
])
|
|
||||||
AC_CHECK_LIB(neon, ne_send_request_chunk, [
|
|
||||||
AC_DEFINE(HAVE_NEON_NE_SEND_REQUEST_CHUNK, 1, [Define to 1 if you have ne_send_request_chunk() in libneon.])
|
|
||||||
])
|
|
||||||
WITH_NEON_INCLUDE=
|
|
||||||
WITH_NEON_LIB="-lneon"
|
|
||||||
AC_DEFINE(WITH_NEON,1,[Build with neon support?])
|
|
||||||
],[
|
|
||||||
AC_MSG_ERROR([--with-neon given, but required library libneon not found])
|
|
||||||
])
|
|
||||||
],[
|
|
||||||
AC_MSG_ERROR([--with-neon given, but required header neon/ne_session.h not found])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
AC_SUBST(WITH_NEON_INCLUDE)
|
|
||||||
AC_SUBST(WITH_NEON_LIB)
|
|
||||||
|
|
||||||
#=================
|
#=================
|
||||||
# Check for magic library.
|
# Check for magic library.
|
||||||
WITH_MAGIC_INCLUDE=
|
WITH_MAGIC_INCLUDE=
|
||||||
|
|
|
@ -71,8 +71,6 @@ const char * rpmcliRootDir = "/";
|
||||||
rpmQueryFlags rpmcliQueryFlags;
|
rpmQueryFlags rpmcliQueryFlags;
|
||||||
|
|
||||||
extern int _ftp_debug;
|
extern int _ftp_debug;
|
||||||
extern int _av_debug;
|
|
||||||
extern int _dav_debug;
|
|
||||||
|
|
||||||
extern int noLibio;
|
extern int noLibio;
|
||||||
|
|
||||||
|
@ -264,10 +262,6 @@ struct poptOption rpmcliAllPoptTable[] = {
|
||||||
N_("use threads for file state machine"), NULL},
|
N_("use threads for file state machine"), NULL},
|
||||||
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
||||||
N_("debug FTP/HTTP data stream"), NULL},
|
N_("debug FTP/HTTP data stream"), NULL},
|
||||||
{ "avdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_av_debug, -1,
|
|
||||||
N_("debug argv collections"), NULL},
|
|
||||||
{ "davdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_dav_debug, -1,
|
|
||||||
N_("debug WebDAV data stream"), NULL},
|
|
||||||
{ "hdrdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_hdr_debug, -1,
|
{ "hdrdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_hdr_debug, -1,
|
||||||
NULL, NULL},
|
NULL, NULL},
|
||||||
#ifdef DYING
|
#ifdef DYING
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
AM_CPPFLAGS = -I. \
|
AM_CPPFLAGS = -I. \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
@WITH_BEECRYPT_INCLUDE@ \
|
@WITH_BEECRYPT_INCLUDE@ \
|
||||||
@WITH_NEON_INCLUDE@ \
|
|
||||||
@WITH_LUA_INCLUDE@ \
|
@WITH_LUA_INCLUDE@ \
|
||||||
@WITH_POPT_INCLUDE@ \
|
@WITH_POPT_INCLUDE@ \
|
||||||
-I$(top_srcdir)/misc
|
-I$(top_srcdir)/misc
|
||||||
|
@ -11,21 +10,20 @@ AM_CPPFLAGS += -DRPMCONFIGDIR="\"@RPMCONFIGDIR@\""
|
||||||
|
|
||||||
pkgincdir = $(pkgincludedir)
|
pkgincdir = $(pkgincludedir)
|
||||||
pkginc_HEADERS = \
|
pkginc_HEADERS = \
|
||||||
argv.h fts.h rpmdav.h \
|
argv.h fts.h \
|
||||||
rpmio.h rpmurl.h rpmmacro.h rpmlog.h rpmmessages.h rpmerr.h rpmpgp.h \
|
rpmio.h rpmurl.h rpmmacro.h rpmlog.h rpmmessages.h rpmerr.h rpmpgp.h \
|
||||||
rpmsq.h rpmsw.h ugid.h
|
rpmsq.h rpmsw.h ugid.h
|
||||||
|
|
||||||
usrlibdir = $(libdir)
|
usrlibdir = $(libdir)
|
||||||
usrlib_LTLIBRARIES = librpmio.la
|
usrlib_LTLIBRARIES = librpmio.la
|
||||||
librpmio_la_SOURCES = \
|
librpmio_la_SOURCES = \
|
||||||
argv.c digest.c fts.c macro.c rpmdav.c \
|
argv.c digest.c fts.c macro.c \
|
||||||
rpmhook.c rpmio.c rpmlog.c rpmlua.c rpmmalloc.c \
|
rpmhook.c rpmio.c rpmlog.c rpmlua.c rpmmalloc.c \
|
||||||
rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c stubs.c url.c ugid.c \
|
rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c stubs.c url.c ugid.c \
|
||||||
rpmio_internal.h rpmlua.h rpmhook.h
|
rpmio_internal.h rpmlua.h rpmhook.h
|
||||||
librpmio_la_LDFLAGS = -release 4.4
|
librpmio_la_LDFLAGS = -release 4.4
|
||||||
librpmio_la_LIBADD = \
|
librpmio_la_LIBADD = \
|
||||||
@WITH_BEECRYPT_LIB@ \
|
@WITH_BEECRYPT_LIB@ \
|
||||||
@WITH_NEON_LIB@ \
|
|
||||||
@WITH_LUA_LIB@ \
|
@WITH_LUA_LIB@ \
|
||||||
@WITH_MAGIC_LIB@ \
|
@WITH_MAGIC_LIB@ \
|
||||||
@WITH_ZLIB_LIB@ \
|
@WITH_ZLIB_LIB@ \
|
||||||
|
@ -53,10 +51,6 @@ check_PROGRAMS += thkp
|
||||||
thkp_SOURCES = thkp.c rpmio_internal.h
|
thkp_SOURCES = thkp.c rpmio_internal.h
|
||||||
thkp_LDADD = librpmio.la @WITH_POPT_LIB@
|
thkp_LDADD = librpmio.la @WITH_POPT_LIB@
|
||||||
|
|
||||||
check_PROGRAMS += tput
|
|
||||||
tput_SOURCES = tput.c rpmio_internal.h
|
|
||||||
tput_LDADD = librpmio.la @WITH_POPT_LIB@
|
|
||||||
|
|
||||||
check_PROGRAMS += tglob
|
check_PROGRAMS += tglob
|
||||||
tglob_SOURCES = tglob.c rpmio_internal.h
|
tglob_SOURCES = tglob.c rpmio_internal.h
|
||||||
tglob_LDADD = librpmio.la @WITH_POPT_LIB@
|
tglob_LDADD = librpmio.la @WITH_POPT_LIB@
|
||||||
|
|
663
rpmio/rpmdav.c
663
rpmio/rpmdav.c
|
@ -1,663 +0,0 @@
|
||||||
/** \ingroup rpmio
|
|
||||||
* \file rpmio/rpmdav.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "system.h"
|
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_H)
|
|
||||||
#include <pthread.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_NEON
|
|
||||||
|
|
||||||
#include "neon/ne_alloc.h"
|
|
||||||
#include "neon/ne_auth.h"
|
|
||||||
#include "neon/ne_basic.h"
|
|
||||||
#include "neon/ne_dates.h"
|
|
||||||
#include "neon/ne_locks.h"
|
|
||||||
|
|
||||||
#include "neon/ne_props.h"
|
|
||||||
#include "neon/ne_request.h"
|
|
||||||
#include "neon/ne_socket.h"
|
|
||||||
#include "neon/ne_string.h"
|
|
||||||
#include "neon/ne_utils.h"
|
|
||||||
|
|
||||||
/* XXX don't assume access to neon internal headers, ugh.. */
|
|
||||||
#define NEONBLOWSCHUNKS
|
|
||||||
|
|
||||||
#endif /* WITH_NEON */
|
|
||||||
|
|
||||||
#include <rpmio_internal.h>
|
|
||||||
|
|
||||||
#define _RPMDAV_INTERNAL
|
|
||||||
#include <rpmdav.h>
|
|
||||||
|
|
||||||
#include "argv.h"
|
|
||||||
#include "ugid.h"
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if 0 /* HACK: reasonable value needed. */
|
|
||||||
#define TIMEOUT_SECS 60
|
|
||||||
#else
|
|
||||||
#define TIMEOUT_SECS 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_NEON
|
|
||||||
static int httpTimeoutSecs = TIMEOUT_SECS;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
|
|
||||||
* @param p memory to free
|
|
||||||
* @retval NULL always
|
|
||||||
*/
|
|
||||||
static inline void *
|
|
||||||
_free(const void * p)
|
|
||||||
{
|
|
||||||
if (p != NULL) free((void *)p);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WITH_NEON
|
|
||||||
|
|
||||||
/* =============================================================== */
|
|
||||||
|
|
||||||
static void davProgress(void * userdata, off_t current, off_t total)
|
|
||||||
{
|
|
||||||
urlinfo u = userdata;
|
|
||||||
ne_session * sess;
|
|
||||||
|
|
||||||
assert(u != NULL);
|
|
||||||
sess = u->sess;
|
|
||||||
assert(sess != NULL);
|
|
||||||
assert(u == ne_get_session_private(sess, "urlinfo"));
|
|
||||||
|
|
||||||
u->current = current;
|
|
||||||
u->total = total;
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davProgress(%p,0x%x:0x%x) sess %p u %p\n", userdata, (unsigned int)current, (unsigned int)total, sess, u);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void davNotify(void * userdata,
|
|
||||||
ne_conn_status connstatus, const char * info)
|
|
||||||
{
|
|
||||||
urlinfo u = userdata;
|
|
||||||
ne_session * sess;
|
|
||||||
static const char * connstates[] = {
|
|
||||||
"namelookup",
|
|
||||||
"connecting",
|
|
||||||
"connected",
|
|
||||||
"secure",
|
|
||||||
"unknown"
|
|
||||||
};
|
|
||||||
|
|
||||||
assert(u != NULL);
|
|
||||||
sess = u->sess;
|
|
||||||
assert(sess != NULL);
|
|
||||||
assert(u == ne_get_session_private(sess, "urlinfo"));
|
|
||||||
|
|
||||||
#ifdef REFERENCE
|
|
||||||
typedef enum {
|
|
||||||
ne_conn_namelookup, /* lookup up hostname (info = hostname) */
|
|
||||||
ne_conn_connecting, /* connecting to host (info = hostname) */
|
|
||||||
ne_conn_connected, /* connected to host (info = hostname) */
|
|
||||||
ne_conn_secure /* connection now secure (info = crypto level) */
|
|
||||||
} ne_conn_status;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
u->connstatus = connstatus;
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davNotify(%p,%d,%p) sess %p u %p %s\n", userdata, connstatus, info, sess, u, connstates[ (connstatus < 4 ? connstatus : 4)]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void davCreateRequest(ne_request * req, void * userdata,
|
|
||||||
const char * method, const char * uri)
|
|
||||||
{
|
|
||||||
urlinfo u = userdata;
|
|
||||||
ne_session * sess;
|
|
||||||
void * private = NULL;
|
|
||||||
const char * id = "urlinfo";
|
|
||||||
|
|
||||||
assert(u != NULL);
|
|
||||||
assert(u->sess != NULL);
|
|
||||||
assert(req != NULL);
|
|
||||||
sess = ne_get_session(req);
|
|
||||||
assert(sess == u->sess);
|
|
||||||
assert(u == ne_get_session_private(sess, "urlinfo"));
|
|
||||||
|
|
||||||
assert(sess != NULL);
|
|
||||||
private = ne_get_session_private(sess, id);
|
|
||||||
assert(u == private);
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davCreateRequest(%p,%p,%s,%s) %s:%p\n", req, userdata, method, uri, id, private);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void davPreSend(ne_request * req, void * userdata, ne_buffer * buf)
|
|
||||||
{
|
|
||||||
urlinfo u = userdata;
|
|
||||||
ne_session * sess;
|
|
||||||
const char * id = "fd";
|
|
||||||
FD_t fd = NULL;
|
|
||||||
|
|
||||||
assert(u != NULL);
|
|
||||||
assert(u->sess != NULL);
|
|
||||||
assert(req != NULL);
|
|
||||||
sess = ne_get_session(req);
|
|
||||||
assert(sess == u->sess);
|
|
||||||
assert(u == ne_get_session_private(sess, "urlinfo"));
|
|
||||||
|
|
||||||
fd = ne_get_request_private(req, id);
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davPreSend(%p,%p,%p) sess %p %s %p\n", req, userdata, buf, sess, id, fd);
|
|
||||||
if (_dav_debug)
|
|
||||||
fprintf(stderr, "-> %s\n", buf->data);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static int davPostSend(ne_request * req, void * userdata, const ne_status * status)
|
|
||||||
{
|
|
||||||
urlinfo u = userdata;
|
|
||||||
ne_session * sess;
|
|
||||||
const char * id = "fd";
|
|
||||||
FD_t fd = NULL;
|
|
||||||
|
|
||||||
assert(u != NULL);
|
|
||||||
assert(u->sess != NULL);
|
|
||||||
assert(req != NULL);
|
|
||||||
sess = ne_get_session(req);
|
|
||||||
assert(sess == u->sess);
|
|
||||||
assert(u == ne_get_session_private(sess, "urlinfo"));
|
|
||||||
|
|
||||||
fd = ne_get_request_private(req, id);
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davPostSend(%p,%p,%p) sess %p %s %p %s\n", req, userdata, status, sess, id, fd, ne_get_error(sess));
|
|
||||||
return NE_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void davDestroyRequest(ne_request * req, void * userdata)
|
|
||||||
{
|
|
||||||
urlinfo u = userdata;
|
|
||||||
ne_session * sess;
|
|
||||||
const char * id = "fd";
|
|
||||||
FD_t fd = NULL;
|
|
||||||
|
|
||||||
assert(u != NULL);
|
|
||||||
assert(u->sess != NULL);
|
|
||||||
assert(req != NULL);
|
|
||||||
sess = ne_get_session(req);
|
|
||||||
assert(sess == u->sess);
|
|
||||||
assert(u == ne_get_session_private(sess, "urlinfo"));
|
|
||||||
|
|
||||||
fd = ne_get_request_private(req, id);
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davDestroyRequest(%p,%p) sess %p %s %p\n", req, userdata, sess, id, fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void davDestroySession(void * userdata)
|
|
||||||
{
|
|
||||||
urlinfo u = userdata;
|
|
||||||
ne_session * sess;
|
|
||||||
void * private = NULL;
|
|
||||||
const char * id = "urlinfo";
|
|
||||||
|
|
||||||
assert(u != NULL);
|
|
||||||
assert(u->sess != NULL);
|
|
||||||
sess = u->sess;
|
|
||||||
assert(u == ne_get_session_private(sess, "urlinfo"));
|
|
||||||
|
|
||||||
assert(sess != NULL);
|
|
||||||
private = ne_get_session_private(sess, id);
|
|
||||||
assert(u == private);
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davDestroySession(%p) sess %p %s %p\n", userdata, sess, id, private);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
davVerifyCert(void *userdata, int failures, const ne_ssl_certificate *cert)
|
|
||||||
{
|
|
||||||
const char *hostname = userdata;
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davVerifyCert(%p,%d,%p) %s\n", userdata, failures, cert, hostname);
|
|
||||||
|
|
||||||
return 0; /* HACK: trust all server certificates. */
|
|
||||||
}
|
|
||||||
|
|
||||||
static int davConnect(urlinfo u)
|
|
||||||
{
|
|
||||||
const char * path = NULL;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
/* HACK: hkp:// has no steenkin' options */
|
|
||||||
if (!(u->urltype == URL_IS_HTTP || u->urltype == URL_IS_HTTPS))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* HACK: where should server capabilities be read? */
|
|
||||||
(void) urlPath(u->url, &path);
|
|
||||||
/* HACK: perhaps capture Allow: tag, look for PUT permitted. */
|
|
||||||
rc = ne_options(u->sess, path, u->capabilities);
|
|
||||||
switch (rc) {
|
|
||||||
case NE_OK:
|
|
||||||
break;
|
|
||||||
case NE_ERROR:
|
|
||||||
/* HACK: "301 Moved Permanently" on empty subdir. */
|
|
||||||
if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
|
|
||||||
break;
|
|
||||||
case NE_CONNECT:
|
|
||||||
case NE_LOOKUP:
|
|
||||||
default:
|
|
||||||
if (_dav_debug)
|
|
||||||
fprintf(stderr, "*** Connect to %s:%d failed(%d):\n\t%s\n",
|
|
||||||
u->host, u->port, rc, ne_get_error(u->sess));
|
|
||||||
u = urlLink(u, __FUNCTION__); /* XXX error exit refcount adjustment */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* HACK: sensitive to error returns? */
|
|
||||||
u->httpVersion = (ne_version_pre_http11(u->sess) ? 0 : 1);
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int davInit(const char * url, urlinfo * uret)
|
|
||||||
{
|
|
||||||
urlinfo u = NULL;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
if (urlSplit(url, &u))
|
|
||||||
return -1; /* XXX error returns needed. */
|
|
||||||
|
|
||||||
if (u->url != NULL && u->sess == NULL)
|
|
||||||
switch (u->urltype) {
|
|
||||||
default:
|
|
||||||
assert(u->urltype != u->urltype);
|
|
||||||
break;
|
|
||||||
case URL_IS_HTTPS:
|
|
||||||
case URL_IS_HTTP:
|
|
||||||
case URL_IS_HKP:
|
|
||||||
{ ne_server_capabilities * capabilities;
|
|
||||||
|
|
||||||
/* HACK: oneshots should be done Somewhere Else Instead. */
|
|
||||||
rc = ((_dav_debug < 0) ? NE_DBG_HTTP : 0);
|
|
||||||
ne_debug_init(stderr, rc); /* XXX oneshot? */
|
|
||||||
rc = ne_sock_init(); /* XXX oneshot? */
|
|
||||||
|
|
||||||
u->lockstore = ne_lockstore_create(); /* XXX oneshot? */
|
|
||||||
|
|
||||||
u->capabilities = capabilities = xcalloc(1, sizeof(*capabilities));
|
|
||||||
u->sess = ne_session_create(u->scheme, u->host, u->port);
|
|
||||||
|
|
||||||
ne_lockstore_register(u->lockstore, u->sess);
|
|
||||||
|
|
||||||
if (u->proxyh != NULL)
|
|
||||||
ne_session_proxy(u->sess, u->proxyh, u->proxyp);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
{ const ne_inet_addr ** addrs;
|
|
||||||
unsigned int n;
|
|
||||||
ne_set_addrlist(u->sess, addrs, n);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ne_set_progress(u->sess, davProgress, u);
|
|
||||||
ne_set_status(u->sess, davNotify, u);
|
|
||||||
|
|
||||||
ne_set_persist(u->sess, 1);
|
|
||||||
ne_set_read_timeout(u->sess, httpTimeoutSecs);
|
|
||||||
ne_set_useragent(u->sess, PACKAGE "/" PACKAGE_VERSION);
|
|
||||||
|
|
||||||
/* XXX check that neon is ssl enabled. */
|
|
||||||
if (!strcasecmp(u->scheme, "https"))
|
|
||||||
ne_ssl_set_verify(u->sess, davVerifyCert, (char *)u->host);
|
|
||||||
|
|
||||||
ne_set_session_private(u->sess, "urlinfo", u);
|
|
||||||
|
|
||||||
ne_hook_destroy_session(u->sess, davDestroySession, u);
|
|
||||||
|
|
||||||
ne_hook_create_request(u->sess, davCreateRequest, u);
|
|
||||||
ne_hook_pre_send(u->sess, davPreSend, u);
|
|
||||||
ne_hook_post_send(u->sess, davPostSend, u);
|
|
||||||
ne_hook_destroy_request(u->sess, davDestroyRequest, u);
|
|
||||||
|
|
||||||
/* HACK: where should server capabilities be read? */
|
|
||||||
rc = davConnect(u);
|
|
||||||
if (rc)
|
|
||||||
goto exit;
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
|
||||||
if (rc == 0 && uret != NULL)
|
|
||||||
*uret = urlLink(u, __FUNCTION__);
|
|
||||||
u = urlFree(u, "urlSplit (davInit)");
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* =============================================================== */
|
|
||||||
static int my_result(const char * msg, int ret, FILE * fp)
|
|
||||||
{
|
|
||||||
/* HACK: don't print unless debugging. */
|
|
||||||
if (_dav_debug >= 0)
|
|
||||||
return ret;
|
|
||||||
if (fp == NULL)
|
|
||||||
fp = stderr;
|
|
||||||
if (msg != NULL)
|
|
||||||
fprintf(fp, "*** %s: ", msg);
|
|
||||||
|
|
||||||
/* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */
|
|
||||||
#ifdef HACK
|
|
||||||
fprintf(fp, "%s: %s\n", ftpStrerror(-ret), ne_get_error(sess));
|
|
||||||
#else
|
|
||||||
fprintf(fp, "%s\n", ftpStrerror(-ret));
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DYING
|
|
||||||
static void hexdump(const unsigned char * buf, ssize_t len)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (len <= 0)
|
|
||||||
return;
|
|
||||||
for (i = 0; i < len; i++) {
|
|
||||||
if (i != 0 && (i%16) == 0)
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
fprintf(stderr, " %02X", buf[i]);
|
|
||||||
}
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void davAcceptRanges(void * userdata, const char * value)
|
|
||||||
{
|
|
||||||
urlinfo u = userdata;
|
|
||||||
|
|
||||||
if (!(u && value)) return;
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** u %p Accept-Ranges: %s\n", u, value);
|
|
||||||
if (!strcmp(value, "bytes"))
|
|
||||||
u->httpHasRange = 1;
|
|
||||||
if (!strcmp(value, "none"))
|
|
||||||
u->httpHasRange = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
|
|
||||||
static void davAllHeaders(void * userdata, const char * value)
|
|
||||||
{
|
|
||||||
FD_t ctrl = userdata;
|
|
||||||
|
|
||||||
if (!(ctrl && value)) return;
|
|
||||||
if (_dav_debug)
|
|
||||||
fprintf(stderr, "<- %s\n", value);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void davContentLength(void * userdata, const char * value)
|
|
||||||
{
|
|
||||||
FD_t ctrl = userdata;
|
|
||||||
|
|
||||||
if (!(ctrl && value)) return;
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** fd %p Content-Length: %s\n", ctrl, value);
|
|
||||||
ctrl->contentLength = strtoll(value, NULL, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void davConnection(void * userdata, const char * value)
|
|
||||||
{
|
|
||||||
FD_t ctrl = userdata;
|
|
||||||
|
|
||||||
if (!(ctrl && value)) return;
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** fd %p Connection: %s\n", ctrl, value);
|
|
||||||
if (!strcasecmp(value, "close"))
|
|
||||||
ctrl->persist = 0;
|
|
||||||
else if (!strcasecmp(value, "Keep-Alive"))
|
|
||||||
ctrl->persist = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* HACK: stash error in *str. */
|
|
||||||
int davResp(urlinfo u, FD_t ctrl, char *const * str)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
rc = ne_begin_request(ctrl->req);
|
|
||||||
rc = my_result("ne_begin_req(ctrl->req)", rc, NULL);
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davResp(%p,%p,%p) sess %p req %p rc %d\n", u, ctrl, str, u->sess, ctrl->req, rc);
|
|
||||||
|
|
||||||
/* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */
|
|
||||||
if (rc)
|
|
||||||
fdSetSyserrno(ctrl, errno, ftpStrerror(-rc));
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg)
|
|
||||||
{
|
|
||||||
urlinfo u;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
assert(ctrl != NULL);
|
|
||||||
u = ctrl->url;
|
|
||||||
URLSANE(u);
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davReq(%p,%s,\"%s\") entry sess %p req %p\n", ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req);
|
|
||||||
|
|
||||||
ctrl->persist = (u->httpVersion > 0 ? 1 : 0);
|
|
||||||
ctrl = fdLink(ctrl, "open ctrl (davReq)");
|
|
||||||
|
|
||||||
assert(u->sess != NULL);
|
|
||||||
assert(ctrl->req == NULL);
|
|
||||||
ctrl->req = ne_request_create(u->sess, httpCmd, httpArg);
|
|
||||||
assert(ctrl->req != NULL);
|
|
||||||
|
|
||||||
ne_set_request_private(ctrl->req, "fd", ctrl);
|
|
||||||
|
|
||||||
#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
|
|
||||||
ne_add_response_header_catcher(ctrl->req, davAllHeaders, ctrl);
|
|
||||||
|
|
||||||
ne_add_response_header_handler(ctrl->req, "Content-Length",
|
|
||||||
davContentLength, ctrl);
|
|
||||||
ne_add_response_header_handler(ctrl->req, "Connection",
|
|
||||||
davConnection, ctrl);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!strcmp(httpCmd, "PUT")) {
|
|
||||||
#if defined(HAVE_NEON_NE_SEND_REQUEST_CHUNK)
|
|
||||||
ctrl->wr_chunked = 1;
|
|
||||||
ne_add_request_header(ctrl->req, "Transfer-Encoding", "chunked");
|
|
||||||
ne_set_request_chunked(ctrl->req, 1);
|
|
||||||
/* HACK: no retries if/when chunking. */
|
|
||||||
rc = davResp(u, ctrl, NULL);
|
|
||||||
#else
|
|
||||||
rc = FTPERR_SERVER_IO_ERROR;
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
/* HACK: possible Last-Modified: Tue, 02 Nov 2004 14:29:36 GMT */
|
|
||||||
/* HACK: possible ETag: "inode-size-mtime" */
|
|
||||||
#if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
|
|
||||||
ne_add_response_header_handler(ctrl->req, "Accept-Ranges",
|
|
||||||
davAcceptRanges, u);
|
|
||||||
#endif
|
|
||||||
/* HACK: possible Transfer-Encoding: on GET. */
|
|
||||||
|
|
||||||
/* HACK: other errors may need retry too. */
|
|
||||||
/* HACK: neon retries once, gud enuf. */
|
|
||||||
/* HACK: retry counter? */
|
|
||||||
do {
|
|
||||||
rc = davResp(u, ctrl, NULL);
|
|
||||||
} while (rc == NE_RETRY);
|
|
||||||
}
|
|
||||||
if (rc)
|
|
||||||
goto errxit;
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davReq(%p,%s,\"%s\") exit sess %p req %p rc %d\n", ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req, rc);
|
|
||||||
|
|
||||||
#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
|
|
||||||
davContentLength(ctrl,
|
|
||||||
ne_get_response_header(ctrl->req, "Content-Length"));
|
|
||||||
davConnection(ctrl,
|
|
||||||
ne_get_response_header(ctrl->req, "Connection"));
|
|
||||||
if (strcmp(httpCmd, "PUT"))
|
|
||||||
davAcceptRanges(u,
|
|
||||||
ne_get_response_header(ctrl->req, "Accept-Ranges"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ctrl = fdLink(ctrl, "open data (davReq)");
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
errxit:
|
|
||||||
fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
|
|
||||||
|
|
||||||
/* HACK balance fd refs. ne_session_destroy to tear down non-keepalive? */
|
|
||||||
ctrl = fdLink(ctrl, "error data (davReq)");
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
FD_t davOpen(const char * url, int flags,
|
|
||||||
mode_t mode, urlinfo * uret)
|
|
||||||
{
|
|
||||||
const char * path = NULL;
|
|
||||||
urltype urlType = urlPath(url, &path);
|
|
||||||
urlinfo u = NULL;
|
|
||||||
FD_t fd = NULL;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
#if 0 /* XXX makeTempFile() heartburn */
|
|
||||||
assert(!(flags & O_RDWR));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davOpen(%s,0x%x,0%o,%p)\n", url, flags, mode, uret);
|
|
||||||
rc = davInit(url, &u);
|
|
||||||
if (rc || u == NULL || u->sess == NULL)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
if (u->ctrl == NULL)
|
|
||||||
u->ctrl = fdNew("persist ctrl (davOpen)");
|
|
||||||
if (u->ctrl->nrefs > 2 && u->data == NULL)
|
|
||||||
u->data = fdNew("persist data (davOpen)");
|
|
||||||
|
|
||||||
if (u->ctrl->url == NULL)
|
|
||||||
fd = fdLink(u->ctrl, "grab ctrl (davOpen persist ctrl)");
|
|
||||||
else if (u->data->url == NULL)
|
|
||||||
fd = fdLink(u->data, "grab ctrl (davOpen persist data)");
|
|
||||||
else
|
|
||||||
fd = fdNew("grab ctrl (davOpen)");
|
|
||||||
|
|
||||||
if (fd) {
|
|
||||||
fdSetIo(fd, ufdio);
|
|
||||||
fd->ftpFileDoneNeeded = 0;
|
|
||||||
fd->rd_timeoutsecs = httpTimeoutSecs;
|
|
||||||
fd->contentLength = fd->bytesRemain = -1;
|
|
||||||
fd->url = urlLink(u, "url (davOpen)");
|
|
||||||
fd = fdLink(fd, "grab data (davOpen)");
|
|
||||||
assert(urlType == URL_IS_HTTPS || urlType == URL_IS_HTTP || urlType == URL_IS_HKP);
|
|
||||||
fd->urlType = urlType;
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
|
||||||
if (uret)
|
|
||||||
*uret = u;
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t davRead(void * cookie, char * buf, size_t count)
|
|
||||||
{
|
|
||||||
FD_t fd = cookie;
|
|
||||||
ssize_t rc;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
assert(count >= 128); /* HACK: see ne_request.h comment */
|
|
||||||
#endif
|
|
||||||
rc = ne_read_response_block(fd->req, buf, count);
|
|
||||||
|
|
||||||
if (_dav_debug < 0) {
|
|
||||||
fprintf(stderr, "*** davRead(%p,%p,0x%x) rc 0x%x\n", cookie, buf, (unsigned)count, (unsigned)rc);
|
|
||||||
#ifdef DYING
|
|
||||||
hexdump(buf, rc);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t davWrite(void * cookie, const char * buf, size_t count)
|
|
||||||
{
|
|
||||||
ssize_t rc;
|
|
||||||
int xx;
|
|
||||||
|
|
||||||
#ifndef NEONBLOWSCHUNKS
|
|
||||||
ne_session * sess;
|
|
||||||
|
|
||||||
assert(fd->req != NULL);
|
|
||||||
sess = ne_get_session(fd->req);
|
|
||||||
assert(sess != NULL);
|
|
||||||
|
|
||||||
/* HACK: include ne_private.h to access sess->socket for now. */
|
|
||||||
xx = ne_sock_fullwrite(sess->socket, buf, count);
|
|
||||||
#else
|
|
||||||
#if defined(HAVE_NEON_NE_SEND_REQUEST_CHUNK)
|
|
||||||
assert(fd->req != NULL);
|
|
||||||
xx = ne_send_request_chunk(fd->req, buf, count);
|
|
||||||
#else
|
|
||||||
errno = EIO; /* HACK */
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* HACK: stupid error impedence matching. */
|
|
||||||
rc = (xx == 0 ? count : -1);
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davWrite(%p,%p,0x%x) rc 0x%x\n", cookie, buf, (unsigned)count, (unsigned)rc);
|
|
||||||
#ifdef DYING
|
|
||||||
if (count > 0)
|
|
||||||
hexdump(buf, count);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
int davSeek(void * cookie, _libio_pos_t pos, int whence)
|
|
||||||
{
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int davClose(void * cookie)
|
|
||||||
{
|
|
||||||
FD_t fd = cookie;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
assert(fd->req != NULL);
|
|
||||||
rc = ne_end_request(fd->req);
|
|
||||||
rc = my_result("ne_end_request(req)", rc, NULL);
|
|
||||||
|
|
||||||
ne_request_destroy(fd->req);
|
|
||||||
fd->req = NULL;
|
|
||||||
|
|
||||||
if (_dav_debug < 0)
|
|
||||||
fprintf(stderr, "*** davClose(%p) rc %d\n", fd, rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* WITH_NEON */
|
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
#ifndef RPMDAV_H
|
|
||||||
#define RPMDAV_H
|
|
||||||
|
|
||||||
/** \ingroup rpmio
|
|
||||||
* \file rpmio/rpmdav.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a http request.
|
|
||||||
* @param ctrl
|
|
||||||
* @param httpCmd http command
|
|
||||||
* @param httpArg http command argument (NULL if none)
|
|
||||||
* @returns 0 on success
|
|
||||||
*/
|
|
||||||
int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read a http response.
|
|
||||||
* @param u
|
|
||||||
* @param cntl
|
|
||||||
* @retval *str error msg
|
|
||||||
* @returns 0 on success
|
|
||||||
*/
|
|
||||||
int davResp(urlinfo u, FD_t ctrl, char *const * str);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
FD_t davOpen(const char * url, int flags,
|
|
||||||
mode_t mode, urlinfo * uret);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
ssize_t davRead(void * cookie, char * buf, size_t count);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
ssize_t davWrite(void * cookie, const char * buf, size_t count);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
int davSeek(void * cookie, _libio_pos_t pos, int whence);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
int davClose(void * cookie);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* RPMDAV_H */
|
|
|
@ -65,7 +65,6 @@ static int inet_aton(const char *cp, struct in_addr *inp)
|
||||||
#undef fdClose
|
#undef fdClose
|
||||||
#define fdClose __fdClose
|
#define fdClose __fdClose
|
||||||
|
|
||||||
#include <rpmdav.h>
|
|
||||||
#include "ugid.h"
|
#include "ugid.h"
|
||||||
#include "rpmmessages.h"
|
#include "rpmmessages.h"
|
||||||
|
|
||||||
|
@ -105,18 +104,10 @@ static int httpTimeoutSecs = TIMEOUT_SECS;
|
||||||
*/
|
*/
|
||||||
int _rpmio_debug = 0;
|
int _rpmio_debug = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
int _av_debug = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
int _ftp_debug = 0;
|
int _ftp_debug = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
int _dav_debug = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
|
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
|
||||||
* @param p memory to free
|
* @param p memory to free
|
||||||
|
@ -340,18 +331,7 @@ static ssize_t fdRead(void * cookie, char * buf, size_t count)
|
||||||
if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
|
if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
|
||||||
|
|
||||||
fdstat_enter(fd, FDSTAT_READ);
|
fdstat_enter(fd, FDSTAT_READ);
|
||||||
/* HACK: flimsy wiring for davRead */
|
rc = read(fdFileno(fd), buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
|
||||||
if (fd->req != NULL) {
|
|
||||||
#ifdef WITH_NEON
|
|
||||||
rc = davRead(fd, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
|
|
||||||
#else
|
|
||||||
rc = -1;
|
|
||||||
#endif
|
|
||||||
/* XXX Chunked davRead EOF. */
|
|
||||||
if (rc == 0)
|
|
||||||
fd->bytesRemain = 0;
|
|
||||||
} else
|
|
||||||
rc = read(fdFileno(fd), buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
|
|
||||||
fdstat_exit(fd, FDSTAT_READ, rc);
|
fdstat_exit(fd, FDSTAT_READ, rc);
|
||||||
|
|
||||||
if (fd->ndigests && rc > 0) fdUpdateDigests(fd, (void *)buf, rc);
|
if (fd->ndigests && rc > 0) fdUpdateDigests(fd, (void *)buf, rc);
|
||||||
|
@ -374,15 +354,7 @@ static ssize_t fdWrite(void * cookie, const char * buf, size_t count)
|
||||||
if (count == 0) return 0;
|
if (count == 0) return 0;
|
||||||
|
|
||||||
fdstat_enter(fd, FDSTAT_WRITE);
|
fdstat_enter(fd, FDSTAT_WRITE);
|
||||||
/* HACK: flimsy wiring for davWrite */
|
rc = write(fdno, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
|
||||||
if (fd->req != NULL) {
|
|
||||||
#ifdef WITH_NEON
|
|
||||||
rc = davWrite(fd, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
} else
|
|
||||||
rc = write(fdno, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
|
|
||||||
fdstat_exit(fd, FDSTAT_WRITE, rc);
|
fdstat_exit(fd, FDSTAT_WRITE, rc);
|
||||||
|
|
||||||
DBGIO(fd, (stderr, "==>\tfdWrite(%p,%p,%ld) rc %ld %s\n", cookie, buf, (long)count, (long)rc, fdbg(fd)));
|
DBGIO(fd, (stderr, "==>\tfdWrite(%p,%p,%ld) rc %ld %s\n", cookie, buf, (long)count, (long)rc, fdbg(fd)));
|
||||||
|
@ -423,15 +395,7 @@ static int fdClose( void * cookie)
|
||||||
fdSetFdno(fd, -1);
|
fdSetFdno(fd, -1);
|
||||||
|
|
||||||
fdstat_enter(fd, FDSTAT_CLOSE);
|
fdstat_enter(fd, FDSTAT_CLOSE);
|
||||||
/* HACK: flimsy wiring for davClose */
|
rc = ((fdno >= 0) ? close(fdno) : -2);
|
||||||
if (fd->req != NULL) {
|
|
||||||
#ifdef WITH_NEON
|
|
||||||
rc = davClose(fd);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
} else
|
|
||||||
rc = ((fdno >= 0) ? close(fdno) : -2);
|
|
||||||
fdstat_exit(fd, FDSTAT_CLOSE, rc);
|
fdstat_exit(fd, FDSTAT_CLOSE, rc);
|
||||||
|
|
||||||
DBGIO(fd, (stderr, "==>\tfdClose(%p) rc %lx %s\n", (fd ? fd : NULL), (unsigned long)rc, fdbg(fd)));
|
DBGIO(fd, (stderr, "==>\tfdClose(%p) rc %lx %s\n", (fd ? fd : NULL), (unsigned long)rc, fdbg(fd)));
|
||||||
|
@ -478,10 +442,6 @@ int fdWritable(FD_t fd, int secs)
|
||||||
FD_ZERO(&wrfds);
|
FD_ZERO(&wrfds);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* HACK: flimsy wiring for davWrite */
|
|
||||||
if (fd->req != NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if ((fdno = fdFileno(fd)) < 0)
|
if ((fdno = fdFileno(fd)) < 0)
|
||||||
return -1; /* XXX W2DO? */
|
return -1; /* XXX W2DO? */
|
||||||
|
|
||||||
|
@ -530,10 +490,6 @@ int fdReadable(FD_t fd, int secs)
|
||||||
FD_ZERO(&rdfds);
|
FD_ZERO(&rdfds);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* HACK: flimsy wiring for davRead */
|
|
||||||
if (fd->req != NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if ((fdno = fdFileno(fd)) < 0)
|
if ((fdno = fdFileno(fd)) < 0)
|
||||||
return -1; /* XXX W2DO? */
|
return -1; /* XXX W2DO? */
|
||||||
|
|
||||||
|
@ -2001,7 +1957,6 @@ exit:
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WITH_NEON
|
|
||||||
/* FIX: u->{ctrl,data}->url undef after XurlLink. */
|
/* FIX: u->{ctrl,data}->url undef after XurlLink. */
|
||||||
static FD_t httpOpen(const char * url, int flags,
|
static FD_t httpOpen(const char * url, int flags,
|
||||||
mode_t mode, urlinfo * uret)
|
mode_t mode, urlinfo * uret)
|
||||||
|
@ -2042,7 +1997,6 @@ exit:
|
||||||
*uret = u;
|
*uret = u;
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static FD_t ufdOpen(const char * url, int flags, mode_t mode)
|
static FD_t ufdOpen(const char * url, int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
|
@ -2079,11 +2033,7 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mo
|
||||||
case URL_IS_HTTPS:
|
case URL_IS_HTTPS:
|
||||||
case URL_IS_HTTP:
|
case URL_IS_HTTP:
|
||||||
case URL_IS_HKP:
|
case URL_IS_HKP:
|
||||||
#ifdef WITH_NEON
|
|
||||||
fd = davOpen(url, flags, mode, &u);
|
|
||||||
#else
|
|
||||||
fd = httpOpen(url, flags, mode, &u);
|
fd = httpOpen(url, flags, mode, &u);
|
||||||
#endif
|
|
||||||
if (fd == NULL || u == NULL)
|
if (fd == NULL || u == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2091,11 +2041,7 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mo
|
||||||
? ((flags & O_APPEND) ? "PUT" :
|
? ((flags & O_APPEND) ? "PUT" :
|
||||||
((flags & O_CREAT) ? "PUT" : "PUT"))
|
((flags & O_CREAT) ? "PUT" : "PUT"))
|
||||||
: "GET");
|
: "GET");
|
||||||
#ifdef WITH_NEON
|
|
||||||
u->openError = davReq(fd, cmd, path);
|
|
||||||
#else
|
|
||||||
u->openError = httpReq(fd, cmd, path);
|
u->openError = httpReq(fd, cmd, path);
|
||||||
#endif
|
|
||||||
if (u->openError < 0) {
|
if (u->openError < 0) {
|
||||||
/* XXX make sure that we can exit through ufdClose */
|
/* XXX make sure that we can exit through ufdClose */
|
||||||
fd = fdLink(fd, "error ctrl (ufdOpen HTTP)");
|
fd = fdLink(fd, "error ctrl (ufdOpen HTTP)");
|
||||||
|
@ -2946,10 +2892,6 @@ int Ferror(FD_t fd)
|
||||||
int i, rc = 0;
|
int i, rc = 0;
|
||||||
|
|
||||||
if (fd == NULL) return -1;
|
if (fd == NULL) return -1;
|
||||||
if (fd->req != NULL) {
|
|
||||||
/* HACK: flimsy wiring for neon errors. */
|
|
||||||
rc = (fd->syserrno || fd->errcookie != NULL) ? -1 : 0;
|
|
||||||
} else
|
|
||||||
for (i = fd->nfps; rc == 0 && i >= 0; i--) {
|
for (i = fd->nfps; rc == 0 && i >= 0; i--) {
|
||||||
FDSTACK_t * fps = &fd->fps[i];
|
FDSTACK_t * fps = &fd->fps[i];
|
||||||
int ec;
|
int ec;
|
||||||
|
|
|
@ -169,12 +169,8 @@ struct _FD_s {
|
||||||
|
|
||||||
extern int _rpmio_debug;
|
extern int _rpmio_debug;
|
||||||
|
|
||||||
extern int _av_debug;
|
|
||||||
|
|
||||||
extern int _ftp_debug;
|
extern int _ftp_debug;
|
||||||
|
|
||||||
extern int _dav_debug;
|
|
||||||
|
|
||||||
#define DBG(_f, _m, _x) \
|
#define DBG(_f, _m, _x) \
|
||||||
\
|
\
|
||||||
if ((_rpmio_debug | ((_f) ? ((FD_t)(_f))->flags : 0)) & (_m)) fprintf _x \
|
if ((_rpmio_debug | ((_f) ? ((FD_t)(_f))->flags : 0)) & (_m)) fprintf _x \
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
|
|
||||||
#include <rpmio_internal.h>
|
#include <rpmio_internal.h>
|
||||||
|
|
||||||
#define _RPMDAV_INTERNAL
|
|
||||||
#include <rpmdav.h>
|
|
||||||
|
|
||||||
#include "ugid.h"
|
#include "ugid.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
|
@ -44,21 +44,6 @@ int nrefs; /*!< no. of references */
|
||||||
FD_t ctrl; /*!< control channel */
|
FD_t ctrl; /*!< control channel */
|
||||||
FD_t data; /*!< per-xfer data channel */
|
FD_t data; /*!< per-xfer data channel */
|
||||||
|
|
||||||
void * capabilities; /*!< neon: ne_server_capabilities ptr */
|
|
||||||
void * lockstore; /*!< neon: ne_lock_store ptr */
|
|
||||||
void * sess; /*!< neon: ne_session ptr */
|
|
||||||
off_t current; /*!< neon: current body offset. */
|
|
||||||
off_t total; /*!< neon: total body length. */
|
|
||||||
int connstatus; /*!< neon: connection status. */
|
|
||||||
#ifdef REFERENCE
|
|
||||||
typedef enum {
|
|
||||||
ne_conn_namelookup, /* lookup up hostname (info = hostname) */
|
|
||||||
ne_conn_connecting, /* connecting to host (info = hostname) */
|
|
||||||
ne_conn_connected, /* connected to host (info = hostname) */
|
|
||||||
ne_conn_secure /* connection now secure (info = crypto level) */
|
|
||||||
} ne_conn_status;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int bufAlloced; /*!< sizeof I/O buffer */
|
int bufAlloced; /*!< sizeof I/O buffer */
|
||||||
char * buf; /*!< I/O buffer */
|
char * buf; /*!< I/O buffer */
|
||||||
int openError; /*!< Type of open failure */
|
int openError; /*!< Type of open failure */
|
||||||
|
|
|
@ -71,9 +71,7 @@ main(int argc, const char *argv[])
|
||||||
rpmIncreaseVerbosity();
|
rpmIncreaseVerbosity();
|
||||||
}
|
}
|
||||||
|
|
||||||
_av_debug = -1;
|
|
||||||
_ftp_debug = -1;
|
_ftp_debug = -1;
|
||||||
_dav_debug = -1;
|
|
||||||
printDir(dirpath);
|
printDir(dirpath);
|
||||||
printDir(ftppath);
|
printDir(ftppath);
|
||||||
printDir(httppath);
|
printDir(httppath);
|
||||||
|
|
|
@ -161,9 +161,7 @@ main(int argc, const char *argv[])
|
||||||
if (ftsOpts == 0)
|
if (ftsOpts == 0)
|
||||||
ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT);
|
ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT);
|
||||||
|
|
||||||
_av_debug = -1;
|
|
||||||
_ftp_debug = -1;
|
_ftp_debug = -1;
|
||||||
_dav_debug = 1;
|
|
||||||
#if 0
|
#if 0
|
||||||
ftsWalk(dirpath);
|
ftsWalk(dirpath);
|
||||||
ftsWalk(ftppath);
|
ftsWalk(ftppath);
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
static int _debug = 0;
|
static int _debug = 0;
|
||||||
|
|
||||||
int noNeon;
|
|
||||||
|
|
||||||
#define HTTPSPATH "https://localhost/test.txt"
|
#define HTTPSPATH "https://localhost/test.txt"
|
||||||
#define HTTPPATH "http://localhost/test.txt"
|
#define HTTPPATH "http://localhost/test.txt"
|
||||||
#define FTPPATH "ftp://localhost/test.txt"
|
#define FTPPATH "ftp://localhost/test.txt"
|
||||||
|
@ -40,8 +38,6 @@ static struct poptOption optionsTable[] = {
|
||||||
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
|
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
|
||||||
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
||||||
N_("debug protocol data stream"), NULL},
|
N_("debug protocol data stream"), NULL},
|
||||||
{ "noneon", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noNeon, 1,
|
|
||||||
N_("disable use of libneon for HTTP"), NULL},
|
|
||||||
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
||||||
N_("debug rpmio I/O"), NULL},
|
N_("debug rpmio I/O"), NULL},
|
||||||
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
||||||
|
@ -72,9 +68,7 @@ main(int argc, const char *argv[])
|
||||||
rpmIncreaseVerbosity();
|
rpmIncreaseVerbosity();
|
||||||
}
|
}
|
||||||
|
|
||||||
_av_debug = -1;
|
|
||||||
_ftp_debug = -1;
|
_ftp_debug = -1;
|
||||||
_dav_debug = 1;
|
|
||||||
#if 1
|
#if 1
|
||||||
readFile(dirpath);
|
readFile(dirpath);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
static int _debug = 0;
|
static int _debug = 0;
|
||||||
|
|
||||||
int noNeon;
|
|
||||||
|
|
||||||
#define HTTPSPATH "https://localhost/rawhide/test/*.rpm"
|
#define HTTPSPATH "https://localhost/rawhide/test/*.rpm"
|
||||||
#if 0
|
#if 0
|
||||||
#define HTTPPATH "http://localhost/rawhide/test/*.rpm"
|
#define HTTPPATH "http://localhost/rawhide/test/*.rpm"
|
||||||
|
@ -54,8 +52,6 @@ static struct poptOption optionsTable[] = {
|
||||||
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
|
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
|
||||||
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
||||||
N_("debug protocol data stream"), NULL},
|
N_("debug protocol data stream"), NULL},
|
||||||
{ "noneon", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noNeon, 1,
|
|
||||||
N_("disable use of libneon for HTTP"), NULL},
|
|
||||||
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
||||||
N_("debug rpmio I/O"), NULL},
|
N_("debug rpmio I/O"), NULL},
|
||||||
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
||||||
|
@ -86,9 +82,7 @@ main(int argc, const char *argv[])
|
||||||
rpmIncreaseVerbosity();
|
rpmIncreaseVerbosity();
|
||||||
}
|
}
|
||||||
|
|
||||||
_av_debug = -1;
|
|
||||||
_ftp_debug = -1;
|
_ftp_debug = -1;
|
||||||
_dav_debug = -1;
|
|
||||||
#if 0
|
#if 0
|
||||||
printGlob(dirpath);
|
printGlob(dirpath);
|
||||||
printGlob(ftppath);
|
printGlob(ftppath);
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
static int _debug = 0;
|
static int _debug = 0;
|
||||||
static int _printing = 0;
|
static int _printing = 0;
|
||||||
|
|
||||||
int noNeon;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define HKPPATH "hkp://pgp.mit.edu:11371/pks/lookup?op=get&search=0xF5C75256"
|
#define HKPPATH "hkp://pgp.mit.edu:11371/pks/lookup?op=get&search=0xF5C75256"
|
||||||
#else
|
#else
|
||||||
|
@ -91,12 +89,8 @@ static struct poptOption optionsTable[] = {
|
||||||
{ "print", 'p', POPT_ARG_VAL, &_printing, 1, NULL, NULL },
|
{ "print", 'p', POPT_ARG_VAL, &_printing, 1, NULL, NULL },
|
||||||
{ "noprint", 'n', POPT_ARG_VAL, &_printing, 0, NULL, NULL },
|
{ "noprint", 'n', POPT_ARG_VAL, &_printing, 0, NULL, NULL },
|
||||||
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
|
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
|
||||||
{ "davdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_dav_debug, -1,
|
|
||||||
N_("debug protocol data stream"), NULL},
|
|
||||||
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
||||||
N_("debug protocol data stream"), NULL},
|
N_("debug protocol data stream"), NULL},
|
||||||
{ "noneon", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noNeon, 1,
|
|
||||||
N_("disable use of libneon for HTTP"), NULL},
|
|
||||||
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
||||||
N_("debug rpmio I/O"), NULL},
|
N_("debug rpmio I/O"), NULL},
|
||||||
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
static int _debug = 0;
|
static int _debug = 0;
|
||||||
|
|
||||||
int noNeon;
|
|
||||||
|
|
||||||
#define HTTPSPATH "https://localhost/rawhide/toad/tput.txt"
|
#define HTTPSPATH "https://localhost/rawhide/toad/tput.txt"
|
||||||
#define HTTPPATH "http://localhost/rawhide/toad/tput.txt"
|
#define HTTPPATH "http://localhost/rawhide/toad/tput.txt"
|
||||||
#define FTPPATH "ftp://localhost/home/test/tput.txt"
|
#define FTPPATH "ftp://localhost/home/test/tput.txt"
|
||||||
|
@ -100,8 +98,6 @@ static struct poptOption optionsTable[] = {
|
||||||
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
|
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
|
||||||
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
||||||
N_("debug protocol data stream"), NULL},
|
N_("debug protocol data stream"), NULL},
|
||||||
{ "noneon", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noNeon, 1,
|
|
||||||
N_("disable use of libneon for HTTP"), NULL},
|
|
||||||
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
||||||
N_("debug rpmio I/O"), NULL},
|
N_("debug rpmio I/O"), NULL},
|
||||||
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
||||||
|
@ -132,9 +128,7 @@ main(int argc, const char *argv[])
|
||||||
rpmIncreaseVerbosity();
|
rpmIncreaseVerbosity();
|
||||||
}
|
}
|
||||||
|
|
||||||
_av_debug = -1;
|
|
||||||
_ftp_debug = -1;
|
_ftp_debug = -1;
|
||||||
_dav_debug = -1;
|
|
||||||
#if 0
|
#if 0
|
||||||
doFile(dirpath);
|
doFile(dirpath);
|
||||||
doFile(ftppath);
|
doFile(ftppath);
|
||||||
|
|
|
@ -130,13 +130,6 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
|
||||||
u, u->data, (u->host ? u->host : ""),
|
u, u->data, (u->host ? u->host : ""),
|
||||||
(u->scheme ? u->scheme : ""));
|
(u->scheme ? u->scheme : ""));
|
||||||
}
|
}
|
||||||
if (u->sess != NULL) {
|
|
||||||
#ifdef WITH_NEON
|
|
||||||
/* HACK: neon include has prototype. */
|
|
||||||
ne_session_destroy(u->sess);
|
|
||||||
#endif
|
|
||||||
u->sess = NULL;
|
|
||||||
}
|
|
||||||
u->buf = _free(u->buf);
|
u->buf = _free(u->buf);
|
||||||
u->url = _free(u->url);
|
u->url = _free(u->url);
|
||||||
u->scheme = _free((void *)u->scheme);
|
u->scheme = _free((void *)u->scheme);
|
||||||
|
|
Loading…
Reference in New Issue