protocol

protocol tests
Log | Files | Refs | Submodules | README | git clone https://git.ne02ptzero.me/git/protocol

commit efb824acbfbcc584085361f9ef720b91c459627e
parent 6dd7917838c9c79ebcaf59a342d0903585bcd20f
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 22 Mar 2017 18:56:54 +0100

Add(Description): Add description in package structure

Diffstat:
Minc/package.h | 5++++-
Msrc/client_test.c | 4++--
Msrc/package.c | 5++++-
3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/inc/package.h b/inc/package.h @@ -153,12 +153,14 @@ typedef struct resp_pkg_s { u16_t name_len; u16_t category_len; u16_t version_len; + u16_t description_len; u16_t archive_len; u16_t checksum_len; u16_t dependencies_size; char *name; char *category; char *version; + char *description; char *archive; char *checksum; u64_t *dependencies; @@ -222,7 +224,8 @@ void *pkg_build_req_get_cat(size_t *size, u16_t len, u64_t *a_cat); void *pkg_build_req_get_upd(size_t *size, u64_t len, u64_t *a_pkgs); void *pkg_build_resp_pkg(size_t *size, u64_t id, float comp_time, float inst_size, float arch_size, u8_t state, const char *name, - const char *category, const char *version, const char *archive, + const char *category, const char *version, const char *description, + const char *archive, const char *checksum, u16_t dep_size, u64_t *dependencies); void *pkg_build_resp_file(size_t *size, u64_t id, u8_t type, u64_t parent_id, const char *path); diff --git a/src/client_test.c b/src/client_test.c @@ -206,8 +206,8 @@ TEST(pkg_req_get_pkg_2_read) { READ_TIMEOUT(sockfd, ret, 2048, 1, r_n); ptr = pkg_build_resp_pkg(&size, pkg->id, pkg->sbu, pkg->inst_size, - pkg->arch_size, 0, pkg->name, pkg->category, pkg->version, pkg->archive, - pkg->arch_hash, 0, NULL); + pkg->arch_size, 0, pkg->name, pkg->category, pkg->version, pkg->description, + pkg->archive, pkg->arch_hash, 0, NULL); TEST_ASSERT_FMT(memcmp(ptr, ret, size) == 0, "Expected package is wrong %s", print_package(ptr, ret, size, r_n)); return TEST_SUCCESS; diff --git a/src/package.c b/src/package.c @@ -138,7 +138,8 @@ void *pkg_build_req_get_upd(size_t *size, u64_t len, u64_t *a_pkgs) { void *pkg_build_resp_pkg(size_t *size, u64_t id, float comp_time, float inst_size, float arch_size, u8_t state, const char *name, - const char *category, const char *version, const char *archive, + const char *category, const char *version, const char *description, + const char *archive, const char *checksum, u16_t dep_size, u64_t *dependencies) { resp_pkg_t *pkg; prot_package_t *ptr; @@ -152,12 +153,14 @@ void *pkg_build_resp_pkg(size_t *size, u64_t id, float comp_time, pkg->name_len = strlen(name); pkg->category_len = strlen(name); pkg->version_len = strlen(version); + pkg->description_len = strlen(description); pkg->checksum_len = strlen(checksum); pkg->dependencies_size = dep_size; pkg->name = strdup(name); pkg->category = strdup(category); pkg->version = strdup(version); + pkg->description = strdup(description); pkg->archive = strdup(archive); pkg->checksum = strdup(checksum); pkg->dependencies = malloc(sizeof(*dependencies) * dep_size);