###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### PSGConf::Import::inittab - psgconf-import module to parse input
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Import::inittab;
use strict;
BEGIN {
use Exporter ();
our (@ISA, @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(&init &parse);
}
sub init {
my ($psgconf) = @_;
my ($self);
return $self;
}
sub parse {
my ($self, $line) = @_;
my ($i, @res);
### Remove all comments...
$line =~ s/#.*$//;
foreach $i ( split(':', $line)) {
### If we have "" in the string, then escape them
$i =~ s/"/\\"/g if ( $i =~ m/["]+/o );
### If we have a missing field, use the null string
$i = q("") if ( ! length $i );
$i = q(") . $i . q(") if ( $i =~ m/[-\s\t\*\+\.\\]+/o );
push @res, $i;
}
return ( scalar @res )? @res: ();
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Import::inittab - psgconf-import module to parse input
=head1 SYNOPSIS
use PSGConf::Import::inittab;
=head1 DESCRIPTION
The B<PSGConf::Import::inittab> module provides a class which
defines how psgconf-import will parse the F</etc/inittab> file
to write out Config::Objective formatted directives to use
in psgconf config files.
=over 4
=item init()
Currently unimplemented.
=item parse()
Reads the F</etc/inittab> file and returns a C<PSGConf::Data::List>
object for each line.
=back
=head1 SEE ALSO
L<perl>
L<Config::Objective>
=cut
syntax highlighted by Code2HTML, v. 0.9.1