Permalink
Browse files

Initial import

  • Loading branch information...
0 parents commit e8e37a460322d92c4c37e5cca8d65f70c675e1de @umitanuki committed Apr 29, 2011
Showing with 3,319 additions and 0 deletions.
  1. +31 −0 Makefile
  2. +18 −0 README
  3. +78 −0 libjson-0.8/Makefile
  4. +72 −0 libjson-0.8/README
  5. +5 −0 libjson-0.8/debian/changelog
  6. +1 −0 libjson-0.8/debian/compat
  7. +22 −0 libjson-0.8/debian/control
  8. +26 −0 libjson-0.8/debian/copyright
  9. +1 −0 libjson-0.8/debian/docs
  10. +2 −0 libjson-0.8/debian/libjson-dev.dirs
  11. +4 −0 libjson-0.8/debian/libjson-dev.install
  12. +1 −0 libjson-0.8/debian/libjson.dirs
  13. +1 −0 libjson-0.8/debian/libjson.install
  14. +57 −0 libjson-0.8/debian/rules
  15. +4 −0 libjson-0.8/debian/watch
  16. +505 −0 libjson-0.8/documentation
  17. +963 −0 libjson-0.8/json.c
  18. +207 −0 libjson-0.8/json.h
  19. +540 −0 libjson-0.8/jsonlint.c
  20. +10 −0 libjson-0.8/libjson.pc.in
  21. 0 libjson-0.8/tests/bad/empty.json
  22. +3 −0 libjson-0.8/tests/bad/esc0.json
  23. +3 −0 libjson-0.8/tests/bad/esc1.json
  24. +3 −0 libjson-0.8/tests/bad/esc2.json
  25. +3 −0 libjson-0.8/tests/bad/esc3.json
  26. +3 −0 libjson-0.8/tests/bad/esc4.json
  27. +3 −0 libjson-0.8/tests/bad/float0.json
  28. +3 −0 libjson-0.8/tests/bad/float1.json
  29. +1 −0 libjson-0.8/tests/bad/object0.json
  30. +3 −0 libjson-0.8/tests/bad/object1.json
  31. +3 −0 libjson-0.8/tests/bad/object2.json
  32. +5 −0 libjson-0.8/tests/bad/object3.json
  33. +2 −0 libjson-0.8/tests/good/1.json
  34. +3 −0 libjson-0.8/tests/good/2.json
  35. +4 −0 libjson-0.8/tests/good/2obj.json
  36. +3 −0 libjson-0.8/tests/good/3.json
  37. +3 −0 libjson-0.8/tests/good/4.json
  38. +5 −0 libjson-0.8/tests/good/5.json
  39. +4 −0 libjson-0.8/tests/good/6.json
  40. +7 −0 libjson-0.8/tests/good/7.json
  41. +13 −0 libjson-0.8/tests/good/c-comment.json
  42. +21 −0 libjson-0.8/tests/good/complex0.json
  43. +3 −0 libjson-0.8/tests/good/emptyobj.json
  44. +3 −0 libjson-0.8/tests/good/esc0.json
  45. +3 −0 libjson-0.8/tests/good/esc1.json
  46. +3 −0 libjson-0.8/tests/good/esc2.json
  47. +3 −0 libjson-0.8/tests/good/esc3.json
  48. +3 −0 libjson-0.8/tests/good/esc4.json
  49. +3 −0 libjson-0.8/tests/good/float0.json
  50. +3 −0 libjson-0.8/tests/good/float1.json
  51. +3 −0 libjson-0.8/tests/good/float2.json
  52. +13 −0 libjson-0.8/tests/good/multiobj.json
  53. +10 −0 libjson-0.8/tests/good/yaml-comment.json
  54. +27 −0 libjson-0.8/tests/runtest
  55. +558 −0 twitter_fdw.c
  56. +38 −0 twitter_fdw.sql.in
