This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
aae48c2b283af003218b89c79476943ba868f576
[perl5.git] / ext / I18N-Langinfo / Langinfo.xs
1 #define PERL_NO_GET_CONTEXT
2
3 #include "EXTERN.h"
4 #include "perl.h"
5 #include "XSUB.h"
6
7 #ifdef I_LANGINFO
8 #   define __USE_GNU 1 /* Enables YESSTR, otherwise only __YESSTR. */
9 #   include <langinfo.h>
10 #endif
11
12 #include "const-c.inc"
13
14 MODULE = I18N::Langinfo PACKAGE = I18N::Langinfo
15
16 PROTOTYPES: ENABLE
17
18 INCLUDE: const-xs.inc
19
20 SV*
21 langinfo(code)
22         int     code
23   PROTOTYPE: _
24   CODE:
25 #ifdef HAS_NL_LANGINFO
26         if (code < 0) {
27             SETERRNO(EINVAL, LIB_INVARG);
28             RETVAL = &PL_sv_undef;
29         } else {
30             RETVAL = newSVpv(Perl_langinfo(code), 0);
31         }
32 #else
33         croak("nl_langinfo() not implemented on this architecture");
34 #endif
35   OUTPUT:
36         RETVAL