Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ HEADER_FILES = $(SOURCE_FILES:.c=.h)
if ENABLE_LIBOCISPEC_INSTALL
ocispec_includedir = $(includedir)/ocispec
ocispec_include_HEADERS = $(HEADER_FILES) \
src/ocispec/json_common.h \
src/ocispec/read-file.h
src/ocispec/json_common.h
endif

src/runtime_spec_stamp: src/ocispec/json_common.h src/ocispec/json_common.c
Expand Down Expand Up @@ -151,7 +150,6 @@ $(HEADER_FILES): %.h: %.c src/ocispec/generate.py
BUILT_SOURCES = $(HEADER_FILES) $(SOURCE_FILES)

libocispec_la_SOURCES = $(BUILT_SOURCES) \
src/ocispec/read-file.c \
src/ocispec/json_common.c

TMP_H_FILES = $(HEADER_FILES:.h=.h.tmp)
Expand Down Expand Up @@ -272,7 +270,6 @@ EXTRA_DIST = autogen.sh \
src/ocispec/json_api.py \
src/ocispec/sources.py \
$(HEADER_FILES) \
src/ocispec/read-file.h \
runtime-spec \
image-spec \
src/ocispec/json_common.h \
Expand Down
6 changes: 6 additions & 0 deletions src/ocispec/json_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ def gen_free(gen):
def doc_read(data, len_expr):
return f"json_tokener_parse ({data})"

def doc_read_file(path):
return f"json_object_from_file ({path})"

def doc_read_fd(fd_expr):
return f"json_object_from_fd ({fd_expr})"

def doc_get_root(doc):
return doc

Expand Down
22 changes: 22 additions & 0 deletions src/ocispec/json_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,13 @@ gen_json_map_int_string (void *ctx, const json_map_int_string *map, const struct
stat = json_gen_string (g, numstr, strlen (numstr));
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
if (map->values[i] == NULL)
{
stat = json_gen_null (g);
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
continue;
}
stat = json_gen_string (g, map->values[i], strlen (map->values[i]));
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
Expand Down Expand Up @@ -1304,6 +1311,8 @@ gen_json_map_string_int (void *ctx, const json_map_string_int *map, const struct
GEN_SET_ERROR_AND_RETURN (stat, err);
for (i = 0; i < len; i++)
{
if (map->keys[i] == NULL)
continue;
stat = json_gen_string (g, map->keys[i], strlen (map->keys[i]));
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
Expand Down Expand Up @@ -1468,6 +1477,8 @@ gen_json_map_string_int64 (void *ctx, const json_map_string_int64 *map, const st

for (i = 0; i < len; i++)
{
if (map->keys[i] == NULL)
continue;
stat = json_gen_string (g, map->keys[i], strlen (map->keys[i]));
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
Expand Down Expand Up @@ -1607,6 +1618,8 @@ gen_json_map_string_bool (void *ctx, const json_map_string_bool *map, const stru
GEN_SET_ERROR_AND_RETURN (stat, err);
for (i = 0; i < len; i++)
{
if (map->keys[i] == NULL)
continue;
stat = json_gen_string (g, map->keys[i], strlen (map->keys[i]));
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
Expand Down Expand Up @@ -1774,9 +1787,18 @@ gen_json_map_string_string (void *ctx, const json_map_string_string *map, const

for (i = 0; i < len; i++)
{
if (map->keys[i] == NULL)
continue;
stat = json_gen_string (g, map->keys[i], strlen (map->keys[i]));
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
if (map->values[i] == NULL)
{
stat = json_gen_null (g);
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
continue;
}
stat = json_gen_string (g, map->values[i], strlen (map->values[i]));
if (json_gen_status_ok != stat)
GEN_SET_ERROR_AND_RETURN (stat, err);
Expand Down
142 changes: 0 additions & 142 deletions src/ocispec/read-file.c

This file was deleted.

27 changes: 0 additions & 27 deletions src/ocispec/read-file.h

This file was deleted.

Loading