Commit Graph
157 Commits
Author SHA1 Message Date
Bertrand Roussel 70f58e8b8a Fix LICENSE
Updating LICENSE file so project can be recognized as MIT in
GitHub.

Signed-off-by: Bertrand Roussel <broussel@sierrawireless.com>
2017-07-26 10:29:17 -07:00
Thiago Macieira 25ea8aff91 Hide the API using FILE* from freestanding C implementations
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-06-09 12:49:45 -07:00
Thiago Macieira 60f164ffad Add a README file.
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-30 17:55:29 -07:00
Thiago Macieira bfbd4de1a0 Makefile.nmake: add missing .obj files to the lib sources
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-13 23:58:02 -07:00
Fabrice Fontaine ae608ea273 Fix static compilation of json2cbor
json2cbor depends on cjson so tools/json2cbor/json2cbor.o must be
before -lcjson

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2017-03-06 20:40:35 +01:00
Thiago Macieira 5f0078c264 Update version number for future (possible) v0.4.2
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-06 08:27:38 +01:00
alradmsft acf202a381 Fix stack corruption due to calling convention mismatch
Standard library implementations may specify calling convention for memcpy
explicitly. However, the cbor* APIs don't do that. If you compile the lib
with default calling convention that doesn't match the calling convention o
memcpy(), the iterate_string_chunks() will not setup the stack for memcpy()
call correctly resulting in a stack corruption. The compiler doesn't catch
this issue because of the cast that is being applied when passing memcpy()
to the iterate_string_chunks().

The fix is to wrap memcpy() in a function that conforms to the declaration o
the IterateFunction which does two things, removes the need for a cast and
uncouples memcpy() calling convention from the rest of the cbor* APIs.

Signed-off-by: Alex Radutskiy (alex.radutskiy@microsoft.com)
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
v0.4.1
2017-03-06 08:12:35 +01:00
Thiago Macieira 726b786fba Update .travis.yml to refer to Qt 5.6.2
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-05 10:36:46 +01:00
Thiago Macieira e136febe76 Don't cast an actual string literal to uint8_t*
This removes an ugly cast from the source and an unnecessary 1-byte
variable from the .rodata section.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-05 00:25:16 -06:00
Philippe Coval 3e23929f59 Support C99 standards (enums, assert)
Fix various errors when -Werror=pedantic flag is enabled:

Cast enum values to int to prevent errors like:
   deps/tinycbor/src/cborconstants_p.h:47:31:\
   error: ISO C restricts enumerator values to range of ‘int’\
   [-Werror=pedantic]
   MajorTypeMask           = ~0U << MajorTypeShift,

"error: ISO C99 does not support" ‘Static_assert’

This effort is needed for RIOT port of iotivity-contrained

