Skip to content

Commit 4be36e0

Browse files
committed
misc: Cleanup, add headers.
1 parent 0021740 commit 4be36e0

22 files changed

+223
-296
lines changed

src/clib-build.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ int build_package_with_manifest_name(const char *dir, const char *file) {
205205
#ifdef DEBUG
206206
package = clib_package_new_from_slug(dir, 1);
207207
#else
208-
package = clib_package_new_from_slug_and_url(dir, 0);
208+
package = clib_package_new_from_slug_and_url(dir, "FIXME", 0);
209209
#endif
210210
}
211211

@@ -336,7 +336,7 @@ int build_package_with_manifest_name(const char *dir, const char *file) {
336336
char *dep_dir = 0;
337337
asprintf(&slug, "%s/%s@%s", dep->author, dep->name, dep->version);
338338

339-
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, 0);
339+
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, "FIXME", 0);
340340
if (opts.dir && dependency && dependency->name) {
341341
dep_dir = path_join(opts.dir, dependency->name);
342342
}
@@ -407,7 +407,7 @@ int build_package_with_manifest_name(const char *dir, const char *file) {
407407
char *slug = 0;
408408
asprintf(&slug, "%s/%s@%s", dep->author, dep->name, dep->version);
409409

410-
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, 0);
410+
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, "FIXME", 0);
411411
char *dep_dir = path_join(opts.dir, dependency->name);
412412

413413
free(slug);

src/clib-configure.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ int configure_package_with_manifest_name(const char *dir, const char *file) {
198198
#ifdef DEBUG
199199
package = clib_package_new_from_slug(dir, 1);
200200
#else
201-
package = clib_package_new_from_slug_and_url(dir, 0);
201+
package = clib_package_new_from_slug_and_url(dir, "FIXME", 0);
202202
#endif
203203
}
204204

@@ -294,7 +294,7 @@ int configure_package_with_manifest_name(const char *dir, const char *file) {
294294
char *slug = 0;
295295
asprintf(&slug, "%s/%s@%s", dep->author, dep->name, dep->version);
296296

297-
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, 0);
297+
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, "FIXME", 0);
298298
char *dep_dir = path_join(opts.dir, dependency->name);
299299

300300
free(slug);
@@ -365,7 +365,7 @@ int configure_package_with_manifest_name(const char *dir, const char *file) {
365365
char *slug = 0;
366366
asprintf(&slug, "%s/%s@%s", dep->author, dep->name, dep->version);
367367

368-
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, 0);
368+
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, "FIXME", 0);
369369
char *dep_dir = path_join(opts.dir, dependency->name);
370370

371371
free(slug);

src/clib-install.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,14 @@ static int install_package(const char *slug) {
293293

294294
registries_t registries = registry_manager_init_registries(package->registries, secrets);
295295
registry_manager_fetch_registries(registries);
296-
wiki_package_ptr_t package_info = registry_manger_find_package(registries, slug);
296+
registry_package_ptr_t package_info = registry_manger_find_package(registries, slug);
297297
if (!package_info) {
298298
debug(&debugger, "Package %s not found in any registry.", slug);
299299
return -1;
300300
}
301301

302302

303-
pkg = clib_package_new_from_slug_and_url(slug, wiki_package_get_href(package_info), opts.verbose);
303+
pkg = clib_package_new_from_slug_and_url(slug, registry_package_get_href(package_info), opts.verbose);
304304
if (NULL == pkg)
305305
return -1;
306306

src/clib-search.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "logger/logger.h"
1818
#include "parson/parson.h"
1919
#include "registry-manager.h"
20-
#include "registry/wiki-registry.h"
20+
#include "registry/registry.h"
2121
#include "strdup/strdup.h"
2222
#include "tempdir/tempdir.h"
2323
#include "version.h"
@@ -63,7 +63,7 @@ static void setopt_json(command_t *self) { opt_json = 1; }
6363
} \
6464
}
6565

