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) {
/*@=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 */
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
-/*@-globuse@*/
/**
* Send a http request.
* @param ctrl
/*@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 @*/;
/**
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.
}
/* =============================================================== */
-/* XXX rebuilddb.c: analogues to mkdir(2)/rmdir(2). */
int Mkdir (const char * path, mode_t mode)
{
const char * lpath;
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@*/
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@*/
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@*/
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:
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@*/
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@*/
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@*/
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@*/
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@*/