From cddc309afba50efc0f325520b0620d04758614ca Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 19 Aug 2007 18:37:38 +0000 Subject: [PATCH] Generator frontend scripts (./libcevap_gen.sh to be run in libcevap/) --- libburn/trunk/doc/libdax_model.txt | 49 ++------------------ libburn/trunk/libcevap/extract_cgen_input.sh | 30 ++++++++++++ libburn/trunk/libcevap/libcevap_gen.sh | 16 +++++++ libburn/trunk/libcevap/main.c | 24 ++++++++++ 4 files changed, 73 insertions(+), 46 deletions(-) create mode 100755 libburn/trunk/libcevap/extract_cgen_input.sh create mode 100755 libburn/trunk/libcevap/libcevap_gen.sh create mode 100644 libburn/trunk/libcevap/main.c diff --git a/libburn/trunk/doc/libdax_model.txt b/libburn/trunk/doc/libdax_model.txt index 594496d3..18519515 100644 --- a/libburn/trunk/doc/libdax_model.txt +++ b/libburn/trunk/doc/libdax_model.txt @@ -862,53 +862,10 @@ Notes: ---------------------------------------------------------------------------- Generate C stubs: - test_dir=...where_to_generate_the_stub... - model_dir=...where_to_find_the_model_file_libdax_model.txt... - xtr_dir=...where_to_find_the_extractor_script_extract_cgen_input.sh... - cgen_dir=...where_to_find_the_cgen_binary... + ( cd libcevap ; ./libcevap_gen.sh ) - /bin/rm "$test_dir"/a.out - cd "$test_dir"/ - cat "$model_dir"/libdax_model.txt | \ - "$xtr_dir"/extract_cgen_input.sh | \ - "$cgen_dir"/cgen -smem_local -ansi -overwrite -global_include cevap_global.h - - Compile (a copy of smem.[ch] has to be placed in $test_dir) : - ( cd "$test_dir" ; cc -g -c *.c 2>&1 | less ) - ----------------------------------------------------------------------------- -"$xtr_dir"/extract_cgen_input.sh : - -#!/bin/sh - -copy_mode=0 - -while true -do - read line - if test "$copy_mode" = "0" - then - if echo " $line" | grep '^ Cgen=' >/dev/null 2>&1 - then - copy_mode=1 - if echo " $line" | grep '^ Cgen=..' >/dev/null 2>&1 - then - echo " $line" | sed -e 's/^ Cgen=//' - fi - elif echo " $line" | grep '^ =end Model=' >/dev/null 2>&1 - then -break - fi - else - if test " $line" = " @" - then - copy_mode=0 - echo "@" - else - echo " $line" | sed -e 's/^ //' - fi - fi -done + Compile test: + ( cd libcevap ; rm cc -g main.c cevap*.c smem.c 2>&1 | less ) ---------------------------------------------------------------------------- diff --git a/libburn/trunk/libcevap/extract_cgen_input.sh b/libburn/trunk/libcevap/extract_cgen_input.sh new file mode 100755 index 00000000..3ca096fb --- /dev/null +++ b/libburn/trunk/libcevap/extract_cgen_input.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +copy_mode=0 + +while true +do + read line + if test "$copy_mode" = "0" + then + if echo " $line" | grep '^ Cgen=' >/dev/null 2>&1 + then + copy_mode=1 + if echo " $line" | grep '^ Cgen=..' >/dev/null 2>&1 + then + echo " $line" | sed -e 's/^ Cgen=//' + fi + elif echo " $line" | grep '^ =end Model=' >/dev/null 2>&1 + then +break + fi + else + if test " $line" = " @" + then + copy_mode=0 + echo "@" + else + echo " $line" | sed -e 's/^ //' + fi + fi +done diff --git a/libburn/trunk/libcevap/libcevap_gen.sh b/libburn/trunk/libcevap/libcevap_gen.sh new file mode 100755 index 00000000..2c7c89d6 --- /dev/null +++ b/libburn/trunk/libcevap/libcevap_gen.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +test_dir=. +model_file=../doc/libdax_model.txt +xtr_dir=. +cgen_dir=. +# cgen_dir=~/projekte/cdrskin_dir/libburn-develop/libcevap + +cd "$test_dir" || exit 1 +test -e smem.h || exit 1 + +cat "$model_file" | \ + "$xtr_dir"/extract_cgen_input.sh | \ + "$cgen_dir"/cgen -smem_local -ansi -global_include cevap_global.h \ + -overwrite "$@" + diff --git a/libburn/trunk/libcevap/main.c b/libburn/trunk/libcevap/main.c new file mode 100644 index 00000000..1d6a3442 --- /dev/null +++ b/libburn/trunk/libcevap/main.c @@ -0,0 +1,24 @@ + +#include +#include + +#include "cevapi.h" + +int main(int argc, char **argv) +{ + struct CevapI *cevap= NULL; + int ret; + + /* full memory supervision */ + Smem_set_record_items(1); + + /* one short trip for testing */ + ret= Cevapi_new(&cevap,0); + if(ret>0) + Cevapi_destroy(&cevap,0); + + /* report any leaked memory */ + Smem_stderr(1|2); + + exit(ret<=0); +}