Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc progfile {file action arg} {
- set arg [gbfilter $arg]
- set return 0
- set dbr [open database/$file.db r+]
- set dbw [open tmp.tmp w+]
- while {![eof $dbr]} {
- set r [gets $dbr]
- if {$r!=""} {puts $dbw $r}
- }
- close $dbr
- close $dbw
- set dbr [open tmp.tmp r+]
- set dbw [open database/$file.db w+]
- while {![eof $dbr]} {
- set r [gets $dbr]
- if {$action=="add"} {
- if {$r!=""} {
- puts $dbw $r
- } else {
- puts $dbw $arg
- }
- set return 1
- }
- if {$action=="del"} {
- if {$r!=""} {
- if {![string match -nocase $arg [lindex $r 0]] && ![string match -nocase $arg [lindex $r 1]]} {
- puts $dbw $r
- } else {
- set return 1
- }
- }
- }
- if {$action=="chk"} {
- if {$r!=""} {
- puts $dbw $r
- if [string match -nocase [lindex $arg 0] [lindex $r 1]] {
- set return [lindex $r 0]
- if ![string match -nocase [lindex $arg 1] [lindex $r 2]] {set return 2}
- if ![string match [lindex $arg 2] [lindex $r 3]] {set return 3}
- }
- }
- }
- if {$action=="icr"} {
- if {$r!=""} {
- puts $dbw $r
- if [string match -nocase $arg [lindex $r 0]] {
- set return 1
- }
- }
- }
- if {$action=="cf"} {
- if {$r!=""} {
- puts $dbw $r
- if [string match -nocase [lindex $r 0] $arg] {
- set return 1
- }
- }
- }
- if {$action=="ibr"} {
- if {$r!=""} {
- puts $dbw $r
- if [string match -nocase $arg [lindex $r 1]] {
- set return 1
- }
- }
- }
- }
- close $dbr
- close $dbw
- return $return
- }
Add Comment
Please, Sign In to add comment