Skip to content

Commit

Permalink
Merge branch 'dev' into dup_encode
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Lundblade committed Mar 3, 2024
2 parents 3dc2ccb + 3f34e5a commit 5e64f71
Show file tree
Hide file tree
Showing 18 changed files with 2,259 additions and 704 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI

on: [push, pull_request]

# Fan out for the two compilers
# Fan out disabling on feature at a time -- too slow to do the full combo fan out
jobs:
main:
strategy:
fail-fast: false
matrix:
c-compiler: [gcc, clang]

config:
- os-image: ubuntu-latest
container: ubuntu:22.04

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DQCBOR_DISABLE_TAGS'

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DUSEFULBUF_DISABLE_ALL_FLOAT'

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DQCBOR_DISABLE_FLOAT_HW_USE'

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DQCBOR_DISABLE_PREFERRED_FLOAT'

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DQCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA'

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DQCBOR_DISABLE_ENCODE_USAGE_GUARDS'

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DQCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS'

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DQCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS'

- os-image: ubuntu-latest
container: ubuntu:22.04
dis-xxx: '-DQCBOR_DISABLE_UNCOMMON_TAGS'


name: ${{ matrix.config.dis-xxx }} • ${{ matrix.c-compiler }} • ${{ matrix.config.container }}

runs-on: ${{ matrix.config.os-image }}
container: ${{ matrix.config.container }}

steps:
- uses: actions/checkout@v3

- name: Install build tools
run: |
set -ex
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y build-essential cmake ${{ matrix.c-compiler }}
echo "CC=${{ matrix.c-compiler }}" >> $GITHUB_ENV

