X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fyaz-comp;h=247b607f23f43d842b1df7dbd4b4c5f6804bc472;hb=c39a893dfdae5f792139177132e7e7a70e010aa7;hp=5e1199f908b0a61ba5ad23b5e8173e0a8a3f6d69;hpb=d90d31f39aba4c7256d5b83eaf4192630b18ae02;p=yaz-moved-to-github.git diff --git a/util/yaz-comp b/util/yaz-comp index 5e1199f..247b607 100755 --- a/util/yaz-comp +++ b/util/yaz-comp @@ -3,56 +3,10 @@ exec tclsh "$0" "$@" # # yaz-comp: ASN.1 Compiler for YAZ -# (c) Index Data 1996-2000 +# (c) Index Data 1996-2003 # See the file LICENSE for details. # -# $Log: yaz-comp,v $ -# Revision 1.1 2000-03-02 08:48:20 adam -# Renamed ASN.1 compiler to yaz-comp (used to be yc.tcl). -# -# Revision 1.6 2000/02/10 13:44:02 adam -# Tcl command clock not used if unavailable (Tcl7.4 and earlier). -# -# Revision 1.5 2000/01/15 09:18:42 adam -# Bug fix: some elements where treated as OPTIONAL when they shouldn't. -# -# Revision 1.4 1999/12/16 23:36:19 adam -# Implemented ILL protocol. Minor updates ASN.1 compiler. -# -# Revision 1.3 1999/11/30 13:47:12 adam -# Improved installation. Moved header files to include/yaz. -# -# Revision 1.2 1999/06/09 09:43:11 adam -# Added option -I and variable h-path to specify path for header files. -# -# Revision 1.1 1999/06/08 10:10:16 adam -# New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree. -# -# Revision 1.8 1999/04/20 10:37:04 adam -# Updated for ODR - added name parameter. -# -# Revision 1.7 1998/04/03 14:44:20 adam -# Small fix. -# -# Revision 1.6 1998/04/03 13:21:17 adam -# Yet another fix. -# -# Revision 1.5 1998/04/03 12:48:17 adam -# Fixed bug: missed handling of constructed tags for CHOICE. -# -# Revision 1.4 1998/03/31 15:47:45 adam -# First compiled ASN.1 code for YAZ. -# -# Revision 1.3 1998/03/23 17:13:20 adam -# Implemented SET OF and ENUM. The Compiler now eats ILL (ISO10161) and -# LDAP (RFC1777). -# -# Revision 1.2 1997/10/07 10:31:01 adam -# Added facility to specify tag type (CONTEXT, APPLICATION, ...). -# -# Revision 1.1.1.1 1996/10/31 14:04:40 adam -# First version of the compiler for YAZ. -# +# $Id: yaz-comp,v 1.6 2003-05-20 19:55:30 adam Exp $ # set yc_version 0.3 @@ -256,7 +210,9 @@ proc asnName {name} { if {$inf(verbose)} { puts " mapping member $name,$val to $nval" } - lex + if {![string match {[A-Z]*} $val]} { + lex + } } else { set nval $val if {![string match {[A-Z]*} $val]} { @@ -554,16 +510,16 @@ proc asnSequence {name tag implicit tagtype} { set nchoice 0 if {![string length $tag]} { lappend l "\tif (!odr_sequence_begin (o, p, sizeof(**p), name))" - lappend l "\t\treturn opt && odr_ok (o);" + lappend l "\t\treturn odr_missing(o, opt, name) && odr_ok (o);" } elseif {$implicit} { lappend l "\tif (!odr_implicit_settag (o, $tagtype, $tag) ||" lappend l "\t\t!odr_sequence_begin (o, p, sizeof(**p), name))" - lappend l "\t\treturn opt && odr_ok(o);" + lappend l "\t\treturn odr_missing(o, opt, name);" } else { lappend l "\tif (!odr_constructed_begin (o, p, $tagtype, $tag, name))" - lappend l "\t\treturn opt && odr_ok(o);" + lappend l "\t\treturn odr_missing(o, opt, name);" lappend l "\tif (o->direction == ODR_DECODE)" - lappend l "\t\t*p = odr_malloc (o, sizeof(**p));" + lappend l "\t\t*p = ($inf(vprefix)$name *) odr_malloc (o, sizeof(**p));" lappend l "\tif (!odr_sequence_begin (o, p, sizeof(**p), 0))" lappend l "\t\{" @@ -753,7 +709,7 @@ proc asnOf {name tag implicit tagtype isset} { lappend j "\tint [lindex $numName 0];" lappend l "\tif (!odr_initmember (o, p, sizeof(**p)))" - lappend l "\t\treturn opt && odr_ok(o);" + lappend l "\t\treturn odr_missing(o, opt, name);" if {[string length $tag]} { if {$implicit} { lappend l "\todr_implicit_settag (o, $tagtype, $tag);" @@ -780,7 +736,7 @@ proc asnOf {name tag implicit tagtype isset} { lappend j "\}" lappend l "\t\treturn 1;" lappend l "\t*p = 0;" - lappend l "\treturn opt && odr_ok(o);" + lappend l "\treturn odr_missing(o, opt, name);" return [list [join $l \n] [join $j \n]] } @@ -876,26 +832,26 @@ proc asnChoice {name tag implicit tagtype} { lappend l "\t\};" if {![string length $tag]} { lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))" - lappend l "\t\treturn opt && odr_ok(o);" + lappend l "\t\treturn odr_missing(o, opt, name);" lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))" } elseif {$implicit} { lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))" - lappend l "\t\treturn opt && odr_ok(o);" + lappend l "\t\treturn odr_missing(o, opt, name);" 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 opt && odr_ok(o);" + lappend l "\t\treturn odr_missing(o, opt, name);" lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))" - lappend l "\t\treturn opt && odr_ok(o);" + lappend l "\t\treturn odr_missing(o, opt, name);" lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name) &&" lappend l "\t\todr_constructed_end(o))" } lappend l "\t\treturn 1;" lappend l "\t*p = 0;" - lappend l "\treturn opt && odr_ok(o);" + lappend l "\treturn odr_missing(o, opt, name);" return [list [join $l \n] [join $j \n]] } @@ -1154,7 +1110,7 @@ proc asnModules {} { puts $file(outh) "\#ifndef ${ppname}_H" puts $file(outh) "\#define ${ppname}_H" puts $file(outh) {} - puts $file(outh) "\#include <$inf(h-dir)odr.h>" + puts $file(outh) "\#include " if {[info exists file(outp)]} { puts $file(outp) "\#ifndef ${ppname}_P_H"