Question on TCL Procs

Hi Folks,

I’d like to know if someone already had figured out a stable solution to enumerate procedures and then access the body of a given procedure?

The commands [info procs proc_*] and [info body proc_name] doesn’t seem to work for iRule based procedures.

Cheers, Kai

Hi folks,

in the meantime I’ve found a “good enough” workaround to locate the procedures and fetch their bodys. Its a kinda arkward and intrusive TCL hack, but its able to support my current requirements.

Below is a stripped down version of the workaround:

Script: IRULE_1

when RULE_INIT priority 500 {
    set static::local_procs(IRULE_1::PROC_NAME_A) ""
}
proc PROC_NAME_A {} { 
    uplevel {
         iControl will verify this TCL code
    }
}

Script: IRULE_2

when RULE_INIT priority 500 {
    set static::local_procs(IRULE_2::PROC_NAME_B) ""
}
proc PROC_NAME_B {} { 
    uplevel {
         iControl will verify this TCL code
    }
}

Script: IRULE_3

when RULE_INIT priority 999 {
    if { not ( [info commands uplevel_ren] ) } then {
        set static::cmd(rename_uplevel) {
            rename uplevel uplevel_ren
            interp alias {} uplevel {} return
        }
        eval $static::cmd(rename_uplevel)
    }
    foreach local_proc [array names static::local_procs] {
        eval "set static::local_procedures_body($local_proc) \[call $local_proc\]"
    }
    if { [info commands uplevel_ren] } then {
        set static::cmd(restore_uplevel) {
            interp alias {} uplevel {} 
            rename uplevel_ren uplevel
        }
        eval $static::cmd(restore_uplevel)
    }
}

If someone figures out a less intrusive method to access the body of a given procedure, then please let me know. Thanks in advance! :wink:

Cheers, Kai