- name: Build QCBOR
run: |
set -ex
make warn CMD_LINE=${{ matrix.config.dis-xxx }}
- name: Run tests
run: ./qcbortest
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions QCBOR.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
E78C91DF240C90C100F4CECE /* qcbor_common.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; name = qcbor_common.h; path = inc/qcbor/qcbor_common.h; sourceTree = "<group>"; tabWidth = 3; };
E78C91E0240C90C100F4CECE /* qcbor_private.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; name = qcbor_private.h; path = inc/qcbor/qcbor_private.h; sourceTree = "<group>"; tabWidth = 3; };
E78C91E1240C90C100F4CECE /* qcbor_encode.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; name = qcbor_encode.h; path = inc/qcbor/qcbor_encode.h; sourceTree = "<group>"; tabWidth = 3; };
E7A7B60E2B76FB62009102C2 /* Serialization.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = Serialization.md; path = doc/Serialization.md; sourceTree = "<group>"; };
E7C960B72800A09E00FB537C /* ub-example.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ub-example.h"; sourceTree = "<group>"; };
E7C960B82800A09E00FB537C /* ub-example.c */ = {isa = PBXFileReference; indentWidth = 3; lastKnownFileType = sourcecode.c.c; path = "ub-example.c"; sourceTree = "<group>"; tabWidth = 3; };
E7FDBF16256C969D007138A8 /* QCBOR_Disable_Indef */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = QCBOR_Disable_Indef; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -246,6 +247,7 @@
children = (
E776E161214EE19C00E67947 /* README.md */,
E743D132251014E60017899F /* Tagging.md */,
E7A7B60E2B76FB62009102C2 /* Serialization.md */,
E776E096214AE0C700E67947 /* cmd_line_main.c */,
E776E092214AE07C00E67947 /* inc */,
E776E08B214AE06600E67947 /* src */,
Expand Down
8 changes: 8 additions & 0 deletions doc/Serialization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@file Serialization.md

@anchor Serialization

# Serialization and Determinism

To be filled in...

26 changes: 20 additions & 6 deletions inc/qcbor/qcbor_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ==========================================================================
* Copyright (c) 2016-2018, The Linux Foundation.
* Copyright (c) 2018-2023, Laurence Lundblade.
* Copyright (c) 2018-2024, Laurence Lundblade.
* Copyright (c) 2021, Arm Limited.
* All rights reserved.
*
Expand Down Expand Up @@ -44,6 +44,7 @@ extern "C" {
#endif



/**
* @file qcbor_common.h
*
Expand Down Expand Up @@ -392,9 +393,9 @@ typedef enum {
* decoding possible.*/
QCBOR_ERR_NO_STRING_ALLOCATOR = 45,

/** Error allocating space for a string, usually for an
* indefinite-length string. This error makes no further decoding
* possible. */
/** Error allocating memory for a string, usually out of memory.
* This primarily occurs decoding indefinite-length strings. This
* error makes no further decoding possible. */
QCBOR_ERR_STRING_ALLOCATE = 46,

/** During decoding, the type of the label for a map entry is not
Expand All @@ -407,7 +408,7 @@ typedef enum {
* this error is returned. This error is unrecoverable because the
* built-in tag decoding doesn't try to consume the unexpected
* type. In previous versions of QCBOR this was considered a
* recoverable error hence @ref QCBOR_ERR_BAD_TAG_CONTENT. Going
* recoverable error hence QCBOR_ERR_BAD_TAG_CONTENT. Going
* back further, RFC 7049 use the name "optional tags". That name
* is no longer used because "optional" was causing confusion. See
* also @ref QCBOR_ERR_RECOVERABLE_BAD_TAG_CONTENT. */
Expand Down Expand Up @@ -521,7 +522,20 @@ typedef enum {
* whole tag contents when it is not the correct tag content, this
* error can be returned. None of the built-in tag decoders do this
* (to save object code). */
QCBOR_ERR_RECOVERABLE_BAD_TAG_CONTENT = 78
QCBOR_ERR_RECOVERABLE_BAD_TAG_CONTENT = 78,

/** Attempt to output non-preferred, non-CDE or non-dCBOR when not
* allowed by mode. See QCBOREncode_SerializationPreferred(),
* QCBOREncode_SerializationCDE(),
* QCBOREncode_SerializationdCBOR().
*/
QCBOR_ERR_NOT_PREFERRED = 79,

/* Trying to encode something that is discouraged (e.g., 65-bit
* negative integer) without allowing it by calling
* QCBOREncode_Allow() */
QCBOR_ERR_NOT_ALLOWED = 80


/* This is stored in uint8_t; never add values > 255 */
} QCBORError;
Expand Down
54 changes: 41 additions & 13 deletions inc/qcbor/qcbor_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,42 +211,59 @@ typedef enum {
/* Do not renumber these. Code depends on some of these values. */
/** The data type is unknown, unset or invalid. */
#define QCBOR_TYPE_NONE 0

/** Never used in QCBORItem. Used by functions that match QCBOR types. */
#define QCBOR_TYPE_ANY 1

/** Type for an integer that decoded either between @c INT64_MIN and
* @c INT32_MIN or @c INT32_MAX and @c INT64_MAX. Data is in member
* @c val.int64. */
#define QCBOR_TYPE_INT64 2

/** Type for an integer that decoded to a more than @c INT64_MAX and
* @c UINT64_MAX. Data is in member @c val.uint64. */
#define QCBOR_TYPE_UINT64 3

/** Type for an array. See comments on @c val.uCount. */
#define QCBOR_TYPE_ARRAY 4

/** Type for a map. See comments on @c val.uCount. */
#define QCBOR_TYPE_MAP 5

/** Type for a buffer full of bytes. Data is in @c val.string. */
#define QCBOR_TYPE_BYTE_STRING 6

/** Type for a UTF-8 string. It is not NULL-terminated. See
* QCBOREncode_AddText() for a discussion of line endings in CBOR. Data
* is in @c val.string. */
#define QCBOR_TYPE_TEXT_STRING 7

/** Type for a positive big number. Data is in @c val.bignum, a
* pointer and a length. */
#define QCBOR_TYPE_POSBIGNUM 9

/** Type for a negative big number. Data is in @c val.bignum, a
* pointer and a length. */
#define QCBOR_TYPE_NEGBIGNUM 10

/** Type for [RFC 3339] (https://tools.ietf.org/html/rfc3339) date
* string, possibly with time zone. Data is in @c val.string . Note this
* was previously in @c val.dateString, however this is the same as
* val.string being the same type in same union. */
* val.string being the same type in same union. val.dateString will
* be deprecated.. */
#define QCBOR_TYPE_DATE_STRING 11

/** Type for integer seconds since Jan 1970 + floating-point
* fraction. Data is in @c val.epochDate */
#define QCBOR_TYPE_DATE_EPOCH 12
/** A simple type that this CBOR implementation doesn't know about;
* Type is in @c val.uSimple. */

/** The CBOR major type "simple" has a small integer value indicating
* what it is. The standard CBOR simples are true, false, null, undef
* (values 20-23) and float-point numbers (values 25-27). The values
* 0-19 and 32-255 are unassigned and may be used if registered with
* in the IANA Simple Values Registry. If these unassigned simple
* values occur in the input they will be decoded as this. The value
* is in @c val.uSimple. */
#define QCBOR_TYPE_UKNOWN_SIMPLE 13

/** A decimal fraction made of decimal exponent and integer mantissa.
Expand Down Expand Up @@ -278,19 +295,34 @@ typedef enum {
* QCBOREncode_AddBigFloatBigNum(). */
#define QCBOR_TYPE_BIGFLOAT_NEG_BIGNUM 19

/** Type for the value false. */
/** Type for the simple value false. */
#define QCBOR_TYPE_FALSE 20
/** Type for the value true. */

/** Type for the simple value true. */
#define QCBOR_TYPE_TRUE 21
/** Type for the value null. */

/** Type for the simple value null. */
#define QCBOR_TYPE_NULL 22
/** Type for the value undef. */

/** Type for the simple value undef. */
#define QCBOR_TYPE_UNDEF 23

/** Type for a floating-point number. Data is in @c val.float. */
#define QCBOR_TYPE_FLOAT 26

/** Type for a double floating-point number. Data is in @c val.double. */
#define QCBOR_TYPE_DOUBLE 27

/** Special type for integers between -2^63 - 1 to -2^64 that
* can't be returned as @ref QCBOR_TYPE_INT64 because they don't fit
* in an int64_t. The value is returned in @c val.uint64, but this
* isn't the number transmitted. Do this arithmatic (carefully to
* avoid over/underflow) to get the value transmitted: - val.uint64 - 1.
* See QCBOREncode_AddNegativeUInt64() for a longer explanation
* and warning. */
#define QCBOR_TYPE_65BIT_NEG_INT 28


#define QCBOR_TYPE_BREAK 31 /* Used internally; never returned */

/** For @ref QCBOR_DECODE_MODE_MAP_AS_ARRAY decode mode, a map that is
Expand Down Expand Up @@ -439,14 +471,10 @@ typedef struct _QCBORItem {
* number of days before or after Jan 1, 1970. */
int64_t epochDays;

/** No longer used. Was the value for @ref QCBOR_TYPE_DATE_STRING,
* but now that value is in @c string. TODO: finish writing this.*/
UsefulBufC dateString;

/** The value for @c uDataType @ref QCBOR_TYPE_POSBIGNUM and
@ref QCBOR_TYPE_NEGBIGNUM. TODO: change to string*/
* @ref QCBOR_TYPE_NEGBIGNUM. */
UsefulBufC bigNum;
/** The integer value for unknown simple types. TODO: doc this better. */
/** See @ref QCBOR_TYPE_UKNOWN_SIMPLE */
uint8_t uSimple;
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
/**
Expand Down
Loading

0 comments on commit 5e64f71

Please sign in to comment.