2020-09-08 18:37:17 +08:00
|
|
|
// Copyright 2020 Google LLC
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
2022-01-28 17:47:32 +08:00
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2020-09-08 18:37:17 +08:00
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2022-02-02 17:09:26 +08:00
|
|
|
#ifndef CONTRIB_JSONNET_JSONNET_HELPER_H_
|
|
|
|
#define CONTRIB_JSONNET_JSONNET_HELPER_H_
|
2020-09-08 18:37:17 +08:00
|
|
|
|
|
|
|
extern "C" {
|
2022-02-02 17:09:26 +08:00
|
|
|
#include <libjsonnet.h>
|
|
|
|
#include <libjsonnet_fmt.h>
|
2020-09-08 18:37:17 +08:00
|
|
|
}
|
|
|
|
|
2020-10-02 21:47:41 +08:00
|
|
|
#include "jsonnet/cmd/utils.h" // NOLINT(build/include)
|
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
extern "C" {
|
2022-02-02 17:09:26 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
struct JsonnetVm* c_jsonnet_make(void);
|
2020-09-08 18:37:17 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
void c_jsonnet_destroy(struct JsonnetVm* vm);
|
2020-09-08 18:37:17 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
char* c_jsonnet_evaluate_snippet(struct JsonnetVm* vm, const char* filename,
|
|
|
|
char* snippet, int* error);
|
2020-09-08 18:37:17 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
char* c_jsonnet_evaluate_snippet_multi(struct JsonnetVm* vm,
|
|
|
|
const char* filename,
|
|
|
|
const char* snippet, int* error);
|
2020-09-10 21:27:22 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
char* c_jsonnet_evaluate_snippet_stream(struct JsonnetVm* vm,
|
|
|
|
const char* filename,
|
|
|
|
const char* snippet, int* error);
|
2020-09-10 18:19:06 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
char* c_read_input(bool filename_is_code, const char* filename);
|
2020-09-08 18:37:17 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
void c_free_input(char* input);
|
2020-09-08 18:37:17 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
bool c_write_output_file(const char* output, const char* output_file);
|
2020-09-08 18:37:17 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
char* c_jsonnet_realloc(struct JsonnetVm* vm, char* str, size_t sz);
|
2020-09-10 18:19:06 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
bool c_write_multi_output_files(char* output, char* output_dir,
|
|
|
|
bool show_output_file_names);
|
2020-09-10 21:27:22 +08:00
|
|
|
|
2020-10-02 21:47:41 +08:00
|
|
|
bool write_multi_output_files(char* output, const std::string& output_dir,
|
|
|
|
bool show_output_file_names);
|
2020-09-10 21:27:22 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
bool c_write_output_stream(char* output, char* output_file);
|
2020-09-10 18:19:06 +08:00
|
|
|
|
2020-10-02 21:47:41 +08:00
|
|
|
bool write_output_stream(char* output, const std::string& output_file);
|
2020-09-10 23:42:00 +08:00
|
|
|
|
2022-01-27 20:59:14 +08:00
|
|
|
char* c_jsonnet_fmt_snippet(struct JsonnetVm* vm, const char* filename,
|
|
|
|
const char* snippet, int* error);
|
|
|
|
}
|
2020-10-02 21:47:41 +08:00
|
|
|
|
2022-02-02 17:09:26 +08:00
|
|
|
#endif // CONTRIB_JSONNET_JSONNET_HELPER_H_
|