Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: E.h actions.c main.c mod-misc.c Log Message: Refactor/simplify, use execApplication in stead of plain fork/exec. =================================================================== RCS file: /cvs/e/e16/e/src/E.h,v retrieving revision 1.564 retrieving revision 1.565 diff -u -3 -r1.564 -r1.565 --- E.h 28 Aug 2006 22:46:22 -0000 1.564 +++ E.h 10 Sep 2006 14:29:04 -0000 1.565 @@ -553,7 +553,8 @@ int ActionsEnd(EWin * ewin); void About(void); -int execApplication(const char *params); +#define EXEC_SET_LANG 0x01 +int execApplication(const char *params, int flags); void Espawn(int argc, char **argv); void EspawnCmd(const char *cmd); =================================================================== RCS file: /cvs/e/e16/e/src/actions.c,v retrieving revision 1.207 retrieving revision 1.208 diff -u -3 -r1.207 -r1.208 --- actions.c 22 Aug 2006 19:23:36 -0000 1.207 +++ actions.c 10 Sep 2006 14:29:04 -0000 1.208 @@ -26,141 +26,130 @@ #include "file.h" #include "user.h" -static void -runApp(const char *exe, const char *params) +int +execApplication(const char *params, int flags) { + char exe[FILEPATH_LEN_MAX]; char *sh; char *path; char *real_exec; int fd; + if (!params) + return -1; + + sscanf(params, "%4000s", exe); + if (exe[0] == '\0') + return -1; + if (fork()) - return; + return 0; setsid(); /* Close all file descriptors except the std 3 */ for (fd = 3; fd < 1024; fd++) close(fd); - LangExport(); + /* Set up env stuff */ + if (flags & EXEC_SET_LANG) + LangExport(); sh = usershell(getuid()); - if (exe) + + path = pathtoexec(exe); + if (path) + { + Efree(path); + + real_exec = Emalloc(strlen(params) + 6); + if (!real_exec) + return -1; + sprintf(real_exec, "exec %s", params); + + execl(sh, sh, "-c", real_exec, NULL); + /* We should not get here - invalid shell? */ + } + + if (!Mode.wm.startup) { - path = pathtoexec(exe); - if (path) + path = pathtofile(exe); + if (!path) { - Efree(path); - real_exec = Emalloc(strlen(params) + 6); - if (!real_exec) - return; - sprintf(real_exec, "exec %s", params); - execl(sh, sh, "-c", real_exec, NULL); - exit(0); + /* absolute path */ + if (isabspath(exe)) + DialogAlertOK(_ + ("There was an error running the program:\n" + "%s\n" + "This program could not be executed.\n" + "This is because the file does not exist.\n"), + exe); + /* relative path */ + else + DialogAlertOK(_ + ("There was an error running the program:\n" + "%s\n" + "This program could not be executed.\n" + "This is most probably because this " + "program is not in the\n" + "path for your shell which is %s. " + "I suggest you read the manual\n" + "page for that shell and read up how to " + "change or add to your\n" + "execution path.\n"), exe, sh); } - - if (!Mode.wm.startup) + else + /* it is a node on the filing sys */ { - path = pathtofile(exe); - if (!path) + /* it's a file */ + if (isfile(path)) { - /* absolute path */ - if (isabspath(exe)) + /* can execute it */ + if (canexec(path)) DialogAlertOK(_ ("There was an error running the program:\n" "%s\n" "This program could not be executed.\n" - "This is because the file does not exist.\n"), - exe); - /* relative path */ + "I am unsure as to why you could not " + "do this. The file exists,\n" + "is a file, and you are allowed to " + "execute it. I suggest you look\n" + "into this.\n"), path); + /* not executable file */ else DialogAlertOK(_ ("There was an error running the program:\n" "%s\n" "This program could not be executed.\n" - "This is most probably because this " - "program is not in the\n" - "path for your shell which is %s. " - "I suggest you read the manual\n" - "page for that shell and read up how to " - "change or add to your\n" - "execution path.\n"), exe, sh); + "This is because the file exists, is a " + "file, but you are unable\n" + "to execute it because you do not " + "have execute " + "access to this file.\n"), path); } + /* it's not a file */ else - /* it is a node on the filing sys */ { - /* it's a file */ - if (isfile(path)) - { - /* can execute it */ - if (canexec(path)) - DialogAlertOK(_ - ("There was an error running the program:\n" - "%s\n" - "This program could not be executed.\n" - "I am unsure as to why you could not " - "do this. The file exists,\n" - "is a file, and you are allowed to " - "execute it. I suggest you look\n" - "into this.\n"), path); - /* not executable file */ - else - DialogAlertOK(_ - ("There was an error running the program:\n" - "%s\n" - "This program could not be executed.\n" - "This is because the file exists, is a " - "file, but you are unable\n" - "to execute it because you do not " - "have execute " - "access to this file.\n"), path); - } - /* it's not a file */ + /* its a dir */ + if (isdir(path)) + DialogAlertOK(_ + ("There was an error running the program:\n" + "%s\n" + "This program could not be executed.\n" + "This is because the file is in fact " + "a directory.\n"), path); + /* its not a file or a dir */ else - { - /* its a dir */ - if (isdir(path)) - DialogAlertOK(_ - ("There was an error running the program:\n" - "%s\n" - "This program could not be executed.\n" - "This is because the file is in fact " - "a directory.\n"), path); - /* its not a file or a dir */ - else - DialogAlertOK(_ - ("There was an error running the program:\n" - "%s\n" - "This program could not be executed.\n" - "This is because the file is not a " - "regular file.\n"), path); - } - Efree(path); + DialogAlertOK(_ + ("There was an error running the program:\n" + "%s\n" + "This program could not be executed.\n" + "This is because the file is not a " + "regular file.\n"), path); } + Efree(path); } - exit(100); } - real_exec = Emalloc(strlen(params) + 6); - if (!real_exec) - return; - sprintf(real_exec, "exec %s", params); - execl(sh, sh, "-c", real_exec, NULL); - exit(0); -} - -int -execApplication(const char *params) -{ - char exe[FILEPATH_LEN_MAX]; - const char *s = params; - - if (!s) - return -1; - - sscanf(s, "%4000s", exe); - runApp(exe, s); - - return 0; + exit(100); } void =================================================================== RCS file: /cvs/e/e16/e/src/main.c,v retrieving revision 1.150 retrieving revision 1.151 diff -u -3 -r1.150 -r1.151 --- main.c 24 Jul 2006 21:10:58 -0000 1.150 +++ main.c 10 Sep 2006 14:29:05 -0000 1.151 @@ -443,39 +443,26 @@ static void RunDocBrowser(void) { - char file[FILEPATH_LEN_MAX]; + char buf[FILEPATH_LEN_MAX]; - Esnprintf(file, sizeof(file), "%s/edox", EDirBin()); - if (!canexec(file)) + Esnprintf(buf, sizeof(buf), "%s/edox", EDirBin()); + if (!canexec(buf)) return; - Esnprintf(file, sizeof(file), "%s/E-docs", EDirRoot()); - if (!canread(file)) + Esnprintf(buf, sizeof(buf), "%s/E-docs", EDirRoot()); + if (!canread(buf)) return; - if (fork()) - return; - - Esnprintf(file, sizeof(file), "exec %s/edox %s/E-docs", - EDirBin(), EDirRoot()); - - execl(usershell(getuid()), usershell(getuid()), "-c", (char *)file, NULL); - - exit(0); + Esnprintf(buf, sizeof(buf), "%s/edox %s/E-docs", EDirBin(), EDirRoot()); + execApplication(buf, 0); } static void RunMenuGen(void) { - char file[FILEPATH_LEN_MAX]; - - if (fork()) - return; - - LangExport(); + char buf[FILEPATH_LEN_MAX]; - Esnprintf(file, sizeof(file), "exec %s/scripts/e_gen_menu", EDirRoot()); - execl(usershell(getuid()), usershell(getuid()), "-c", (char *)file, NULL); - exit(0); + Esnprintf(buf, sizeof(buf), "%s/scripts/e_gen_menu", EDirRoot()); + execApplication(buf, EXEC_SET_LANG); } static void =================================================================== RCS file: /cvs/e/e16/e/src/mod-misc.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -3 -r1.43 -r1.44 --- mod-misc.c 24 Aug 2006 20:33:46 -0000 1.43 +++ mod-misc.c 10 Sep 2006 14:29:05 -0000 1.44 @@ -173,7 +173,7 @@ MiscIpcExec(const char *params, Client * c __UNUSED__) { if (params) - execApplication(params); + execApplication(params, EXEC_SET_LANG); else IpcPrintf("exec what?\n"); } ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs