OSSP CVS Repository

ossp - Check-in [2313]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2313
Date: 2002-Jul-18 15:56:25 (local)
2002-Jul-18 13:56:25 (UTC)
User:ps
Branch:
Comment: Appended handle structure.
Tickets:
Inspections:
Files:
ossp-pkg/tabea/TABEA/Tabea.pm      1.1 -> 1.2     102 inserted, 24 deleted

ossp-pkg/tabea/TABEA/Tabea.pm 1.1 -> 1.2

--- Tabea.pm     2002/07/05 13:26:35     1.1
+++ Tabea.pm     2002/07/18 13:56:25     1.2
@@ -27,72 +27,147 @@
 ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 ##  SUCH DAMAGE.
 ##
-##  Tabea.pm: Tabea Perl Module
+##  Tabea.pm: Tabea Module
 ##
 
 
 package TABEA::Tabea;
 require 5.000;
-
+use IO::File;
 
 sub new{
+    #  Currently the only supported $type is "HTML2" which causes only
+    #  tags described in RFC1866 to be used.  When a menu is rendered,
+    #  some elements may require uniqe names in a scope wider than
+    #  known by this module, i.e. when two configs are presented on one
+    #  screen or along with other information, so every item is
+    #  prefixed with $prefix.
+    my $proto = shift;
+    my $class = ref($proto) || $proto || "TABEA::Tabea.pm" ;
     my ($config, $prefix) = @_;
-    my $handle = 0;
+    my $cfgfh;
 
-    return $handle;
+    my $self = {};
+    $self->{Config} = $config;
+    $self->{Prefix} = $prefix;
+    $cfgfh = new IO::File ("<".$self->{Config}) || die ;
+    while (<$cfgfh>) {
+        $self->{Configuration} .= $_;
+    }
+    $cfgfh->close();
+    
+    bless($self, $class);
+     
+    return $self;
 }
 
 
 sub load{
-    my ($data) = @_;
+    #  Reads $data and sets the value of items.
+    my $self = shift;
     my $rc = 1;
 
+    if (! @_) { $rc = 0 };
+    my ($data) = @_;
+
+    print "TABEA::Tabea $data load funtion\n";
+ 
     return $rc;
 }
 
 
 sub save {
-    my ($data) = @_;
+    #  Writes items including their values.
+    my $self = shift;
     my $rc = 1;
 
+    if (! @_) { $rc = 0 };
+    my ($data) = @_;
+
+    print "TABEA::Tabea $data save funtion\n";
+ 
     return $rc;
+
 }
 
 
 sub parse {
-    my ($type, $buffer) = @_;
-    my $rc;
-  
-  
+
+    my $self = shift;
+    my $rc = 1;
+
+    if (! @_) { $rc = 0 };
+    my ($param) = @_;
+
+    print "TABEA::Tabea $param parse funtion\n";
+ 
     return $rc;
 }
 
 
 
 sub render {
-    my ($type, $buffer) = @_;
-    my $rc;
+    #  Renders a menu and writes it into the buffer. The contents of the
+    #  buffer can be merged into a larger output. Values are verified
+    #  and invalid data is marked (FIXME how? red, reset to default,
+    #  configurable behaviour, configurable error messages ...) The
+    #  caller must finally print out the menu and when an input comes
+    #  back it must identify menu activity (i.e. by checking the
+    #  prefix) and call render again and again or execute some action.
+    my $self = shift;
+    my $rc = 1;
 
+    if (! @_) { $rc = 0 };
+    my ($buffer) = @_;
+
+    $buffer .= $self->{Configuration};
     
-    return $rc;
+    return $buffer, $rc;
 }
 
 sub import{
+    #  Reads a legacy (manually edited or previously exported) file and
+    #  tries to match out values.
+    my $self = shift;
+    my $rc = 1;
+
+    if (! @_) { $rc = 0 };
     my ($legacyfile) = @_;
-    my $rc;
-    
-     
-    return $rc;   
+
+    my $legacyfh;
+    my $newdata = "";
+
+    print "TABEA::Tabea import " . $legacyfile . "funtion\n";
+
+    $legacyfh = new IO::File ("<".$legacyfile) || die ;
+    while (<legacyfh>) {
+        $newdata .= $_;
+    }
+    $legacyfh->close();
+ 
+    return $rc;
 }
 
 
 
 sub export{
+    #  Applies variable substitution for a template and writes the
+    #  result out to exportfile.
+    my $self = shift;
+    my $rc = 1;
+
+    if (! @_) { $rc = 0 };
     my ($template, $exportfile) = @_;
-    my $rc;
-    
-     
-    return $rc;   
+    my $exportfh;
+
+    print "TABEA::Tabea $template, $exportfile export funtion\n";
+
+    $exportfh = new IO::File (">".$exportfile) || die "Cannot open $exportfile for writing.";
+    print $exportfh $template;
+    $exportfh->close();
+
+    return $rc;
+
 }
 
 
@@ -101,10 +176,13 @@
 
 
 sub destroy{
-    my $rc;
+    my $self = shift;
+    my $rc = 1;
 
-    return $rc.
-  
+
+    print "TABEA::Tabea $self destroy funtion\n";
+ 
+    return $rc;
 }
 
 

CVSTrac 2.0.1