Skip to content

Commit

Permalink
Merge pull request #83 from chu11/maxattrs
Browse files Browse the repository at this point in the history
libgenders: deprecate genders_getmaxattrs()
  • Loading branch information
chu11 authored Feb 27, 2025
2 parents 87877de + c86e855 commit 79283a9
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 81 deletions.
2 changes: 0 additions & 2 deletions man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ man3_MANS = \
genders_perror.3 \
genders_getnumnodes.3 \
genders_getnumattrs.3 \
genders_getmaxattrs.3 \
genders_getmaxnodelen.3 \
genders_getmaxattrlen.3 \
genders_getmaxvallen.3 \
Expand Down Expand Up @@ -60,7 +59,6 @@ EXTRA_DIST = \
genders_perror.3 \
genders_getnumnodes.3 \
genders_getnumattrs.3 \
genders_getmaxattrs.3 \
genders_getmaxnodelen.3 \
genders_getmaxattrlen.3 \
genders_getmaxvallen.3 \
Expand Down
2 changes: 0 additions & 2 deletions man/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ man3_MANS = \
genders_perror.3 \
genders_getnumnodes.3 \
genders_getnumattrs.3 \
genders_getmaxattrs.3 \
genders_getmaxnodelen.3 \
genders_getmaxattrlen.3 \
genders_getmaxvallen.3 \
Expand Down Expand Up @@ -424,7 +423,6 @@ EXTRA_DIST = \
genders_perror.3 \
genders_getnumnodes.3 \
genders_getnumattrs.3 \
genders_getmaxattrs.3 \
genders_getmaxnodelen.3 \
genders_getmaxattrlen.3 \
genders_getmaxvallen.3 \
Expand Down
8 changes: 4 additions & 4 deletions man/genders_getattr.3
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ attribute values list.

To avoid passing in a list that is not large enough to store all the
attributes and attribute values,
.BR genders_getmaxattrs (3)
should be used to determine the minimum number of elements \fIattrs\fR
and \fIvals\fR should be able to store.
.BR genders_getnumattrs (3)
should be used to get the maximum possible number of elements \fIattrs\fR
and \fIvals\fR could have.
.BR genders_attrlist_create (3)
and
.BR genders_vallist_create (3)
Expand Down Expand Up @@ -96,5 +96,5 @@ point to a genders handle or \fIhandle\fR has been destroyed by
/usr/include/genders.h
.SH SEE ALSO
libgenders(3), genders_handle_create(3), genders_load_data(3),
genders_getmaxattrs(3), genders_attrlist_create(3),
genders_getnumattrs(3), genders_attrlist_create(3),
genders_vallist_create(3), genders_errnum(3), genders_strerror(3)
26 changes: 0 additions & 26 deletions man/genders_getmaxattrs.3

This file was deleted.

23 changes: 8 additions & 15 deletions man/genders_getnumnodes.3
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@
.\"############################################################################
.TH GENDERS_GETNUMNODES 3 "August 2003" "LLNL" "LIBGENDERS"
.SH NAME
genders_getnumnodes, genders_getnumattrs, genders_getmaxattrs,
genders_getmaxnodelen, genders_getmaxattrlen, genders_getmaxvallen \-
genders statistics routines
genders_getnumnodes, genders_getnumattrs, genders_getmaxnodelen, genders_getmaxattrlen,
genders_getmaxvallen \- genders statistics routines
.SH SYNOPSIS
.B #include <genders.h>
.sp
.BI "int genders_getnumnodes(genders_t handle);"
.sp
.BI "int genders_getnumattrs(genders_t handle);"
.sp
.BI "int genders_getmaxattrs(genders_t handle);"
.sp
.BI "int genders_getmaxnodelen(genders_t handle);"
.sp
.BI "int genders_getmaxattrlen(genders_t handle);"
Expand All @@ -45,19 +42,16 @@ genders statistics routines
.br
.SH DESCRIPTION
\fBgenders_getnumnodes()\fR, \fBgenders_getnumattrs()\fR,
\fBgenders_getmaxattrs()\fR, \fBgenders_getmaxnodelen()\fR,
\fBgenders_getmaxattrlen()\fR, and \fBgenders_getmaxvallen()\fR get
statistics about the genders file associated with \fIhandle\fR.
\fBgenders_getmaxnodelen()\fR, \fBgenders_getmaxattrlen()\fR,
and \fBgenders_getmaxvallen()\fR get statistics about the genders
file associated with \fIhandle\fR.

