]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
chfn, chsh, setpwnam: get true/false from stdbool.h
authorSami Kerola <kerolasa@iki.fi>
Sun, 13 Nov 2011 16:36:55 +0000 (17:36 +0100)
committerSami Kerola <kerolasa@iki.fi>
Wed, 23 Nov 2011 20:50:17 +0000 (21:50 +0100)
Requires C99, which should not be a problem.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/chfn.c
login-utils/chsh.c
login-utils/setpwnam.c

index f2f5148334e4e07c68082bb82ae30961e802619c..1ddd5864bf617c64107ffc49b882f369517a1675 100644 (file)
@@ -32,6 +32,7 @@
 #include <errno.h>
 #include <ctype.h>
 #include <getopt.h>
+#include <stdbool.h>
 
 #include "islocal.h"
 #include "setpwnam.h"
 
 #endif /* REQUIRE_PASSWORD */
 
-typedef unsigned char boolean;
-#define false 0
-#define true 1
-
 static char buf[1024];
 
 struct finfo {
@@ -78,12 +75,12 @@ struct finfo {
     char *other;
 };
 
-static boolean parse_argv (int argc, char *argv[], struct finfo *pinfo);
+static int parse_argv (int argc, char *argv[], struct finfo *pinfo);
 static void parse_passwd (struct passwd *pw, struct finfo *pinfo);
 static void ask_info (struct finfo *oldfp, struct finfo *newfp);
 static char *prompt (char *question, char *def_val);
 static int check_gecos_string (char *msg, char *gecos);
-static boolean set_changed_data (struct finfo *oldfp, struct finfo *newfp);
+static int set_changed_data (struct finfo *oldfp, struct finfo *newfp);
 static int save_new_data (struct finfo *pinfo);
 
 /* we do not accept gecos field sizes longer than MAX_FIELD_SIZE */
@@ -108,7 +105,7 @@ static void __attribute__((__noreturn__)) usage(FILE *fp)
 int main (int argc, char **argv) {
     uid_t uid;
     struct finfo oldf, newf;
-    boolean interactive;
+    int interactive;
     int status;
 
     sanitize_env();
@@ -217,10 +214,10 @@ int main (int argc, char **argv) {
  *     parse the command line arguments.
  *     returns true if no information beyond the username was given.
  */
-static boolean parse_argv(int argc, char *argv[], struct finfo *pinfo)
+static int parse_argv(int argc, char *argv[], struct finfo *pinfo)
 {
     int index, c, status;
-    boolean info_given;
+    int info_given;
 
     static struct option long_options[] = {
        { "full-name",    required_argument, 0, 'f' },
@@ -403,9 +400,9 @@ static int check_gecos_string(char *msg, char *gecos)
  *  set_changed_data () --
  *     incorporate the new data into the old finger info.
  */
-static boolean set_changed_data(struct finfo *oldfp, struct finfo *newfp)
+static int set_changed_data(struct finfo *oldfp, struct finfo *newfp)
 {
-    boolean changed = false;
+    int changed = false;
 
     if (newfp->full_name) {
        oldfp->full_name = newfp->full_name; changed = true; }
index f84baba542fa4622c06008cef970610d993319dd..043022ee6e73202b2e6198f14009be6d33513e52 100644 (file)
@@ -31,6 +31,7 @@
 #include <errno.h>
 #include <ctype.h>
 #include <getopt.h>
+#include <stdbool.h>
 
 #include "c.h"
 #include "islocal.h"
 #include "selinux_utils.h"
 #endif
 
-typedef unsigned char boolean;
-#define false 0
-#define true 1
-
 /* Only root is allowed to assign a luser a non-listed shell, by default */
 #define ONLY_LISTED_SHELLS 1
 
@@ -76,7 +73,7 @@ struct sinfo {
 static void parse_argv (int argc, char *argv[], struct sinfo *pinfo);
 static char *prompt (char *question, char *def_val);
 static int check_shell (char *shell);
-static boolean get_shell_list (char *shell);
+static int get_shell_list (char *shell);
 
 static void __attribute__((__noreturn__)) usage (FILE *fp)
 {
@@ -345,10 +342,10 @@ check_shell (char *shell) {
  *     return true.  if not, return false.
  *     if the given shell is NULL, /etc/shells is outputted to stdout.
  */
-static boolean
+static int
 get_shell_list (char *shell_name) {
     FILE *fp;
-    boolean found;
+    int found;
     int len;
     char buf[PATH_MAX];
 
index c1e6efb17b1d057897057ee722f1434a0993fbeb..9299ffa831839e9a4d9f6588be334f32ad3671e5 100644 (file)
 #include <sys/resource.h>
 #include <sys/stat.h>
 #include <paths.h>
+#include <stdbool.h>
 
 #include "setpwnam.h"
 #include "c.h"
 
-#define false 0
-#define true 1
-
-typedef int boolean;
-
 static void pw_init(void);
 
 /*
@@ -83,7 +79,7 @@ setpwnam (struct passwd *pwd)
 {
     FILE *fp = NULL, *pwf = NULL;
     int x, save_errno, fd, ret;
-    boolean found;
+    int found;
     int oldumask;
     int namelen;
     int buflen = 256;