2 # ldaperr.tcl: scan ldap.h for error return codes for initializing
6 proc genstrings {path} {
8 while {[gets $fp line] != -1 &&
9 ![string match "#define LDAP_SUCCESS*" $line]} { }
10 puts "/* This file automatically generated, hand edit at your own risk! */"
11 puts -nonewline "char *ldaptclerrorcode\[\] = {
13 while {[gets $fp line] != -1} {
14 if {[clength $line] == 0 || [ctype space $line]} continue
15 if {[string match *typedef* $line]} break
16 if {![string match #define* $line]} continue
17 if {![string match "#define LDAP_*" $line]} continue
18 if {[string match "*LDAP_RANGE*" $line]} continue
19 if {[string match "*LDAP_API_RESULT*" $line]} continue
20 if {[string match {*\\} $line]} {
21 append line [gets $fp]
23 lassign $line define macro value
24 set ldap_errcode($macro) $value
27 foreach i [array names ldap_errcode] {
28 set value $ldap_errcode($i)
29 #puts stderr "checking $value"
30 if [regexp {^[A-Z_]} $value] {
31 if [info exists ldap_errcode($value)] {
32 set value $ldap_errcode($value)
33 set ldap_errcode($i) $value
36 set ldap_errname($value) $i
39 foreach value [lsort -integer [array names ldap_errname]] {
41 while {$lasterr < $value} {
42 puts -nonewline ",\n\tNULL"
45 puts -nonewline ",\n\t\"$ldap_errname($value)\""
48 puts "#define LDAPTCL_MAXERR\t$value"
52 if !$tcl_interactive {
53 genstrings [lindex $argv 0]