@voxgig/sdkgen 4.8.2 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/action/doctor.d.ts +1 -0
- package/dist/action/doctor.js +50 -2
- package/dist/action/doctor.js.map +1 -1
- package/dist/helpers/naming.js +4 -2
- package/dist/helpers/naming.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/sdkgen.aon +21 -0
- package/package.json +1 -1
- package/project/.sdk/model/feature/secrets.aon +120 -18
- package/project/.sdk/model/target/c.aon +10 -0
- package/project/.sdk/model/target/clojure.aon +13 -0
- package/project/.sdk/model/target/cpp.aon +10 -0
- package/project/.sdk/model/target/csharp.aon +9 -0
- package/project/.sdk/model/target/dart.aon +10 -0
- package/project/.sdk/model/target/elixir.aon +9 -0
- package/project/.sdk/model/target/go.aon +13 -0
- package/project/.sdk/model/target/java.aon +9 -0
- package/project/.sdk/model/target/js.aon +7 -0
- package/project/.sdk/model/target/kotlin.aon +9 -0
- package/project/.sdk/model/target/lean.aon +17 -0
- package/project/.sdk/model/target/lua.aon +8 -0
- package/project/.sdk/model/target/ocaml.aon +9 -0
- package/project/.sdk/model/target/perl.aon +8 -0
- package/project/.sdk/model/target/php.aon +8 -0
- package/project/.sdk/model/target/py.aon +13 -0
- package/project/.sdk/model/target/rb.aon +8 -0
- package/project/.sdk/model/target/rust.aon +10 -0
- package/project/.sdk/model/target/scala.aon +21 -2
- package/project/.sdk/model/target/swift.aon +18 -0
- package/project/.sdk/model/target/ts.aon +13 -0
- package/project/.sdk/model/target/zig.aon +9 -0
- package/project/.sdk/src/cmp/clojure/Package_clojure.ts +9 -2
- package/project/.sdk/src/cmp/cpp/Gitignore_cpp.ts +3 -0
- package/project/.sdk/src/cmp/dart/Test_dart.ts +2 -0
- package/project/.sdk/src/cmp/elixir/Package_elixir.ts +4 -1
- package/project/.sdk/src/cmp/go/Config_go.ts +59 -2
- package/project/.sdk/src/cmp/go/Main_go.ts +8 -2
- package/project/.sdk/src/cmp/java/Test_java.ts +6 -5
- package/project/.sdk/src/cmp/kotlin/Test_kotlin.ts +6 -5
- package/project/.sdk/src/cmp/lean/Package_lean.ts +23 -0
- package/project/.sdk/src/cmp/lean/ReadmeInstall_lean.ts +1 -0
- package/project/.sdk/src/cmp/lean/ReadmeTopTest_lean.ts +1 -0
- package/project/.sdk/src/cmp/ocaml/Gitignore_ocaml.ts +1 -0
- package/project/.sdk/src/cmp/ocaml/Main_ocaml.ts +7 -3
- package/project/.sdk/src/cmp/py/Config_py.ts +82 -1
- package/project/.sdk/src/cmp/py/Main_py.ts +44 -0
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +2 -0
- package/project/.sdk/src/cmp/swift/Main_swift.ts +10 -0
- package/project/.sdk/src/cmp/swift/Package_swift.ts +13 -1
- package/project/.sdk/src/cmp/ts/Config_ts.ts +42 -17
- package/project/.sdk/src/cmp/ts/fragment/Config.data.fragment.ts +13 -1
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +13 -1
- package/project/.sdk/src/cmp/zig/Package_zig.ts +15 -11
- package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +3 -3
- package/project/.sdk/src/cmp/zig/fragment/EntityListOp.fragment.zig +3 -3
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +3 -3
- package/project/.sdk/src/cmp/zig/utility_zig.ts +50 -1
- package/project/.sdk/tm/c/Makefile +38 -3
- package/project/.sdk/tm/c/tests/omni_resolver.h +361 -0
- package/project/.sdk/tm/c/tests/omni_smoke_test.c +237 -0
- package/project/.sdk/tm/c/tests/primary_corpus_test.c +205 -284
- package/project/.sdk/tm/c/tests/struct_corpus_test.c +292 -212
- package/project/.sdk/tm/c/tests/vendor/omni/json.c +811 -0
- package/project/.sdk/tm/c/tests/vendor/omni/omni.h +240 -0
- package/project/.sdk/tm/c/tests/vendor/omni/runner.c +940 -0
- package/project/.sdk/tm/c/tests/vendor/omni/util.c +351 -0
- package/project/.sdk/tm/c/utility/struct/utility.c +7 -2
- package/project/.sdk/tm/clojure/test/sdk/test/omni.clj +401 -0
- package/project/.sdk/tm/clojure/test/sdk/test/omni_smoke.clj +81 -0
- package/project/.sdk/tm/clojure/test/sdk/test/primary.clj +92 -58
- package/project/.sdk/tm/clojure/test/sdk/test/struct_corpus.clj +122 -149
- package/project/.sdk/tm/clojure/test/sdk/test_runner.clj +8 -3
- package/project/.sdk/tm/clojure/test/vendor/omni/voxgig/omni/json.clj +145 -0
- package/project/.sdk/tm/clojure/test/vendor/omni/voxgig/omni/runner.clj +445 -0
- package/project/.sdk/tm/clojure/test/vendor/omni/voxgig/omni/util.clj +145 -0
- package/project/.sdk/tm/cpp/Makefile +5 -1
- package/project/.sdk/tm/cpp/test/omni_resolver.hpp +473 -0
- package/project/.sdk/tm/cpp/test/omni_smoke_test.cpp +209 -0
- package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +243 -184
- package/project/.sdk/tm/cpp/test/runner_support.hpp +68 -181
- package/project/.sdk/tm/cpp/test/struct_corpus_test.cpp +183 -56
- package/project/.sdk/tm/cpp/test/vendor/omni/json.hpp +406 -0
- package/project/.sdk/tm/cpp/test/vendor/omni/omni.hpp +751 -0
- package/project/.sdk/tm/cpp/test/vendor/omni/util.hpp +256 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +7 -1
- package/project/.sdk/tm/csharp/test/OmniResolver.cs +491 -0
- package/project/.sdk/tm/csharp/test/OmniSmokeTest.cs +106 -0
- package/project/.sdk/tm/csharp/test/PrimaryUtilityTest.cs +299 -316
- package/project/.sdk/tm/csharp/test/Runner.cs +104 -269
- package/project/.sdk/tm/csharp/test/StructUtilityTest.cs +535 -724
- package/project/.sdk/tm/csharp/test/vendor/omni/Runner.cs +864 -0
- package/project/.sdk/tm/csharp/test/vendor/omni/Util.cs +347 -0
- package/project/.sdk/tm/csharp/utility/MakeSpec.cs +3 -1
- package/project/.sdk/tm/csharp/utility/PrepareMethod.cs +6 -1
- package/project/.sdk/tm/csharp/utility/struct/Struct.cs +21 -5
- package/project/.sdk/tm/dart/test/omni.dart +520 -0
- package/project/.sdk/tm/dart/test/omni_smoke_test.dart +143 -0
- package/project/.sdk/tm/dart/test/primary_test.dart +86 -28
- package/project/.sdk/tm/dart/test/struct_test.dart +438 -11
- package/project/.sdk/tm/dart/test/vendor/omni/omni.dart +7 -0
- package/project/.sdk/tm/dart/test/vendor/omni/runner.dart +653 -0
- package/project/.sdk/tm/dart/test/vendor/omni/util.dart +232 -0
- package/project/.sdk/tm/elixir/Makefile +11 -3
- package/project/.sdk/tm/elixir/test/omni_smoke_test.exs +117 -0
- package/project/.sdk/tm/elixir/test/primary_utility_test.exs +341 -16
- package/project/.sdk/tm/elixir/test/struct_corpus_test.exs +554 -9
- package/project/.sdk/tm/elixir/test/support/omni.ex +377 -0
- package/project/.sdk/tm/elixir/test/vendor/omni/json.ex +122 -0
- package/project/.sdk/tm/elixir/test/vendor/omni/runner.ex +623 -0
- package/project/.sdk/tm/elixir/test/vendor/omni/util.ex +187 -0
- package/project/.sdk/tm/go/core/context.go +32 -16
- package/project/.sdk/tm/go/feature/secrets/plugin/capability.go +261 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/catalog.go +78 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/config.go +652 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/depend.go +250 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/env.go +194 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/export.go +80 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/graph.go +238 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/host.go +1575 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/order.go +248 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/point.go +184 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/ref.go +123 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/resolve.go +79 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/types.go +296 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/util.go +87 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/version.go +161 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/aws/aws.go +292 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/aws/sigv4.go +201 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/azuresecrets/azuresecrets.go +187 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/boru/boru.go +184 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/doppler/doppler.go +114 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/gcpsecrets/gcpsecrets.go +156 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/hashicorp/hashicorp.go +208 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/httpjson/httpjson.go +241 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/infisical/infisical.go +150 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/onepassword/onepassword.go +152 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/secretspec/secretspec.go +143 -0
- package/project/.sdk/tm/go/feature/secrets/sekreto/addr.go +120 -0
- package/project/.sdk/tm/go/feature/secrets/sekreto/providers.go +442 -0
- package/project/.sdk/tm/go/feature/secrets/sekreto/sekreto.go +714 -0
- package/project/.sdk/tm/go/feature/secrets_feature.go +675 -0
- package/project/.sdk/tm/go/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/go/test/feature/secrets/secrets_feature_test.go +799 -0
- package/project/.sdk/tm/go/test/omni/omni.go +902 -0
- package/project/.sdk/tm/go/test/omni/util.go +381 -0
- package/project/.sdk/tm/go/test/omniresolver_test.go +748 -0
- package/project/.sdk/tm/go/test/omnismoke_test.go +112 -0
- package/project/.sdk/tm/go/test/primary_utility_test.go +123 -191
- package/project/.sdk/tm/go/test/struct_utility_test.go +323 -16
- package/project/.sdk/tm/go/test/testsupport_test.go +294 -0
- package/project/.sdk/tm/go/utility/make_options.go +8 -1
- package/project/.sdk/tm/go/utility/prepare_method.go +5 -1
- package/project/.sdk/tm/go/utility/struct/voxgigstruct.go +2 -2
- package/project/.sdk/tm/java/test/OmniResolver.java +355 -0
- package/project/.sdk/tm/java/test/OmniSmokeTest.java +99 -0
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +254 -280
- package/project/.sdk/tm/java/test/RunnerSupport.java +9 -194
- package/project/.sdk/tm/java/test/StructCorpusTest.java +119 -42
- package/project/.sdk/tm/java/test/vendor/omni/Json.java +287 -0
- package/project/.sdk/tm/java/test/vendor/omni/Runner.java +851 -0
- package/project/.sdk/tm/java/test/vendor/omni/Util.java +322 -0
- package/project/.sdk/tm/java/utility/MakeSpec.java +3 -1
- package/project/.sdk/tm/java/utility/PrepareMethod.java +5 -5
- package/project/.sdk/tm/java/utility/struct/Struct.java +17 -4
- package/project/.sdk/tm/js/src/utility/StructUtility.js +3 -3
- package/project/.sdk/tm/js/test/omni.js +251 -0
- package/project/.sdk/tm/js/test/omni.test.js +105 -0
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +6 -2
- package/project/.sdk/tm/js/test/utility/StructUtility.test.js +27 -2
- package/project/.sdk/tm/js/test/vendor/omni/index.js +77 -0
- package/project/.sdk/tm/js/test/vendor/omni/runner.js +628 -0
- package/project/.sdk/tm/js/test/vendor/omni/util.js +229 -0
- package/project/.sdk/tm/kotlin/core/Utility.kt +1 -1
- package/project/.sdk/tm/kotlin/test/OmniResolver.kt +343 -0
- package/project/.sdk/tm/kotlin/test/OmniSmokeTest.kt +100 -0
- package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +244 -262
- package/project/.sdk/tm/kotlin/test/RunnerSupport.kt +9 -178
- package/project/.sdk/tm/kotlin/test/StructCorpusTest.kt +121 -32
- package/project/.sdk/tm/kotlin/test/vendor/omni/Json.kt +264 -0
- package/project/.sdk/tm/kotlin/test/vendor/omni/Runner.kt +615 -0
- package/project/.sdk/tm/kotlin/test/vendor/omni/Util.kt +139 -0
- package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +6 -3
- package/project/.sdk/tm/kotlin/utility/Prepare.kt +6 -6
- package/project/.sdk/tm/kotlin/utility/struct/Struct.kt +18 -2
- package/project/.sdk/tm/lean/Makefile +12 -5
- package/project/.sdk/tm/lean/src/SdkUtility.lean +14 -1
- package/project/.sdk/tm/lean/test/OmniResolver.lean +358 -0
- package/project/.sdk/tm/lean/test/OmniSmoke.lean +174 -0
- package/project/.sdk/tm/lean/test/StructCorpus.lean +245 -574
- package/project/.sdk/tm/lean/test/TPrimaryUtility.lean +155 -291
- package/project/.sdk/tm/lean/test/vendor/omni/Omni.lean +997 -0
- package/project/.sdk/tm/lua/test/omni.lua +456 -0
- package/project/.sdk/tm/lua/test/omni_smoke_test.lua +103 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +250 -509
- package/project/.sdk/tm/lua/test/struct_utility_test.lua +161 -70
- package/project/.sdk/tm/lua/test/vendor/omni/json.lua +268 -0
- package/project/.sdk/tm/lua/test/vendor/omni/regex.lua +385 -0
- package/project/.sdk/tm/lua/test/vendor/omni/runner.lua +641 -0
- package/project/.sdk/tm/lua/test/vendor/omni/util.lua +282 -0
- package/project/.sdk/tm/lua/utility/prepare_method.lua +5 -1
- package/project/.sdk/tm/lua/utility/struct/regex.lua +663 -0
- package/project/.sdk/tm/lua/utility/struct/struct.lua +660 -420
- package/project/.sdk/tm/ocaml/Makefile +37 -12
- package/project/.sdk/tm/ocaml/test/omni_resolver.ml +284 -0
- package/project/.sdk/tm/ocaml/test/omni_smoke_test.ml +169 -0
- package/project/.sdk/tm/ocaml/test/primary_utility_test.ml +84 -100
- package/project/.sdk/tm/ocaml/test/struct_corpus.ml +225 -201
- package/project/.sdk/tm/ocaml/test/vendor/omni/omni.ml +1157 -0
- package/project/.sdk/tm/perl/lib/Voxgig/Struct.pm +88 -12
- package/project/.sdk/tm/perl/t/omni.pm +647 -0
- package/project/.sdk/tm/perl/t/omni_smoke.t +87 -0
- package/project/.sdk/tm/perl/t/primary_utility.t +189 -487
- package/project/.sdk/tm/perl/t/struct_utility.t +455 -389
- package/project/.sdk/tm/perl/t/vendor/omni/Voxgig/Omni/Runner.pm +649 -0
- package/project/.sdk/tm/perl/t/vendor/omni/Voxgig/Omni/Util.pm +253 -0
- package/project/.sdk/tm/perl/t/vendor/omni/Voxgig/Omni.pm +24 -0
- package/project/.sdk/tm/perl/utility/prepare_method.pm +7 -2
- package/project/.sdk/tm/php/test/Omni.php +691 -0
- package/project/.sdk/tm/php/test/OmniSmokeTest.php +93 -0
- package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +210 -571
- package/project/.sdk/tm/php/test/StructUtilityTest.php +320 -342
- package/project/.sdk/tm/php/test/vendor/omni/Runner.php +644 -0
- package/project/.sdk/tm/php/test/vendor/omni/Util.php +283 -0
- package/project/.sdk/tm/php/utility/MakeSpec.php +10 -3
- package/project/.sdk/tm/php/utility/PrepareBody.php +7 -1
- package/project/.sdk/tm/php/utility/PrepareMethod.php +6 -2
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/__init__.py +36 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/capability.py +141 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/catalog.py +50 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/config.py +333 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/depend.py +198 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/env.py +147 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/export.py +52 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/graph.py +139 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/host.py +1053 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/order.py +171 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/point.py +95 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/ref.py +116 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/resolve.py +59 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/types.py +87 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/version.py +112 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/__init__.py +76 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/addr.py +116 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/aws.py +192 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/azuresecrets.py +120 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/boru.py +140 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/doppler.py +62 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/gcpsecrets.py +101 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/hashicorp.py +151 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/httpjson.py +115 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/infisical.py +90 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/onepassword.py +101 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/secretspec.py +119 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/sigv4.py +125 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/providers.py +211 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/sekreto.py +475 -0
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +467 -0
- package/project/.sdk/tm/py/pkg/utility/prepare_method.py +5 -1
- package/project/.sdk/tm/py/pkg/utility/voxgig_struct/__init__.py +0 -2
- package/project/.sdk/tm/py/pkg/utility/voxgig_struct/voxgig_struct.py +780 -529
- package/project/.sdk/tm/py/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/py/test/feature/__init__.py +0 -0
- package/project/.sdk/tm/py/test/feature/secrets/__init__.py +0 -0
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +337 -0
- package/project/.sdk/tm/py/test/omni.py +415 -0
- package/project/.sdk/tm/py/test/test_omni_smoke.py +74 -0
- package/project/.sdk/tm/py/test/test_primary_utility.py +144 -668
- package/project/.sdk/tm/py/test/test_struct_utility.py +74 -27
- package/project/.sdk/tm/py/test/voxgig_omni/__init__.py +62 -0
- package/project/.sdk/tm/py/test/voxgig_omni/runner.py +580 -0
- package/project/.sdk/tm/py/test/voxgig_omni/util.py +252 -0
- package/project/.sdk/tm/rb/test/omni.rb +505 -0
- package/project/.sdk/tm/rb/test/omni_smoke_test.rb +72 -0
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +174 -560
- package/project/.sdk/tm/rb/test/struct_utility_test.rb +13 -7
- package/project/.sdk/tm/rb/test/vendor/omni/runner.rb +493 -0
- package/project/.sdk/tm/rb/test/vendor/omni/util.rb +199 -0
- package/project/.sdk/tm/rb/test/vendor/omni/voxgig_omni.rb +15 -0
- package/project/.sdk/tm/rb/utility/prepare_method.rb +5 -1
- package/project/.sdk/tm/rust/tests/common/mod.rs +19 -242
- package/project/.sdk/tm/rust/tests/omni_resolver/mod.rs +888 -0
- package/project/.sdk/tm/rust/tests/omni_smoke_test.rs +286 -0
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +318 -312
- package/project/.sdk/tm/rust/tests/struct_utility_test.rs +66 -28
- package/project/.sdk/tm/rust/tests/vendor/omni/json.rs +412 -0
- package/project/.sdk/tm/rust/tests/vendor/omni/mod.rs +38 -0
- package/project/.sdk/tm/rust/tests/vendor/omni/regex.rs +392 -0
- package/project/.sdk/tm/rust/tests/vendor/omni/runner.rs +1001 -0
- package/project/.sdk/tm/rust/tests/vendor/omni/util.rs +161 -0
- package/project/.sdk/tm/rust/utility/prepare_method.rs +5 -1
- package/project/.sdk/tm/scala/Makefile +16 -6
- package/project/.sdk/tm/scala/sdktest/OmniResolver.scala +497 -0
- package/project/.sdk/tm/scala/sdktest/OmniSmoke.scala +192 -0
- package/project/.sdk/tm/scala/sdktest/PrimaryCorpus.scala +47 -19
- package/project/.sdk/tm/scala/sdktest/StructCorpus.scala +0 -0
- package/project/.sdk/tm/scala/sdktest/vendor/omni/Json.scala +229 -0
- package/project/.sdk/tm/scala/sdktest/vendor/omni/Runner.scala +552 -0
- package/project/.sdk/tm/scala/sdktest/vendor/omni/Util.scala +104 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Constants.swift +10 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Inject.swift +28 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Injection.swift +5 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Minor.swift +4 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Validate.swift +15 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Prepare.swift +6 -1
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/OmniResolver.swift +474 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/OmniSmokeTest.swift +107 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +141 -178
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/Runner.swift +17 -113
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/StructUtilityTest.swift +295 -446
- package/project/.sdk/tm/swift/Tests/vendor/omni/Json.swift +364 -0
- package/project/.sdk/tm/swift/Tests/vendor/omni/Runner.swift +730 -0
- package/project/.sdk/tm/swift/Tests/vendor/omni/Util.swift +162 -0
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +7 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Capability.ts +148 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Catalog.ts +55 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Config.ts +344 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Depend.ts +205 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Env.ts +138 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Export.ts +46 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/FeatureHost.ts +349 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Graph.ts +181 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Host.ts +1132 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Order.ts +177 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Point.ts +119 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Ref.ts +102 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Resolve.ts +61 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Types.ts +112 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Version.ts +100 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/index.ts +37 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/Sekreto.ts +163 -30
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/index.ts +27 -22
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/aws.ts +26 -36
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/azuresecrets.ts +19 -21
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/boru.ts +36 -17
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/doppler.ts +14 -21
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/gcpsecrets.ts +27 -27
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/hashicorp.ts +25 -39
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/plugins/httpjson.ts +99 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/infisical.ts +14 -16
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/onepassword.ts +15 -22
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/plugins/secretspec.ts +98 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{Sigv4.ts → plugins/sigv4.ts} +7 -6
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/addr.ts +97 -23
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/builtin.ts +37 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/dotenv.ts +4 -17
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/env.ts +4 -16
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/file.ts +11 -25
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/memory.ts +6 -23
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/support.ts +106 -39
- package/project/.sdk/tm/ts/src/utility/StructUtility.ts +3 -3
- package/project/.sdk/tm/ts/test/omni.ts +104 -32
- package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +27 -0
- package/project/.sdk/tm/ts/test/vendor/omni/Runner.ts +32 -5
- package/project/.sdk/tm/ts/test/vendor/omni/Util.ts +2 -2
- package/project/.sdk/tm/ts/test/vendor/omni/index.ts +2 -2
- package/project/.sdk/tm/zig/Makefile +15 -1
- package/project/.sdk/tm/zig/build.zig +23 -5
- package/project/.sdk/tm/zig/core/helpers.zig +52 -11
- package/project/.sdk/tm/zig/core/mem.zig +17 -1
- package/project/.sdk/tm/zig/core/utility.zig +23 -19
- package/project/.sdk/tm/zig/feature/audit.zig +2 -2
- package/project/.sdk/tm/zig/feature/cache.zig +2 -2
- package/project/.sdk/tm/zig/feature/debug.zig +5 -5
- package/project/.sdk/tm/zig/feature/netsim.zig +2 -2
- package/project/.sdk/tm/zig/feature/paging.zig +2 -2
- package/project/.sdk/tm/zig/feature/proxy.zig +15 -8
- package/project/.sdk/tm/zig/feature/streaming.zig +5 -5
- package/project/.sdk/tm/zig/feature/support.zig +3 -3
- package/project/.sdk/tm/zig/feature/telemetry.zig +5 -5
- package/project/.sdk/tm/zig/feature/test.zig +10 -5
- package/project/.sdk/tm/zig/test/fh.zig +10 -10
- package/project/.sdk/tm/zig/test/gotcha_test.zig +5 -5
- package/project/.sdk/tm/zig/test/omniresolver.zig +515 -0
- package/project/.sdk/tm/zig/test/omnismoke_test.zig +284 -0
- package/project/.sdk/tm/zig/test/pipeline_test.zig +8 -8
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +145 -155
- package/project/.sdk/tm/zig/test/struct_corpus.zig +264 -187
- package/project/.sdk/tm/zig/test/vendor/omni/omni.zig +1314 -0
- package/project/.sdk/tm/zig/test/vendor/omni/regex.zig +446 -0
- package/project/.sdk/tm/zig/utility/voxgigstruct/regex.zig +7 -4
- package/project/.sdk/tm/zig/utility/voxgigstruct/struct.zig +356 -157
- package/project/sdkgen-package.json +1 -1
- package/src/action/doctor.ts +66 -2
- package/src/helpers/naming.ts +4 -2
- package/project/.sdk/tm/c/tests/runner.h +0 -274
- package/project/.sdk/tm/cpp/test/struct_runner.hpp +0 -314
- package/project/.sdk/tm/csharp/test/StructRunner.cs +0 -276
- package/project/.sdk/tm/dart/test/runner.dart +0 -406
- package/project/.sdk/tm/dart/test/struct_corpus.dart +0 -531
- package/project/.sdk/tm/elixir/test/support/struct_corpus.ex +0 -1088
- package/project/.sdk/tm/go/test/runner_test.go +0 -629
- package/project/.sdk/tm/go/test/struct_runner_test.go +0 -1094
- package/project/.sdk/tm/java/test/StructRunner.java +0 -281
- package/project/.sdk/tm/js/test/runner.js +0 -387
- package/project/.sdk/tm/kotlin/test/StructRunner.kt +0 -177
- package/project/.sdk/tm/lua/test/struct_runner.lua +0 -602
- package/project/.sdk/tm/ocaml/test/corpus_runner.ml +0 -185
- package/project/.sdk/tm/perl/t/struct_runner.pm +0 -275
- package/project/.sdk/tm/php/test/StructRunner.php +0 -275
- package/project/.sdk/tm/py/test/struct_runner.py +0 -411
- package/project/.sdk/tm/rb/test/struct_runner.rb +0 -309
- package/project/.sdk/tm/rust/tests/struct_runner/mod.rs +0 -424
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/Registry.ts +0 -90
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/http.ts +0 -66
- package/project/.sdk/tm/ts/test/vendor/omni/compat.ts +0 -188
- package/project/.sdk/tm/zig/test/struct_runner.zig +0 -464
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
// VENDORED: @voxgig/omni sdk-20260907-0029-0 (c/src/json.c)
|
|
2
|
+
// Source: https://github.com/voxgig/omni @ 274708cc2d12b21707d975543953f845f8444be0 [tag: sdk-20260907-0029-0]
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
/* The omni JSON value model, pool allocator, parser and printer.
|
|
5
|
+
*
|
|
6
|
+
* The omni runner must be able to test *any* library, and must add no
|
|
7
|
+
* third-party dependencies, so it carries its own JSON support rather than
|
|
8
|
+
* borrowing one or using the system under test.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <math.h>
|
|
12
|
+
#include <stdio.h>
|
|
13
|
+
#include <stdlib.h>
|
|
14
|
+
#include <string.h>
|
|
15
|
+
|
|
16
|
+
#include "omni.h"
|
|
17
|
+
|
|
18
|
+
/* ---- pool ---------------------------------------------------------- */
|
|
19
|
+
|
|
20
|
+
typedef struct omni_block omni_block;
|
|
21
|
+
|
|
22
|
+
struct omni_block {
|
|
23
|
+
void *ptr;
|
|
24
|
+
omni_block *next;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
struct omni_pool {
|
|
28
|
+
omni_block *blocks;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
omni_pool *omni_pool_new(void) {
|
|
32
|
+
omni_pool *pool = (omni_pool *)calloc(1, sizeof(omni_pool));
|
|
33
|
+
return pool;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void *omni_pool_alloc(omni_pool *pool, size_t size) {
|
|
37
|
+
void *ptr = calloc(1, size);
|
|
38
|
+
omni_block *block;
|
|
39
|
+
|
|
40
|
+
if (NULL == ptr) {
|
|
41
|
+
return NULL;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
block = (omni_block *)calloc(1, sizeof(omni_block));
|
|
45
|
+
if (NULL == block) {
|
|
46
|
+
free(ptr);
|
|
47
|
+
return NULL;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
block->ptr = ptr;
|
|
51
|
+
block->next = pool->blocks;
|
|
52
|
+
pool->blocks = block;
|
|
53
|
+
|
|
54
|
+
return ptr;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
char *omni_pool_strdup(omni_pool *pool, const char *text) {
|
|
58
|
+
size_t len;
|
|
59
|
+
char *out;
|
|
60
|
+
|
|
61
|
+
if (NULL == text) {
|
|
62
|
+
text = "";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
len = strlen(text);
|
|
66
|
+
out = (char *)omni_pool_alloc(pool, len + 1);
|
|
67
|
+
if (NULL == out) {
|
|
68
|
+
return NULL;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
memcpy(out, text, len);
|
|
72
|
+
out[len] = '\0';
|
|
73
|
+
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void omni_pool_free(omni_pool *pool) {
|
|
78
|
+
omni_block *block;
|
|
79
|
+
|
|
80
|
+
if (NULL == pool) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
block = pool->blocks;
|
|
85
|
+
while (NULL != block) {
|
|
86
|
+
omni_block *next = block->next;
|
|
87
|
+
free(block->ptr);
|
|
88
|
+
free(block);
|
|
89
|
+
block = next;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
free(pool);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* ---- values -------------------------------------------------------- */
|
|
96
|
+
|
|
97
|
+
static omni_json *omni_new(omni_pool *pool, omni_type type) {
|
|
98
|
+
omni_json *val = (omni_json *)omni_pool_alloc(pool, sizeof(omni_json));
|
|
99
|
+
if (NULL == val) {
|
|
100
|
+
return NULL;
|
|
101
|
+
}
|
|
102
|
+
val->type = type;
|
|
103
|
+
val->pool = pool;
|
|
104
|
+
return val;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
omni_json *omni_absent(omni_pool *pool) { return omni_new(pool, OMNI_ABSENT); }
|
|
108
|
+
omni_json *omni_null(omni_pool *pool) { return omni_new(pool, OMNI_NULL); }
|
|
109
|
+
|
|
110
|
+
omni_json *omni_bool(omni_pool *pool, int val) {
|
|
111
|
+
omni_json *out = omni_new(pool, OMNI_BOOL);
|
|
112
|
+
out->boolval = val ? 1 : 0;
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
omni_json *omni_num(omni_pool *pool, double val) {
|
|
117
|
+
omni_json *out = omni_new(pool, OMNI_NUM);
|
|
118
|
+
out->numval = val;
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
omni_json *omni_str(omni_pool *pool, const char *val) {
|
|
123
|
+
omni_json *out = omni_new(pool, OMNI_STR);
|
|
124
|
+
out->strval = omni_pool_strdup(pool, val);
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
omni_json *omni_list(omni_pool *pool) { return omni_new(pool, OMNI_LIST); }
|
|
129
|
+
omni_json *omni_map(omni_pool *pool) { return omni_new(pool, OMNI_MAP); }
|
|
130
|
+
|
|
131
|
+
/* Pool-backed growth: the old array is kept (and freed with the pool). */
|
|
132
|
+
static void *omni_grow(omni_pool *pool, void *old, size_t entrysize, size_t used, size_t *cap) {
|
|
133
|
+
size_t newcap = (0 == *cap) ? 8 : (*cap * 2);
|
|
134
|
+
void *out = omni_pool_alloc(pool, entrysize * newcap);
|
|
135
|
+
|
|
136
|
+
if (NULL == out) {
|
|
137
|
+
return old;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (NULL != old && 0 < used) {
|
|
141
|
+
memcpy(out, old, entrysize * used);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
*cap = newcap;
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
void omni_list_push(omni_json *list, omni_json *val) {
|
|
149
|
+
if (NULL == list || OMNI_LIST != list->type) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (list->listlen >= list->listcap) {
|
|
154
|
+
list->list = (omni_json **)omni_grow(list->pool, list->list, sizeof(omni_json *),
|
|
155
|
+
list->listlen, &list->listcap);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
list->list[list->listlen++] = val;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
void omni_map_set(omni_json *map, const char *key, omni_json *val) {
|
|
162
|
+
size_t index;
|
|
163
|
+
|
|
164
|
+
if (NULL == map || OMNI_MAP != map->type) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
for (index = 0; index < map->maplen; index++) {
|
|
169
|
+
if (0 == strcmp(map->keys[index], key)) {
|
|
170
|
+
map->vals[index] = val;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (map->maplen >= map->mapcap) {
|
|
176
|
+
size_t keycap = map->mapcap;
|
|
177
|
+
size_t valcap = map->mapcap;
|
|
178
|
+
map->keys = (char **)omni_grow(map->pool, map->keys, sizeof(char *), map->maplen, &keycap);
|
|
179
|
+
map->vals =
|
|
180
|
+
(omni_json **)omni_grow(map->pool, map->vals, sizeof(omni_json *), map->maplen, &valcap);
|
|
181
|
+
map->mapcap = keycap;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
map->keys[map->maplen] = omni_pool_strdup(map->pool, key);
|
|
185
|
+
map->vals[map->maplen] = val;
|
|
186
|
+
map->maplen++;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
omni_json *omni_map_get(const omni_json *map, const char *key) {
|
|
190
|
+
size_t index;
|
|
191
|
+
|
|
192
|
+
if (NULL == map || OMNI_MAP != map->type) {
|
|
193
|
+
return NULL;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
for (index = 0; index < map->maplen; index++) {
|
|
197
|
+
if (0 == strcmp(map->keys[index], key)) {
|
|
198
|
+
return map->vals[index];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return omni_absent(map->pool);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
int omni_map_has(const omni_json *map, const char *key) {
|
|
206
|
+
size_t index;
|
|
207
|
+
|
|
208
|
+
if (NULL == map || OMNI_MAP != map->type) {
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
for (index = 0; index < map->maplen; index++) {
|
|
213
|
+
if (0 == strcmp(map->keys[index], key)) {
|
|
214
|
+
return 1;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
omni_json *omni_list_get(const omni_json *list, size_t index) {
|
|
222
|
+
if (NULL == list || OMNI_LIST != list->type || index >= list->listlen) {
|
|
223
|
+
return NULL;
|
|
224
|
+
}
|
|
225
|
+
return list->list[index];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
int omni_ismap(const omni_json *val) { return NULL != val && OMNI_MAP == val->type; }
|
|
229
|
+
int omni_islist(const omni_json *val) { return NULL != val && OMNI_LIST == val->type; }
|
|
230
|
+
int omni_isnode(const omni_json *val) { return omni_ismap(val) || omni_islist(val); }
|
|
231
|
+
int omni_isabsent(const omni_json *val) { return NULL == val || OMNI_ABSENT == val->type; }
|
|
232
|
+
int omni_isnull(const omni_json *val) { return NULL != val && OMNI_NULL == val->type; }
|
|
233
|
+
int omni_isnone(const omni_json *val) { return omni_isabsent(val) || omni_isnull(val); }
|
|
234
|
+
int omni_isnum(const omni_json *val) { return NULL != val && OMNI_NUM == val->type; }
|
|
235
|
+
int omni_isstr(const omni_json *val) { return NULL != val && OMNI_STR == val->type; }
|
|
236
|
+
|
|
237
|
+
const char *omni_strval(const omni_json *val) {
|
|
238
|
+
return omni_isstr(val) ? val->strval : NULL;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
double omni_numval(const omni_json *val) { return omni_isnum(val) ? val->numval : 0.0; }
|
|
242
|
+
|
|
243
|
+
/* ---- text buffer --------------------------------------------------- */
|
|
244
|
+
|
|
245
|
+
typedef struct {
|
|
246
|
+
omni_pool *pool;
|
|
247
|
+
char *text;
|
|
248
|
+
size_t len;
|
|
249
|
+
size_t cap;
|
|
250
|
+
} omni_buf;
|
|
251
|
+
|
|
252
|
+
static void buf_init(omni_buf *buf, omni_pool *pool) {
|
|
253
|
+
buf->pool = pool;
|
|
254
|
+
buf->cap = 64;
|
|
255
|
+
buf->len = 0;
|
|
256
|
+
buf->text = (char *)omni_pool_alloc(pool, buf->cap);
|
|
257
|
+
if (NULL != buf->text) {
|
|
258
|
+
buf->text[0] = '\0';
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
static void buf_add(omni_buf *buf, const char *text) {
|
|
263
|
+
size_t len = strlen(text);
|
|
264
|
+
|
|
265
|
+
if (buf->len + len + 1 > buf->cap) {
|
|
266
|
+
size_t newcap = buf->cap;
|
|
267
|
+
char *grown;
|
|
268
|
+
while (buf->len + len + 1 > newcap) {
|
|
269
|
+
newcap *= 2;
|
|
270
|
+
}
|
|
271
|
+
grown = (char *)omni_pool_alloc(buf->pool, newcap);
|
|
272
|
+
if (NULL == grown) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
memcpy(grown, buf->text, buf->len);
|
|
276
|
+
buf->text = grown;
|
|
277
|
+
buf->cap = newcap;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
memcpy(buf->text + buf->len, text, len);
|
|
281
|
+
buf->len += len;
|
|
282
|
+
buf->text[buf->len] = '\0';
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
static void buf_addchar(omni_buf *buf, char ch) {
|
|
286
|
+
char text[2];
|
|
287
|
+
text[0] = ch;
|
|
288
|
+
text[1] = '\0';
|
|
289
|
+
buf_add(buf, text);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/* ---- number and string rendering ----------------------------------- */
|
|
293
|
+
|
|
294
|
+
char *omni_numstr(omni_pool *pool, double val) {
|
|
295
|
+
char text[64];
|
|
296
|
+
|
|
297
|
+
if (val != val || val > 1e308 * 10 || val < -1e308 * 10) {
|
|
298
|
+
return omni_pool_strdup(pool, "null");
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (val == floor(val) && fabs(val) < 9007199254740992.0) {
|
|
302
|
+
snprintf(text, sizeof(text), "%.0f", val);
|
|
303
|
+
/* "-0" is still zero. */
|
|
304
|
+
if (0 == strcmp(text, "-0")) {
|
|
305
|
+
return omni_pool_strdup(pool, "0");
|
|
306
|
+
}
|
|
307
|
+
return omni_pool_strdup(pool, text);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
snprintf(text, sizeof(text), "%.17g", val);
|
|
311
|
+
return omni_pool_strdup(pool, text);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
static void buf_quote(omni_buf *buf, const char *text) {
|
|
315
|
+
size_t index;
|
|
316
|
+
char escape[8];
|
|
317
|
+
|
|
318
|
+
buf_addchar(buf, '"');
|
|
319
|
+
|
|
320
|
+
for (index = 0; '\0' != text[index]; index++) {
|
|
321
|
+
unsigned char ch = (unsigned char)text[index];
|
|
322
|
+
switch (ch) {
|
|
323
|
+
case '"':
|
|
324
|
+
buf_add(buf, "\\\"");
|
|
325
|
+
break;
|
|
326
|
+
case '\\':
|
|
327
|
+
buf_add(buf, "\\\\");
|
|
328
|
+
break;
|
|
329
|
+
case '\n':
|
|
330
|
+
buf_add(buf, "\\n");
|
|
331
|
+
break;
|
|
332
|
+
case '\r':
|
|
333
|
+
buf_add(buf, "\\r");
|
|
334
|
+
break;
|
|
335
|
+
case '\t':
|
|
336
|
+
buf_add(buf, "\\t");
|
|
337
|
+
break;
|
|
338
|
+
default:
|
|
339
|
+
if (0x20 > ch) {
|
|
340
|
+
snprintf(escape, sizeof(escape), "\\u%04x", ch);
|
|
341
|
+
buf_add(buf, escape);
|
|
342
|
+
} else {
|
|
343
|
+
buf_addchar(buf, (char)ch);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
buf_addchar(buf, '"');
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
static void jsonstr_val(omni_buf *buf, const omni_json *val) {
|
|
352
|
+
size_t index;
|
|
353
|
+
size_t inner;
|
|
354
|
+
|
|
355
|
+
if (omni_isabsent(val)) {
|
|
356
|
+
buf_add(buf, "undefined");
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
switch (val->type) {
|
|
361
|
+
case OMNI_NULL:
|
|
362
|
+
buf_add(buf, "null");
|
|
363
|
+
return;
|
|
364
|
+
case OMNI_BOOL:
|
|
365
|
+
buf_add(buf, val->boolval ? "true" : "false");
|
|
366
|
+
return;
|
|
367
|
+
case OMNI_NUM:
|
|
368
|
+
buf_add(buf, omni_numstr(buf->pool, val->numval));
|
|
369
|
+
return;
|
|
370
|
+
case OMNI_STR:
|
|
371
|
+
buf_quote(buf, val->strval);
|
|
372
|
+
return;
|
|
373
|
+
case OMNI_LIST:
|
|
374
|
+
buf_addchar(buf, '[');
|
|
375
|
+
for (index = 0; index < val->listlen; index++) {
|
|
376
|
+
if (0 < index) {
|
|
377
|
+
buf_addchar(buf, ',');
|
|
378
|
+
}
|
|
379
|
+
jsonstr_val(buf, val->list[index]);
|
|
380
|
+
}
|
|
381
|
+
buf_addchar(buf, ']');
|
|
382
|
+
return;
|
|
383
|
+
case OMNI_MAP: {
|
|
384
|
+
/* Sorted keys, so messages are identical in every port. */
|
|
385
|
+
size_t *order = (size_t *)omni_pool_alloc(buf->pool, sizeof(size_t) * (val->maplen + 1));
|
|
386
|
+
for (index = 0; index < val->maplen; index++) {
|
|
387
|
+
order[index] = index;
|
|
388
|
+
}
|
|
389
|
+
for (index = 1; index < val->maplen; index++) {
|
|
390
|
+
size_t hold = order[index];
|
|
391
|
+
inner = index;
|
|
392
|
+
while (0 < inner && 0 < strcmp(val->keys[order[inner - 1]], val->keys[hold])) {
|
|
393
|
+
order[inner] = order[inner - 1];
|
|
394
|
+
inner--;
|
|
395
|
+
}
|
|
396
|
+
order[inner] = hold;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
buf_addchar(buf, '{');
|
|
400
|
+
for (index = 0; index < val->maplen; index++) {
|
|
401
|
+
if (0 < index) {
|
|
402
|
+
buf_addchar(buf, ',');
|
|
403
|
+
}
|
|
404
|
+
buf_quote(buf, val->keys[order[index]]);
|
|
405
|
+
buf_addchar(buf, ':');
|
|
406
|
+
jsonstr_val(buf, val->vals[order[index]]);
|
|
407
|
+
}
|
|
408
|
+
buf_addchar(buf, '}');
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
default:
|
|
412
|
+
buf_add(buf, "undefined");
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
char *omni_jsonstr(omni_pool *pool, const omni_json *val) {
|
|
417
|
+
omni_buf buf;
|
|
418
|
+
buf_init(&buf, pool);
|
|
419
|
+
jsonstr_val(&buf, val);
|
|
420
|
+
return buf.text;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
char *omni_stringify(omni_pool *pool, const omni_json *val) {
|
|
424
|
+
if (omni_isstr(val)) {
|
|
425
|
+
return omni_pool_strdup(pool, val->strval);
|
|
426
|
+
}
|
|
427
|
+
return omni_jsonstr(pool, val);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/* ---- parser -------------------------------------------------------- */
|
|
431
|
+
|
|
432
|
+
/* Nesting bound: a value nested deeper than this fails the parse rather
|
|
433
|
+
* than overflowing the C stack. */
|
|
434
|
+
#define OMNI_PARSE_MAXDEPTH 4096
|
|
435
|
+
|
|
436
|
+
typedef struct {
|
|
437
|
+
omni_pool *pool;
|
|
438
|
+
const char *text;
|
|
439
|
+
size_t pos;
|
|
440
|
+
size_t len;
|
|
441
|
+
int depth;
|
|
442
|
+
char *err;
|
|
443
|
+
} omni_parser;
|
|
444
|
+
|
|
445
|
+
static void parse_error(omni_parser *parser, const char *reason) {
|
|
446
|
+
char text[128];
|
|
447
|
+
if (NULL != parser->err) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
snprintf(text, sizeof(text), "omni: %s at %lu", reason, (unsigned long)parser->pos);
|
|
451
|
+
parser->err = omni_pool_strdup(parser->pool, text);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
static void parse_ws(omni_parser *parser) {
|
|
455
|
+
while (parser->pos < parser->len) {
|
|
456
|
+
char ch = parser->text[parser->pos];
|
|
457
|
+
if (' ' == ch || '\t' == ch || '\n' == ch || '\r' == ch) {
|
|
458
|
+
parser->pos++;
|
|
459
|
+
} else {
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
static omni_json *parse_val(omni_parser *parser);
|
|
466
|
+
|
|
467
|
+
static char *parse_rawstr(omni_parser *parser) {
|
|
468
|
+
omni_buf buf;
|
|
469
|
+
|
|
470
|
+
if (parser->pos >= parser->len || '"' != parser->text[parser->pos]) {
|
|
471
|
+
parse_error(parser, "expected string");
|
|
472
|
+
return NULL;
|
|
473
|
+
}
|
|
474
|
+
parser->pos++;
|
|
475
|
+
|
|
476
|
+
buf_init(&buf, parser->pool);
|
|
477
|
+
|
|
478
|
+
while (parser->pos < parser->len) {
|
|
479
|
+
char ch = parser->text[parser->pos++];
|
|
480
|
+
|
|
481
|
+
if ('"' == ch) {
|
|
482
|
+
return buf.text;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if ('\\' != ch) {
|
|
486
|
+
buf_addchar(&buf, ch);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (parser->pos >= parser->len) {
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
ch = parser->text[parser->pos++];
|
|
495
|
+
switch (ch) {
|
|
496
|
+
case '"':
|
|
497
|
+
buf_addchar(&buf, '"');
|
|
498
|
+
break;
|
|
499
|
+
case '\\':
|
|
500
|
+
buf_addchar(&buf, '\\');
|
|
501
|
+
break;
|
|
502
|
+
case '/':
|
|
503
|
+
buf_addchar(&buf, '/');
|
|
504
|
+
break;
|
|
505
|
+
case 'b':
|
|
506
|
+
buf_addchar(&buf, '\b');
|
|
507
|
+
break;
|
|
508
|
+
case 'f':
|
|
509
|
+
buf_addchar(&buf, '\f');
|
|
510
|
+
break;
|
|
511
|
+
case 'n':
|
|
512
|
+
buf_addchar(&buf, '\n');
|
|
513
|
+
break;
|
|
514
|
+
case 'r':
|
|
515
|
+
buf_addchar(&buf, '\r');
|
|
516
|
+
break;
|
|
517
|
+
case 't':
|
|
518
|
+
buf_addchar(&buf, '\t');
|
|
519
|
+
break;
|
|
520
|
+
case 'u': {
|
|
521
|
+
unsigned int code = 0;
|
|
522
|
+
int digit;
|
|
523
|
+
if (parser->pos + 4 > parser->len) {
|
|
524
|
+
parse_error(parser, "bad unicode escape");
|
|
525
|
+
return NULL;
|
|
526
|
+
}
|
|
527
|
+
for (digit = 0; digit < 4; digit++) {
|
|
528
|
+
char hex = parser->text[parser->pos++];
|
|
529
|
+
code *= 16;
|
|
530
|
+
if ('0' <= hex && '9' >= hex) {
|
|
531
|
+
code += (unsigned int)(hex - '0');
|
|
532
|
+
} else if ('a' <= hex && 'f' >= hex) {
|
|
533
|
+
code += (unsigned int)(hex - 'a' + 10);
|
|
534
|
+
} else if ('A' <= hex && 'F' >= hex) {
|
|
535
|
+
code += (unsigned int)(hex - 'A' + 10);
|
|
536
|
+
} else {
|
|
537
|
+
parse_error(parser, "bad unicode escape");
|
|
538
|
+
return NULL;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
/* UTF-8 encode the code point. */
|
|
542
|
+
if (0x80 > code) {
|
|
543
|
+
buf_addchar(&buf, (char)code);
|
|
544
|
+
} else if (0x800 > code) {
|
|
545
|
+
buf_addchar(&buf, (char)(0xC0 | (code >> 6)));
|
|
546
|
+
buf_addchar(&buf, (char)(0x80 | (code & 0x3F)));
|
|
547
|
+
} else {
|
|
548
|
+
buf_addchar(&buf, (char)(0xE0 | (code >> 12)));
|
|
549
|
+
buf_addchar(&buf, (char)(0x80 | ((code >> 6) & 0x3F)));
|
|
550
|
+
buf_addchar(&buf, (char)(0x80 | (code & 0x3F)));
|
|
551
|
+
}
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
default:
|
|
555
|
+
parse_error(parser, "bad escape");
|
|
556
|
+
return NULL;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
parse_error(parser, "unterminated string");
|
|
561
|
+
return NULL;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
static omni_json *parse_map(omni_parser *parser) {
|
|
565
|
+
omni_json *out = omni_map(parser->pool);
|
|
566
|
+
parser->pos++; /* { */
|
|
567
|
+
|
|
568
|
+
parse_ws(parser);
|
|
569
|
+
if (parser->pos < parser->len && '}' == parser->text[parser->pos]) {
|
|
570
|
+
parser->pos++;
|
|
571
|
+
return out;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
for (;;) {
|
|
575
|
+
char *key;
|
|
576
|
+
omni_json *val;
|
|
577
|
+
|
|
578
|
+
parse_ws(parser);
|
|
579
|
+
key = parse_rawstr(parser);
|
|
580
|
+
if (NULL == key) {
|
|
581
|
+
return NULL;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
parse_ws(parser);
|
|
585
|
+
if (parser->pos >= parser->len || ':' != parser->text[parser->pos]) {
|
|
586
|
+
parse_error(parser, "expected ':'");
|
|
587
|
+
return NULL;
|
|
588
|
+
}
|
|
589
|
+
parser->pos++;
|
|
590
|
+
|
|
591
|
+
parse_ws(parser);
|
|
592
|
+
val = parse_val(parser);
|
|
593
|
+
if (NULL == val) {
|
|
594
|
+
return NULL;
|
|
595
|
+
}
|
|
596
|
+
omni_map_set(out, key, val);
|
|
597
|
+
|
|
598
|
+
parse_ws(parser);
|
|
599
|
+
if (parser->pos >= parser->len) {
|
|
600
|
+
parse_error(parser, "unterminated object");
|
|
601
|
+
return NULL;
|
|
602
|
+
}
|
|
603
|
+
if (',' == parser->text[parser->pos]) {
|
|
604
|
+
parser->pos++;
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
if ('}' == parser->text[parser->pos]) {
|
|
608
|
+
parser->pos++;
|
|
609
|
+
return out;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
parse_error(parser, "expected ',' or '}'");
|
|
613
|
+
return NULL;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
static omni_json *parse_list(omni_parser *parser) {
|
|
618
|
+
omni_json *out = omni_list(parser->pool);
|
|
619
|
+
parser->pos++; /* [ */
|
|
620
|
+
|
|
621
|
+
parse_ws(parser);
|
|
622
|
+
if (parser->pos < parser->len && ']' == parser->text[parser->pos]) {
|
|
623
|
+
parser->pos++;
|
|
624
|
+
return out;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
for (;;) {
|
|
628
|
+
omni_json *val;
|
|
629
|
+
|
|
630
|
+
parse_ws(parser);
|
|
631
|
+
val = parse_val(parser);
|
|
632
|
+
if (NULL == val) {
|
|
633
|
+
return NULL;
|
|
634
|
+
}
|
|
635
|
+
omni_list_push(out, val);
|
|
636
|
+
|
|
637
|
+
parse_ws(parser);
|
|
638
|
+
if (parser->pos >= parser->len) {
|
|
639
|
+
parse_error(parser, "unterminated array");
|
|
640
|
+
return NULL;
|
|
641
|
+
}
|
|
642
|
+
if (',' == parser->text[parser->pos]) {
|
|
643
|
+
parser->pos++;
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
if (']' == parser->text[parser->pos]) {
|
|
647
|
+
parser->pos++;
|
|
648
|
+
return out;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
parse_error(parser, "expected ',' or ']'");
|
|
652
|
+
return NULL;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
static int parse_word(omni_parser *parser, const char *word) {
|
|
657
|
+
size_t len = strlen(word);
|
|
658
|
+
if (parser->pos + len > parser->len ||
|
|
659
|
+
0 != strncmp(parser->text + parser->pos, word, len)) {
|
|
660
|
+
parse_error(parser, "bad literal");
|
|
661
|
+
return 0;
|
|
662
|
+
}
|
|
663
|
+
parser->pos += len;
|
|
664
|
+
return 1;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
static omni_json *parse_num(omni_parser *parser) {
|
|
668
|
+
size_t start = parser->pos;
|
|
669
|
+
char text[64];
|
|
670
|
+
char *end;
|
|
671
|
+
size_t len;
|
|
672
|
+
double val;
|
|
673
|
+
|
|
674
|
+
if (parser->pos < parser->len &&
|
|
675
|
+
('-' == parser->text[parser->pos] || '+' == parser->text[parser->pos])) {
|
|
676
|
+
parser->pos++;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
while (parser->pos < parser->len) {
|
|
680
|
+
char ch = parser->text[parser->pos];
|
|
681
|
+
if (('0' <= ch && '9' >= ch) || '.' == ch || 'e' == ch || 'E' == ch || '-' == ch ||
|
|
682
|
+
'+' == ch) {
|
|
683
|
+
parser->pos++;
|
|
684
|
+
} else {
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
len = parser->pos - start;
|
|
690
|
+
if (0 == len || len >= sizeof(text)) {
|
|
691
|
+
parse_error(parser, "bad number");
|
|
692
|
+
return NULL;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
memcpy(text, parser->text + start, len);
|
|
696
|
+
text[len] = '\0';
|
|
697
|
+
|
|
698
|
+
/* The number must consume exactly the scanned run: `1-2` scans as one
|
|
699
|
+
* token, strtod stops at the `-`, and the remainder is garbage, not a
|
|
700
|
+
* number. Silently keeping the prefix would accept malformed JSON. */
|
|
701
|
+
end = NULL;
|
|
702
|
+
val = strtod(text, &end);
|
|
703
|
+
if (end != text + len) {
|
|
704
|
+
parse_error(parser, "bad number");
|
|
705
|
+
return NULL;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return omni_num(parser->pool, val);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
static omni_json *parse_val(omni_parser *parser) {
|
|
712
|
+
char ch;
|
|
713
|
+
|
|
714
|
+
if (parser->pos >= parser->len) {
|
|
715
|
+
parse_error(parser, "unexpected end of JSON");
|
|
716
|
+
return NULL;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
ch = parser->text[parser->pos];
|
|
720
|
+
|
|
721
|
+
if ('{' == ch || '[' == ch) {
|
|
722
|
+
omni_json *out;
|
|
723
|
+
|
|
724
|
+
if (OMNI_PARSE_MAXDEPTH <= parser->depth) {
|
|
725
|
+
parse_error(parser, "too deeply nested");
|
|
726
|
+
return NULL;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
parser->depth++;
|
|
730
|
+
out = '{' == ch ? parse_map(parser) : parse_list(parser);
|
|
731
|
+
parser->depth--;
|
|
732
|
+
return out;
|
|
733
|
+
}
|
|
734
|
+
if ('"' == ch) {
|
|
735
|
+
char *text = parse_rawstr(parser);
|
|
736
|
+
return NULL == text ? NULL : omni_str(parser->pool, text);
|
|
737
|
+
}
|
|
738
|
+
if ('t' == ch) {
|
|
739
|
+
return parse_word(parser, "true") ? omni_bool(parser->pool, 1) : NULL;
|
|
740
|
+
}
|
|
741
|
+
if ('f' == ch) {
|
|
742
|
+
return parse_word(parser, "false") ? omni_bool(parser->pool, 0) : NULL;
|
|
743
|
+
}
|
|
744
|
+
if ('n' == ch) {
|
|
745
|
+
return parse_word(parser, "null") ? omni_null(parser->pool) : NULL;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return parse_num(parser);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
omni_json *omni_parse(omni_pool *pool, const char *text, char **errout) {
|
|
752
|
+
omni_parser parser;
|
|
753
|
+
omni_json *val;
|
|
754
|
+
|
|
755
|
+
parser.pool = pool;
|
|
756
|
+
parser.text = text;
|
|
757
|
+
parser.pos = 0;
|
|
758
|
+
parser.len = strlen(text);
|
|
759
|
+
parser.depth = 0;
|
|
760
|
+
parser.err = NULL;
|
|
761
|
+
|
|
762
|
+
parse_ws(&parser);
|
|
763
|
+
val = parse_val(&parser);
|
|
764
|
+
parse_ws(&parser);
|
|
765
|
+
|
|
766
|
+
if (NULL != val && parser.pos < parser.len) {
|
|
767
|
+
parse_error(&parser, "trailing content");
|
|
768
|
+
val = NULL;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
if (NULL != errout) {
|
|
772
|
+
*errout = parser.err;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
return val;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
char *omni_readfile(omni_pool *pool, const char *path) {
|
|
779
|
+
FILE *handle = fopen(path, "rb");
|
|
780
|
+
char *text;
|
|
781
|
+
long size;
|
|
782
|
+
size_t got;
|
|
783
|
+
|
|
784
|
+
if (NULL == handle) {
|
|
785
|
+
return NULL;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
if (0 != fseek(handle, 0, SEEK_END)) {
|
|
789
|
+
fclose(handle);
|
|
790
|
+
return NULL;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
size = ftell(handle);
|
|
794
|
+
if (0 > size) {
|
|
795
|
+
fclose(handle);
|
|
796
|
+
return NULL;
|
|
797
|
+
}
|
|
798
|
+
rewind(handle);
|
|
799
|
+
|
|
800
|
+
text = (char *)omni_pool_alloc(pool, (size_t)size + 1);
|
|
801
|
+
if (NULL == text) {
|
|
802
|
+
fclose(handle);
|
|
803
|
+
return NULL;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
got = fread(text, 1, (size_t)size, handle);
|
|
807
|
+
text[got] = '\0';
|
|
808
|
+
fclose(handle);
|
|
809
|
+
|
|
810
|
+
return text;
|
|
811
|
+
}
|