Paul Nasrat 6de784
Allow build without the neon library. Resurrects old httpOpen
Paul Nasrat 6de784
code from rpm-4.1.1.
Paul Nasrat 6de784
Building without neon means no webdav file uploads, though.
Paul Nasrat 6de784
Paul Nasrat 6de784
Index: rpm-4.4.2/rpmio/rpmdav.c
Paul Nasrat 6de784
===================================================================
Paul Nasrat 6de784
--- rpm-4.4.2.orig/rpmio/rpmdav.c
Paul Nasrat 6de784
+++ rpm-4.4.2/rpmio/rpmdav.c
Paul Nasrat 6de784
@@ -9,6 +9,8 @@
Paul Nasrat 6de784
 #include <pthread.h>
Paul Nasrat 6de784
 #endif
Paul Nasrat 6de784
 
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
+
Paul Nasrat 6de784
 #include "ne_alloc.h"
Paul Nasrat 6de784
 #include "ne_auth.h"
Paul Nasrat 6de784
 #include "ne_basic.h"
Paul Nasrat 6de784
@@ -27,6 +29,8 @@
Paul Nasrat 6de784
 #include "ne_string.h"
Paul Nasrat 6de784
 #include "ne_utils.h"
Paul Nasrat 6de784
 
Paul Nasrat 6de784
+#endif /* WITH_NEON */
Paul Nasrat 6de784
+
Paul Nasrat 6de784
 #include <rpmio_internal.h>
Paul Nasrat 6de784
 
Paul Nasrat 6de784
 #define _RPMDAV_INTERNAL
Paul Nasrat 6de784
@@ -61,6 +65,8 @@ _free(/*@only@*/ /*@null@*/ /*@out@*/ co
Paul Nasrat 6de784
     return NULL;
Paul Nasrat 6de784
 }
Paul Nasrat 6de784
 
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
+
Paul Nasrat 6de784
 /* =============================================================== */
Paul Nasrat 6de784
 static int davFree(urlinfo u)
Paul Nasrat 6de784
 	/*@globals internalState @*/
Paul Nasrat 6de784
@@ -1370,6 +1376,8 @@ fprintf(stderr, "*** davReadlink(%s) rc 
Paul Nasrat 6de784
 }
Paul Nasrat 6de784
 #endif	/* NOTYET */
Paul Nasrat 6de784
 
Paul Nasrat 6de784
+#endif /* WITH_NEON */
Paul Nasrat 6de784
+
Paul Nasrat 6de784
 /* =============================================================== */
Paul Nasrat 6de784
 /*@unchecked@*/
Paul Nasrat 6de784
 int avmagicdir = 0x3607113;
Paul Nasrat 6de784
@@ -1494,6 +1502,8 @@ fprintf(stderr, "*** avOpendir(%s)\n", p
Paul Nasrat 6de784
 }
Paul Nasrat 6de784
 /*@=boundswrite@*/
Paul Nasrat 6de784
 
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
+
Paul Nasrat 6de784
 /* =============================================================== */
Paul Nasrat 6de784
 /*@unchecked@*/
Paul Nasrat 6de784
 int davmagicdir = 0x8440291;
Paul Nasrat 6de784
@@ -1661,4 +1671,6 @@ fprintf(stderr, "*** davOpendir(%s)\n", 
Paul Nasrat 6de784
     return (DIR *) avdir;
Paul Nasrat 6de784
 /*@=kepttrans@*/
Paul Nasrat 6de784
 }
Paul Nasrat 6de784
+
Paul Nasrat 6de784
+#endif /* WITH_NEON */
Paul Nasrat 6de784
 /*@=modfilesys@*/
