network

low level network subjects
Log | Files | Refs | Submodules | README | git clone https://git.ne02ptzero.me/git/network

commit f179a616a04cd57982d8bbb4b3350b32d70e7e73
parent 72399d4336ef9f876fea605a24a90287406f8be8
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 22 Mar 2017 19:09:47 +0100

Fix(Package): Now setting properly dependencies array

Diffstat:
Minc/package.h | 3+++
Msrc/client_test.c | 17++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/inc/package.h b/inc/package.h @@ -31,6 +31,9 @@ typedef struct intern_package_s { u16_t arch_size; u16_t inst_size; char *arch_hash; + u64_t *dependencies_arr; + u16_t dependencies_arr_size; + } intern_package_t; /* Header */ diff --git a/src/client_test.c b/src/client_test.c @@ -38,6 +38,20 @@ SQL_CALLBACK_DEF(pkg_cb) { else assert(0); } + + char *tmp = pkg->dependencies, *token; + u16_t i = 0; + while ((token = strtok_r(tmp, ", ", &tmp)) != NULL) + i++; + + pkg->dependencies_arr = malloc(sizeof(u64_t) * i); + tmp = pkg->dependencies; + i = 0; + + while ((token = strtok_r(tmp, ", ", &tmp)) != NULL) + pkg->dependencies_arr[i++] = strtoull(token, (char **)NULL, 10); + + pkg->dependencies_arr_size = i; list_add(*(head), pkg, sizeof(intern_package_t)); free(pkg); return 0; @@ -190,7 +204,8 @@ TEST(pkg_req_get_pkg_2_read) { ptr = pkg_build_resp_pkg(&size, pkg->id, pkg->sbu, pkg->inst_size, pkg->arch_size, 0, pkg->name, pkg->category, pkg->version, pkg->description, - pkg->archive, pkg->arch_hash, 0, NULL); + pkg->archive, pkg->arch_hash, pkg->dependencies_arr_size, + pkg->dependencies_arr); TEST_ASSERT_FMT(memcmp(ptr, ret, size) == 0, "Expected package is wrong %s", print_package(ptr, ret, size, r_n)); return TEST_SUCCESS;