Skip to content

Commit

Permalink
Merge pull request #80 from chu11/misc_cleanup
Browse files Browse the repository at this point in the history
misc cleanup
  • Loading branch information
chu11 authored Feb 27, 2025
2 parents 04c8561 + beb96de commit a4f5a38
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 178 deletions.
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ configuration of a cluster by modifying only one file.

This package includes:

* libgenders
* libgenders
- A C library for parsing and querying a genders database. See
libgenders(3).

Expand Down Expand Up @@ -44,4 +44,4 @@ For a thorough introduction to Genders, please read the TUTORIAL.

Albert Chu
[email protected]
Lawrence Livermore National Laboratories
Lawrence Livermore National Laboratories
22 changes: 11 additions & 11 deletions TUTORIAL
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

June 19, 2000

(Revised by Albert Chu - May 2003, April 2004)
(Revised by Ben Casses - July 2015)
(Revised by Albert Chu - May 2003, April 2004)
(Revised by Ben Casses - July 2015)

------------------------------------------------------------------------
NOTE: This document is part of the "Genders" software package,
Expand All @@ -33,7 +33,7 @@ workstations.

Basic Operation

This section describes the formats of the genders file and the nodeattr
This section describes the formats of the genders file and the nodeattr
command. The genders file, briefly described in the introduction, contains
a list of node names and attributes. The genders file is typically found
in /etc (on Linux when installed from the genders RPM) or /admin/etc (on
Expand All @@ -57,7 +57,7 @@ lines. However, no single node may have duplicate attributes.

There must be no spaces embedded in the attribute list and there is
no provision for continuation lines. Commas and equal characters are special
and cannot appear in attribute names or their values. Comments are prefixed
and cannot appear in attribute names or their values. Comments are prefixed
with the hash character (#) and can appear anywhere in the file. The active
genders file is typically found at /etc/genders or /admin/etc/genders.

Expand All @@ -74,14 +74,14 @@ Host Ranges
As noted in section above, the genders database accepts ranges of
nodenames in the general form: prefix[n-m,l-k,...], where n < m and l <
k, etc., as an alternative to explicit lists of nodenames.

This range syntax is meant only as a convenience on clusters with a
prefixNN naming convention and specification of ranges should not be
considered necessary -- the list foo1,foo9 could be specified as such,
or by the range foo[1,9].

Some examples of range usage follow:

foo01,foo02,foo03,foo04,foo05: foo[01-05]
foo3,foo7,foo9,foo11: foo[3,7,9-11]
fooi,fooj,foo0,foo1,foo2: fooi,fooj,foo[0-2]
Expand Down Expand Up @@ -121,14 +121,14 @@ will be listed.
The -k option checks the genders file for proper formatting. Information
about improper formatting will be output to standard error.

Nodeattr can usually be found in /usr/bin (Linux RPM) or /admin/scripts
Nodeattr can usually be found in /usr/bin (Linux RPM) or /admin/scripts
(other systems).

Programming with Genders

Three different APIs have been developed that allow programmers to parse
Three different APIs have been developed that allow programmers to parse
and query the genders file. "libgenders" is a C API which can be linked
by including genders.h and linking the library libgenders. "Libgenders"
by including genders.h and linking the library libgenders. "Libgenders"
is a Perl module developed with Perl extensions. "Genders" is another
Perl modules, but offers a more traditional Perl API than "Libgenders."
The reader can learn more about these libraries by reading the manpages
Expand Down Expand Up @@ -265,7 +265,7 @@ in the cluster. It then adds them to the NMAP database used by NQS:
if (open(PIPE, "|$path_nmapmgr")) {
printf PIPE ("create\n");
$i = 0;
$obj = Genders->new();
$obj = Genders->new();
foreach $node ($obj->getnodes()) {
printf PIPE ("add mid %d %s\n", $i, $node);
$i++;
Expand Down
3 changes: 0 additions & 3 deletions src/libgenders/genders.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,6 @@ _genders_copy_nodeslist(genders_t handle, genders_t handlecopy)
*/
static int _genders_copy_fill_node_index(genders_t handle, genders_t handlecopy)
{
List l = NULL;
ListIterator itr = NULL;
genders_node_t n;
int rv = -1;
Expand All @@ -1312,8 +1311,6 @@ static int _genders_copy_fill_node_index(genders_t handle, genders_t handlecopy)

rv = 0;
cleanup:
if (rv < 0)
__list_destroy(l);
__list_iterator_destroy(itr);
return rv;
}
Expand Down
6 changes: 3 additions & 3 deletions src/libgenders/genders.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ int genders_testattrval(genders_t handle,
* Tests whether the node exists in the genders file. If 'node' is
* NULL, tests the current node.
*
* Returns 1=true , 0=false, -1=failure
* Returns 1=true, 0=false, -1=failure
*/
int genders_isnode(genders_t handle, const char *node);

Expand All @@ -369,7 +369,7 @@ int genders_isnode(genders_t handle, const char *node);
*
* Tests whether the attribute exists in the genders file.
*
* Returns 1=true , 0=false, -1=failure
* Returns 1=true, 0=false, -1=failure
*/
int genders_isattr(genders_t handle, const char *attr);

Expand All @@ -378,7 +378,7 @@ int genders_isattr(genders_t handle, const char *attr);
*
* Tests whether an attr=val exists for some node in the genders file.
*
* Returns 1=true , 0=false, -1=failure
* Returns 1=true, 0=false, -1=failure
*/
int genders_isattrval(genders_t handle, const char *attr, const char *val);

Expand Down
44 changes: 3 additions & 41 deletions src/libgenders/genders_parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,6 @@ strsep (char **stringp, const char *delim)
*
* Returns -1 on error, 1 if there was a parse error, 0 if no errors
*/
/* achu: 'parsed_nodes' is no longer needed, but leave it here if we
* change our minds later concerning whether and empty genders file
* is acceptable.
*/
static int
_parse_line(genders_t handle,
int *numattrs,
Expand All @@ -360,8 +356,7 @@ _parse_line(genders_t handle,
int *attr_index_size,
char *line,
int line_num,
FILE *stream,
int *parsed_nodes)
FILE *stream)
{
char *temp, *nodenames, *node = NULL;
int max_n_subst_vallen = 0, line_maxnodelen = 0, rv = -1;
Expand Down Expand Up @@ -396,9 +391,6 @@ _parse_line(genders_t handle,
if (!(nodenames = strsep(&line, " \t\0")))
return 0;

/* Something resembling a node was found */
*parsed_nodes = 1;

/* if strsep() sets line == NULL, line has no attributes */
if (line)
{
Expand Down Expand Up @@ -630,11 +622,7 @@ _genders_open_and_parse(genders_t handle,
int debug,
FILE *stream)
{
/* achu: 'parsed_nodes' is no longer needed, but leave it here if we
* change our minds later concerning whether and empty genders file
* is acceptable.
*/
int len, errcount = 0, rv = -1, line_count = 1, parsed_nodes = 0;
int len, errcount = 0, rv = -1, line_count = 1;
char buf[GENDERS_BUFLEN];

if (!filename || !strlen(filename))
Expand Down Expand Up @@ -677,8 +665,7 @@ _genders_open_and_parse(genders_t handle,
attr_index_size,
buf,
(debug) ? line_count : 0,
stream,
&parsed_nodes)) < 0)
stream)) < 0)
goto cleanup;

if (debug)
Expand Down Expand Up @@ -706,31 +693,6 @@ _genders_open_and_parse(genders_t handle,
goto cleanup;
}

#if 0

/* achu: Later discussions lead several developers to conclude an
* empty genders file should be acceptable. I'll leave this code
* here for legacy documentation.
*/

if (list_count(nodeslist) == 0)
{
if (debug)
{
fprintf(stream, "No nodes successfully parsed\n");

/* Only increase the parse error count if the file is truly
* empty.
*/
if (!parsed_nodes)
errcount++;
rv = errcount;
}
handle->errnum = GENDERS_ERR_PARSE;
goto cleanup;
}
#endif

rv = (debug) ? errcount : 0;
cleanup:
/* ignore potential error, just return results */
Expand Down
Loading

0 comments on commit a4f5a38

Please sign in to comment.