Commit 58798153 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add silly little IsShelved predicate. Tired of that regex all over the

place. As an added bonus, it will optionally split out the shelf and
unit number and return them in reference variables provided. Returns
0/1 exit status either way.
parent 022c2d6a
......@@ -89,13 +89,14 @@ sub TBAdmin(;$)
}
#
# Check access permission to a list of nodes. First argument is a *reference* to
# a single node, or a list of nodes. Second argument is optional uid, defaults
# to the current uid.
# Check access permission to a list of nodes. First argument is a *reference*
# to a single node, or a list of nodes. Second argument is optional uid,
# defaults to the current uid.
#
# usage: NodeAccessCheck(array or scalar \@nodelist, [int uid])
# returns 1 if the uid is allowed to muck with all the nodes.
# returns 0 if the uid is not allowed to muck with at least one of the nodes.
# returns 0 if the uid is not allowed to muck with at least one of the
# nodes.
#
sub NodeAccessCheck($;$)
{
......@@ -276,6 +277,31 @@ sub OSFeatureSupported($$) {
return 0;
}
#
# Ah, what a hack! I'm tired of seeing regexs for sharks scattered around
# the code. Anyway, this checks to see if a node is a shelf, and fills
# in the shelf/node, return 1 if it is. The shelf/node arguments are
# optional, if all you want to do is see if its a shelf type thing.
#
# usage: IsShelved(char *nodeid, [\@shelf], [\@node])
# returns 1 if the node is a shelf type thing. Optionally fills in info.
# returns 0 if the node is just a normal kind of node.
#
sub IsShelved ($;$$) {
my($nodeid, $shelf, $node) = @_;
if ($nodeid =~ /sh(\d+)-(\d+)/) {
if (defined($shelf)) {
$$shelf = $1;
}
if (defined($node)) {
$$node = $2;
}
return 1;
}
return 0;
}
#
# Issue a DB query. Argument is a string. Returns the actual query object, so
# it is up to the caller to test it. I would not for one moment view this
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment