This file is indexed.

/usr/bin/cimconv is in centerim-common 4.22.10-2ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#!/usr/bin/env perl

#
# Contact list, history and other stuff conversion script from
# various flavours of icq client software to centerim format.
#
# by Konstantin Klyagin <k@thekonst.net>
# trillian support by Vassilios Karakoidas <bkarak@aueb.gr>
#
# $Id: cimconv,v 1.9 2003/09/26 07:13:21 konst Exp $
#

use Time::Local;

my $ourUIN = 0;

#
# cicq_adduser
#
# Adds a user to contact list.
# One arguments: user's UIN.
#

sub cicq_adduser {
    local ($uin) = @_;
    system("mkdir -p $ENV{HOME}/.centerim/$uin");
}

#
# cicq_addhistoryitem
#
# Adds a message to a user's events history.
# Requires the following parameters to be passed:
#
# to_UIN
#	Uin of the receiver.
# from_UIN
#	Sender's uin.
# timestamp
#	UNIX timestamp (seconds since 1980).
# text
#	Message text.
#

sub cicq_addhistoryitem {
    local ($touin, $fromuin, $timestamp, $text) = @_;

    if($ourUIN) {
	$histuin = ($touin == $ourUIN) ? $fromuin : $touin;

	if(open(UF, ">>$ENV{HOME}/.centerim/$histuin/history")) {
	    print UF "\f\n";
	    print UF ($touin == $ourUIN) ? "IN" : "OUT", "\nMSG\n";
	    print UF "$timestamp\n$timestamp\n";
	    print UF "$text\n\n";
	    close UF;
	}

	if(open(UF, ">$ENV{HOME}/.centerim/$histuin/lastread")) {
	    print UF "$timestamp\n";
	    close UF;
	}
    }
}

#
# LICQ specific functions
#

sub licq_conv_history {
    local ($uin) = @_;

    local $uto = 0;
    local $ufrom = 0;
    local $utimestamp = 0;
    local $text = "";

    if(open(HF, "<$ENV{HOME}/.licq/history/$uin.history")) {
	while(<HF>) {
	    chomp;
	    $buf = $_;

	    if($buf =~ m/\[ (.?) .+ ([0-9]+) \]$/) {
		if($text ne "") {
		    cicq_addhistoryitem($uto, $ufrom, $timestamp, $text);
		    $text = "";
		}

		$timestamp = $2;

		if($1 eq "R") {
		    $ufrom = $uin;
		    $uto = $ourUIN;
		} elsif($1 eq "S") {
		    $ufrom = $ourUIN;
		    $uto = $uin;
		}
	    } else {
		$buf = substr($buf, 1) if substr($buf, 0, 1) eq ":";
		$text .= $buf;
	    }
	}

	cicq_addhistoryitem($uto, $ufrom, $timestamp, $text)
	    if $text ne "";

	close HF;
    }
}

sub licq {
    if(open(F, "<$ENV{HOME}/.licq/owner.uin")) {
	while(<F>) {
	    chomp; $buf = $_;

	    if($buf =~ m/^Uin = ([0-9]+)$/) {
		$ourUIN = $1;
		last;
	    }
	}

	close F;
    }

    open(F, "<$ENV{HOME}/.licq/users.conf")
	or die "cannot find licq users file $ENV{HOME}/.licq/users.conf";

    while(<F>) {
	chomp; $buf = $_;

	if($buf =~ m/^User[0-9]+ = ([0-9]+)$/) {
	    cicq_adduser($1);
	    licq_conv_history($1);
	}
    }

    close F;
}

#
# micq specific functions
#

sub micq {
    $contsection = 0;
    $fname = "$ENV{HOME}/.micq/micqrc";
    
    open(F, "<$fname")
	or die "cannot find micq config file $fname";

    while(<F>) {
	chomp;
	s/#.*//;
	s/^\s+//;
	next unless length;
	$buf = $_;
	if($contsection) {
	    if($buf =~ m/^([0-9]+)\s.+$/) {
		cicq_adduser($1);
	    }
	} else {
	    $contsection = $buf =~ m/^\[Contacts\]$/;
	}
    }
    
    close F;
}

#
# GnomeICU specific functions
#

sub gnomeicu {
    $contsection = 0;
    $fname = "$ENV{HOME}/.gnome/GnomeICU";

    open(F, "<$fname")
	or die "cannot find GnomeICU config file $fname";

    while(<F>) {
	chomp;
	$buf = $_;

	if($contsection) {
	    if($buf =~ m/^([0-9]+)=.+$/) {
		cicq_adduser($1);
	    }
	} else {
	    $contsection = $buf =~ m/^\[NewContacts\]$/;
	}
    }

    close F;
}

#
# KXicq2 specific functions
#

