Skip to content

Commit 61bc64c

Browse files
committed
[*.h] LIBACQUIRE_LIB_EXPORT -> LIBACQUIRE_EXPORT ; [acquire/tests/CMakeLists.txt] Upgrade greatest.h ; miniz ; [**CMakeLists.txt] Rename targets ; deduplicate target dependencies ; lots of work towards getting builds to work
1 parent b73b2bb commit 61bc64c

16 files changed

+317
-425
lines changed

acquire/CMakeLists.txt

Lines changed: 157 additions & 305 deletions
Large diffs are not rendered by default.

acquire/acquire_checksums.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extern "C" {
3838
*
3939
* @return true if valid.
4040
*/
41-
extern LIBACQUIRE_LIB_EXPORT bool crc32c(const char *filename,
41+
extern LIBACQUIRE_EXPORT bool crc32c(const char *filename,
4242
const char *hash);
4343

4444
/**
@@ -49,7 +49,7 @@ extern LIBACQUIRE_LIB_EXPORT bool crc32c(const char *filename,
4949
*
5050
* @return true if valid.
5151
*/
52-
extern LIBACQUIRE_LIB_EXPORT bool sha256(const char *filename,
52+
extern LIBACQUIRE_EXPORT bool sha256(const char *filename,
5353
const char *hash);
5454

5555
/**
@@ -60,7 +60,7 @@ extern LIBACQUIRE_LIB_EXPORT bool sha256(const char *filename,
6060
*
6161
* @return true if valid.
6262
*/
63-
extern LIBACQUIRE_LIB_EXPORT bool sha512(const char *filename,
63+
extern LIBACQUIRE_EXPORT bool sha512(const char *filename,
6464
const char *hash);
6565

6666
enum Checksum {
@@ -70,7 +70,7 @@ enum Checksum {
7070
LIBACQUIRE_UNSUPPORTED_CHECKSUM
7171
};
7272

73-
extern LIBACQUIRE_LIB_EXPORT enum Checksum string2checksum(const char *);
73+
extern LIBACQUIRE_EXPORT enum Checksum string2checksum(const char *);
7474

7575
/**
7676
* @brief Obtain a pointer to a checksum function by name.
@@ -83,10 +83,12 @@ extern LIBACQUIRE_LIB_EXPORT enum Checksum string2checksum(const char *);
8383
*
8484
* @return Function pointer on success; NULL on failure.
8585
*/
86-
extern LIBACQUIRE_LIB_EXPORT bool (
86+
extern LIBACQUIRE_EXPORT bool (
8787
*get_checksum_function(enum Checksum checksum))(const char *, const char *);
8888

8989
#ifdef LIBACQUIRE_IMPLEMENTATION
90+
#ifndef LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL
91+
#define LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL
9092

9193
enum Checksum string2checksum(const char *const s) {
9294
if (strncasecmp(s, "CRC32C", 6) == 0)
@@ -114,6 +116,7 @@ bool (*get_checksum_function(enum Checksum checksum))(const char *,
114116
}
115117
}
116118

119+
#endif /* !LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL */
117120
#endif /* LIBACQUIRE_IMPLEMENTATION */
118121

119122
#ifdef __cplusplus

acquire/acquire_crc32c.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ unsigned int crc32_file(FILE *file) {
126126
}
127127

128128
#ifdef LIBACQUIRE_IMPLEMENTATION
129+
#ifndef LIBACQUIRE_ACQUIRE_CRC32C_IMPL
130+
#define LIBACQUIRE_ACQUIRE_CRC32C_IMPL 1
131+
#ifndef USE_CRC32C
132+
#define USE_CRC32C 1
133+
#endif /* !USE_CRC32C */
129134
#ifdef USE_CRC32C
130135

131136
/**
@@ -172,6 +177,7 @@ bool crc32c(const char *filename, const char *hash) {
172177
}
173178

174179
#endif /* USE_CRC32C */
180+
#endif /* !LIBACQUIRE_ACQUIRE_CRC32C_IMPL */
175181
#endif /* LIBACQUIRE_IMPLEMENTATION */
176182

177183
#ifdef __cplusplus

acquire/acquire_download.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ extern "C" {
3434
#include "acquire_wincrypt.h"
3535
#endif /* defined(USE_COMMON_CRYPTO) || defined(USE_OPENSSL) */
3636

37-
extern LIBACQUIRE_LIB_EXPORT const char *get_download_dir(void);
37+
extern LIBACQUIRE_EXPORT const char *get_download_dir(void);
3838

39-
extern LIBACQUIRE_LIB_EXPORT bool is_downloaded(const char *, enum Checksum,
39+
extern LIBACQUIRE_EXPORT bool is_downloaded(const char *, enum Checksum,
4040
const char *, const char *);
4141

42-
extern LIBACQUIRE_LIB_EXPORT int download(const char *, enum Checksum,
42+
extern LIBACQUIRE_EXPORT int download(const char *, enum Checksum,
4343
const char *, const char[NAME_MAX],
4444
bool, size_t, size_t);
4545

46-
extern LIBACQUIRE_LIB_EXPORT int download_many(const char *[], const char *[],
46+
extern LIBACQUIRE_EXPORT int download_many(const char *[], const char *[],
4747
enum Checksum[], const char *,
4848
bool, size_t, size_t);
4949
#ifdef __cplusplus

acquire/acquire_extract.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525

2626
#include "libacquire_export.h"
2727

28-
enum LIBACQUIRE_LIB_EXPORT Archive {
28+
enum LIBACQUIRE_EXPORT Archive {
2929
LIBACQUIRE_ZIP,
3030
LIBACQUIRE_INFER,
3131
LIBACQUIRE_UNSUPPORTED_ARCHIVE
@@ -43,7 +43,7 @@ enum LIBACQUIRE_LIB_EXPORT Archive {
4343
* @return `EXIT_SUCCESS` if extraction succeeds;
4444
* `EXIT_FAILURE` or non-`EXIT_SUCCESS` otherwise.
4545
*/
46-
extern LIBACQUIRE_LIB_EXPORT int extract_archive(enum Archive archive,
46+
extern LIBACQUIRE_EXPORT int extract_archive(enum Archive archive,
4747
const char *archive_filepath,
4848
const char *output_folder);
4949

@@ -57,22 +57,24 @@ extern LIBACQUIRE_LIB_EXPORT int extract_archive(enum Archive archive,
5757
* @return `enum Archive` discriminant; including potential values of
5858
* `LIBACQUIRE_UNSUPPORTED_ARCHIVE` xor `LIBACQUIRE_INFER`.
5959
*/
60-
extern LIBACQUIRE_LIB_EXPORT enum Archive
60+
extern LIBACQUIRE_EXPORT enum Archive
6161
extension2archive(const char *extension);
6262

6363
#ifdef LIBACQUIRE_IMPLEMENTATION
64-
64+
#ifndef LIBACQUIRE_IMPL_ACQUIRE_EXTRACT_H
65+
#define LIBACQUIRE_IMPL_ACQUIRE_EXTRACT_H
6566
#include <acquire_string_extras.h>
6667

67-
extern enum Archive extension2archive(const char *const s) {
68-
if (strncasecmp(s, ".zip", 6) == 0)
68+
extern enum Archive extension2archive(const char *const extension) {
69+
if (strncasecmp(extension, ".zip", 6) == 0)
6970
return LIBACQUIRE_ZIP;
70-
else if (strlen(s) == 0)
71+
else if (strlen(extension) == 0)
7172
return LIBACQUIRE_UNSUPPORTED_ARCHIVE;
7273
else
7374
return LIBACQUIRE_INFER;
7475
}
7576

77+
#endif /* !LIBACQUIRE_IMPL_ACQUIRE_EXTRACT_H */
7678
#endif /* LIBACQUIRE_IMPLEMENTATION */
7779

7880
#ifdef __cplusplus

acquire/acquire_fileutils.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,33 @@ extern "C" {
4242
#endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || \
4343
defined(__NT__) */
4444

45-
extern LIBACQUIRE_LIB_EXPORT bool is_directory(const char *);
45+
extern LIBACQUIRE_EXPORT bool is_directory(const char *);
4646

47-
extern LIBACQUIRE_LIB_EXPORT bool is_file(const char *);
47+
extern LIBACQUIRE_EXPORT bool is_file(const char *);
4848

4949
/**
5050
* @brief Check if a file exists.
5151
*
5252
* @param path Path of the file to check.
5353
* @return `true` if path is present
5454
*/
55-
extern LIBACQUIRE_LIB_EXPORT bool exists(const char *path);
55+
extern LIBACQUIRE_EXPORT bool exists(const char *path);
5656

5757
/**
5858
* @brief Get the size of a given path
5959
*
6060
* @param path Path of the file to get the size of.
6161
* @return `-1` if file doesn't exist otherwise its size
6262
*/
63-
extern LIBACQUIRE_LIB_EXPORT off_t filesize(const char *path);
63+
extern LIBACQUIRE_EXPORT off_t filesize(const char *path);
6464

6565
/**
6666
* @brief Get the size of a given path
6767
*
6868
* @param path Path of the file to determine relativity of
6969
* @return `true` if the path is a relative
7070
*/
71-
extern LIBACQUIRE_LIB_EXPORT bool is_relative(const char *path);
71+
extern LIBACQUIRE_EXPORT bool is_relative(const char *path);
7272

7373
/**
7474
* @brief Get the extension from a path
@@ -77,9 +77,11 @@ extern LIBACQUIRE_LIB_EXPORT bool is_relative(const char *path);
7777
* @return `path` if the path failed to determine extension otherwise extension
7878
* (with leading ".").
7979
*/
80-
extern LIBACQUIRE_LIB_EXPORT const char *get_extension(const char *path);
80+
extern LIBACQUIRE_EXPORT const char *get_extension(const char *path);
81+
82+
#if defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_IMPL_ACQUIRE_FILEUTILS)
83+
#define LIBACQUIRE_ACQUIRE_FILEUTILS_IMPL
8184

82-
#ifdef LIBACQUIRE_IMPLEMENTATION
8385
bool is_directory(const char *const path) {
8486
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
8587
const DWORD dwAttrib = GetFileAttributes(path);
@@ -157,7 +159,7 @@ const char *get_extension(const char *const filename) {
157159
return strncmp(ext0, ".tar", 4) == 0 ? ext0 : ext1;
158160
}
159161

160-
#endif /* LIBACQUIRE_IMPLEMENTATION */
162+
#endif /* defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_IMPL_ACQUIRE_FILEUTILS) */
161163

162164
#ifdef __cplusplus
163165
}

acquire/acquire_libfetch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ static int fetch(char *URL, const char *path) {
791791
/* CUSTOM libacquire stuff */
792792
#ifndef DOWNLOAD_DIR_IMPL
793793
#define DOWNLOAD_DIR_IMPL
794-
const char *get_download_dir() { return ".downloads"; }
794+
const char *get_download_dir(void) { return ".downloads"; }
795795
#endif /* !DOWNLOAD_DIR_IMPL */
796796

797797
int download(const char *url, enum Checksum checksum, const char *hash,

acquire/acquire_miniz.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ int extract_archive(enum Archive archive, const char *archive_filepath,
3131
return UNIMPLEMENTED;
3232
{
3333
static int arg = 2;
34+
printf("Extracting archive %s to %s\n", archive_filepath, output_folder);
3435
return zip_extract(archive_filepath, output_folder, on_extract_entry, &arg);
3536
}
3637
}

acquire/acquire_net_common.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ extern "C" {
2525
* ".downloads")
2626
* @return true if already downloaded and checksum verifies, else false
2727
*/
28-
extern LIBACQUIRE_LIB_EXPORT bool is_downloaded(const char *url,
28+
extern LIBACQUIRE_EXPORT bool is_downloaded(const char *url,
2929
enum Checksum checksum,
3030
const char *hash,
3131
const char *target_location);
3232

33-
#ifdef LIBACQUIRE_IMPLEMENTATION
33+
#if defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_IMPL_ACQUIRE_NET_COMMON)
34+
#define LIBACQUIRE_IMPL_ACQUIRE_NET_COMMON 1
3435

3536
#ifndef DOWNLOAD_DIR_IMPL
3637
#define DOWNLOAD_DIR_IMPL
37-
const char *get_download_dir() { return ".downloads"; }
38+
const char *get_download_dir(void) { return ".downloads"; }
3839
#endif /* !DOWNLOAD_DIR_IMPL */
3940

4041
/**
@@ -75,7 +76,7 @@ bool is_downloaded(const char *url, enum Checksum checksum, const char *hash,
7576
}
7677
}
7778

78-
#endif /* LIBACQUIRE_IMPLEMENTATION */
79+
#endif /* defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_IMPL_ACQUIRE_NET_COMMON) */
7980

8081
#ifdef __cplusplus
8182
}

acquire/acquire_openbsd_ftp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern "C" {
1515

1616
#ifndef DOWNLOAD_DIR_IMPL
1717
#define DOWNLOAD_DIR_IMPL
18-
const char *get_download_dir() { return ".downloads"; }
18+
const char *get_download_dir(void) { return ".downloads"; }
1919
#endif /* !DOWNLOAD_DIR_IMPL */
2020

2121
int download(const char *url, enum Checksum checksum, const char *hash,

0 commit comments

Comments
 (0)