void my_mkcol2_proppatch(char* uri, int depth, const ne_propname pops[]) { char tmp[256] = "/tmp/Davtest-XXXXXX"; char myuri[128]; int i, fd; if ( (fd=mkstemp(tmp)) < 0){ perror("mkstemp() :"); return ; } for( i=0; i<4; i++) write(fd, tmp, sizeof(tmp)); if ( depth > 1){ memset(myuri, 0, sizeof(myuri)); strcpy( myuri, uri); sprintf( myuri, "%ssub/", myuri); ONV(ne_mkcol(i_session, myuri), ("MKCOL %s: %s", myuri, ne_get_error(i_session))); ONMREQ("PROPPATCH",myuri, ne_proppatch(i_session, myuri, pops)); my_mkcol2( myuri, depth-1); }else if ( depth == 1) for ( i=0; i<pget_option.width; i++){ memset(myuri, 0, sizeof(myuri)); strcpy( myuri, uri); sprintf( myuri, "%sfile%d", myuri, i); ONV(ne_put(i_session, myuri, fd), ("PUT of %s: %s", myuri, ne_get_error(i_session))); } return; }
static int owner_modify(void) { char *tmp; ne_propname pname = { "http://webdav.org/neon/litmus/", "random" }; ne_proppatch_operation pops[] = { { NULL, ne_propset, "foobar" }, { NULL } }; PRECOND(gotlock); ONV(ne_put(i_session, res, i_foo_fd), ("PUT on locked resource failed: %s", ne_get_error(i_session))); tmp = ne_concat(i_path, "whocares", NULL); ONN("COPY of locked resource", ne_copy(i_session, 1, NE_DEPTH_ZERO, res, tmp) == NE_ERROR); if (STATUS(201)) t_warning("COPY failed with %d not 201", GETSTATUS); ONN("DELETE of locked resource by owner", ne_delete(i_session, tmp) == NE_ERROR); if (STATUS(204)) t_warning("DELETE of %s failed with %d not 200", tmp, GETSTATUS); free(tmp); ONN("PROPPATCH of locked resource", ne_proppatch(i_session, res, pops) == NE_ERROR); if (STATUS(207)) t_warning("PROPPATCH failed with %d", GETSTATUS); return OK; }
static int notowner_modify(void) { char *tmp; ne_propname pname = { "http://webdav.org/neon/litmus/", "random" }; ne_proppatch_operation pops[] = { { NULL, ne_propset, "foobar" }, { NULL } }; PRECOND(gotlock); pops[0].name = &pname; ONN("DELETE of locked resource should fail", ne_delete(i_session2, res) != NE_ERROR); if (STATUS2(423)) t_warning("DELETE failed with %d not 423", GETSTATUS2); tmp = ne_concat(i_path, "whocares", NULL); ONN("MOVE of locked resource should fail", ne_move(i_session2, 0, res, tmp) != NE_ERROR); free(tmp); if (STATUS2(423)) t_warning("MOVE failed with %d not 423", GETSTATUS2); ONN("COPY onto locked resource should fail", ne_copy(i_session2, 1, NE_DEPTH_ZERO, res2, res) != NE_ERROR); if (STATUS2(423)) t_warning("COPY failed with %d not 423", GETSTATUS2); ONN("PROPPATCH of locked resource should fail", ne_proppatch(i_session2, res, pops) != NE_ERROR); if (STATUS2(423)) t_warning("PROPPATCH failed with %d not 423", GETSTATUS2); ONN("PUT on locked resource should fail", ne_put(i_session2, res, i_foo_fd) != NE_ERROR); if (STATUS2(423)) t_warning("PUT failed with %d not 423", GETSTATUS2); return OK; }
static int owner_modify(void) { PRECOND(gotlock); ne_proppatch_operation pops[] = { { NULL, ne_propset, "foobar" }, { NULL } }; const ne_propname pname = { "http://webdav.org/neon/litmus/", "random" }; pops[0].name = &pname; ONV(ne_put(i_session, res, i_foo_fd), ("PUT on locked resource failed: %s", ne_get_error(i_session))); ONMREQ("PROPPATCH on locked resouce", res, ne_proppatch(i_session, res, pops)); return OK; }
static int owncloud_utimes(const char *uri, const struct timeval *times) { ne_proppatch_operation ops[2]; ne_propname pname; int rc = NE_OK; char val[255]; char *curi; curi = _cleanPath( uri ); if( ! uri ) { errno = ENOENT; return -1; } if( !times ) { errno = EACCES; return -1; /* FIXME: Find good errno */ } pname.nspace = "DAV:"; pname.name = "lastmodified"; snprintf( val, sizeof(val), "%ld", times->tv_sec ); DEBUG_WEBDAV("Setting LastModified of %s to %s", curi, val ); ops[0].name = &pname; ops[0].type = ne_propset; ops[0].value = val; ops[1].name = NULL; rc = ne_proppatch( dav_session.ctx, curi, ops ); SAFE_FREE(curi); if( rc != NE_OK ) { errno = EPERM; DEBUG_WEBDAV("Error in propatch: %d", rc); return -1; } return 0; }