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