git.delta.rocks / jrsonnet / refs/commits / a05afd32cebc

difftreelog

source

bindings/c/libjsonnet_test_file.c1.2 KiBsourcehistory
1/*2Copyright 2015 Google Inc. All rights reserved.3Licensed under the Apache License, Version 2.0 (the "License");4you may not use this file except in compliance with the License.5You may obtain a copy of the License at6    http://www.apache.org/licenses/LICENSE-2.07Unless required by applicable law or agreed to in writing, software8distributed under the License is distributed on an "AS IS" BASIS,9WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.10See the License for the specific language governing permissions and11limitations under the License.12*/1314#include <stdlib.h>15#include <stdio.h>1617#include "libjsonnet.h"1819int main(int argc, const char **argv)20{21    int error;22    char *output;23    struct JsonnetVm *vm;24    if (argc != 2) {25        fprintf(stderr, "libjsonnet_test_file <file>\n");26        return EXIT_FAILURE;27    }28    vm = jsonnet_make();29    output = jsonnet_evaluate_file(vm, argv[1], &error);30    if (error) {31        fprintf(stderr, "%s", output);32        jsonnet_realloc(vm, output, 0);33        jsonnet_destroy(vm);34        return EXIT_FAILURE;35    }36    printf("%s", output);37    jsonnet_realloc(vm, output, 0);38    jsonnet_destroy(vm);39    return EXIT_SUCCESS;40}