aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@linux.intel.com>2011-04-26 09:46:34 +0100
committerMatt Fleming <matt.fleming@linux.intel.com>2011-04-26 09:46:34 +0100
commit10d05cbef13345ef3730234c1da7b0a34cdca9b6 (patch)
treed5a582d888db9c2dc360c9005c133b713f248e55 /com32/modules
parent844e965443e08133a7a366a496d8cc52ef93ca48 (diff)
parentd7d20a78c72237f85d8508c93aa411529d0ac17a (diff)
downloadsyslinux-10d05cbef13345ef3730234c1da7b0a34cdca9b6.tar.gz
syslinux-10d05cbef13345ef3730234c1da7b0a34cdca9b6.tar.xz
syslinux-10d05cbef13345ef3730234c1da7b0a34cdca9b6.zip
Merge remote-tracking branch 'zytor/master' into elflink
We need the recent Makefile filename changes to be merged into the elflink branch because it will make things simpler when converting all modules to ELF format. Conflicts: com32/Makefile com32/modules/Makefile version
Diffstat (limited to 'com32/modules')
-rw-r--r--com32/modules/Makefile7
-rw-r--r--com32/modules/zzjson.c101
2 files changed, 105 insertions, 3 deletions
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index 69bd01bd..e9ce1d1f 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -16,13 +16,14 @@
##
topdir = ../..
-include ../MCONFIG
+MAKEDIR = $(topdir)/mk
+include $(MAKEDIR)/com32.mk
MODULES = chain.c32 config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 \
disk.c32 pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 \
meminfo.c32 sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32 \
- kbdmap.c32 cmd.c32 vpdtest.c32 host.c32 dir.c32 gpxecmd.c32 \
- ifcpu.c32 cpuid.c32 cat.c32
+ kbdmap.c32 cmd.c32 vpdtest.c32 host.c32 ls.c32 gpxecmd.c32 \
+ ifcpu.c32 cpuid.c32 cat.c32 pwd.c32 ifplop.c32 zzjson.c32 whichsys.c32
TESTFILES =
diff --git a/com32/modules/zzjson.c b/com32/modules/zzjson.c
new file mode 100644
index 00000000..e2516fa1
--- /dev/null
+++ b/com32/modules/zzjson.c
@@ -0,0 +1,101 @@
+/*
+ * Display directory contents
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <console.h>
+#include <string.h>
+#include <com32.h>
+#include <zzjson/zzjson.h>
+#include <stdarg.h>
+
+static void myerror(void *ehandle, const char *format, ...) {
+ va_list ap;
+ fprintf(ehandle, "error: ");
+ va_start(ap, format);
+ vfprintf(ehandle, format, ap);
+ va_end(ap);
+ fputc('\n', ehandle);
+}
+
+
+int main(int argc, char *argv[])
+{
+ openconsole(&dev_rawcon_r, &dev_stdcon_w);
+ (void) argc;
+ (void) argv;
+ ZZJSON *tmp;
+ ZZJSON_CONFIG config = { ZZJSON_VERY_STRICT, NULL,
+ (int(*)(void*)) fgetc,
+ NULL,
+ malloc, calloc, free, realloc,
+ stderr, myerror, stdout,
+ (int(*)(void*,const char*,...)) fprintf,
+ (int(*)(int,void*)) fputc };
+
+ do {
+ ZZJSON *tmp2;
+
+ tmp = zzjson_create_array(&config,
+ zzjson_create_number_d(&config, 3.14),
+ zzjson_create_number_i(&config, 1234LL),
+ zzjson_create_number_i(&config, -4321LL),
+ zzjson_create_true(&config),
+ zzjson_create_false(&config),
+ zzjson_create_null(&config),
+ zzjson_create_string(&config, "hello, world"),
+ zzjson_create_object(&config,
+ "picard", zzjson_create_string(&config, "jean-luc"),
+ "riker", zzjson_create_string(&config, "william t."),
+ NULL),
+ zzjson_create_object(&config, NULL),
+ zzjson_create_array(&config, NULL),
+ NULL );
+
+ if (!tmp) {
+ fprintf(stderr, "error during creation of json tree\n");
+ break;
+ }
+
+ tmp2 = zzjson_array_prepend(&config, tmp,
+ zzjson_create_string(&config, "prepended string"));
+
+ if (!tmp2) {
+ fprintf(stderr, "error during prepend\n");
+ break;
+ }
+ tmp = tmp2;
+
+ tmp2 = zzjson_array_append(&config, tmp,
+ zzjson_create_string(&config, "appended string (slow)"));
+
+ if (!tmp2) {
+ fprintf(stderr, "error during append\n");
+ break;
+ }
+ tmp = tmp2;
+
+ zzjson_print(&config, tmp);
+ } while(0);
+ if (tmp) zzjson_free(&config, tmp);
+
+ {
+ tmp = zzjson_create_array(&config, NULL); /* empty array */
+ tmp = zzjson_array_prepend(&config, tmp, zzjson_create_true(&config));
+ zzjson_print(&config, tmp);
+ zzjson_free(&config, tmp);
+ }
+
+ {
+ tmp = zzjson_create_object(&config, NULL); /* empty object */
+ tmp = zzjson_object_prepend(&config, tmp, "hello",
+ zzjson_create_string(&config, "world"));
+ tmp = zzjson_object_append(&config, tmp, "goodbye",
+ zzjson_create_string(&config, "cruel world"));
+ zzjson_print(&config, tmp);
+ zzjson_free(&config, tmp);
+ }
+
+ return 0;
+}
+