Paul Nasrat 6de784
Index: rpm-4.4.2/rpmio/rpmio.c
Paul Nasrat 6de784
===================================================================
Paul Nasrat 6de784
--- rpm-4.4.2.orig/rpmio/rpmio.c
Paul Nasrat 6de784
+++ rpm-4.4.2/rpmio/rpmio.c
Paul Nasrat 6de784
@@ -375,7 +375,11 @@ static ssize_t fdRead(void * cookie, /*@
Paul Nasrat 6de784
 /*@-boundswrite@*/
Paul Nasrat 6de784
     /* HACK: flimsy wiring for davRead */
Paul Nasrat 6de784
     if (fd->req != NULL) {
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	rc = davRead(fd, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
Paul Nasrat 6de784
+#else
Paul Nasrat 6de784
+	rc = -1;
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	/* XXX Chunked davRead EOF. */
Paul Nasrat 6de784
 	if (rc == 0)
Paul Nasrat 6de784
 	    fd->bytesRemain = 0;
Paul Nasrat 6de784
@@ -408,9 +412,13 @@ static ssize_t fdWrite(void * cookie, co
Paul Nasrat 6de784
     fdstat_enter(fd, FDSTAT_WRITE);
Paul Nasrat 6de784
 /*@-boundsread@*/
Paul Nasrat 6de784
     /* HACK: flimsy wiring for davWrite */
Paul Nasrat 6de784
-    if (fd->req != NULL)
Paul Nasrat 6de784
+    if (fd->req != NULL) {
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	rc = davWrite(fd, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
Paul Nasrat 6de784
-    else
Paul Nasrat 6de784
+#else
Paul Nasrat 6de784
+	return -1;
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
+    } else
Paul Nasrat 6de784
 	rc = write(fdno, buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
Paul Nasrat 6de784
 /*@=boundsread@*/
Paul Nasrat 6de784
     fdstat_exit(fd, FDSTAT_WRITE, rc);
Paul Nasrat 6de784
@@ -459,9 +467,13 @@ static int fdClose( /*@only@*/ void * co
Paul Nasrat 6de784
     fdstat_enter(fd, FDSTAT_CLOSE);
Paul Nasrat 6de784
     /* HACK: flimsy wiring for davClose */
Paul Nasrat 6de784
 /*@-branchstate@*/
Paul Nasrat 6de784
-    if (fd->req != NULL)
Paul Nasrat 6de784
+    if (fd->req != NULL) {
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	rc = davClose(fd);
Paul Nasrat 6de784
-    else
Paul Nasrat 6de784
+#else
Paul Nasrat 6de784
+	return -1;
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
+    } else
Paul Nasrat 6de784
 	rc = ((fdno >= 0) ? close(fdno) : -2);
Paul Nasrat 6de784
 /*@=branchstate@*/
Paul Nasrat 6de784
     fdstat_exit(fd, FDSTAT_CLOSE, rc);
Paul Nasrat 6de784
@@ -2182,6 +2194,56 @@ exit:
Paul Nasrat 6de784
 }
Paul Nasrat 6de784
 /*@=nullstate@*/
Paul Nasrat 6de784
 
Paul Nasrat 6de784
+#ifndef WITH_NEON
Paul Nasrat 6de784
+/*@-nullstate@*/        /* FIX: u->{ctrl,data}->url undef after XurlLink. */
Paul Nasrat 6de784
+static /*@null@*/ FD_t httpOpen(const char * url, /*@unused@*/ int flags,
Paul Nasrat 6de784
+                /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
Paul Nasrat 6de784
+        /*@globals internalState @*/
Paul Nasrat 6de784
+        /*@modifies *uret, internalState @*/
Paul Nasrat 6de784
+{
Paul Nasrat 6de784
+    urlinfo u = NULL;
Paul Nasrat 6de784
+    FD_t fd = NULL;
Paul Nasrat 6de784
+
Paul Nasrat 6de784
+#if 0   /* XXX makeTempFile() heartburn */
Paul Nasrat 6de784
+    assert(!(flags & O_RDWR));
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
+    if (urlSplit(url, &u))
Paul Nasrat 6de784
+        goto exit;
Paul Nasrat 6de784
+
Paul Nasrat 6de784
+    if (u->ctrl == NULL)
Paul Nasrat 6de784
+        u->ctrl = fdNew("persist ctrl (httpOpen)");
Paul Nasrat 6de784
+    if (u->ctrl->nrefs > 2 && u->data == NULL)
Paul Nasrat 6de784
+        u->data = fdNew("persist data (httpOpen)");
Paul Nasrat 6de784
+
Paul Nasrat 6de784
+    if (u->ctrl->url == NULL)
Paul Nasrat 6de784
+        fd = fdLink(u->ctrl, "grab ctrl (httpOpen persist ctrl)");
Paul Nasrat 6de784
+    else if (u->data->url == NULL)
Paul Nasrat 6de784
+        fd = fdLink(u->data, "grab ctrl (httpOpen persist data)");
Paul Nasrat 6de784
+    else
Paul Nasrat 6de784
+        fd = fdNew("grab ctrl (httpOpen)");
Paul Nasrat 6de784
+
Paul Nasrat 6de784
+    if (fd) {
Paul Nasrat 6de784
+        fdSetIo(fd, ufdio);
Paul Nasrat 6de784
+        fd->ftpFileDoneNeeded = 0;
Paul Nasrat 6de784
+        fd->rd_timeoutsecs = httpTimeoutSecs;
Paul Nasrat 6de784
+        fd->contentLength = fd->bytesRemain = -1;
Paul Nasrat 6de784
+        fd->url = urlLink(u, "url (httpOpen)");
Paul Nasrat 6de784
+        fd = fdLink(fd, "grab data (httpOpen)");
Paul Nasrat 6de784
+        fd->urlType = URL_IS_HTTP;
Paul Nasrat 6de784
+    }
Paul Nasrat 6de784
+
Paul Nasrat 6de784
+exit:
Paul Nasrat 6de784
+/*@-boundswrite@*/
Paul Nasrat 6de784
+    if (uret)
Paul Nasrat 6de784
+        *uret = u;
Paul Nasrat 6de784
+/*@=boundswrite@*/
Paul Nasrat 6de784
+    /*@-refcounttrans@*/
Paul Nasrat 6de784
+    return fd;
Paul Nasrat 6de784
+    /*@=refcounttrans@*/
Paul Nasrat 6de784
+}
Paul Nasrat 6de784
+/*@=nullstate@*/
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
+
Paul Nasrat 6de784
 static /*@null@*/ FD_t ufdOpen(const char * url, int flags, mode_t mode)
Paul Nasrat 6de784
 	/*@globals h_errno, fileSystem, internalState @*/
Paul Nasrat 6de784
 	/*@modifies fileSystem, internalState @*/
Paul Nasrat 6de784
@@ -2220,7 +2282,11 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o
Paul Nasrat 6de784
     case URL_IS_HTTPS:
Paul Nasrat 6de784
     case URL_IS_HTTP:
Paul Nasrat 6de784
     case URL_IS_HKP:
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	fd = davOpen(url, flags, mode, &u);
Paul Nasrat 6de784
+#else
Paul Nasrat 6de784
+	fd = httpOpen(url, flags, mode, &u);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	if (fd == NULL || u == NULL)
Paul Nasrat 6de784
 	    break;
Paul Nasrat 6de784
 
Paul Nasrat 6de784
@@ -2228,7 +2294,11 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o
Paul Nasrat 6de784
 		?  ((flags & O_APPEND) ? "PUT" :
Paul Nasrat 6de784
 		   ((flags & O_CREAT) ? "PUT" : "PUT"))
Paul Nasrat 6de784
 		: "GET");
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	u->openError = davReq(fd, cmd, path);
Paul Nasrat 6de784
+#else
Paul Nasrat 6de784
+	u->openError = httpReq(fd, cmd, path);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	if (u->openError < 0) {
Paul Nasrat 6de784
 	    /* XXX make sure that we can exit through ufdClose */
Paul Nasrat 6de784
 	    fd = fdLink(fd, "error ctrl (ufdOpen HTTP)");
Paul Nasrat 6de784
Index: rpm-4.4.2/rpmio/rpmrpc.c
Paul Nasrat 6de784
===================================================================
Paul Nasrat 6de784
--- rpm-4.4.2.orig/rpmio/rpmrpc.c
Paul Nasrat 6de784
+++ rpm-4.4.2/rpmio/rpmrpc.c
Paul Nasrat 6de784
@@ -93,7 +93,9 @@ int Mkdir (const char * path, mode_t mod
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_HTTPS:
Paul Nasrat 6de784
     case URL_IS_HTTP:
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	return davMkdir(path, mode);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_PATH:
Paul Nasrat 6de784
 	path = lpath;
Paul Nasrat 6de784
@@ -151,7 +153,9 @@ int Rmdir (const char * path)
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_HTTPS:
Paul Nasrat 6de784
     case URL_IS_HTTP:
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	return davRmdir(path);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_PATH:
Paul Nasrat 6de784
 	path = lpath;
Paul Nasrat 6de784
@@ -182,7 +186,9 @@ int Rename (const char * oldpath, const 
Paul Nasrat 6de784
     switch (oldut) {
Paul Nasrat 6de784
     case URL_IS_HTTPS:
Paul Nasrat 6de784
     case URL_IS_HTTP:
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	return davRename(oldpath, newpath);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_FTP:		/* XXX WRONG WRONG WRONG */
Paul Nasrat 6de784
     case URL_IS_PATH:
Paul Nasrat 6de784
@@ -280,7 +286,9 @@ int Unlink(const char * path) {
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_HTTPS:
Paul Nasrat 6de784
     case URL_IS_HTTP:
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	return davUnlink(path);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_PATH:
Paul Nasrat 6de784
 	path = lpath;
Paul Nasrat 6de784
@@ -1282,7 +1290,9 @@ fprintf(stderr, "*** Stat(%s,%p)\n", pat
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_HTTPS:
Paul Nasrat 6de784
     case URL_IS_HTTP:
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	return davStat(path, st);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_PATH:
Paul Nasrat 6de784
 	path = lpath;
Paul Nasrat 6de784
@@ -1311,7 +1321,9 @@ fprintf(stderr, "*** Lstat(%s,%p)\n", pa
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_HTTPS:
Paul Nasrat 6de784
     case URL_IS_HTTP:
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	return davLstat(path, st);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_PATH:
Paul Nasrat 6de784
 	path = lpath;
Paul Nasrat 6de784
@@ -1489,7 +1501,9 @@ fprintf(stderr, "*** Opendir(%s)\n", pat
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_HTTPS:	
Paul Nasrat 6de784
     case URL_IS_HTTP:
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	return davOpendir(path);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	/*@notreached@*/ break;
Paul Nasrat 6de784
     case URL_IS_PATH:
Paul Nasrat 6de784
 	path = lpath;
Paul Nasrat 6de784
@@ -1515,8 +1529,10 @@ fprintf(stderr, "*** Readdir(%p)\n", (vo
Paul Nasrat 6de784
 	return NULL;
Paul Nasrat 6de784
     if (ISAVMAGIC(dir))
Paul Nasrat 6de784
 	return avReaddir(dir);
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
     if (ISDAVMAGIC(dir))
Paul Nasrat 6de784
 	return davReaddir(dir);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
     return readdir(dir);
Paul Nasrat 6de784
 }
Paul Nasrat 6de784
 
Paul Nasrat 6de784
@@ -1528,7 +1544,9 @@ fprintf(stderr, "*** Closedir(%p)\n", (v
Paul Nasrat 6de784
 	return 0;
Paul Nasrat 6de784
     if (ISAVMAGIC(dir))
Paul Nasrat 6de784
 	return avClosedir(dir);
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
     if (ISDAVMAGIC(dir))
Paul Nasrat 6de784
 	return davClosedir(dir);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
     return closedir(dir);
Paul Nasrat 6de784
 }
Paul Nasrat 6de784
Index: rpm-4.4.2/rpmio/url.c
Paul Nasrat 6de784
===================================================================
Paul Nasrat 6de784
--- rpm-4.4.2.orig/rpmio/url.c
Paul Nasrat 6de784
+++ rpm-4.4.2/rpmio/url.c
Paul Nasrat 6de784
@@ -147,8 +147,10 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d
Paul Nasrat 6de784
 	/*@=usereleased@*/
Paul Nasrat 6de784
     }
Paul Nasrat 6de784
     if (u->sess != NULL) {
Paul Nasrat 6de784
+#ifdef WITH_NEON
Paul Nasrat 6de784
 	/* HACK: neon include has prototype. */
Paul Nasrat 6de784
 	ne_session_destroy(u->sess);
Paul Nasrat 6de784
+#endif
Paul Nasrat 6de784
 	u->sess = NULL;
Paul Nasrat 6de784
     }
Paul Nasrat 6de784
     u->buf = _free(u->buf);