File: tm_misc.pl

package info (click to toggle)
tct 1.19-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,916 kB
  • ctags: 1,128
  • sloc: perl: 9,609; ansic: 5,347; makefile: 430; sh: 38
file content (43 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (4)
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;