Skip to content

Commit 8006e92

Browse files
IgorTodorovskiIBMkhwilliamson
authored andcommitted
Add os390.c
z/OS has extra startup needs like a couple other platforms, e.g. cygwin. This adds a file that handles them. Principally, z/OS files have extra status fields regarding "tags". Files on this system may be encoded in different character sets, and these fields describe them. Hence the OS has within it the knowledge of a file's encoding. A file is "tagged" as being in a particular encoding (or encodings plural; I have no idea how that works). This file adds a function to deal with them.
1 parent 741ab8d commit 8006e92

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5665,6 +5665,7 @@ os2/os2thread.h pthread-like typedefs
56655665
os2/perl2cmd.pl Corrects installed binaries under OS/2
56665666
os2/perlrexx.c Support perl interpreter embedded in REXX
56675667
os2/perlrexx.cmd Test perl interpreter embedded in REXX
5668+
os390/os390.c z/OS specific code
56685669
plan9/9front.patch Plan9 port: patch for 9front-specific flavor of Plan 9
56695670
plan9/aperl Plan9 port: shell to make Perl error messages Acme-friendly
56705671
plan9/arpa/inet.h Plan9 port: replacement C header file

os390/os390.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include <string.h>
2+
#include <sys/stat.h>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <sys/ps.h>
6+
#include <unistd.h>
7+
#include <stdarg.h>
8+
#include <varargs.h>
9+
#include <limits.h>
10+
#include <_Nascii.h>
11+
#include <fcntl.h>
12+
#include <libgen.h>
13+
#include <termios.h>
14+
#include <zos.h>
15+
#include "EXTERN.h"
16+
#include "perl.h"
17+
#include "XSUB.h"
18+
19+
void
20+
zos_copytags_fd(pTHX_ CV *cv)
21+
{
22+
dXSARGS;
23+
int ret = 0;
24+
25+
if (items != 2)
26+
Perl_croak(aTHX_ "Usage: ZOS::Filespec::copytags_fd(f1, f2])");
27+
28+
int from_fd = (int)SvIV(ST(0));
29+
int to_fd = (int)SvIV(ST(1));
30+
31+
char path[_XOPEN_PATH_MAX] = {0};
32+
int rc = w_ioctl(from_fd, _IOCC_GPN, _XOPEN_PATH_MAX, path);
33+
if (rc == 0) {
34+
__e2a_l(path, _XOPEN_PATH_MAX);
35+
}
36+
37+
struct stat src_statsbuf;
38+
if (stat(path, &src_statsbuf)) {
39+
ret = -1;
40+
}
41+
if (ret != -1) {
42+
ret = __setfdccsid(to_fd, (src_statsbuf.st_tag.ft_txtflag << 16) | src_statsbuf.st_tag.ft_ccsid);
43+
}
44+
45+
XSRETURN_IV(ret);
46+
}
47+
48+
void
49+
init_os_extras(void)
50+
{
51+
dTHX;
52+
char* file = __FILE__;
53+
54+
newXSproto("ZOS::Filespec::copytags_fd",zos_copytags_fd,file,"$;$");
55+
56+
return;
57+
}

0 commit comments

Comments
 (0)