sub kxicq2 {
    if(open(F, "<$ENV{HOME}/.kde/share/config/kxicq2rc")) {
	while(<F>) {
	    chomp; $buf = $_;
	    if($buf =~ m/^UIN=([0-9]+)$/) {
		$ourUIN = $1;
		last;
	    }
	}

	close F;
    }

    $fname = "$ENV{HOME}/.kde/share/apps/kxicq2/contacts.kxicq";

    open(F, "<$fname")
	or die "cannot find kxicq2 contacts file $fname";

    while(<F>) {
	chomp; $buf = $_;

	if($buf =~ m/^UIN=([0-9]+)$/) {
	    cicq_adduser($1);
	}
    }

    close F;

    #
    # Now convert messages history
    #

    $fname = "$ENV{HOME}/.kde/share/apps/kxicq2/messages.kxicq2";

    local $uto = 0;
    local $ufrom = 0;
    local $utimestamp = 0;
    local $text = "";
    local $msgmode = "R";

    if(open(F, "<$fname")) {
	while(<F>) {
	    chomp; $buf = $_;

	    if($buf =~ m/^\[Message [0-9]+\]$/) {
		cicq_addhistoryitem($uto, $ufrom, $timestamp, $text)
		    if $text ne "";
		$text = "";
	    } elsif($buf =~ m/Options=[0-9]+ [0-9]+ ([0-9]+) [0-9]+$/) {
		$msgmode = $1 ? "S" : "R";
	    } elsif($buf =~ m/Uin=([0-9]+)$/) {
		if($msgmode eq "R") {
		    $ufrom = $1;
		    $uto = $ourUIN;
		} else {
		    $ufrom = $ourUIN;
		    $uto = $1;
		}
	    } elsif($buf =~ m/DateTime=([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+)$/) {
		$timestamp = timelocal(0, $5, $4, $1, $2, $3);
	    } elsif($buf =~ m/Message=(.+)$/) {
		$text = $1;
		$text =~ s/\\r//g;
		$text =~ s/\\n/\n/g;
	    }
	}

	cicq_addhistoryitem($uto, $ufrom, $timestamp, $text)
	    if $text ne "";

	close F;
    }
}

# Trillian specific functions

sub create_account_irc {
    local $OUTPUT_DIR = "$ENV{HOME}/.centerim/";
    local $buddy_dir = $OUTPUT_DIR."i".$_[0];
    
    mkdir($buddy_dir);
}

sub create_account_msn {
    local $OUTPUT_DIR = "$ENV{HOME}/.centerim/";
    local @buddy_mail = split("@",$_[0]);
    local $buddy_dir = $OUTPUT_DIR."m".$buddy_mail[0];
    
    mkdir($buddy_dir);	    
    open(INFO_FP,">".$buddy_dir."/info");
    print INFO_FP $buddy_mail[0]."\n\n\n".$_[0]."\n";
    close(INFO_FP);
}

sub trillian {
    open(TRILLIAN_XML,"Buddies.xml") or
	die "Can not open Buddies.xml";
    @lines = <TRILLIAN_XML>;
    close(TRILLIAN_XML);

    foreach(@lines){
	if($_ =~ /\<buddy uri=\"ICQ:1%3A(.*)\"\>(.*)\<\/buddy\>/) {
	    @buddy_icq_array = split("%3A",$1);
	    cicq_adduser($buddy_icq_array[0]);
	} elsif($_ =~ /\<buddy uri=\"MSN:1%3A(.*)\"\>(.*)\<\/buddy\>/) {
	    @buddy_msn_array = split("%3A",$1);
	    $buddy_msn_array[0] =~ s/%([0-9A-Za-z]{2})/pack("H2",$1)/ge;
	    create_account_msn($buddy_msn_array[0]);
	} elsif($_ =~ /\<buddy uri=\"IRC:(.*)\"\>(.*)\<\/buddy\>/) {
	    $buddy_irc = $2;
	    $buddy_irc =~ s/%([0-9A-Za-z]{2})/pack("H2",$1)/ge;
	    create_account_irc($buddy_irc);
	}
    }
}

sub usage {

    print <<EOF
Centerim contact list and history convertor usage:
    $0 <client>

Where <client> is the name of program you can to convert from.
Can be: licq, kxicq2, gnomeicu, micq, trillian.

EOF

}

my $flavour = $ARGV[0];

if($flavour eq "licq") {
    print "Converting from $flavour.. ";
    licq; print "done.\n";
} elsif($flavour eq "kxicq2") {
    print "Converting from $flavour.. ";
    kxicq2; print "done.\n";
} elsif($flavour eq "gnomeicu") {
    print "Converting from $flavour.. ";
    gnomeicu; print "done.\n";
} elsif($flavour eq "micq") {
    print "Converting from $flavour.. ";
    micq; print "done.\n";
} elsif($flavour eq "trillian") {
    print "Converting from $flavour.. ";
    trillian; print "done.\n";
} else {
    usage;
}