66-
static int matches(int count, char *args[], wiki_package_ptr_t pkg) {
66+
static int matches(int count, char *args[], registry_package_ptr_t pkg) {
6767
// Display all packages if there's no query
6868
if (0 == count)
6969
return 1;
@@ -74,16 +74,16 @@ static int matches(int count, char *args[], wiki_package_ptr_t pkg) {
7474
char *href = NULL;
7575
int rc = 0;
7676

77-
name = clib_package_parse_name(wiki_package_get_id(pkg));
77+
name = clib_package_parse_name(registry_package_get_id(pkg));
7878
COMPARE(name);
7979

80-
description = strdup(wiki_package_get_description(pkg));
80+
description = strdup(registry_package_get_description(pkg));
8181
COMPARE(description);
8282

83-
repo = strdup(wiki_package_get_id(pkg));
83+
repo = strdup(registry_package_get_id(pkg));
8484
COMPARE(repo);
8585

86-
href = strdup(wiki_package_get_href(pkg));
86+
href = strdup(registry_package_get_href(pkg));
8787
COMPARE(href);
8888

8989
cleanup:
@@ -122,26 +122,26 @@ static char *wiki_html_cache() {
122122
}
123123
*/
124124

125-
static void display_package(const wiki_package_ptr_t pkg,
125+
static void display_package(const registry_package_ptr_t pkg,
126126
cc_color_t fg_color_highlight,
127127
cc_color_t fg_color_text) {
128-
cc_fprintf(fg_color_highlight, stdout, " %s\n", wiki_package_get_id(pkg));
128+
cc_fprintf(fg_color_highlight, stdout, " %s\n", registry_package_get_id(pkg));
129129
printf(" url: ");
130-
cc_fprintf(fg_color_text, stdout, "%s\n", wiki_package_get_href(pkg));
130+
cc_fprintf(fg_color_text, stdout, "%s\n", registry_package_get_href(pkg));
131131
printf(" desc: ");
132-
cc_fprintf(fg_color_text, stdout, "%s\n", wiki_package_get_description(pkg));
132+
cc_fprintf(fg_color_text, stdout, "%s\n", registry_package_get_description(pkg));
133133
printf("\n");
134134
}
135135

136-
static void add_package_to_json(const wiki_package_ptr_t pkg,
136+
static void add_package_to_json(const registry_package_ptr_t pkg,
137137
JSON_Array *json_list) {
138138
JSON_Value *json_pkg_root = json_value_init_object();
139139
JSON_Object *json_pkg = json_value_get_object(json_pkg_root);
140140

141-
json_object_set_string(json_pkg, "repo", wiki_package_get_id(pkg));
142-
json_object_set_string(json_pkg, "href", wiki_package_get_href(pkg));
143-
json_object_set_string(json_pkg, "description", wiki_package_get_description(pkg));
144-
json_object_set_string(json_pkg, "category", wiki_package_get_category(pkg));
141+
json_object_set_string(json_pkg, "repo", registry_package_get_id(pkg));
142+
json_object_set_string(json_pkg, "href", registry_package_get_href(pkg));
143+
json_object_set_string(json_pkg, "description", registry_package_get_description(pkg));
144+
json_object_set_string(json_pkg, "category", registry_package_get_category(pkg));
145145

146146
json_array_append_value(json_list, json_pkg_root);
147147
}
@@ -198,11 +198,11 @@ int main(int argc, char *argv[]) {
198198
*/
199199

200200
registry_iterator_t it = registry_iterator_new(registries);
201-
wiki_registry_ptr_t registry = NULL;
201+
registry_ptr_t registry = NULL;
202202
while ((registry = registry_iterator_next(it))) {
203-
printf("SEARCH: packages from %s\n", wiki_registry_get_url(registry));
204-
wiki_package_ptr_t pkg;
205-
wiki_registry_iterator_t it = wiki_registry_iterator_new(registry);
203+
printf("SEARCH: packages from %s\n", registry_get_url(registry));
204+
registry_package_ptr_t pkg;
205+
registry_package_iterator_t it = registry_package_iterator_new(registry);
206206

207207
JSON_Array *json_list = NULL;
208208
JSON_Value *json_list_root = NULL;
@@ -214,15 +214,15 @@ int main(int argc, char *argv[]) {
214214

215215
printf("\n");
216216

217-
while ((pkg = wiki_registry_iterator_next(it))) {
217+
while ((pkg = registry_package_iterator_next(it))) {
218218
if (matches(program.argc, program.argv, pkg)) {
219219
if (opt_json) {
220220
add_package_to_json(pkg, json_list);
221221
} else {
222222
display_package(pkg, fg_color_highlight, fg_color_text);
223223
}
224224
} else {
225-
debug(&debugger, "skipped package %s", wiki_package_get_id(pkg));
225+
debug(&debugger, "skipped package %s", registry_package_get_id(pkg));
226226
}
227227
}
228228

@@ -234,7 +234,7 @@ int main(int argc, char *argv[]) {
234234
json_value_free(json_list_root);
235235
}
236236

237-
wiki_registry_iterator_destroy(it);
237+
registry_package_iterator_destroy(it);
238238
}
239239
command_free(&program);
240240
return 0;

src/clib-update.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static int install_package(const char *slug) {
237237
}
238238

239239
if (!pkg) {
240-
pkg = clib_package_new_from_slug_and_url(slug, opts.verbose);
240+
pkg = clib_package_new_from_slug_and_url(slug, "FIXME", opts.verbose);
241241
}
242242

243243
if (NULL == pkg)

src/clib-upgrade.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static int install_package(const char *slug) {
143143

144144
logger_info("info", "Upgrading to %s", extended_slug);
145145

146-
pkg = clib_package_new_from_slug_and_url(extended_slug, opts.verbose);
146+
pkg = clib_package_new_from_slug_and_url(extended_slug, "FIXME", opts.verbose);
147147

148148
if (NULL == pkg) {
149149
logger_error("error",

src/common/clib-package.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ clib_package_new_from_slug_with_package_name(const char *slug, const char* url,
730730
free(author);
731731
free(name);
732732
free(version);
733-
free(url);
734733
free(json_url);
735734
free(repo);
736735
if (!res && json)

src/registry/github-registry.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
//
22
// github-registry.c
33
//
4-
// Copyright (c) 2020 Elbert van de Put
4+
// Copyright (c) 2021 Elbert van de Put
55
// Based on work by Stephen Mathieson
66
// MIT licensed
77
//
8-
#include <string.h>
98
#include "github-registry.h"
10-
#include "gumbo-text-content/gumbo-text-content.h"
9+
#include "case/case.h"
1110
#include "gumbo-get-element-by-id/get-element-by-id.h"
1211
#include "gumbo-get-elements-by-tag-name/get-elements-by-tag-name.h"
12+
#include "gumbo-text-content/gumbo-text-content.h"
1313
#include "http-get/http-get.h"
14-
#include <curl/curl.h>
15-
#include "substr/substr.h"
14+
#include "registry-internal.h"
1615
#include "strdup/strdup.h"
17-
#include "case/case.h"
16+
#include "substr/substr.h"
1817
#include "trim/trim.h"
19-
#include "wiki-registry-internal.h"
18+
#include <curl/curl.h>
19+
#include <string.h>
2020

2121
/**
2222
* Add `href` to the given `package`.
2323
*/
24-
static void add_package_href(wiki_package_ptr_t self) {
24+
static void add_package_href(registry_package_ptr_t self) {
2525
size_t len = strlen(self->id) + 20; // https://github.com/ \0
2626
self->href = malloc(len);
2727
if (self->href)
@@ -31,8 +31,8 @@ static void add_package_href(wiki_package_ptr_t self) {
3131
/**
3232
* Parse the given wiki `li` into a package.
3333
*/
34-
static wiki_package_ptr_t parse_li(GumboNode *li) {
35-
wiki_package_ptr_t self = wiki_package_new();
34+
static registry_package_ptr_t parse_li(GumboNode *li) {
35+
registry_package_ptr_t self = registry_package_new();
3636
char *text = NULL;
3737

3838
if (!self) goto cleanup;
@@ -96,13 +96,14 @@ list_t *wiki_registry_parse(const char *html) {
9696
list_iterator_t *li_iterator = list_iterator_new(lis, LIST_HEAD);
9797
list_node_t *li_node;
9898
while ((li_node = list_iterator_next(li_iterator))) {
99-
wiki_package_ptr_t package = parse_li(li_node->val);
99+
registry_package_ptr_t package = parse_li(li_node->val);
100100
if (package && package->description) {
101101
package->category = strdup(category);
102102
list_rpush(pkgs, list_node_new(package));
103103
} else {
104104
// failed to parse package
105-
if (package) wiki_package_free(package);
105+
if (package)
106+
registry_package_free(package);
106107
}
107108
}
108109
list_iterator_destroy(li_iterator);

0 commit comments

Comments
 (0)