59 if (strlen(sigact) == 0) {
60 context->InvalidRoutine();
64 else if (*sigact ==
'D' || *sigact ==
'd') {
65 signal(signum, SIG_DFL);
68 else if (*sigact ==
'I' || *sigact ==
'i') {
69 signal(signum, SIG_IGN);
72 context->InvalidRoutine();
88 OPTIONAL_CSTRING, ichar)
93 if (ichar == NULL || *ichar ==
'S' || *ichar ==
's') {
94 return (
RexxObjectPtr)context->NewStringFromAsciiz(name.sysname);
96 else if (*ichar ==
'N' || *ichar ==
'n') {
97 return (
RexxObjectPtr)context->NewStringFromAsciiz(name.nodename);
99 else if (*ichar ==
'R' || *ichar ==
'r') {
100 return (
RexxObjectPtr)context->NewStringFromAsciiz(name.release);
102 else if (*ichar ==
'V' || *ichar ==
'v') {
103 return (
RexxObjectPtr)context->NewStringFromAsciiz(name.version);
105 else if (*ichar ==
'M' || *ichar ==
'm') {
106 return (
RexxObjectPtr)context->NewStringFromAsciiz(name.machine);
108 context->InvalidRoutine();
109 return context->NullString();
143 pid = getsid((pid_t)pid);
162 return context->WholeNumberToObject((
wholenumber_t)setuid((uid_t)uid));
177 return context->WholeNumberToObject((
wholenumber_t)getuid());
195 return context->WholeNumberToObject((
wholenumber_t)seteuid((uid_t)uid));
210 return context->WholeNumberToObject((
wholenumber_t)geteuid());
228 return context->WholeNumberToObject((
wholenumber_t)setgid((gid_t)gid));
243 return context->WholeNumberToObject((
wholenumber_t)getgid());
260 return context->WholeNumberToObject((
wholenumber_t)setegid((gid_t)gid));
275 return context->WholeNumberToObject((
wholenumber_t)getegid());
289 #if defined(OPENBSD) || defined(OPSYS_NETBSD) || defined(OPSYS_FREEBSD)
290 return context->WholeNumberToObject((
wholenumber_t)setpgrp(0, 0));
292 return context->WholeNumberToObject((
wholenumber_t)setpgrp());
308 return context->WholeNumberToObject((
wholenumber_t)getpgrp());
329 return context->WholeNumberToObject((
wholenumber_t)setpgid((pid_t)pid1, (pid_t)pid2));
347 return context->WholeNumberToObject((
wholenumber_t)getpgid((pid_t)pid));
361 pid_t pid = getpid();
376 pid_t pid = getppid();
391 pthread_t tid = pthread_self();
392 return context->UnsignedInt64ToObject((
uint64_t)tid);
412 return kill((pid_t)pid1, sig1);
432 return symlink(path1, path2);
452 return link(path1, path2);
469 return unlink(path1);
492 return chown(path1, (uid_t)uid, (gid_t)gid);
515 return lchown(path1, (uid_t)uid, (gid_t)gid);
535 return chroot(path1);
552 return umask((mode_t)nmask);
589 if (strlen(user) == 0 || strlen(ichar) == 0) {
590 context->InvalidRoutine();
591 return context->NullString();
593 struct passwd *pw = getpwnam(user);
595 return context->NullString();
597 else if (*ichar ==
'N' || *ichar ==
'n') {
598 return (
RexxObjectPtr)context->NewStringFromAsciiz(pw->pw_name);
600 else if (*ichar ==
'U' || *ichar ==
'u') {
603 else if (*ichar ==
'G' || *ichar ==
'g') {
606 else if (*ichar ==
'R' || *ichar ==
'r') {
607 return (
RexxObjectPtr)context->NewStringFromAsciiz(pw->pw_gecos);
609 else if (*ichar ==
'D' || *ichar ==
'd') {
610 return (
RexxObjectPtr)context->NewStringFromAsciiz(pw->pw_dir);
612 else if (*ichar ==
'S' || *ichar ==
's') {
613 return (
RexxObjectPtr)context->NewStringFromAsciiz(pw->pw_shell);
615 else if (*ichar ==
'P' || *ichar ==
'p') {
616 return context->NullString();
618 context->InvalidRoutine();
619 return context->NullString();
639 if (strlen(ichar) == 0) {
640 context->InvalidRoutine();
641 return context->NullString();
643 struct passwd *pw = getpwuid((uid_t)uid);
645 return context->NullString();
647 else if (*ichar ==
'N' || *ichar ==
'n') {
648 return (
RexxObjectPtr)context->NewStringFromAsciiz(pw->pw_name);
650 else if (*ichar ==
'U' || *ichar ==
'u') {
653 else if (*ichar ==
'G' || *ichar ==
'g') {
656 else if (*ichar ==
'R' || *ichar ==
'r') {
657 return (
RexxObjectPtr)context->NewStringFromAsciiz(pw->pw_gecos);
659 else if (*ichar ==
'D' || *ichar ==
'd') {
660 return (
RexxObjectPtr)context->NewStringFromAsciiz(pw->pw_dir);
662 else if (*ichar ==
'S' || *ichar ==
's') {
663 return (
RexxObjectPtr)context->NewStringFromAsciiz(pw->pw_shell);
665 else if (*ichar ==
'P' || *ichar ==
'p') {
666 return context->NullString();
668 context->InvalidRoutine();
669 return context->NullString();
689 if (strlen(grpname) == 0 || strlen(ichar) == 0) {
690 context->InvalidRoutine();
691 return context->NullString();
693 struct group *gr = getgrnam(grpname);
694 if (*ichar ==
'N' || *ichar ==
'n') {
695 return (
RexxObjectPtr)context->NewStringFromAsciiz(gr->gr_name);
697 else if (*ichar ==
'P' || *ichar ==
'p') {
698 return context->NullString();
700 else if (*ichar ==
'G' || *ichar ==
'g') {
703 else if (*ichar ==
'M' || *ichar ==
'm') {
705 char **members = gr->gr_mem;
706 while (*members != NULL) {
707 context->ArrayAppendString(arr, *members, strlen(*members));
712 context->InvalidRoutine();
713 return context->NullString();
733 if (strlen(ichar) == 0) {
734 context->InvalidRoutine();
735 return context->NullString();
737 struct group *gr = getgrgid(gid);
738 if (*ichar ==
'N' || *ichar ==
'n') {
739 return (
RexxObjectPtr)context->NewStringFromAsciiz(gr->gr_name);
741 else if (*ichar ==
'P' || *ichar ==
'p') {
742 return context->NullString();
744 else if (*ichar ==
'G' || *ichar ==
'g') {
747 else if (*ichar ==
'M' || *ichar ==
'm') {
749 char **members = gr->gr_mem;
750 while (*members != NULL) {
751 context->ArrayAppendString(arr, *members, strlen(*members));
756 context->InvalidRoutine();
757 return context->NullString();
781 if (strlen(fname) == 0 || strlen(ichar) == 0) {
782 context->InvalidRoutine();
783 return context->NullString();
785 int retc = stat64(fname, &st);
787 return context->NullString();
789 else if (*ichar ==
'D' || *ichar ==
'd') {
792 else if (*ichar ==
'I' || *ichar ==
'i') {
795 else if (*ichar ==
'P' || *ichar ==
'p') {
797 if (S_ISREG(st.st_mode)) strcpy(buf,
"-");
798 else if (S_ISDIR(st.st_mode)) strcpy(buf,
"d");
799 else if (S_ISLNK(st.st_mode)) strcpy(buf,
"l");
800 else if (S_ISSOCK(st.st_mode)) strcpy(buf,
"s");
801 else if (S_ISCHR(st.st_mode)) strcpy(buf,
"c");
802 else if (S_ISBLK(st.st_mode)) strcpy(buf,
"b");
803 else if (S_ISFIFO(st.st_mode)) strcpy(buf,
"p");
806 strcat(buf, S_IRUSR & st.st_mode ?
"r" :
"-");
809 strcat(buf, S_IWUSR & st.st_mode ?
"w" :
"-");
816 strcat(buf, S_ISUID & st.st_mode ? (S_IXUSR & st.st_mode ?
"s" :
"S") : (S_IXUSR & st.st_mode ?
"x" :
"-"));
819 strcat(buf, S_IRGRP & st.st_mode ?
"r" :
"-");
822 strcat(buf, S_IWGRP & st.st_mode ?
"w" :
"-");
829 strcat(buf, S_ISGID & st.st_mode ? (S_IXGRP & st.st_mode ?
"s" :
"S") : (S_IXGRP & st.st_mode ?
"x" :
"-"));
832 strcat(buf, S_IROTH & st.st_mode ?
"r" :
"-");
835 strcat(buf, S_IWOTH & st.st_mode ?
"w" :
"-");
842 strcat(buf, S_ISVTX & st.st_mode ? (S_IXOTH & st.st_mode ?
"t" :
"T") : (S_IXOTH & st.st_mode ?
"x" :
"-"));
846 else if (*ichar ==
'N' || *ichar ==
'n') {
849 else if (*ichar ==
'U' || *ichar ==
'u') {
852 else if (*ichar ==
'G' || *ichar ==
'g') {
855 else if (*ichar ==
'R' || *ichar ==
'r') {
858 else if (*ichar ==
'S' || *ichar ==
's') {
861 else if (*ichar ==
'A' || *ichar ==
'a') {
862 ftime = localtime(&st.st_atime);
863 strftime(buf,
sizeof(buf),
"%F %T", ftime);
866 else if (*ichar ==
'M' || *ichar ==
'm') {
867 ftime = localtime(&st.st_mtime);
868 strftime(buf,
sizeof(buf),
"%F %T", ftime);
871 else if (*ichar ==
'C' || *ichar ==
'c') {
872 ftime = localtime(&st.st_ctime);
873 strftime(buf,
sizeof(buf),
"%F %T", ftime);
876 context->InvalidRoutine();
877 return context->NullString();
898 return access(file, option);
902 #if defined (HAVE_EUIDACCESS)
920 return euidaccess(file, option);
943 if (strlen(name) == 0 || strlen(proto) == 0) {
944 context->InvalidRoutine();
945 return context->NullString();
947 struct servent *se = getservbyname(name, proto);
949 return context->NullString();
951 if (*ichar ==
'N' || *ichar ==
'n') {
952 return (
RexxObjectPtr)context->NewStringFromAsciiz(se->s_name);
954 else if (*ichar ==
'P' || *ichar ==
'p') {
957 else if (*ichar ==
'A' || *ichar ==
'a') {
959 char **members = se->s_aliases;
960 while (*members != NULL) {
961 context->ArrayAppendString(arr, *members, strlen(*members));
966 context->InvalidRoutine();
967 return context->NullString();
990 if (port <= 0 || port >= 65535 || strlen(proto) == 0) {
991 context->InvalidRoutine();
992 return context->NullString();
994 struct servent *se = getservbyport(htons(port), proto);
996 return context->NullString();
998 else if (*ichar ==
'N' || *ichar ==
'n') {
999 return (
RexxObjectPtr)context->NewStringFromAsciiz(se->s_name);
1001 else if (*ichar ==
'P' || *ichar ==
'p') {
1004 else if (*ichar ==
'A' || *ichar ==
'a') {
1006 char **members = se->s_aliases;
1007 while (*members != NULL) {
1008 context->ArrayAppendString(arr, *members, strlen(*members));
1013 context->InvalidRoutine();
1014 return context->NullString();
1027 #if !defined(OPENBSD)
1034 if (strlen(inexp) == 0) {
1035 context->InvalidRoutine();
1036 return context->NullString();
1040 wordexp(inexp, &p, 0);
1043 for (
int i = 0; i < p.we_wordc; i++) {
1044 context->ArrayAppendString(arr, w[i], strlen(w[i]));
1072 return SetXattr(fname, name, val, strlen(val) + 1, 0);
1095 sz =
GetXattr(fname, name, NULL, 0);
1097 return context->NullString();
1099 buf = (
char *)alloca(sz);
1124 return context->NullString();
1126 buf = (
char *)alloca(sz);
1132 context->ArrayAppendString(arr, buf, strlen(buf));
1133 sz -= strlen(buf) + 1;
1134 buf += strlen(buf) + 1;
1176 return sizeof(
void *) * 8;
1190 char hostname[HOST_NAME_MAX];
1192 gethostname(hostname, HOST_NAME_MAX);
1193 return (
RexxObjectPtr)context->NewStringFromAsciiz(hostname);
1218 if (strlen(mode) != 9) {
1219 context->InvalidRoutine();
1224 if (mode[0] ==
'r') {
1227 else if (mode[0] ==
'-') {
1230 context->InvalidRoutine();
1233 if (mode[1] ==
'w') {
1236 else if (mode[1] ==
'-') {
1239 context->InvalidRoutine();
1242 if (mode[2] ==
'x') {
1245 else if (mode[2] ==
'S') {
1248 else if (mode[2] ==
's') {
1252 else if (mode[2] ==
'-') {
1255 context->InvalidRoutine();
1260 if (mode[3] ==
'r') {
1263 else if (mode[3] ==
'-') {
1266 context->InvalidRoutine();
1269 if (mode[4] ==
'w') {
1272 else if (mode[4] ==
'-') {
1275 context->InvalidRoutine();
1278 if (mode[5] ==
'x') {
1281 else if (mode[5] ==
'S') {
1284 else if (mode[5] ==
's') {
1288 else if (mode[5] ==
'-') {
1291 context->InvalidRoutine();
1296 if (mode[6] ==
'r') {
1299 else if (mode[6] ==
'-') {
1302 context->InvalidRoutine();
1305 if (mode[7] ==
'w') {
1308 else if (mode[7] ==
'-') {
1311 context->InvalidRoutine();
1314 if (mode[8] ==
'x') {
1317 else if (mode[8] ==
'T') {
1320 else if (mode[8] ==
't') {
1324 else if (mode[8] ==
'-') {
1327 context->InvalidRoutine();
1331 return chmod(file, perm);
1361 static const char *msgs[] = {
1363 "Operation not permitted",
1364 "No such file or directory",
1366 "Interrupted system call",
1368 "No such device or address",
1369 "Argument list too long",
1370 "Exec format error",
1372 "No child processes",
1375 "Permission denied",
1377 "Block device required",
1378 "Device or resource busy",
1380 "Cross-device link",
1385 "File table overflow",
1386 "Too many open files",
1390 "No space left on device",
1392 "Read-only file system",
1395 "Math argument out of domain of func",
1396 "Math result not representable",
1397 "Resource deadlock would occur",
1398 "File name too long",
1399 "No record locks available",
1400 "Function not implemented",
1401 "Directory not empty",
1402 "Too many symbolic links encountered",
1403 "Operation would block",
1404 "No message of desired type",
1405 "Identifier removed",
1406 "Channel number out of range",
1407 "Level 2 not synchronized",
1410 "Link number out of range",
1411 "Protocol driver not attached",
1412 "No CSI structure available",
1415 "Invalid request descriptor",
1418 "Invalid request code",
1421 "Bad font file format",
1422 "Device not a stream",
1423 "No data available",
1425 "Out of streams resources",
1426 "Machine is not on the network",
1427 "Package not installed",
1429 "Link has been severed",
1432 "Communication error on send",
1434 "Multihop attempted",
1435 "RFS specific error",
1436 "Not a data message",
1437 "Value too large for defined data type",
1438 "Name not unique on network",
1439 "File descriptor in bad state",
1440 "Remote address changed",
1441 "Can not access a needed shared library",
1442 "Accessing a corrupted shared library",
1443 ".lib section in a.out corrupted",
1444 "Attempting to link in too many shared libraries",
1445 "Cannot exec a shared library directly",
1446 "Illegal byte sequence",
1447 "Interrupted system call should be restarted",
1448 "Streams pipe error",
1450 "Socket operation on non-socket",
1451 "Destination address required",
1453 "Protocol wrong type for socket",
1454 "Protocol not available",
1455 "Protocol not supported",
1456 "Socket type not supported",
1457 "Operation not supported on transport endpoint",
1458 "Protocol family not supported",
1459 "Address family not supported by protocol",
1460 "Address already in use",
1461 "Cannot assign requested address",
1463 "Network is unreachable",
1464 "Network dropped connection because of reset",
1465 "Software caused connection abort",
1466 "Connection reset by peer",
1467 "No buffer space available",
1468 "Transport endpoint is already connected",
1469 "Transport endpoint is not connected",
1470 "Cannot send after transport endpoint shutdown",
1471 "Too many references: cannot splice",
1472 "Connection timed out",
1473 "Connection refused",
1476 "Operation already in progress",
1477 "Operation now in progress",
1478 "Stale NFS file handle",
1479 "Structure needs cleaning",
1480 "Not a XENIX named type file",
1481 "No XENIX semaphores available",
1482 "Is a named type file",
1486 "Wrong medium type",
1487 "Operation Canceled",
1488 "Required key not available",
1490 "Key has been revoked",
1491 "Key was rejected by service",
1493 "State not recoverable",
1494 "Operation not possible due to RF-kill",
1497 if (en >=
sizeof(msgs) /
sizeof(
char *)) {
1498 return (
RexxObjectPtr)context->NewStringFromAsciiz(
"Unknown");
1500 return (
RexxObjectPtr)context->NewStringFromAsciiz(msgs[en]);
1524 if (strlen(str) == 0)
1527 context->String(
"SYSCRYPT"), context->String(
"1"));
1528 return context->NullString();
1530 if (strlen(salt) == 0)
1533 context->String(
"SYSCRYPT"), context->String(
"2"));
1534 return context->NullString();
1537 es = crypt(str, salt);
1539 return context->NullString();
1561 return mkdir(dir, mode);
1597 struct dirent *direntry;
1599 dirptr = opendir(dir);
1600 if (dirptr != NULL) {
1601 direntry = readdir(dirptr);
1602 while (direntry != NULL) {
1603 context->ArrayAppendString(arr, direntry->d_name, strlen(direntry->d_name));
1604 direntry = readdir(dirptr);
1624 return (
RexxObjectPtr)context->NewStringFromAsciiz(tzname[0]);
1640 return (
RexxObjectPtr)context->NewStringFromAsciiz(tzname[1]);
1685 #if defined (HAVE_EUIDACCESS)
#define REXX_INTERPRETER_4_0_0
#define REXX_LAST_ROUTINE()
#define REXX_LAST_METHOD()
#define REXX_TYPED_ROUTINE(n, e)
#define STANDARD_PACKAGE_HEADER
#define Rexx_Error_Incorrect_call_null
struct _RexxArrayObject * RexxArrayObject
struct _RexxObjectPtr * RexxObjectPtr
RexxRoutine3(int, SysChown, CSTRING, path1, int, uid, int, gid)
RexxMethodEntry orxnixclib_methods[]
RexxRoutineEntry orxnixclib_routines[]
RexxRoutine0(RexxObjectPtr, SysSetsid)
RexxRoutine1(RexxObjectPtr, SysUname, OPTIONAL_CSTRING, ichar)
RexxRoutine2(int, SysSignal, int, signum, CSTRING, sigact)
static void orxnixclib_loader(RexxThreadContext *context)
RexxPackageEntry orxnixclib_package_entry
OOREXX_GET_PACKAGE(orxnixclib)
unsigned __int64 uint64_t