diff --git a/lib/core/libwebsockets.c b/lib/core/libwebsockets.c index 2cca7ba3e..bc076dead 100644 --- a/lib/core/libwebsockets.c +++ b/lib/core/libwebsockets.c @@ -1530,7 +1530,7 @@ lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path, pf = fops->next; while (pf) { n = 0; - while (n < (int)ARRAY_SIZE(pf->fi) && pf->fi[n].sig) { + while (n < (int)LWS_ARRAY_SIZE(pf->fi) && pf->fi[n].sig) { if (p >= vfs_path + pf->fi[n].len) if (!strncmp(p - (pf->fi[n].len - 1), pf->fi[n].sig, @@ -2023,14 +2023,14 @@ LWS_VISIBLE void lwsl_emit_stderr(int level, const char *line) { char buf[50]; static char tty = 3; - int n, m = ARRAY_SIZE(colours) - 1; + int n, m = LWS_ARRAY_SIZE(colours) - 1; if (!tty) tty = isatty(2) | 2; lwsl_timestamp(level, buf, sizeof(buf)); if (tty == 3) { - n = 1 << (ARRAY_SIZE(colours) - 1); + n = 1 << (LWS_ARRAY_SIZE(colours) - 1); while (n) { if (level & n) break; diff --git a/lib/core/private.h b/lib/core/private.h index 84b4a949a..839c3a292 100644 --- a/lib/core/private.h +++ b/lib/core/private.h @@ -136,6 +136,20 @@ #include "tls/private.h" +#if defined(WIN32) || defined(_WIN32) + // Visual studio older than 2015 and WIN_CE has only _stricmp + #if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE) + #define strcasecmp _stricmp + #elif !defined(__MINGW32__) + #define strcasecmp stricmp + #endif + #define getdtablesize() 30000 +#endif + +#ifndef LWS_ARRAY_SIZE +#define LWS_ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/lib/event-libs/libuv/libuv.c b/lib/event-libs/libuv/libuv.c index ec37e09e8..ddcbc4adb 100644 --- a/lib/event-libs/libuv/libuv.c +++ b/lib/event-libs/libuv/libuv.c @@ -722,7 +722,7 @@ elops_destroy_pt_uv(struct lws_context *context, int tsi) if (!pt->event_loop_foreign) { uv_signal_stop(&pt->w_sigint.uv.watcher); - ns = ARRAY_SIZE(sigs); + ns = LWS_ARRAY_SIZE(sigs); if (lws_check_opt(context->options, LWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN)) ns = 2; @@ -783,13 +783,13 @@ elops_init_pt_uv(struct lws_context *context, void *_loop, int tsi) LWS_UV_REFCOUNT_STATIC_HANDLE_NEW(&pt->uv.idle, context); - ns = ARRAY_SIZE(sigs); + ns = LWS_ARRAY_SIZE(sigs); if (lws_check_opt(context->options, LWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN)) ns = 2; if (!pt->event_loop_foreign) { - assert(ns <= (int)ARRAY_SIZE(pt->uv.signals)); + assert(ns <= (int)LWS_ARRAY_SIZE(pt->uv.signals)); for (n = 0; n < ns; n++) { uv_signal_init(loop, &pt->uv.signals[n]); LWS_UV_REFCOUNT_STATIC_HANDLE_NEW(&pt->uv.signals[n], diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 4857850ce..ddf92f993 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -66,14 +66,6 @@ typedef unsigned long long lws_intptr_t; #define O_RDONLY _O_RDONLY #endif -// Visual studio older than 2015 and WIN_CE has only _stricmp -#if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE) -#define strcasecmp _stricmp -#elif !defined(__MINGW32__) -#define strcasecmp stricmp -#endif -#define getdtablesize() 30000 - #define LWS_INLINE __inline #define LWS_VISIBLE #define LWS_WARN_UNUSED_RESULT @@ -462,9 +454,6 @@ lwsl_visible(int level); #endif struct lws; -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif typedef int64_t lws_usec_t; @@ -7097,10 +7086,9 @@ lws_email_destroy(struct lws_email *email); //@{ struct lejp_ctx; -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(_x) (sizeof(_x) / sizeof(_x[0])) -#endif +#if !defined(LWS_ARRAY_SIZE) #define LWS_ARRAY_SIZE(_x) (sizeof(_x) / sizeof(_x[0])) +#endif #define LEJP_FLAG_WS_KEEP 64 #define LEJP_FLAG_WS_COMMENTLINE 32 diff --git a/lib/misc/jws/jwk.c b/lib/misc/jws/jwk.c index 2337d5e8c..3a346906c 100644 --- a/lib/misc/jws/jwk.c +++ b/lib/misc/jws/jwk.c @@ -135,7 +135,7 @@ lws_jwk_import(struct lws_jwk *s, const char *in, size_t len) cbs.b64 = b64; cbs.b64max = b64max; cbs.pos = 0; - lejp_construct(&jctx, cb_jwk, &cbs, jwk_tok, ARRAY_SIZE(jwk_tok)); + lejp_construct(&jctx, cb_jwk, &cbs, jwk_tok, LWS_ARRAY_SIZE(jwk_tok)); m = (int)(signed char)lejp_parse(&jctx, (uint8_t *)in, len); lejp_destruct(&jctx); diff --git a/lib/misc/jws/jws.c b/lib/misc/jws/jws.c index 23a863ca5..72cfc9806 100644 --- a/lib/misc/jws/jws.c +++ b/lib/misc/jws/jws.c @@ -273,7 +273,7 @@ lws_jws_confirm_sig(const char *in, size_t len, struct lws_jwk *jwk) args.alg[0] = '\0'; args.is_rsa = 0; - lejp_construct(&jctx, cb_hdr, &args, jhdr_tok, ARRAY_SIZE(jhdr_tok)); + lejp_construct(&jctx, cb_hdr, &args, jhdr_tok, LWS_ARRAY_SIZE(jhdr_tok)); m = (int)(signed char)lejp_parse(&jctx, (uint8_t *)buf, n); lejp_destruct(&jctx); if (m < 0) { diff --git a/lib/misc/lejp.c b/lib/misc/lejp.c index f945d09ae..99142b955 100644 --- a/lib/misc/lejp.c +++ b/lib/misc/lejp.c @@ -20,6 +20,7 @@ */ #include +#include "core/private.h" #include #include @@ -30,7 +31,7 @@ * \param callback: your user callback which will received parsed tokens * \param user: optional user data pointer untouched by lejp * \param paths: your array of name elements you are interested in - * \param count_paths: ARRAY_SIZE() of @paths + * \param count_paths: LWS_ARRAY_SIZE() of @paths * * Prepares your context struct for use with lejp */ @@ -417,7 +418,7 @@ lejp_parse(struct lejp_ctx *ctx, const unsigned char *json, int len) goto reject; } ctx->i[ctx->ipos++] = 0; - if (ctx->ipos > ARRAY_SIZE(ctx->i)) { + if (ctx->ipos > LWS_ARRAY_SIZE(ctx->i)) { ret = LEJP_REJECT_MP_DELIM_ISTACK; goto reject; } @@ -722,7 +723,7 @@ add_stack_level: ctx->st[ctx->sp].p = ctx->ppos; ctx->st[ctx->sp].i = ctx->ipos; - if (++ctx->sp == ARRAY_SIZE(ctx->st)) { + if (++ctx->sp == LWS_ARRAY_SIZE(ctx->st)) { ret = LEJP_REJECT_STACK_OVERFLOW; goto reject; } diff --git a/lib/plat/esp32/esp32-helpers.c b/lib/plat/esp32/esp32-helpers.c index b624651f3..cf60784e5 100644 --- a/lib/plat/esp32/esp32-helpers.c +++ b/lib/plat/esp32/esp32-helpers.c @@ -412,7 +412,7 @@ end_scan() uint16_t count_ap_records; int n, m; - count_ap_records = ARRAY_SIZE(ap_records); + count_ap_records = LWS_ARRAY_SIZE(ap_records); if (esp_wifi_scan_get_ap_records(&count_ap_records, ap_records)) { lwsl_err("%s: failed\n", __func__); return; @@ -636,7 +636,7 @@ esp_err_t lws_esp32_event_passthru(void *ctx, system_event_t *event) mdns_service_add(lws_esp32.group, "_lwsgrmem", "_tcp", 443, txta, - ARRAY_SIZE(txta)); + LWS_ARRAY_SIZE(txta)); mem = lws_esp32.first; while (mem) { diff --git a/lib/plat/windows/windows-file.c b/lib/plat/windows/windows-file.c index ee9dc7418..6516b70b0 100644 --- a/lib/plat/windows/windows-file.c +++ b/lib/plat/windows/windows-file.c @@ -38,7 +38,7 @@ _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename, lws_fop_fd_t fop_fd; LARGE_INTEGER llFileSize = {0}; - MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, ARRAY_SIZE(buf)); + MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, LWS_ARRAY_SIZE(buf)); if (((*flags) & 7) == _O_RDONLY) { ret = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); diff --git a/lib/roles/cgi/cgi-server.c b/lib/roles/cgi/cgi-server.c index 5c4b10c27..cb80fc5a5 100644 --- a/lib/roles/cgi/cgi-server.c +++ b/lib/roles/cgi/cgi-server.c @@ -228,7 +228,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len }; if (script_uri_path_len >= 0) - for (m = 0; m < (int)ARRAY_SIZE(meths); m++) + for (m = 0; m < (int)LWS_ARRAY_SIZE(meths); m++) if (lws_hdr_total_length(wsi, meths[m]) >= script_uri_path_len) { uritok = meths[m]; diff --git a/lib/roles/h2/hpack.c b/lib/roles/h2/hpack.c index d25849d0a..b59ce9f9e 100644 --- a/lib/roles/h2/hpack.c +++ b/lib/roles/h2/hpack.c @@ -219,7 +219,7 @@ static int lws_frag_start(struct lws *wsi, int hdr_token_idx) return 1; } - if (ah->nfrag >= ARRAY_SIZE(ah->frag_index)) { + if (ah->nfrag >= LWS_ARRAY_SIZE(ah->frag_index)) { lwsl_err("%s: frag index %d too big\n", __func__, ah->nfrag); return 1; } @@ -375,8 +375,8 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len, if (index < 0) return -1; - if (index < (int)ARRAY_SIZE(static_token)) { - if (arg && index < (int)ARRAY_SIZE(http2_canned)) { + if (index < (int)LWS_ARRAY_SIZE(static_token)) { + if (arg && index < (int)LWS_ARRAY_SIZE(http2_canned)) { *arg = http2_canned[index]; *len = (int)strlen(http2_canned[index]); } @@ -391,8 +391,8 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len, return -1; } - if (index < (int)ARRAY_SIZE(static_token) || - index >= (int)ARRAY_SIZE(static_token) + dyn->used_entries) { + if (index < (int)LWS_ARRAY_SIZE(static_token) || + index >= (int)LWS_ARRAY_SIZE(static_token) + dyn->used_entries) { lwsl_info(" %s: adjusted index %d >= %d\n", __func__, index, dyn->used_entries); lws_h2_goaway(wsi, H2_ERR_COMPRESSION_ERROR, @@ -400,7 +400,7 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len, return -1; } - index -= (int)ARRAY_SIZE(static_token); + index -= (int)LWS_ARRAY_SIZE(static_token); index = (dyn->pos - 1 - index) % dyn->num_entries; if (index < 0) index += dyn->num_entries; @@ -435,7 +435,7 @@ lws_h2_dynamic_table_dump(struct lws *wsi) lwsl_header("Dump dyn table for nwsi %p (%d / %d members, pos = %d, " "start index %d, virt used %d / %d)\n", nwsi, dyn->used_entries, dyn->num_entries, dyn->pos, - (uint32_t)ARRAY_SIZE(static_token), + (uint32_t)LWS_ARRAY_SIZE(static_token), dyn->virtual_payload_usage, dyn->virtual_payload_max); for (n = 0; n < dyn->used_entries; n++) { @@ -448,7 +448,7 @@ lws_h2_dynamic_table_dump(struct lws *wsi) else p = "(ignored)"; lwsl_header(" %3d: tok %s: (len %d) val '%s'\n", - (int)(n + ARRAY_SIZE(static_token)), p, + (int)(n + LWS_ARRAY_SIZE(static_token)), p, dyn->entries[m].hdr_len, dyn->entries[m].value ? dyn->entries[m].value : "null"); } @@ -552,7 +552,7 @@ lws_dynamic_token_insert(struct lws *wsi, int hdr_len, dyn->virtual_payload_usage += hdr_len + len; lwsl_info("%s: index %ld: lws_hdr_index 0x%x, hdr len %d, '%s' len %d\n", - __func__, (long)ARRAY_SIZE(static_token), + __func__, (long)LWS_ARRAY_SIZE(static_token), lws_hdr_index, hdr_len, dyn->entries[new_index].value ? dyn->entries[new_index].value : "null", len); @@ -726,7 +726,7 @@ lws_hpack_use_idx_hdr(struct lws *wsi, int idx, int known_token) if (arg) p = arg; - if (idx < (int)ARRAY_SIZE(http2_canned)) + if (idx < (int)LWS_ARRAY_SIZE(http2_canned)) p = http2_canned[idx]; if (lws_frag_start(wsi, tok)) diff --git a/lib/roles/h2/minihuf.c b/lib/roles/h2/minihuf.c index eaf84e5d8..ee19e378e 100644 --- a/lib/roles/h2/minihuf.c +++ b/lib/roles/h2/minihuf.c @@ -16,7 +16,7 @@ #include #include -#define ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0])) +#define LWS_ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0])) struct huf { unsigned int code; @@ -340,7 +340,7 @@ int main(void) int fails = 0; m = 0; - while (m < ARRAY_SIZE(state)) { + while (m < LWS_ARRAY_SIZE(state)) { for (j = 0; j < PARALLEL; j++) { state[m].state[j] = 0xffff; state[m].terminal = 0; @@ -348,7 +348,7 @@ int main(void) m++; } - while (n < ARRAY_SIZE(huf_literal)) { + while (n < LWS_ARRAY_SIZE(huf_literal)) { m = 0; walk = 0; @@ -474,7 +474,7 @@ again: * Try to parse every legal input string */ - for (n = 0; n < ARRAY_SIZE(huf_literal); n++) { + for (n = 0; n < LWS_ARRAY_SIZE(huf_literal); n++) { walk = 0; m = 0; y = -1; diff --git a/lib/roles/http/header.c b/lib/roles/http/header.c index 2f020f153..ca2e6dad3 100644 --- a/lib/roles/http/header.c +++ b/lib/roles/http/header.c @@ -26,7 +26,7 @@ const unsigned char * lws_token_to_string(enum lws_token_indexes token) { - if ((unsigned int)token >= ARRAY_SIZE(set)) + if ((unsigned int)token >= LWS_ARRAY_SIZE(set)) return NULL; return (unsigned char *)set[token]; @@ -215,9 +215,9 @@ lws_add_http_header_status(struct lws *wsi, unsigned int _code, if (lwsi_role_h2(wsi) || lwsi_role_h2_ENCAPSULATION(wsi)) return lws_add_http2_header_status(wsi, code, p, end); #endif - if (code >= 400 && code < (400 + ARRAY_SIZE(err400))) + if (code >= 400 && code < (400 + LWS_ARRAY_SIZE(err400))) description = err400[code - 400]; - if (code >= 500 && code < (500 + ARRAY_SIZE(err500))) + if (code >= 500 && code < (500 + LWS_ARRAY_SIZE(err500))) description = err500[code - 500]; if (code == 100) @@ -230,7 +230,7 @@ lws_add_http_header_status(struct lws *wsi, unsigned int _code, if (code >= 300 && code < 400) description = "Redirect"; - if (wsi->http.request_version < ARRAY_SIZE(hver)) + if (wsi->http.request_version < LWS_ARRAY_SIZE(hver)) p1 = hver[wsi->http.request_version]; else p1 = hver[0]; diff --git a/lib/roles/http/server/lejp-conf.c b/lib/roles/http/server/lejp-conf.c index dc49bf61f..94912439d 100644 --- a/lib/roles/http/server/lejp-conf.c +++ b/lib/roles/http/server/lejp-conf.c @@ -225,7 +225,7 @@ arg_to_bool(const char *s) if (n) return 1; - for (n = 0; n < (int)ARRAY_SIZE(on); n++) + for (n = 0; n < (int)LWS_ARRAY_SIZE(on); n++) if (!strcasecmp(s, on[n])) return 1; @@ -503,7 +503,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason) if (a->last) a->last->mount_next = m; - for (n = 0; n < (int)ARRAY_SIZE(mount_protocols); n++) + for (n = 0; n < (int)LWS_ARRAY_SIZE(mount_protocols); n++) if (!strncmp(a->m.origin, mount_protocols[n], strlen(mount_protocols[n]))) { lwsl_info("----%s\n", a->m.origin); @@ -513,7 +513,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason) break; } - if (n == (int)ARRAY_SIZE(mount_protocols)) { + if (n == (int)LWS_ARRAY_SIZE(mount_protocols)) { lwsl_err("unsupported protocol:// %s\n", a->m.origin); return 1; } @@ -928,11 +928,11 @@ lwsws_get_config_globals(struct lws_context_creation_info *info, const char *d, lws_snprintf(dd, sizeof(dd) - 1, "%s/conf", d); if (lwsws_get_config(&a, dd, paths_global, - ARRAY_SIZE(paths_global), lejp_globals_cb) > 1) + LWS_ARRAY_SIZE(paths_global), lejp_globals_cb) > 1) return 1; lws_snprintf(dd, sizeof(dd) - 1, "%s/conf.d", d); if (lwsws_get_config_d(&a, dd, paths_global, - ARRAY_SIZE(paths_global), lejp_globals_cb) > 1) + LWS_ARRAY_SIZE(paths_global), lejp_globals_cb) > 1) return 1; a.plugin_dirs[a.count_plugin_dirs] = NULL; @@ -963,11 +963,11 @@ lwsws_get_config_vhosts(struct lws_context *context, lws_snprintf(dd, sizeof(dd) - 1, "%s/conf", d); if (lwsws_get_config(&a, dd, paths_vhosts, - ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) > 1) + LWS_ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) > 1) return 1; lws_snprintf(dd, sizeof(dd) - 1, "%s/conf.d", d); if (lwsws_get_config_d(&a, dd, paths_vhosts, - ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) > 1) + LWS_ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) > 1) return 1; *cs = a.p; diff --git a/lib/roles/http/server/lws-spa.c b/lib/roles/http/server/lws-spa.c index 916254c0a..a67bd9fee 100644 --- a/lib/roles/http/server/lws-spa.c +++ b/lib/roles/http/server/lws-spa.c @@ -263,7 +263,7 @@ retry_as_first: c =*in; if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; - for (n = 0; n < (int)ARRAY_SIZE(mp_hdr); n++) + for (n = 0; n < (int)LWS_ARRAY_SIZE(mp_hdr); n++) if (c == mp_hdr[n][s->mp]) { m++; hit = n; diff --git a/lib/roles/http/server/parsers.c b/lib/roles/http/server/parsers.c index 62778b8a0..1c0f6564e 100644 --- a/lib/roles/http/server/parsers.c +++ b/lib/roles/http/server/parsers.c @@ -563,7 +563,7 @@ int LWS_WARN_UNUSED_RESULT lws_hdr_simple_create(struct lws *wsi, enum lws_token_indexes h, const char *s) { wsi->http.ah->nfrag++; - if (wsi->http.ah->nfrag == ARRAY_SIZE(wsi->http.ah->frags)) { + if (wsi->http.ah->nfrag == LWS_ARRAY_SIZE(wsi->http.ah->frags)) { lwsl_warn("More hdr frags than we can deal with, dropping\n"); return -1; } @@ -683,7 +683,7 @@ lws_parse_urldecode(struct lws *wsi, uint8_t *_c) /* link to next fragment */ ah->frags[ah->nfrag].nfrag = ah->nfrag + 1; ah->nfrag++; - if (ah->nfrag >= ARRAY_SIZE(ah->frags)) + if (ah->nfrag >= LWS_ARRAY_SIZE(ah->frags)) goto excessive; /* start next fragment after the & */ ah->post_literal_equal = 0; @@ -786,7 +786,7 @@ lws_parse_urldecode(struct lws *wsi, uint8_t *_c) /* move to using WSI_TOKEN_HTTP_URI_ARGS */ ah->nfrag++; - if (ah->nfrag >= ARRAY_SIZE(ah->frags)) + if (ah->nfrag >= LWS_ARRAY_SIZE(ah->frags)) goto excessive; ah->frags[ah->nfrag].offset = ++ah->pos; ah->frags[ah->nfrag].len = 0; @@ -851,10 +851,10 @@ lws_parse(struct lws *wsi, unsigned char *buf, int *len) c == ' ') break; - for (m = 0; m < ARRAY_SIZE(methods); m++) + for (m = 0; m < LWS_ARRAY_SIZE(methods); m++) if (ah->parser_state == methods[m]) break; - if (m == ARRAY_SIZE(methods)) + if (m == LWS_ARRAY_SIZE(methods)) /* it was not any of the methods */ goto check_eol; @@ -982,7 +982,7 @@ nope: if (ah->lextable_pos < 0 && lwsi_role_h1(wsi) && lwsi_role_server(wsi)) { /* this is not a header we know about */ - for (m = 0; m < ARRAY_SIZE(methods); m++) + for (m = 0; m < LWS_ARRAY_SIZE(methods); m++) if (ah->frag_index[methods[m]]) { /* * already had the method, no idea what @@ -995,7 +995,7 @@ nope: * hm it's an unknown http method from a client in fact, * it cannot be valid http */ - if (m == ARRAY_SIZE(methods)) { + if (m == LWS_ARRAY_SIZE(methods)) { /* * are we set up to accept raw in these cases? */ @@ -1024,7 +1024,7 @@ nope: lextable[ah->lextable_pos + 1]; lwsl_parser("known hdr %d\n", n); - for (m = 0; m < ARRAY_SIZE(methods); m++) + for (m = 0; m < LWS_ARRAY_SIZE(methods); m++) if (n == methods[m] && ah->frag_index[methods[m]]) { lwsl_warn("Duplicated method\n"); @@ -1060,7 +1060,7 @@ nope: start_fragment: ah->nfrag++; excessive: - if (ah->nfrag == ARRAY_SIZE(ah->frags)) { + if (ah->nfrag == LWS_ARRAY_SIZE(ah->frags)) { lwsl_warn("More hdr frags than we can deal with\n"); return -1; } diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c index d948fa298..44b84a234 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -855,7 +855,7 @@ lws_http_get_uri_and_method(struct lws *wsi, char **puri_ptr, int *puri_len) { int n, count = 0; - for (n = 0; n < (int)ARRAY_SIZE(methods); n++) + for (n = 0; n < (int)LWS_ARRAY_SIZE(methods); n++) if (lws_hdr_total_length(wsi, methods[n])) count++; if (!count) { @@ -870,7 +870,7 @@ lws_http_get_uri_and_method(struct lws *wsi, char **puri_ptr, int *puri_len) return -1; } - for (n = 0; n < (int)ARRAY_SIZE(methods); n++) + for (n = 0; n < (int)LWS_ARRAY_SIZE(methods); n++) if (lws_hdr_total_length(wsi, methods[n])) { *puri_ptr = lws_hdr_simple_ptr(wsi, methods[n]); *puri_len = lws_hdr_total_length(wsi, methods[n]); @@ -900,7 +900,7 @@ lws_http_action(struct lws *wsi) }; meth = lws_http_get_uri_and_method(wsi, &uri_ptr, &uri_len); - if (meth < 0 || meth >= (int)ARRAY_SIZE(method_names)) + if (meth < 0 || meth >= (int)LWS_ARRAY_SIZE(method_names)) goto bail_nuke_ah; /* we insist on absolute paths */ diff --git a/lib/roles/ws/ext/extension-permessage-deflate.c b/lib/roles/ws/ext/extension-permessage-deflate.c index 3998003cc..405c23298 100644 --- a/lib/roles/ws/ext/extension-permessage-deflate.c +++ b/lib/roles/ws/ext/extension-permessage-deflate.c @@ -83,12 +83,12 @@ lws_extension_callback_pm_deflate(struct lws_context *context, if (!oa->option_name) break; lwsl_ext("%s: named option set: %s\n", __func__, oa->option_name); - for (n = 0; n < (int)ARRAY_SIZE(lws_ext_pm_deflate_options); n++) + for (n = 0; n < (int)LWS_ARRAY_SIZE(lws_ext_pm_deflate_options); n++) if (!strcmp(lws_ext_pm_deflate_options[n].name, oa->option_name)) break; - if (n == (int)ARRAY_SIZE(lws_ext_pm_deflate_options)) + if (n == (int)LWS_ARRAY_SIZE(lws_ext_pm_deflate_options)) break; oa->option_index = n; diff --git a/lib/tls/mbedtls/mbedtls-server.c b/lib/tls/mbedtls/mbedtls-server.c index 2de6d422e..f17c7e549 100644 --- a/lib/tls/mbedtls/mbedtls-server.c +++ b/lib/tls/mbedtls/mbedtls-server.c @@ -631,7 +631,7 @@ lws_tls_acme_sni_csr_create(struct lws_context *context, const char *elements[], /* subject must be formatted like "C=TW,O=warmcat,CN=myserver" */ - for (n = 0; n < (int)ARRAY_SIZE(x5); n++) { + for (n = 0; n < (int)LWS_ARRAY_SIZE(x5); n++) { if (p != subject) *p++ = ','; if (elements[n]) diff --git a/lwsws/main.c b/lwsws/main.c index 2055d774b..ecfd948b0 100644 --- a/lwsws/main.c +++ b/lwsws/main.c @@ -183,7 +183,7 @@ reload_handler(int signum) fprintf(stderr, "root process receives reload\n"); if (!do_reload) { fprintf(stderr, "passing HUP to child processes\n"); - for (m = 0; m < (int)ARRAY_SIZE(pids); m++) + for (m = 0; m < (int)LWS_ARRAY_SIZE(pids); m++) if (pids[m]) kill(pids[m], SIGHUP); sleep(1); @@ -196,7 +196,7 @@ reload_handler(int signum) fprintf(stderr, "master process waiting 2s...\n"); sleep(2); /* give children a chance to deal with the signal */ fprintf(stderr, "killing service processes\n"); - for (m = 0; m < (int)ARRAY_SIZE(pids); m++) + for (m = 0; m < (int)LWS_ARRAY_SIZE(pids); m++) if (pids[m]) kill(pids[m], SIGTERM); exit(0); @@ -254,7 +254,7 @@ int main(int argc, char **argv) break; /* old */ if (n > 0) - for (m = 0; m < (int)ARRAY_SIZE(pids); m++) + for (m = 0; m < (int)LWS_ARRAY_SIZE(pids); m++) if (!pids[m]) { // fprintf(stderr, "added child pid %d\n", n); pids[m] = n; @@ -266,7 +266,7 @@ int main(int argc, char **argv) n = waitpid(-1, &status, WNOHANG); if (n > 0) - for (m = 0; m < (int)ARRAY_SIZE(pids); m++) + for (m = 0; m < (int)LWS_ARRAY_SIZE(pids); m++) if (pids[m] == n) { // fprintf(stderr, "reaped child pid %d\n", pids[m]); pids[m] = 0; diff --git a/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c b/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c index 7fb811eee..8e9a454d6 100644 --- a/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c +++ b/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c @@ -264,7 +264,7 @@ init_protocol_minimal(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c b/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c index 54f0f1188..ae2380ce9 100644 --- a/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c +++ b/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c @@ -43,7 +43,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, /* we just dump the decoded things to the log */ - for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) { + for (n = 0; n < (int)LWS_ARRAY_SIZE(param_names); n++) { val = lws_get_urlarg_by_name(wsi, param_names[n], (char *)buf, sizeof(buf)); if (!val) diff --git a/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c b/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c index 486e9e643..d58d89202 100644 --- a/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c +++ b/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c @@ -125,7 +125,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, if (!pss->spa) { pss->spa = lws_spa_create(wsi, param_names, - ARRAY_SIZE(param_names), 1024, + LWS_ARRAY_SIZE(param_names), 1024, file_upload_cb, pss); if (!pss->spa) return -1; @@ -145,7 +145,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, /* we just dump the decoded things to the log */ - for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) { + for (n = 0; n < (int)LWS_ARRAY_SIZE(param_names); n++) { if (!lws_spa_get_string(pss->spa, n)) lwsl_user("%s: undefined\n", param_names[n]); else diff --git a/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c b/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c index 2f50863a0..d6cfc6b78 100644 --- a/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c +++ b/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c @@ -69,7 +69,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, if (!pss->spa) { pss->spa = lws_spa_create(wsi, param_names, - ARRAY_SIZE(param_names), 1024, + LWS_ARRAY_SIZE(param_names), 1024, NULL, NULL); /* no file upload */ if (!pss->spa) return -1; @@ -89,7 +89,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, /* we just dump the decoded things to the log */ - for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) { + for (n = 0; n < (int)LWS_ARRAY_SIZE(param_names); n++) { if (!lws_spa_get_string(pss->spa, n)) lwsl_user("%s: undefined\n", param_names[n]); else diff --git a/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c b/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c index cdee75c4f..31149074b 100644 --- a/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c +++ b/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c @@ -294,7 +294,7 @@ init_protocol_minimal_client_echo(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c index e4c48c101..a1bb7052f 100644 --- a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c +++ b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c @@ -304,7 +304,7 @@ init_protocol_minimal_pmd_bulk(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c index b2efc6cbe..8fba88185 100644 --- a/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c @@ -235,7 +235,7 @@ init_protocol_minimal(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c b/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c index aa3a0440e..fd108606f 100644 --- a/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c +++ b/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c @@ -243,7 +243,7 @@ init_protocol_minimal_server_echo(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c index 58fe1604b..33d4eedc1 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c +++ b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c @@ -241,7 +241,7 @@ init_protocol_minimal_pmd_bulk(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c index b9ec3305f..441951e98 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c @@ -178,7 +178,7 @@ init_protocol_minimal(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c index bd88f0295..0da2ff424 100644 --- a/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c @@ -299,7 +299,7 @@ init_protocol_minimal(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c index 121296291..ab9b88d6e 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c @@ -303,7 +303,7 @@ init_protocol_minimal(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c index 26f20c2f8..2d41257b3 100644 --- a/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c @@ -172,7 +172,7 @@ init_protocol_minimal(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugin-standalone/protocol_example_standalone.c b/plugin-standalone/protocol_example_standalone.c index 36172d43b..19a5a435e 100644 --- a/plugin-standalone/protocol_example_standalone.c +++ b/plugin-standalone/protocol_example_standalone.c @@ -138,7 +138,7 @@ init_protocol_example_standalone(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/acme-client/protocol_lws_acme_client.c b/plugins/acme-client/protocol_lws_acme_client.c index 828ef95bf..9ccd8945e 100644 --- a/plugins/acme-client/protocol_lws_acme_client.c +++ b/plugins/acme-client/protocol_lws_acme_client.c @@ -585,7 +585,7 @@ callback_acme_client(struct lws *wsi, enum lws_callback_reasons reason, memcpy(start, pvo->value, n); p += n; - for (m = 0; m < (int)ARRAY_SIZE(pvo_names); m++) + for (m = 0; m < (int)LWS_ARRAY_SIZE(pvo_names); m++) if (!strcmp(pvo->name, pvo_names[m])) vhd->pvop[m] = start; @@ -593,7 +593,7 @@ callback_acme_client(struct lws *wsi, enum lws_callback_reasons reason, } n = 0; - for (m = 0; m < (int)ARRAY_SIZE(pvo_names); m++) + for (m = 0; m < (int)LWS_ARRAY_SIZE(pvo_names); m++) if (!vhd->pvop[m] && m >= LWS_TLS_REQ_ELEMENT_COMMON_NAME) { lwsl_notice("%s: require pvo '%s'\n", __func__, pvo_names[m]); @@ -669,7 +669,7 @@ callback_acme_client(struct lws *wsi, enum lws_callback_reasons reason, if (vhd->vhost != caa->vh) return 1; - for (n = 0; n < (int)ARRAY_SIZE(vhd->pvop);n++) + for (n = 0; n < (int)LWS_ARRAY_SIZE(vhd->pvop);n++) if (caa->element_overrides[n]) vhd->pvop_active[n] = caa->element_overrides[n]; else @@ -720,19 +720,19 @@ callback_acme_client(struct lws *wsi, enum lws_callback_reasons reason, switch (ac->state) { case ACME_STATE_DIRECTORY: lejp_construct(&ac->jctx, cb_dir, vhd, jdir_tok, - ARRAY_SIZE(jdir_tok)); + LWS_ARRAY_SIZE(jdir_tok)); break; case ACME_STATE_NEW_REG: break; case ACME_STATE_NEW_AUTH: lejp_construct(&ac->jctx, cb_authz, ac, jauthz_tok, - ARRAY_SIZE(jauthz_tok)); + LWS_ARRAY_SIZE(jauthz_tok)); break; case ACME_STATE_POLLING: case ACME_STATE_ACCEPT_CHALL: lejp_construct(&ac->jctx, cb_chac, ac, jchac_tok, - ARRAY_SIZE(jchac_tok)); + LWS_ARRAY_SIZE(jchac_tok)); break; case ACME_STATE_POLLING_CSR: @@ -1598,7 +1598,7 @@ init_protocol_lws_acme_client(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/generic-sessions/protocol_generic_sessions.c b/plugins/generic-sessions/protocol_generic_sessions.c index eb2ab6759..975659daf 100644 --- a/plugins/generic-sessions/protocol_generic_sessions.c +++ b/plugins/generic-sessions/protocol_generic_sessions.c @@ -553,7 +553,7 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, a.wsi = wsi; pss->phs.vars = vars; - pss->phs.count_vars = ARRAY_SIZE(vars); + pss->phs.count_vars = LWS_ARRAY_SIZE(vars); pss->phs.replace = lwsgs_subst; pss->phs.data = &a; @@ -568,7 +568,7 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, if (!pss->spa) { pss->spa = lws_spa_create(wsi, param_names, - ARRAY_SIZE(param_names), 1024, + LWS_ARRAY_SIZE(param_names), 1024, NULL, NULL); if (!pss->spa) return -1; @@ -901,7 +901,7 @@ init_protocol_generic_sessions(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/generic-sessions/protocol_lws_messageboard.c b/plugins/generic-sessions/protocol_lws_messageboard.c index de65ad702..45ad1f5cb 100644 --- a/plugins/generic-sessions/protocol_lws_messageboard.c +++ b/plugins/generic-sessions/protocol_lws_messageboard.c @@ -294,7 +294,7 @@ callback_messageboard(struct lws *wsi, enum lws_callback_reasons reason, break; if (!pss->spa) { pss->spa = lws_spa_create(wsi, param_names, - ARRAY_SIZE(param_names), + LWS_ARRAY_SIZE(param_names), MAX_MSG_LEN + 1024, NULL, NULL); if (!pss->spa) return -1; @@ -408,7 +408,7 @@ init_protocol_lws_messageboard(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/generic-table/protocol_table_dirlisting.c b/plugins/generic-table/protocol_table_dirlisting.c index 9cbb21559..ed184f6e1 100644 --- a/plugins/generic-table/protocol_table_dirlisting.c +++ b/plugins/generic-table/protocol_table_dirlisting.c @@ -380,7 +380,7 @@ init_protocol_lws_table_dirlisting(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/protocol_client_loopback_test.c b/plugins/protocol_client_loopback_test.c index 5ec33f6f2..5ae15ddc1 100644 --- a/plugins/protocol_client_loopback_test.c +++ b/plugins/protocol_client_loopback_test.c @@ -184,7 +184,7 @@ init_protocol_client_loopback_test(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/protocol_dumb_increment.c b/plugins/protocol_dumb_increment.c index 47b293c07..7f6b5cac3 100644 --- a/plugins/protocol_dumb_increment.c +++ b/plugins/protocol_dumb_increment.c @@ -132,7 +132,7 @@ init_protocol_dumb_increment(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/protocol_esp32_lws_ota.c b/plugins/protocol_esp32_lws_ota.c index 5eeee7f41..74f249397 100644 --- a/plugins/protocol_esp32_lws_ota.c +++ b/plugins/protocol_esp32_lws_ota.c @@ -200,7 +200,7 @@ callback_esplws_ota(struct lws *wsi, enum lws_callback_reasons reason, lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT, 30); if (!pss->spa) { pss->spa = lws_spa_create(wsi, ota_param_names, - ARRAY_SIZE(ota_param_names), 4096, + LWS_ARRAY_SIZE(ota_param_names), 4096, ota_file_upload_cb, pss); if (!pss->spa) return -1; diff --git a/plugins/protocol_esp32_lws_scan.c b/plugins/protocol_esp32_lws_scan.c index 4dcc1b2ac..80ac55861 100644 --- a/plugins/protocol_esp32_lws_scan.c +++ b/plugins/protocol_esp32_lws_scan.c @@ -347,10 +347,10 @@ scan_finished(uint16_t count, wifi_ap_record_t *recs, void *v) vhd->scan_ongoing = 0; - if (count < ARRAY_SIZE(vhd->ap_records)) + if (count < LWS_ARRAY_SIZE(vhd->ap_records)) vhd->count_ap_records = count; else - vhd->count_ap_records = ARRAY_SIZE(vhd->ap_records); + vhd->count_ap_records = LWS_ARRAY_SIZE(vhd->ap_records); memcpy(vhd->ap_records, recs, vhd->count_ap_records * sizeof(*recs)); @@ -826,7 +826,7 @@ issue: lwsl_notice("si %d\n", si); - for (n = 0; n < ARRAY_SIZE(store_json); n++) { + for (n = 0; n < LWS_ARRAY_SIZE(store_json); n++) { if (esplws_simple_arg(p, sizeof(p), in, store_json[n].j)) continue; @@ -1020,7 +1020,7 @@ start_le: /* create the POST argument parser if not already existing */ if (!pss->spa) { pss->spa = lws_spa_create(wsi, param_names, - ARRAY_SIZE(param_names), 1024, + LWS_ARRAY_SIZE(param_names), 1024, file_upload_cb, pss); if (!pss->spa) return -1; @@ -1039,7 +1039,7 @@ start_le: /* call to inform no more payload data coming */ lws_spa_finalize(pss->spa); - for (n = 0; n < ARRAY_SIZE(param_names); n++) + for (n = 0; n < LWS_ARRAY_SIZE(param_names); n++) if (lws_spa_get_string(pss->spa, n)) lwsl_notice(" Param %s: %s\n", param_names[n], lws_spa_get_string(pss->spa, n)); diff --git a/plugins/protocol_lws_mirror.c b/plugins/protocol_lws_mirror.c index f6e2dd498..32340d014 100644 --- a/plugins/protocol_lws_mirror.c +++ b/plugins/protocol_lws_mirror.c @@ -482,7 +482,7 @@ init_protocol_lws_mirror(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/protocol_lws_raw_test.c b/plugins/protocol_lws_raw_test.c index abef4ca66..502a1245f 100644 --- a/plugins/protocol_lws_raw_test.c +++ b/plugins/protocol_lws_raw_test.c @@ -280,7 +280,7 @@ init_protocol_lws_raw_test(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/protocol_lws_server_status.c b/plugins/protocol_lws_server_status.c index c37f05c3f..ceef61049 100644 --- a/plugins/protocol_lws_server_status.c +++ b/plugins/protocol_lws_server_status.c @@ -224,7 +224,7 @@ init_protocol_lws_server_status(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/protocol_lws_sshd_demo.c b/plugins/protocol_lws_sshd_demo.c index bca536bb8..0143ce8f9 100644 --- a/plugins/protocol_lws_sshd_demo.c +++ b/plugins/protocol_lws_sshd_demo.c @@ -465,7 +465,7 @@ init_protocol_lws_sshd_demo(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/protocol_lws_status.c b/plugins/protocol_lws_status.c index ab91b6067..3df174886 100644 --- a/plugins/protocol_lws_status.c +++ b/plugins/protocol_lws_status.c @@ -255,7 +255,7 @@ init_protocol_lws_status(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/protocol_post_demo.c b/plugins/protocol_post_demo.c index 8b209273b..c5ad9c2d7 100644 --- a/plugins/protocol_post_demo.c +++ b/plugins/protocol_post_demo.c @@ -130,7 +130,7 @@ format_result(struct per_session_data__post_demo *pss) "

Form results (after urldecoding)

" ""); - for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) { + for (n = 0; n < (int)LWS_ARRAY_SIZE(param_names); n++) { if (!lws_spa_get_string(pss->spa, n)) p += lws_snprintf((char *)p, end - p, "
NameLengthValue
%s0" @@ -169,7 +169,7 @@ callback_post_demo(struct lws *wsi, enum lws_callback_reasons reason, /* create the POST argument parser if not already existing */ if (!pss->spa) { pss->spa = lws_spa_create(wsi, param_names, - ARRAY_SIZE(param_names), 1024, + LWS_ARRAY_SIZE(param_names), 1024, file_upload_cb, pss); if (!pss->spa) return -1; @@ -295,7 +295,7 @@ init_protocol_post_demo(struct lws_context *context, } c->protocols = protocols; - c->count_protocols = ARRAY_SIZE(protocols); + c->count_protocols = LWS_ARRAY_SIZE(protocols); c->extensions = NULL; c->count_extensions = 0; diff --git a/plugins/ssh-base/sshd.c b/plugins/ssh-base/sshd.c index e532a3688..980e4eb3d 100644 --- a/plugins/ssh-base/sshd.c +++ b/plugins/ssh-base/sshd.c @@ -2588,7 +2588,7 @@ init_protocol_lws_ssh_base(struct lws_context *context, } c->protocols = protocols_sshd; - c->count_protocols = ARRAY_SIZE(protocols_sshd); + c->count_protocols = LWS_ARRAY_SIZE(protocols_sshd); c->extensions = NULL; c->count_extensions = 0; diff --git a/test-apps/test-client.c b/test-apps/test-client.c index 690564081..d05e347e3 100644 --- a/test-apps/test-client.c +++ b/test-apps/test-client.c @@ -151,7 +151,7 @@ callback_dumb_increment(struct lws *wsi, enum lws_callback_reasons reason, wsi_mirror = NULL; } - for (n = 0; n < (int)ARRAY_SIZE(wsi_multi); n++) + for (n = 0; n < (int)LWS_ARRAY_SIZE(wsi_multi); n++) if (wsi == wsi_multi[n]) { sprintf(which_wsi, "multi %d", n); which = which_wsi; @@ -786,7 +786,7 @@ int main(int argc, char **argv) while (!force_exit) { if (do_multi) { - for (n = 0; n < (int)ARRAY_SIZE(wsi_multi); n++) { + for (n = 0; n < (int)LWS_ARRAY_SIZE(wsi_multi); n++) { if (!wsi_multi[n] && ratelimit_connects(&rl_multi[n], 2u)) { lwsl_notice("dumb %d: connecting\n", n); i.protocol = protocols[PROTOCOL_DUMB_INCREMENT].name; diff --git a/test-apps/test-lejp.c b/test-apps/test-lejp.c index b31770df7..c5fcdbc22 100644 --- a/test-apps/test-lejp.c +++ b/test-apps/test-lejp.c @@ -94,7 +94,7 @@ main(int argc, char *argv[]) lwsl_notice("libwebsockets-test-lejp (C) 2017 - 2018 andy@warmcat.com\n"); lwsl_notice(" usage: cat my.json | libwebsockets-test-lejp\n\n"); - lejp_construct(&ctx, cb, NULL, tok, ARRAY_SIZE(tok)); + lejp_construct(&ctx, cb, NULL, tok, LWS_ARRAY_SIZE(tok)); fd = 0;