Skip to content

Commit 251634c

Browse files
committed
misc: Cleanup, add headers.
1 parent f3ddef0 commit 251634c

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
@@ -199,7 +199,7 @@ int build_package_with_manifest_name(const char *dir, const char *file) {
199199
#ifdef DEBUG
200200
package = clib_package_new_from_slug(dir, 1);
201201
#else
202-
package = clib_package_new_from_slug_and_url(dir, 0);
202+
package = clib_package_new_from_slug_and_url(dir, "FIXME", 0);
203203
#endif
204204
}
205205

@@ -330,7 +330,7 @@ int build_package_with_manifest_name(const char *dir, const char *file) {
330330
char *dep_dir = 0;
331331
asprintf(&slug, "%s/%s@%s", dep->author, dep->name, dep->version);
332332

333-
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, 0);
333+
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, "FIXME", 0);
334334
if (opts.dir && dependency && dependency->name) {
335335
dep_dir = path_join(opts.dir, dependency->name);
336336
}
@@ -401,7 +401,7 @@ int build_package_with_manifest_name(const char *dir, const char *file) {
401401
char *slug = 0;
402402
asprintf(&slug, "%s/%s@%s", dep->author, dep->name, dep->version);
403403

404-
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, 0);
404+
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, "FIXME", 0);
405405
char *dep_dir = path_join(opts.dir, dependency->name);
406406

407407
free(slug);

src/clib-configure.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ int configure_package_with_manifest_name(const char *dir, const char *file) {
192192
#ifdef DEBUG
193193
package = clib_package_new_from_slug(dir, 1);
194194
#else
195-
package = clib_package_new_from_slug_and_url(dir, 0);
195+
package = clib_package_new_from_slug_and_url(dir, "FIXME", 0);
196196
#endif
197197
}
198198

@@ -288,7 +288,7 @@ int configure_package_with_manifest_name(const char *dir, const char *file) {
288288
char *slug = 0;
289289
asprintf(&slug, "%s/%s@%s", dep->author, dep->name, dep->version);
290290

291-
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, 0);
291+
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, "FIXME", 0);
292292
char *dep_dir = path_join(opts.dir, dependency->name);
293293

294294
free(slug);
@@ -359,7 +359,7 @@ int configure_package_with_manifest_name(const char *dir, const char *file) {
359359
char *slug = 0;
360360
asprintf(&slug, "%s/%s@%s", dep->author, dep->name, dep->version);
361361

362-
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, 0);
362+
clib_package_t *dependency = clib_package_new_from_slug_and_url(slug, "FIXME", 0);
363363
char *dep_dir = path_join(opts.dir, dependency->name);
364364

365365
free(slug);

src/clib-install.c

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

287287
registries_t registries = registry_manager_init_registries(package->registries, secrets);
288288
registry_manager_fetch_registries(registries);
289-
wiki_package_ptr_t package_info = registry_manger_find_package(registries, slug);
289+
registry_package_ptr_t package_info = registry_manger_find_package(registries, slug);
290290
if (!package_info) {
291291
debug(&debugger, "Package %s not found in any registry.", slug);
292292
return -1;
293293
}
294294

295295

296-
pkg = clib_package_new_from_slug_and_url(slug, wiki_package_get_href(package_info), opts.verbose);
296+
pkg = clib_package_new_from_slug_and_url(slug, registry_package_get_href(package_info), opts.verbose);
297297
if (NULL == pkg)
298298
return -1;
299299

src/clib-search.c

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

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

78-
name = clib_package_parse_name(wiki_package_get_id(pkg));
78+
name = clib_package_parse_name(registry_package_get_id(pkg));
7979
COMPARE(name);
8080

81-
description = strdup(wiki_package_get_description(pkg));
81+
description = strdup(registry_package_get_description(pkg));
8282
COMPARE(description);
8383

84-
repo = strdup(wiki_package_get_id(pkg));
84+
repo = strdup(registry_package_get_id(pkg));
8585
COMPARE(repo);
8686

87-
href = strdup(wiki_package_get_href(pkg));
87+
href = strdup(registry_package_get_href(pkg));
8888
COMPARE(href);
8989

9090
cleanup:
@@ -123,26 +123,26 @@ static char *wiki_html_cache() {
123123
}
124124
*/
125125

126-
static void display_package(const wiki_package_ptr_t pkg,
126+
static void display_package(const registry_package_ptr_t pkg,
127127
cc_color_t fg_color_highlight,
128128
cc_color_t fg_color_text) {
129-
cc_fprintf(fg_color_highlight, stdout, " %s\n", wiki_package_get_id(pkg));
129+
cc_fprintf(fg_color_highlight, stdout, " %s\n", registry_package_get_id(pkg));
130130
printf(" url: ");
131-
cc_fprintf(fg_color_text, stdout, "%s\n", wiki_package_get_href(pkg));
131+
cc_fprintf(fg_color_text, stdout, "%s\n", registry_package_get_href(pkg));
132132
printf(" desc: ");
133-
cc_fprintf(fg_color_text, stdout, "%s\n", wiki_package_get_description(pkg));
133+
cc_fprintf(fg_color_text, stdout, "%s\n", registry_package_get_description(pkg));
134134
printf("\n");
135135
}
136136

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

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

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

201201
registry_iterator_t it = registry_iterator_new(registries);
202-
wiki_registry_ptr_t registry = NULL;
202+
registry_ptr_t registry = NULL;
203203
while ((registry = registry_iterator_next(it))) {
204-
printf("SEARCH: packages from %s\n", wiki_registry_get_url(registry));
205-
wiki_package_ptr_t pkg;
206-
wiki_registry_iterator_t it = wiki_registry_iterator_new(registry);
204+
printf("SEARCH: packages from %s\n", registry_get_url(registry));
205+
registry_package_ptr_t pkg;
206+
registry_package_iterator_t it = registry_package_iterator_new(registry);
207207

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

216216
printf("\n");
217217

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

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

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

src/clib-update.c

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

232232
if (!pkg) {
233-
pkg = clib_package_new_from_slug_and_url(slug, opts.verbose);
233+
pkg = clib_package_new_from_slug_and_url(slug, "FIXME", opts.verbose);
234234
}
235235

236236
if (NULL == pkg)

src/clib-upgrade.c

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

137137
logger_info("info", "Upgrading to %s", extended_slug);
138138

139-
pkg = clib_package_new_from_slug_and_url(extended_slug, opts.verbose);
139+
pkg = clib_package_new_from_slug_and_url(extended_slug, "FIXME", opts.verbose);
140140

141141
if (NULL == pkg) {
142142
logger_error("error",

src/common/clib-package.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,6 @@ clib_package_new_from_slug_with_package_name(const char *slug, const char* url,
729729
free(author);
730730
free(name);
731731
free(version);
732-
free(url);
733732
free(json_url);
734733
free(repo);
735734
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)