Calling API Message Functions

The C language LayGO API message functions, such as lgo_ErrorMessage() return pointers to NUL-terminated arrays of one byte characters. In Perl5, they return Perl strings:

LResult result = lgo_OpenProtocol(lgo_PROTOCOL_X21_BIS, line, 0);

if (result < 0)
    char str[256];

    sprintf(str, "Failure opening Line %d: %s",
                      line, lgo_ErrorMessage(result));

becomes in Perl:

my $result = lgo_OpenProtocol(Laygo::PROTOCOL_X21_BIS, $line, 0);

if ($result < 0)
    &PostError(sprintf("Failure opening Line %d: %s",
                               $line, lgo_ErrorMessage($result));