summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/rpmdav.c74
-rw-r--r--rpmio/rpmio.c26
-rw-r--r--rpmio/rpmrpc.c36
-rw-r--r--rpmio/tget.c10
4 files changed, 80 insertions, 66 deletions
diff --git a/rpmio/rpmdav.c b/rpmio/rpmdav.c
index 686fb077e..5eef314ca 100644
--- a/rpmio/rpmdav.c
+++ b/rpmio/rpmdav.c
@@ -83,7 +83,7 @@ assert(u == ne_get_session_private(sess, "urlinfo"));
u->current = current;
u->total = total;
-if (_dav_debug)
+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);
}
@@ -116,7 +116,7 @@ typedef enum {
u->connstatus = connstatus;
-if (_dav_debug)
+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)]);
}
@@ -140,7 +140,7 @@ assert(sess != NULL);
private = ne_get_session_private(sess, id);
assert(u == private);
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davCreateRequest(%p,%p,%s,%s) %s:%p\n", req, userdata, method, uri, id, private);
}
@@ -160,10 +160,10 @@ assert(u == ne_get_session_private(sess, "urlinfo"));
fd = ne_get_request_private(req, id);
-if (_dav_debug) {
+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);
-}
}
@@ -183,7 +183,7 @@ assert(u == ne_get_session_private(sess, "urlinfo"));
fd = ne_get_request_private(req, id);
-if (_dav_debug)
+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;
}
@@ -204,7 +204,7 @@ assert(u == ne_get_session_private(sess, "urlinfo"));
fd = ne_get_request_private(req, id);
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davDestroyRequest(%p,%p) sess %p %s %p\n", req, userdata, sess, id, fd);
}
@@ -224,7 +224,7 @@ assert(sess != NULL);
private = ne_get_session_private(sess, id);
assert(u == private);
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davDestroySession(%p) sess %p %s %p\n", userdata, sess, id, private);
}
@@ -234,7 +234,7 @@ davVerifyCert(void *userdata, int failures, const ne_ssl_certificate *cert)
{
const char *hostname = userdata;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davVerifyCert(%p,%d,%p) %s\n", userdata, failures, cert, hostname);
return 0; /* HACK: trust all server certificates. */
@@ -252,13 +252,14 @@ static int davInit(const char * url, urlinfo * uret)
return -1; /* XXX error returns needed. */
/*@=globs@*/
- if (u->urltype == URL_IS_HTTPS && u->url != NULL && u->sess == NULL) {
+ if ((u->urltype == URL_IS_HTTP || u->urltype == URL_IS_HTTPS)
+ && u->url != NULL && u->sess == NULL)
+ {
ne_server_capabilities * capabilities;
/* HACK: oneshots should be done Somewhere Else Instead. */
/*@-noeffect@*/
- xx = (_dav_debug ? NE_DBG_HTTP : 0);
- xx = 0; /* HACK */
+ xx = ((_dav_debug < 0) ? NE_DBG_HTTP : 0);
ne_debug_init(stderr, xx); /* XXX oneshot? */
/*@=noeffect@*/
xx = ne_sock_init(); /* XXX oneshot? */
@@ -535,12 +536,12 @@ static void fetch_results(void *userdata, const char *uri,
newres = ne_propset_private(set);
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "==> %s in uri %s\n", path, ctx->uri);
if (ne_path_compare(ctx->uri, path) == 0 && !ctx->include_target) {
/* This is the target URI */
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "==> %s skipping target resource.\n", path);
/* Free the private structure. */
free(newres);
@@ -678,7 +679,7 @@ static int davFetch(const urlinfo u, struct fetch_context_s * ctx)
/*@=nullpass@*/
xx = argvAdd(&ctx->av, val);
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** argvAdd(%p,\"%s\")\n", &ctx->av, val);
NE_FREE(val);
@@ -783,7 +784,7 @@ static int my_result(const char * msg, int ret, FILE * fp)
/*@*/
{
/* HACK: don't print unless debugging. */
- if (_dav_debug == 0)
+ if (_dav_debug >= 0)
return ret;
if (fp == NULL)
fp = stderr;
@@ -817,7 +818,7 @@ static void davAcceptRanges(void * userdata, const char * value)
{
urlinfo u = userdata;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** u %p Accept-Ranges: %s\n", u, value);
if (!strcmp(value, "bytes"))
u->httpHasRange = 1;
@@ -837,7 +838,7 @@ static void davContentLength(void * userdata, const char * value)
{
FD_t ctrl = userdata;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** fd %p Content-Length: %s\n", ctrl, value);
ctrl->contentLength = strtoll(value, NULL, 10);
}
@@ -846,7 +847,7 @@ static void davConnection(void * userdata, const char * value)
{
FD_t ctrl = userdata;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** fd %p Connection: %s\n", ctrl, value);
if (!strcasecmp(value, "close"))
ctrl->persist = 0;
@@ -862,14 +863,9 @@ int davResp(urlinfo u, FD_t ctrl, /*@unused@*/ char *const * str)
rc = ne_begin_request(ctrl->req);
rc = my_result("ne_begin_req(ctrl->req)", rc, NULL);
-if (_dav_debug)
+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);
-#ifdef NOTYET
-if (_ftp_debug)
-fprintf(stderr, "<- %s", resp);
-#endif
-
/* HACK: stupid error impedence matching. */
switch (rc) {
case NE_OK: rc = 0; break;
@@ -902,7 +898,7 @@ assert(ctrl != NULL);
u = ctrl->url;
URLSANE(u);
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davReq(%p,%s,\"%s\") entry sess %p req %p\n", ctrl, httpCmd, httpArg, u->sess, ctrl->req);
/* HACK: handle proxy host and port here. */
@@ -953,7 +949,7 @@ fprintf(stderr, "-> %s", req);
if (rc)
goto errxit;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davReq(%p,%s,\"%s\") exit sess %p req %p rc %d\n", ctrl, httpCmd, httpArg, u->sess, ctrl->req, rc);
ctrl = fdLink(ctrl, "open data (davReq)");
@@ -978,7 +974,7 @@ FD_t davOpen(const char * url, /*@unused@*/ int flags,
assert(!(flags & O_RDWR));
#endif
-if (_dav_debug)
+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)
@@ -1003,7 +999,7 @@ fprintf(stderr, "*** davOpen(%s,0x%x,0%o,%p)\n", url, flags, mode, uret);
fd->contentLength = fd->bytesRemain = -1;
fd->url = urlLink(u, "url (davOpen)");
fd = fdLink(fd, "grab data (davOpen)");
-assert(urlType == URL_IS_HTTPS);
+assert(urlType == URL_IS_HTTPS || urlType == URL_IS_HTTP);
fd->urlType = urlType; /* URL_IS_HTTPS */
}
@@ -1024,7 +1020,7 @@ ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
rc = ne_read_response_block(fd->req, buf, count);
-if (_dav_debug) {
+if (_dav_debug < 0) {
fprintf(stderr, "*** davRead(%p,%p,0x%x) rc 0x%x\n", cookie, buf, count, (unsigned)rc);
#ifdef DYING
hexdump(buf, rc);
@@ -1040,7 +1036,7 @@ ssize_t davWrite(void * cookie, const char * buf, size_t count)
FD_t fd = cookie;
return ne_read_response_block(fd->req, buf, count);
#else
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davWrite(%p,%p,0x%x)\n", cookie, buf, count);
return -1;
#endif
@@ -1048,7 +1044,7 @@ fprintf(stderr, "*** davWrite(%p,%p,0x%x)\n", cookie, buf, count);
int davSeek(void * cookie, _libio_pos_t pos, int whence)
{
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence);
return -1;
}
@@ -1065,7 +1061,7 @@ assert(fd->req != NULL);
ne_request_destroy(fd->req);
fd->req = NULL;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davClose(%p) rc %d\n", fd, rc);
return rc;
}
@@ -1179,7 +1175,7 @@ int davStat(const char * path, /*@out@*/ struct stat *st)
/* XXX fts(3) needs/uses st_ino, make something up for now. */
if (st->st_ino == 0)
st->st_ino = dav_st_ino++;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
exit:
ctx = fetch_destroy_context(ctx);
@@ -1224,7 +1220,7 @@ int davLstat(const char * path, /*@out@*/ struct stat *st)
/* XXX fts(3) needs/uses st_ino, make something up for now. */
if (st->st_ino == 0)
st->st_ino = dav_st_ino++;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
exit:
ctx = fetch_destroy_context(ctx);
@@ -1239,7 +1235,7 @@ static int davReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
{
int rc;
rc = davNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davReadlink(%s) rc %d\n", path, rc);
return rc;
}
@@ -1375,7 +1371,7 @@ int davClosedir(/*@only@*/ DIR * dir)
{
DAVDIR avdir = (DAVDIR)dir;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davClosedir(%p)\n", avdir);
#if defined(HAVE_PTHREAD_H)
@@ -1429,7 +1425,7 @@ struct dirent * davReaddir(DIR * dir)
/*@=type@*/
strncpy(dp->d_name, av[i], sizeof(dp->d_name));
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davReaddir(%p) %p \"%s\"\n", (void *)avdir, dp, dp->d_name);
return dp;
@@ -1448,7 +1444,7 @@ DIR * davOpendir(const char * path)
int ac, nac;
int rc;
-if (_dav_debug)
+if (_dav_debug < 0)
fprintf(stderr, "*** davOpendir(%s)\n", path);
/* Load DAV collection into argv. */
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index aa6b1a6d7..b40d82a00 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -94,6 +94,9 @@ int noLibio = 0;
int noLibio = 1;
#endif
+/*@unchecked@*/
+int noNeon = 0;
+
#define TIMEOUT_SECS 60
/**
@@ -460,10 +463,9 @@ static int fdClose( /*@only@*/ void * cookie)
fdstat_enter(fd, FDSTAT_CLOSE);
/* HACK: flimsy wiring for davClose */
- if (fd->req != NULL) {
+ if (fd->req != NULL)
rc = davClose(fd);
-assert(fd->req == NULL);
- } else
+ else
rc = ((fdno >= 0) ? close(fdno) : -2);
fdstat_exit(fd, FDSTAT_CLOSE, rc);
@@ -514,6 +516,10 @@ int fdWritable(FD_t fd, int secs)
FD_ZERO(&wrfds);
#endif
+ /* HACK: flimsy wiring for davWrite */
+ if (fd->req != NULL)
+ return 1;
+
if ((fdno = fdFileno(fd)) < 0)
return -1; /* XXX W2DO? */
@@ -1416,10 +1422,6 @@ static int urlConnect(const char * url, /*@out@*/ urlinfo * uret)
}
}
}
-#ifdef NOTYET
- if (u->urltype == URL_IS_HTTPS) {
- }
-#endif
/*@-boundswrite@*/
if (uret != NULL)
@@ -2064,8 +2066,8 @@ static /*@null@*/ FD_t httpOpen(const char * url, /*@unused@*/ int flags,
fd->contentLength = fd->bytesRemain = -1;
fd->url = urlLink(u, "url (httpOpen)");
fd = fdLink(fd, "grab data (httpOpen)");
- fd->urlType = URL_IS_HTTP;
- /* XXX URL_IS_HTTPS */
+assert(u->urltype == URL_IS_HTTP);
+ fd->urlType = u->urltype;
}
exit:
@@ -2115,6 +2117,8 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mo
}
break;
case URL_IS_HTTPS:
+ case URL_IS_HTTP:
+ if (!noNeon) {
fd = davOpen(url, flags, mode, &u);
if (fd == NULL || u == NULL)
break;
@@ -2134,8 +2138,7 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mo
fd->wr_chunked = ((!strcmp(cmd, "PUT"))
? fd->wr_chunked : 0);
}
- break;
- case URL_IS_HTTP:
+ } else {
fd = httpOpen(url, flags, mode, &u);
if (fd == NULL || u == NULL)
break;
@@ -2155,6 +2158,7 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mo
fd->wr_chunked = ((!strcmp(cmd, "PUT"))
? fd->wr_chunked : 0);
}
+ }
break;
case URL_IS_DASH:
assert(!(flags & O_RDWR));
diff --git a/rpmio/rpmrpc.c b/rpmio/rpmrpc.c
index a3052ebdb..4f06b52c0 100644
--- a/rpmio/rpmrpc.c
+++ b/rpmio/rpmrpc.c
@@ -20,6 +20,9 @@
/*@access FD_t @*/
/*@access urlinfo @*/
+/*@unchecked@*/
+extern int noNeon;
+
/**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
* @param p memory to free
@@ -1260,9 +1263,10 @@ fprintf(stderr, "*** Stat(%s,%p)\n", path, st);
return ftpStat(path, st);
/*@notreached@*/ break;
case URL_IS_HTTPS:
- return davStat(path, st);
- /*@notreached@*/ break;
- case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
+ case URL_IS_HTTP:
+ if (!noNeon)
+ return davStat(path, st);
+ /*@fallthrough@*/ /* WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
/*@fallthrough@*/
@@ -1288,9 +1292,10 @@ fprintf(stderr, "*** Lstat(%s,%p)\n", path, st);
return ftpLstat(path, st);
/*@notreached@*/ break;
case URL_IS_HTTPS:
- return davLstat(path, st);
- /*@notreached@*/ break;
- case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
+ case URL_IS_HTTP:
+ if (!noNeon)
+ return davLstat(path, st);
+ /*@fallthrough@*/ /* WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
/*@fallthrough@*/
@@ -1412,6 +1417,13 @@ fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)e
/*@=castfcnptr@*/
switch (ut) {
case URL_IS_HTTPS:
+ case URL_IS_HTTP:
+ if (noNeon) { /* XXX WRONG WRONG WRONG */
+ flags &= ~GLOB_TILDE;
+ pattern = lpath;
+ break;
+ }
+ /*@fallthrough@*/
case URL_IS_FTP:
/*@-type@*/
pglob->gl_closedir = Closedir;
@@ -1423,9 +1435,6 @@ fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)e
flags |= GLOB_ALTDIRFUNC;
flags &= ~GLOB_TILDE;
break;
- case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
- flags &= ~GLOB_TILDE;
- /*@fallthrough@*/
case URL_IS_PATH:
pattern = lpath;
/*@fallthrough@*/
@@ -1457,10 +1466,11 @@ fprintf(stderr, "*** Opendir(%s)\n", path);
case URL_IS_FTP:
return ftpOpendir(path);
/*@notreached@*/ break;
- case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
- return davOpendir(path);
- /*@notreached@*/ break;
- case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
+ case URL_IS_HTTPS:
+ case URL_IS_HTTP:
+ if (!noNeon)
+ return davOpendir(path);
+ /*@fallthrough@*/ /* WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
/*@fallthrough@*/
diff --git a/rpmio/tget.c b/rpmio/tget.c
index a97871ffd..fdea5e4cb 100644
--- a/rpmio/tget.c
+++ b/rpmio/tget.c
@@ -9,6 +9,8 @@
static int _debug = 0;
+extern int noNeon;
+
#define HTTPSPATH "https://wellfleet.jbj.org/test.txt"
#define HTTPPATH "http://wellfleet.jbj.org/test.txt"
#define FTPPATH "ftp://wellfleet.jbj.org/test.txt"
@@ -38,6 +40,8 @@ static struct poptOption optionsTable[] = {
{ "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
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,
N_("debug rpmio I/O"), NULL},
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
@@ -70,7 +74,7 @@ main(int argc, const char *argv[])
_av_debug = -1;
_ftp_debug = -1;
-_dav_debug = -1;
+_dav_debug = 1;
#if 0
readFile(dirpath);
#endif
@@ -79,12 +83,12 @@ _dav_debug = -1;
readFile(ftppath);
readFile(ftppath);
#endif
-#if 0
+#if 1
readFile(httppath);
readFile(httppath);
readFile(httppath);
#endif
-#if 1
+#if 0
readFile(httpspath);
readFile(httpspath);
readFile(httpspath);