File: ldaperr.tcl

package info (click to toggle)
openldap2 2.0.23-6.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,816 kB
  • ctags: 6,366
  • sloc: ansic: 86,391; sh: 9,816; makefile: 1,270; cpp: 1,107; sql: 838; php: 700; perl: 134; tcl: 40
file content (49 lines) | stat: -rw-r--r-- 1,359 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#
# 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} {
	#puts stderr $line
	if {[clength $line] == 0 || [ctype space $line]} continue
	if {![string match #define* $line]} break
	if {![string match "#define LDAP_*" $line]} continue
	if {[string match "*LDAP_RANGE*" $line]} continue
	lassign $line define macro value
	set ldap_errcode($macro) $value
    }
    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]
}