Skip to content

Commit

Permalink
Merge pull request #147 from saschagrunert/yajl-refs
Browse files Browse the repository at this point in the history
Cleanup references to yajl
  • Loading branch information
saschagrunert authored Nov 28, 2024
2 parents 19192a0 + 622247e commit e9f0fb4
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 43 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ jobs:
distro: ubuntu_latest
steps:
- uses: actions/[email protected]
with:
submodules: true
set-safe-directory: true

- uses: uraimo/[email protected]
name: Build
Expand All @@ -33,9 +30,6 @@ jobs:

githubToken: ${{ github.token }}

setup: |
git submodule update --init --recursive
install: |
apt-get update -q -y
apt-get install -q -y python3 automake libtool autotools-dev git make cmake pkg-config gcc wget xz-utils libjansson-dev
Expand Down
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ COPY . libocispec
RUN cd libocispec && \
./autogen.sh && \
./configure CFLAGS='-Wall -Wextra -Werror' && \
make -j $(nproc) distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-embedded-yajl" AM_DISTCHECK_DVI_TARGET="" TESTS="" && \
make clean
make -j $(nproc) distcheck AM_DISTCHECK_DVI_TARGET="" TESTS="" && \
make clean
2 changes: 1 addition & 1 deletion ocispec.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ includedir=@includedir@

Name: @PACKAGE_NAME@
Description: A library for easily parsing [OCI runtime](https://github.com/opencontainers/runtime-spec) and [OCI image](https://github.com/opencontainers/image-spec) files.
Requires: yajl jansson
Requires: jansson
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -locispec
Cflags: -I${includedir}/ocispec
5 changes: 1 addition & 4 deletions src/ocispec/json_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include <limits.h>
#include "ocispec/json_common.h"

#define YAJL_GET_OBJECT_NO_CHECK(v) (&(v)->u.object)
#define YAJL_GET_STRING_NO_CHECK(v) ((v)->u.string)

#define MAX_NUM_STR_LEN 21

char *
Expand Down Expand Up @@ -893,4 +890,4 @@ json_t *copy_unmatched_fields(json_t *src, const char **exclude_keys, size_t num
}

return dst;
}
}
30 changes: 0 additions & 30 deletions src/ocispec/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,34 +131,6 @@ def parse_obj_type_array(obj, c_file, prefix, obj_typename):
c_file.append(' }\n')
c_file.append(' }\n')
c_file.append(' while (0);\n')
elif obj.subtyp == 'byte':
c_file.append(' do\n')
c_file.append(' {\n')
c_file.append(f' yajl_val tmp = get_val (tree, "{obj.origname}", yajl_t_string);\n')
c_file.append(' if (tmp != NULL)\n')
c_file.append(' {\n')
if obj.doublearray:
c_file.append(' yajl_val *items = YAJL_GET_ARRAY_NO_CHECK(tmp)->values;\n')
c_file.append(f' ret->{obj.fixname} = calloc ( YAJL_GET_ARRAY_NO_CHECK(tmp)->len + 1, sizeof (*ret->{obj.fixname}));\n')
c_file.append(f' if (ret->{obj.fixname}[i] == NULL)\n')
c_file.append(' return NULL;\n')
c_file.append(' size_t j;\n')
c_file.append(' for (j = 0; j < YAJL_GET_ARRAY_NO_CHECK(tmp)->len; j++)\n')
c_file.append(' {\n')
c_file.append(' char *str = YAJL_GET_STRING (itmes[j]);\n')
c_file.append(f' ret->{obj.fixname}[j] = (uint8_t *)strdup (str ? str : "");\n')
c_file.append(f' if (ret->{obj.fixname}[j] == NULL)\n')
c_file.append(" return NULL;\n")
c_file.append(' };\n')
else:
c_file.append(' char *str = YAJL_GET_STRING (tmp);\n')
c_file.append(f' ret->{obj.fixname} = (uint8_t *)strdup (str ? str : "");\n')
c_file.append(f' if (ret->{obj.fixname} == NULL)\n')
c_file.append(' return NULL;\n')
c_file.append(f' ret->{obj.fixname}_len = str != NULL ? strlen (str) : 0;\n')
c_file.append(' }\n')
c_file.append(' }\n')
c_file.append(' while (0);\n')
else:
c_file.append(' do\n')
c_file.append(' {\n')
Expand Down Expand Up @@ -682,8 +654,6 @@ def read_val_generator(c_file, level, src, dest, typ, keyname, obj_typename):
c_file.append(f'{" " * (level + 1)}sinvalid = json_double_to_{num_type} (json_number_value(val), {dest});\n')
c_file.append(f"{' ' * (level + 1)}if (invalid)\n")
c_file.append(f'{" " * (level + 1)} {{\n')
c_file.append(f'{" " * (level + 1)} if (asprintf (err, "Invalid value \'%s\' with type \'{typ}\' ' \
f'for key \'{keyname}\': %s", YAJL_GET_NUMBER (val), strerror (-invalid)) < 0)\n')
c_file.append(f'{" " * (level + 1)} *err = strdup ("error allocating memory");\n')
c_file.append(f"{' ' * (level + 1)} return NULL;\n")
c_file.append(f'{" " * (level + 1)}}}\n')
Expand Down

0 comments on commit e9f0fb4

Please sign in to comment.