X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fyaz-asncomp;h=e0a86b123a71b2e26c12fbaae8e2f2900733d1ad;hp=3e6bf21f1add5ac0f1bde824b2a44911c9059d90;hb=d940392c53c32ccf76fb287cc5b997b9e921a431;hpb=92887fb8af4d8697f6569d6a6756860fea5f4b84 diff --git a/util/yaz-asncomp b/util/yaz-asncomp index 3e6bf21..e0a86b1 100755 --- a/util/yaz-asncomp +++ b/util/yaz-asncomp @@ -1,15 +1,11 @@ -#!/bin/sh -# the next line restarts using tclsh \ -exec tclsh "$0" "$@" +#!/usr/bin/tclsh # # yaz-comp: ASN.1 Compiler for YAZ -# (c) Index Data 1996-2003 +# (c) Index Data 1996-2007 # See the file LICENSE for details. # -# $Id: yaz-asncomp,v 1.1 2003-05-27 21:12:23 adam Exp $ -# -set yc_version 0.3 +set yc_version 0.4 # Syntax for the ASN.1 supported: # file -> file module @@ -523,7 +519,8 @@ proc asnSequence {name tag implicit tagtype} { lappend l "\tif (!odr_sequence_begin (o, p, sizeof(**p), 0))" lappend l "\t\{" - lappend l "\t\t*p = 0;" + lappend l "\t\tif(o->direction == ODR_DECODE)" + lappend l "\t\t\t*p = 0;" lappend l "\t\treturn 0;" lappend l "\t\}" } @@ -735,7 +732,8 @@ proc asnOf {name tag implicit tagtype isset} { } lappend j "\}" lappend l "\t\treturn 1;" - lappend l "\t*p = 0;" + lappend l "\tif(o->direction == ODR_DECODE)" + lappend l "\t\t*p = 0;" lappend l "\treturn odr_missing(o, opt, name);" return [list [join $l \n] [join $j \n]] } @@ -840,8 +838,6 @@ proc asnChoice {name tag implicit tagtype} { lappend l "\todr_implicit_settag(o, $tagtype, $tag);" lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))" } else { - lappend l "\tif (!*p && o->direction != ODR_DECODE)" - lappend l "\t\treturn opt;" lappend l "\tif (!odr_constructed_begin(o, p, $tagtype, $tag, 0))" lappend l "\t\treturn odr_missing(o, opt, name);" lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))" @@ -850,7 +846,10 @@ proc asnChoice {name tag implicit tagtype} { lappend l "\t\todr_constructed_end(o))" } lappend l "\t\treturn 1;" - lappend l "\t*p = 0;" + + lappend l "\tif(o->direction == ODR_DECODE)" + lappend l "\t\t*p = 0;" + lappend l "\treturn odr_missing(o, opt, name);" return [list [join $l \n] [join $j \n]] } @@ -1086,20 +1085,29 @@ proc asnModules {} { set file(outp) [open $inf(h-path)/$inf(h-dir)$inf(p-file) w] } - set greeting {Generated automatically by the YAZ ASN.1 Compiler} + set greeting {Generated automatically by YAZ ASN.1 Compiler} - puts $file(outc) "/* ${greeting} ${yc_version} */" - puts $file(outc) "/* Module-C: $inf(module) */" + puts $file(outc) "/** \\file $inf(c-file)" + puts $file(outc) " \\brief ASN.1 Module $inf(module)" + puts $file(outc) "" + puts $file(outc) " ${greeting} ${yc_version}" + puts $file(outc) "*/" puts $file(outc) {} - puts $file(outh) "/* ${greeting} ${yc_version} */" - puts $file(outh) "/* Module-H $inf(module) */" + puts $file(outh) "/** \\file $inf(h-file)" + puts $file(outh) " \\brief ASN.1 Module $inf(module)" + puts $file(outh) "" + puts $file(outh) " ${greeting} ${yc_version}" + puts $file(outh) "*/" puts $file(outh) {} if {[info exists file(outp)]} { - puts $file(outp) "/* ${greeting} ${yc_version} */" - puts $file(outp) "/* Module-P: $inf(module) */" - puts $file(outp) {} + puts $file(outp) "/** \\file $inf(p-file)" + puts $file(outp) " \\brief ASN.1 Module $inf(module)" + puts $file(outp) "" + puts $file(outp) " ${greeting} ${yc_version}" + puts $file(outp) "*/" + puts $file(outp) {} } if {[info exists inf(p-file)]} { @@ -1387,8 +1395,8 @@ if {![info exists inf(iname)]} { puts "YAZ ASN.1 Compiler ${yc_version}" puts "Usage:" puts -nonewline ${argv0} - puts { [-v] [-c cfile] [-h hfile] [-p hfile] [-d dfile] [-I iout] [-i idir]} - puts { [-m module] file} + puts { [-v] [-c cfile] [-h hfile] [-p hfile] [-d dfile] [-I iout]} + puts { [-i idir] [-m module] file} exit 1 }