\fBgenders_getnumnodes()\fR returns the number of nodes stored in the
genders file.

\fBgenders_getnumattrs()\fR returns the number of attributes listed in
the genders file.

\fBgenders_getmaxattrs()\fR returns the maximum number of attributes
listed with a node in the genders file.

\fBgenders_getmaxnodelen()\fR returns the maximum length of any node
listed in the genders file.

Expand All @@ -68,10 +62,9 @@ attribute listed in the genders file.
attribute value listed in the genders file.

In general, \fBgenders_getnumnodes()\fR, \fBgenders_getnumattrs()\fR,
\fBgenders_getmaxattrs()\fR, \fBgenders_getmaxnodelen()\fR,
\fBgenders_getmaxattrlen()\fR, and \fBgenders_getmaxvallen()\fR are
used so a programmer can dynamically allocate a proper amount of
memory to store genders file information in.
\fBgenders_getmaxnodelen()\fR, \fBgenders_getmaxattrlen()\fR, and
\fBgenders_getmaxvallen()\fR are used so a programmer can dynamically
allocate a proper amount of memory to store genders file information in.
.br
.SH RETURN VALUES
On success, 0 is returned. On error, -1 is returned, and an error
Expand Down
2 changes: 0 additions & 2 deletions man/libgenders.3
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ libgenders \- a library of functions to parse and retrieve genders data
.sp
.BI "int genders_getnumattrs(genders_t handle);"
.sp
.BI "int genders_getmaxattrs(genders_t handle);"
.sp
.BI "int genders_getmaxnodelen(genders_t handle);"
.sp
.BI "int genders_getmaxattrlen(genders_t handle);"
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/cplusplus/gendersplusplus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ unsigned int Genders::getmaxattrs() const
{
int rv;

if ((rv = genders_getmaxattrs(gh)) < 0)
if ((rv = genders_getnumattrs(gh)) < 0)
_throw_exception(genders_errnum(gh));

return rv;
Expand Down
1 change: 1 addition & 0 deletions src/extensions/cplusplus/gendersplusplus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class Genders
~Genders();
unsigned int getnumnodes() const;
unsigned int getnumattrs() const;
[[deprecated("use getnumattrs()")]]
unsigned int getmaxattrs() const;
std::string getnodename() const;
std::vector< std::string > getnodes(const std::string attr = "", const std::string val = "") const;
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/java/gov/llnl/lc/chaos/Genders.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public Genders(String filename) throws GendersException
* the genders database
*
* @throws GendersException on error
*
* @deprecated Use getnumattrs()
*/
@Deprecated
public native int getmaxattrs() throws GendersException;

/**
Expand Down
11 changes: 1 addition & 10 deletions src/libgenders/genders.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ _initialize_handle_info(genders_t handle)
handle->flags = GENDERS_FLAG_DEFAULT;
handle->numnodes = 0;
handle->numattrs = 0;
handle->maxattrs = 0;
handle->maxnodelen = 0;
handle->maxattrlen = 0;
handle->maxvallen = 0;
Expand Down Expand Up @@ -187,7 +186,6 @@ genders_load_data(genders_t handle, const char *filename)
if (_genders_open_and_parse(handle,
filename,
&handle->numattrs,
&handle->maxattrs,
&handle->maxnodelen,
&handle->maxattrlen,
&handle->maxvallen,
Expand Down Expand Up @@ -341,11 +339,7 @@ genders_getnumattrs(genders_t handle)
int
genders_getmaxattrs(genders_t handle)
{
if (_genders_loaded_handle_error_check(handle) < 0)
return -1;

handle->errnum = GENDERS_ERR_SUCCESS;
return handle->maxattrs;
return genders_getnumattrs(handle);
}

int
Expand Down Expand Up @@ -1169,7 +1163,6 @@ genders_parse(genders_t handle, const char *filename, FILE *stream)
{
int errcount, rv = -1;
int debugnumattrs = 0;
int debugmaxattrs = 0;
int debugmaxnodelen = 0;
int debugmaxattrlen = 0;
int debugmaxvallen = 0;
Expand Down Expand Up @@ -1204,7 +1197,6 @@ genders_parse(genders_t handle, const char *filename, FILE *stream)
if ((errcount = _genders_open_and_parse(handle,
filename,
&debugnumattrs,
&debugmaxattrs,
&debugmaxnodelen,
&debugmaxattrlen,
&debugmaxvallen,
Expand Down Expand Up @@ -1579,7 +1571,6 @@ genders_copy(genders_t handle)
handlecopy->flags = handle->flags;
handlecopy->numnodes = handle->numnodes;
handlecopy->numattrs = handle->numattrs;
handlecopy->maxattrs = handle->maxattrs;
handlecopy->maxnodelen = handle->maxnodelen;
handlecopy->maxattrlen = handle->maxattrlen;
handlecopy->maxvallen = handle->maxvallen;
Expand Down
11 changes: 2 additions & 9 deletions src/libgenders/genders.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,8 @@ int genders_getnumnodes(genders_t handle);
*/
int genders_getnumattrs(genders_t handle);

/*
* genders_getmaxattrs
*
* Get the max number of attributes read of any one node in the
* genders file.
*
* Returns number of attributes on success, -1 on failure
*/
int genders_getmaxattrs(genders_t handle);
/* deprecated - calls genders_getnumattrs() */
int genders_getmaxattrs(genders_t handle) __attribute__((deprecated));

/*
* genders_getmaxnodelen
Expand Down
2 changes: 0 additions & 2 deletions src/libgenders/genders_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ typedef struct genders_attrvals_container *genders_attrvals_container_t;
* is_loaded = 1
* numnodes = 3
* numattrs = 6
* maxattrs = 4
* maxnodelen = 9
* maxattrlen = 5
* maxvallen = 4
Expand Down Expand Up @@ -160,7 +159,6 @@ struct genders {
unsigned int flags; /* flags for alternate behavior */
int numnodes; /* number of nodes */
int numattrs; /* number of attrs */
int maxattrs; /* max attrs for any one node */
int maxnodelen; /* max node name length */
int maxattrlen; /* max attr name length */
int maxvallen; /* max value name length */
Expand Down
4 changes: 0 additions & 4 deletions src/libgenders/genders_parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ strsep (char **stringp, const char *delim)
static int
_parse_line(genders_t handle,
int *numattrs,
int *maxattrs,
int *maxnodelen,
int *maxattrlen,
int *maxvallen,
Expand Down Expand Up @@ -570,7 +569,6 @@ _parse_line(genders_t handle,

if (!line_num)
{
(*maxattrs) = GENDERS_MAX(n->attrcount, (*maxattrs));
(*maxnodelen) = GENDERS_MAX(strlen(node), (*maxnodelen));
line_maxnodelen = GENDERS_MAX(strlen(node), line_maxnodelen);
}
Expand Down Expand Up @@ -608,7 +606,6 @@ int
_genders_open_and_parse(genders_t handle,
const char *filename,
int *numattrs,
int *maxattrs,
int *maxnodelen,
int *maxattrlen,
int *maxvallen,
Expand Down Expand Up @@ -652,7 +649,6 @@ _genders_open_and_parse(genders_t handle,

if ((bug_count = _parse_line(handle,
numattrs,
maxattrs,
maxnodelen,
maxattrlen,
maxvallen,
Expand Down
1 change: 0 additions & 1 deletion src/libgenders/genders_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
int _genders_open_and_parse(genders_t handle,
const char *filename,
int *numattrs,
int *maxattrs,
int *maxnodelen,
int *maxattrlen,
int *maxvallen,
Expand Down
6 changes: 3 additions & 3 deletions src/testsuite/libgenders/genders_test_database.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ genders_database_data_t genders_database_data_test_2 =
"val2",
4,
8,
4,
8, /* maxattrs deprecated, same as numattrs */
5,
5,
4,
Expand Down Expand Up @@ -746,7 +746,7 @@ genders_database_data_t genders_database_data_test_3 =
"val2",
4,
16,
4,
16, /* maxattrs deprecated, same as numattrs */
5,
6,
5,
Expand Down Expand Up @@ -967,7 +967,7 @@ genders_database_data_t genders_database_data_test_4 =
"val2",
8,
8,
4,
8, /* maxattrs deprecated, same as numattrs */
5,
5,
4,
Expand Down

0 comments on commit 79283a9

Please sign in to comment.