Skip to content

Commit

Permalink
* src/ne_basic.c: Rename 'uri' parameters to 'path', plus style
Browse files Browse the repository at this point in the history
  fixes throughout. No functional change.
  • Loading branch information
notroj committed Nov 12, 2023
1 parent 7276d07 commit bc41917
Showing 1 changed file with 42 additions and 39 deletions.
81 changes: 42 additions & 39 deletions src/ne_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
#include "ne_dates.h"
#include "ne_internal.h"

int ne_getmodtime(ne_session *sess, const char *uri, time_t *modtime)
int ne_getmodtime(ne_session *sess, const char *path, time_t *modtime)
{
ne_request *req = ne_request_create(sess, "HEAD", uri);
ne_request *req = ne_request_create(sess, "HEAD", path);
const char *value;
int ret;

Expand Down Expand Up @@ -84,8 +84,8 @@ typedef struct stat64 struct_stat;
typedef struct stat struct_stat;
#endif

/* PUT's from fd to URI */
int ne_put(ne_session *sess, const char *uri, int fd)
/* PUT's from fd to PATH */
int ne_put(ne_session *sess, const char *path, int fd)
{
ne_request *req;
struct_stat st;
Expand All @@ -100,11 +100,11 @@ int ne_put(ne_session *sess, const char *uri, int fd)
return NE_ERROR;
}

req = ne_request_create(sess, "PUT", uri);
req = ne_request_create(sess, "PUT", path);

#ifdef NE_HAVE_DAV
ne_lock_using_resource(req, uri, 0);
ne_lock_using_parent(req, uri);
ne_lock_using_resource(req, path, 0);
ne_lock_using_parent(req, path);
#endif

ne_set_request_body_fd(req, fd, 0, st.st_size);
Expand Down Expand Up @@ -175,7 +175,8 @@ static int dispatch_to_fd(ne_request *req, int fd, const char *range)

if ((range && st->code == 206) || (!range && st->klass == 2)) {
ret = ne_read_response_to_fd(req, fd);
} else {
}
else {
ret = ne_discard_response(req);
}

Expand All @@ -185,11 +186,11 @@ static int dispatch_to_fd(ne_request *req, int fd, const char *range)
return ret;
}

