X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fyc.tcl;h=49627ccae1406434c869f6a3d1523a48ca8ff3b9;hb=fc2093cfd23eda0ee8384b18dc7e7b8adffd073a;hp=76785d3fa90a36cb88cc66efc585984cf8c8dfa9;hpb=161ec45b40a3ab08e08946c9654ab6fea4604760;p=yaz-moved-to-github.git diff --git a/util/yc.tcl b/util/yc.tcl index 76785d3..49627cc 100755 --- a/util/yc.tcl +++ b/util/yc.tcl @@ -2,13 +2,22 @@ # the next line restarts using tclsh \ exec tclsh "$0" "$@" # -# YC: YAZ ODR Compiler -# (c) Index Data 1996-1998 +# YC: ASN.1 Compiler for YAZ +# (c) Index Data 1996-1999 # See the file LICENSE for details. # Sebastian Hammer, Adam Dickmeiss # # $Log: yc.tcl,v $ -# Revision 1.1 1999-06-08 10:10:16 adam +# 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 @@ -543,7 +552,7 @@ proc asnSequence {name tag implicit tagtype} { lappend l "\t\t!odr_sequence_begin (o, p, sizeof(**p), name))" lappend l "\t\treturn opt && odr_ok(o);" } else { - lappend l "\tif (!odr_constructed_begin (o, p, $tagtype, $tag, name)" + lappend l "\tif (!odr_constructed_begin (o, p, $tagtype, $tag, name))" lappend l "\t\treturn opt && odr_ok(o);" lappend l "\tif (o->direction == ODR_DECODE)" lappend l "\t\t*p = odr_malloc (o, sizeof(**p));" @@ -904,7 +913,7 @@ proc asnImports {} { } else { set fname $val } - puts $file(outh) "\#include \"${fname}.h\"" + puts $file(outh) "\#include <$inf(h-dir)${fname}.h>" if {[info exists inf(prefix,$val)]} { set prefix $inf(prefix,$val) @@ -912,9 +921,14 @@ proc asnImports {} { set prefix $inf(prefix) } foreach n $nam { - set m [join [split $n -] _] - set inf(imports,$n) [list [lindex $prefix 0]$m \ - [lindex $prefix 1]$m] + if {[info exists inf(map,$val,$n)]} { + set v $inf(map,$val,$n) + } else { + set v $n + } + set w [join [split $v -] _] + set inf(imports,$n) [list [lindex $prefix 0]$w \ + [lindex $prefix 1]$w] } unset nam lex @@ -1084,8 +1098,6 @@ proc asnModules {} { lex if {![string length $type]} return } - - if {[info exists inf(filename,$inf(module))]} { set fname $inf(filename,$inf(module)) } else { @@ -1101,12 +1113,14 @@ proc asnModules {} { if {![info exists inf(h-file)]} { set inf(h-file) ${fname}.h } - set file(outh) [open $inf(h-file) w] + set file(outh) [open $inf(h-path)/$inf(h-dir)$inf(h-file) w] - if {![info exists inf(p-file)]} { - set inf(p-file) ${fname}-p.h - } - set file(outp) [open $inf(p-file) w] + if {0} { + if {![info exists inf(p-file)]} { + set inf(p-file) ${fname}-p.h + } + set file(outp) [open $inf(h-path)/$inf(h-dir)$inf(p-file) w] + } set md [clock format [clock seconds]] @@ -1118,26 +1132,29 @@ proc asnModules {} { puts $file(outh) "/* Module-H $inf(module) */" puts $file(outh) {} - puts $file(outp) "/* YC ${yc_version}: $md */" - puts $file(outp) "/* Module-P: $inf(module) */" - puts $file(outp) {} - - puts $file(outc) "\#include \"$inf(p-file)\"" + if {[info exists file(outp)]} { + puts $file(outp) "/* YC ${yc_version}: $md */" + puts $file(outp) "/* Module-P: $inf(module) */" + puts $file(outp) {} + } + if {[info exists inf(p-file)]} { + puts $file(outc) "\#include <$inf(h-dir)$inf(p-file)>" + } else { + puts $file(outc) "\#include <$inf(h-dir)$inf(h-file)>" + } puts $file(outh) "\#ifndef ${ppname}_H" puts $file(outh) "\#define ${ppname}_H" puts $file(outh) {} - puts $file(outh) "\#include " - - puts $file(outp) "\#ifndef ${ppname}_P_H" - puts $file(outp) "\#define ${ppname}_P_H" - puts $file(outp) {} - puts $file(outp) "\#include \"$inf(h-file)\"" + puts $file(outh) "\#include <$inf(h-dir)odr.h>" + + if {[info exists file(outp)]} { + puts $file(outp) "\#ifndef ${ppname}_P_H" + puts $file(outp) "\#define ${ppname}_P_H" + puts $file(outp) {} + puts $file(outp) "\#include <$inf(h-dir)$inf(h-file)>" - - puts $file(outp) "\#ifdef __cplusplus" - puts $file(outp) "extern \"C\" \{" - puts $file(outp) "\#endif" + } asnTagDefault if {[string compare $type :]} { @@ -1155,6 +1172,9 @@ proc asnModules {} { } else { set f $file(outh) } + puts $f "\#ifdef __cplusplus" + puts $f "extern \"C\" \{" + puts $f "\#endif" for {set i 1} {$i < $inf(nodef)} {incr i} { puts $f $inf(var,$i) if {[info exists inf(asn,$i)]} { @@ -1170,9 +1190,9 @@ proc asnModules {} { unset inf(var,$i) puts $f {} } - puts $file(outp) "\#ifdef __cplusplus" - puts $file(outp) "\}" - puts $file(outp) "\#endif" + puts $f "\#ifdef __cplusplus" + puts $f "\}" + puts $f "\#endif" if {[info exists inf(body,$inf(module),h)]} { puts $file(outh) $inf(body,$inf(module),h) @@ -1181,16 +1201,20 @@ proc asnModules {} { puts $file(outc) $inf(body,$inf(module),c) } if {[info exists inf(body,$inf(module),p)]} { - puts $file(outp) $inf(body,$inf(module),p) + if {[info exists file(outp)]} { + puts $file(outp) $inf(body,$inf(module),p) + } } puts $file(outh) "\#endif" - puts $file(outp) "\#endif" + if {[info exists file(outp)]} { + puts $file(outp) "\#endif" + } foreach f [array names file] { close $file($f) } unset inf(c-file) unset inf(h-file) - unset inf(p-file) + catch {unset inf(p-file)} } } } @@ -1254,6 +1278,18 @@ proc asnBasicOBJECT {} { return {odr_oid {Odr_oid}} } +proc asnBasicGeneralString {} { + return {odr_generalstring char} +} + +proc asnBasicVisibleString {} { + return {odr_visiblestring char} +} + +proc asnBasicGeneralizedTime {} { + return {odr_generalizedtime char} +} + proc asnBasicANY {} { upvar name name global inf @@ -1272,6 +1308,9 @@ proc userDef {name} { if {[info exists default-prefix]} { set inf(prefix) ${default-prefix} } + if {[info exists h-path]} { + set inf(h-path) ${h-path} + } foreach m [array names prefix] { set inf(prefix,$m) $prefix($m) } @@ -1297,6 +1336,8 @@ proc userDef {name} { set inf(verbose) 0 set inf(prefix) {yc_ Yc_ YC_} +set inf(h-path) . +set inf(h-dir) "" # Parse command line set l [llength $argv] @@ -1314,6 +1355,20 @@ while {$i < $l} { } set inf(c-file) $p } + -I* { + set p [string range $arg 2 end] + if {![string length $p]} { + set p [lindex $argv [incr i]] + } + set inf(h-path) $p + } + -i* { + set p [string range $arg 2 end] + if {![string length $p]} { + set p [lindex $argv [incr i]] + } + set inf(h-dir) [string trim $p \\/]/ + } -h* { set p [string range $arg 2 end] if {![string length $p]} { @@ -1365,9 +1420,9 @@ while {$i < $l} { } if {![info exists inf(iname)]} { - puts "YAZ ODR Compiler ${yc_version}" + puts "YAZ ASN.1 Compiler ${yc_version}" puts -nonewline "Usage: ${argv0}" - puts { [-v] [-c cfile] [-h hfile] [-p hfile] [-d dfile] } + puts { [-v] [-c cfile] [-h hfile] [-p hfile] [-d dfile] [-I path]} puts { [-x prefix] [-m module] file} exit 1 }