Skip to content

Commit 7c1a3d0

Browse files
committed
registry: Store extra registries in clib.json and read these registries in clib-search
1 parent 9b54ae0 commit 7c1a3d0

File tree

13 files changed

+851
-146
lines changed

13 files changed

+851
-146
lines changed

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CC ?= cc
1+
CC ?= gcc
22
PREFIX ?= /usr/local
33

44
BINS = clib clib-install clib-search clib-init clib-configure clib-build clib-update clib-upgrade clib-uninstall
@@ -18,15 +18,14 @@ SDEPS = $(wildcard deps/*/*.c)
1818
ODEPS = $(SDEPS:.c=.o)
1919
DEPS = $(filter-out $(ODEPS), $(SDEPS))
2020
OBJS = $(DEPS:.c=.o)
21-
MAKEFILES = $(wildcard deps/*/Makefile)
2221

2322
export CC
2423

2524
ifdef STATIC
2625
CFLAGS += -DCURL_STATICLIB -std=c99 -Ideps -Wall -Werror=return-type -Wno-unused-function -U__STRICT_ANSI__ $(shell deps/curl/bin/curl-config --cflags)
2726
LDFLAGS += -static $(shell deps/curl/bin/curl-config --static-libs)
2827
else
29-
CFLAGS += -std=c99 -Ideps -g -Wall -Werror=return-type -Wno-unused-function -U__STRICT_ANSI__ $(shell curl-config --cflags)
28+
CFLAGS += -std=gnu17 -Ideps -g -Wall -Werror=return-type -Wno-unused-function $(shell curl-config --cflags)
3029
LDFLAGS += $(shell curl-config --libs)
3130
endif
3231

@@ -46,7 +45,7 @@ all: $(BINS)
4645

4746
build: $(BINS)
4847

49-
$(BINS): $(SRC) $(MAKEFILES) $(OBJS)
48+
$(BINS): $(SRC) $(COMMON_SRC) $(OBJS)
5049
$(CC) $(CFLAGS) -o $@ $(COMMON_SRC) src/$(@:.exe=).c $(OBJS) $(LDFLAGS)
5150

5251
$(MAKEFILES):

deps/http-get/http-get.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static size_t http_get_cb(void *contents, size_t size, size_t nmemb, void *userp
4040
return realsize;
4141
}
4242

43-
http_get_response_t *http_get_shared(const char *url, CURLSH *share) {
43+
http_get_response_t *http_get_shared(const char *url, CURLSH *share, const char** headers, int header_count) {
4444
CURL *req = curl_easy_init();
4545

4646
http_get_response_t *res = malloc(sizeof(http_get_response_t));
@@ -50,6 +50,15 @@ http_get_response_t *http_get_shared(const char *url, CURLSH *share) {
5050
curl_easy_setopt(req, CURLOPT_SHARE, share);
5151
}
5252

53+
if (header_count > 0) {
54+
struct curl_slist *chunk = NULL;
55+
for (int i = 0; i < header_count; i++) {
56+
chunk = curl_slist_append(chunk, headers[i]);
57+
}
58+
/* set our custom set of headers */
59+
curl_easy_setopt(req, CURLOPT_HTTPHEADER, chunk);
60+
}
61+
5362
curl_easy_setopt(req, CURLOPT_URL, url);
5463
curl_easy_setopt(req, CURLOPT_HTTPGET, 1);
5564
curl_easy_setopt(req, CURLOPT_FOLLOWLOCATION, 1);
@@ -70,8 +79,8 @@ http_get_response_t *http_get_shared(const char *url, CURLSH *share) {
7079
* Perform an HTTP(S) GET on `url`
7180
*/
7281

73-
http_get_response_t *http_get(const char *url) {
74-
return http_get_shared(url, NULL);
82+
http_get_response_t *http_get(const char *url, const char** headers, int header_count) {
83+
return http_get_shared(url, NULL, headers, header_count);
7584
}
7685

7786
/**

deps/http-get/http-get.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ typedef struct {
2121
int ok;
2222
} http_get_response_t;
2323

24-
http_get_response_t *http_get(const char *);
25-
http_get_response_t *http_get_shared(const char *, void *);
24+
http_get_response_t *http_get(const char *url, const char** headers, int header_count);
25+
http_get_response_t *http_get_shared(const char *url, void *, const char** headers, int header_count);
2626

2727
int http_get_file(const char *, const char *);
2828
int http_get_file_shared(const char *, const char *, void *);

deps/url/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "url",
3+
"version": "0.0.2",
4+
"repo": "jwerle/url.h",
5+
"description": "Parse URLs much like Node's url module",
6+
"keywords": ["url", "parse"],
7+
"license": "MIT",
8+
"src": ["url.h"]
9+
}

0 commit comments

Comments
 (0)