Bug-RIOT: https://github.com/RIOT-OS/RIOT/issues/6241
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-26 12:43:55 -08:00
Fabrice Fontaine 8ba8e2030e Update cjson include path
Since cjson-v1.0.0 (https://github.com/DaveGamble/cJSON/releases),
cJSON.h is installed into cjson/cJSON.h and library has been renamed
from cJSON to cjson

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-18 15:47:32 -08:00
Thiago Macieira c2242c5b36 Stop setting TINYCBOR_VERSION in the build
For TinyCBOR 0.5, I'd like to make it numeric. Anyway, nothing was using
this.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-30 12:56:20 -08:00
Thiago Macieira 80d76e79b8 Fix build in shadow builds: need to mkdir bin and lib
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-30 12:53:45 -08:00
Thiago Macieira 2921240965 Create a Perl script that properly creates tags
The previous part of the Makefile didn't work properly. Instead of using
the contents of the VERSION file, it updated the file right before the
tagging and always for the next minor release.

Instead, move everything to a Perl script that updates the VERSION file
only after the tagging and sets up for a patch release (which are more
frequent). Updating of the dev branch is left as an exercise for the
reader.

As a bonus, this will work on Windows too without Unix shell tools.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-11 10:07:18 +08:00
Thiago Macieira e248db96ab Update version number for the next patch release
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-10 11:34:37 +08:00
Thiago Macieira a088996aa5 Update "make release" target
This commit allos the use of the VERSION variable to set the version to
be tagged, instead of just incrementing the last digit in the VERSION
file.

It stops creating the .zip and .tar.gz files since those are kept in
GitHub anyway.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
v0.4
2016-11-02 22:00:07 -07:00
Thiago Macieira 8fc4528745 Merge branch 'master' into dev
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-02 21:30:10 -07:00
Thiago Macieira 0a78b71322 Fix forgotten update of the number of characters left in dumping UTF-8
We forgot to update the counter variable. This fixes #54.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-02 21:14:18 -07:00
James Prestwood eed8aa4b6c Fixed duplicate definitions for targets with certain macros already defined
Signed-off-by: James Prestwood <james.prestwood@intel.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-02 20:52:29 -07:00
Thiago Macieira 863a480dc4 Fix #51: correct OOM reporting in cbor_encoder_create_{array,map}
If the OOM condition happened on the encoding of the type and item
count, those two functions failed to return an error indicating that
there was an OOM. We had a unit test for this, but due to an off-by-one
error, we never actually tested the condition and just reported a false
positive.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-26 20:48:54 -07:00
alradmsft 9ba4791ad5 Supress data loss warnings in VS2015
Where safe, use explicit casts to supress data loss warnings in VS2015
compiler.

This fixes #45.

Signed-off-by: Alex Radutskiy (alex.radutskiy@microsoft.com)
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-20 07:30:56 -07:00
Fabrice Fontaine ad09b6af11 Fix detection of system-cjson
Replace CCLFAGS-system-cjson by CCFLAGS-system-cjson

Fixes:
  - http://autobuild.buildroot.net/results/8fc/8fc7365e0dc777edc57e950a84df7fddc13c6776

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-11 16:17:18 +02:00
Thiago Macieira 0171135ec3 Merge branch 'master' into dev
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-11 09:37:26 +02:00
Thiago Macieira 7f554dd5b1 Update .gitignore files
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-07 15:13:31 +02:00
Thiago Macieira 806f0c99b0 cbor.h: Add explicit casts to conversions from uint64_t to size_t
User code might have stronger warning settings than the ones we've used
so far. The explict casting will make the compiler not complain, as it
was clearly intentional.

This fixes #45.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-07 15:10:18 +02:00
Thiago Macieira a27578f7bc Merge branch 'master' into dev
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-03 20:52:21 +02:00
David Antler a50c0122f2 Update VERSION file
Signed-off-by: David Antler <david.a.antler@intel.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-03 20:52:02 +02:00
Thiago Macieira 075562fe4a Merge branch 'master' into dev 2016-08-31 12:25:11 -07:00
Fabrice Fontaine 04ada5890c Properly manage open_memstream availability
- Update Makefile.configure to test the availability of fopencookie
- If open_memstream is not available on the system AND funopen or fopencookie are available, compile our own version of open_memstream
- If open_memstream can not be compiled, return a new error (CborErrorJsonNotImplemented)

fixes #42

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-31 10:39:48 -07:00
Thiago Macieira 930b265d36 Merge branch 'master' into dev
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-04 14:39:05 -07:00
Thiago Macieira 86c8186775 Properly fix support for stdint.h on Arduino
There are at least two fixes in the codebase already due to macros that
should have come from stdint.h not being defined. I was blaming the
libc, as stdint.h is a C99 header and C99 requires those macros.

Turns out that the Arduino toolchain compiles everything as C++ and
officially C++98 does not have stdint.h, so "anything goes". The Arduino
docs recommend #define'ing __STDC_LIMIT_MACROS to get those macros.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-04 14:28:01 -07:00
Thiago Macieira fb10a783cd Update .gitignore
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-04 14:25:32 -07:00
Thiago Macieira ede7f1431a Revert "Revert "Give a name to unnamed union in CborEncoder""
This reverts commit 4628a110b7 and thus
brings 0e1440ab92 back.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-30 23:09:56 -07:00
Thomas Petazzoni 31c7f81d45 Makefile: use installation logic compatible with old make version
The installation logic used by the Makefile causes a problem with old
make versions, such as make 3.81. Indeed, the rule "$(DESTDIR)%/" gets
matched even for targets like "$(DESTDIR)$(libdir)/libtinycbor.a". Due
to this, with those old make versions, tinycbor.a is installed as a
directory, and the library is never copied:

make[1]: Entering directory `/home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/build/tinycbor-v0.3.1'
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/bin/cbordump
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/lib/libtinycbor.a
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/lib/pkgconfig/tinycbor.pc
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/include/tinycbor/cbor.h
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/include/tinycbor/cborjson.h
make[1]: Leaving directory `/home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/build/tinycbor-v0.3.1'

To address this, we create the destination directory directly within
the per-file make targets.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
v0.3.2
2016-07-30 23:07:32 -07:00
Thiago Macieira 1735f9cb7c Fix "make distcheck" when TMPDIR isn't set
Otherwise, we get this:
 GIT_DIR=./.git git archive --prefix=tinycbor-distcheck/ --format=tar HEAD | tar -xf - -C $TMPDIR
 tar: option requires an argument -- 'C'

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-30 23:07:32 -07:00
Thiago Macieira 4628a110b7 Revert "Give a name to unnamed union in CborEncoder"
This breaks the build in two circumstances:
 a) tools/json2cbor wasn't included in the change
 b) some old code accessed the ptr member before
    cbor_encoder_get_buffer_size and cbor_encoder_get_extra_bytes_needed

