package FS::SelfService;
use strict;
-use vars qw($VERSION @ISA @EXPORT_OK $socket);
+use vars qw($VERSION @ISA @EXPORT_OK $socket %autoload );
use Exporter;
use Socket;
use FileHandle;
$VERSION = '0.03';
@ISA = qw( Exporter );
-@EXPORT_OK = qw( passwd );
$socket = "/usr/local/freeside/selfservice_socket";
+%autoload = (
+ 'passwd' => 'passwd/passwd',
+ 'chfn' => 'passwd/passwd',
+ 'chsh' => 'passwd/passwd',
+ 'login' => 'MyAccount/login',
+ 'customer_info' => 'MyAccount/customer_info',
+ 'invoice' => 'MyAccount/invoice',
+ 'cancel' => 'MyAccount/cancel',
+);
+@EXPORT_OK = keys %autoload;
+
$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
$ENV{'SHELL'} = '/bin/sh';
$ENV{'IFS'} = " \t\n";
=cut
-sub passwd {
- my $param;
- if ( ref($_[0]) ) {
- $param = shift;
- } else {
- $param = { @_ };
- }
+foreach my $autoload ( keys %autoload ) {
+
+ my $eval =
+ "sub $autoload { ". '
+ my $param;
+ if ( ref($_[0]) ) {
+ $param = shift;
+ } else {
+ $param = { @_ };
+ }
+
+ $param->{_packet} = \''. $autoload{$autoload}. '\';
+
+ simple_packet($param);
+ }';
- $param->{_packet} = 'passwd';
+ eval $eval;
+ die $@ if $@;
- simple_packet($param);
}
sub simple_packet {
my $return = fd_retrieve(\*SOCK) or die "error reading result: $!";
die $return->{'_error'} if defined $return->{_error} && $return->{_error};
- $return->{'error'};
+ $return;
}
=back