diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 01:23:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 01:23:53 +0000 |
commit | c000cad09d0b54c455c99271bfb996c2dfe13073 (patch) | |
tree | e47ca809ed512d7fb43ec3d555753b1b658e9819 /contrib/ldaptcl/ldaperr.tcl | |
parent | Initial commit. (diff) | |
download | openldap-c000cad09d0b54c455c99271bfb996c2dfe13073.tar.xz openldap-c000cad09d0b54c455c99271bfb996c2dfe13073.zip |
Adding upstream version 2.4.47+dfsg.upstream/2.4.47+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | contrib/ldaptcl/ldaperr.tcl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/contrib/ldaptcl/ldaperr.tcl b/contrib/ldaptcl/ldaperr.tcl new file mode 100644 index 0000000..e9f8568 --- /dev/null +++ b/contrib/ldaptcl/ldaperr.tcl @@ -0,0 +1,54 @@ +# +# ldaperr.tcl: scan ldap.h for error return codes for initializing +# errorCode table. +# + +proc genstrings {path} { + set fp [open $path] + while {[gets $fp line] != -1 && + ![string match "#define LDAP_SUCCESS*" $line]} { } + puts "/* This file automatically generated, hand edit at your own risk! */" + puts -nonewline "char *ldaptclerrorcode\[\] = { + NULL" + while {[gets $fp line] != -1} { + if {[clength $line] == 0 || [ctype space $line]} continue + if {[string match *typedef* $line]} break + if {![string match #define* $line]} continue + if {![string match "#define LDAP_*" $line]} continue + if {[string match "*LDAP_RANGE*" $line]} continue + if {[string match "*LDAP_API_RESULT*" $line]} continue + if {[string match {*\\} $line]} { + append line [gets $fp] + } + lassign $line define macro value + set ldap_errcode($macro) $value + } + #parray ldap_errcode + foreach i [array names ldap_errcode] { + set value $ldap_errcode($i) + #puts stderr "checking $value" + if [regexp {^[A-Z_]} $value] { + if [info exists ldap_errcode($value)] { + set value $ldap_errcode($value) + set ldap_errcode($i) $value + } + } + set ldap_errname($value) $i + } + set lasterr 0 + foreach value [lsort -integer [array names ldap_errname]] { + incr lasterr + while {$lasterr < $value} { + puts -nonewline ",\n\tNULL" + incr lasterr + } + puts -nonewline ",\n\t\"$ldap_errname($value)\"" + } + puts "\n};" + puts "#define LDAPTCL_MAXERR\t$value" +} + +#cmdtrace on +if !$tcl_interactive { + genstrings [lindex $argv 0] +} |