aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/enums.c4
-rw-r--r--src/errors.c6
-rw-r--r--src/getinfo.c5
-rw-r--r--src/main.c1
-rw-r--r--src/setopt.c5
5 files changed, 12 insertions, 9 deletions
diff --git a/src/enums.c b/src/enums.c
index 1228f63..bd975bc 100644
--- a/src/enums.c
+++ b/src/enums.c
@@ -169,11 +169,11 @@ static const struct jurl_enum jurl_enums[] = {
{CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_KEYBOARD, "ssh-auth/keyboard"},
{CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_AGENT, "ssh-auth/agent"},
{CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_ANY, "ssh-auth/any"},
+ {0, 0, NULL},
};
-#define jurl_enum_size (sizeof(jurl_enums) / sizeof(struct jurl_enum))
static long get_eq(CURLoption opt, JanetKeyword kw) {
- for (size_t i = 0; i < jurl_enum_size; i++) {
+ for (size_t i = 0; jurl_enums[i].keyword; i++) {
if (jurl_enums[i].opt == opt && !strcmp(jurl_enums[i].keyword, (const char*)kw)) {
return jurl_enums[i].value;
}
diff --git a/src/errors.c b/src/errors.c
index 94219fe..57097dc 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -105,12 +105,12 @@ static const struct jurl_error jurl_errors[] = {
{CURLE_PROXY, "error/proxy"},
{CURLE_SSL_CLIENTCERT, "error/ssl-clientcert"},
{CURLE_UNRECOVERABLE_POLL, "error/unrecoverable-poll"},
+ {0, NULL},
};
-#define jurl_error_size (sizeof(jurl_errors) / sizeof(struct jurl_error))
// translate a CURLcode return code into a keyword
Janet jurl_geterror(CURLcode code) {
- for (size_t i = 0; i < jurl_error_size; i++) {
+ for (size_t i = 0; jurl_errors[i].keyword; i++) {
if (jurl_errors[i].code == code) {
return janet_ckeywordv(jurl_errors[i].keyword);
}
@@ -125,7 +125,7 @@ JANET_CFUN(jurl_strerror) {
Janet arg = argv[0];
switch (janet_checktypes(arg, JANET_TFLAG_KEYWORD | JANET_TFLAG_NUMBER)) {
case JANET_TFLAG_KEYWORD:
- for (size_t i = 0; i < jurl_error_size; i++) {
+ for (size_t i = 0; jurl_errors[i].keyword; i++) {
if (janet_keyeq(arg, jurl_errors[i].keyword)) {
code = jurl_errors[i].code;
break;
diff --git a/src/getinfo.c b/src/getinfo.c
index 95fd6be..bf058f8 100644
--- a/src/getinfo.c
+++ b/src/getinfo.c
@@ -86,6 +86,7 @@ static const struct jurl_opt jurl_opts[] = {
{CURLINFO_RTSP_CSEQ_RECV, "rtsp-cseq-recv", JURL_PARAMTYPE_LONG},
// SKIP: protocol: deprecated for scheme
{CURLINFO_SCHEME, "scheme", JURL_PARAMTYPE_STRING},
+ {0, NULL, 0},
};
JANET_CFUN(jurl_getinfo) {
@@ -95,7 +96,7 @@ JANET_CFUN(jurl_getinfo) {
const struct jurl_opt *opt;
Janet jopt = argv[1];
- for (size_t i = 0; i < sizeof(jurl_opts) / sizeof(struct jurl_opt); i++) {
+ for (size_t i = 0; jurl_opts[i].keyword; i++) {
if(janet_keyeq(jopt, jurl_opts[i].keyword)) {
opt = &jurl_opts[i];
break;
@@ -103,7 +104,7 @@ JANET_CFUN(jurl_getinfo) {
}
if (!opt) {
int num = janet_getinteger(argv, 1);
- for (size_t i = 0; i < sizeof(jurl_opts) / sizeof(struct jurl_opt); i++) {
+ for (size_t i = 0; jurl_opts[i].keyword; i++) {
if (num == jurl_opts[i].info) {
opt = &jurl_opts[i];
break;
diff --git a/src/main.c b/src/main.c
index a322d99..2a7ffa9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -152,6 +152,7 @@ static const JanetRegExt cfuns[] = {
// jurl_setopt.c
JANET_REG("setopt", jurl_setopt),
+ JANET_REG_END,
};
JANET_MODULE_ENTRY(JanetTable *env) {
diff --git a/src/setopt.c b/src/setopt.c
index e000731..a32c8a8 100644
--- a/src/setopt.c
+++ b/src/setopt.c
@@ -351,6 +351,7 @@ static const struct jurl_opt jurl_opts[] = {
// * telnet options
{CURLOPT_TELNETOPTIONS, "telnetoptions", JURL_PARAMTYPE_SLIST},
+ {0, NULL, 0},
};
JANET_CFUN(jurl_setopt) {
@@ -359,7 +360,7 @@ JANET_CFUN(jurl_setopt) {
const struct jurl_opt *opt;
Janet jopt = argv[1];
- for (size_t i = 0; i < sizeof(jurl_opts) / sizeof(struct jurl_opt); i++) {
+ for (size_t i = 0; jurl_opts[i].keyword; i++) {
if (janet_keyeq(jopt, jurl_opts[i].keyword)) {
opt = &jurl_opts[i];
break;
@@ -367,7 +368,7 @@ JANET_CFUN(jurl_setopt) {
}
if (!opt) {
int num = janet_getinteger(argv, 1);
- for (size_t i = 0; i < sizeof(jurl_opts) / sizeof(struct jurl_opt); i++) {
+ for (size_t i = 0; jurl_opts[i].keyword; i++) {
if (num == jurl_opts[i].opt) {
opt = &jurl_opts[i];
break;