commit 15c6d0445e25e7d0ceb25b798ae7989fb2b1c03d
parent 1db2437133e6161b4683706ac8854a990209378e
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Sun, 21 Feb 2021 11:20:12 -0600
pkg.*: pkg_retrieve: remove count argument
Diffstat:
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/kiss.c b/kiss.c
@@ -17,7 +17,6 @@ kiss_download_names(char *kiss_path, char *names[], int len)
struct source_t sources[PKG_SOURCES_MAX];
memset(sources, 0, sizeof(sources));
char *repo, kp[strlen(kiss_path)], path[PATH_LEN];
- int count;
/* TODO put names in linked list to make O(n) instead of O(n^2) */
for (int i = 0; i < len; i++) {
@@ -29,8 +28,8 @@ kiss_download_names(char *kiss_path, char *names[], int len)
do {
if (pkg_exists(repo, names[i], path)) {
- count = pkg_sources(repo, names[i], sources);
- pkg_retrieve( sources, count);
+ pkg_sources(repo, names[i], sources);
+ pkg_retrieve(sources);
break;
}
} while ((repo = strtok(NULL, ":")) != NULL);
@@ -41,7 +40,6 @@ void
kiss_checksum_names(char *kiss_path, char *names[], int len)
{
char *repo, kp[strlen(kiss_path)], path[PATH_LEN];
- int count;
struct source_t sources[64];
for (int i = 0; i < len; i++) {
/* iterate through KISS_PATH */
@@ -53,8 +51,8 @@ kiss_checksum_names(char *kiss_path, char *names[], int len)
do {
if (pkg_exists(repo, names[i], path)) {
memset(sources, 0, sizeof(sources));
- count = pkg_sources(repo, names[i], sources);
- pkg_retrieve(sources, count);
+ pkg_sources(repo, names[i], sources);
+ pkg_retrieve(sources);
pkg_checksums_gen(repo, names[i], sources);
break;
}
diff --git a/pkg.c b/pkg.c
@@ -14,9 +14,9 @@
#include "util.h"
void
-pkg_retrieve(struct source_t *sources, int count)
+pkg_retrieve(struct source_t *sources)
{
- for (int i = 0; i < count; i++) {
+ for (int i = 0; sources[i].path[0] != '\0'; i++) {
if (!sources[i].local && !sources[i].present) {
http_fetch(sources[i].loc, sources[i].path);
}
diff --git a/pkg.h b/pkg.h
@@ -17,7 +17,7 @@ struct source_t {
char checksum[HASH_LEN];
};
-void pkg_retrieve(struct source_t *sources, int count);
+void pkg_retrieve(struct source_t *sources);
int pkg_sources(char *repo, char *name, struct source_t *);
void pkg_checksums_load(char *repo, char *name, struct source_t *);
void pkg_checksums_gen(char *repo, char *name, struct source_t *sources);