Skip to content

Commit 70bff44

Browse files
committed
[*.h] C++ support ; [*.h,*.c] fd -eh -ec -x clang-format --style=LLVM -i ; [LICENSE-{APACHE,MIT}] Welcome back libacquire!
1 parent ce930d1 commit 70bff44

24 files changed

+168
-22
lines changed

LICENSE-APACHE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright 2020-2021 Samuel Marks (for Offscale.io)
190+
Copyright 2020-2025 Samuel Marks (for Offscale.io)
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

LICENSE-MIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2020-2021 Samuel Marks (for Offscale.io)
1+
Copyright 2020-2025 Samuel Marks (for Offscale.io)
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

acquire/acquire_checksums.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#ifndef LIBACQUIRE_ACQUIRE_CHECKSUMS_H
99
#define LIBACQUIRE_ACQUIRE_CHECKSUMS_H
1010

11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif /* __cplusplus */
14+
1115
#include "libacquire_export.h"
1216
#if defined(HAS_STDBOOL) && !defined(bool)
1317
#include <stdbool.h>
@@ -65,4 +69,8 @@ bool (*get_checksum_function(enum Checksum checksum))(const char *,
6569

6670
#endif /* LIBACQUIRE_IMPLEMENTATION */
6771

72+
#ifdef __cplusplus
73+
}
74+
#endif /* __cplusplus */
75+
6876
#endif /* ! LIBACQUIRE_ACQUIRE_CHECKSUMS_H */

acquire/acquire_common_defs.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
#ifndef LIBACQUIRE_ACQUIRE_COMMON_DEFS_H
88
#define LIBACQUIRE_ACQUIRE_COMMON_DEFS_H
99

10-
#if defined(HAS_STDBOOL) && !defined(bool)
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif /* __cplusplus */
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#elif defined(HAS_STDBOOL) && !defined(bool)
1117
#include <stdbool.h>
1218
#else
1319
#include "acquire_stdbool.h"
14-
#endif /* defined(HAS_STDBOOL) && !defined(bool) */
20+
#endif /* __cplusplus */
1521

1622
#include "acquire_checksums.h"
1723
#include "acquire_download.h"
@@ -93,4 +99,8 @@
9399
#endif
94100
#endif /* !defined(_AMD64_) && !defined(_X86_) && defined(_ARM_) */
95101

102+
#ifdef __cplusplus
103+
}
104+
#endif /* __cplusplus */
105+
96106
#endif /* ! LIBACQUIRE_ACQUIRE_COMMON_DEFS_H */

acquire/acquire_crc32c.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
defined(LIBACQUIRE_IMPLEMENTATION) && defined(USE_CRC32C)
1313
#define LIBACQUIRE_ACQUIRE_CRC32C_H
1414

15-
#if defined(HAS_STDBOOL) && !defined(bool)
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#elif defined(HAS_STDBOOL) && !defined(bool)
1618
#include <stdbool.h>
1719
#else
1820
#include "acquire_stdbool.h"
19-
#endif
21+
#endif /* __cplusplus */
2022

2123
#define CHUNK_SIZE 4096
2224

@@ -115,5 +117,9 @@ bool crc32c(const char *filename, const char *hash) {
115117
return true;
116118
}
117119

120+
#ifdef __cplusplus
121+
}
122+
#endif /* __cplusplus */
123+
118124
#endif /* !defined(LIBACQUIRE_ACQUIRE_CRC32C_H) && \
119125
defined(LIBACQUIRE_IMPLEMENTATION) && defined(USE_CRC32C) */

acquire/acquire_download.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010

1111
#include <stdlib.h>
1212

13-
#if defined(HAS_STDBOOL) && !defined(bool)
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#elif defined(HAS_STDBOOL) && !defined(bool)
1416
#include <stdbool.h>
1517
#else
1618
#include "acquire_stdbool.h"
17-
#endif /* defined(HAS_STDBOOL) && !defined(bool) */
19+
#endif /* __cplusplus */
1820
#include "acquire_config.h"
1921
#include "acquire_fileutils.h"
2022
#include "acquire_url_utils.h"
@@ -40,5 +42,8 @@ extern LIBACQUIRE_LIB_EXPORT int download(const char *, enum Checksum,
4042
extern LIBACQUIRE_LIB_EXPORT int download_many(const char *[], const char *[],
4143
enum Checksum[], const char *,
4244
bool, size_t, size_t);
45+
#ifdef __cplusplus
46+
}
47+
#endif /* __cplusplus */
4348