This reverts commit 0e1440ab92. I will
re-apply it in the master branch and fix the missing code.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-30 23:04:46 -07:00
Fabrice Fontaine 0e1440ab92 Give a name to unnamed union in CborEncoder
cbor.h contains an unnamed union in CborEncoder structure, this functionality is
not always supported by all compilers, especially it seems that the Blackfin
build on buildroot fails (with gcc 4.3). This patch names this union "data".

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-30 12:26:04 -07:00
Thiago Macieira 481ec6e8a9 Use printf instead of echo -e in Makefile.configure
echo -e is not POSIX-compliant, but printf is supposed to interpret
escaped sequences like \n.

Fixes: #34
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
v0.3.1
2016-07-22 08:51:40 -07:00
Fabrice Fontaine c88913e53c Fix compilation error due to file descriptor
In Makefile, the file descriptor 10 is used to redirect input to .config:
$(MAKE) -f $(SRCDIR)Makefile.configure OUT='>&10' configure 10> $@

This patch replaces this file descriptor from to 10 to 9 as
"Redirections using file descriptors greater than 9 should be used with
care, as they may conflict with file descriptors the shell uses
internally."
(cf. https://www.gnu.org/software/bash/manual/html_node/Redirections.html)

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-21 08:35:18 -07:00
Thiago Macieira f775cf5b9d Merge branch 'master' into dev v0.3 2016-07-11 08:46:05 -07:00
Otavio Pontes e73e4d87be Add missing dependencies to cbordump build
Compilation was failing when trying to compile cbordump running make in
tools directory. Add missing dependencies, cbortojson and
cborparser_dup_string to cbordump Makefile.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-11 08:45:15 -07:00
Thiago Macieira f2acf3cf40 Update .travis.yml to match new PPA repositories
After the Qt 5.6.1 release, Stephan renamed the repository.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 11:01:23 -07:00
Thiago Macieira b590a2be69 Merge branch 'master' into HEAD
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 10:05:48 -07:00
Otavio Pontes e2d5dd563e Fix _BSD_SOURCE is deprecated warning
In systems with glibc >= 2.2 _BSD_SOURCE is deprecated. In order to use
it and to keep compatibility with older systems _DEFAULT_SOURCE should
  also be defined when _BSD_SOURCE is defined, according to
feature_test_macros man page
(http://man7.org/linux/man-pages/man7/feature_test_macros.7.html)

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 09:55:15 -07:00
Otavio Pontes 225304ddf8 Add tinycbor.pc to .gitignore
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 09:55:15 -07:00
Otavio Pontes 4ce56694ed Remove from cborparser.c file the dependency on stdlib header
Function _cbor_value_dup_string from cborparser.c is using malloc/free
functions, from sdtlib header, so it is not possible to compile the
cborparser in systems without stdlib support. Move this function to a
different c file in order to remove the dependency on stdlib header from
cborparser.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 09:55:15 -07:00
Thiago Macieira 0f02e793b8 Parsing: implement the missing cbor_value_get_int{,64}_checked functions
The int64_t version is easier because the C99 & C11 standards require
that int64_t use two's complement representation. We're unlikely to find
an architecture that supports two's complement 64-bit but doesn't
support it for int, but the code is written to be strictly conforming.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-07 20:40:13 -07:00
Thiago Macieira eabee060e3 CborValue: fix mis-named cbor_value_is_{null,undefined}
The cbor_type_is_ prefix is an old iteration of the API. Apparently I
never tested the "is" functions.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-07 20:40:13 -07:00
Thiago Macieira cac5db5a60 CborValue: add missing convenience FP cbor_value_is_xxxx functions
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-07 20:40:13 -07:00
Thiago Macieira 740e29d225 Parsing: Add cbor_value_get_next_byte()
Replaces direct access to the "ptr" member.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-07 20:40:13 -07:00