Stub in rpmrpc primitives.
authorjbj <devnull@localhost>
Mon, 8 Nov 2004 22:49:00 +0000 (22:49 +0000)
committerjbj <devnull@localhost>
Mon, 8 Nov 2004 22:49:00 +0000 (22:49 +0000)
CVS patchset: 7561
CVS date: 2004/11/08 22:49:00

rpmio/rpmdav.c
rpmio/rpmdav.h
rpmio/rpmrpc.c

index 9177965..f91b544 100644 (file)
@@ -1042,7 +1042,9 @@ ssize_t davRead(void * cookie, /*@out@*/ 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) {
@@ -1096,52 +1098,115 @@ fprintf(stderr, "*** davClose(%p) rc %d\n", fd, rc);
 /*@=mustmod@*/
 
 /* =============================================================== */
-#ifdef NOTYET
-static int davMkdir(const char * path, /*@unused@*/ mode_t mode)
-       /*@globals h_errno, fileSystem, internalState @*/
-       /*@modifies fileSystem, internalState @*/
+int davMkdir(const char * path, mode_t mode)
 {
+    urlinfo u = NULL;
+    const char * src = NULL;
     int rc;
-    if ((rc = davCmd("MKD", path, NULL)) != 0)
-       return rc;
-#if NOTYET
-    {  char buf[20];
-       sprintf(buf, " 0%o", mode);
-       (void) davCmd("SITE CHMOD", path, buf);
-    }
-#endif
+
+    rc = davInit(path, &u);
+assert(u != NULL);
+    if (rc)
+       goto exit;
+
+    (void) urlPath(path, &src);
+
+    rc = ne_mkcol(u->sess, path);
+
+    if (rc) rc = -1;   /* XXX HACK: errno impedance match */
+
+    /* XXX HACK: verify getrestype(remote) == resr_collection */
+
+exit:
+if (_dav_debug)
+fprintf(stderr, "*** davMkdir(%s,0%o) rc %d\n", path, mode, rc);
     return rc;
 }
 
-static int davChdir(const char * path)
-       /*@globals h_errno, fileSystem, internalState @*/
-       /*@modifies fileSystem, internalState @*/
+int davRmdir(const char * path)
 {
-    return davCmd("CWD", path, NULL);
+    urlinfo u = NULL;
+    const char * src = NULL;
+    int rc;
+
+    rc = davInit(path, &u);
+assert(u != NULL);
+    if (rc)
+       goto exit;
+
+    (void) urlPath(path, &src);
+
+    /* XXX HACK: only getrestype(remote) == resr_collection */
+
+    rc = ne_delete(u->sess, path);
+
+    if (rc) rc = -1;   /* XXX HACK: errno impedance match */
+
+exit:
+if (_dav_debug)
+fprintf(stderr, "*** davRmdir(%s) rc %d\n", path, rc);
+    return rc;
 }
 
-static int davRmdir(const char * path)
-       /*@globals h_errno, fileSystem, internalState @*/
-       /*@modifies fileSystem, internalState @*/
+int davRename(const char * oldpath, const char * newpath)
 {
-    return davCmd("RMD", path, NULL);
+    urlinfo u = NULL;
+    const char * src = NULL;
+    const char * dst = NULL;
+    int overwrite = 1;         /* HACK: set this correctly. */
+    int rc;
+
+    rc = davInit(oldpath, &u);
+assert(u != NULL);
+    if (rc)
+       goto exit;
+
+    (void) urlPath(oldpath, &src);
+    (void) urlPath(newpath, &dst);
+
+    /* XXX HACK: only getrestype(remote) != resr_collection */
+
+    rc = ne_move(u->sess, overwrite, src, dst);
+
+    if (rc) rc = -1;   /* XXX HACK: errno impedance match */
+
+exit:
+if (_dav_debug)
+fprintf(stderr, "*** davRename(%s,%s) rc %d\n", oldpath, newpath, rc);
+    return rc;
 }
 
-static int davRename(const char * oldpath, const char * newpath)
-       /*@globals h_errno, fileSystem, internalState @*/
-       /*@modifies fileSystem, internalState @*/
+int davUnlink(const char * path)
 {
+    urlinfo u = NULL;
+    const char * src = NULL;
     int rc;
-    if ((rc = davCmd("RNFR", oldpath, NULL)) != 0)
-       return rc;
-    return davCmd("RNTO", newpath, NULL);
+
+    rc = davInit(path, &u);
+assert(u != NULL);
+    if (rc)
+       goto exit;
+
+    (void) urlPath(path, &src);
+
+    /* XXX HACK: only getrestype(remote) != resr_collection */
+
+    rc = ne_delete(u->sess, src);
+
+    if (rc) rc = -1;   /* XXX HACK: errno impedance match */
+
+exit:
+if (_dav_debug)
+fprintf(stderr, "*** davUnlink(%s) rc %d\n", path, rc);
+    return rc;
 }
 
-static int davUnlink(const char * path)
+#ifdef NOTYET
+static int davChdir(const char * path)
        /*@globals h_errno, fileSystem, internalState @*/
        /*@modifies fileSystem, internalState @*/
 {
-    return davCmd("DELE", path, NULL);
+    return davCommand("CWD", path, NULL);
 }
 #endif /* NOTYET */
 
index 3832e8d..1d64867 100644 (file)
@@ -80,7 +80,6 @@ DIR * avOpendir(const char * path)
        /*@globals fileSystem, internalState @*/
        /*@modifies fileSystem, internalState @*/;
 
-/*@-globuse@*/
 /**
  * Send a http request.
  * @param ctrl         
@@ -108,7 +107,7 @@ int davResp(urlinfo u, FD_t ctrl, /*@out@*/ /*@null@*/ char *const * str)
 /*@null@*/
 FD_t davOpen(const char * url, /*@unused@*/ int flags,
                /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
-        /*@globals h_errno, internalState @*/
+        /*@globals internalState @*/
         /*@modifies *uret, internalState @*/;
 
 /**
@@ -138,7 +137,30 @@ int davSeek(void * cookie, _libio_pos_t pos, int whence)
 int davClose(void * cookie)
        /*@globals fileSystem, internalState @*/
        /*@modifies cookie, fileSystem, internalState @*/;
-/*@=globuse@*/
+
+/**
+ */
+int davMkdir(const char * path, mode_t mode)
+       /*@globals fileSystem, internalState @*/
+       /*@modifies fileSystem, internalState @*/;
+
+/**
+ */
+int davRmdir(const char * path)
+       /*@globals fileSystem, internalState @*/
+       /*@modifies fileSystem, internalState @*/;
+
+/**
+ */
+int davRename(const char * oldpath, const char * newpath)
+       /*@globals fileSystem, internalState @*/
+       /*@modifies fileSystem, internalState @*/;
+
+/**
+ */
+int davUnlink(const char * path)
+       /*@globals fileSystem, internalState @*/
+       /*@modifies fileSystem, internalState @*/;
 
 /**
  * Close a DAV collection.
index 0c8c025..94f7fb0 100644 (file)
@@ -87,7 +87,6 @@ static int ftpUnlink(const char * path)
 }
 
 /* =============================================================== */
-/* XXX rebuilddb.c: analogues to mkdir(2)/rmdir(2). */
 int Mkdir (const char * path, mode_t mode)
 {
     const char * lpath;
@@ -97,8 +96,11 @@ int Mkdir (const char * path, mode_t mode)
     case URL_IS_FTP:
        return ftpMkdir(path, mode);
        /*@notreached@*/ break;
-    case URL_IS_HTTPS:         /* XXX WRONG WRONG WRONG */
-    case URL_IS_HTTP:          /* XXX WRONG WRONG WRONG */
+    case URL_IS_HTTPS:
+    case URL_IS_HTTP:
+       if (!noNeon)
+           return davMkdir(path, mode);
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
        path = lpath;
        /*@fallthrough@*/
@@ -121,8 +123,13 @@ int Chdir (const char * path)
     case URL_IS_FTP:
        return ftpChdir(path);
        /*@notreached@*/ break;
-    case URL_IS_HTTPS:         /* XXX WRONG WRONG WRONG */
-    case URL_IS_HTTP:          /* XXX WRONG WRONG WRONG */
+    case URL_IS_HTTPS:
+    case URL_IS_HTTP:
+#ifdef NOTYET
+       if (!noNeon)
+           return davChdir(path);
+#endif
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
        path = lpath;
        /*@fallthrough@*/
@@ -145,8 +152,11 @@ int Rmdir (const char * path)
     case URL_IS_FTP:
        return ftpRmdir(path);
        /*@notreached@*/ break;
-    case URL_IS_HTTPS:         /* XXX WRONG WRONG WRONG */
-    case URL_IS_HTTP:          /* XXX WRONG WRONG WRONG */
+    case URL_IS_HTTPS:
+    case URL_IS_HTTP:
+       if (!noNeon)
+           return davRmdir(path);
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
        path = lpath;
        /*@fallthrough@*/
@@ -173,8 +183,11 @@ int Rename (const char * oldpath, const char * newpath)
 
     oldut = urlPath(oldpath, &oe);
     switch (oldut) {
-    case URL_IS_HTTPS:         /* XXX WRONG WRONG WRONG */
-    case URL_IS_HTTP:          /* XXX WRONG WRONG WRONG */
+    case URL_IS_HTTPS:
+    case URL_IS_HTTP:
+       if (!noNeon)
+           return davRename(oldpath, newpath);
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_FTP:           /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
     case URL_IS_UNKNOWN:
@@ -265,8 +278,11 @@ int Unlink(const char * path) {
     case URL_IS_FTP:
        return ftpUnlink(path);
        /*@notreached@*/ break;
-    case URL_IS_HTTPS:         /* XXX WRONG WRONG WRONG */
-    case URL_IS_HTTP:          /* XXX WRONG WRONG WRONG */
+    case URL_IS_HTTPS:
+    case URL_IS_HTTP:
+       if (!noNeon)
+           return davUnlink(path);
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
        path = lpath;
        /*@fallthrough@*/
@@ -1268,7 +1284,7 @@ fprintf(stderr, "*** Stat(%s,%p)\n", path, st);
     case URL_IS_HTTP:
        if (!noNeon)
            return davStat(path, st);
-       /*@fallthrough@*/       /* WRONG WRONG WRONG */
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
        path = lpath;
        /*@fallthrough@*/
@@ -1297,7 +1313,7 @@ fprintf(stderr, "*** Lstat(%s,%p)\n", path, st);
     case URL_IS_HTTP:
        if (!noNeon)
            return davLstat(path, st);
-       /*@fallthrough@*/       /* WRONG WRONG WRONG */
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
        path = lpath;
        /*@fallthrough@*/
@@ -1320,8 +1336,13 @@ int Readlink(const char * path, char * buf, size_t bufsiz)
     case URL_IS_FTP:
        return ftpReadlink(path, buf, bufsiz);
        /*@notreached@*/ break;
-    case URL_IS_HTTPS:         /* XXX WRONG WRONG WRONG */
-    case URL_IS_HTTP:          /* XXX WRONG WRONG WRONG */
+    case URL_IS_HTTPS:
+    case URL_IS_HTTP:
+#ifdef NOTYET
+       if (!noNeon)
+           return davReadlink(path, buf, bufsiz);
+#endif
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
        path = lpath;
        /*@fallthrough@*/
@@ -1472,7 +1493,7 @@ fprintf(stderr, "*** Opendir(%s)\n", path);
     case URL_IS_HTTP:
        if (!noNeon)
            return davOpendir(path);
-       /*@fallthrough@*/       /* WRONG WRONG WRONG */
+       /*@fallthrough@*/       /* XXX WRONG WRONG WRONG */
     case URL_IS_PATH:
        path = lpath;
        /*@fallthrough@*/