File: tm_misc.pl

package info (click to toggle)
tct 1.07-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,828 kB
  • ctags: 1,128
  • sloc: perl: 9,604; ansic: 4,861; makefile: 516; sh: 77
file content (43 lines) | stat: -rw-r--r-- 765 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
#
# tm_misc.pl - misc routines to slice and dice time machine records
#

#
# Split a time machine record.
#
sub tm_split {
        local($line) = @_;
        local(@fields);

        for (@fields = split(/\|/, $line)) {
                s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/egis;
        }
        return @fields;
}

#
# tm_string - convert list to time machine record format.
#
sub tm_string {
    local(@out) = @_;

    for (@out) {
	s/([^-_`~!@#$^&*()+={}[\]:;"'<>,.?\/a-z0-9 ])/sprintf("%%%02X",unpack("C", $1))/egis;
    }
    return join('|', @out);
}

#
# tm_print 
#
sub tm_print {
    local(@out) = @_;

    for (@out) {
	s/([^-_`~!@#$^&*()+={}[\]:;"'<>,.?\/a-z0-9 ])/sprintf("%%%02X",unpack("C", $1))/egis;
    }
    print join('|', @out),"\n";
}

1;