4449
#endif /* ! LIBACQUIRE_ACQUIRE_DOWNLOAD_H */

acquire/acquire_extract.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#ifndef LIBACQUIRE_ACQUIRE_EXTRACT_H
1111
#define LIBACQUIRE_ACQUIRE_EXTRACT_H
1212

13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif /* __cplusplus */
16+
1317
#include "libacquire_export.h"
1418

1519
enum LIBACQUIRE_LIB_EXPORT Archive {
@@ -38,4 +42,8 @@ extern enum Archive extension2archive(const char *const s) {
3842

3943
#endif /* LIBACQUIRE_IMPLEMENTATION */
4044

45+
#ifdef __cplusplus
46+
}
47+
#endif /* __cplusplus */
48+
4149
#endif /* ! LIBACQUIRE_ACQUIRE_EXTRACT_H */

acquire/acquire_fileutils.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
#ifndef LIBACQUIRE_ACQUIRE_FILEUTILS_H
99
#define LIBACQUIRE_ACQUIRE_FILEUTILS_H
1010

11-
#if defined(HAS_STDBOOL) && !defined(bool)
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#elif defined(HAS_STDBOOL) && !defined(bool)
1214
#include <stdbool.h>
1315
#else
1416
#include "acquire_stdbool.h"
1517
#include "libacquire_export.h"
18+
#endif /* __cplusplus */
1619

17-
#endif /* defined(HAS_STDBOOL) && !defined(bool) */
1820
#include <string.h>
1921

2022
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
@@ -127,4 +129,8 @@ const char *get_extension(const char *const filename) {
127129

128130
#endif /* LIBACQUIRE_IMPLEMENTATION */
129131

132+
#ifdef __cplusplus
133+
}
134+
#endif /* __cplusplus */
135+
130136
#endif /* ! LIBACQUIRE_ACQUIRE_FILEUTILS_H */

acquire/acquire_libarchive.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
* https://github.com/libarchive/libarchive/wiki/Examples#a-complete-extractor
77
*/
88

9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif /* __cplusplus */
12+
913
#include "acquire_extract.h"
1014

1115
#include <archive.h>
@@ -102,5 +106,9 @@ int extract_archive(enum Archive archive, const char *archive_filepath,
102106
return EXIT_SUCCESS;
103107
}
104108

109+
#ifdef __cplusplus
110+
}
111+
#endif /* __cplusplus */
112+
105113
#endif /* !defined(LIBACQUIRE_ACQUIRE_LIBARCHIVE_H) && defined(USE_LIBARCHIVE) \
106114
&& defined(LIBACQUIRE_IMPLEMENTATION) */

acquire/acquire_libcurl.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
#define LIBACQUIRE_LIBCURL_H
1515

16+
#ifdef __cplusplus
17+
}
18+
#endif /* __cplusplus */
19+
1620
#include <stdint.h>
1721
#include <stdlib.h>
1822

@@ -185,7 +189,7 @@ int download(const char *url, enum Checksum checksum, const char *hash,
185189
if (filesize(target_location) > 0 /* && check checksum */) {
186190
return EEXIST /*CURLE_ALREADY_COMPLETE*/;
187191
} else
188-
set_remote_fname_to_target_location : {
192+
set_remote_fname_to_target_location: {
189193
const size_t target_location_n = strlen(target_location);
190194
strncpy(dnld_params.dnld_remote_fname, target_location,
191195
target_location_n);
@@ -304,5 +308,9 @@ int download_many(const char *url[], const char *hashes[],
304308
return UNIMPLEMENTED;
305309
}
306310

311+
#ifdef __cplusplus
312+
}
313+
#endif /* __cplusplus */
314+
307315
#endif /* !defined(LIBACQUIRE_LIBCURL_H) && defined(USE_LIBCURL) && \
308316
defined(LIBACQUIRE_IMPLEMENTATION) */

0 commit comments

Comments
 (0)