- if (gans ("Do you want a path below your login directory? ",
- anoyes)) {
- printf ("What is the path? %s/", mypath);
- path = geta ();
- } else {
- printf ("What is the whole path? /");
- path = concat ("/", geta (), NULL);
- }
+ if (gans("Do you want a path below your login directory? ", anoyes)) {
+ printf("What is the path? %s/", mypath);
+ pathname = geta();
+ } else {
+ printf("What is the whole path? /");
+ pathname = concat("/", geta(), NULL);
+ }
+ }
+ }
+
+ chdir(mypath);
+ if (chdir(pathname) == NOTOK) {
+ cp = concat("\"", pathname, "\" doesn't exist; Create it? ",
+ NULL);
+ if (autof || gans(cp, anoyes))
+ if (makedir(pathname) == 0)
+ adios(NULL, "unable to create %s", pathname);
+ } else {
+ printf("[Using existing directory]\n");
+ }
+
+ /*
+ ** Add some initial elements to the profile/context list
+ */
+ m_defs = (struct node *) mh_xmalloc(sizeof *np);
+ np = m_defs;
+ np->n_name = getcpy("Path");
+ np->n_field = getcpy(pathname);
+ np->n_context = 0;
+ np->n_next = NULL;
+
+ /*
+ ** If there is a default profile file in the
+ ** nmh `etc' directory, then read it also.
+ */
+ if ((in = fopen(mh_defaults, "r"))) {
+ readconfig(&np->n_next, in, mh_defaults, 0);
+ fclose(in);
+ }
+
+ ctxpath = getcpy(m_maildir(context = "context"));
+
+ /* Initialize current folder to default */
+ context_replace(pfolder, defaultfolder);
+ context_save();
+
+ /*
+ ** Now write out the initial .mh_profile
+ */
+ if ((out = fopen(defpath, "w")) == NULL)
+ adios(defpath, "unable to write");
+ for (np = m_defs; np; np = np->n_next) {
+ if (!np->n_context)
+ fprintf(out, "%s: %s\n", np->n_name, np->n_field);