X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/7d57ffc92fe378f7a445a841609adba86bcef0b3..dc4d0c4bf247cfc88e1f3f9463fa2264d3d226b5:/uip/install-mh.c diff --git a/uip/install-mh.c b/uip/install-mh.c index 414a4877..f059296a 100644 --- a/uip/install-mh.c +++ b/uip/install-mh.c @@ -6,10 +6,12 @@ */ #include /* mh internals */ +#include "h/done.h" #include -#include "../sbr/m_maildir.h" -#include "../sbr/makedir.h" +#include "sbr/m_maildir.h" +#include "sbr/makedir.h" #include /* structure for getpwuid() results */ +#include "sbr/read_line.h" #define INSTALLMH_SWITCHES \ X("auto", 0, AUTOSW) \ @@ -29,7 +31,7 @@ DEFINE_SWITCH_ARRAY(INSTALLMH, switches); int main (int argc, char **argv) { - int autof = 0; + bool autof = false; char *cp, buf[BUFSIZ]; const char *pathname; char *dp, **arguments, **argp; @@ -37,14 +39,14 @@ main (int argc, char **argv) struct passwd *pw; struct stat st; FILE *in, *out; - int check; + bool check; - if (nmh_init(argv[0], 0 /* use context_foil() */ )) { return 1; } + if (nmh_init(argv[0], false, false)) { return 1; } arguments = getarguments (invo_name, argc, argv, 0); argp = arguments; - check = 0; + check = false; while ((dp = *argp++)) { if (*dp == '-') { @@ -53,7 +55,7 @@ main (int argc, char **argv) ambigsw (dp, switches); done (1); case UNKWNSW: - adios (NULL, "-%s unknown\n", dp); + die("-%s unknown\n", dp); case HELPSW: snprintf (buf, sizeof(buf), "%s [switches]", invo_name); @@ -64,15 +66,15 @@ main (int argc, char **argv) done (0); case AUTOSW: - autof++; + autof = true; continue; case CHECKSW: - check = 1; + check = true; continue; } } else { - adios (NULL, "%s is invalid argument", dp); + die("%s is invalid argument", dp); } } @@ -83,7 +85,7 @@ main (int argc, char **argv) if ((mypath = getenv("HOME")) == NULL) { if ((pw = getpwuid(getuid())) == NULL || *pw->pw_dir == '\0') - adios(NULL, "cannot determine your home directory"); + die("cannot determine your home directory"); mypath = pw->pw_dir; } @@ -109,8 +111,8 @@ main (int argc, char **argv) if (check) done(0); if (autof) - adios (NULL, "invocation error"); - adios (NULL, "You already have an nmh profile, use an editor to modify it"); + die("invocation error"); + die("You already have an nmh profile, use an editor to modify it"); } if (check) done(1); @@ -151,7 +153,7 @@ query: pathname = read_line (); if (pathname == NULL) done (1); } else { - printf ("What is the whole path? /"); + fputs("What is the whole path? /", stdout); pathname = read_line (); if (pathname == NULL) done (1); pathname = concat ("/", pathname, NULL); @@ -166,7 +168,7 @@ query: cp = concat ("\"", pathname, "\" doesn't exist; Create it? ", NULL); if (autof || read_switch (cp, anoyes)) if (makedir (pathname) == 0) - adios (NULL, "unable to create %s", pathname); + die("unable to create %s", pathname); } else { puts("[Using existing directory]"); } @@ -190,7 +192,7 @@ query: fclose (in); } - ctxpath = getcpy (m_maildir (context = "context")); + ctxpath = mh_xstrdup(m_maildir(context = "context")); /* Initialize current folder to default */ context_replace (pfolder, defaultfolder); @@ -214,8 +216,8 @@ query: } fclose (out); - puts ("\nPlease see the nmh(7) man page for an introduction to nmh.\n"); - print_intro (stdout, FALSE); + puts ("\nPlease see nmh(7) for an introduction to nmh.\n"); + print_intro (stdout, false); /* Initialize the saved nmh version. The Path profile entry was added above, that's all this needs. */