releasing/makecbr/Win32/Pipe.pm
author Zheng Shen <zheng.shen@nokia.com>
Tue, 20 Jul 2010 15:02:28 +0800
changeset 617 3a747a240983
parent 602 3145852acc89
permissions -rw-r--r--
ROM Tools 12.2.0.4 Postlinker 2.2.5 Revert package_definition.xml to changeset 360bd6b35136
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
package Win32::Pipe;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
$VERSION = '0.024';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# Win32::Pipe.pm
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
#       +==========================================================+
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
#       |                                                          |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
#       |                     PIPE.PM package                      |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
#       |                     ---------------                      |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
#       |                    Release v96.05.11                     |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
#       |                                                          |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
#       |    Copyright (c) 1996 Dave Roth. All rights reserved.    |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
#       |   This program is free software; you can redistribute    |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
#       | it and/or modify it under the same terms as Perl itself. |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
#       |                                                          |
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
#       +==========================================================+
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
#	Use under GNU General Public License or Larry Wall's "Artistic License"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
#	Check the README.TXT file that comes with this package for details about
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
#	it's history.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
require Exporter;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
require DynaLoader;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
@ISA= qw( Exporter DynaLoader );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
    # Items to export into callers namespace by default. Note: do not export
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
    # names by default without a very good reason. Use EXPORT_OK instead.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
    # Do not simply export all your public functions/methods/constants.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
