Revert^2 "Use cil_write_build_ast"

bde09de39f

Change-Id: I1c94eb98d1b37216096dfba297434377f805eed9
This commit is contained in:
Thiébaud Weksteen 2021-10-27 04:50:56 +00:00
parent bde09de39f
commit 1c574576b5

View file

@ -9,7 +9,6 @@
#include <sys/stat.h>
#include <cil/android.h>
#include <cil/cil.h>
#include <cil/cil_write_ast.h>
void __attribute__ ((noreturn)) static usage(char *prog) {
printf("Usage: %s [OPTION]...\n", prog);
@ -90,6 +89,7 @@ int main(int argc, char *argv[])
char *num = NULL;
char *dot;
char *output = NULL;
FILE *output_file = NULL;
struct cil_db *base_db = NULL;
struct cil_db *out_db = NULL;
@ -177,11 +177,21 @@ int main(int argc, char *argv[])
goto exit;
}
}
rc = cil_write_ast(out_db, output);
if (rc != SEPOL_OK) {
output_file = fopen(output, "we");
if (!output_file) {
fprintf(stderr, "Could not open file: %s\n", output);
goto exit;
}
rc = cil_write_build_ast(output_file, out_db);
if (rc != SEPOL_OK) {
fprintf(stderr, "Failed to write AST\n");
goto build_err;
}
build_err:
fclose(output_file);
exit:
free(base);
free(tgt_policy);