FunctionalPerl
view release on metacpan or search on metacpan
lib/Chj/xhome.pm view on Meta::CPAN
=item xHOME ()
Just the $HOME env var, dieing if not set, and also checked against a
couple assertments.
In taint mode, is tainted.
=item xeffectiveuserhome ()
Just the getpwuid setting. Throws unimplemented exception on Windows
(Raspberry, not Cygwin Perl).
Is not tainted.
=item xsafehome ()
Always take xeffectiveuserhome (unless on Windows, in which case this
is currently the same as xhome), but is asserting that HOME is the
same if set.
lib/Chj/xhome.pm view on Meta::CPAN
@_ == 0 or fp_croak_arity 0;
__ "is untainted";
# (Don't bother about caching, premature opt & dangerous.)
my $uid = $>;
my (
$name, $passwd, $_uid, $gid, $quota,
$comment, $gcos, $dir, $shell, $expire
)
= getpwuid $uid
or die "unknown user for uid $uid";
$dir
}
sub xsafehome {
@_ == 0 or fp_croak_arity 0;
__ "is untainted except on Windows where it's tainted";
if ($^O eq 'MSWin32') {
# XX or how to look it up on Windows again? If implemented, update pod.
lib/Chj/xhome.pm view on Meta::CPAN
our $warned = 0;
sub xchecked_home {
@_ == 2 or fp_croak_arity 2;
my ($home, $what) = @_;
xcheck_home $home;
if (-d $home) {
$home
} else {
warn "$what: dir '$home' does not exist, falling back to getpwuid"
unless $warned++;
undef
}
}
sub maybe_HOME {
__ "is tainted";
if (my $home = $ENV{HOME}) {
xchecked_home $home, '$ENV{HOME}'
} else {
lib/Chj/xperlfunc.pm view on Meta::CPAN
XLmtimed
xLmtime
XLmtime
min max
fstype_for_device
xgetfile_utf8 xslurp
maybe_getfile_utf8
);
# would we really want to export these?:
#caching_getpwuid
#caching_getgrgid
our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
use Carp;
use FP::Carp;
use Chj::singlequote 'singlequote_many'; # the only dependency so far
use Chj::Unix::Exitcode qw(exitcode);
BEGIN {
if ($^O eq 'linux') {
lib/Chj/xperlfunc.pm view on Meta::CPAN
if (not defined($v = $cache{$id})) {
$v = [&$function($id)];
$cache{$id} = $v;
}
wantarray ? @$v : $$v[$scalarindex] ## no critic
} else {
croak "$methodname: got undefined value";
}
}
}
*caching_getpwuid
= mk_caching_getANYid(sub { getpwuid $_[0] }, 0, "caching_getpwuid");
*caching_getgrgid
= mk_caching_getANYid(sub { getgrgid $_[0] }, 0, "caching_getgrgid");
*caching_getpwnam
= mk_caching_getANYid(sub { getpwnam $_[0] }, 2, "caching_getpwnam");
*caching_getgrnam
= mk_caching_getANYid(sub { getgrnam $_[0] }, 2, "caching_getgrnam");
our $fstype_for_device;
lib/Chj/xperlfunc.pm view on Meta::CPAN
sub groupname {
my $s = shift;
scalar $s->getgr
}
# note that those are sensitive to list context!:
# (and yes those should 'probably' return such objects as these, too..)
sub getpw {
my $s = shift;
getpwuid($s->uid)
}
sub getgr {
my $s = shift;
getgrgid($s->gid)
}
# for performance:
sub caching_getpw {
my $s = shift;
Chj::xperlfunc::caching_getpwuid($s->uid);
}
sub caching_getgr {
my $s = shift;
Chj::xperlfunc::caching_getgrgid($s->gid);
}
sub caching_username {
my $s = shift;
scalar $s->caching_getpw
lib/FP/Repl/corefuncs.pm view on Meta::CPAN
Low-level socket functions
"accept", "bind", "connect", "getpeername", "getsockname", "getsockopt", "lisÂ
ten", "recv", "send", "setsockopt", "shutdown", "socket", "socketpair"
System V interprocess communication functions
"msgctl", "msgget", "msgrcv", "msgsnd", "semctl", "semget", "semop", "shmctl",
"shmget", "shmread", "shmwrite"
Fetching user and group info
"endgrent", "endhostent", "endnetent", "endpwent", "getgrent", "getgrgid",
"getgrnam", "getlogin", "getpwent", "getpwnam", "getpwuid", "setgrent", "setpÂ
went"
Fetching network info
"endprotoent", "endservent", "gethostbyaddr", "gethostbyname", "gethostent",
"getnetbyaddr", "getnetbyname", "getnetent", "getprotobyname", "getprotobynumÂ
ber", "getprotoent", "getservbyname", "getservbyport", "getservent", "sethosÂ
tent", "setnetent", "setprotoent", "setservent"
Time-related functions
"gmtime", "localtime", "time", "times"
( run in 0.352 second using v1.01-cache-2.11-cpan-8d75d55dd25 )