@@ -0,0 +1,31 @@
+# contrib/twitter_fdw/Makefile
+
+LIBJSON = libjson-0.8
+MODULE_big = twitter_fdw
+OBJS = twitter_fdw.o
+
+DATA_built = twitter_fdw.sql
+DATA = uninstall_twitter_fdw.sql
+REGRESS = twitter_fdw
+SHLIB_LINK = -L$(LIBJSON) -ljson -lcurl
+
+all:all-libjson
+
+all-libjson:
+ $(MAKE) -C $(LIBJSON) all
+
+clean: clean-libjson
+
+clean-libjson:
+ $(MAKE) -C $(LIBJSON) clean
+
+ifdef USE_PGXS
+PG_CONFIG = pg_config
+PGXS := $(shell $(PG_CONFIG) --pgxs)
+include $(PGXS)
+else
+subdir = contrib/twitter_fdw
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
18 README
@@ -0,0 +1,18 @@
+Twitter Foreign Data Wrapper
+ Auther: Hitoshi Harada <umi.tanuki@gmail.com>
+
+This module implements Foreign Data Wrapper (FDW) handler of PostgreSQL which
+fetches text messages from Twitter over the Internet and returns as a table.
+The purpose is limited to the proof of concept of Foreign Data Wrapper API
+desgin only, so it is not recommended to use this for any other purpose.
+
+This module is depended on
+ libcurl <http://curl.haxx.se/libcurl/>
+ libjson <http://projects.snarc.org/libjson/>
+
+To install and try it,
+ $ export USE_PGXS=1
+ $ make && make install
+ $ psql -f twitter_fdw.sql
+ # SELECT from_user, created_at, text FROM twitter WHERE q = '#postgresql';
+
@@ -0,0 +1,78 @@
+AR = ar
+CC = gcc
+CFLAGS ?= -Wall -Os -fPIC
+LDFLAGS = -L.
+SHLIB_CFLAGS = -shared
+
+INSTALL_EXEC = install -m 755 -o root -g root
+INSTALL_DATA = install -m 644 -o root -g root
+COPY_PRESERVELINKS = cp -d
+INSTALL_SOLINKS = $(COPY_PRESERVELINKS)
+
+MAJOR = 0
+MINOR = 8
+MICRO = 0
+
+NAME = json
+A_TARGETS = lib$(NAME).a
+BIN_TARGETS = $(NAME)lint
+PC_TARGET = lib$(NAME).pc
+SO_LINKS = lib$(NAME).so lib$(NAME).so.$(MAJOR) lib$(NAME).so.$(MAJOR).$(MINOR)
+SO_FILE = lib$(NAME).so.$(MAJOR).$(MINOR).$(MICRO)
+HEADERS = $(NAME).h
+
+PREFIX ?= /usr
+DESTDIR ?=
+INSTALLDIR ?= $(DESTDIR)$(PREFIX)
+
+TARGETS = $(A_TARGETS) $(SO_FILE) $(SO_LINKS) $(BIN_TARGETS) $(PC_TARGET)
+
+all: $(TARGETS)
+
+lib$(NAME).a: $(NAME).o
+ $(AR) rc $@ $+
+
+lib$(NAME).so: lib$(NAME).so.$(MAJOR)
+ ln -sf $< $@
+
+lib$(NAME).so.$(MAJOR): lib$(NAME).so.$(MAJOR).$(MINOR)
+ ln -sf $< $@
+
+lib$(NAME).so.$(MAJOR).$(MINOR): lib$(NAME).so.$(MAJOR).$(MINOR).$(MICRO)
+ ln -sf $< $@
+
+lib$(NAME).so.$(MAJOR).$(MINOR).$(MICRO): $(NAME).o
+ $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,lib$(NAME).so.$(MAJOR).$(MINOR).$(MICRO) $(SHLIB_CFLAGS) -o $@ $^
+
+$(NAME)lint: $(NAME)lint.o $(NAME).o
+ $(CC) $(CFLAGS) -o $@ $+
+
+%.o: %.c %.h
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+.PHONY: lib$(NAME).pc
+lib$(NAME).pc: lib$(NAME).pc.in
+ sed -e 's;@PREFIX@;$(PREFIX);' -e 's;@LIBJSON_VER_MAJOR@;$(MAJOR);' -e 's;@LIBJSON_VER_MINOR@;$(MINOR);' < $< > $@
+
+.PHONY: tests clean install install-bin install-lib
+tests: $(NAME)lint
+ (cd tests; ./runtest)
+
+install-lib: $(SO_TARGETS) $(A_TARGETS) $(PC_TARGET)
+ mkdir -p $(INSTALLDIR)/lib/pkgconfig
+ $(INSTALL_DATA) -t $(INSTALLDIR)/lib/pkgconfig $(PC_TARGET)
+ mkdir -p $(INSTALLDIR)/include
+ $(INSTALL_DATA) -t $(INSTALLDIR)/include $(HEADERS)
+ mkdir -p $(INSTALLDIR)/lib
+ $(INSTALL_EXEC) -t $(INSTALLDIR)/lib $(SO_FILE)
+ $(INSTALL_DATA) -t $(INSTALLDIR)/lib $(A_TARGETS)
+ $(INSTALL_SOLINKS) $(SO_LINKS) $(INSTALLDIR)/lib
+
+install-bin: $(BIN_TARGETS)
+ mkdir -p $(INSTALLDIR)/bin
+ $(INSTALL_EXEC) -t $(INSTALLDIR)/bin $(BIN_TARGETS)
+
+install: install-lib install-bin
+
+clean:
+ rm -f *.o $(TARGETS)
@@ -0,0 +1,72 @@
+= libjson README =
+
+libjson is a simple library without any dependancies to parse and pretty print
+the json format (RFC4627). The JSON format is a concise and structured data
+format.
+
+libjson parser is an interruptible handcoded state parse. the parser takes
+character or string as input. Since it's interruptible, it's up to the
+user to feed the stream to the parser, which permits complete flexibility
+as to whether the data is coming from a pipe, a network socket, a file on disk,
+a serial line, or crafted by the user.
+
+The parser doesn't create an object tree for you, but each time it comes up
+with an element in this data, it just callback to the user with the type found and
+for some type, the data associated with it. it can be compared to the SAX way of XML,
+hence it's called SAJ (Simple API for JSon).
+
+The parser doesn't convert number to any native C format, but instead callback
+with a string that is a valid JSon number. JSon number can be of any size,
+so that's up to user to decide whetever or not, the number can map to native C type
+int32_t, int64_t, or a complex integer type. As well the user has a choice to
+refuse the integer at the callback stage if the length is not appropriate.
+
+The parser optionally allows YAML and/or C comments to be ignored if the config
+structure is set accordingly, otherwise a JSON_ERROR_COMMENT_NOT_ALLOWED is returned.
+
+the parser API is really simple, totaling only 5 API calls:
+
+* json_parser_init
+* json_parser_char
+* json_parser_string
+* json_parser_is_done
+* json_parser_free
+
+json_parser_init initializes a new parser context from a parser config and
+takes a callback + userdata. This callback function is used everything the
+parser need to communicate a type and value to the client side of the library.
+
+json_parser_char take one character and inject it in the parser. on parsing
+success it will return a 0 value, but on parsing error it returns a parsing
+error that represents the type of the error encounters. see JSON_ERROR_*
+for the full set of return values.
+
+json_parser_string is similar to json_parser_char except that it takes a string
+and a length. it also returns the number of character processed, which is
+useful when an parser error happened in the stream to pinpoint where.
+
+json_parser_is_done permits to test whetever or not the parser is in a
+terminated state. it involves not beeing into any structure.
+
+json_parser_free is the opposite of init, it just free the allocated structure.
+
+the printer API is simple too:
+
+* json_printer_init
+* json_printer_free
+* json_printer_pretty
+* json_printer_raw
+
+json_printer_init initialise a printing context and takes a callback + userdata
+that will be called for every character that the printer wants to output. the
+caller can have the printer callback redirect to anything it wants.
+
+json_printer_free is the opposite of init
+
+json_printer_raw takes a json type and an optional data and length value
+depending on the type. it's up to the caller to verify that the order of type
+are JSON-compliant, otherwise the generated document won't be able to be parsed
+again.
+
+json_printer_pretty works like json_printer_raw but is targetted for human
+reading by appending newlines and spaces
@@ -0,0 +1,5 @@
+libjson (0.7-1) unstable; urgency=low
+
+ * Initial release.
+
+ -- William Dauchy <wdauchy@gmail.com> Tue, 16 Mar 2010 15:45:59 +0100
@@ -0,0 +1 @@
+7
@@ -0,0 +1,22 @@
+Source: libjson
+Priority: extra
+Maintainer: William Dauchy <wdauchy@gmail.com>
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.8.4
+Section: libs
+Homepage: http://projects.snarc.org/libjson/
+
+Package: libjson-dev
+Section: libdevel
+Architecture: any
+Depends: libjson (= ${binary:Version})
+Description: Development files for libjson
+ This package contains the header files and static library needed to
+ compile applications that use confuse.
+
+Package: libjson
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Library to parse and pretty print the json format (RFC4627).
+ The JSON format is a concise and structured data format.
@@ -0,0 +1,26 @@
+This work was packaged for Debian by:
+
+ William Dauchy <wdauchy@gmail.com> on Tue, 16 Mar 2010 15:45:59 +0100
+
+It was downloaded from:
+
+ http://projects.snarc.org/libjson/
+
+Upstream Author(s):
+
+ Vincent Hanquez <tab@snarc.org>
+
+Copyright:
+
+ Copyright (C) 2009-2010 Vincent Hanquez
+
+License:
+
+ libjson is covered by the LGPLv2 license, or at your option the LGPLv3 license
+
+The Debian packaging is:
+
+ Copyright (C) 2010 William Dauchy <wdauchy@gmail.com>
+
+and is licensed under the LGPL version 3,
+see "/usr/share/common-licenses/LGPL".
@@ -0,0 +1 @@
+README
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
@@ -0,0 +1,4 @@
+usr/include/*
+usr/lib/lib*.a
+usr/lib/lib*.so
+usr/lib/pkgconfig/*
@@ -0,0 +1 @@
+usr/lib
@@ -0,0 +1 @@
+usr/lib/lib*.so.*
@@ -0,0 +1,57 @@
+#!/usr/bin/make -f
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS = -Wall -Wno-unused -g -fPIC
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+build: build-stamp
+
+build-stamp:
+ dh_testdir
+ $(MAKE)
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ dh_prep
+ dh_clean
+ rm -f build-stamp
+ $(MAKE) clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_prep
+ dh_clean
+ dh_installdirs
+ $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp PREFIX=/usr
+ mv libjson.pc $(CURDIR)/debian/tmp/usr/lib/pkgconfig/
+ dh_install --list-missing
+
+binary-indep: build install
+
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_makeshlibs -V
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
@@ -0,0 +1,4 @@
+# Compulsory line, this is a version 3 file
+version=3
+
+http://projects.snarc.org/libjson/download/libjson-(.*)\.tar\.gz
Oops, something went wrong.

0 comments on commit e8e37a4

Please sign in to comment.