Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libpkg: Use designated initializers for fetchers
Mark Johnston committed 6 months ago
commit 65408a1fae39097498b1db730c3953d7d13387a4
parent 246c90e
2 files changed +38 -45
modified libpkg/fetch.c
@@ -47,62 +47,55 @@
#include "private/utils.h"
#include "private/fetch.h"

-
static struct fetcher fetchers [] = {
+
static struct fetcher fetchers[] = {
	{
-
		"tcp",
-
		0,
-
		tcp_open,
-
		NULL,
-
		fh_close,
-
		stdio_fetch,
+
		.scheme = "tcp",
+
		.open = tcp_open,
+
		.close = NULL,
+
		.cleanup = fh_close,
+
		.fetch = stdio_fetch,
	},
	{
-
		"ssh",
-
		0,
-
		ssh_open,
-
		NULL,
-
		fh_close,
-
		stdio_fetch,
+
		.scheme = "ssh",
+
		.open = ssh_open,
+
		.close = NULL,
+
		.cleanup = fh_close,
+
		.fetch = stdio_fetch,
	},
	{
-
		"pkg+https",
-
		0,
-
		curl_open,
-
		NULL,
-
		curl_cleanup,
-
		curl_fetch,
+
		.scheme = "pkg+https",
+
		.open = curl_open,
+
		.close = NULL,
+
		.cleanup = curl_cleanup,
+
		.fetch = curl_fetch,
	},
	{
-
		"pkg+http",
-
		0,
-
		curl_open,
-
		NULL,
-
		curl_cleanup,
-
		curl_fetch,
+
		.scheme = "pkg+http",
+
		.open = curl_open,
+
		.close = NULL,
+
		.cleanup = curl_cleanup,
+
		.fetch = curl_fetch,
	},
	{
-
		"https",
-
		0,
-
		curl_open,
-
		NULL,
-
		curl_cleanup,
-
		curl_fetch,
+
		.scheme = "https",
+
		.open = curl_open,
+
		.close = NULL,
+
		.cleanup = curl_cleanup,
+
		.fetch = curl_fetch,
	},
	{
-
		"http",
-
		0,
-
		curl_open,
-
		NULL,
-
		curl_cleanup,
-
		curl_fetch,
+
		.scheme = "http",
+
		.open = curl_open,
+
		.close = NULL,
+
		.cleanup = curl_cleanup,
+
		.fetch = curl_fetch,
	},
	{
-
		"file",
-
		0,
-
		file_open,
-
		fh_close,
-
		NULL,
-
		stdio_fetch,
+
		.scheme = "file",
+
		.open = file_open,
+
		.close = fh_close,
+
		.cleanup = NULL,
+
		.fetch = stdio_fetch,
	},
};

@@ -203,7 +196,7 @@ pkg_fetch_file(struct pkg_repo *repo, const char *url, char *dest, time_t t,

#define URL_SCHEME_PREFIX	"pkg+"

-
static struct fetcher *
+
static const struct fetcher *
select_fetcher(const char *url)
{
	struct fetcher *f;
modified libpkg/private/pkg.h
@@ -523,7 +523,7 @@ struct pkg_repo {
	const struct pkg_repo_ops *ops;

	char *name;
-
	struct fetcher *fetcher;
+
	const struct fetcher *fetcher;
	char *url;
	char *pubkey;
	mirror_t mirror_type;