X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Foidtoc.tcl;h=87443e16253a69c01136072553f66627e99aaa75;hb=2581c46b3b3f9f26fb74621beb5ede69f8816382;hp=265132887a7afc08d598a17649ea381eeee34d62;hpb=fe507b6b15788a3a8e58063d9dae52532a5229a5;p=yaz-moved-to-github.git
diff --git a/src/oidtoc.tcl b/src/oidtoc.tcl
index 2651328..87443e1 100644
--- a/src/oidtoc.tcl
+++ b/src/oidtoc.tcl
@@ -2,7 +2,7 @@
# Copyright (c) Index Data 2006-2007
# See the file LICENSE for details.
#
-# $Id: oidtoc.tcl,v 1.4 2007-05-06 20:12:20 adam Exp $
+# $Id: oidtoc.tcl,v 1.8 2007-05-31 12:14:02 adam Exp $
#
# Converts a CSV file with Object identifiers to C
@@ -34,8 +34,70 @@ proc readoids {input} {
return $oids
}
+proc constant_var {oid} {
+ set lname [string tolower [lindex $oid 2]]
+ set lname [string map {- _ . _ { } _ ( {} ) {}} $lname]
+ set prefix [string tolower [lindex $oid 0]]
+
+ return yaz_oid_${prefix}_${lname}
+}
+
+proc oid_to_xml {srcdir input xname} {
+ set oids [readoids "${input}"]
+ set xfile [open "${xname}" w]
+
+ puts $xfile ""
+ puts $xfile {}
+ puts $xfile {}
+ puts $xfile {}
+ puts $xfile {}
+ puts $xfile {}
+ puts $xfile {}
+ puts $xfile {}
+ puts $xfile {Name}
+ puts $xfile {Class}
+ puts $xfile {Constant / OID}
+ puts $xfile {
}
+ puts $xfile {}
+ puts $xfile {}
+
+ foreach oid $oids {
+ puts $xfile {}
+
+ puts $xfile {}
+ puts $xfile [lindex $oid 2]
+ puts $xfile {}
+
+
+ puts $xfile {}
+ puts $xfile [lindex $oid 0]
+ puts $xfile {}
+
+ puts $xfile {}
+ set v [constant_var $oid]
+ puts $xfile $v
+ puts $xfile {}
+
+
+ puts $xfile {
}
+ puts $xfile {}
+
+ puts $xfile {}
+ puts $xfile [lindex $oid 1]
+ puts $xfile {}
+
+ puts $xfile {
}
+ }
+
+ puts $xfile {}
+ puts $xfile {}
+
+ puts $xfile {}
+ close $xfile
+}
+
proc oid_to_c {srcdir input cname hname} {
- set oids [readoids "${srcdir}/${input}"]
+ set oids [readoids "${input}"]
set cfile [open "${srcdir}/${cname}" w]
set hfile [open "${srcdir}/../include/yaz/${hname}" w]
@@ -48,8 +110,6 @@ proc oid_to_c {srcdir input cname hname} {
puts $hfile "\#ifndef OID_STD_H"
puts $hfile "\#define OID_STD_H"
- # Define this. So that we don't get duplicate declartions with MSVC
- puts $cfile "\#define OID_STD_H"
puts $cfile "\#include "
puts $cfile ""
# To avoid LNK4049
@@ -61,26 +121,23 @@ proc oid_to_c {srcdir input cname hname} {
puts $hfile "YAZ_BEGIN_CDECL"
foreach oid $oids {
- set lname [string tolower [lindex $oid 2]]
- set lname [string map {- _ . _ { } _ ( {} ) {}} $lname]
- set prefix [string tolower [lindex $oid 0]]
+
+ set v [constant_var $oid]
- puts -nonewline $cfile "YAZ_EXPORT extern const int yaz_oid_${prefix}_${lname}\[\] = \{"
+ puts -nonewline $cfile "YAZ_EXPORT const Odr_oid $v\[\] = \{"
puts -nonewline $cfile [string map {. ,} [lindex $oid 1]]
puts $cfile ",-1\};"
- puts $hfile "OID_EXPORT extern const int yaz_oid_${prefix}_${lname}\[\];"
+ puts $hfile "OID_EXPORT extern const Odr_oid $v\[\];"
}
puts $cfile "YAZ_EXPORT struct yaz_oid_entry yaz_oid_standard_entries\[\] ="
puts $cfile "\{"
foreach oid $oids {
- set lname [string tolower [lindex $oid 2]]
- set lname [string map {- _ . _ { } _ ( {} ) {}} $lname]
- set prefix [string tolower [lindex $oid 0]]
+ set v [constant_var $oid]
puts -nonewline $cfile "\t\{CLASS_[lindex $oid 0], "
- puts -nonewline $cfile "yaz_oid_${prefix}_${lname}, "
+ puts -nonewline $cfile "$v, "
puts -nonewline $cfile \"[lindex $oid 2]\"
puts $cfile "\},"
}
@@ -95,8 +152,11 @@ proc oid_to_c {srcdir input cname hname} {
close $hfile
}
-if {[llength $argv] != 4} {
+if {[llength $argv] == 4} {
+ oid_to_c [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3]
+} elseif {[llength $argv] == 3} {
+ oid_to_xml [lindex $argv 0] [lindex $argv 1] [lindex $argv 2]
+} else {
puts "oidtoc.tcl srcdir csv cfile hfile"
exit 1
}
-oid_to_c [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3]