lib/, src/: str2*(): Rename functions and reorder parameters

This makes them compatible with liba2i's functions.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-01-16 21:38:24 +01:00
committed by Serge Hallyn
parent b085c3f612
commit f39ac101ff
19 changed files with 69 additions and 71 deletions

View File

@@ -171,14 +171,14 @@ static int new_fields (void)
SNPRINTF(buf, "%ld", mindays);
change_field (buf, sizeof buf, _("Minimum Password Age"));
if ( (getlong(buf, &mindays) == -1)
if ( (str2sl(&mindays, buf) == -1)
|| (mindays < -1)) {
return 0;
}
SNPRINTF(buf, "%ld", maxdays);
change_field (buf, sizeof buf, _("Maximum Password Age"));
if ( (getlong(buf, &maxdays) == -1)
if ( (str2sl(&maxdays, buf) == -1)
|| (maxdays < -1)) {
return 0;
}
@@ -201,14 +201,14 @@ static int new_fields (void)
SNPRINTF(buf, "%ld", warndays);
change_field (buf, sizeof buf, _("Password Expiration Warning"));
if ( (getlong(buf, &warndays) == -1)
if ( (str2sl(&warndays, buf) == -1)
|| (warndays < -1)) {
return 0;
}
SNPRINTF(buf, "%ld", inactdays);
change_field (buf, sizeof buf, _("Password Inactive"));
if ( (getlong(buf, &inactdays) == -1)
if ( (str2sl(&inactdays, buf) == -1)
|| (inactdays < -1)) {
return 0;
}
@@ -397,7 +397,7 @@ static void process_flags (int argc, char **argv)
break;
case 'I':
Iflg = true;
if ( (getlong(optarg, &inactdays) == -1)
if ( (str2sl(&inactdays, optarg) == -1)
|| (inactdays < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
@@ -410,7 +410,7 @@ static void process_flags (int argc, char **argv)
break;
case 'm':
mflg = true;
if ( (getlong(optarg, &mindays) == -1)
if ( (str2sl(&mindays, optarg) == -1)
|| (mindays < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
@@ -420,7 +420,7 @@ static void process_flags (int argc, char **argv)
break;
case 'M':
Mflg = true;
if ( (getlong(optarg, &maxdays) == -1)
if ( (str2sl(&maxdays, optarg) == -1)
|| (maxdays < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
@@ -434,7 +434,7 @@ static void process_flags (int argc, char **argv)
break;
case 'W':
Wflg = true;
if ( (getlong(optarg, &warndays) == -1)
if ( (str2sl(&warndays, optarg) == -1)
|| (warndays < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),

View File

@@ -198,19 +198,19 @@ static void process_flags (int argc, char **argv)
}
#if defined(USE_SHA_CRYPT)
if ( ( ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512")))
&& (-1 == getlong(optarg, &sha_rounds)))) {
&& (-1 == str2sl(&sha_rounds, optarg)))) {
bad_s = 1;
}
#endif /* USE_SHA_CRYPT */
#if defined(USE_BCRYPT)
if (( (0 == strcmp (crypt_method, "BCRYPT"))
&& (-1 == getlong(optarg, &bcrypt_rounds)))) {
&& (-1 == str2sl(&bcrypt_rounds, optarg)))) {
bad_s = 1;
}
#endif /* USE_BCRYPT */
#if defined(USE_YESCRYPT)
if (( (0 == strcmp (crypt_method, "YESCRYPT"))
&& (-1 == getlong(optarg, &yescrypt_cost)))) {
&& (-1 == str2sl(&yescrypt_cost, optarg)))) {
bad_s = 1;
}
#endif /* USE_YESCRYPT */

View File

@@ -193,19 +193,19 @@ static void process_flags (int argc, char **argv)
bad_s = 0;
#if defined(USE_SHA_CRYPT)
if ((IS_CRYPT_METHOD("SHA256") || IS_CRYPT_METHOD("SHA512"))
&& (-1 == getlong(optarg, &sha_rounds))) {
&& (-1 == str2sl(&sha_rounds, optarg))) {
bad_s = 1;
}
#endif /* USE_SHA_CRYPT */
#if defined(USE_BCRYPT)
if (IS_CRYPT_METHOD("BCRYPT")
&& (-1 == getlong(optarg, &bcrypt_rounds))) {
&& (-1 == str2sl(&bcrypt_rounds, optarg))) {
bad_s = 1;
}
#endif /* USE_BCRYPT */
#if defined(USE_YESCRYPT)
if (IS_CRYPT_METHOD("YESCRYPT")
&& (-1 == getlong(optarg, &yescrypt_cost))) {
&& (-1 == str2sl(&yescrypt_cost, optarg))) {
bad_s = 1;
}
#endif /* USE_YESCRYPT */

View File

@@ -547,7 +547,7 @@ int main (int argc, char **argv)
usage (E_SUCCESS);
/*@notreached@*/break;
case 'l':
if (getlong(optarg, &fail_locktime) == -1) {
if (str2sl(&fail_locktime, optarg) == -1) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);
@@ -559,7 +559,7 @@ int main (int argc, char **argv)
{
long lmax;
if ( (getlong(optarg, &lmax) == -1)
if ( (str2sl(&lmax, optarg) == -1)
|| ((long)(short) lmax != lmax)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
@@ -576,7 +576,7 @@ int main (int argc, char **argv)
case 'R': /* no-op, handled in process_root_flag () */
break;
case 't':
if (getlong(optarg, &days) == -1) {
if (str2sl(&days, optarg) == -1) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);

View File

@@ -328,7 +328,7 @@ int main (int argc, char **argv)
case 'b':
{
unsigned long inverse_days;
if (getulong(optarg, &inverse_days) == -1) {
if (str2ul(&inverse_days, optarg) == -1) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);
@@ -356,7 +356,7 @@ int main (int argc, char **argv)
case 't':
{
unsigned long days;
if (getulong(optarg, &days) == -1) {
if (str2ul(&days, optarg) == -1) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);

View File

@@ -674,19 +674,19 @@ static void process_flags (int argc, char **argv)
}
#if defined(USE_SHA_CRYPT)
if ( ( ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512")))
&& (-1 == getlong(optarg, &sha_rounds)))) {
&& (-1 == str2sl(&sha_rounds, optarg)))) {
bad_s = 1;
}
#endif /* USE_SHA_CRYPT */
#if defined(USE_BCRYPT)
if (( (0 == strcmp (crypt_method, "BCRYPT"))
&& (-1 == getlong(optarg, &bcrypt_rounds)))) {
&& (-1 == str2sl(&bcrypt_rounds, optarg)))) {
bad_s = 1;
}
#endif /* USE_BCRYPT */
#if defined(USE_YESCRYPT)
if (( (0 == strcmp (crypt_method, "YESCRYPT"))
&& (-1 == getlong(optarg, &yescrypt_cost)))) {
&& (-1 == str2sl(&yescrypt_cost, optarg)))) {
bad_s = 1;
}
#endif /* USE_YESCRYPT */

View File

@@ -801,7 +801,7 @@ int main (int argc, char **argv)
usage (E_SUCCESS);
/*@notreached@*/break;
case 'i':
if ( (getlong(optarg, &inact) == -1)
if ( (str2sl(&inact, optarg) == -1)
|| (inact < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
@@ -820,7 +820,7 @@ int main (int argc, char **argv)
anyflag = true;
break;
case 'n':
if ( (getlong(optarg, &age_min) == -1)
if ( (str2sl(&age_min, optarg) == -1)
|| (age_min < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
@@ -855,7 +855,7 @@ int main (int argc, char **argv)
anyflag = true;
break;
case 'w':
if ( (getlong(optarg, &warn) == -1)
if ( (str2sl(&warn, optarg) == -1)
|| (warn < -1)) {
(void) fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
@@ -866,7 +866,7 @@ int main (int argc, char **argv)
anyflag = true;
break;
case 'x':
if ( (getlong(optarg, &age_max) == -1)
if ( (str2sl(&age_max, optarg) == -1)
|| (age_max < -1)) {
(void) fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),

View File

@@ -416,7 +416,7 @@ static void get_defaults (void)
* Default Password Inactive value
*/
else if (MATCH (buf, DINACT)) {
if ( (getlong(ccp, &def_inactive) == -1)
if ( (str2sl(&def_inactive, ccp) == -1)
|| (def_inactive < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
@@ -1302,7 +1302,7 @@ static void process_flags (int argc, char **argv)
eflg = true;
break;
case 'f':
if ( (getlong(optarg, &def_inactive) == -1)
if ( (str2sl(&def_inactive, optarg) == -1)
|| (def_inactive < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),

View File

@@ -1062,7 +1062,7 @@ static void process_flags (int argc, char **argv)
eflg = true;
break;
case 'f':
if ( (getlong(optarg, &user_newinactive) == -1)
if ( (str2sl(&user_newinactive, optarg) == -1)
|| (user_newinactive < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),