static int get_range_common(ne_session *sess, const char *uri,
static int get_range_common(ne_session *sess, const char *path,
const char *brange, int fd)

{
ne_request *req = ne_request_create(sess, "GET", uri);
ne_request *req = ne_request_create(sess, "GET", path);
const ne_status *status;
int ret;

Expand Down Expand Up @@ -221,13 +222,13 @@ static int get_range_common(ne_session *sess, const char *uri,
return ret;
}

int ne_get_range(ne_session *sess, const char *uri,
int ne_get_range(ne_session *sess, const char *path,
ne_content_range *range, int fd)
{
char brange[64];

if (range->end == -1) {
ne_snprintf(brange, sizeof brange, "bytes=%" FMT_NE_OFF_T "-",
ne_snprintf(brange, sizeof brange, "bytes=%" FMT_NE_OFF_T "-",
range->start);
}
else {
Expand All @@ -236,13 +237,13 @@ int ne_get_range(ne_session *sess, const char *uri,
range->start, range->end);
}

return get_range_common(sess, uri, brange, fd);
return get_range_common(sess, path, brange, fd);
}

/* Get to given fd */
int ne_get(ne_session *sess, const char *uri, int fd)
int ne_get(ne_session *sess, const char *path, int fd)
{
ne_request *req = ne_request_create(sess, "GET", uri);
ne_request *req = ne_request_create(sess, "GET", path);
int ret;

ret = dispatch_to_fd(req, fd, NULL);
Expand All @@ -258,9 +259,9 @@ int ne_get(ne_session *sess, const char *uri, int fd)


/* Get to given fd */
int ne_post(ne_session *sess, const char *uri, int fd, const char *buffer)
int ne_post(ne_session *sess, const char *path, int fd, const char *buffer)
{
ne_request *req = ne_request_create(sess, "POST", uri);
ne_request *req = ne_request_create(sess, "POST", path);
int ret;

ne_set_request_flag(req, NE_REQFLAG_IDEMPOTENT, 0);
Expand Down Expand Up @@ -309,7 +310,8 @@ int ne_get_content_type(ne_request *req, ne_content_type *ct)
tok = strstr(tok, "charset=");
if (tok)
ct->charset = ne_shave(tok+8, "\"\'");
} else {
}
else {
break;
}
} while (sep != NULL);
Expand Down Expand Up @@ -376,9 +378,9 @@ static void parse_dav_header(const char *value, unsigned int *caps)
ne_free(tokens);
}

int ne_options2(ne_session *sess, const char *uri, unsigned int *caps)
int ne_options2(ne_session *sess, const char *path, unsigned int *caps)
{
ne_request *req = ne_request_create(sess, "OPTIONS", uri);
ne_request *req = ne_request_create(sess, "OPTIONS", path);
int ret = ne_request_dispatch(req);
const char *header = ne_get_response_header(req, "DAV");

Expand Down Expand Up @@ -430,7 +432,7 @@ void ne_add_depth_header(ne_request *req, int depth)
}

static int copy_or_move(ne_session *sess, int is_move, int overwrite,
int depth, const char *src, const char *dest)
int depth, const char *src, const char *dest)
{
ne_request *req = ne_request_create( sess, is_move?"MOVE":"COPY", src );

Expand All @@ -452,8 +454,8 @@ static int copy_or_move(ne_session *sess, int is_move, int overwrite,
ne_add_request_header(req, "Destination", dest);
}
else {
ne_print_request_header(req, "Destination", "%s://%s%s",
ne_get_scheme(sess),
ne_print_request_header(req, "Destination", "%s://%s%s",
ne_get_scheme(sess),
ne_get_server_hostport(sess), dest);
}

Expand All @@ -463,25 +465,25 @@ static int copy_or_move(ne_session *sess, int is_move, int overwrite,
}

int ne_copy(ne_session *sess, int overwrite, int depth,
const char *src, const char *dest)
const char *src, const char *dest)
{
return copy_or_move(sess, 0, overwrite, depth, src, dest);
}

int ne_move(ne_session *sess, int overwrite,
const char *src, const char *dest)
const char *src, const char *dest)
{
return copy_or_move(sess, 1, overwrite, 0, src, dest);
}

/* Deletes the specified resource. (and in only two lines of code!) */
int ne_delete(ne_session *sess, const char *uri)
int ne_delete(ne_session *sess, const char *path)
{
ne_request *req = ne_request_create(sess, "DELETE", uri);
ne_request *req = ne_request_create(sess, "DELETE", path);

#ifdef NE_HAVE_DAV
ne_lock_using_resource(req, uri, NE_DEPTH_INFINITE);
ne_lock_using_parent(req, uri);
ne_lock_using_resource(req, path, NE_DEPTH_INFINITE);
ne_lock_using_parent(req, path);
#endif

/* joe: I asked on the DAV WG list about whether we might get a
Expand All @@ -495,28 +497,29 @@ int ne_delete(ne_session *sess, const char *uri)
return ne_simple_request(sess, req);
}

int ne_mkcol(ne_session *sess, const char *uri)
int ne_mkcol(ne_session *sess, const char *path)
{
ne_request *req;
char *real_uri;
char *real_path;
int ret;

if (ne_path_has_trailing_slash(uri)) {
real_uri = ne_strdup(uri);
} else {
real_uri = ne_concat(uri, "/", NULL);
if (ne_path_has_trailing_slash(path)) {
real_path = ne_strdup(path);
}
else {
real_path = ne_concat(path, "/", NULL);
}

req = ne_request_create(sess, "MKCOL", real_uri);
req = ne_request_create(sess, "MKCOL", real_path);

#ifdef NE_HAVE_DAV
ne_lock_using_resource(req, real_uri, 0);
ne_lock_using_parent(req, real_uri);
ne_lock_using_resource(req, real_path, 0);
ne_lock_using_parent(req, real_path);
#endif

ret = ne_simple_request(sess, req);

ne_free(real_uri);
ne_free(real_path);

return ret;
}
Expand Down

0 comments on commit bc41917

Please sign in to comment.