├── jansson ├── doc │ ├── .gitignore │ ├── changes.rst │ ├── README │ ├── Makefile.am │ ├── index.rst │ ├── ext │ │ └── refcounting.py │ ├── upgrading.rst │ ├── portability.rst │ ├── conformance.rst │ └── github_commits.c ├── test │ ├── suites │ │ ├── invalid │ │ │ ├── empty │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── null │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── apostrophe │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── brace-comma │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── bracket-comma │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── lone-open-brace │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── lone-open-bracket │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── object-no-colon │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── unicode-identifier │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── unterminated-key │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── bracket-one-comma │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── extra-comma-in-array │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── invalid-identifier │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── object-apostrophes │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── object-no-value │ │ │ │ ├── input │ │ │ │ ├── error.strip │ │ │ │ └── error.normal │ │ │ ├── real-truncated-at-e │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── unterminated-array │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── unterminated-empty-key │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── unterminated-string │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── ascii-unicode-identifier │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── garbage-at-the-end │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── null-byte-outside-string │ │ │ │ ├── input │ │ │ │ ├── error │ │ │ │ └── nostrip │ │ │ ├── real-garbage-after-e │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── real-truncated-at-point │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── integer-starting-with-zero │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── invalid-negative-integer │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── invalid-negative-real │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── minus-sign-without-number │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── object-garbage-at-end │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── object-in-unterminated-array │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── object-unterminated-value │ │ │ │ ├── input │ │ │ │ ├── error.normal │ │ │ │ └── error.strip │ │ │ ├── unterminated-array-and-object │ │ │ │ ├── input │ │ │ │ ├── error.strip │ │ │ │ └── error.normal │ │ │ ├── unterminated-object-and-array │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── garbage-after-newline │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── invalid-escape │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── null-byte-in-object-key │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── real-negative-overflow │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── real-positive-overflow │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── negative-integer-starting-with-zero │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── null-byte-in-string │ │ │ │ ├── input │ │ │ │ ├── error │ │ │ │ └── nostrip │ │ │ ├── tab-character-in-string │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── too-big-positive-integer │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-unicode-escape │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── lone-second-surrogate │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── null-escape-in-string │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── too-big-negative-integer │ │ │ │ ├── input │ │ │ │ └── error │ │ │ ├── truncated-unicode-surrogate │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── extra-comma-in-multiline-array │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-second-surrogate │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── recursion-depth │ │ │ │ └── error │ │ │ └── run │ │ ├── valid │ │ │ ├── null │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── true │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── empty-array │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── empty-object │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── false │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── simple-int-0 │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── simple-int-1 │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── empty-string │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── negative-int │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── negative-one │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── negative-zero │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-capital-e │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-underflow │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── short-string │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── simple-int-123 │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── empty-object-in-array │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-exponent │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── simple-object │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── simple-real │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── complex-array │ │ │ │ ├── env │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-negative-exponent │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-positive-exponent │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── one-byte-utf-8 │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-fraction-exponent │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── string-escapes │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── two-byte-utf-8 │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-capital-e-negative-exponent │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-capital-e-positive-exponent │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── three-byte-utf-8 │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── utf-8-string │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── real-subnormal-number │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── escaped-utf-control-char │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── simple-ascii-string │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── utf-surrogate-four-byte-encoding │ │ │ │ ├── output │ │ │ │ └── input │ │ │ └── run │ │ ├── encoding-flags │ │ │ ├── array │ │ │ │ ├── output │ │ │ │ └── input │ │ │ ├── compact-array │ │ │ │ ├── output │ │ │ │ ├── input │ │ │ │ └── env │ │ │ ├── indent-array │ │ │ │ ├── input │ │ │ │ ├── output │ │ │ │ └── env │ │ │ ├── object │ │ │ │ ├── input │ │ │ │ ├── output │ │ │ │ └── env │ │ │ ├── compact-object │ │ │ │ ├── output │ │ │ │ ├── input │ │ │ │ └── env │ │ │ ├── indent-compact-array │ │ │ │ ├── input │ │ │ │ ├── output │ │ │ │ └── env │ │ │ ├── real-precision │ │ │ │ ├── output │ │ │ │ ├── input │ │ │ │ └── env │ │ │ ├── indent-object │ │ │ │ ├── input │ │ │ │ ├── output │ │ │ │ └── env │ │ │ ├── indent-compact-object │ │ │ │ ├── input │ │ │ │ ├── output │ │ │ │ └── env │ │ │ ├── sort-keys │ │ │ │ ├── output │ │ │ │ ├── env │ │ │ │ └── input │ │ │ ├── ensure-ascii │ │ │ │ ├── env │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── preserve-order │ │ │ │ ├── env │ │ │ │ ├── output │ │ │ │ └── input │ │ │ └── run │ │ ├── .gitattributes │ │ ├── Makefile.am │ │ ├── invalid-unicode │ │ │ ├── lone-invalid-utf-8 │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-in-array │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── restricted-utf-8 │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── truncated-utf-8 │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-in-int │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── not-in-unicode-range │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── encoded-surrogate-half │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-in-escape │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-in-string │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── overlong-3-byte-encoding │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── overlong-4-byte-encoding │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── overlong-ascii-encoding │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-after-backslash │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-in-bigger-int │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-in-exponent │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-in-identifier │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── invalid-utf-8-in-real-after-e │ │ │ │ ├── error │ │ │ │ └── input │ │ │ ├── lone-utf-8-continuation-byte │ │ │ │ ├── error │ │ │ │ └── input │ │ │ └── run │ │ └── api │ │ │ ├── check-exports │ │ │ ├── run │ │ │ ├── test_sprintf.c │ │ │ ├── test_loadb.c │ │ │ ├── Makefile.am │ │ │ ├── test_dump_callback.c │ │ │ ├── test_load_callback.c │ │ │ ├── test_memory_funcs.c │ │ │ ├── test_number.c │ │ │ ├── util.h │ │ │ └── test_chaos.c │ ├── bin │ │ └── Makefile.am │ ├── Makefile.am │ ├── .gitignore │ ├── scripts │ │ ├── valgrind.sh │ │ └── run-tests.sh │ └── run-suites ├── examples │ └── README.rst ├── cmake │ ├── janssonConfig.cmake.in │ ├── CheckFunctionKeywords.cmake │ ├── CoverallsClear.cmake │ ├── jansson_private_config.h.cmake │ ├── jansson_config.h.cmake │ └── Coveralls.cmake ├── jansson.pc.in ├── Makefile.am ├── appveyor.yml ├── .gitignore ├── src │ ├── Makefile.am │ ├── utf.h │ ├── strbuffer.h │ ├── memory.c │ ├── jansson.def │ ├── jansson_config.h.in │ ├── error.c │ ├── strbuffer.c │ ├── jansson_private.h │ ├── strconv.c │ ├── utf.c │ └── hashtable.h ├── Android.mk ├── LICENSE ├── .travis.yml ├── android │ └── jansson_config.h ├── release.sh ├── README.rst ├── CleanSpec.mk ├── include │ └── jansson_config.h └── configure.ac ├── FileScoreWriter.h ├── APIState.h ├── main.cpp ├── ScoreWriter.h ├── Observer.h ├── SC2State.h ├── Webhook.h ├── FileScoreWriter.cpp ├── SC2Data.h ├── Config.h ├── ScoreTracker.h ├── Constants.h ├── MainWindow.h ├── CMakeLists.txt ├── README.md ├── SC2Data.cpp ├── SC2State.cpp ├── Webhook.cpp └── Config.cpp /jansson/doc/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/empty/input: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/null/output: -------------------------------------------------------------------------------- 1 | [null] -------------------------------------------------------------------------------- /jansson/test/suites/valid/true/output: -------------------------------------------------------------------------------- 1 | [true] -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null/input: -------------------------------------------------------------------------------- 1 | null 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/empty-array/output: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /jansson/test/suites/valid/empty-object/output: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /jansson/test/suites/valid/false/output: -------------------------------------------------------------------------------- 1 | [false] -------------------------------------------------------------------------------- /jansson/test/suites/valid/null/input: -------------------------------------------------------------------------------- 1 | [null] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-int-0/output: -------------------------------------------------------------------------------- 1 | [0] -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-int-1/output: -------------------------------------------------------------------------------- 1 | [1] -------------------------------------------------------------------------------- /jansson/test/suites/valid/true/input: -------------------------------------------------------------------------------- 1 | [true] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/array/output: -------------------------------------------------------------------------------- 1 | [1, 2] -------------------------------------------------------------------------------- /jansson/test/suites/invalid/apostrophe/input: -------------------------------------------------------------------------------- 1 | [' 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/brace-comma/input: -------------------------------------------------------------------------------- 1 | {, 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/empty-array/input: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/empty-object/input: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/empty-string/input: -------------------------------------------------------------------------------- 1 | [""] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/empty-string/output: -------------------------------------------------------------------------------- 1 | [""] -------------------------------------------------------------------------------- /jansson/test/suites/valid/false/input: -------------------------------------------------------------------------------- 1 | [false] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/negative-int/output: -------------------------------------------------------------------------------- 1 | [-123] -------------------------------------------------------------------------------- /jansson/test/suites/valid/negative-one/input: -------------------------------------------------------------------------------- 1 | [-1] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/negative-one/output: -------------------------------------------------------------------------------- 1 | [-1] -------------------------------------------------------------------------------- /jansson/test/suites/valid/negative-zero/output: -------------------------------------------------------------------------------- 1 | [0] -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-capital-e/output: -------------------------------------------------------------------------------- 1 | [1e22] -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-underflow/output: -------------------------------------------------------------------------------- 1 | [0.0] -------------------------------------------------------------------------------- /jansson/test/suites/valid/short-string/output: -------------------------------------------------------------------------------- 1 | ["a"] -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-int-0/input: -------------------------------------------------------------------------------- 1 | [0] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-int-1/input: -------------------------------------------------------------------------------- 1 | [1] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-int-123/output: -------------------------------------------------------------------------------- 1 | [123] -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/array/input: -------------------------------------------------------------------------------- 1 | [1, 2] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/bracket-comma/input: -------------------------------------------------------------------------------- 1 | [, 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/lone-open-brace/input: -------------------------------------------------------------------------------- 1 | { 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/lone-open-bracket/input: -------------------------------------------------------------------------------- 1 | [ 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-no-colon/input: -------------------------------------------------------------------------------- 1 | {"a" 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unicode-identifier/input: -------------------------------------------------------------------------------- 1 | å 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-key/input: -------------------------------------------------------------------------------- 1 | {"a 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/empty-object-in-array/output: -------------------------------------------------------------------------------- 1 | [{}] -------------------------------------------------------------------------------- /jansson/test/suites/valid/negative-int/input: -------------------------------------------------------------------------------- 1 | [-123] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/negative-zero/input: -------------------------------------------------------------------------------- 1 | [-0] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-capital-e/input: -------------------------------------------------------------------------------- 1 | [1E22] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-exponent/input: -------------------------------------------------------------------------------- 1 | [123e45] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/short-string/input: -------------------------------------------------------------------------------- 1 | ["a"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-int-123/input: -------------------------------------------------------------------------------- 1 | [123] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-object/input: -------------------------------------------------------------------------------- 1 | {"a":[]} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-object/output: -------------------------------------------------------------------------------- 1 | {"a": []} -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-real/output: -------------------------------------------------------------------------------- 1 | [123.456789] -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/compact-array/output: -------------------------------------------------------------------------------- 1 | [1,2] -------------------------------------------------------------------------------- /jansson/test/suites/invalid/bracket-one-comma/input: -------------------------------------------------------------------------------- 1 | [1, 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/extra-comma-in-array/input: -------------------------------------------------------------------------------- 1 | [1,] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-identifier/input: -------------------------------------------------------------------------------- 1 | [troo 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-apostrophes/input: -------------------------------------------------------------------------------- 1 | {'a' 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-no-value/input: -------------------------------------------------------------------------------- 1 | {"a": 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-truncated-at-e/input: -------------------------------------------------------------------------------- 1 | [1e] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-array/input: -------------------------------------------------------------------------------- 1 | ["a" 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-empty-key/input: -------------------------------------------------------------------------------- 1 | {" 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-string/input: -------------------------------------------------------------------------------- 1 | ["a 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/complex-array/env: -------------------------------------------------------------------------------- 1 | JSON_SORT_KEYS=1 -------------------------------------------------------------------------------- /jansson/test/suites/valid/empty-object-in-array/input: -------------------------------------------------------------------------------- 1 | [{}] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-negative-exponent/output: -------------------------------------------------------------------------------- 1 | [0.01] -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-positive-exponent/output: -------------------------------------------------------------------------------- 1 | [100.0] -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-real/input: -------------------------------------------------------------------------------- 1 | [123.456789] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/.gitattributes: -------------------------------------------------------------------------------- 1 | api/ text=auto 2 | * text eol=lf -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/compact-array/input: -------------------------------------------------------------------------------- 1 | [1, 2] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-array/input: -------------------------------------------------------------------------------- 1 | [1, 2] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/object/input: -------------------------------------------------------------------------------- 1 | {"a": 1, "b": 2} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/object/output: -------------------------------------------------------------------------------- 1 | {"a": 1, "b": 2} -------------------------------------------------------------------------------- /jansson/test/suites/invalid/ascii-unicode-identifier/input: -------------------------------------------------------------------------------- 1 | aå 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/garbage-at-the-end/input: -------------------------------------------------------------------------------- 1 | [1,2,3]foo 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-byte-outside-string/input: -------------------------------------------------------------------------------- 1 | [ 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-garbage-after-e/input: -------------------------------------------------------------------------------- 1 | [1ea] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-truncated-at-point/input: -------------------------------------------------------------------------------- 1 | [1.] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/one-byte-utf-8/output: -------------------------------------------------------------------------------- 1 | [", one-byte UTF-8"] -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-fraction-exponent/output: -------------------------------------------------------------------------------- 1 | [1.23456e80] -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-negative-exponent/input: -------------------------------------------------------------------------------- 1 | [1e-2] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-positive-exponent/input: -------------------------------------------------------------------------------- 1 | [1e+2] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-underflow/input: -------------------------------------------------------------------------------- 1 | [123e-10000000] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/string-escapes/output: -------------------------------------------------------------------------------- 1 | ["\"\\/\b\f\n\r\t"] -------------------------------------------------------------------------------- /jansson/test/suites/valid/two-byte-utf-8/output: -------------------------------------------------------------------------------- 1 | ["ģ two-byte UTF-8"] -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/compact-object/output: -------------------------------------------------------------------------------- 1 | {"a":1,"b":2} -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-compact-array/input: -------------------------------------------------------------------------------- 1 | [1, 2] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/real-precision/output: -------------------------------------------------------------------------------- 1 | [1.235, 1.0, 1.0] -------------------------------------------------------------------------------- /jansson/test/suites/invalid/integer-starting-with-zero/input: -------------------------------------------------------------------------------- 1 | [012] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-negative-integer/input: -------------------------------------------------------------------------------- 1 | [-123foo] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-negative-real/input: -------------------------------------------------------------------------------- 1 | [-123.123foo] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/minus-sign-without-number/input: -------------------------------------------------------------------------------- 1 | [-foo] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-garbage-at-end/input: -------------------------------------------------------------------------------- 1 | {"a":"a" 123} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-in-unterminated-array/input: -------------------------------------------------------------------------------- 1 | [{} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-unterminated-value/input: -------------------------------------------------------------------------------- 1 | {"a":"a 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-array-and-object/input: -------------------------------------------------------------------------------- 1 | [{ 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-object-and-array/input: -------------------------------------------------------------------------------- 1 | {[ 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-capital-e-negative-exponent/output: -------------------------------------------------------------------------------- 1 | [0.01] -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-capital-e-positive-exponent/output: -------------------------------------------------------------------------------- 1 | [100.0] -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-exponent/output: -------------------------------------------------------------------------------- 1 | [1.2299999999999999e47] -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-fraction-exponent/input: -------------------------------------------------------------------------------- 1 | [123.456e78] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/string-escapes/input: -------------------------------------------------------------------------------- 1 | ["\"\\\/\b\f\n\r\t"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/three-byte-utf-8/output: -------------------------------------------------------------------------------- 1 | ["ࠡ three-byte UTF-8"] -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/compact-object/input: -------------------------------------------------------------------------------- 1 | {"a": 1, "b": 2} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-object/input: -------------------------------------------------------------------------------- 1 | {"a": 1, "b": 2} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/garbage-after-newline/input: -------------------------------------------------------------------------------- 1 | [1,2,3] 2 | foo 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-escape/input: -------------------------------------------------------------------------------- 1 | ["\a <-- invalid escape"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-byte-in-object-key/input: -------------------------------------------------------------------------------- 1 | {"foo\u0000bar": 42} -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-negative-overflow/input: -------------------------------------------------------------------------------- 1 | [-123123e100000] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-positive-overflow/input: -------------------------------------------------------------------------------- 1 | [123123e100000] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/one-byte-utf-8/input: -------------------------------------------------------------------------------- 1 | ["\u002c one-byte UTF-8"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-capital-e-negative-exponent/input: -------------------------------------------------------------------------------- 1 | [1E-2] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-capital-e-positive-exponent/input: -------------------------------------------------------------------------------- 1 | [1E+2] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/two-byte-utf-8/input: -------------------------------------------------------------------------------- 1 | ["\u0123 two-byte UTF-8"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/utf-8-string/output: -------------------------------------------------------------------------------- 1 | ["€þıœəßð some utf-8 ĸʒ×ŋµåäö𝄞"] -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-array/output: -------------------------------------------------------------------------------- 1 | [ 2 | 1, 3 | 2 4 | ] -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-compact-object/input: -------------------------------------------------------------------------------- 1 | {"a": 1, "b": 2} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/object/env: -------------------------------------------------------------------------------- 1 | HASHSEED=1 2 | export HASHSEED 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/apostrophe/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | invalid token near ''' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/negative-integer-starting-with-zero/input: -------------------------------------------------------------------------------- 1 | [-012] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-subnormal-number/input: -------------------------------------------------------------------------------- 1 | [1.8011670033376514e-308] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/real-subnormal-number/output: -------------------------------------------------------------------------------- 1 | [1.8011670033376514e-308] -------------------------------------------------------------------------------- /jansson/test/suites/valid/three-byte-utf-8/input: -------------------------------------------------------------------------------- 1 | ["\u0821 three-byte UTF-8"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/utf-8-string/input: -------------------------------------------------------------------------------- 1 | ["€þıœəßð some utf-8 ĸʒ×ŋµåäö𝄞"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/bracket-comma/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unexpected token near ',' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-escape/error: -------------------------------------------------------------------------------- 1 | 1 4 4 2 | invalid escape near '"\a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-byte-in-string/input: -------------------------------------------------------------------------------- 1 | ["null byte not allowed"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null/error: -------------------------------------------------------------------------------- 1 | 1 4 4 2 | '[' or '{' expected near 'null' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/tab-character-in-string/input: -------------------------------------------------------------------------------- 1 | [" <-- tab character"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-array/env: -------------------------------------------------------------------------------- 1 | JSON_INDENT=4 2 | export JSON_INDENT 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-compact-array/output: -------------------------------------------------------------------------------- 1 | [ 2 | 1, 3 | 2 4 | ] -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-object/output: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1, 3 | "b": 2 4 | } -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/sort-keys/output: -------------------------------------------------------------------------------- 1 | {"bar": 2, "baz": 3, "foo": 1, "quux": 4} -------------------------------------------------------------------------------- /jansson/test/suites/invalid/brace-comma/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | string or '}' expected near ',' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/empty/error: -------------------------------------------------------------------------------- 1 | 1 0 0 2 | '[' or '{' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-identifier/error: -------------------------------------------------------------------------------- 1 | 1 5 5 2 | invalid token near 'troo' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-garbage-after-e/error: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | invalid token near '1e' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-truncated-at-e/error: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | invalid token near '1e' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/too-big-positive-integer/error: -------------------------------------------------------------------------------- 1 | 1 31 31 2 | too big integer 3 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/escaped-utf-control-char/output: -------------------------------------------------------------------------------- 1 | ["\u0012 escaped control character"] -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-ascii-string/output: -------------------------------------------------------------------------------- 1 | ["abcdefghijklmnopqrstuvwxyz1234567890 "] -------------------------------------------------------------------------------- /jansson/test/suites/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = api 2 | EXTRA_DIST = invalid invalid-unicode valid 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/compact-array/env: -------------------------------------------------------------------------------- 1 | JSON_COMPACT=1 2 | export JSON_COMPACT 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/real-precision/input: -------------------------------------------------------------------------------- 1 | [1.23456789, 1.0, 1.0000000000000002] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/sort-keys/env: -------------------------------------------------------------------------------- 1 | JSON_SORT_KEYS=1 2 | export JSON_SORT_KEYS 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/sort-keys/input: -------------------------------------------------------------------------------- 1 | {"foo": 1, "bar": 2, "baz": 3, "quux": 4} 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/extra-comma-in-array/error: -------------------------------------------------------------------------------- 1 | 1 4 4 2 | unexpected token near ']' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/integer-starting-with-zero/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | invalid token near '0' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-negative-integer/error: -------------------------------------------------------------------------------- 1 | 1 8 8 2 | ']' expected near 'foo' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-negative-real/error: -------------------------------------------------------------------------------- 1 | 1 12 12 2 | ']' expected near 'foo' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-unicode-escape/error: -------------------------------------------------------------------------------- 1 | 1 5 5 2 | invalid escape near '"\uq' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-unicode-escape/input: -------------------------------------------------------------------------------- 1 | ["\uqqqq <-- invalid unicode escape"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/lone-second-surrogate/error: -------------------------------------------------------------------------------- 1 | 1 40 40 2 | invalid Unicode '\uDFAA' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/minus-sign-without-number/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | invalid token near '-' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-escape-in-string/input: -------------------------------------------------------------------------------- 1 | ["null escape \u0000 not allowed"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-apostrophes/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | string or '}' expected near ''' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-garbage-at-end/error: -------------------------------------------------------------------------------- 1 | 1 12 12 2 | '}' expected near '123' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-truncated-at-point/error: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | invalid token near '1.' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/too-big-negative-integer/input: -------------------------------------------------------------------------------- 1 | [-123123123123123123123123123123] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/too-big-positive-integer/input: -------------------------------------------------------------------------------- 1 | [123123123123123123123123123123] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unicode-identifier/error: -------------------------------------------------------------------------------- 1 | 1 1 2 2 | '[' or '{' expected near 'å' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/escaped-utf-control-char/input: -------------------------------------------------------------------------------- 1 | ["\u0012 escaped control character"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/simple-ascii-string/input: -------------------------------------------------------------------------------- 1 | ["abcdefghijklmnopqrstuvwxyz1234567890 "] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/utf-surrogate-four-byte-encoding/output: -------------------------------------------------------------------------------- 1 | ["𝄞 surrogate, four-byte UTF-8"] -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-compact-object/output: -------------------------------------------------------------------------------- 1 | { 2 | "a":1, 3 | "b":2 4 | } -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/lone-invalid-utf-8/error: -------------------------------------------------------------------------------- 1 | 1 0 0 2 | unable to decode byte 0xe5 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/ascii-unicode-identifier/error: -------------------------------------------------------------------------------- 1 | 1 1 1 2 | '[' or '{' expected near 'a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/bracket-one-comma/error.normal: -------------------------------------------------------------------------------- 1 | 2 0 4 2 | ']' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/bracket-one-comma/error.strip: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | ']' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/garbage-after-newline/error: -------------------------------------------------------------------------------- 1 | 2 3 11 2 | end of file expected near 'foo' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/garbage-at-the-end/error: -------------------------------------------------------------------------------- 1 | 1 10 10 2 | end of file expected near 'foo' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/lone-open-bracket/error.normal: -------------------------------------------------------------------------------- 1 | 2 0 2 2 | ']' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/lone-open-bracket/error.strip: -------------------------------------------------------------------------------- 1 | 1 1 1 2 | ']' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/lone-second-surrogate/input: -------------------------------------------------------------------------------- 1 | ["\uDFAA (second surrogate on it's own)"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-byte-outside-string/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | invalid token near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-no-colon/error.normal: -------------------------------------------------------------------------------- 1 | 2 0 5 2 | ':' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-no-colon/error.strip: -------------------------------------------------------------------------------- 1 | 1 4 4 2 | ':' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-no-value/error.strip: -------------------------------------------------------------------------------- 1 | 1 5 5 2 | unexpected token near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/tab-character-in-string/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | control character 0x9 near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/too-big-negative-integer/error: -------------------------------------------------------------------------------- 1 | 1 32 32 2 | too big negative integer 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/truncated-unicode-surrogate/error: -------------------------------------------------------------------------------- 1 | 1 46 46 2 | invalid Unicode '\uDADA' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-array/error.normal: -------------------------------------------------------------------------------- 1 | 2 0 5 2 | ']' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-array/error.strip: -------------------------------------------------------------------------------- 1 | 1 4 4 2 | ']' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-key/error.normal: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | unexpected newline near '"a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-key/error.strip: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | premature end of input near '"a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-string/error.normal: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | unexpected newline near '"a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/ensure-ascii/env: -------------------------------------------------------------------------------- 1 | JSON_ENSURE_ASCII=1 2 | export JSON_ENSURE_ASCII 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/error: -------------------------------------------------------------------------------- 1 | 1 1 1 2 | unable to decode byte 0xe5 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/restricted-utf-8/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xfd near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/truncated-utf-8/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xe0 near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/extra-comma-in-multiline-array/error: -------------------------------------------------------------------------------- 1 | 6 1 17 2 | unexpected token near ']' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/extra-comma-in-multiline-array/input: -------------------------------------------------------------------------------- 1 | [1, 2 | 2, 3 | 3, 4 | 4, 5 | 5, 6 | ] 7 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-second-surrogate/error: -------------------------------------------------------------------------------- 1 | 1 62 62 2 | invalid Unicode '\uD888\u3210' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/negative-integer-starting-with-zero/error: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | invalid token near '-0' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-no-value/error.normal: -------------------------------------------------------------------------------- 1 | 2 0 6 2 | unexpected token near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/recursion-depth/error: -------------------------------------------------------------------------------- 1 | 1 2049 2049 2 | maximum parsing depth reached near '[' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-empty-key/error.normal: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unexpected newline near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-empty-key/error.strip: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | premature end of input near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-string/error.strip: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | premature end of input near '"a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/preserve-order/env: -------------------------------------------------------------------------------- 1 | JSON_PRESERVE_ORDER=1 2 | export JSON_PRESERVE_ORDER 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/real-precision/env: -------------------------------------------------------------------------------- 1 | JSON_REAL_PRECISION=4 2 | export JSON_REAL_PRECISION 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xe5 near '0' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/not-in-unicode-range/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xf4 near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/lone-open-brace/error.normal: -------------------------------------------------------------------------------- 1 | 2 0 2 2 | string or '}' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/lone-open-brace/error.strip: -------------------------------------------------------------------------------- 1 | 1 1 1 2 | string or '}' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-byte-in-string/error: -------------------------------------------------------------------------------- 1 | 1 12 12 2 | control character 0x0 near '"null byte ' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-in-unterminated-array/error.normal: -------------------------------------------------------------------------------- 1 | 2 0 4 2 | ']' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-in-unterminated-array/error.strip: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | ']' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-unterminated-value/error.normal: -------------------------------------------------------------------------------- 1 | 1 7 7 2 | unexpected newline near '"a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/object-unterminated-value/error.strip: -------------------------------------------------------------------------------- 1 | 1 7 7 2 | premature end of input near '"a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/truncated-unicode-surrogate/input: -------------------------------------------------------------------------------- 1 | ["\uDADA (first surrogate without the second)"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-object-and-array/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | string or '}' expected near '[' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/utf-surrogate-four-byte-encoding/input: -------------------------------------------------------------------------------- 1 | ["\uD834\uDD1E surrogate, four-byte UTF-8"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-object/env: -------------------------------------------------------------------------------- 1 | JSON_INDENT=4 2 | HASHSEED=1 3 | export JSON_INDENT HASHSEED 4 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/encoded-surrogate-half/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xed near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/error: -------------------------------------------------------------------------------- 1 | 1 4 4 2 | unable to decode byte 0xe5 near '"\u' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xe5 near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xe0 near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xf0 near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/overlong-ascii-encoding/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xc1 near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-escape-in-string/error: -------------------------------------------------------------------------------- 1 | 1 33 33 2 | \u0000 is not allowed without JSON_ALLOW_NUL 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-negative-overflow/error: -------------------------------------------------------------------------------- 1 | 1 15 15 2 | real number overflow near '-123123e100000' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/real-positive-overflow/error: -------------------------------------------------------------------------------- 1 | 1 14 14 2 | real number overflow near '123123e100000' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/compact-object/env: -------------------------------------------------------------------------------- 1 | JSON_COMPACT=1 2 | HASHSEED=1 3 | export JSON_COMPACT HASHSEED 4 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/error: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | unable to decode byte 0xe5 near '"\' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/error: -------------------------------------------------------------------------------- 1 | 1 4 4 2 | unable to decode byte 0xe5 near '123' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/error: -------------------------------------------------------------------------------- 1 | 1 4 4 2 | unable to decode byte 0xe5 near '1e1' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0xe5 near 'a' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/error: -------------------------------------------------------------------------------- 1 | 1 3 3 2 | unable to decode byte 0xe5 near '1e' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/error: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | unable to decode byte 0x81 near '"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-array-and-object/error.strip: -------------------------------------------------------------------------------- 1 | 1 2 2 2 | string or '}' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/doc/changes.rst: -------------------------------------------------------------------------------- 1 | ****************** 2 | Changes in Jansson 3 | ****************** 4 | 5 | .. include:: ../CHANGES 6 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/invalid-second-surrogate/input: -------------------------------------------------------------------------------- 1 | ["\uD888\u3210 (first surrogate and invalid second surrogate)"] 2 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/unterminated-array-and-object/error.normal: -------------------------------------------------------------------------------- 1 | 2 0 3 2 | string or '}' expected near end of file 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-compact-array/env: -------------------------------------------------------------------------------- 1 | JSON_INDENT=4 2 | JSON_COMPACT=1 3 | export JSON_INDENT JSON_COMPACT 4 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/preserve-order/output: -------------------------------------------------------------------------------- 1 | {"foo": 1, "bar": 2, "asdf": 3, "deadbeef": 4, "badc0ffee": 5, "qwerty": 6} -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-byte-in-object-key/error: -------------------------------------------------------------------------------- 1 | 1 15 15 2 | NUL byte in object key not supported near '"foo\u0000bar"' 3 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/preserve-order/input: -------------------------------------------------------------------------------- 1 | {"foo": 1, "bar": 2, "asdf": 3, "deadbeef": 4, "badc0ffee": 5, "qwerty": 6} 2 | -------------------------------------------------------------------------------- /jansson/doc/README: -------------------------------------------------------------------------------- 1 | To build the documentation, invoke 2 | 3 | make html 4 | 5 | Then point your browser to _build/html/index.html. 6 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/complex-array/output: -------------------------------------------------------------------------------- 1 | [1, 2, 3, 4, "a", "b", "c", {"core": "dump", "foo": "bar"}, true, false, true, true, null, false] -------------------------------------------------------------------------------- /jansson/examples/README.rst: -------------------------------------------------------------------------------- 1 | Jansson examples 2 | ================ 3 | 4 | This directory contains simple example programs that use Jansson. 5 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/indent-compact-object/env: -------------------------------------------------------------------------------- 1 | JSON_INDENT=4 2 | JSON_COMPACT=1 3 | HASHSEED=1 4 | export JSON_INDENT JSON_COMPACT HASHSEED 5 | -------------------------------------------------------------------------------- /jansson/test/suites/valid/complex-array/input: -------------------------------------------------------------------------------- 1 | [1,2,3,4, 2 | "a", "b", "c", 3 | {"foo": "bar", "core": "dump"}, 4 | true, false, true, true, null, false 5 | ] 6 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-byte-in-string/nostrip: -------------------------------------------------------------------------------- 1 | The embedded NULL byte breaks json_loads(), which is used instead of 2 | json_loadf() in the stripped tests. 3 | -------------------------------------------------------------------------------- /jansson/cmake/janssonConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/janssonTargets.cmake") 4 | check_required_components("@PROJECT_NAME@") 5 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/ensure-ascii/input: -------------------------------------------------------------------------------- 1 | [ 2 | "foo", 3 | "å ä ö", 4 | "foo åä", 5 | "åä foo", 6 | "å foo ä", 7 | "clef g: 𝄞" 8 | ] 9 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/ensure-ascii/output: -------------------------------------------------------------------------------- 1 | ["foo", "\u00E5 \u00E4 \u00F6", "foo \u00E5\u00E4", "\u00E5\u00E4 foo", "\u00E5 foo \u00E4", "clef g: \uD834\uDD1E"] -------------------------------------------------------------------------------- /jansson/test/suites/invalid/null-byte-outside-string/nostrip: -------------------------------------------------------------------------------- 1 | The embedded NULL byte breaks json_loads(), which is used instead of 2 | json_loadf() in the stripped tests. 3 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/restricted-utf-8/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/restricted-utf-8/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/truncated-utf-8/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/truncated-utf-8/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/lone-invalid-utf-8/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/lone-invalid-utf-8/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/not-in-unicode-range/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/not-in-unicode-range/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/encoded-surrogate-half/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/encoded-surrogate-half/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/overlong-ascii-encoding/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/overlong-ascii-encoding/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/input -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leigholiver/SC2Switcher-Standalone/master/jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/input -------------------------------------------------------------------------------- /jansson/test/bin/Makefile.am: -------------------------------------------------------------------------------- 1 | check_PROGRAMS = json_process 2 | 3 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 4 | LDFLAGS = -static # for speed and Valgrind 5 | LDADD = $(top_builddir)/src/libjansson.la 6 | -------------------------------------------------------------------------------- /jansson/test/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = bin suites 2 | EXTRA_DIST = scripts run-suites 3 | 4 | TESTS = run-suites 5 | TESTS_ENVIRONMENT = \ 6 | top_srcdir=$(top_srcdir) \ 7 | top_builddir=$(top_builddir) 8 | 9 | clean-local: 10 | rm -rf logs 11 | -------------------------------------------------------------------------------- /FileScoreWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ScoreWriter.h" 4 | #include "ScoreTracker.h" 5 | 6 | class FileScoreWriter : public ScoreWriter { 7 | 8 | public: 9 | explicit FileScoreWriter(ScoreTracker* tracker); 10 | 11 | public slots: 12 | void notify(std::string scoreString); 13 | }; -------------------------------------------------------------------------------- /jansson/jansson.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: Jansson 7 | Description: Library for encoding, decoding and manipulating JSON data 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -ljansson 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /APIState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct player { 4 | const char* name; 5 | const char* type; 6 | const char* race; 7 | const char* result; 8 | }; 9 | 10 | struct APIState { 11 | std::vector activeScreens; 12 | bool isReplay; 13 | double displayTime; 14 | std::vector players; 15 | }; -------------------------------------------------------------------------------- /jansson/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = CHANGES LICENSE README.rst CMakeLists.txt cmake android examples 2 | SUBDIRS = doc src test 3 | 4 | # "make distcheck" builds the dvi target, so use it to check that the 5 | # documentation is built correctly. 6 | dvi: 7 | $(MAKE) SPHINXOPTS_EXTRA=-W html 8 | 9 | pkgconfigdir = $(libdir)/pkgconfig 10 | pkgconfig_DATA = jansson.pc 11 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MainWindow.h" 3 | #include "Config.h" 4 | 5 | int main(int argc, char **argv) 6 | { 7 | QApplication *app = new QApplication(argc, argv); 8 | MainWindow *mw = new MainWindow(); 9 | mw->show(); 10 | app->exec(); 11 | 12 | Config* cfg = Config::Current(); 13 | cfg->save(); 14 | 15 | return true; 16 | } -------------------------------------------------------------------------------- /ScoreWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "ScoreTracker.h" 6 | 7 | class ScoreWriter : public QObject { 8 | Q_OBJECT 9 | ScoreTracker *st; 10 | 11 | public: 12 | ScoreWriter(ScoreTracker *tracker, QObject* parent = Q_NULLPTR) 13 | : QObject(parent) { 14 | st = tracker; 15 | st->attach(this); 16 | } 17 | virtual void notify(std::string scoreString) = 0; 18 | }; -------------------------------------------------------------------------------- /Observer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "SC2Data.h" 6 | #include "SC2State.h" 7 | 8 | class Observer : public QObject { 9 | Q_OBJECT 10 | SC2Data *sc2; 11 | 12 | public: 13 | Observer(SC2Data *scdata, QObject* parent = Q_NULLPTR) 14 | : QObject(parent) { 15 | sc2 = scdata; 16 | sc2->attach(this); 17 | } 18 | virtual void notify(SC2State*& previous, SC2State*& current) = 0; 19 | }; -------------------------------------------------------------------------------- /SC2State.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Constants.h" 3 | #include "APIState.h" 4 | 5 | class SC2State : public QObject { 6 | Q_OBJECT 7 | 8 | public: 9 | explicit SC2State(QObject* parent = Q_NULLPTR); 10 | virtual ~SC2State(); 11 | int appState = 0; 12 | int gameState = 0; 13 | int menuState = 0; 14 | APIState fullState; 15 | void fromJSONString(std::string uiResponse, std::string gameResponse); 16 | void fillState(); 17 | }; -------------------------------------------------------------------------------- /Webhook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Observer.h" 4 | #include "SC2State.h" 5 | #include 6 | 7 | class Webhook : public Observer { 8 | private: 9 | void sendRequest(SC2State*& game, std::string event); 10 | std::string getJSONStringFromSC2State(SC2State*& game, std::string event); 11 | 12 | public: 13 | explicit Webhook(SC2Data *sc2); 14 | 15 | public slots: 16 | void notify(SC2State*& previous, SC2State*& current); 17 | 18 | }; -------------------------------------------------------------------------------- /FileScoreWriter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ScoreWriter.h" 4 | #include "FileScoreWriter.h" 5 | using namespace std; 6 | 7 | FileScoreWriter::FileScoreWriter(ScoreTracker *tracker): ScoreWriter(tracker){} 8 | 9 | void FileScoreWriter::notify(std::string scoreString) { 10 | ofstream settingsFile("scores.txt"); 11 | if (settingsFile.is_open()) { 12 | settingsFile << scoreString; 13 | settingsFile.close(); 14 | } 15 | } -------------------------------------------------------------------------------- /jansson/appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | matrix: 3 | - VS: Visual Studio 9 2008 4 | - VS: Visual Studio 10 2010 5 | - VS: Visual Studio 11 2012 6 | - VS: Visual Studio 12 2013 7 | - VS: Visual Studio 14 2015 8 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 9 | VS: Visual Studio 15 2017 10 | 11 | build_script: 12 | - md build 13 | - cd build 14 | - cmake -G "%VS%" .. 15 | - cmake --build . --config Release 16 | - ctest --output-on-failure 17 | -------------------------------------------------------------------------------- /jansson/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.o 3 | *.a 4 | .libs 5 | .deps 6 | Makefile 7 | Makefile.in 8 | aclocal.m4 9 | autom4te.cache 10 | config.guess 11 | config.h 12 | config.h.in 13 | config.log 14 | config.status 15 | config.sub 16 | configure 17 | depcomp 18 | install-sh 19 | libtool 20 | ltmain.sh 21 | missing 22 | compile 23 | test-driver 24 | *.lo 25 | *.la 26 | stamp-h1 27 | *.pyc 28 | *.pc 29 | /src/jansson_config.h 30 | /jansson_private_config.h.in 31 | /jansson_private_config.h 32 | /build 33 | *.exe 34 | .idea 35 | cmake-build-debug/ 36 | -------------------------------------------------------------------------------- /SC2Data.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "SC2State.h" 8 | 9 | using std::vector; 10 | 11 | class Observer; 12 | class SC2Data : public QObject { 13 | Q_OBJECT 14 | 15 | private: 16 | SC2State* state; 17 | QTimer* timer; 18 | vector watchers; 19 | 20 | public: 21 | explicit SC2Data(QObject* parent = Q_NULLPTR); 22 | virtual ~SC2Data(); 23 | static SC2Data* Instance; 24 | void attach(Observer* obs); 25 | 26 | public slots: 27 | void update(); 28 | }; -------------------------------------------------------------------------------- /jansson/test/.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | bin/json_process 3 | suites/api/test_array 4 | suites/api/test_chaos 5 | suites/api/test_copy 6 | suites/api/test_cpp 7 | suites/api/test_dump 8 | suites/api/test_dump_callback 9 | suites/api/test_equal 10 | suites/api/test_load 11 | suites/api/test_load_callback 12 | suites/api/test_loadb 13 | suites/api/test_memory_funcs 14 | suites/api/test_number 15 | suites/api/test_object 16 | suites/api/test_pack 17 | suites/api/test_simple 18 | suites/api/test_sprintf 19 | suites/api/test_unpack 20 | run-suites.log 21 | run-suites.trs 22 | test-suite.log 23 | 24 | -------------------------------------------------------------------------------- /jansson/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = conf.py apiref.rst changes.rst conformance.rst \ 2 | gettingstarted.rst github_commits.c index.rst portability.rst \ 3 | tutorial.rst upgrading.rst ext/refcounting.py 4 | 5 | SPHINXBUILD = sphinx-build 6 | SPHINXOPTS = -d _build/doctrees $(SPHINXOPTS_EXTRA) 7 | 8 | html-local: 9 | $(SPHINXBUILD) -b html $(SPHINXOPTS) $(srcdir) _build/html 10 | 11 | install-html-local: html 12 | mkdir -p $(DESTDIR)$(htmldir) 13 | cp -r _build/html $(DESTDIR)$(htmldir) 14 | 15 | uninstall-local: 16 | rm -rf $(DESTDIR)$(htmldir) 17 | 18 | clean-local: 19 | rm -rf _build 20 | rm -f ext/refcounting.pyc 21 | -------------------------------------------------------------------------------- /jansson/src/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = jansson.def 2 | 3 | include_HEADERS = jansson.h 4 | nodist_include_HEADERS = jansson_config.h 5 | 6 | lib_LTLIBRARIES = libjansson.la 7 | libjansson_la_SOURCES = \ 8 | dump.c \ 9 | error.c \ 10 | hashtable.c \ 11 | hashtable.h \ 12 | hashtable_seed.c \ 13 | jansson_private.h \ 14 | load.c \ 15 | lookup3.h \ 16 | memory.c \ 17 | pack_unpack.c \ 18 | strbuffer.c \ 19 | strbuffer.h \ 20 | strconv.c \ 21 | utf.c \ 22 | utf.h \ 23 | value.c 24 | libjansson_la_LDFLAGS = \ 25 | -no-undefined \ 26 | -export-symbols-regex '^json_' \ 27 | -version-info 15:0:11 \ 28 | @JSON_BSYMBOLIC_LDFLAGS@ 29 | -------------------------------------------------------------------------------- /jansson/cmake/CheckFunctionKeywords.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCSourceCompiles) 2 | 3 | macro(check_function_keywords _wordlist) 4 | set(${_result} "") 5 | foreach(flag ${_wordlist}) 6 | string(REGEX REPLACE "[-+/ ()]" "_" flagname "${flag}") 7 | string(TOUPPER "${flagname}" flagname) 8 | set(have_flag "HAVE_${flagname}") 9 | check_c_source_compiles("${flag} void func(); void func() { } int main() { func(); return 0; }" ${have_flag}) 10 | if(${have_flag} AND NOT ${_result}) 11 | set(${_result} "${flag}") 12 | # break() 13 | endif(${have_flag} AND NOT ${_result}) 14 | endforeach(flag) 15 | endmacro(check_function_keywords) 16 | -------------------------------------------------------------------------------- /jansson/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_ARM_MODE := arm 5 | 6 | LOCAL_SRC_FILES := \ 7 | src/dump.c \ 8 | src/error.c \ 9 | src/hashtable.c \ 10 | src/hashtable_seed.c \ 11 | src/load.c \ 12 | src/memory.c \ 13 | src/pack_unpack.c \ 14 | src/strbuffer.c \ 15 | src/strconv.c \ 16 | src/utf.c \ 17 | src/value.c 18 | 19 | LOCAL_C_INCLUDES += \ 20 | $(LOCAL_PATH) \ 21 | $(LOCAL_PATH)/android \ 22 | $(LOCAL_PATH)/src 23 | 24 | LOCAL_MODULE_TAGS := optional 25 | LOCAL_SHARED_LIBRARIES := libc 26 | LOCAL_CFLAGS += -O3 -DHAVE_STDINT_H=1 27 | 28 | LOCAL_MODULE:= libjansson 29 | 30 | include $(BUILD_SHARED_LIBRARY) 31 | -------------------------------------------------------------------------------- /Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "Constants.h" 7 | 8 | using namespace std; 9 | 10 | class Config { 11 | public: 12 | Config(); 13 | static Config* Current(); 14 | void load(); 15 | void save(); 16 | std::string escape_json(const std::string &s); 17 | 18 | std::string ipAddr; 19 | vector usernames; 20 | vector recentUsernames; 21 | 22 | std::string updateURL; 23 | std::string updateDescription; 24 | void checkForUpdates(); 25 | vector webhookURLList; 26 | 27 | std::string scoreString; 28 | bool scoresEnabled; 29 | bool popupsEnabled; 30 | 31 | 32 | private: 33 | static Config* _instance; 34 | }; -------------------------------------------------------------------------------- /jansson/test/suites/invalid-unicode/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2009-2016 Petri Lehtinen 4 | # 5 | # Jansson is free software; you can redistribute it and/or modify 6 | # it under the terms of the MIT license. See LICENSE for details. 7 | 8 | is_test() { 9 | test -d $test_path 10 | } 11 | 12 | run_test() { 13 | $json_process --env <$test_path/input >$test_log/stdout 2>$test_log/stderr 14 | valgrind_check $test_log/stderr || return 1 15 | cmp -s $test_path/error $test_log/stderr 16 | } 17 | 18 | show_error() { 19 | valgrind_show_error && return 20 | 21 | echo "EXPECTED ERROR:" 22 | nl -bn $test_path/error 23 | echo "ACTUAL ERROR:" 24 | nl -bn $test_log/stderr 25 | } 26 | 27 | . $top_srcdir/test/scripts/run-tests.sh 28 | -------------------------------------------------------------------------------- /jansson/test/suites/api/check-exports: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This test checks that libjansson.so exports the correct symbols. 4 | # 5 | 6 | SOFILE="../src/.libs/libjansson.so" 7 | 8 | # The list of symbols, which the shared object should export, is read 9 | # from the def file, which is used in Windows builds 10 | grep 'json_' $top_srcdir/src/jansson.def \ 11 | | sed -e 's/ //g' \ 12 | | sort \ 13 | >$test_log/exports 14 | 15 | nm -D $SOFILE >/dev/null >$test_log/symbols 2>/dev/null \ 16 | || exit 77 # Skip if "nm -D" doesn't seem to work 17 | 18 | grep ' [DT] ' $test_log/symbols | cut -d' ' -f3 | grep -v '^_' | sort >$test_log/output 19 | 20 | if ! cmp -s $test_log/exports $test_log/output; then 21 | diff -u $test_log/exports $test_log/output >&2 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /jansson/src/utf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef UTF_H 9 | #define UTF_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include 13 | #endif 14 | 15 | #ifdef HAVE_STDINT_H 16 | #include 17 | #endif 18 | 19 | int utf8_encode(int32_t codepoint, char *buffer, size_t *size); 20 | 21 | size_t utf8_check_first(char byte); 22 | size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint); 23 | const char *utf8_iterate(const char *buffer, size_t size, int32_t *codepoint); 24 | 25 | int utf8_check_string(const char *string, size_t length); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /jansson/test/suites/encoding-flags/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2009-2016 Petri Lehtinen 4 | # 5 | # Jansson is free software; you can redistribute it and/or modify 6 | # it under the terms of the MIT license. See LICENSE for details. 7 | 8 | is_test() { 9 | test -d $test_path 10 | } 11 | 12 | run_test() { 13 | ( 14 | if [ -f $test_path/env ]; then 15 | . $test_path/env 16 | fi 17 | $json_process --env <$test_path/input >$test_log/stdout 2>$test_log/stderr 18 | ) 19 | valgrind_check $test_log/stderr || return 1 20 | cmp -s $test_path/output $test_log/stdout 21 | } 22 | 23 | show_error() { 24 | valgrind_show_error && return 25 | 26 | echo "EXPECTED OUTPUT:" 27 | nl -bn $test_path/output 28 | echo "ACTUAL OUTPUT:" 29 | nl -bn $test_log/stdout 30 | } 31 | 32 | . $top_srcdir/test/scripts/run-tests.sh 33 | -------------------------------------------------------------------------------- /jansson/test/suites/api/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2009-2016 Petri Lehtinen 4 | # 5 | # Jansson is free software; you can redistribute it and/or modify 6 | # it under the terms of the MIT license. See LICENSE for details. 7 | 8 | is_test() { 9 | case "$test_name" in 10 | *.c|check-exports) 11 | return 0 12 | ;; 13 | *) 14 | return 1 15 | ;; 16 | esac 17 | } 18 | 19 | run_test() { 20 | if [ "$test_name" = "check-exports" ]; then 21 | test_log=$test_log $test_path >$test_log/stdout 2>$test_log/stderr 22 | else 23 | $test_runner $suite_builddir/${test_name%.c} \ 24 | >$test_log/stdout \ 25 | 2>$test_log/stderr \ 26 | || return 1 27 | valgrind_check $test_log/stderr || return 1 28 | fi 29 | } 30 | 31 | show_error() { 32 | valgrind_show_error && return 33 | cat $test_log/stderr 34 | } 35 | 36 | . $top_srcdir/test/scripts/run-tests.sh 37 | -------------------------------------------------------------------------------- /jansson/test/suites/api/test_sprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "util.h" 4 | 5 | 6 | static void test_sprintf() { 7 | json_t *s = json_sprintf("foo bar %d", 42); 8 | if (!s) 9 | fail("json_sprintf returned NULL"); 10 | if (!json_is_string(s)) 11 | fail("json_sprintf didn't return a JSON string"); 12 | if (strcmp(json_string_value(s), "foo bar 42")) 13 | fail("json_sprintf generated an unexpected string"); 14 | 15 | json_decref(s); 16 | 17 | s = json_sprintf("%s", ""); 18 | if (!s) 19 | fail("json_sprintf returned NULL"); 20 | if (!json_is_string(s)) 21 | fail("json_sprintf didn't return a JSON string"); 22 | if (json_string_length(s) != 0) 23 | fail("string is not empty"); 24 | json_decref(s); 25 | 26 | if (json_sprintf("%s", "\xff\xff")) 27 | fail("json_sprintf unexpected success with invalid UTF"); 28 | } 29 | 30 | 31 | static void run_tests() 32 | { 33 | test_sprintf(); 34 | } 35 | -------------------------------------------------------------------------------- /ScoreTracker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Observer.h" 7 | #include "SC2State.h" 8 | 9 | using namespace std; 10 | 11 | class ScoreWriter; 12 | class ScoreTracker : public Observer { 13 | private: 14 | QTimer* timer; 15 | vector watchers; 16 | QMainWindow* mw; 17 | 18 | public: 19 | explicit ScoreTracker(SC2Data *sc2, QMainWindow* window); 20 | static ScoreTracker* Current(); 21 | ~ScoreTracker(); 22 | std::map < 23 | std::string, 24 | std::map 25 | > scores; 26 | std::string getScoreString(); 27 | void recordScore(std::string race, std::string result); 28 | void handleButton(std::string race, std::string result, std::string name); 29 | void addRandomConfirmMessage(std::string result); 30 | void addConfirmMessage(player* playerA, player* playerB); 31 | void attach(ScoreWriter* sw); 32 | 33 | public slots: 34 | void notify(SC2State*& previous, SC2State*& current); 35 | void updateText(); 36 | std::string getName(); 37 | }; -------------------------------------------------------------------------------- /jansson/src/strbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef STRBUFFER_H 9 | #define STRBUFFER_H 10 | 11 | #include 12 | 13 | typedef struct { 14 | char *value; 15 | size_t length; /* bytes used */ 16 | size_t size; /* bytes allocated */ 17 | } strbuffer_t; 18 | 19 | int strbuffer_init(strbuffer_t *strbuff) JANSSON_ATTRS(warn_unused_result); 20 | void strbuffer_close(strbuffer_t *strbuff); 21 | 22 | void strbuffer_clear(strbuffer_t *strbuff); 23 | 24 | const char *strbuffer_value(const strbuffer_t *strbuff); 25 | 26 | /* Steal the value and close the strbuffer */ 27 | char *strbuffer_steal_value(strbuffer_t *strbuff); 28 | 29 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte); 30 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); 31 | 32 | char strbuffer_pop(strbuffer_t *strbuff); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /jansson/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2018 Petri Lehtinen 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /jansson/test/scripts/valgrind.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2016 Petri Lehtinen 2 | # 3 | # Jansson is free software; you can redistribute it and/or modify 4 | # it under the terms of the MIT license. See LICENSE for details. 5 | 6 | [ -z "$VALGRIND" ] && VALGRIND=0 7 | 8 | VALGRIND_CMDLINE="valgrind --leak-check=full --show-reachable=yes --track-origins=yes -q" 9 | 10 | if [ $VALGRIND -eq 1 ]; then 11 | test_runner="$VALGRIND_CMDLINE" 12 | json_process="$VALGRIND_CMDLINE $json_process" 13 | else 14 | test_runner="" 15 | fi 16 | 17 | valgrind_check() { 18 | if [ $VALGRIND -eq 1 ]; then 19 | # Check for Valgrind error output. The valgrind option 20 | # --error-exitcode is not enough because Valgrind doesn't 21 | # think unfreed allocs are errors. 22 | if grep -E -q '^==[0-9]+== ' $1; then 23 | touch $test_log/valgrind_error 24 | return 1 25 | fi 26 | fi 27 | } 28 | 29 | valgrind_show_error() { 30 | if [ $VALGRIND -eq 1 -a -f $test_log/valgrind_error ]; then 31 | echo "valgrind detected an error" 32 | return 0 33 | fi 34 | return 1 35 | } 36 | -------------------------------------------------------------------------------- /jansson/test/suites/api/test_loadb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #include 9 | #include 10 | #include "util.h" 11 | 12 | static void run_tests() 13 | { 14 | json_t *json; 15 | json_error_t error; 16 | const char str[] = "[\"A\", {\"B\": \"C\"}, 1, 2, 3]garbage"; 17 | size_t len = strlen(str) - strlen("garbage"); 18 | 19 | json = json_loadb(str, len, 0, &error); 20 | if(!json) { 21 | fail("json_loadb failed on a valid JSON buffer"); 22 | } 23 | json_decref(json); 24 | 25 | json = json_loadb(str, len - 1, 0, &error); 26 | if (json) { 27 | json_decref(json); 28 | fail("json_loadb should have failed on an incomplete buffer, but it didn't"); 29 | } 30 | if(error.line != 1) { 31 | fail("json_loadb returned an invalid line number on fail"); 32 | } 33 | if(strcmp(error.text, "']' expected near end of file") != 0) { 34 | fail("json_loadb returned an invalid error message for an unclosed top-level array"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jansson/test/suites/api/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = run check-exports 2 | 3 | check_PROGRAMS = \ 4 | test_array \ 5 | test_chaos \ 6 | test_copy \ 7 | test_dump \ 8 | test_dump_callback \ 9 | test_equal \ 10 | test_load \ 11 | test_loadb \ 12 | test_load_callback \ 13 | test_memory_funcs \ 14 | test_number \ 15 | test_object \ 16 | test_pack \ 17 | test_simple \ 18 | test_sprintf \ 19 | test_unpack 20 | 21 | test_array_SOURCES = test_array.c util.h 22 | test_chaos_SOURCES = test_chaos.c util.h 23 | test_copy_SOURCES = test_copy.c util.h 24 | test_dump_SOURCES = test_dump.c util.h 25 | test_dump_callback_SOURCES = test_dump_callback.c util.h 26 | test_load_SOURCES = test_load.c util.h 27 | test_loadb_SOURCES = test_loadb.c util.h 28 | test_memory_funcs_SOURCES = test_memory_funcs.c util.h 29 | test_number_SOURCES = test_number.c util.h 30 | test_object_SOURCES = test_object.c util.h 31 | test_pack_SOURCES = test_pack.c util.h 32 | test_simple_SOURCES = test_simple.c util.h 33 | test_sprintf_SOURCES = test_sprintf.c util.h 34 | test_unpack_SOURCES = test_unpack.c util.h 35 | 36 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 37 | LDFLAGS = -static # for speed and Valgrind 38 | LDADD = $(top_builddir)/src/libjansson.la 39 | -------------------------------------------------------------------------------- /jansson/test/run-suites: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while [ -n "$1" ]; do 4 | suite=$1 5 | if [ -x $top_srcdir/test/suites/$suite/run ]; then 6 | SUITES="$SUITES $suite" 7 | else 8 | echo "No such suite: $suite" 9 | exit 1 10 | fi 11 | shift 12 | done 13 | 14 | if [ -z "$SUITES" ]; then 15 | suitedirs=$top_srcdir/test/suites/* 16 | for suitedir in $suitedirs; do 17 | if [ -d $suitedir ]; then 18 | SUITES="$SUITES `basename $suitedir`" 19 | fi 20 | done 21 | fi 22 | 23 | [ -z "$STOP" ] && STOP=0 24 | 25 | suites_srcdir=$top_srcdir/test/suites 26 | suites_builddir=suites 27 | scriptdir=$top_srcdir/test/scripts 28 | logdir=logs 29 | bindir=bin 30 | export suites_srcdir suites_builddir scriptdir logdir bindir 31 | 32 | passed=0 33 | failed=0 34 | for suite in $SUITES; do 35 | echo "Suite: $suite" 36 | if $suites_srcdir/$suite/run $suite; then 37 | passed=`expr $passed + 1` 38 | else 39 | failed=`expr $failed + 1` 40 | [ $STOP -eq 1 ] && break 41 | fi 42 | done 43 | 44 | if [ $failed -gt 0 ]; then 45 | echo "$failed of `expr $passed + $failed` test suites failed" 46 | exit 1 47 | else 48 | echo "$passed test suites passed" 49 | rm -rf $logdir 50 | fi 51 | -------------------------------------------------------------------------------- /jansson/cmake/CoverallsClear.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Permission is hereby granted, free of charge, to any person obtaining a copy 3 | # of this software and associated documentation files (the "Software"), to deal 4 | # in the Software without restriction, including without limitation the rights 5 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | # copies of the Software, and to permit persons to whom the Software is 7 | # furnished to do so, subject to the following conditions: 8 | # 9 | # The above copyright notice and this permission notice shall be included in all 10 | # copies or substantial portions of the Software. 11 | # 12 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 | # SOFTWARE. 19 | # 20 | # Copyright (C) 2014 Joakim Söderberg 21 | # 22 | 23 | file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/*.gcda) 24 | 25 | -------------------------------------------------------------------------------- /Constants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // the order is important with these as the labels are not 4 | // in a consistent order in sc2. the scene switcher will 5 | // use whichever it comes accross first. menu consts must 6 | // go first so that they match up to the menuLabels array 7 | // properly. this is kind of bad? 8 | const int MENU_SCORESCREEN = 0; 9 | const int MENU_PROFILE = 1; 10 | const int MENU_LOBBY = 2; 11 | const int MENU_HOME = 3; 12 | const int MENU_CAMPAIGN = 4; 13 | const int MENU_COLLECTION = 5; 14 | const int MENU_COOP = 6; 15 | const int MENU_CUSTOM = 7; 16 | const int MENU_REPLAYS = 8; 17 | const int MENU_VERSUS = 9; 18 | const int MENU_NONE = 10; 19 | 20 | const char* const menuLabels[] = { 21 | "ScreenScore/ScreenScore", 22 | "ScreenUserProfile/ScreenUserProfile", 23 | "ScreenBattleLobby/ScreenBattleLobby", 24 | "ScreenHome/ScreenHome", 25 | "ScreenSingle/ScreenSingle", 26 | "ScreenCollection/ScreenCollection", 27 | "ScreenCoopCampaign/ScreenCoopCampaign", 28 | "ScreenCustom/ScreenCustom", 29 | "ScreenReplay/ScreenReplay", 30 | "ScreenMultiplayer/ScreenMultiplayer", 31 | }; 32 | 33 | const int APP_INGAME = 11; 34 | const int APP_MENU = 12; 35 | const int APP_LOADING = 13; 36 | 37 | const int GAME_INGAME = 14; 38 | const int GAME_OBS = 15; 39 | const int GAME_REPLAY = 16; -------------------------------------------------------------------------------- /jansson/doc/index.rst: -------------------------------------------------------------------------------- 1 | Jansson Documentation 2 | ===================== 3 | 4 | This is the documentation for Jansson_ |release|, last updated |today|. 5 | 6 | Introduction 7 | ------------ 8 | 9 | Jansson_ is a C library for encoding, decoding and manipulating JSON 10 | data. Its main features and design principles are: 11 | 12 | - Simple and intuitive API and data model 13 | 14 | - Comprehensive documentation 15 | 16 | - No dependencies on other libraries 17 | 18 | - Full Unicode support (UTF-8) 19 | 20 | - Extensive test suite 21 | 22 | Jansson is licensed under the `MIT license`_; see LICENSE in the 23 | source distribution for details. 24 | 25 | Jansson is used in production and its API is stable. It works on 26 | numerous platforms, including numerous Unix like systems and Windows. 27 | It's suitable for use on any system, including desktop, server, and 28 | small embedded systems. 29 | 30 | 31 | .. _`MIT license`: http://www.opensource.org/licenses/mit-license.php 32 | .. _Jansson: http://www.digip.org/jansson/ 33 | 34 | Contents 35 | -------- 36 | 37 | .. toctree:: 38 | :maxdepth: 2 39 | 40 | gettingstarted 41 | upgrading 42 | tutorial 43 | conformance 44 | portability 45 | apiref 46 | changes 47 | 48 | 49 | Indices and Tables 50 | ================== 51 | 52 | * :ref:`genindex` 53 | * :ref:`search` 54 | -------------------------------------------------------------------------------- /MainWindow.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ui_MainWindow.h" 3 | 4 | class MainWindow : public QMainWindow 5 | { 6 | Q_OBJECT 7 | public: 8 | explicit MainWindow(QWidget *parent = 0); 9 | ~MainWindow(); 10 | public slots: 11 | void on_ipAddr_textChanged(const QString &name); 12 | void on_addUsernameButton_clicked(); 13 | void on_removeUsernameButton_clicked(); 14 | void on_userNames_itemSelectionChanged(); 15 | void on_recentUsernames_itemSelectionChanged(); 16 | void on_addURLButton_clicked(); 17 | void on_removeURLButton_clicked(); 18 | void on_webhookURLList_itemSelectionChanged(); 19 | void on_textTemplate_textChanged(); 20 | void on_scoresEnabled_stateChanged(int state); 21 | void on_popupsEnabled_stateChanged(int state); 22 | void on_tWinPlus_clicked(); 23 | void on_tWinMinus_clicked(); 24 | void on_tLossPlus_clicked(); 25 | void on_tLossMinus_clicked(); 26 | void on_zWinPlus_clicked(); 27 | void on_zWinMinus_clicked(); 28 | void on_zLossPlus_clicked(); 29 | void on_zLossMinus_clicked(); 30 | void on_pWinPlus_clicked(); 31 | void on_pWinMinus_clicked(); 32 | void on_pLossPlus_clicked(); 33 | void on_pLossMinus_clicked(); 34 | 35 | void updateForm(); 36 | private: 37 | Ui::MainWindow *ui; 38 | bool isLoading = false; 39 | QTimer* timer; 40 | }; -------------------------------------------------------------------------------- /jansson/test/suites/valid/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2009-2016 Petri Lehtinen 4 | # 5 | # Jansson is free software; you can redistribute it and/or modify 6 | # it under the terms of the MIT license. See LICENSE for details. 7 | 8 | JSON_SORT_KEYS=1 9 | export JSON_SORT_KEYS 10 | 11 | is_test() { 12 | test -d $test_path 13 | } 14 | 15 | do_run() { 16 | variant=$1 17 | s=".$1" 18 | 19 | strip=0 20 | [ "$variant" = "strip" ] && strip=1 21 | 22 | STRIP=$strip $json_process --env \ 23 | <$test_path/input >$test_log/stdout$s 2>$test_log/stderr$s 24 | valgrind_check $test_log/stderr$s || return 1 25 | 26 | ref=output 27 | [ -f $test_path/output$s ] && ref=output$s 28 | 29 | if ! cmp -s $test_path/$ref $test_log/stdout$s; then 30 | echo $variant > $test_log/variant 31 | return 1 32 | fi 33 | } 34 | 35 | run_test() { 36 | do_run normal && do_run strip 37 | } 38 | 39 | show_error() { 40 | valgrind_show_error && return 41 | 42 | read variant < $test_log/variant 43 | s=".$variant" 44 | 45 | echo "VARIANT: $variant" 46 | 47 | echo "EXPECTED OUTPUT:" 48 | ref=output 49 | [ -f $test_path/output$s ] && ref=output$s 50 | nl -bn $test_path/$ref 51 | 52 | echo "ACTUAL OUTPUT:" 53 | nl -bn $test_log/stdout$s 54 | } 55 | 56 | . $top_srcdir/test/scripts/run-tests.sh 57 | -------------------------------------------------------------------------------- /jansson/cmake/jansson_private_config.h.cmake: -------------------------------------------------------------------------------- 1 | #cmakedefine HAVE_ENDIAN_H 1 2 | #cmakedefine HAVE_FCNTL_H 1 3 | #cmakedefine HAVE_SCHED_H 1 4 | #cmakedefine HAVE_UNISTD_H 1 5 | #cmakedefine HAVE_SYS_PARAM_H 1 6 | #cmakedefine HAVE_SYS_STAT_H 1 7 | #cmakedefine HAVE_SYS_TIME_H 1 8 | #cmakedefine HAVE_SYS_TYPES_H 1 9 | #cmakedefine HAVE_STDINT_H 1 10 | 11 | #cmakedefine HAVE_CLOSE 1 12 | #cmakedefine HAVE_GETPID 1 13 | #cmakedefine HAVE_GETTIMEOFDAY 1 14 | #cmakedefine HAVE_OPEN 1 15 | #cmakedefine HAVE_READ 1 16 | #cmakedefine HAVE_SCHED_YIELD 1 17 | 18 | #cmakedefine HAVE_SYNC_BUILTINS 1 19 | #cmakedefine HAVE_ATOMIC_BUILTINS 1 20 | 21 | #cmakedefine HAVE_LOCALE_H 1 22 | #cmakedefine HAVE_SETLOCALE 1 23 | 24 | #cmakedefine HAVE_INT32_T 1 25 | #ifndef HAVE_INT32_T 26 | # define int32_t @JSON_INT32@ 27 | #endif 28 | 29 | #cmakedefine HAVE_UINT32_T 1 30 | #ifndef HAVE_UINT32_T 31 | # define uint32_t @JSON_UINT32@ 32 | #endif 33 | 34 | #cmakedefine HAVE_UINT16_T 1 35 | #ifndef HAVE_UINT16_T 36 | # define uint16_t @JSON_UINT16@ 37 | #endif 38 | 39 | #cmakedefine HAVE_UINT8_T 1 40 | #ifndef HAVE_UINT8_T 41 | # define uint8_t @JSON_UINT8@ 42 | #endif 43 | 44 | #cmakedefine HAVE_SSIZE_T 1 45 | 46 | #ifndef HAVE_SSIZE_T 47 | # define ssize_t @JSON_SSIZE@ 48 | #endif 49 | 50 | #cmakedefine USE_URANDOM 1 51 | #cmakedefine USE_WINDOWS_CRYPTOAPI 1 52 | 53 | #define INITIAL_HASHTABLE_ORDER @JANSSON_INITIAL_HASHTABLE_ORDER@ 54 | -------------------------------------------------------------------------------- /jansson/.travis.yml: -------------------------------------------------------------------------------- 1 | env: 2 | matrix: 3 | - JANSSON_BUILD_METHOD=cmake JANSSON_CMAKE_OPTIONS="-DJANSSON_TEST_WITH_VALGRIND=ON" JANSSON_EXTRA_INSTALL="valgrind" 4 | - JANSSON_BUILD_METHOD=autotools 5 | - JANSSON_BUILD_METHOD=coverage JANSSON_CMAKE_OPTIONS="-DJANSSON_COVERAGE=ON -DJANSSON_COVERALLS=ON -DCMAKE_BUILD_TYPE=Debug" JANSSON_EXTRA_INSTALL="lcov curl" 6 | language: c 7 | compiler: 8 | - gcc 9 | - clang 10 | matrix: 11 | exclude: 12 | - compiler: clang 13 | env: JANSSON_BUILD_METHOD=coverage JANSSON_CMAKE_OPTIONS="-DJANSSON_COVERAGE=ON -DJANSSON_COVERALLS=ON -DCMAKE_BUILD_TYPE=Debug" JANSSON_EXTRA_INSTALL="lcov curl" 14 | allow_failures: 15 | - env: JANSSON_BUILD_METHOD=coverage JANSSON_CMAKE_OPTIONS="-DJANSSON_COVERAGE=ON -DJANSSON_COVERALLS=ON -DCMAKE_BUILD_TYPE=Debug" JANSSON_EXTRA_INSTALL="lcov curl" 16 | install: 17 | - sudo apt-get update -qq 18 | - sudo apt-get install -y -qq cmake $JANSSON_EXTRA_INSTALL 19 | script: 20 | - if [ "$JANSSON_BUILD_METHOD" = "autotools" ]; then autoreconf -f -i && CFLAGS=-Werror ./configure && make check; fi 21 | - if [ "$JANSSON_BUILD_METHOD" = "cmake" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && ctest --output-on-failure; fi 22 | - if [ "$JANSSON_BUILD_METHOD" = "coverage" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && cmake --build . --target coveralls; fi 23 | -------------------------------------------------------------------------------- /jansson/test/suites/invalid/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2009-2016 Petri Lehtinen 4 | # 5 | # Jansson is free software; you can redistribute it and/or modify 6 | # it under the terms of the MIT license. See LICENSE for details. 7 | 8 | is_test() { 9 | test -d $test_path 10 | } 11 | 12 | do_run() { 13 | variant=$1 14 | s=".$1" 15 | 16 | strip=0 17 | if [ "$variant" = "strip" ]; then 18 | # This test should not be stripped 19 | [ -f $test_path/nostrip ] && return 20 | strip=1 21 | fi 22 | 23 | STRIP=$strip $json_process --env \ 24 | <$test_path/input >$test_log/stdout$s 2>$test_log/stderr$s 25 | valgrind_check $test_log/stderr$s || return 1 26 | 27 | ref=error 28 | [ -f $test_path/error$s ] && ref=error$s 29 | 30 | if ! cmp -s $test_path/$ref $test_log/stderr$s; then 31 | echo $variant > $test_log/variant 32 | return 1 33 | fi 34 | } 35 | 36 | run_test() { 37 | do_run normal && do_run strip 38 | } 39 | 40 | show_error() { 41 | valgrind_show_error && return 42 | 43 | read variant < $test_log/variant 44 | s=".$variant" 45 | 46 | echo "VARIANT: $variant" 47 | 48 | echo "EXPECTED ERROR:" 49 | ref=error 50 | [ -f $test_path/error$s ] && ref=error$s 51 | nl -bn $test_path/$ref 52 | 53 | echo "ACTUAL ERROR:" 54 | nl -bn $test_log/stderr$s 55 | } 56 | 57 | . $top_srcdir/test/scripts/run-tests.sh 58 | -------------------------------------------------------------------------------- /jansson/android/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | 21 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 22 | defined to `inline', otherwise empty. In C++, the inline is always 23 | supported. */ 24 | #ifdef __cplusplus 25 | #define JSON_INLINE inline 26 | #else 27 | #define JSON_INLINE inline 28 | #endif 29 | 30 | /* If your compiler supports the `long long` type and the strtoll() 31 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 32 | otherwise to 0. */ 33 | #define JSON_INTEGER_IS_LONG_LONG 1 34 | 35 | /* If locale.h and localeconv() are available, define to 1, 36 | otherwise to 0. */ 37 | #define JSON_HAVE_LOCALECONV 0 38 | 39 | /* Maximum recursion depth for parsing JSON input. 40 | This limits the depth of e.g. array-within-array constructions. */ 41 | #define JSON_PARSER_MAX_DEPTH 2048 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | set(CMAKE_AUTOMOC ON) 3 | project(webhook) 4 | 5 | list(APPEND CMAKE_MODULE_PATH "${OBS_CMAKE_MODULES_PATH}/") 6 | find_package(Libcurl REQUIRED) 7 | include_directories(${LIBCURL_INCLUDE_DIRS}) 8 | 9 | add_subdirectory(jansson) 10 | 11 | set(OBS_JANSSON_IMPORT "jansson" CACHE INTERNAL "Internal var") 12 | set(OBS_JANSSON_INCLUDE_DIRS "" CACHE INTERNAL "Internal var") 13 | include_directories(${JANSSON_INCLUDE_DIRS}) 14 | 15 | 16 | set(webhook_HEADERS 17 | ${webhook_HEADERS} 18 | SC2Data.h 19 | Observer.h 20 | SC2State.h 21 | Constants.h 22 | Webhook.h 23 | Config.h 24 | ScoreTracker.h 25 | MainWindow.h 26 | FileScoreWriter.h 27 | ScoreTracker.h 28 | ScoreWriter.h 29 | ) 30 | set(webhook_SOURCES 31 | ${webhook_SOURCES} 32 | main.cpp 33 | SC2Data.cpp 34 | SC2State.cpp 35 | Webhook.cpp 36 | Config.cpp 37 | ScoreTracker.cpp 38 | MainWindow.cpp 39 | FileScoreWriter.cpp 40 | ) 41 | set(webhook_UI 42 | ${webhook_UI} 43 | MainWindow.ui 44 | ) 45 | 46 | set(webhook_PLATFORM_LIBS 47 | ${OBS_JANSSON_IMPORT} 48 | ) 49 | 50 | find_package(Qt5 COMPONENTS Widgets REQUIRED) 51 | qt5_wrap_ui(webhook_UI_HEADERS 52 | ${webhook_UI}) 53 | 54 | add_executable(webhook WIN32 55 | ${webhook_HEADERS} 56 | ${webhook_SOURCES} 57 | ${webhook_UI_HEADERS} 58 | ${webhook_PLATFORM_SOURCES} 59 | ${webhook_PLATFORM_HEADERS} 60 | ) 61 | 62 | 63 | target_link_libraries(webhook 64 | ${webhook_PLATFORM_LIBS} 65 | Qt5::Widgets 66 | ${LIBCURL_LIBRARIES}) 67 | -------------------------------------------------------------------------------- /jansson/src/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * Copyright (c) 2011-2012 Basile Starynkevitch 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify it 6 | * under the terms of the MIT license. See LICENSE for details. 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include "jansson.h" 13 | #include "jansson_private.h" 14 | 15 | /* C89 allows these to be macros */ 16 | #undef malloc 17 | #undef free 18 | 19 | /* memory function pointers */ 20 | static json_malloc_t do_malloc = malloc; 21 | static json_free_t do_free = free; 22 | 23 | void *jsonp_malloc(size_t size) 24 | { 25 | if(!size) 26 | return NULL; 27 | 28 | return (*do_malloc)(size); 29 | } 30 | 31 | void jsonp_free(void *ptr) 32 | { 33 | if(!ptr) 34 | return; 35 | 36 | (*do_free)(ptr); 37 | } 38 | 39 | char *jsonp_strdup(const char *str) 40 | { 41 | return jsonp_strndup(str, strlen(str)); 42 | } 43 | 44 | char *jsonp_strndup(const char *str, size_t len) 45 | { 46 | char *new_str; 47 | 48 | new_str = jsonp_malloc(len + 1); 49 | if(!new_str) 50 | return NULL; 51 | 52 | memcpy(new_str, str, len); 53 | new_str[len] = '\0'; 54 | return new_str; 55 | } 56 | 57 | void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) 58 | { 59 | do_malloc = malloc_fn; 60 | do_free = free_fn; 61 | } 62 | 63 | void json_get_alloc_funcs(json_malloc_t *malloc_fn, json_free_t *free_fn) 64 | { 65 | if (malloc_fn) 66 | *malloc_fn = do_malloc; 67 | if (free_fn) 68 | *free_fn = do_free; 69 | } 70 | -------------------------------------------------------------------------------- /jansson/src/jansson.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | json_delete 3 | json_true 4 | json_false 5 | json_null 6 | json_sprintf 7 | json_vsprintf 8 | json_string 9 | json_stringn 10 | json_string_nocheck 11 | json_stringn_nocheck 12 | json_string_value 13 | json_string_length 14 | json_string_set 15 | json_string_setn 16 | json_string_set_nocheck 17 | json_string_setn_nocheck 18 | json_integer 19 | json_integer_value 20 | json_integer_set 21 | json_real 22 | json_real_value 23 | json_real_set 24 | json_number_value 25 | json_array 26 | json_array_size 27 | json_array_get 28 | json_array_set_new 29 | json_array_append_new 30 | json_array_insert_new 31 | json_array_remove 32 | json_array_clear 33 | json_array_extend 34 | json_object 35 | json_object_size 36 | json_object_get 37 | json_object_set_new 38 | json_object_set_new_nocheck 39 | json_object_del 40 | json_object_clear 41 | json_object_update 42 | json_object_update_existing 43 | json_object_update_missing 44 | json_object_iter 45 | json_object_iter_at 46 | json_object_iter_next 47 | json_object_iter_key 48 | json_object_iter_value 49 | json_object_iter_set_new 50 | json_object_key_to_iter 51 | json_object_seed 52 | json_dumps 53 | json_dumpb 54 | json_dumpf 55 | json_dumpfd 56 | json_dump_file 57 | json_dump_callback 58 | json_loads 59 | json_loadb 60 | json_loadf 61 | json_loadfd 62 | json_load_file 63 | json_load_callback 64 | json_equal 65 | json_copy 66 | json_deep_copy 67 | json_pack 68 | json_pack_ex 69 | json_vpack_ex 70 | json_unpack 71 | json_unpack_ex 72 | json_vunpack_ex 73 | json_set_alloc_funcs 74 | json_get_alloc_funcs 75 | 76 | -------------------------------------------------------------------------------- /jansson/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to easily make releases of Jansson. It configures 4 | # the source tree, and builds and signs all tarballs. 5 | 6 | die() { 7 | echo $1 >&2 8 | exit 1 9 | } 10 | 11 | confirm() { 12 | local answer 13 | read -p "$1 [yN]: " answer 14 | [ "$answer" = "Y" -o "$answer" = "y" ] || exit 0 15 | } 16 | 17 | set -e 18 | [ -f configure.ac ] || die "Must be run at project root directory" 19 | 20 | # Determine version 21 | v=$(grep AC_INIT configure.ac | sed -r 's/.*, \[(.+?)\],.*/\1/') 22 | [ -n "$v" ] || die "Unable to determine version" 23 | confirm "Version is $v, proceed?" 24 | 25 | # Sanity checks 26 | vi=$(grep version-info src/Makefile.am | sed 's/^[ \t]*//g' | cut -d" " -f2) 27 | confirm "Libtool version-info is $vi, proceed?" 28 | 29 | r=$(grep 'Released ' CHANGES | head -n 1) 30 | confirm "Last CHANGES entry says \"$r\", proceed??" 31 | 32 | dv=$(grep ^version doc/conf.py | sed -r "s/.*'(.*)'.*/\1/") 33 | if [ "$dv" != "$v" ]; then 34 | die "Documentation version ($dv) doesn't match library version" 35 | fi 36 | 37 | [ -f Makefile ] && make distclean || true 38 | rm -f jansson-$v.tar.* 39 | rm -rf jansson-$v-doc 40 | rm -f jansson-$v-doc.tar.* 41 | 42 | autoreconf -fi 43 | ./configure 44 | 45 | # Run tests and make gz source tarball 46 | : ${VALGRIND:=1} 47 | export VALGRIND 48 | make distcheck 49 | 50 | # Make bzip2 source tarball 51 | make dist-bzip2 52 | 53 | # Sign source tarballs 54 | for s in gz bz2; do 55 | gpg --detach-sign --armor jansson-$v.tar.$s 56 | done 57 | 58 | # Build documentation 59 | make html 60 | mv doc/_build/html jansson-$v-doc 61 | 62 | # Make and sign documentation tarballs 63 | for s in gz bz2; do 64 | [ $s = gz ] && compress=gzip 65 | [ $s = bz2 ] && compress=bzip2 66 | tar cf - jansson-$v-doc | $compress -9 -c > jansson-$v-doc.tar.$s 67 | gpg --detach-sign --armor jansson-$v-doc.tar.$s 68 | done 69 | 70 | echo "All done" 71 | -------------------------------------------------------------------------------- /jansson/src/jansson_config.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | 21 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 22 | defined to `inline', otherwise empty. In C++, the inline is always 23 | supported. */ 24 | #ifdef __cplusplus 25 | #define JSON_INLINE inline 26 | #else 27 | #define JSON_INLINE @json_inline@ 28 | #endif 29 | 30 | /* If your compiler supports the `long long` type and the strtoll() 31 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 32 | otherwise to 0. */ 33 | #define JSON_INTEGER_IS_LONG_LONG @json_have_long_long@ 34 | 35 | /* If locale.h and localeconv() are available, define to 1, 36 | otherwise to 0. */ 37 | #define JSON_HAVE_LOCALECONV @json_have_localeconv@ 38 | 39 | /* If __atomic builtins are available they will be used to manage 40 | reference counts of json_t. */ 41 | #define JSON_HAVE_ATOMIC_BUILTINS @json_have_atomic_builtins@ 42 | 43 | /* If __atomic builtins are not available we try using __sync builtins 44 | to manage reference counts of json_t. */ 45 | #define JSON_HAVE_SYNC_BUILTINS @json_have_sync_builtins@ 46 | 47 | /* Maximum recursion depth for parsing JSON input. 48 | This limits the depth of e.g. array-within-array constructions. */ 49 | #define JSON_PARSER_MAX_DEPTH 2048 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /jansson/src/error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "jansson_private.h" 3 | 4 | void jsonp_error_init(json_error_t *error, const char *source) 5 | { 6 | if(error) 7 | { 8 | error->text[0] = '\0'; 9 | error->line = -1; 10 | error->column = -1; 11 | error->position = 0; 12 | if(source) 13 | jsonp_error_set_source(error, source); 14 | else 15 | error->source[0] = '\0'; 16 | } 17 | } 18 | 19 | void jsonp_error_set_source(json_error_t *error, const char *source) 20 | { 21 | size_t length; 22 | 23 | if(!error || !source) 24 | return; 25 | 26 | length = strlen(source); 27 | if(length < JSON_ERROR_SOURCE_LENGTH) 28 | strncpy(error->source, source, length + 1); 29 | else { 30 | size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; 31 | memcpy(error->source, "...", 3); 32 | strncpy(error->source + 3, source + extra, length - extra + 1); 33 | } 34 | } 35 | 36 | void jsonp_error_set(json_error_t *error, int line, int column, 37 | size_t position, enum json_error_code code, 38 | const char *msg, ...) 39 | { 40 | va_list ap; 41 | 42 | va_start(ap, msg); 43 | jsonp_error_vset(error, line, column, position, code, msg, ap); 44 | va_end(ap); 45 | } 46 | 47 | void jsonp_error_vset(json_error_t *error, int line, int column, 48 | size_t position, enum json_error_code code, 49 | const char *msg, va_list ap) 50 | { 51 | if(!error) 52 | return; 53 | 54 | if(error->text[0] != '\0') { 55 | /* error already set */ 56 | return; 57 | } 58 | 59 | error->line = line; 60 | error->column = column; 61 | error->position = (int)position; 62 | 63 | vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH - 1, msg, ap); 64 | error->text[JSON_ERROR_TEXT_LENGTH - 2] = '\0'; 65 | error->text[JSON_ERROR_TEXT_LENGTH - 1] = code; 66 | } 67 | -------------------------------------------------------------------------------- /jansson/doc/ext/refcounting.py: -------------------------------------------------------------------------------- 1 | """ 2 | refcounting 3 | ~~~~~~~~~~~ 4 | 5 | Reference count annotations for C API functions. Has the same 6 | result as the sphinx.ext.refcounting extension but works for all 7 | functions regardless of the signature, and the reference counting 8 | information is written inline with the documentation instead of a 9 | separate file. 10 | 11 | Adds a new directive "refcounting". The directive has no content 12 | and one required positional parameter:: "new" or "borrow". 13 | 14 | Example: 15 | 16 | .. cfunction:: json_t *json_object(void) 17 | 18 | .. refcounting:: new 19 | 20 | 21 | 22 | :copyright: Copyright (c) 2009-2016 Petri Lehtinen 23 | :license: MIT, see LICENSE for details. 24 | """ 25 | 26 | from docutils import nodes 27 | 28 | class refcounting(nodes.emphasis): pass 29 | 30 | def visit(self, node): 31 | self.visit_emphasis(node) 32 | 33 | def depart(self, node): 34 | self.depart_emphasis(node) 35 | 36 | def html_visit(self, node): 37 | self.body.append(self.starttag(node, 'em', '', CLASS='refcount')) 38 | 39 | def html_depart(self, node): 40 | self.body.append('') 41 | 42 | 43 | def refcounting_directive(name, arguments, options, content, lineno, 44 | content_offset, block_text, state, state_machine): 45 | if arguments[0] == 'borrow': 46 | text = 'Return value: Borrowed reference.' 47 | elif arguments[0] == 'new': 48 | text = 'Return value: New reference.' 49 | else: 50 | raise Error('Valid arguments: new, borrow') 51 | 52 | return [refcounting(text, text)] 53 | 54 | def setup(app): 55 | app.add_node(refcounting, 56 | html=(html_visit, html_depart), 57 | latex=(visit, depart), 58 | text=(visit, depart), 59 | man=(visit, depart)) 60 | app.add_directive('refcounting', refcounting_directive, 0, (1, 0, 0)) 61 | -------------------------------------------------------------------------------- /jansson/README.rst: -------------------------------------------------------------------------------- 1 | Jansson README 2 | ============== 3 | 4 | .. image:: https://travis-ci.org/akheron/jansson.png 5 | :target: https://travis-ci.org/akheron/jansson 6 | 7 | .. image:: https://ci.appveyor.com/api/projects/status/lmhkkc4q8cwc65ko 8 | :target: https://ci.appveyor.com/project/akheron/jansson 9 | 10 | .. image:: https://coveralls.io/repos/akheron/jansson/badge.png?branch=master 11 | :target: https://coveralls.io/r/akheron/jansson?branch=master 12 | 13 | Jansson_ is a C library for encoding, decoding and manipulating JSON 14 | data. Its main features and design principles are: 15 | 16 | - Simple and intuitive API and data model 17 | 18 | - `Comprehensive documentation`_ 19 | 20 | - No dependencies on other libraries 21 | 22 | - Full Unicode support (UTF-8) 23 | 24 | - Extensive test suite 25 | 26 | Jansson is licensed under the `MIT license`_; see LICENSE in the 27 | source distribution for details. 28 | 29 | 30 | Compilation and Installation 31 | ---------------------------- 32 | 33 | If you obtained a source tarball, just use the standard autotools 34 | commands:: 35 | 36 | $ ./configure 37 | $ make 38 | $ make install 39 | 40 | To run the test suite, invoke:: 41 | 42 | $ make check 43 | 44 | If the source has been checked out from a Git repository, the 45 | ./configure script has to be generated first. The easiest way is to 46 | use autoreconf:: 47 | 48 | $ autoreconf -i 49 | 50 | 51 | Documentation 52 | ------------- 53 | 54 | Documentation is available at http://jansson.readthedocs.io/en/latest/. 55 | 56 | The documentation source is in the ``doc/`` subdirectory. To generate 57 | HTML documentation, invoke:: 58 | 59 | $ make html 60 | 61 | Then, point your browser to ``doc/_build/html/index.html``. Sphinx_ 62 | 1.0 or newer is required to generate the documentation. 63 | 64 | 65 | .. _Jansson: http://www.digip.org/jansson/ 66 | .. _`Comprehensive documentation`: http://jansson.readthedocs.io/en/latest/ 67 | .. _`MIT license`: http://www.opensource.org/licenses/mit-license.php 68 | .. _Sphinx: http://sphinx.pocoo.org/ 69 | -------------------------------------------------------------------------------- /jansson/test/suites/api/test_dump_callback.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "util.h" 12 | 13 | struct my_sink { 14 | char *buf; 15 | size_t off; 16 | size_t cap; 17 | }; 18 | 19 | static int my_writer(const char *buffer, size_t len, void *data) { 20 | struct my_sink *s = data; 21 | if (len > s->cap - s->off) { 22 | return -1; 23 | } 24 | memcpy(s->buf + s->off, buffer, len); 25 | s->off += len; 26 | return 0; 27 | } 28 | 29 | static void run_tests() 30 | { 31 | struct my_sink s; 32 | json_t *json; 33 | const char str[] = "[\"A\", {\"B\": \"C\", \"e\": false}, 1, null, \"foo\"]"; 34 | char *dumped_to_string; 35 | 36 | json = json_loads(str, 0, NULL); 37 | if(!json) { 38 | fail("json_loads failed"); 39 | } 40 | 41 | dumped_to_string = json_dumps(json, 0); 42 | if (!dumped_to_string) { 43 | json_decref(json); 44 | fail("json_dumps failed"); 45 | } 46 | 47 | s.off = 0; 48 | s.cap = strlen(dumped_to_string); 49 | s.buf = malloc(s.cap); 50 | if (!s.buf) { 51 | json_decref(json); 52 | free(dumped_to_string); 53 | fail("malloc failed"); 54 | } 55 | 56 | if (json_dump_callback(json, my_writer, &s, 0) == -1) { 57 | json_decref(json); 58 | free(dumped_to_string); 59 | free(s.buf); 60 | fail("json_dump_callback failed on an exact-length sink buffer"); 61 | } 62 | 63 | if (strncmp(dumped_to_string, s.buf, s.off) != 0) { 64 | json_decref(json); 65 | free(dumped_to_string); 66 | free(s.buf); 67 | fail("json_dump_callback and json_dumps did not produce identical output"); 68 | } 69 | 70 | s.off = 1; 71 | if (json_dump_callback(json, my_writer, &s, 0) != -1) { 72 | json_decref(json); 73 | free(dumped_to_string); 74 | free(s.buf); 75 | fail("json_dump_callback succeeded on a short buffer when it should have failed"); 76 | } 77 | 78 | json_decref(json); 79 | free(dumped_to_string); 80 | free(s.buf); 81 | } 82 | -------------------------------------------------------------------------------- /jansson/test/suites/api/test_load_callback.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2011 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "util.h" 12 | 13 | struct my_source { 14 | const char *buf; 15 | size_t off; 16 | size_t cap; 17 | }; 18 | 19 | static const char my_str[] = "[\"A\", {\"B\": \"C\", \"e\": false}, 1, null, \"foo\"]"; 20 | 21 | static size_t greedy_reader(void *buf, size_t buflen, void *arg) 22 | { 23 | struct my_source *s = arg; 24 | if (buflen > s->cap - s->off) 25 | buflen = s->cap - s->off; 26 | if (buflen > 0) { 27 | memcpy(buf, s->buf + s->off, buflen); 28 | s->off += buflen; 29 | return buflen; 30 | } else { 31 | return 0; 32 | } 33 | } 34 | 35 | static void run_tests() 36 | { 37 | struct my_source s; 38 | json_t *json; 39 | json_error_t error; 40 | 41 | s.off = 0; 42 | s.cap = strlen(my_str); 43 | s.buf = my_str; 44 | 45 | json = json_load_callback(greedy_reader, &s, 0, &error); 46 | 47 | if (!json) 48 | fail("json_load_callback failed on a valid callback"); 49 | json_decref(json); 50 | 51 | s.off = 0; 52 | s.cap = strlen(my_str) - 1; 53 | s.buf = my_str; 54 | 55 | json = json_load_callback(greedy_reader, &s, 0, &error); 56 | if (json) { 57 | json_decref(json); 58 | fail("json_load_callback should have failed on an incomplete stream, but it didn't"); 59 | } 60 | if (strcmp(error.source, "") != 0) { 61 | fail("json_load_callback returned an invalid error source"); 62 | } 63 | if (strcmp(error.text, "']' expected near end of file") != 0) { 64 | fail("json_load_callback returned an invalid error message for an unclosed top-level array"); 65 | } 66 | 67 | json = json_load_callback(NULL, NULL, 0, &error); 68 | if (json) { 69 | json_decref(json); 70 | fail("json_load_callback should have failed on NULL load callback, but it didn't"); 71 | } 72 | if (strcmp(error.text, "wrong arguments") != 0) { 73 | fail("json_load_callback returned an invalid error message for a NULL load callback"); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /jansson/CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | # ************************************************ 48 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 49 | # ************************************************ 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## SC2Switcher Webhook Standalone 2 | 3 | ## [Download](https://github.com/leigholiver/SC2Switcher-Standalone/releases/latest/) 4 | 5 | ## Installation: 6 | Double click webhook.exe 7 | 8 | ### Game Webhook 9 | - When entering or leaving a game, the plugin will send a request to the specified url with information about the game for use in other applications 10 | - For an example of how this could be used you could check out [Ladderbet](https://github.com/leigholiver/ladderbet/), an automated twitch chat betting bot 11 | 12 | ``` 13 | event: 'enter' or 'exit', 14 | displayTime: ~, 15 | players: [ 16 | { 17 | 'name': ~, 18 | 'type': ~, 19 | 'race': 'Terr', 'Zerg' or 'Prot', 20 | 'result': 'Victory' or 'Defeat', 21 | 'isme': 'true' or 'false', 22 | }, 23 | ] 24 | scores: { 25 | 'Terr', 'Zerg' or 'Prot': { 26 | "Victory": ~, 27 | "Defeat": ~ 28 | }, 29 | } 30 | ``` 31 | - Known issue: Scores may not update until the start of the next game if you change the score manually or come across one of the situations mentioned in the Score Tracker section 32 | 33 | 34 | ### Score Tracker 35 | - The `scores.txt` file will be updated with your session scores (mostly) automatically 36 | - If you play against a random player the plugin will ask you for their race 37 | - If you are neither player or both players (ie barcodes), the plugin will ask which player you were 38 | - There is a small chance that these notifications will take focus over sc2. If this is an issue you can untick 'Popups Enabled' and these will be ignored. You can use the buttons to update the score manually 39 | 40 | 41 | ## If you use a separate PC to stream: 42 | Enter the IP address of your SC2 computer in the SC2 PC IP box. 43 | On your SC2 PC, open the Battle.net launcher, click Options, Game Settings, and under SC2, check 'Additional Command Line Arguments', and enter `-clientapi 6119` into the text box. 44 | 45 | You can check that SC2 is configured correctly by going to `http://[Your SC2 PC IP]:6119/ui` in your browser on the streaming PC. It should look something like: 46 | `{"activeScreens":["ScreenBackgroundSC2/ScreenBackgroundSC2","ScreenReplay/ScreenReplay","ScreenNavigationSC2/ScreenNavigationSC2","ScreenForegroundSC2/ScreenForegroundSC2","ScreenBattlenet/ScreenBattlenet"]}`. 47 | 48 | 49 | ## Build 50 | In cmake set the following variables: 51 | Qt5_DIR [qt directory]/msvc2013_64/lib/cmake/Qt5 52 | OBS_CMAKE_MODULES_PATH [obs-studio source direcrory]\cmake\Modules -------------------------------------------------------------------------------- /jansson/include/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The CMake system will generate the jansson_config.h file and 13 | * copy it to the build and install directories. 14 | */ 15 | 16 | #ifndef JANSSON_CONFIG_H 17 | #define JANSSON_CONFIG_H 18 | 19 | /* Define this so that we can disable scattered automake configuration in source files */ 20 | #ifndef JANSSON_USING_CMAKE 21 | #define JANSSON_USING_CMAKE 22 | #endif 23 | 24 | /* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used, 25 | * as we will also check for __int64 etc types. 26 | * (the definition was used in the automake system) */ 27 | 28 | /* Bring in the cmake-detected defines */ 29 | #define HAVE_STDINT_H 1 30 | /* #undef HAVE_INTTYPES_H */ 31 | #define HAVE_SYS_TYPES_H 1 32 | 33 | /* Include our standard type header for the integer typedef */ 34 | 35 | #if defined(HAVE_STDINT_H) 36 | # include 37 | #elif defined(HAVE_INTTYPES_H) 38 | # include 39 | #elif defined(HAVE_SYS_TYPES_H) 40 | # include 41 | #endif 42 | 43 | 44 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 45 | defined to `inline', otherwise empty. In C++, the inline is always 46 | supported. */ 47 | #ifdef __cplusplus 48 | #define JSON_INLINE inline 49 | #else 50 | #define JSON_INLINE __inline 51 | #endif 52 | 53 | 54 | #define json_int_t long long 55 | #define json_strtoint strtoll 56 | #define JSON_INTEGER_FORMAT "I64d" 57 | 58 | 59 | /* If locale.h and localeconv() are available, define to 1, otherwise to 0. */ 60 | #define JSON_HAVE_LOCALECONV 1 61 | 62 | /* If __atomic builtins are available they will be used to manage 63 | reference counts of json_t. */ 64 | #define JSON_HAVE_ATOMIC_BUILTINS 0 65 | 66 | /* If __atomic builtins are not available we try using __sync builtins 67 | to manage reference counts of json_t. */ 68 | #define JSON_HAVE_SYNC_BUILTINS 0 69 | 70 | /* Maximum recursion depth for parsing JSON input. 71 | This limits the depth of e.g. array-within-array constructions. */ 72 | #define JSON_PARSER_MAX_DEPTH 2048 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /jansson/cmake/jansson_config.h.cmake: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The CMake system will generate the jansson_config.h file and 13 | * copy it to the build and install directories. 14 | */ 15 | 16 | #ifndef JANSSON_CONFIG_H 17 | #define JANSSON_CONFIG_H 18 | 19 | /* Define this so that we can disable scattered automake configuration in source files */ 20 | #ifndef JANSSON_USING_CMAKE 21 | #define JANSSON_USING_CMAKE 22 | #endif 23 | 24 | /* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used, 25 | * as we will also check for __int64 etc types. 26 | * (the definition was used in the automake system) */ 27 | 28 | /* Bring in the cmake-detected defines */ 29 | #cmakedefine HAVE_STDINT_H 1 30 | #cmakedefine HAVE_INTTYPES_H 1 31 | #cmakedefine HAVE_SYS_TYPES_H 1 32 | 33 | /* Include our standard type header for the integer typedef */ 34 | 35 | #if defined(HAVE_STDINT_H) 36 | # include 37 | #elif defined(HAVE_INTTYPES_H) 38 | # include 39 | #elif defined(HAVE_SYS_TYPES_H) 40 | # include 41 | #endif 42 | 43 | 44 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 45 | defined to `inline', otherwise empty. In C++, the inline is always 46 | supported. */ 47 | #ifdef __cplusplus 48 | #define JSON_INLINE inline 49 | #else 50 | #define JSON_INLINE @JSON_INLINE@ 51 | #endif 52 | 53 | 54 | #define json_int_t @JSON_INT_T@ 55 | #define json_strtoint @JSON_STRTOINT@ 56 | #define JSON_INTEGER_FORMAT @JSON_INTEGER_FORMAT@ 57 | 58 | 59 | /* If locale.h and localeconv() are available, define to 1, otherwise to 0. */ 60 | #define JSON_HAVE_LOCALECONV @JSON_HAVE_LOCALECONV@ 61 | 62 | /* If __atomic builtins are available they will be used to manage 63 | reference counts of json_t. */ 64 | #define JSON_HAVE_ATOMIC_BUILTINS @JSON_HAVE_ATOMIC_BUILTINS@ 65 | 66 | /* If __atomic builtins are not available we try using __sync builtins 67 | to manage reference counts of json_t. */ 68 | #define JSON_HAVE_SYNC_BUILTINS @JSON_HAVE_SYNC_BUILTINS@ 69 | 70 | /* Maximum recursion depth for parsing JSON input. 71 | This limits the depth of e.g. array-within-array constructions. */ 72 | #define JSON_PARSER_MAX_DEPTH 2048 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /SC2Data.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "SC2Data.h" 7 | #include "SC2State.h" 8 | #include "Observer.h" 9 | #include "Config.h" 10 | 11 | QT_USE_NAMESPACE 12 | 13 | SC2Data* SC2Data::Instance = nullptr; 14 | 15 | SC2Data::SC2Data(QObject* parent) 16 | : QObject(parent) 17 | { 18 | timer = new QTimer(this); 19 | connect(timer, SIGNAL(timeout()), this, SLOT(update())); 20 | timer->start(1000); 21 | state = nullptr; 22 | } 23 | 24 | SC2Data::~SC2Data() { 25 | delete Instance; 26 | } 27 | 28 | void SC2Data::attach(Observer *obs) { 29 | watchers.push_back(obs); 30 | } 31 | 32 | static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) 33 | { 34 | ((std::string*)userp)->append((char*)contents, size * nmemb); 35 | return size * nmemb; 36 | } 37 | 38 | void SC2Data::update() { 39 | Config* config = Config::Current(); 40 | CURL *curl; 41 | CURLcode res; 42 | std::string reqURL; 43 | std::string UIResponse; 44 | std::string gameResponse; 45 | 46 | reqURL = config->ipAddr; 47 | if(reqURL == "") { 48 | reqURL = "localhost"; 49 | } 50 | reqURL = "http://" + reqURL + ":6119/"; 51 | 52 | curl = curl_easy_init(); 53 | if (curl) { 54 | std::string url = reqURL + "ui"; 55 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); 56 | curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 100); 57 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); 58 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &UIResponse); 59 | res = curl_easy_perform(curl); 60 | //curl_easy_cleanup(curl); 61 | if (res != CURLE_OK) { 62 | curl_easy_cleanup(curl); 63 | return; 64 | } 65 | } 66 | curl_easy_reset(curl); 67 | if (curl) { 68 | std::string url = reqURL + "game"; 69 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); 70 | curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 100); 71 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); 72 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &gameResponse); 73 | res = curl_easy_perform(curl); 74 | curl_easy_cleanup(curl); 75 | if (res != CURLE_OK) { 76 | return; 77 | } 78 | } 79 | 80 | // create an sc2state object 81 | SC2State* newState = new SC2State(); 82 | newState->fromJSONString(UIResponse, gameResponse); 83 | if(state == nullptr) { 84 | state = newState; 85 | } 86 | 87 | if(state->appState != newState->appState || 88 | state->gameState != newState->gameState || 89 | state->menuState != newState->menuState ) { 90 | for (size_t i = 0; i < watchers.size(); i++) { 91 | watchers[i]->notify(state, newState); 92 | } 93 | state = newState; 94 | } 95 | } -------------------------------------------------------------------------------- /jansson/test/scripts/run-tests.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2016 Petri Lehtinen 2 | # 3 | # Jansson is free software; you can redistribute it and/or modify 4 | # it under the terms of the MIT license. See LICENSE for details. 5 | 6 | die() { 7 | echo "$1" >&2 8 | exit 1 9 | } 10 | 11 | [ -n "$1" ] || die "Usage: $0 suite-name" 12 | [ -n "$bindir" ] || die "Set bindir" 13 | [ -n "$logdir" ] || die "Set logdir" 14 | [ -n "$scriptdir" ] || die "Set scriptdir" 15 | [ -n "$suites_srcdir" ] || die "Set suites_srcdir" 16 | [ -n "$suites_builddir" ] || die "Set suites_builddir" 17 | 18 | json_process=$bindir/json_process 19 | 20 | suite_name=$1 21 | suite_srcdir=$suites_srcdir/$suite_name 22 | suite_builddir=$suites_builddir/$suite_name 23 | suite_log=$logdir/$suite_name 24 | 25 | [ -z "$VERBOSE" ] && VERBOSE=0 26 | [ -z "$STOP" ] && STOP=0 27 | 28 | . $scriptdir/valgrind.sh 29 | 30 | rm -rf $suite_log 31 | mkdir -p $suite_log 32 | 33 | for test_path in $suite_srcdir/*; do 34 | test_name=$(basename $test_path) 35 | test_builddir=$suite_builddir/$test_name 36 | test_log=$suite_log/$test_name 37 | 38 | [ "$test_name" = "run" ] && continue 39 | is_test || continue 40 | 41 | rm -rf $test_log 42 | mkdir -p $test_log 43 | if [ $VERBOSE -eq 1 ]; then 44 | printf '%s... ' "$test_name" 45 | fi 46 | 47 | run_test 48 | case $? in 49 | 0) 50 | # Success 51 | if [ $VERBOSE -eq 1 ]; then 52 | printf 'ok\n' 53 | else 54 | printf '.' 55 | fi 56 | rm -rf $test_log 57 | ;; 58 | 59 | 77) 60 | # Skip 61 | if [ $VERBOSE -eq 1 ]; then 62 | printf 'skipped\n' 63 | else 64 | printf 'S' 65 | fi 66 | rm -rf $test_log 67 | ;; 68 | 69 | *) 70 | # Failure 71 | if [ $VERBOSE -eq 1 ]; then 72 | printf 'FAILED\n' 73 | else 74 | printf 'F' 75 | fi 76 | 77 | [ $STOP -eq 1 ] && break 78 | ;; 79 | esac 80 | done 81 | 82 | if [ $VERBOSE -eq 0 ]; then 83 | printf '\n' 84 | fi 85 | 86 | if [ -n "$(ls -A $suite_log)" ]; then 87 | for test_log in $suite_log/*; do 88 | test_name=$(basename $test_log) 89 | test_path=$suite_srcdir/$test_name 90 | echo "=================================================================" 91 | echo "$suite_name/$test_name" 92 | echo "=================================================================" 93 | show_error 94 | echo 95 | done 96 | echo "=================================================================" 97 | exit 1 98 | else 99 | rm -rf $suite_log 100 | fi 101 | -------------------------------------------------------------------------------- /jansson/src/strbuffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef _GNU_SOURCE 9 | #define _GNU_SOURCE 10 | #endif 11 | 12 | #include 13 | #include 14 | #include "jansson_private.h" 15 | #include "strbuffer.h" 16 | 17 | #define STRBUFFER_MIN_SIZE 16 18 | #define STRBUFFER_FACTOR 2 19 | #define STRBUFFER_SIZE_MAX ((size_t)-1) 20 | 21 | int strbuffer_init(strbuffer_t *strbuff) 22 | { 23 | strbuff->size = STRBUFFER_MIN_SIZE; 24 | strbuff->length = 0; 25 | 26 | strbuff->value = jsonp_malloc(strbuff->size); 27 | if(!strbuff->value) 28 | return -1; 29 | 30 | /* initialize to empty */ 31 | strbuff->value[0] = '\0'; 32 | return 0; 33 | } 34 | 35 | void strbuffer_close(strbuffer_t *strbuff) 36 | { 37 | if(strbuff->value) 38 | jsonp_free(strbuff->value); 39 | 40 | strbuff->size = 0; 41 | strbuff->length = 0; 42 | strbuff->value = NULL; 43 | } 44 | 45 | void strbuffer_clear(strbuffer_t *strbuff) 46 | { 47 | strbuff->length = 0; 48 | strbuff->value[0] = '\0'; 49 | } 50 | 51 | const char *strbuffer_value(const strbuffer_t *strbuff) 52 | { 53 | return strbuff->value; 54 | } 55 | 56 | char *strbuffer_steal_value(strbuffer_t *strbuff) 57 | { 58 | char *result = strbuff->value; 59 | strbuff->value = NULL; 60 | return result; 61 | } 62 | 63 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte) 64 | { 65 | return strbuffer_append_bytes(strbuff, &byte, 1); 66 | } 67 | 68 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) 69 | { 70 | if(size >= strbuff->size - strbuff->length) 71 | { 72 | size_t new_size; 73 | char *new_value; 74 | 75 | /* avoid integer overflow */ 76 | if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR 77 | || size > STRBUFFER_SIZE_MAX - 1 78 | || strbuff->length > STRBUFFER_SIZE_MAX - 1 - size) 79 | return -1; 80 | 81 | new_size = max(strbuff->size * STRBUFFER_FACTOR, 82 | strbuff->length + size + 1); 83 | 84 | new_value = jsonp_malloc(new_size); 85 | if(!new_value) 86 | return -1; 87 | 88 | memcpy(new_value, strbuff->value, strbuff->length); 89 | 90 | jsonp_free(strbuff->value); 91 | strbuff->value = new_value; 92 | strbuff->size = new_size; 93 | } 94 | 95 | memcpy(strbuff->value + strbuff->length, data, size); 96 | strbuff->length += size; 97 | strbuff->value[strbuff->length] = '\0'; 98 | 99 | return 0; 100 | } 101 | 102 | char strbuffer_pop(strbuffer_t *strbuff) 103 | { 104 | if(strbuff->length > 0) { 105 | char c = strbuff->value[--strbuff->length]; 106 | strbuff->value[strbuff->length] = '\0'; 107 | return c; 108 | } 109 | else 110 | return '\0'; 111 | } 112 | -------------------------------------------------------------------------------- /jansson/doc/upgrading.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: c 2 | 3 | ****************** 4 | Upgrading from 1.x 5 | ****************** 6 | 7 | This chapter lists the backwards incompatible changes introduced in 8 | Jansson 2.0, and the steps that are needed for upgrading your code. 9 | 10 | **The incompatibilities are not dramatic.** The biggest change is that 11 | all decoding functions now require and extra parameter. Most programs 12 | can be modified to work with 2.0 by adding a ``0`` as the second 13 | parameter to all calls of :func:`json_loads()`, :func:`json_loadf()` 14 | and :func:`json_load_file()`. 15 | 16 | 17 | Compatibility 18 | ============= 19 | 20 | Jansson 2.0 is backwards incompatible with the Jansson 1.x releases. 21 | It is ABI incompatible, i.e. all programs dynamically linking to the 22 | Jansson library need to be recompiled. It's also API incompatible, 23 | i.e. the source code of programs using Jansson 1.x may need 24 | modifications to make them compile against Jansson 2.0. 25 | 26 | All the 2.x releases are guaranteed to be backwards compatible for 27 | both ABI and API, so no recompilation or source changes are needed 28 | when upgrading from 2.x to 2.y. 29 | 30 | 31 | List of Incompatible Changes 32 | ============================ 33 | 34 | **Decoding flags** 35 | For future needs, a ``flags`` parameter was added as the second 36 | parameter to all decoding functions, i.e. :func:`json_loads()`, 37 | :func:`json_loadf()` and :func:`json_load_file()`. All calls to 38 | these functions need to be changed by adding a ``0`` as the second 39 | argument. For example:: 40 | 41 | /* old code */ 42 | json_loads(input, &error); 43 | 44 | /* new code */ 45 | json_loads(input, 0, &error); 46 | 47 | 48 | **Underlying type of JSON integers** 49 | The underlying C type of JSON integers has been changed from 50 | :type:`int` to the widest available signed integer type, i.e. 51 | :type:`long long` or :type:`long`, depending on whether 52 | :type:`long long` is supported on your system or not. This makes 53 | the whole 64-bit integer range available on most modern systems. 54 | 55 | ``jansson.h`` has a typedef :type:`json_int_t` to the underlying 56 | integer type. :type:`int` should still be used in most cases when 57 | dealing with smallish JSON integers, as the compiler handles 58 | implicit type coercion. Only when the full 64-bit range is needed, 59 | :type:`json_int_t` should be explicitly used. 60 | 61 | 62 | **Maximum encoder indentation depth** 63 | The maximum argument of the ``JSON_INDENT()`` macro has been 64 | changed from 255 to 31, to free up bits from the ``flags`` 65 | parameter of :func:`json_dumps()`, :func:`json_dumpf()` and 66 | :func:`json_dump_file()`. If your code uses a bigger indentation 67 | than 31, it needs to be changed. 68 | 69 | 70 | **Unsigned integers in API functions** 71 | Version 2.0 unifies unsigned integer usage in the API. All uses of 72 | :type:`unsigned int` and :type:`unsigned long` have been replaced 73 | with :type:`size_t`. This includes flags, container sizes, etc. 74 | This should not require source code changes, as both 75 | :type:`unsigned int` and :type:`unsigned long` are usually 76 | compatible with :type:`size_t`. 77 | -------------------------------------------------------------------------------- /jansson/test/suites/api/test_memory_funcs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "util.h" 5 | 6 | static int malloc_called = 0; 7 | static int free_called = 0; 8 | static size_t malloc_used = 0; 9 | 10 | /* helpers */ 11 | static void create_and_free_complex_object() 12 | { 13 | json_t *obj; 14 | 15 | obj = json_pack("{s:i,s:n,s:b,s:b,s:{s:s},s:[i,i,i]}", 16 | "foo", 42, 17 | "bar", 18 | "baz", 1, 19 | "qux", 0, 20 | "alice", "bar", "baz", 21 | "bob", 9, 8, 7); 22 | 23 | json_decref(obj); 24 | } 25 | 26 | static void create_and_free_object_with_oom() 27 | { 28 | int i; 29 | char key[4]; 30 | json_t *obj = json_object(); 31 | 32 | for (i = 0; i < 10; i++) 33 | { 34 | snprintf(key, sizeof key, "%d", i); 35 | json_object_set_new(obj, key, json_integer(i)); 36 | } 37 | 38 | json_decref(obj); 39 | } 40 | 41 | static void *my_malloc(size_t size) 42 | { 43 | malloc_called = 1; 44 | return malloc(size); 45 | } 46 | 47 | static void my_free(void *ptr) 48 | { 49 | free_called = 1; 50 | free(ptr); 51 | } 52 | 53 | static void test_simple() 54 | { 55 | json_malloc_t mfunc = NULL; 56 | json_free_t ffunc = NULL; 57 | 58 | json_set_alloc_funcs(my_malloc, my_free); 59 | json_get_alloc_funcs(&mfunc, &ffunc); 60 | create_and_free_complex_object(); 61 | 62 | if (malloc_called != 1 || free_called != 1 63 | || mfunc != my_malloc || ffunc != my_free) 64 | fail("Custom allocation failed"); 65 | } 66 | 67 | 68 | static void *oom_malloc(size_t size) 69 | { 70 | if (malloc_used + size > 800) 71 | return NULL; 72 | 73 | malloc_used += size; 74 | return malloc(size); 75 | } 76 | 77 | static void oom_free(void *ptr) 78 | { 79 | free_called++; 80 | free(ptr); 81 | } 82 | 83 | static void test_oom() 84 | { 85 | free_called = 0; 86 | json_set_alloc_funcs(oom_malloc, oom_free); 87 | create_and_free_object_with_oom(); 88 | 89 | if (free_called == 0) 90 | fail("Allocation with OOM failed"); 91 | } 92 | 93 | 94 | /* 95 | Test the secure memory functions code given in the API reference 96 | documentation, but by using plain memset instead of 97 | guaranteed_memset(). 98 | */ 99 | 100 | static void *secure_malloc(size_t size) 101 | { 102 | /* Store the memory area size in the beginning of the block */ 103 | void *ptr = malloc(size + 8); 104 | *((size_t *)ptr) = size; 105 | return (char *)ptr + 8; 106 | } 107 | 108 | static void secure_free(void *ptr) 109 | { 110 | size_t size; 111 | 112 | ptr = (char *)ptr - 8; 113 | size = *((size_t *)ptr); 114 | 115 | /*guaranteed_*/memset(ptr, 0, size + 8); 116 | free(ptr); 117 | } 118 | 119 | static void test_secure_funcs(void) 120 | { 121 | json_set_alloc_funcs(secure_malloc, secure_free); 122 | create_and_free_complex_object(); 123 | } 124 | 125 | static void test_bad_args(void) 126 | { 127 | /* The result of this test is not crashing. */ 128 | json_get_alloc_funcs(NULL, NULL); 129 | } 130 | 131 | static void run_tests() 132 | { 133 | test_simple(); 134 | test_secure_funcs(); 135 | test_oom(); 136 | test_bad_args(); 137 | } 138 | -------------------------------------------------------------------------------- /jansson/doc/portability.rst: -------------------------------------------------------------------------------- 1 | *********** 2 | Portability 3 | *********** 4 | 5 | .. _portability-thread-safety: 6 | 7 | Thread safety 8 | ------------- 9 | 10 | Jansson as a library is thread safe and has no mutable global state. 11 | The only exceptions are the hash function seed and memory allocation 12 | functions, see below. 13 | 14 | There's no locking performed inside Jansson's code. **Read-only** 15 | access to JSON values shared by multiple threads is safe, but 16 | **mutating** a JSON value that's shared by multiple threads is not. A 17 | multithreaded program must perform its own locking if JSON values 18 | shared by multiple threads are mutated. 19 | 20 | However, **reference count manipulation** (:func:`json_incref()`, 21 | :func:`json_decref()`) is usually thread-safe, and can be performed on 22 | JSON values that are shared among threads. The thread-safety of 23 | reference counting can be checked with the 24 | ``JANSSON_THREAD_SAFE_REFCOUNT`` preprocessor constant. Thread-safe 25 | reference count manipulation is achieved using compiler built-in 26 | atomic functions, which are available in most modern compilers. 27 | 28 | If compiler support is not available (``JANSSON_THREAD_SAFE_REFCOUNT`` 29 | is not defined), it may be very difficult to ensure thread safety of 30 | reference counting. It's possible to have a reference to a value 31 | that's also stored inside an array or object in another thread. 32 | Modifying the container (adding or removing values) may trigger 33 | concurrent access to such values, as containers manage the reference 34 | count of their contained values. 35 | 36 | 37 | Hash function seed 38 | ================== 39 | 40 | To prevent an attacker from intentionally causing large JSON objects 41 | with specially crafted keys to perform very slow, the hash function 42 | used by Jansson is randomized using a seed value. The seed is 43 | automatically generated on the first explicit or implicit call to 44 | :func:`json_object()`, if :func:`json_object_seed()` has not been 45 | called beforehand. 46 | 47 | The seed is generated by using operating system's entropy sources if 48 | they are available (``/dev/urandom``, ``CryptGenRandom()``). The 49 | initialization is done in as thread safe manner as possible, by using 50 | architecture specific lockless operations if provided by the platform 51 | or the compiler. 52 | 53 | If you're using threads, it's recommended to autoseed the hashtable 54 | explicitly before spawning any threads by calling 55 | ``json_object_seed(0)`` , especially if you're unsure whether the 56 | initialization is thread safe on your platform. 57 | 58 | 59 | Memory allocation functions 60 | =========================== 61 | 62 | Memory allocation functions should be set at most once, and only on 63 | program startup. See :ref:`apiref-custom-memory-allocation`. 64 | 65 | 66 | Locale 67 | ------ 68 | 69 | Jansson works fine under any locale. 70 | 71 | However, if the host program is multithreaded and uses ``setlocale()`` 72 | to switch the locale in one thread while Jansson is currently encoding 73 | or decoding JSON data in another thread, the result may be wrong or 74 | the program may even crash. 75 | 76 | Jansson uses locale specific functions for certain string conversions 77 | in the encoder and decoder, and then converts the locale specific 78 | values to/from the JSON representation. This fails if the locale 79 | changes between the string conversion and the locale-to-JSON 80 | conversion. This can only happen in multithreaded programs that use 81 | ``setlocale()``, because ``setlocale()`` switches the locale for all 82 | running threads, not only the thread that calls ``setlocale()``. 83 | 84 | If your program uses ``setlocale()`` as described above, consider 85 | using the thread-safe ``uselocale()`` instead. 86 | -------------------------------------------------------------------------------- /jansson/test/suites/api/test_number.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #include 9 | #include 10 | #include "util.h" 11 | 12 | #ifdef INFINITY 13 | // This test triggers "warning C4756: overflow in constant arithmetic" 14 | // in Visual Studio. This warning is triggered here by design, so disable it. 15 | // (This can only be done on function level so we keep these tests separate) 16 | #ifdef _MSC_VER 17 | #pragma warning(push) 18 | #pragma warning (disable: 4756) 19 | #endif 20 | static void test_inifity() 21 | { 22 | json_t *real = json_real(INFINITY); 23 | if (real != NULL) 24 | fail("could construct a real from Inf"); 25 | 26 | real = json_real(1.0); 27 | if (json_real_set(real, INFINITY) != -1) 28 | fail("could set a real to Inf"); 29 | 30 | if (json_real_value(real) != 1.0) 31 | fail("real value changed unexpectedly"); 32 | 33 | json_decref(real); 34 | #ifdef _MSC_VER 35 | #pragma warning(pop) 36 | #endif 37 | } 38 | #endif // INFINITY 39 | 40 | static void test_bad_args(void) 41 | { 42 | json_t *txt = json_string("test"); 43 | 44 | if(json_integer_value(NULL) != 0) 45 | fail("json_integer_value did not return 0 for non-integer"); 46 | if(json_integer_value(txt) != 0) 47 | fail("json_integer_value did not return 0 for non-integer"); 48 | 49 | if(!json_integer_set(NULL, 0)) 50 | fail("json_integer_set did not return error for non-integer"); 51 | if(!json_integer_set(txt, 0)) 52 | fail("json_integer_set did not return error for non-integer"); 53 | 54 | if(json_real_value(NULL) != 0.0) 55 | fail("json_real_value did not return 0.0 for non-real"); 56 | if(json_real_value(txt) != 0.0) 57 | fail("json_real_value did not return 0.0 for non-real"); 58 | 59 | if(!json_real_set(NULL, 0.0)) 60 | fail("json_real_set did not return error for non-real"); 61 | if(!json_real_set(txt, 0.0)) 62 | fail("json_real_set did not return error for non-real"); 63 | 64 | if(json_number_value(NULL) != 0.0) 65 | fail("json_number_value did not return 0.0 for non-numeric"); 66 | if(json_number_value(txt) != 0.0) 67 | fail("json_number_value did not return 0.0 for non-numeric"); 68 | 69 | if (txt->refcount != 1) 70 | fail("unexpected reference count for txt"); 71 | 72 | json_decref(txt); 73 | } 74 | 75 | static void run_tests() 76 | { 77 | json_t *integer, *real; 78 | json_int_t i; 79 | double d; 80 | 81 | integer = json_integer(5); 82 | real = json_real(100.1); 83 | 84 | if(!integer) 85 | fail("unable to create integer"); 86 | if(!real) 87 | fail("unable to create real"); 88 | 89 | i = json_integer_value(integer); 90 | if(i != 5) 91 | fail("wrong integer value"); 92 | 93 | d = json_real_value(real); 94 | if(d != 100.1) 95 | fail("wrong real value"); 96 | 97 | d = json_number_value(integer); 98 | if(d != 5.0) 99 | fail("wrong number value"); 100 | d = json_number_value(real); 101 | if(d != 100.1) 102 | fail("wrong number value"); 103 | 104 | json_decref(integer); 105 | json_decref(real); 106 | 107 | #ifdef NAN 108 | real = json_real(NAN); 109 | if(real != NULL) 110 | fail("could construct a real from NaN"); 111 | 112 | real = json_real(1.0); 113 | if(json_real_set(real, NAN) != -1) 114 | fail("could set a real to NaN"); 115 | 116 | if(json_real_value(real) != 1.0) 117 | fail("real value changed unexpectedly"); 118 | 119 | json_decref(real); 120 | #endif 121 | 122 | #ifdef INFINITY 123 | test_inifity(); 124 | #endif 125 | test_bad_args(); 126 | } 127 | -------------------------------------------------------------------------------- /jansson/src/jansson_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef JANSSON_PRIVATE_H 9 | #define JANSSON_PRIVATE_H 10 | 11 | #include "jansson_private_config.h" 12 | #include 13 | #include "jansson.h" 14 | #include "hashtable.h" 15 | #include "strbuffer.h" 16 | 17 | #define container_of(ptr_, type_, member_) \ 18 | ((type_ *)((char *)ptr_ - offsetof(type_, member_))) 19 | 20 | /* On some platforms, max() may already be defined */ 21 | #ifndef max 22 | #define max(a, b) ((a) > (b) ? (a) : (b)) 23 | #endif 24 | 25 | /* va_copy is a C99 feature. In C89 implementations, it's sometimes 26 | available as __va_copy. If not, memcpy() should do the trick. */ 27 | #ifndef va_copy 28 | #ifdef __va_copy 29 | #define va_copy __va_copy 30 | #else 31 | #define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) 32 | #endif 33 | #endif 34 | 35 | typedef struct { 36 | json_t json; 37 | hashtable_t hashtable; 38 | } json_object_t; 39 | 40 | typedef struct { 41 | json_t json; 42 | size_t size; 43 | size_t entries; 44 | json_t **table; 45 | } json_array_t; 46 | 47 | typedef struct { 48 | json_t json; 49 | char *value; 50 | size_t length; 51 | } json_string_t; 52 | 53 | typedef struct { 54 | json_t json; 55 | double value; 56 | } json_real_t; 57 | 58 | typedef struct { 59 | json_t json; 60 | json_int_t value; 61 | } json_integer_t; 62 | 63 | #define json_to_object(json_) container_of(json_, json_object_t, json) 64 | #define json_to_array(json_) container_of(json_, json_array_t, json) 65 | #define json_to_string(json_) container_of(json_, json_string_t, json) 66 | #define json_to_real(json_) container_of(json_, json_real_t, json) 67 | #define json_to_integer(json_) container_of(json_, json_integer_t, json) 68 | 69 | /* Create a string by taking ownership of an existing buffer */ 70 | json_t *jsonp_stringn_nocheck_own(const char *value, size_t len); 71 | 72 | /* Error message formatting */ 73 | void jsonp_error_init(json_error_t *error, const char *source); 74 | void jsonp_error_set_source(json_error_t *error, const char *source); 75 | void jsonp_error_set(json_error_t *error, int line, int column, 76 | size_t position, enum json_error_code code, 77 | const char *msg, ...); 78 | void jsonp_error_vset(json_error_t *error, int line, int column, 79 | size_t position, enum json_error_code code, 80 | const char *msg, va_list ap); 81 | 82 | /* Locale independent string<->double conversions */ 83 | int jsonp_strtod(strbuffer_t *strbuffer, double *out); 84 | int jsonp_dtostr(char *buffer, size_t size, double value, int prec); 85 | 86 | /* Wrappers for custom memory functions */ 87 | void* jsonp_malloc(size_t size) JANSSON_ATTRS(warn_unused_result); 88 | void jsonp_free(void *ptr); 89 | char *jsonp_strndup(const char *str, size_t length) JANSSON_ATTRS(warn_unused_result); 90 | char *jsonp_strdup(const char *str) JANSSON_ATTRS(warn_unused_result); 91 | char *jsonp_strndup(const char *str, size_t len) JANSSON_ATTRS(warn_unused_result); 92 | 93 | 94 | /* Windows compatibility */ 95 | #if defined(_WIN32) || defined(WIN32) 96 | # if defined(_MSC_VER) /* MS compiller */ 97 | # if (_MSC_VER < 1900) && !defined(snprintf) /* snprintf not defined yet & not introduced */ 98 | # define snprintf _snprintf 99 | # endif 100 | # if (_MSC_VER < 1500) && !defined(vsnprintf) /* vsnprintf not defined yet & not introduced */ 101 | # define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a) 102 | # endif 103 | # else /* Other Windows compiller, old definition */ 104 | # define snprintf _snprintf 105 | # define vsnprintf _vsnprintf 106 | # endif 107 | #endif 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /jansson/src/strconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #ifdef __MINGW32__ 7 | #undef __NO_ISOCEXT /* ensure stdlib.h will declare prototypes for mingw own 'strtod' replacement, called '__strtod' */ 8 | #endif 9 | #include "jansson_private.h" 10 | #include "strbuffer.h" 11 | 12 | /* need jansson_private_config.h to get the correct snprintf */ 13 | #ifdef HAVE_CONFIG_H 14 | #include 15 | #endif 16 | 17 | #ifdef __MINGW32__ 18 | #define strtod __strtod 19 | #endif 20 | 21 | #if JSON_HAVE_LOCALECONV 22 | #include 23 | 24 | /* 25 | - This code assumes that the decimal separator is exactly one 26 | character. 27 | 28 | - If setlocale() is called by another thread between the call to 29 | localeconv() and the call to sprintf() or strtod(), the result may 30 | be wrong. setlocale() is not thread-safe and should not be used 31 | this way. Multi-threaded programs should use uselocale() instead. 32 | */ 33 | 34 | static void to_locale(strbuffer_t *strbuffer) 35 | { 36 | const char *point; 37 | char *pos; 38 | 39 | point = localeconv()->decimal_point; 40 | if(*point == '.') { 41 | /* No conversion needed */ 42 | return; 43 | } 44 | 45 | pos = strchr(strbuffer->value, '.'); 46 | if(pos) 47 | *pos = *point; 48 | } 49 | 50 | static void from_locale(char *buffer) 51 | { 52 | const char *point; 53 | char *pos; 54 | 55 | point = localeconv()->decimal_point; 56 | if(*point == '.') { 57 | /* No conversion needed */ 58 | return; 59 | } 60 | 61 | pos = strchr(buffer, *point); 62 | if(pos) 63 | *pos = '.'; 64 | } 65 | #endif 66 | 67 | int jsonp_strtod(strbuffer_t *strbuffer, double *out) 68 | { 69 | double value; 70 | char *end; 71 | 72 | #if JSON_HAVE_LOCALECONV 73 | to_locale(strbuffer); 74 | #endif 75 | 76 | errno = 0; 77 | value = strtod(strbuffer->value, &end); 78 | assert(end == strbuffer->value + strbuffer->length); 79 | 80 | if((value == HUGE_VAL || value == -HUGE_VAL) && errno == ERANGE) { 81 | /* Overflow */ 82 | return -1; 83 | } 84 | 85 | *out = value; 86 | return 0; 87 | } 88 | 89 | int jsonp_dtostr(char *buffer, size_t size, double value, int precision) 90 | { 91 | int ret; 92 | char *start, *end; 93 | size_t length; 94 | 95 | if (precision == 0) 96 | precision = 17; 97 | 98 | ret = snprintf(buffer, size, "%.*g", precision, value); 99 | if(ret < 0) 100 | return -1; 101 | 102 | length = (size_t)ret; 103 | if(length >= size) 104 | return -1; 105 | 106 | #if JSON_HAVE_LOCALECONV 107 | from_locale(buffer); 108 | #endif 109 | 110 | /* Make sure there's a dot or 'e' in the output. Otherwise 111 | a real is converted to an integer when decoding */ 112 | if(strchr(buffer, '.') == NULL && 113 | strchr(buffer, 'e') == NULL) 114 | { 115 | if(length + 3 >= size) { 116 | /* No space to append ".0" */ 117 | return -1; 118 | } 119 | buffer[length] = '.'; 120 | buffer[length + 1] = '0'; 121 | buffer[length + 2] = '\0'; 122 | length += 2; 123 | } 124 | 125 | /* Remove leading '+' from positive exponent. Also remove leading 126 | zeros from exponents (added by some printf() implementations) */ 127 | start = strchr(buffer, 'e'); 128 | if(start) { 129 | start++; 130 | end = start + 1; 131 | 132 | if(*start == '-') 133 | start++; 134 | 135 | while(*end == '0') 136 | end++; 137 | 138 | if(end != start) { 139 | memmove(start, end, length - (size_t)(end - buffer)); 140 | length -= (size_t)(end - start); 141 | } 142 | } 143 | 144 | return (int)length; 145 | } 146 | -------------------------------------------------------------------------------- /SC2State.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "Constants.h" 7 | #include "Config.h" 8 | #include "SC2State.h" 9 | #include "APIState.h" 10 | 11 | const char* jsonToString(json_t * result, const char* name) { 12 | json_t * jsonName = json_object_get(result, name); 13 | if (NULL != jsonName && json_is_string(jsonName)) { 14 | return json_string_value(jsonName); 15 | } 16 | return nullptr; 17 | } 18 | 19 | 20 | /** 21 | AppState (GAME/MENU/LOADING) 22 | GameState (INGAME/OBS/REPLAY) 23 | MenuState (SCORESCREEN/PROFILE/HOME/CAMPAIGN/COOP/REPLAYS/VERSUS/CUSTOM/LOBBY/COLLECTION) 24 | **/ 25 | SC2State::SC2State(QObject* parent) 26 | : QObject(parent) 27 | { 28 | 29 | } 30 | 31 | SC2State::~SC2State() { 32 | } 33 | 34 | void SC2State::fromJSONString(std::string uiResponse, std::string gameResponse) { 35 | 36 | APIState api; 37 | 38 | json_error_t error; 39 | json_t* root = json_loads(uiResponse.c_str(), 0, &error); 40 | if (!root) { 41 | return; 42 | } 43 | json_t* screens = json_object_get(root, "activeScreens"); 44 | for (size_t i = 0; i < json_array_size(screens); i++) { 45 | json_t* obj_txt = json_array_get(screens, i);; 46 | const char* strText; 47 | if (NULL != obj_txt && json_is_string(obj_txt)) { 48 | strText = json_string_value(obj_txt); 49 | api.activeScreens.push_back(strText); 50 | } 51 | } 52 | 53 | root = json_loads(gameResponse.c_str(), 0, &error); 54 | if (!root) { 55 | return; 56 | } 57 | 58 | json_t* isReplay = json_object_get(root, "isReplay"); 59 | api.isReplay = (isReplay == json_true()); 60 | 61 | json_t* displayTime = json_object_get(root, "displayTime"); 62 | if(json_is_number(displayTime)) { 63 | double dp = json_real_value(displayTime); 64 | api.displayTime = dp; 65 | } 66 | 67 | 68 | json_t* players = json_object_get(root, "players"); 69 | for (size_t i = 0; i < json_array_size(players); i++) { 70 | player* p = new player; 71 | json_t* playerJSON = json_array_get(players, i); 72 | p->name = (jsonToString(playerJSON, "name") == nullptr? "" : jsonToString(playerJSON, "name")); 73 | p->type = (jsonToString(playerJSON, "type") == nullptr? "" : jsonToString(playerJSON, "type")); 74 | p->race = (jsonToString(playerJSON, "race") == nullptr? "" : jsonToString(playerJSON, "race")); 75 | p->result = (jsonToString(playerJSON, "result") == nullptr? "" : jsonToString(playerJSON, "result")); 76 | api.players.push_back(p); 77 | } 78 | 79 | fullState = api; 80 | fillState(); 81 | } 82 | 83 | void SC2State::fillState() { 84 | Config* cfg = Config::Current(); 85 | if (fullState.activeScreens.size() > 1) { 86 | bool found = false; 87 | int sceneIdx = 0; 88 | int max = sizeof(menuLabels) / sizeof(menuLabels[0]); 89 | 90 | while (!found && sceneIdx < max) { 91 | for (size_t i = 0; i < fullState.activeScreens.size(); i++) { 92 | std::string active = fullState.activeScreens[i]; 93 | std::string label = menuLabels[sceneIdx]; 94 | if (active == label) { 95 | menuState = sceneIdx; 96 | found = true; 97 | break; 98 | } 99 | } 100 | sceneIdx++; 101 | } 102 | if(!found) { 103 | menuState = MENU_NONE; 104 | } 105 | appState = APP_MENU; 106 | } 107 | else if (fullState.activeScreens.size() == 0) { 108 | // in game 109 | appState = APP_INGAME; 110 | gameState = GAME_INGAME; 111 | } 112 | else { 113 | // we are in the loading screen 114 | appState = APP_LOADING; 115 | } 116 | 117 | if(fullState.isReplay) { 118 | gameState = GAME_REPLAY; 119 | } 120 | 121 | bool usernameFound = false; 122 | for (size_t i = 0; i < fullState.players.size(); i++) { 123 | if (cfg->usernames.size() > 0) { 124 | // if this is one of our usernames 125 | if (std::find(cfg->usernames.begin(), cfg->usernames.end(), fullState.players[i]->name) != cfg->usernames.end()) { 126 | usernameFound = true; 127 | } 128 | } 129 | // if this username isnt already in our recents, add it 130 | if (std::find(cfg->recentUsernames.begin(), cfg->recentUsernames.end(), fullState.players[i]->name) == cfg->recentUsernames.end()) { 131 | cfg->recentUsernames.push_back(fullState.players[i]->name); 132 | 133 | // limit the size of the recent usernames list, it could get quite big 134 | if (cfg->recentUsernames.size() > 8) { 135 | cfg->recentUsernames.erase(cfg->recentUsernames.begin()); 136 | } 137 | } 138 | } 139 | 140 | if (!usernameFound && cfg->usernames.size() > 0) { 141 | gameState = GAME_OBS; 142 | } 143 | } 144 | 145 | 146 | -------------------------------------------------------------------------------- /jansson/cmake/Coveralls.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Permission is hereby granted, free of charge, to any person obtaining a copy 3 | # of this software and associated documentation files (the "Software"), to deal 4 | # in the Software without restriction, including without limitation the rights 5 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | # copies of the Software, and to permit persons to whom the Software is 7 | # furnished to do so, subject to the following conditions: 8 | # 9 | # The above copyright notice and this permission notice shall be included in all 10 | # copies or substantial portions of the Software. 11 | # 12 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 | # SOFTWARE. 19 | # 20 | # Copyright (C) 2014 Joakim Söderberg 21 | # 22 | 23 | 24 | # 25 | # Param _COVERAGE_SRCS A list of source files that coverage should be collected for. 26 | # Param _COVERALLS_UPLOAD Upload the result to coveralls? 27 | # 28 | function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD) 29 | # When passing a CMake list to an external process, the list 30 | # will be converted from the format "1;2;3" to "1 2 3". 31 | # This means the script we're calling won't see it as a list 32 | # of sources, but rather just one long path. We remedy this 33 | # by replacing ";" with "*" and then reversing that in the script 34 | # that we're calling. 35 | # http://cmake.3232098.n2.nabble.com/Passing-a-CMake-list-quot-as-is-quot-to-a-custom-target-td6505681.html 36 | set(COVERAGE_SRCS_TMP ${_COVERAGE_SRCS}) 37 | set(COVERAGE_SRCS "") 38 | foreach (COVERAGE_SRC ${COVERAGE_SRCS_TMP}) 39 | set(COVERAGE_SRCS "${COVERAGE_SRCS}*${COVERAGE_SRC}") 40 | endforeach() 41 | 42 | #message("Coverage sources: ${COVERAGE_SRCS}") 43 | set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json) 44 | 45 | add_custom_target(coveralls_generate 46 | 47 | # Zero the coverage counters. 48 | COMMAND ${CMAKE_COMMAND} 49 | -P "${PROJECT_SOURCE_DIR}/cmake/CoverallsClear.cmake" 50 | 51 | # Run regress tests. 52 | COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure 53 | 54 | # Generate Gcov and translate it into coveralls JSON. 55 | # We do this by executing an external CMake script. 56 | # (We don't want this to run at CMake generation time, but after compilation and everything has run). 57 | COMMAND ${CMAKE_COMMAND} 58 | -DCOVERAGE_SRCS="${COVERAGE_SRCS}" # TODO: This is passed like: "a b c", not "a;b;c" 59 | -DCOVERALLS_OUTPUT_FILE="${COVERALLS_FILE}" 60 | -DCOV_PATH="${PROJECT_BINARY_DIR}" 61 | -DPROJECT_ROOT="${PROJECT_SOURCE_DIR}" 62 | -P "${PROJECT_SOURCE_DIR}/cmake/CoverallsGenerateGcov.cmake" 63 | 64 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 65 | COMMENT "Generating coveralls output..." 66 | ) 67 | 68 | if (_COVERALLS_UPLOAD) 69 | message("COVERALLS UPLOAD: ON") 70 | 71 | find_program(CURL_EXECUTABLE curl) 72 | 73 | if (NOT CURL_EXECUTABLE) 74 | message(FATAL_ERROR "Coveralls: curl not found! Aborting") 75 | endif() 76 | 77 | add_custom_target(coveralls_upload 78 | # Upload the JSON to coveralls. 79 | COMMAND ${CURL_EXECUTABLE} 80 | -S -F json_file=@${COVERALLS_FILE} 81 | https://coveralls.io/api/v1/jobs 82 | 83 | DEPENDS coveralls_generate 84 | 85 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 86 | COMMENT "Uploading coveralls output...") 87 | 88 | add_custom_target(coveralls DEPENDS coveralls_upload) 89 | else() 90 | message("COVERALLS UPLOAD: OFF") 91 | add_custom_target(coveralls DEPENDS coveralls_generate) 92 | endif() 93 | 94 | endfunction() 95 | 96 | macro(coveralls_turn_on_coverage) 97 | if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) 98 | AND (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) 99 | message(FATAL_ERROR "Coveralls: Compiler ${CMAKE_C_COMPILER_ID} is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") 100 | endif() 101 | 102 | if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") 103 | message(FATAL_ERROR "Coveralls: Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug") 104 | endif() 105 | 106 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") 107 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") 108 | endmacro() 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /jansson/test/suites/api/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef UTIL_H 9 | #define UTIL_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include 13 | #endif 14 | 15 | #include 16 | #include 17 | #if HAVE_LOCALE_H 18 | #include 19 | #endif 20 | 21 | #include 22 | 23 | #define failhdr fprintf(stderr, "%s:%d: ", __FILE__, __LINE__) 24 | 25 | #define fail(msg) \ 26 | do { \ 27 | failhdr; \ 28 | fprintf(stderr, "%s\n", msg); \ 29 | exit(1); \ 30 | } while(0) 31 | 32 | /* Assumes json_error_t error */ 33 | #define check_errors(code_, texts_, num_, source_, \ 34 | line_, column_, position_) \ 35 | do { \ 36 | int i_, found_ = 0; \ 37 | if(json_error_code(&error) != code_) { \ 38 | failhdr; \ 39 | fprintf(stderr, "code: %d != %d\n", \ 40 | json_error_code(&error), code_); \ 41 | exit(1); \ 42 | } \ 43 | for(i_ = 0; i_ < num_; i_++) { \ 44 | if(strcmp(error.text, texts_[i_]) == 0) { \ 45 | found_ = 1; \ 46 | break; \ 47 | } \ 48 | } \ 49 | if (!found_) { \ 50 | failhdr; \ 51 | if (num_ == 1) { \ 52 | fprintf(stderr, "text: \"%s\" != \"%s\"\n", error.text, texts_[0]); \ 53 | } else { \ 54 | fprintf(stderr, "text: \"%s\" does not match\n", error.text); \ 55 | } \ 56 | exit(1); \ 57 | } \ 58 | if(strcmp(error.source, source_) != 0) { \ 59 | failhdr; \ 60 | \ 61 | fprintf(stderr, "source: \"%s\" != \"%s\"\n", error.source, source_); \ 62 | exit(1); \ 63 | } \ 64 | if(error.line != line_) { \ 65 | failhdr; \ 66 | fprintf(stderr, "line: %d != %d\n", error.line, line_); \ 67 | exit(1); \ 68 | } \ 69 | if(error.column != column_) { \ 70 | failhdr; \ 71 | fprintf(stderr, "column: %d != %d\n", error.column, column_); \ 72 | exit(1); \ 73 | } \ 74 | if(error.position != position_) { \ 75 | failhdr; \ 76 | fprintf(stderr, "position: %d != %d\n", error.position, position_); \ 77 | exit(1); \ 78 | } \ 79 | } while(0) 80 | 81 | 82 | /* Assumes json_error_t error */ 83 | #define check_error(code_, text_, source_, line_, column_, position_) \ 84 | check_errors(code_, &text_, 1, source_, line_, column_, position_) 85 | 86 | 87 | static void run_tests(); 88 | 89 | int main() { 90 | #ifdef HAVE_SETLOCALE 91 | setlocale(LC_ALL, ""); 92 | #endif 93 | run_tests(); 94 | return 0; 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /jansson/src/utf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #include 9 | #include "utf.h" 10 | 11 | int utf8_encode(int32_t codepoint, char *buffer, size_t *size) 12 | { 13 | if(codepoint < 0) 14 | return -1; 15 | else if(codepoint < 0x80) 16 | { 17 | buffer[0] = (char)codepoint; 18 | *size = 1; 19 | } 20 | else if(codepoint < 0x800) 21 | { 22 | buffer[0] = 0xC0 + ((codepoint & 0x7C0) >> 6); 23 | buffer[1] = 0x80 + ((codepoint & 0x03F)); 24 | *size = 2; 25 | } 26 | else if(codepoint < 0x10000) 27 | { 28 | buffer[0] = 0xE0 + ((codepoint & 0xF000) >> 12); 29 | buffer[1] = 0x80 + ((codepoint & 0x0FC0) >> 6); 30 | buffer[2] = 0x80 + ((codepoint & 0x003F)); 31 | *size = 3; 32 | } 33 | else if(codepoint <= 0x10FFFF) 34 | { 35 | buffer[0] = 0xF0 + ((codepoint & 0x1C0000) >> 18); 36 | buffer[1] = 0x80 + ((codepoint & 0x03F000) >> 12); 37 | buffer[2] = 0x80 + ((codepoint & 0x000FC0) >> 6); 38 | buffer[3] = 0x80 + ((codepoint & 0x00003F)); 39 | *size = 4; 40 | } 41 | else 42 | return -1; 43 | 44 | return 0; 45 | } 46 | 47 | size_t utf8_check_first(char byte) 48 | { 49 | unsigned char u = (unsigned char)byte; 50 | 51 | if(u < 0x80) 52 | return 1; 53 | 54 | if(0x80 <= u && u <= 0xBF) { 55 | /* second, third or fourth byte of a multi-byte 56 | sequence, i.e. a "continuation byte" */ 57 | return 0; 58 | } 59 | else if(u == 0xC0 || u == 0xC1) { 60 | /* overlong encoding of an ASCII byte */ 61 | return 0; 62 | } 63 | else if(0xC2 <= u && u <= 0xDF) { 64 | /* 2-byte sequence */ 65 | return 2; 66 | } 67 | 68 | else if(0xE0 <= u && u <= 0xEF) { 69 | /* 3-byte sequence */ 70 | return 3; 71 | } 72 | else if(0xF0 <= u && u <= 0xF4) { 73 | /* 4-byte sequence */ 74 | return 4; 75 | } 76 | else { /* u >= 0xF5 */ 77 | /* Restricted (start of 4-, 5- or 6-byte sequence) or invalid 78 | UTF-8 */ 79 | return 0; 80 | } 81 | } 82 | 83 | size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint) 84 | { 85 | size_t i; 86 | int32_t value = 0; 87 | unsigned char u = (unsigned char)buffer[0]; 88 | 89 | if(size == 2) 90 | { 91 | value = u & 0x1F; 92 | } 93 | else if(size == 3) 94 | { 95 | value = u & 0xF; 96 | } 97 | else if(size == 4) 98 | { 99 | value = u & 0x7; 100 | } 101 | else 102 | return 0; 103 | 104 | for(i = 1; i < size; i++) 105 | { 106 | u = (unsigned char)buffer[i]; 107 | 108 | if(u < 0x80 || u > 0xBF) { 109 | /* not a continuation byte */ 110 | return 0; 111 | } 112 | 113 | value = (value << 6) + (u & 0x3F); 114 | } 115 | 116 | if(value > 0x10FFFF) { 117 | /* not in Unicode range */ 118 | return 0; 119 | } 120 | 121 | else if(0xD800 <= value && value <= 0xDFFF) { 122 | /* invalid code point (UTF-16 surrogate halves) */ 123 | return 0; 124 | } 125 | 126 | else if((size == 2 && value < 0x80) || 127 | (size == 3 && value < 0x800) || 128 | (size == 4 && value < 0x10000)) { 129 | /* overlong encoding */ 130 | return 0; 131 | } 132 | 133 | if(codepoint) 134 | *codepoint = value; 135 | 136 | return 1; 137 | } 138 | 139 | const char *utf8_iterate(const char *buffer, size_t bufsize, int32_t *codepoint) 140 | { 141 | size_t count; 142 | int32_t value; 143 | 144 | if(!bufsize) 145 | return buffer; 146 | 147 | count = utf8_check_first(buffer[0]); 148 | if(count <= 0) 149 | return NULL; 150 | 151 | if(count == 1) 152 | value = (unsigned char)buffer[0]; 153 | else 154 | { 155 | if(count > bufsize || !utf8_check_full(buffer, count, &value)) 156 | return NULL; 157 | } 158 | 159 | if(codepoint) 160 | *codepoint = value; 161 | 162 | return buffer + count; 163 | } 164 | 165 | int utf8_check_string(const char *string, size_t length) 166 | { 167 | size_t i; 168 | 169 | for(i = 0; i < length; i++) 170 | { 171 | size_t count = utf8_check_first(string[i]); 172 | if(count == 0) 173 | return 0; 174 | else if(count > 1) 175 | { 176 | if(count > length - i) 177 | return 0; 178 | 179 | if(!utf8_check_full(&string[i], count, NULL)) 180 | return 0; 181 | 182 | i += count - 1; 183 | } 184 | } 185 | 186 | return 1; 187 | } 188 | -------------------------------------------------------------------------------- /jansson/doc/conformance.rst: -------------------------------------------------------------------------------- 1 | .. _rfc-conformance: 2 | 3 | *************** 4 | RFC Conformance 5 | *************** 6 | 7 | JSON is specified in :rfc:`4627`, *"The application/json Media Type 8 | for JavaScript Object Notation (JSON)"*. 9 | 10 | Character Encoding 11 | ================== 12 | 13 | Jansson only supports UTF-8 encoded JSON texts. It does not support or 14 | auto-detect any of the other encodings mentioned in the RFC, namely 15 | UTF-16LE, UTF-16BE, UTF-32LE or UTF-32BE. Pure ASCII is supported, as 16 | it's a subset of UTF-8. 17 | 18 | Strings 19 | ======= 20 | 21 | JSON strings are mapped to C-style null-terminated character arrays, 22 | and UTF-8 encoding is used internally. 23 | 24 | All Unicode codepoints U+0000 through U+10FFFF are allowed in string 25 | values. However, U+0000 is not allowed in object keys because of API 26 | restrictions. 27 | 28 | Unicode normalization or any other transformation is never performed 29 | on any strings (string values or object keys). When checking for 30 | equivalence of strings or object keys, the comparison is performed 31 | byte by byte between the original UTF-8 representations of the 32 | strings. 33 | 34 | Numbers 35 | ======= 36 | 37 | .. _real-vs-integer: 38 | 39 | Real vs. Integer 40 | ---------------- 41 | 42 | JSON makes no distinction between real and integer numbers; Jansson 43 | does. Real numbers are mapped to the ``double`` type and integers to 44 | the ``json_int_t`` type, which is a typedef of ``long long`` or 45 | ``long``, depending on whether ``long long`` is supported by your 46 | compiler or not. 47 | 48 | A JSON number is considered to be a real number if its lexical 49 | representation includes one of ``e``, ``E``, or ``.``; regardless if 50 | its actual numeric value is a true integer (e.g., all of ``1E6``, 51 | ``3.0``, ``400E-2``, and ``3.14E3`` are mathematical integers, but 52 | will be treated as real values). With the ``JSON_DECODE_INT_AS_REAL`` 53 | decoder flag set all numbers are interpreted as real. 54 | 55 | All other JSON numbers are considered integers. 56 | 57 | When encoding to JSON, real values are always represented 58 | with a fractional part; e.g., the ``double`` value 3.0 will be 59 | represented in JSON as ``3.0``, not ``3``. 60 | 61 | Overflow, Underflow & Precision 62 | ------------------------------- 63 | 64 | Real numbers whose absolute values are too small to be represented in 65 | a C ``double`` will be silently estimated with 0.0. Thus, depending on 66 | platform, JSON numbers very close to zero such as 1E-999 may result in 67 | 0.0. 68 | 69 | Real numbers whose absolute values are too large to be represented in 70 | a C ``double`` will result in an overflow error (a JSON decoding 71 | error). Thus, depending on platform, JSON numbers like 1E+999 or 72 | -1E+999 may result in a parsing error. 73 | 74 | Likewise, integer numbers whose absolute values are too large to be 75 | represented in the ``json_int_t`` type (see above) will result in an 76 | overflow error (a JSON decoding error). Thus, depending on platform, 77 | JSON numbers like 1000000000000000 may result in parsing error. 78 | 79 | Parsing JSON real numbers may result in a loss of precision. As long 80 | as overflow does not occur (i.e. a total loss of precision), the 81 | rounded approximate value is silently used. Thus the JSON number 82 | 1.000000000000000005 may, depending on platform, result in the 83 | ``double`` value 1.0. 84 | 85 | Signed zeros 86 | ------------ 87 | 88 | JSON makes no statement about what a number means; however Javascript 89 | (ECMAscript) does state that +0.0 and -0.0 must be treated as being 90 | distinct values, i.e. -0.0 |not-equal| 0.0. Jansson relies on the 91 | underlying floating point library in the C environment in which it is 92 | compiled. Therefore it is platform-dependent whether 0.0 and -0.0 will 93 | be distinct values. Most platforms that use the IEEE 754 94 | floating-point standard will support signed zeros. 95 | 96 | Note that this only applies to floating-point; neither JSON, C, or 97 | IEEE support the concept of signed integer zeros. 98 | 99 | .. |not-equal| unicode:: U+2260 100 | 101 | Types 102 | ----- 103 | 104 | No support is provided in Jansson for any C numeric types other than 105 | ``json_int_t`` and ``double``. This excludes things such as unsigned 106 | types, ``long double``, etc. Obviously, shorter types like ``short``, 107 | ``int``, ``long`` (if ``json_int_t`` is ``long long``) and ``float`` 108 | are implicitly handled via the ordinary C type coercion rules (subject 109 | to overflow semantics). Also, no support or hooks are provided for any 110 | supplemental "bignum" type add-on packages. 111 | 112 | Depth of nested values 113 | ---------------------- 114 | 115 | To avoid stack exhaustion, Jansson currently limits the nesting depth 116 | for arrays and objects to a certain value (default: 2048), defined as 117 | a macro ``JSON_PARSER_MAX_DEPTH`` within ``jansson_config.h``. 118 | 119 | The limit is allowed to be set by the RFC; there is no recommended value 120 | or required minimum depth to be supported. 121 | -------------------------------------------------------------------------------- /Webhook.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "SC2Data.h" 4 | #include "Observer.h" 5 | #include "SC2State.h" 6 | #include "Webhook.h" 7 | #include "Constants.h" 8 | #include "Config.h" 9 | #include "APIState.h" 10 | #include "ScoreTracker.h" 11 | 12 | #include 13 | 14 | Webhook::Webhook(SC2Data *sc2): Observer(sc2){ } 15 | 16 | void Webhook::notify(SC2State*& previous, SC2State*& current) { 17 | Config* cfg = Config::Current(); 18 | 19 | std::string event = ""; 20 | // quit and rewind 21 | if(previous->gameState == GAME_INGAME && 22 | previous->appState == APP_INGAME && 23 | current->gameState == GAME_REPLAY) { 24 | if (current->fullState.players.size() == 2) { 25 | event = "exit"; 26 | } 27 | } 28 | 29 | // just quit 30 | if(current->appState != APP_INGAME && 31 | previous->appState == APP_INGAME) { 32 | if (current->fullState.players.size() == 2 && !current->fullState.isReplay) { 33 | event = "exit"; 34 | } 35 | } 36 | 37 | if(current->appState == APP_INGAME && 38 | previous->appState != APP_INGAME && 39 | current->gameState != GAME_REPLAY) { 40 | event = "enter"; 41 | } 42 | 43 | if (event != "") { 44 | sendRequest(current, event); 45 | } 46 | } 47 | 48 | static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) 49 | { 50 | ((std::string*)userp)->append((char*)contents, size * nmemb); 51 | return size * nmemb; 52 | } 53 | 54 | void Webhook::sendRequest(SC2State*& game, std::string event) { 55 | Config* cfg = Config::Current(); 56 | 57 | int still_running = 0; 58 | CURLM *multi_handle; 59 | multi_handle = curl_multi_init(); 60 | 61 | // vector of handles 62 | vector handles; 63 | vector responses; 64 | 65 | for (string &url : cfg->webhookURLList) { 66 | CURL *handle; 67 | handle = curl_easy_init(); 68 | if (handle) { 69 | curl_multi_add_handle(multi_handle, handle); 70 | handles.push_back(handle); 71 | std::string qdelim = "?"; 72 | std::size_t found = url.find(qdelim); 73 | if (found!=std::string::npos) { 74 | qdelim = "&"; 75 | } 76 | 77 | std::string resp = getJSONStringFromSC2State(game, event); 78 | std::string respEscaped = curl_easy_escape(handle, resp.c_str(), 0); 79 | std::string c_url = url + qdelim + "json=" + respEscaped; 80 | curl_easy_setopt(handle, CURLOPT_URL, c_url.c_str()); 81 | curl_easy_setopt(handle, CURLOPT_TIMEOUT_MS, 1000); 82 | curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L); 83 | curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L); 84 | 85 | } 86 | } 87 | 88 | curl_multi_perform(multi_handle, &still_running); 89 | while(still_running) { 90 | CURLMcode mc; /* curl_multi_wait() return code */ 91 | int numfds; 92 | mc = curl_multi_wait(multi_handle, NULL, 0, 1000, &numfds); 93 | 94 | if(mc != CURLM_OK) { 95 | break; 96 | } 97 | curl_multi_perform(multi_handle, &still_running); 98 | } 99 | // clean up each handle 100 | for (CURL* &handle : handles) { 101 | curl_multi_remove_handle(multi_handle, handle); 102 | curl_easy_cleanup(handle); 103 | } 104 | curl_multi_cleanup(multi_handle); 105 | } 106 | 107 | std::string Webhook::getJSONStringFromSC2State(SC2State*& game, std::string event) { 108 | // i know this is dirty but im just testing it as the query string option 109 | // doesnt work with node. ill update it... 110 | Config* cfg = Config::Current(); 111 | std::string resp = ""; 112 | resp = resp + "{\"players\": ["; 113 | for(size_t i=0; ifullState.players.size(); i++) { 114 | resp = resp + "{"; 115 | resp = resp + "\"name\": \"" + game->fullState.players[i]->name + "\","; 116 | resp = resp + "\"type\": \"" + game->fullState.players[i]->type + "\","; 117 | resp = resp + "\"race\": \"" + game->fullState.players[i]->race + "\","; 118 | resp = resp + "\"result\": \"" + game->fullState.players[i]->result + "\","; 119 | 120 | if (std::find(cfg->usernames.begin(), cfg->usernames.end(), game->fullState.players[i]->name) != cfg->usernames.end()) { 121 | resp = resp + "\"isme\": true"; 122 | } 123 | else { 124 | resp = resp + "\"isme\": false"; 125 | } 126 | resp = resp + "}"; 127 | if(i + 1 != game->fullState.players.size()) { 128 | resp = resp + ","; 129 | } 130 | } 131 | resp = resp + "],"; 132 | 133 | ScoreTracker* st = ScoreTracker::Current(); 134 | resp = resp + "\"scores\": { "; 135 | resp = resp + "\"Terr\": {\"Victory\": " + to_string(st->scores["Terr"]["Victory"]) + ", \"Defeat\": " + to_string(st->scores["Terr"]["Defeat"]) + " },"; 136 | resp = resp + "\"Prot\": {\"Victory\": " + to_string(st->scores["Prot"]["Victory"]) + ", \"Defeat\": " + to_string(st->scores["Prot"]["Defeat"]) + " },"; 137 | resp = resp + "\"Zerg\": {\"Victory\": " + to_string(st->scores["Zerg"]["Victory"]) + ", \"Defeat\": " + to_string(st->scores["Zerg"]["Defeat"]) + " }"; 138 | resp = resp + "},"; 139 | 140 | std::string dp = std::to_string(game->fullState.displayTime); 141 | resp = resp + "\"displayTime\": \"" + dp + "\","; 142 | resp = resp + "\"event\": \"" + event + "\""; 143 | resp = resp + "}"; 144 | return resp; 145 | } -------------------------------------------------------------------------------- /Config.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Config.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | Config* Config::_instance = new Config(); 12 | 13 | static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) 14 | { 15 | ((std::string*)userp)->append((char*)contents, size * nmemb); 16 | return size * nmemb; 17 | } 18 | 19 | Config::Config() : 20 | ipAddr(std::string("localhost")), 21 | scoreString(std::string("vT: ${tw}-${tl}\nvZ: ${zw}-${zl}\nvP: ${pw}-${pl}")) 22 | { } 23 | 24 | Config* Config::Current() { 25 | return _instance; 26 | } 27 | 28 | void Config::load() { 29 | string line; 30 | ifstream settingsFile("webhook.json"); 31 | if (settingsFile.is_open()) { 32 | getline(settingsFile, line); 33 | settingsFile.close(); 34 | 35 | json_error_t error; 36 | json_t* root = json_loads(line.c_str(), 0, &error); 37 | if (!root) { 38 | return; 39 | } 40 | 41 | ipAddr = json_string_value(json_object_get(root, "ipAddr")); 42 | popupsEnabled = json_boolean_value(json_object_get(root, "popupsEnabled")); 43 | scoresEnabled = json_boolean_value(json_object_get(root, "scoresEnabled")); 44 | scoreString = json_string_value(json_object_get(root, "scoreString")); 45 | 46 | vector seen; 47 | json_t* jsonusernames = json_object_get(root, "usernames"); 48 | for (size_t i = 0; i < json_array_size(jsonusernames); i++) { 49 | string un = json_string_value(json_array_get(jsonusernames, i)); 50 | if (std::find(seen.begin(), seen.end(), un) == seen.end() && un != "") { 51 | usernames.push_back(un); 52 | seen.push_back(un); 53 | } 54 | } 55 | 56 | seen.clear(); 57 | json_t* webhookURLListJSON = json_object_get(root, "webhookURLList"); 58 | for (size_t i = 0; i < json_array_size(webhookURLListJSON); i++) { 59 | string un = json_string_value(json_array_get(webhookURLListJSON, i)); 60 | if (std::find(seen.begin(), seen.end(), un) == seen.end() && un != "") { 61 | webhookURLList.push_back(un); 62 | seen.push_back(un); 63 | } 64 | } 65 | } 66 | else { 67 | qDebug("settings file not open"); 68 | } 69 | } 70 | 71 | void Config::save() { 72 | ofstream settingsFile("webhook.json"); 73 | if (settingsFile.is_open()) { 74 | std::string out = "{"; 75 | out += "\"ipAddr\": \"" + escape_json(ipAddr) + "\", "; 76 | 77 | out += "\"usernames\": ["; 78 | for (size_t i = 0; i < usernames.size(); i++) { 79 | if(i > 0) { 80 | out += ", "; 81 | } 82 | out += "\"" + escape_json(usernames[i]) + "\""; 83 | } 84 | out += "], "; 85 | 86 | 87 | out += "\"webhookURLList\": ["; 88 | for (size_t i = 0; i < webhookURLList.size(); i++) { 89 | if(i > 0) { 90 | out += ", "; 91 | } 92 | out += "\"" + escape_json(webhookURLList[i]) + "\""; 93 | } 94 | out += "],"; 95 | 96 | out += "\"scoreString\": \"" + escape_json(scoreString) + "\","; // 97 | out += "\"scoresEnabled\": "; 98 | out += (scoresEnabled ? "true" : "false"); 99 | out += ","; 100 | 101 | out += "\"popupsEnabled\": "; 102 | out += (popupsEnabled ? "true" : "false"); 103 | out += ""; 104 | 105 | out += "}"; 106 | settingsFile << out; 107 | settingsFile.close(); 108 | } 109 | } 110 | 111 | void Config::checkForUpdates() { 112 | CURL *curl; 113 | CURLcode res; 114 | std::string response; 115 | 116 | curl = curl_easy_init(); 117 | if (curl) { 118 | std::string reqURL = "https://api.github.com/repos/leigholiver/SC2Switcher-Standalone/releases/latest"; 119 | 120 | struct curl_slist *chunk = NULL; 121 | 122 | curl_easy_setopt(curl, CURLOPT_URL, reqURL.c_str()); 123 | curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 500); 124 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); 125 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); 126 | 127 | chunk = curl_slist_append(chunk, "User-Agent: SC2Switcher-Standalone"); 128 | curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); 129 | 130 | res = curl_easy_perform(curl); 131 | curl_easy_cleanup(curl); 132 | if (res != CURLE_OK) { 133 | return; 134 | } 135 | } 136 | 137 | json_error_t error; 138 | json_t* root = json_loads(response.c_str(), 0, &error); 139 | if (!root) { 140 | return; 141 | } 142 | 143 | json_t* url = json_object_get(root, "tag_name"); 144 | if (!url) { 145 | return; 146 | } 147 | 148 | const char *urlText = json_string_value(url); 149 | float latestVer = stof(urlText); 150 | float currentVer = 0.1; 151 | if(latestVer > currentVer) { 152 | json_t* url2 = json_object_get(root, "html_url"); 153 | const char *urlText2 = json_string_value(url2); 154 | updateURL = urlText2; 155 | 156 | json_t* patch = json_object_get(root, "body"); 157 | const char *patchText = json_string_value(patch); 158 | updateDescription = patchText; 159 | } 160 | } 161 | 162 | std::string Config::escape_json(const std::string &s) { 163 | std::ostringstream o; 164 | for (auto c = s.cbegin(); c != s.cend(); c++) { 165 | if (*c == '"' || *c == '\\' || ('\x00' <= *c && *c <= '\x1f')) { 166 | o << "\\u" 167 | << std::hex << std::setw(4) << std::setfill('0') << (int)*c; 168 | } 169 | else { 170 | o << *c; 171 | } 172 | } 173 | return o.str(); 174 | } -------------------------------------------------------------------------------- /jansson/src/hashtable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * This library is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef HASHTABLE_H 9 | #define HASHTABLE_H 10 | 11 | #include 12 | #include "jansson.h" 13 | 14 | struct hashtable_list { 15 | struct hashtable_list *prev; 16 | struct hashtable_list *next; 17 | }; 18 | 19 | /* "pair" may be a bit confusing a name, but think of it as a 20 | key-value pair. In this case, it just encodes some extra data, 21 | too */ 22 | struct hashtable_pair { 23 | struct hashtable_list list; 24 | struct hashtable_list ordered_list; 25 | size_t hash; 26 | json_t *value; 27 | char key[1]; 28 | }; 29 | 30 | struct hashtable_bucket { 31 | struct hashtable_list *first; 32 | struct hashtable_list *last; 33 | }; 34 | 35 | typedef struct hashtable { 36 | size_t size; 37 | struct hashtable_bucket *buckets; 38 | size_t order; /* hashtable has pow(2, order) buckets */ 39 | struct hashtable_list list; 40 | struct hashtable_list ordered_list; 41 | } hashtable_t; 42 | 43 | 44 | #define hashtable_key_to_iter(key_) \ 45 | (&(container_of(key_, struct hashtable_pair, key)->ordered_list)) 46 | 47 | 48 | /** 49 | * hashtable_init - Initialize a hashtable object 50 | * 51 | * @hashtable: The (statically allocated) hashtable object 52 | * 53 | * Initializes a statically allocated hashtable object. The object 54 | * should be cleared with hashtable_close when it's no longer used. 55 | * 56 | * Returns 0 on success, -1 on error (out of memory). 57 | */ 58 | int hashtable_init(hashtable_t *hashtable) JANSSON_ATTRS(warn_unused_result); 59 | 60 | /** 61 | * hashtable_close - Release all resources used by a hashtable object 62 | * 63 | * @hashtable: The hashtable 64 | * 65 | * Destroys a statically allocated hashtable object. 66 | */ 67 | void hashtable_close(hashtable_t *hashtable); 68 | 69 | /** 70 | * hashtable_set - Add/modify value in hashtable 71 | * 72 | * @hashtable: The hashtable object 73 | * @key: The key 74 | * @serial: For addition order of keys 75 | * @value: The value 76 | * 77 | * If a value with the given key already exists, its value is replaced 78 | * with the new value. Value is "stealed" in the sense that hashtable 79 | * doesn't increment its refcount but decreases the refcount when the 80 | * value is no longer needed. 81 | * 82 | * Returns 0 on success, -1 on failure (out of memory). 83 | */ 84 | int hashtable_set(hashtable_t *hashtable, const char *key, json_t *value); 85 | 86 | /** 87 | * hashtable_get - Get a value associated with a key 88 | * 89 | * @hashtable: The hashtable object 90 | * @key: The key 91 | * 92 | * Returns value if it is found, or NULL otherwise. 93 | */ 94 | void *hashtable_get(hashtable_t *hashtable, const char *key); 95 | 96 | /** 97 | * hashtable_del - Remove a value from the hashtable 98 | * 99 | * @hashtable: The hashtable object 100 | * @key: The key 101 | * 102 | * Returns 0 on success, or -1 if the key was not found. 103 | */ 104 | int hashtable_del(hashtable_t *hashtable, const char *key); 105 | 106 | /** 107 | * hashtable_clear - Clear hashtable 108 | * 109 | * @hashtable: The hashtable object 110 | * 111 | * Removes all items from the hashtable. 112 | */ 113 | void hashtable_clear(hashtable_t *hashtable); 114 | 115 | /** 116 | * hashtable_iter - Iterate over hashtable 117 | * 118 | * @hashtable: The hashtable object 119 | * 120 | * Returns an opaque iterator to the first element in the hashtable. 121 | * The iterator should be passed to hashtable_iter_* functions. 122 | * The hashtable items are not iterated over in any particular order. 123 | * 124 | * There's no need to free the iterator in any way. The iterator is 125 | * valid as long as the item that is referenced by the iterator is not 126 | * deleted. Other values may be added or deleted. In particular, 127 | * hashtable_iter_next() may be called on an iterator, and after that 128 | * the key/value pair pointed by the old iterator may be deleted. 129 | */ 130 | void *hashtable_iter(hashtable_t *hashtable); 131 | 132 | /** 133 | * hashtable_iter_at - Return an iterator at a specific key 134 | * 135 | * @hashtable: The hashtable object 136 | * @key: The key that the iterator should point to 137 | * 138 | * Like hashtable_iter() but returns an iterator pointing to a 139 | * specific key. 140 | */ 141 | void *hashtable_iter_at(hashtable_t *hashtable, const char *key); 142 | 143 | /** 144 | * hashtable_iter_next - Advance an iterator 145 | * 146 | * @hashtable: The hashtable object 147 | * @iter: The iterator 148 | * 149 | * Returns a new iterator pointing to the next element in the 150 | * hashtable or NULL if the whole hastable has been iterated over. 151 | */ 152 | void *hashtable_iter_next(hashtable_t *hashtable, void *iter); 153 | 154 | /** 155 | * hashtable_iter_key - Retrieve the key pointed by an iterator 156 | * 157 | * @iter: The iterator 158 | */ 159 | void *hashtable_iter_key(void *iter); 160 | 161 | /** 162 | * hashtable_iter_value - Retrieve the value pointed by an iterator 163 | * 164 | * @iter: The iterator 165 | */ 166 | void *hashtable_iter_value(void *iter); 167 | 168 | /** 169 | * hashtable_iter_set - Set the value pointed by an iterator 170 | * 171 | * @iter: The iterator 172 | * @value: The value to set 173 | */ 174 | void hashtable_iter_set(void *iter, json_t *value); 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /jansson/test/suites/api/test_chaos.c: -------------------------------------------------------------------------------- 1 | #ifndef _GNU_SOURCE 2 | #define _GNU_SOURCE 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include "util.h" 9 | 10 | static int chaos_pos = 0; 11 | static int chaos_fail = 0; 12 | #define CHAOS_MAX_FAILURE 100 13 | 14 | void *chaos_malloc(size_t size) 15 | { 16 | if (chaos_pos == chaos_fail) 17 | return NULL; 18 | 19 | chaos_pos++; 20 | 21 | return malloc(size); 22 | } 23 | 24 | void chaos_free(void *obj) 25 | { 26 | free(obj); 27 | } 28 | 29 | /* Test all potential allocation failures. */ 30 | #define chaos_loop(condition, code, cleanup) \ 31 | { \ 32 | chaos_pos = chaos_fail = 0; \ 33 | while (condition) { \ 34 | if (chaos_fail > CHAOS_MAX_FAILURE) \ 35 | fail("too many chaos failures"); \ 36 | code \ 37 | chaos_pos = 0; \ 38 | chaos_fail++; \ 39 | } \ 40 | cleanup \ 41 | } 42 | 43 | #define chaos_loop_new_value(json, initcall) \ 44 | chaos_loop(!json, json = initcall;, json_decref(json); json = NULL;) 45 | 46 | int test_unpack() 47 | { 48 | int ret = -1; 49 | int v1; 50 | int v2; 51 | json_error_t error; 52 | json_t *root = json_pack("{s:i, s:i, s:i, s:i}", "n1", 1, "n2", 2, "n3", 3, "n4", 4); 53 | 54 | if (!root) 55 | return -1; 56 | 57 | if (!json_unpack_ex(root, &error, JSON_STRICT, "{s:i, s:i}", "n1", &v1, "n2", &v2)) 58 | fail("Unexpected success"); 59 | 60 | if (json_error_code(&error) != json_error_end_of_input_expected) { 61 | if (json_error_code(&error) != json_error_out_of_memory) 62 | fail("Unexpected error code"); 63 | 64 | goto out; 65 | } 66 | 67 | if (strcmp(error.text, "2 object item(s) left unpacked: n3, n4")) 68 | goto out; 69 | 70 | ret = 0; 71 | 72 | out: 73 | json_decref(root); 74 | return ret; 75 | } 76 | 77 | int dump_chaos_callback(const char *buffer, size_t size, void *data) 78 | { 79 | json_t *obj = json_object(); 80 | 81 | (void)buffer; 82 | (void)size; 83 | (void)data; 84 | 85 | if (!obj) 86 | return -1; 87 | 88 | json_decref(obj); 89 | 90 | return 0; 91 | } 92 | 93 | static void test_chaos() 94 | { 95 | json_malloc_t orig_malloc; 96 | json_free_t orig_free; 97 | json_t *json = NULL; 98 | json_t *obj = json_object(); 99 | json_t *arr1 = json_array(); 100 | json_t *arr2 = json_array(); 101 | json_t *txt = json_string("test"); 102 | json_t *intnum = json_integer(1); 103 | json_t *dblnum = json_real(0.5); 104 | char *dumptxt = NULL; 105 | json_t *dumpobj = json_pack("{s:[iiis], s:s}", 106 | "key1", 1, 2, 3, "txt", 107 | "key2", "v2"); 108 | int keyno; 109 | 110 | if (!obj || !arr1 || !arr2 || !txt || !intnum || !dblnum || !dumpobj) 111 | fail("failed to allocate basic objects"); 112 | 113 | json_get_alloc_funcs(&orig_malloc, &orig_free); 114 | json_set_alloc_funcs(chaos_malloc, chaos_free); 115 | 116 | chaos_loop_new_value(json, json_pack("{s:s}", "key", "value")); 117 | chaos_loop_new_value(json, json_pack("{s:[]}", "key")); 118 | chaos_loop_new_value(json, json_pack("[biIf]", 1, 1, (json_int_t)1, 1.0)); 119 | chaos_loop_new_value(json, json_pack("[s*,s*]", "v1", "v2")); 120 | chaos_loop_new_value(json, json_pack("o", json_incref(txt))); 121 | chaos_loop_new_value(json, json_pack("O", txt)); 122 | chaos_loop_new_value(json, json_pack("s++", "a", 123 | "long string to force realloc", 124 | "another long string to force yet another reallocation of the string because " 125 | "that's what we are testing.")); 126 | 127 | chaos_loop(test_unpack(),,); 128 | 129 | chaos_loop(json_dump_callback(dumpobj, dump_chaos_callback, NULL, JSON_INDENT(1)),,); 130 | chaos_loop(json_dump_callback(dumpobj, dump_chaos_callback, NULL, JSON_INDENT(1) | JSON_SORT_KEYS),,); 131 | chaos_loop(!dumptxt, dumptxt = json_dumps(dumpobj, JSON_COMPACT);, free(dumptxt); dumptxt = NULL;); 132 | 133 | chaos_loop_new_value(json, json_copy(obj)); 134 | chaos_loop_new_value(json, json_deep_copy(obj)); 135 | 136 | chaos_loop_new_value(json, json_copy(arr1)); 137 | chaos_loop_new_value(json, json_deep_copy(arr1)); 138 | 139 | chaos_loop_new_value(json, json_copy(txt)); 140 | chaos_loop_new_value(json, json_copy(intnum)); 141 | chaos_loop_new_value(json, json_copy(dblnum)); 142 | 143 | #define JSON_LOAD_TXT "{\"n\":[1,2,3,4,5,6,7,8,9,10]}" 144 | chaos_loop_new_value(json, json_loads(JSON_LOAD_TXT, 0, NULL)); 145 | chaos_loop_new_value(json, json_loadb(JSON_LOAD_TXT, strlen(JSON_LOAD_TXT), 0, NULL)); 146 | 147 | chaos_loop_new_value(json, json_sprintf("%s", "string")); 148 | 149 | for (keyno = 0; keyno < 100; ++keyno) { 150 | #if !defined(_MSC_VER) || _MSC_VER >= 1900 151 | /* Skip this test on old Windows compilers. */ 152 | char testkey[10]; 153 | 154 | snprintf(testkey, sizeof(testkey), "test%d", keyno); 155 | chaos_loop(json_object_set_new_nocheck(obj, testkey, json_object()),,); 156 | #endif 157 | chaos_loop(json_array_append_new(arr1, json_null()),,); 158 | chaos_loop(json_array_insert_new(arr2, 0, json_null()),,); 159 | } 160 | 161 | chaos_loop(json_array_extend(arr1, arr2),,); 162 | chaos_loop(json_string_set_nocheck(txt, "test"),,); 163 | 164 | json_set_alloc_funcs(orig_malloc, orig_free); 165 | json_decref(obj); 166 | json_decref(arr1); 167 | json_decref(arr2); 168 | json_decref(txt); 169 | json_decref(intnum); 170 | json_decref(dblnum); 171 | json_decref(dumpobj); 172 | } 173 | 174 | static void run_tests() 175 | { 176 | test_chaos(); 177 | } 178 | -------------------------------------------------------------------------------- /jansson/doc/github_commits.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #define BUFFER_SIZE (256 * 1024) /* 256 KB */ 15 | 16 | #define URL_FORMAT "https://api.github.com/repos/%s/%s/commits" 17 | #define URL_SIZE 256 18 | 19 | /* Return the offset of the first newline in text or the length of 20 | text if there's no newline */ 21 | static int newline_offset(const char *text) 22 | { 23 | const char *newline = strchr(text, '\n'); 24 | if(!newline) 25 | return strlen(text); 26 | else 27 | return (int)(newline - text); 28 | } 29 | 30 | struct write_result 31 | { 32 | char *data; 33 | int pos; 34 | }; 35 | 36 | static size_t write_response(void *ptr, size_t size, size_t nmemb, void *stream) 37 | { 38 | struct write_result *result = (struct write_result *)stream; 39 | 40 | if(result->pos + size * nmemb >= BUFFER_SIZE - 1) 41 | { 42 | fprintf(stderr, "error: too small buffer\n"); 43 | return 0; 44 | } 45 | 46 | memcpy(result->data + result->pos, ptr, size * nmemb); 47 | result->pos += size * nmemb; 48 | 49 | return size * nmemb; 50 | } 51 | 52 | static char *request(const char *url) 53 | { 54 | CURL *curl = NULL; 55 | CURLcode status; 56 | struct curl_slist *headers = NULL; 57 | char *data = NULL; 58 | long code; 59 | 60 | curl_global_init(CURL_GLOBAL_ALL); 61 | curl = curl_easy_init(); 62 | if(!curl) 63 | goto error; 64 | 65 | data = malloc(BUFFER_SIZE); 66 | if(!data) 67 | goto error; 68 | 69 | struct write_result write_result = { 70 | .data = data, 71 | .pos = 0 72 | }; 73 | 74 | curl_easy_setopt(curl, CURLOPT_URL, url); 75 | 76 | /* GitHub commits API v3 requires a User-Agent header */ 77 | headers = curl_slist_append(headers, "User-Agent: Jansson-Tutorial"); 78 | curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); 79 | 80 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_response); 81 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result); 82 | 83 | status = curl_easy_perform(curl); 84 | if(status != 0) 85 | { 86 | fprintf(stderr, "error: unable to request data from %s:\n", url); 87 | fprintf(stderr, "%s\n", curl_easy_strerror(status)); 88 | goto error; 89 | } 90 | 91 | curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code); 92 | if(code != 200) 93 | { 94 | fprintf(stderr, "error: server responded with code %ld\n", code); 95 | goto error; 96 | } 97 | 98 | curl_easy_cleanup(curl); 99 | curl_slist_free_all(headers); 100 | curl_global_cleanup(); 101 | 102 | /* zero-terminate the result */ 103 | data[write_result.pos] = '\0'; 104 | 105 | return data; 106 | 107 | error: 108 | if(data) 109 | free(data); 110 | if(curl) 111 | curl_easy_cleanup(curl); 112 | if(headers) 113 | curl_slist_free_all(headers); 114 | curl_global_cleanup(); 115 | return NULL; 116 | } 117 | 118 | int main(int argc, char *argv[]) 119 | { 120 | size_t i; 121 | char *text; 122 | char url[URL_SIZE]; 123 | 124 | json_t *root; 125 | json_error_t error; 126 | 127 | if(argc != 3) 128 | { 129 | fprintf(stderr, "usage: %s USER REPOSITORY\n\n", argv[0]); 130 | fprintf(stderr, "List commits at USER's REPOSITORY.\n\n"); 131 | return 2; 132 | } 133 | 134 | snprintf(url, URL_SIZE, URL_FORMAT, argv[1], argv[2]); 135 | 136 | text = request(url); 137 | if(!text) 138 | return 1; 139 | 140 | root = json_loads(text, 0, &error); 141 | free(text); 142 | 143 | if(!root) 144 | { 145 | fprintf(stderr, "error: on line %d: %s\n", error.line, error.text); 146 | return 1; 147 | } 148 | 149 | if(!json_is_array(root)) 150 | { 151 | fprintf(stderr, "error: root is not an array\n"); 152 | json_decref(root); 153 | return 1; 154 | } 155 | 156 | for(i = 0; i < json_array_size(root); i++) 157 | { 158 | json_t *data, *sha, *commit, *message; 159 | const char *message_text; 160 | 161 | data = json_array_get(root, i); 162 | if(!json_is_object(data)) 163 | { 164 | fprintf(stderr, "error: commit data %d is not an object\n", (int)(i + 1)); 165 | json_decref(root); 166 | return 1; 167 | } 168 | 169 | sha = json_object_get(data, "sha"); 170 | if(!json_is_string(sha)) 171 | { 172 | fprintf(stderr, "error: commit %d: sha is not a string\n", (int)(i + 1)); 173 | return 1; 174 | } 175 | 176 | commit = json_object_get(data, "commit"); 177 | if(!json_is_object(commit)) 178 | { 179 | fprintf(stderr, "error: commit %d: commit is not an object\n", (int)(i + 1)); 180 | json_decref(root); 181 | return 1; 182 | } 183 | 184 | message = json_object_get(commit, "message"); 185 | if(!json_is_string(message)) 186 | { 187 | fprintf(stderr, "error: commit %d: message is not a string\n", (int)(i + 1)); 188 | json_decref(root); 189 | return 1; 190 | } 191 | 192 | message_text = json_string_value(message); 193 | printf("%.8s %.*s\n", 194 | json_string_value(sha), 195 | newline_offset(message_text), 196 | message_text); 197 | } 198 | 199 | json_decref(root); 200 | return 0; 201 | } 202 | -------------------------------------------------------------------------------- /jansson/configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ([2.60]) 2 | AC_INIT([jansson], [2.11], [petri@digip.org]) 3 | 4 | AC_CONFIG_AUX_DIR([.]) 5 | AM_INIT_AUTOMAKE([1.10 foreign]) 6 | 7 | AC_CONFIG_SRCDIR([src/value.c]) 8 | AC_CONFIG_HEADERS([jansson_private_config.h]) 9 | 10 | # Checks for programs. 11 | AC_PROG_CC 12 | AC_PROG_LIBTOOL 13 | AM_CONDITIONAL([GCC], [test x$GCC = xyes]) 14 | 15 | # Checks for libraries. 16 | 17 | # Checks for header files. 18 | AC_CHECK_HEADERS([endian.h fcntl.h locale.h sched.h unistd.h sys/param.h sys/stat.h sys/time.h sys/types.h]) 19 | 20 | # Checks for typedefs, structures, and compiler characteristics. 21 | AC_TYPE_INT32_T 22 | AC_TYPE_UINT32_T 23 | AC_TYPE_UINT16_T 24 | AC_TYPE_UINT8_T 25 | AC_TYPE_LONG_LONG_INT 26 | 27 | AC_C_INLINE 28 | case $ac_cv_c_inline in 29 | yes) json_inline=inline;; 30 | no) json_inline=;; 31 | *) json_inline=$ac_cv_c_inline;; 32 | esac 33 | AC_SUBST([json_inline]) 34 | 35 | # Checks for library functions. 36 | AC_CHECK_FUNCS([close getpid gettimeofday localeconv open read sched_yield strtoll]) 37 | 38 | AC_MSG_CHECKING([for gcc __sync builtins]) 39 | have_sync_builtins=no 40 | AC_TRY_LINK( 41 | [], [unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1); __sync_add_and_fetch(&val, 1); __sync_sub_and_fetch(&val, 1);], 42 | [have_sync_builtins=yes], 43 | ) 44 | if test "x$have_sync_builtins" = "xyes"; then 45 | AC_DEFINE([HAVE_SYNC_BUILTINS], [1], 46 | [Define to 1 if gcc's __sync builtins are available]) 47 | json_have_sync_builtins=1 48 | else 49 | json_have_sync_builtins=0 50 | fi 51 | AC_SUBST([json_have_sync_builtins]) 52 | AC_MSG_RESULT([$have_sync_builtins]) 53 | 54 | AC_MSG_CHECKING([for gcc __atomic builtins]) 55 | have_atomic_builtins=no 56 | AC_TRY_LINK( 57 | [], [char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_RELEASE); __atomic_load_n(&v, __ATOMIC_ACQUIRE); __atomic_add_fetch(&v, 1, __ATOMIC_ACQUIRE); __atomic_sub_fetch(&v, 1, __ATOMIC_RELEASE);], 58 | [have_atomic_builtins=yes], 59 | ) 60 | if test "x$have_atomic_builtins" = "xyes"; then 61 | AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], 62 | [Define to 1 if gcc's __atomic builtins are available]) 63 | json_have_atomic_builtins=1 64 | else 65 | json_have_atomic_builtins=0 66 | fi 67 | AC_SUBST([json_have_atomic_builtins]) 68 | AC_MSG_RESULT([$have_atomic_builtins]) 69 | 70 | case "$ac_cv_type_long_long_int$ac_cv_func_strtoll" in 71 | yesyes) json_have_long_long=1;; 72 | *) json_have_long_long=0;; 73 | esac 74 | AC_SUBST([json_have_long_long]) 75 | 76 | case "$ac_cv_header_locale_h$ac_cv_func_localeconv" in 77 | yesyes) json_have_localeconv=1;; 78 | *) json_have_localeconv=0;; 79 | esac 80 | AC_SUBST([json_have_localeconv]) 81 | 82 | # Features 83 | AC_ARG_ENABLE([urandom], 84 | [AS_HELP_STRING([--disable-urandom], 85 | [Don't use /dev/urandom to seed the hash function])], 86 | [use_urandom=$enableval], [use_urandom=yes]) 87 | 88 | if test "x$use_urandom" = xyes; then 89 | AC_DEFINE([USE_URANDOM], [1], 90 | [Define to 1 if /dev/urandom should be used for seeding the hash function]) 91 | fi 92 | 93 | AC_ARG_ENABLE([windows-cryptoapi], 94 | [AS_HELP_STRING([--disable-windows-cryptoapi], 95 | [Don't use CryptGenRandom to seed the hash function])], 96 | [use_windows_cryptoapi=$enableval], [use_windows_cryptoapi=yes]) 97 | 98 | if test "x$use_windows_cryptoapi" = xyes; then 99 | AC_DEFINE([USE_WINDOWS_CRYPTOAPI], [1], 100 | [Define to 1 if CryptGenRandom should be used for seeding the hash function]) 101 | fi 102 | 103 | AC_ARG_ENABLE([initial-hashtable-order], 104 | [AS_HELP_STRING([--enable-initial-hashtable-order=VAL], 105 | [Number of buckets new object hashtables contain is 2 raised to this power. The default is 3, so empty hashtables contain 2^3 = 8 buckets.])], 106 | [initial_hashtable_order=$enableval], [initial_hashtable_order=3]) 107 | AC_DEFINE_UNQUOTED([INITIAL_HASHTABLE_ORDER], [$initial_hashtable_order], 108 | [Number of buckets new object hashtables contain is 2 raised to this power. E.g. 3 -> 2^3 = 8.]) 109 | 110 | AC_ARG_ENABLE([Bsymbolic], 111 | [AS_HELP_STRING([--disable-Bsymbolic], 112 | [Avoid linking with -Bsymbolic-function])], 113 | [], [with_Bsymbolic=check]) 114 | 115 | if test "x$with_Bsymbolic" != "xno" ; then 116 | AC_MSG_CHECKING([for -Bsymbolic-functions linker flag]) 117 | saved_LDFLAGS="${LDFLAGS}" 118 | LDFLAGS=-Wl,-Bsymbolic-functions 119 | AC_TRY_LINK( 120 | [], [int main (void) { return 0; }], 121 | [AC_MSG_RESULT([yes]) 122 | have_Bsymbolic=yes], 123 | [AC_MSG_RESULT([no]) 124 | have_Bsymbolic=no] 125 | ) 126 | LDFLAGS="${saved_LDFLAGS}" 127 | 128 | if test "x$with_Bsymbolic" = "xcheck" ; then 129 | with_Bsymbolic=$have_Bsymbolic; 130 | fi 131 | if test "x$with_Bsymbolic:x$have_Bsymbolic" = "xyes:xno" ; then 132 | AC_MSG_ERROR([linker support is required for -Bsymbolic]) 133 | fi 134 | fi 135 | 136 | AS_IF([test "x$with_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions]) 137 | AC_SUBST(JSON_BSYMBOLIC_LDFLAGS) 138 | 139 | if test x$GCC = xyes; then 140 | AC_MSG_CHECKING(for -Wno-format-truncation) 141 | wnoformat_truncation="-Wno-format-truncation" 142 | AS_IF([${CC} -Wno-format-truncation -Werror -S -o /dev/null -xc /dev/null > /dev/null 2>&1], 143 | [AC_MSG_RESULT(yes)], 144 | [AC_MSG_RESULT(no) 145 | wnoformat_truncation=""]) 146 | 147 | AM_CFLAGS="-Wall -Wextra -Wdeclaration-after-statement -Wshadow ${wnoformat_truncation}" 148 | fi 149 | AC_SUBST([AM_CFLAGS]) 150 | 151 | AC_CONFIG_FILES([ 152 | jansson.pc 153 | Makefile 154 | doc/Makefile 155 | src/Makefile 156 | src/jansson_config.h 157 | test/Makefile 158 | test/bin/Makefile 159 | test/suites/Makefile 160 | test/suites/api/Makefile 161 | ]) 162 | AC_OUTPUT 163 | --------------------------------------------------------------------------------