@EXPORT = qw();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
$ErrorNum = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
$ErrorText = "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
sub new
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
    my ($self, $Pipe);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
    my ($Type, $Name, $Time) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
    if (! $Time){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
        $Time = DEFAULT_WAIT_TIME();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
    $Pipe = PipeCreate($Name, $Time);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
    if ($Pipe){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
        $self = bless {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
        $self->{'Pipe'} = $Pipe;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
    }else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
        ($ErrorNum, $ErrorText) = PipeError();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
        return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
    $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
sub Write{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
    my($self, $Data) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
    $Data = PipeWrite($self->{'Pipe'}, $Data);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
    return $Data;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
sub Read{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
    my($self) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
    my($Data);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
    $Data = PipeRead($self->{'Pipe'});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
    return $Data;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
sub Error{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
    my($self) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
    my($MyError, $MyErrorText, $Temp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
    if (! ref($self)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
        undef $Temp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
    }else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
        $Temp = $self->{'Pipe'};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
    ($MyError, $MyErrorText) = PipeError($Temp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
    return wantarray? ($MyError, $MyErrorText):"[$MyError] \"$MyErrorText\"";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
sub Close{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
    my ($self) = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
    PipeClose($self->{'Pipe'});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
    $self->{'Pipe'} = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
sub Connect{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
    my ($self) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
    my ($Result);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
    $Result = PipeConnect($self->{'Pipe'});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
    return $Result;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
sub Disconnect{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
    my ($self, $iPurge) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
    my ($Result);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
    if (! $iPurge){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
        $iPurge = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
    $Result = PipeDisconnect($self->{'Pipe'}, $iPurge);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
    return $Result;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
sub BufferSize{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
    my($self) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
    my($Result) =  PipeBufferSize($self->{'Pipe'});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
    return $Result;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
sub ResizeBuffer{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
    my($self, $Size) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
    my($Result) = PipeResizeBuffer($self->{'Pipe'}, $Size);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
    return $Result;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
####
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
#   Auto-Kill an instance of this module
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
####
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
sub DESTROY
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
    my ($self) = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
    Close($self);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
sub Credit{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
    my($Name, $Version, $Date, $Author, $CompileDate, $CompileTime, $Credits) = Win32::Pipe::Info();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
    my($Out, $iWidth);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
    $iWidth = 60;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
    $Out .=  "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    $Out .=  "  +". "=" x ($iWidth). "+\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
    $Out .=  "  |". Center("", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
    $Out .=  "  |" . Center("", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
    $Out .=  "  |". Center("$Name", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
    $Out .=  "  |". Center("-" x length("$Name"), $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
    $Out .=  "  |". Center("", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
    $Out .=  "  |". Center("Version $Version ($Date)", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
    $Out .=  "  |". Center("by $Author", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
    $Out .=  "  |". Center("Compiled on $CompileDate at $CompileTime.", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
    $Out .=  "  |". Center("", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
    $Out .=  "  |". Center("Credits:", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
    $Out .=  "  |". Center(("-" x length("Credits:")), $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
    foreach $Temp (split("\n", $Credits)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
        $Out .=  "  |". Center("$Temp", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
    $Out .=  "  |". Center("", $iWidth). "|\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
    $Out .=  "  +". "=" x ($iWidth). "+\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
    return $Out;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
sub Center{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
    local($Temp, $Width) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
    local($Len) = ($Width - length($Temp)) / 2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
    return " " x int($Len) . $Temp . " " x (int($Len) + (($Len != int($Len))? 1:0));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
# ------------------ A U T O L O A D   F U N C T I O N ---------------------
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
sub AUTOLOAD {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
    # This AUTOLOAD is used to 'autoload' constants from the constant()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
    # XS function.  If a constant is not found then control is passed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
    # to the AUTOLOAD in AutoLoader.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
    my($constname);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
    ($constname = $AUTOLOAD) =~ s/.*:://;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
    #reset $! to zero to reset any current errors.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
    local $! = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
    $val = constant($constname, @_ ? $_[0] : 0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
    if ($! != 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
    if ($! =~ /Invalid/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
        $AutoLoader::AUTOLOAD = $AUTOLOAD;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
        goto &AutoLoader::AUTOLOAD;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
            # Added by JOC 06-APR-96
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
            # $pack = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
        $pack = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
        ($pack,$file,$line) = caller;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
            print "Your vendor has not defined Win32::Pipe macro $constname, used in $file at line $line.";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
    eval "sub $AUTOLOAD { $val }";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
    goto &$AUTOLOAD;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
bootstrap Win32::Pipe;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
Win32::Pipe - Win32 Named Pipe
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
To use this extension, follow these basic steps. First, you need to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
'use' the pipe extension:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
    use Win32::Pipe;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
Then you need to create a server side of a named pipe:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
    $Pipe = new Win32::Pipe("My Pipe Name");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
or if you are going to connect to pipe that has already been created:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
    $Pipe = new Win32::Pipe("\\\\server\\pipe\\My Pipe Name");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
    NOTE: The "\\\\server\\pipe\\" is necessary when connecting
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
          to an existing pipe! If you are accessing the same
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
          machine you could use "\\\\.\\pipe\\" but either way
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
          works fine.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
You should check to see if C<$Pipe> is indeed defined otherwise there
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
has been an error.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
Whichever end is the server, it must now wait for a connection...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
    $Result = $Pipe->Connect();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
    NOTE: The client end does not do this! When the client creates
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
          the pipe it has already connected!
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
Now you can read and write data from either end of the pipe:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
    $Data = $Pipe->Read();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
    $Result = $Pipe->Write("Howdy! This is cool!");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
When the server is finished it must disconnect:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
    $Pipe->Disconnect();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
Now the server could C<Connect> again (and wait for another client) or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
it could destroy the named pipe...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
    $Data->Close();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
The client should C<Close> in order to properly end the session.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
=head2 General Use
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
This extension gives Win32 Perl the ability to use Named Pipes. Why?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
Well considering that Win32 Perl does not (yet) have the ability to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
C<fork> I could not see what good the C<pipe(X,Y)> was. Besides, where
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
I am as an admin I must have several perl daemons running on several
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
NT Servers. It dawned on me one day that if I could pipe all these
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
daemons' output to my workstation (across the net) then it would be
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
much easier to monitor. This was the impetus for an extension using
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
Named Pipes. I think that it is kinda cool. :)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
=head2 Benefits
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
And what are the benefits of this module?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
=over
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
You may create as many named pipes as you want (uh, well, as many as
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
your resources will allow).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
Currently there is a limit of 256 instances of a named pipe (once a
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
pipe is created you can have 256 client/server connections to that
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
name).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
The default buffer size is 512 bytes; this can be altered by the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
C<ResizeBuffer> method.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
All named pipes are byte streams. There is currently no way to alter a
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
pipe to be message based.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
Other things that I cannot think of right now... :)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
=head1 CONSTRUCTOR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
=over
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
=item new ( NAME )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
Creates a named pipe if used in server context or a connection to the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
specified named pipe if used in client context. Client context is
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
determined by prepending $Name with "\\\\".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
Returns I<true> on success, I<false> on failure.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
=head1 METHODS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
=over
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
=item BufferSize ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
Returns the size of the instance of the buffer of the named pipe.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
=item Connect ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
Tells the named pipe to create an instance of the named pipe and wait
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
until a client connects. Returns I<true> on success, I<false> on
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
failure.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
=item Close ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
Closes the named pipe.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
=item Disconnect ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
Disconnects (and destroys) the instance of the named pipe from the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
client. Returns I<true> on success, I<false> on failure.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
=item Error ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
Returns the last error messages pertaining to the named pipe. If used
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
in context to the package. Returns a list containing C<ERROR_NUMBER>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
and C<ERROR_TEXT>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
=item Read ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
Reads from the named pipe. Returns data read from the pipe on success,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
undef on failure.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
=item ResizeBuffer ( SIZE )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
Sets the size of the buffer of the instance of the named pipe to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
C<SIZE>. Returns the size of the buffer on success, I<false> on
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
failure.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
=item Write ( DATA )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
Writes C<DATA> to the named pipe. Returns I<true> on success, I<false>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
on failure.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
=head1 LIMITATIONS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
What known problems does this thing have?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
=over
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
If someone is waiting on a C<Read> and the other end terminates then
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
you will wait for one B<REALLY> long time! (If anyone has an idea on
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   364
how I can detect the termination of the other end let me know!)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   365
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   366
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   367
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   368
All pipes are blocking. I am considering using threads and callbacks
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   369
into Perl to perform async IO but this may be too much for my time
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   370
stress. ;)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   371
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   372
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   373
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   374
There is no security placed on these pipes.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   375
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   376
=item *
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   377
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   378
This module has neither been optimized for speed nor optimized for
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   379
memory consumption. This may run into memory bloat.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   380
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   381
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   382
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   383
=head1 INSTALLATION NOTES
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   384
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   385
If you wish to use this module with a build of Perl other than
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   386
ActivePerl, you may wish to fetch the source distribution for this
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   387
module. The source is included as part of the C<libwin32> bundle,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   388
which you can find in any CPAN mirror here:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   389
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   390
  modules/by-authors/Gurusamy_Sarathy/libwin32-0.151.tar.gz
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   391
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   392
The source distribution also contains a pair of sample client/server
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   393
test scripts. For the latest information on this module, consult the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   394
following web site:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   395
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   396
  http://www.roth.net/perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   397
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   398
=head1 AUTHOR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   399
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   400
Dave Roth <rothd@roth.net>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   401
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   402
=head1 DISCLAIMER
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   403
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   404
I do not guarantee B<ANYTHING> with this package. If you use it you
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   405
are doing so B<AT YOUR OWN RISK>! I may or may not support this
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   406
depending on my time schedule.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   407
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   408
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   409
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   410
Copyright (c) 1996 Dave Roth. All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   411
This program is free software; you can redistribute
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   412
it and/or modify it under the same terms as Perl itself.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   413
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   414
=cut