Commit b8c2da9d b8c2da9dab90d25fab6c44c3474ab990eec0e36a by Sergey Poznyakoff

Added util_get_homedir() and util_fullpath().

1 parent 72a44d34
...@@ -234,14 +234,24 @@ util_do_command (const char *c, ...) ...@@ -234,14 +234,24 @@ util_do_command (const char *c, ...)
234 if (vasprintf (&cmd, c, ap) < 1) 234 if (vasprintf (&cmd, c, ap) < 1)
235 return 0; 235 return 0;
236 236
237 if (cmd[0] == '#')
238 return 0;
239
240 if (cmd) 237 if (cmd)
241 { 238 {
239 struct mail_command_entry entry;
240
241 if (cmd[0] == '#')
242 return 0;
243
242 if (argcv_get (cmd, &argc, &argv) != 0) 244 if (argcv_get (cmd, &argc, &argv) != 0)
243 return argcv_free (argc, argv); 245 return argcv_free (argc, argv);
244 command = util_command_get (argv[0]); 246
247 entry = util_find_entry (argv[0]);
248
249 if (if_cond() == 0 && entry.isflow == 0)
250 {
251 argcv_free (argc, argv);
252 return 0;
253 }
254 command = entry.func;
245 } 255 }
246 else 256 else
247 command = util_command_get ("quit"); 257 command = util_command_get ("quit");
...@@ -537,3 +547,24 @@ readline (const char *prompt) ...@@ -537,3 +547,24 @@ readline (const char *prompt)
537 } 547 }
538 } 548 }
539 #endif 549 #endif
550
551 char *
552 util_get_homedir()
553 {
554 char *homedir = mu_get_homedir();
555 if (!homedir)
556 {
557 /* Shouldn't happen, but one never knows */
558 fprintf(ofile, "can't get homedir\n");
559 exit (EXIT_FAILURE);
560 }
561 return strdup(homedir);
562 }
563
564 char *
565 util_fullpath(char *inpath)
566 {
567 return mu_tilde_expansion(inpath, "/", NULL);
568 }
569
570
......