o2sms
view release on metacpan or search on metacpan
my $retval = $carrier->login($username, $password);
if (!$retval)
{
&log_fatal("relogin failed; " . $carrier->error());
}
}
}
}
}
$message_part_number++;
}
}
# -- do exity stuff
&log_debug("will write to message and/or history files");
$carrier->write_message_file($message_whole);
$carrier->write_history_file($message_whole, &prettyprint_recipients(%recipients)) if ($write_history);
&save_aliases();
# -- quit with success
exit(0);
# -- subs
sub guess_carrier_name
{
if ($0 =~ m/voda(fone)?sms(\.pl)?$/i)
{
return "vodafone";
}
elsif ($0 =~ m/met(eor)?sms(\.pl)?$/i)
{
return "meteor";
}
elsif ($0 =~ m/o2sms(\.pl)?$/i)
{
return "o2";
}
elsif ($0 =~ m/(three|3)sms(\.pl)?$/i)
{
return "three";
}
elsif ($0 =~ m/aft(sms)?(\.pl)?$/i)
{
return "aft";
}
else
{
return undef;
}
}
sub get_username
{
unless (&is_win32())
{
return ( getpwuid $< ) [0];
}
return "user";
}
sub is_win32
{
return ($^O eq 'MSWin32');
}
sub print_usage_and_exit
{
pod2usage(-exitval => $_[0], -verbose => 1);
}
#sub print_version_and_exit
#{
# print "$0 version $VERSION\n";
# exit($_[0]);
#}
sub process_command_line_options
{
Getopt::Long::Configure("bundling_override");
Getopt::Long::Configure("prefix_pattern=-+");
Getopt::Long::Configure("auto_version");
my @ARGV_original = @ARGV;
$debug_level = 0;
GetOptions(%options) or &print_usage_and_exit(1);
# recipents are now in $ARGV
@ARGV_recipients = @ARGV;
@ARGV = @ARGV_original;
return 1;
}
# load configuration from the command line and/or conf file
sub load_configuration
{
# parse arguments
&process_command_line_options();
if (defined($config_file))
{
# another conf file has been specified, read that...
if (!&read_config_file($config_file))
{
&log_error("can't read the configuration file '$config_file'");
}
# ... and load the command line options again to overwrite defaults in config file
&process_command_line_options();
}
if (!defined($carrier_name))
{
# carrier not configured, try to guess based on name of program
( run in 0.774 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )