~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to contrib/ldaptcl/ldaperr.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2008-07-10 14:45:49 UTC
  • Revision ID: james.westby@ubuntu.com-20080710144549-wck73med0e72gfyo
Tags: upstream-2.4.10
ImportĀ upstreamĀ versionĀ 2.4.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# ldaperr.tcl: scan ldap.h for error return codes for initializing
 
3
# errorCode table.
 
4
#
 
5
 
 
6
proc genstrings {path} {
 
7
    set fp [open $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\[\] = {
 
12
        NULL"
 
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]
 
22
        }
 
23
        lassign $line define macro value
 
24
        set ldap_errcode($macro) $value
 
25
    }
 
26
    #parray ldap_errcode
 
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
 
34
            }
 
35
        }
 
36
        set ldap_errname($value) $i
 
37
    }
 
38
    set lasterr 0
 
39
    foreach value [lsort -integer [array names ldap_errname]] {
 
40
        incr lasterr
 
41
        while {$lasterr < $value} {
 
42
            puts -nonewline ",\n\tNULL"
 
43
            incr lasterr
 
44
        }
 
45
        puts -nonewline ",\n\t\"$ldap_errname($value)\""
 
46
    }
 
47
    puts "\n};"
 
48
    puts "#define LDAPTCL_MAXERR\t$value"
 
49
}
 
50
 
 
51
#cmdtrace on
 
52
if !$tcl_interactive {
 
53
    genstrings [lindex $argv 0]
 
54
}