XML file

The file problem_type.xml contains information related to the configuration of the problem type, such as file browser, icon, password validation or message catalog location. Besides this, the file can be used to store assorted structured infomation such as version number, news added from the last version, and whatever the developer decides to include. This file can be read using the Tcl extension tcom which is provided with GiD .

The data included inside the xml file should observe the following structure:

<Infoproblemtype version="1.0">

<Program>

</Program>

</Infoproblemtype>

We suggest that the following nodes are included (the values of these nodes are just examples):

ValidatePassword node

The default action taken by GiD when validating a problem type password is verifying that it is not empty. When a password is considered as valid, this information is written in the file 'password.txt' which is located in the problem type directory. In order to override this behaviour, two nodes are provided in the .xml file

Example:

<PasswordPath>..</PasswordPath>

key with the contents of the password typed,

dir with the path of the problem type, and

computer_name with the name of host machine.

Note: It's like this Tcl procedure prototype: proc PasswordPath { key dir computer_name } { ... body... }

The script should return one of three possible codes:

0 in case of failure.

1 in case of success.

2 in case of success; the difference here is that the problem type has just saved the password information so GiD should not do it.

Furthermore, we can provide a description of the status returned for GiD to show to the user. If another status is returned, it is assumed to be 1 by default.

Below is an example of a <ValidatePassword> node.

<ValidatePassword>

#validation.exe simulates an external program to validade the key for this computername

#instead an external program can be used a tcl procedure

if { [catch {set res [exec [file join $dir validation.exe] $key $computername]} msgerr] } {

return [list 0 "Error $msgerr"]

}

switch -regexp -- $res {

failRB {

return [list 0 "you ask me to fail!"]

}

okandsaveRB {

proc save_pass {dir id pass} {

set date [clock format [clock second] -format "%Y %m %d"]

set fd [open [file join $dir .. "password.txt"] "a"]

puts $fd "$id $pass # $date Password for Problem type '$dir'"

close $fd

}

save_pass $dir $computername $key

rename save_pass ""

return [list 2 "password $key saved by me"]

}

okRB {

return [list 1 "password $key will be saved by gid"]

}

default {

return [list 0 "Error: unexpected return value $res"]

}

}

</ValidatePassword>