mirror of https://git.wownero.com/dsc/mxe.git
add liblaxjson package
This commit is contained in:
parent
d9eb88bab4
commit
f1424bf326
|
@ -1725,6 +1725,10 @@ local-pkg-list: $(LOCAL_PKG_LIST)</pre>
|
|||
<td class="package">libircclient</td>
|
||||
<td class="website"><a href="http://sourceforge.net/projects/libircclient/">libircclient</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="package">liblaxjson</td>
|
||||
<td class="website"><a href="https://github.com/andrewrk/liblaxjson">liblaxjson</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="package">liblo</td>
|
||||
<td class="website"><a href="http://liblo.sourceforge.net/">liblo</a></td>
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* This file is part of MXE.
|
||||
* See index.html for further information.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Andrew Kelley
|
||||
*
|
||||
* This file is part of liblaxjson, which is MIT licensed.
|
||||
* See http://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include <laxjson.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static int on_string(struct LaxJsonContext *context,
|
||||
enum LaxJsonType type, const char *value, int length)
|
||||
{
|
||||
(void)context;
|
||||
(void)length;
|
||||
char *type_name = (type == LaxJsonTypeProperty) ? "property" : "string";
|
||||
printf("%s: %s\n", type_name, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_number(struct LaxJsonContext *context, double x)
|
||||
{
|
||||
(void)context;
|
||||
printf("number: %f\n", x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_primitive(struct LaxJsonContext *context, enum LaxJsonType type)
|
||||
{
|
||||
(void)context;
|
||||
char *type_name;
|
||||
if (type == LaxJsonTypeTrue)
|
||||
type_name = "true";
|
||||
else if (type == LaxJsonTypeFalse)
|
||||
type_name = "false";
|
||||
else
|
||||
type_name = "null";
|
||||
|
||||
printf("primitive: %s\n", type_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_begin(struct LaxJsonContext *context, enum LaxJsonType type)
|
||||
{
|
||||
(void)context;
|
||||
char *type_name = (type == LaxJsonTypeArray) ? "array" : "object";
|
||||
printf("begin %s\n", type_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_end(struct LaxJsonContext *context, enum LaxJsonType type)
|
||||
{
|
||||
(void)context;
|
||||
char *type_name = (type == LaxJsonTypeArray) ? "array" : "object";
|
||||
printf("end %s\n", type_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char buf[1024];
|
||||
struct LaxJsonContext *context;
|
||||
FILE *f;
|
||||
int amt_read;
|
||||
|
||||
context = lax_json_create();
|
||||
|
||||
context->userdata = NULL; /* can set this to whatever you want */
|
||||
context->string = on_string;
|
||||
context->number = on_number;
|
||||
context->primitive = on_primitive;
|
||||
context->begin = on_begin;
|
||||
context->end = on_end;
|
||||
|
||||
f = fopen("file.json", "rb");
|
||||
while ((amt_read = fread(buf, 1, sizeof(buf), f))) {
|
||||
lax_json_feed(context, amt_read, buf);
|
||||
}
|
||||
lax_json_destroy(context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# This file is part of MXE.
|
||||
# See index.html for further information.
|
||||
|
||||
PKG := liblaxjson
|
||||
$(PKG)_IGNORE :=
|
||||
$(PKG)_VERSION := 1.0.3
|
||||
$(PKG)_CHECKSUM := 9e00362429d98d043c02ae726fd507abbc2ca9cc
|
||||
$(PKG)_SUBDIR := liblaxjson-$($(PKG)_VERSION)
|
||||
$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz
|
||||
$(PKG)_URL := https://github.com/andrewrk/liblaxjson/archive/$($(PKG)_VERSION).tar.gz
|
||||
$(PKG)_DEPS := gcc
|
||||
|
||||
define $(PKG)_UPDATE
|
||||
$(WGET) -q -O- 'https://github.com/andrewrk/liblaxjson/releases' | \
|
||||
$(SED) -n 's,.*/archive/\([0-9][^>]*\)\.tar.*,\1,p' | \
|
||||
head -1
|
||||
endef
|
||||
|
||||
define $(PKG)_BUILD
|
||||
mkdir '$(1)/build'
|
||||
cd '$(1)/build' && cmake .. \
|
||||
-DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)'
|
||||
|
||||
$(MAKE) -C '$(1)/build' -j '$(JOBS)' install
|
||||
|
||||
'$(TARGET)-gcc' \
|
||||
-W -Wall -Werror -ansi -pedantic -std=c99 \
|
||||
'$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-liblaxjson.exe' \
|
||||
-llaxjson
|
||||
endef
|
Loading…
Reference in New Issue