From 53061074481e42652e76fc274d7eda7c37a045ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Fri, 5 Apr 2024 11:05:01 +0300
Subject: [PATCH] io: rename io_url.c to io_url_libfetch.c

---
 src/Makefile                        |  2 +-
 src/io.c                            | 14 ++++++++++++++
 src/{io_url.c => io_url_libfetch.c} | 15 +--------------
 src/meson.build                     |  2 +-
 4 files changed, 17 insertions(+), 16 deletions(-)
 rename src/{io_url.c => io_url_libfetch.c} (91%)

diff --git a/src/Makefile b/src/Makefile
index 1ae0d3ab..f7873cb1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -21,7 +21,7 @@ libapk_so		:= $(obj)/libapk.so.$(libapk_soname)
 libapk.so.$(libapk_soname)-objs := \
 	adb.o adb_comp.o adb_walk_adb.o adb_walk_genadb.o adb_walk_gentext.o adb_walk_text.o apk_adb.o \
 	atom.o blob.o commit.o common.o context.o crypto.o crypto_openssl.o ctype.o database.o hash.o \
-	extract_v2.o extract_v3.o fs_fsys.o fs_uvol.o io.o io_gunzip.o io_url.o \
+	extract_v2.o extract_v3.o fs_fsys.o fs_uvol.o io.o io_gunzip.o io_url_libfetch.o \
 	tar.o package.o pathbuilder.o print.o solver.o trust.o version.o
 
 libapk.so.$(libapk_soname)-libs := libfetch/libfetch.a
diff --git a/src/io.c b/src/io.c
index 55ccb743..bec0ea40 100644
--- a/src/io.c
+++ b/src/io.c
@@ -33,6 +33,7 @@
 
 size_t apk_io_bufsize = 128*1024;
 
+
 static inline int atfd_error(int atfd)
 {
 	return atfd < -1 && atfd != AT_FDCWD;
@@ -1162,6 +1163,19 @@ static struct cache_item *idcache_by_id(struct apk_id_hash *hash, unsigned long
 	return 0;
 }
 
+const char *apk_url_local_file(const char *url)
+{
+	if (strncmp(url, "file:", 5) == 0)
+		return &url[5];
+
+	if (strncmp(url, "http:", 5) != 0 &&
+	    strncmp(url, "https:", 6) != 0 &&
+	    strncmp(url, "ftp:", 4) != 0)
+		return url;
+
+	return NULL;
+}
+
 void apk_id_cache_init(struct apk_id_cache *idc, int root_fd)
 {
 	idc->root_fd = root_fd;
diff --git a/src/io_url.c b/src/io_url_libfetch.c
similarity index 91%
rename from src/io_url.c
rename to src/io_url_libfetch.c
index 036d9970..0016f24e 100644
--- a/src/io_url.c
+++ b/src/io_url_libfetch.c
@@ -1,4 +1,4 @@
-/* io_url.c - Alpine Package Keeper (APK)
+/* io_url_libfetch.c - Alpine Package Keeper (APK)
  *
  * Copyright (C) 2005-2008 Natanael Copa <n@tanael.org>
  * Copyright (C) 2008-2011 Timo Teräs <timo.teras@iki.fi>
@@ -18,19 +18,6 @@
 
 #include "apk_io.h"
 
-const char *apk_url_local_file(const char *url)
-{
-	if (strncmp(url, "file:", 5) == 0)
-		return &url[5];
-
-	if (strncmp(url, "http:", 5) != 0 &&
-	    strncmp(url, "https:", 6) != 0 &&
-	    strncmp(url, "ftp:", 4) != 0)
-		return url;
-
-	return NULL;
-}
-
 struct apk_fetch_istream {
 	struct apk_istream is;
 	fetchIO *fetchIO;
diff --git a/src/meson.build b/src/meson.build
index ec9b88df..c1aae550 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -22,7 +22,7 @@ libapk_src = [
 	'fs_uvol.c',
 	'hash.c',
 	'io.c',
-	'io_url.c',
+	'io_url_libfetch.c',
 	'io_gunzip.c',
 	'package.c',
 	'pathbuilder.c',
-- 
GitLab