annotate buddytrans @ 1541:3d07b9f6fe44

[gaim-migrate @ 1551] lala la committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Wed, 07 Mar 2001 07:54:28 +0000
parents 494816c30ca7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 #!/usr/bin/perl -w
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 # gaim
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 # Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 # This program is free software; you can redistribute it and/or modify
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 # it under the terms of the GNU General Public License as published by
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 # the Free Software Foundation; either version 2 of the License, or
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 # (at your option) any later version.
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 # GNU General Public License for more details.
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 # You should have received a copy of the GNU General Public License
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 # along with this program; if not, write to the Free Software
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 # ---
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23 # Buddy List Conversion Script Written By: John Assalone <assalonej@kpe.com>
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 # Modifications by: Rob Flynn <IM: Rob Flynn> <rflynn@blueridge.net>
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 # Syntax: ./buddytrans buddy.list gaimlist
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 print "Gaim - Buddy List Translator\n";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 print "----------------------------\n";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 if ((!$ARGV[0]) || (!$ARGV[1]))
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 print "Syntax: ./buddytrans buddy.lst gaimlist\n";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 exit(0);
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38 $source = $ARGV[0];
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 $dest = $ARGV[1];
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 if (-e $source)
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 print("Source=$source, Dest=$dest\n");
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44 if (-e $dest)
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45 {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46 print ("$dest exists! Should I continue? ");
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 if (<STDIN> =~ /^y/i)
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48 {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 do_trans();
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51 else { exit(0); }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
52 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54 do_trans();
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
56 sub do_trans {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
57 open (SOURCE, $source);
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
58 open (DEST, ">$dest");
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59 print DEST "toc_set_config {m 1\n";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60 while ($line = <SOURCE>) {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61 chomp($line);
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
62 if ($line =~ /[a-zA-Z]+/) {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
63 if ($line =~ /^\s/) { $line =~ s/\s//; }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64 $line =~ s/\s/\*/;
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65 ($field, $name) = split(/\*/, $line);
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66 if ($field eq "group") {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67 $name =~ s/\"//g;
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68 print DEST "g $name\n";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69 next;
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71 if ($field eq "buddy") {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 $name =~ s/\"//g;
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 print DEST "b $name\n";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74 next;
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
75 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76 else { next; }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
78 else { next; }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80 print DEST "}";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 print "Conversion Complete.\n";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83 } else {
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84 print "Source file must exist!\n\nSyntax: ./buddytrans buddy.lst gaimlist\n";
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85 exit(0);
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 }
494816c30ca7 [gaim-migrate @ 14]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87