1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
Commit graph

30 commits

Author SHA1 Message Date
Albert Ribes
c6e9792188 lejp: E implies float
Since eg, 1e-3 is a float without needing a decimal point, let's just
    generally take it that anything with the exponent token is a float, ie, 1e3
    is also a float despite it can be expressed as an integer.

    This seems right also because E is itself not valid in an integer.

    https://github.com/warmcat/libwebsockets/issues/3308
2025-01-10 14:14:49 +00:00
Andy Green
0033accb83 lejp-conf: provide matches for block start paths
Also valgrind shows we should zero down the lejp context to avoid problems
with the wildcard stack
2022-02-11 08:43:16 +00:00
Andy Green
ad990a61a0 ss: policy: unwind after policy syntax errors cleanly 2021-10-05 07:40:17 +01:00
Andy Green
dcaa0013b4 lecp: add CBOR stream parser LECP like JSON LEJP
This provides very memory-efficient CBOR stream parsing
and writing.

The parser  converts pieces of CBOR into callbacks that define
the structure and collate string and blobs into buffer chunks
for extensible and easy access.

It is fragementation-safe and does not need all the CBOR in
the same place at one time, chunks of CBOR are parsed and
discarded as provided.

It does not allocate and just needs a few hundred bytes of
stack for even huge CBOR objects.  Huge strings and blobs
are handled without needing memory to hold them atomically.

Includes ./minimal-examples/api-tests/api-test-lecp that
unit tests it against 82 official example CBORs and
26 additional test vectors from COSE (just checking the CBOR
parsing).

The writing apis allow printf style semantics with a variety
of CBOR-aware %-formats.  The apis write into a context that
manages output buffer usage, if the output buffer fills,
then the apis return with an AGAIN code that lets you issue
and reset the output buffer and repeat the api all to issue
more output.  The subsequent calls can occur much later or
from a different function context, so this is perfect for
WRITEABLE-mediated output from the network parts of lws.

See ./READMEs/README.cbor-lecp.md
2021-08-21 17:44:40 +01:00
Andy Green
c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
Andy Green
b2898b5bfc lejp: allow for no cb on unprepared lejp on destroy
On an error path, we might not have a valid spa / lejp to destroy.
In that case, don't hurl ourselves into calling a
function pointer that can be NULL for the destroy cb.
2021-01-04 05:40:12 +00:00
Andy Green
5c7b5af92a cmake: disable export visibility when building lws static
This is complicated by the fact extern on a function declaration implies
visibility... we have to make LWS_EXTERN empty when building static.

And, setting target_compile_definitions() doesn't work inside macros,
so it has to be set explicitly for the plugins.

Checking the symbol status needs nm -C -D as per

https://stackoverflow.com/questions/37934388/symbol-visibility-not-working-as-expected

after this patch, libwebsockets.a shows no symbols when checked like that and
the static-linked minimal examples only show -U for their other dynamic
imports.

In a handful of cases we use LWS_EXTERN on extern data declarations,
those then need to change to explicit extern.
2020-09-06 11:46:25 +01:00
dev31337
81bff78c86 lejp: enable negative integers
https://github.com/warmcat/libwebsockets/issues/1957
2020-06-22 08:14:56 +01:00
Andy Green
080d1fc2ba lejp: add api test suite and support empty object
Adds api-test-lejp to the CI where LEJP enabled.

Supports empty objects like

  { "a": 123, "b": { } }
2020-06-02 08:37:10 +01:00
Andy Green
e4a9307b11 lejp: support outer element is array 2020-05-11 21:20:29 +01:00
Andy Green
af26f0c765 lejp: correct return temp type to int
lejp_parse() return type is an int... but in the function, the temp
for it is a char.  This leads to badness that is currently worked
around by casting the return through a signed char type.

But that leads to more badness since if there's >127 bytes of buffer
left after the end of the JSON object, we misreport it.

Bite the bullet and fix the temp type, and fix up all the guys
who were working around it at the caller return casting to use the
resulting straight int.

If you are using this api, remove any casting you may have cut-
and-pasted like this

n = (int)(signed char)lejp_parse(...);

... to just be like this...

n = lejp_parse(...);
2020-05-11 15:17:14 +01:00
Andy Green
63c8a23776 lws_spawn: windows
Move the unix spawn.c from lib/misc through to lib/plat/unix, and
add an implementation for windows in lib/plat/windows
2020-04-13 19:29:09 +01:00
Kristján Valur Jónsson
1b51301c8d lejp: fix warnings on windows 2019-10-23 06:36:11 +01:00
Andy Green
d7f0521aeb private.h: rename to contain dir
Having unique private header names is a requirement of a particular
platform build system it's desirable to work with
2019-08-15 10:49:52 +01:00
Andy Green
26319663f7 license: switch LGPLv2.1+SLE parts to MIT 2019-08-14 10:44:38 +01:00
Andy Green
8f06b6fbad lejp: allow up to 20 digit decimal numbers
https://github.com/warmcat/libwebsockets/issues/1559
2019-05-02 09:28:45 +01:00
Andy Green
0405c0c878 lejp: make sure child object close is not mistaken for parent 2019-05-02 09:28:38 +01:00
Andy Green
38fb0e31da lws_struct
lws_struct JSON + sqlite3 serializer and deserializer


See READMEs/README.lws_struct.md
2019-04-06 06:08:47 +08:00
Andy Green
6a88483f02 lejp: integrate error strings and api to core lejp
lejp-conf isn't the only user that needs to generate human-readable
JSON parsing error stacks.

Build it in with lejp and introduce an error code -> string api
2019-03-12 11:57:43 +08:00
Andy Green
eda102e397 jwe 2018-12-27 06:45:32 +08:00
Andy Green
253942ca80 clean: solve type conversion warnings for appveyor 2018-09-11 18:27:59 +08:00
Andy Green
d461f46a97 libwebsockets.h: clean out some boilerplate better put in core/private.h
https://github.com/warmcat/libwebsockets/issues/1370
2018-08-16 19:10:32 +08:00
Andy Green
94e375f552 lejp: improve bogus JSON underrun detection
https://github.com/warmcat/libwebsockets/issues/1357
2018-08-14 08:00:30 +08:00
Andy Green
2e4ac9defe lejp: fix float
https://libwebsockets.org/pipermail/libwebsockets/2018-January/003599.html
2018-01-04 10:28:06 +08:00
Andy Green
2b30c82b9e lejp: dont underflow with anonymous braces 2017-11-26 19:17:11 +08:00
Andy Green
a76e9aad11 lejp: handle empty arrays 2017-11-26 19:17:11 +08:00
Andy Green
5a90bb36d1 lejp: add test app to parse stdin 2017-10-26 18:55:12 +08:00
Andy Green
f9421f084b lejp: integrate header into libwebsockets.h 2017-10-26 18:55:11 +08:00
Andy Green
5a0b5299d2 lejp: use explicit signed char return 2017-10-25 07:54:18 +08:00
Andy Green
c83afc66e6 refactor: subdirs for source in lib
Split out some optional code into own sources to
shrink down libwebsockets.c and server.c a bit
2017-10-16 17:28:37 +08:00
Renamed from lib/lejp.c (Browse further)