annotate buddytrans2 @ 1451:f6cc5cb7faf6

[gaim-migrate @ 1461] patch from customdesigned to hopefully fix proxying once and for all. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 31 Jan 2001 08:07:59 +0000
parents 9ec08f6bb944
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
524
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 #!/usr/bin/perl -w
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 # gaim
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 # Copyright (C) 1998 - 2000, Mark Spencer <markster@marko.net>
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 # This program is free software; you can redistribute it and/or modify
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 # it under the terms of the GNU General Public License as published by
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 # the Free Software Foundation; either version 2 of the License, or
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 # (at your option) any later version.
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 # GNU General Public License for more details.
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 # You should have received a copy of the GNU General Public License
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 # along with this program; if not, write to the Free Software
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 # ---
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 # Buddy List Conversion Script Written By: John Assalone <assalonej@kpe.com>
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 # Modifications by: Rob Flynn <IM: Rob Flynn> <rflynn@blueridge.net>
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 # Obfuscated by: Schuyler Erle <IM: sderle> <schuyler@tridity.org>
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 # Use this script to convert the new WinAIM buddy list format to gaim's format.
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 # Syntax: ./buddytrans buddy.list gaimlist
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 use strict;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 use 5.003;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 sub translate_lst
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 {
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 my $src = shift;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 my ($line, $field, $name, $out);
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 $out = "m 1\n";
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 for $line (grep(/\w/o, split(/[\r\n]+/o, $src))) {
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 ($field, $name) = ($line =~ /^\s*(\w)\w*\s+(.+)$/go);
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 $name =~ y/"//d;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 $out .= "$field $name\n" if $field and $name;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 $out
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 sub translate_blt
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 {
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 my $src = shift;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 my $out = "m 1\n";
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 my $grp;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 $src =~ s/^.*?Buddy\s+{.*?list\s+{//gos;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 while ( $src =~ / } |
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 (?: "([^"]+)" | (\S+) ) \s*
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 (?: {(.+?)} | ([^\n]+) ) \s*/gosx ) {
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 last unless defined( $grp = $1 || $2 );
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 $out .= join( "\n", "g $grp",
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 map { "b $_" }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 grep { defined($_) and /\S/o }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 split ( /"([^"]+)"|\s+/, ($3 || $4) ) )
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 . "\n"
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 $out;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 sub buddy_trans
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 {
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 my ($src_file, $dest_file) = @_;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 die "Syntax: $0 buddy.lst gaimlist\n"
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 unless ($src_file and $dest_file);
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 open SOURCE, "<$src_file" or die "$!: $src_file\n";
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 my $src = do { local $/ = undef; <SOURCE> };
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 close SOURCE;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 if (-e $dest_file) {
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 print STDERR "$dest_file already exists! Continue? ";
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 unless (-t and <STDIN> =~ /^y/io) {
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 print STDERR "Aborted.\n";
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 exit -1
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 open DEST, ">$dest_file" or die "$!: $dest_file\n";
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 print DEST ($src =~ /{/os) ? translate_blt($src) : translate_lst($src);
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 close DEST;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 0;
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 }
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101
9ec08f6bb944 [gaim-migrate @ 534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 buddy_trans( @ARGV );