libmsgcat-perl-1.03/0040700000175000017500000000000006366360151014634 5ustar rhertzogrhertzoglibmsgcat-perl-1.03/Msgcat.xs0100600000175000017500000000215306363206464016431 0ustar rhertzogrhertzog#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include typedef int SysRet; typedef nl_catd *Locale__Msgcat; MODULE = Locale::Msgcat PACKAGE = Locale::Msgcat Locale::Msgcat new(packname = "Locale::Msgcat") char * packname CODE: { RETVAL = (nl_catd *)safemalloc(sizeof(nl_catd)); } OUTPUT: RETVAL void DESTROY(catalog) Locale::Msgcat catalog CODE: safefree((nl_catd *)catalog); SysRet catopen(catalog, name, option) Locale::Msgcat catalog char *name int option CODE: { *catalog = catopen(name, option); if (*catalog == (nl_catd) -1) RETVAL = 0; else RETVAL = 1; } OUTPUT: RETVAL SysRet catclose(catalog) Locale::Msgcat catalog CODE: RETVAL = (catclose(*catalog) == 0); OUTPUT: RETVAL char * catgets(catalog, set_number, message_number, string) Locale::Msgcat catalog int set_number int message_number char * string CODE: RETVAL = catgets(*catalog, set_number, message_number, string); OUTPUT: RETVAL libmsgcat-perl-1.03/Msgcat.pm0100600000175000017500000000422207013727747016417 0ustar rhertzogrhertzogpackage Locale::Msgcat; use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. @EXPORT = qw( ); $VERSION = '1.03'; ## Define required constants #require 'nl_types.ph'; bootstrap Locale::Msgcat $VERSION; # Preloaded methods go here. # Autoload methods go after =cut, and are processed by the autosplit program. 1; __END__ # Below is the stub of documentation for your module. You better edit it! =head1 NAME Locale::Msgcat - Perl extension for blah blah blah =head1 SYNOPSIS use Locale::Msgcat; $cat = new Locale::Msgcat; $rc = $cat->catopen(name, oflag); $msg = $cat->catgets(set_number, message_number, string); $rc = $cat->catclose(); =head1 DESCRIPTION The B module allows access to the message catalog functions which are available on some systems. A new Locale::Msgcat object must first be created for each catalog which has to be open at a given time. The B operation opens the catalog whose name is given as argument. The oflag can be either 0 or NL_CAT_LOCALE (usually 1) which is the recommended value. The B message retrieves message_number for the set_number message set, and if not found returns string. The B function should be used when access to a catalog is not needed anymore. =head1 EXAMPLES use Locale::Msgcat; $cat = new Locale::Msgcat; unless ($cat->catopen("whois.cat", 1)) { print STDERR "Can't open whois catalog.\n"; exit(1); } printf "First message, first set : %s\n", $cat->catgets(1, 1, "not found"); unless ($cat->catclose()) { print STDERR "Can't close whois catalog.\n"; exit(1); } The above example would print the first message from the first message set found in the whois catalog, or if not found it would print "not found". =head1 AUTHOR Christophe Wolfhugel, wolf@pasteur.fr =head1 SEE ALSO catopen(3), catclose(3), catgets(3), perl(1). =cut 1; libmsgcat-perl-1.03/Makefile.PL0100600000175000017500000000057506363200773016614 0ustar rhertzogrhertzoguse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Locale::Msgcat', 'VERSION_FROM' => 'Msgcat.pm', # finds $VERSION 'LIBS' => [''], # e.g., '-lm' 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' 'INC' => '', # e.g., '-I/usr/include/other' ); libmsgcat-perl-1.03/test.pl0100600000175000017500000000252606622505257016157 0ustar rhertzogrhertzog# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..7\n"; } END {print "not ok 1\n" unless $loaded;} my @gencat = qw( gencat /bin/gencat /usr/bin/gencat /usr/sbin/gencat /sbin/gencat /etc/gencat /usr/etc/gencat /usr/local/bin/gencat ); use Locale::Msgcat; $loaded = 1; print "ok 1\n"; ## Generate the catalog if (MakeCat() != 0) { print "not ok 2\n"; exit 0; } print "ok 2\n"; unless ($a = new Locale::Msgcat) { print "not ok 2\n"; exit 0; } print "ok 2\n"; unless ($a->catopen("./sample.cat", 1)) { print "not ok 3\n"; exit 0; } print "ok 3\n"; print "not " if ($a->catgets(1, 1, "test") ne "Hi there ?"); print "ok 4\n"; print "not " if ($a->catgets(2, 1, "test") ne "It's raining."); print "ok 5\n"; print "not " if ($a->catgets(2, 2, "test") ne "test"); print "ok 6\n"; print "not " unless ($a->catclose()); print "ok 7\n"; unlink("sample.cat"); exit 0; ## Makes the message catalog sub MakeCat { my $i; while ($i = shift(@gencat)) { return 0 if (system("$i sample.cat sample.msg") == 0); } return 1; } libmsgcat-perl-1.03/Changes0100600000175000017500000000100007013730007016104 0ustar rhertzogrhertzogRevision history for Perl extension Locale::Msgcat. 1.03 15 November 1999 - Changed the name of the directory for the distribution, ie Msgcat-version/ instead of Msgcat/. 1.02 15 November 1999 - XPG4 says that the fields in the message catalog must be separated by one blank, not many. Corrected this in the sample file. 1.01 12 November 1998 - unlinks "sample.cat" after the test has been executed, as "gencat" would otherwise update the catalog (XPG4). 1.00 26 July 1997 - original version. libmsgcat-perl-1.03/MANIFEST0100600000175000017500000000012306366360175015766 0ustar rhertzogrhertzogChanges MANIFEST Makefile.PL Msgcat.pm Msgcat.xs README sample.msg test.pl typemap libmsgcat-perl-1.03/README0100600000175000017500000000147506366355151015526 0ustar rhertzogrhertzogThis is Msgcat, a small Perl modules for systems which support the XPG4 message catalog functions : catopen(3), catgets(3) and catclose(4). You need perl 5.004 or later to use this library. You install the library by running these commands: perl Makefile.PL make make test make install Please report any bugs/suggestions to Christophe Wolfhugel . All files contained in this installation are Copyright (C) 1997 C. Wolfhugel unless otherwise specified. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Systems where the library is known to work Digital Unix 4 Linux (2.0.29, Debian 1.3) Solaris 2.5 Systems where the library won't work (usually because the catalog functions are not available) SunOS 4.1.3 libmsgcat-perl-1.03/typemap0100600000175000017500000000003106363202765016232 0ustar rhertzogrhertzogLocale::Msgcat T_PTROBJ libmsgcat-perl-1.03/sample.msg0100600000175000017500000000015207013725563016624 0ustar rhertzogrhertzog$quote " $set 1 First set of messages 1 "Hi there ?" $set 2 Second set of messages 1 "It's raining."