2008-11-02 01:01:35 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2009-01-31 10:33:39 -08:00
|
|
|
#include <stdlib.h>
|
2010-04-05 01:26:48 -07:00
|
|
|
|
2012-11-18 22:26:48 -08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2010-04-05 01:26:48 -07:00
|
|
|
# include <unistd.h>
|
2012-11-18 22:26:48 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
2010-04-05 01:38:11 -07:00
|
|
|
# include <process.h>
|
2010-04-05 01:26:48 -07:00
|
|
|
#endif
|
2009-01-31 10:33:39 -08:00
|
|
|
|
2008-11-02 01:01:35 -08:00
|
|
|
#ifdef HAVE_EVIL
|
|
|
|
# include <Evil.h>
|
|
|
|
#endif
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#include "Ecore.h"
|
2009-12-22 13:15:12 -08:00
|
|
|
#include "ecore_private.h"
|
2003-09-23 01:09:32 -07:00
|
|
|
|
|
|
|
static int app_argc = 0;
|
|
|
|
static char **app_argv = NULL;
|
|
|
|
|
2010-10-17 00:03:28 -07:00
|
|
|
/**
|
2011-08-10 12:14:48 -07:00
|
|
|
* @addtogroup Ecore_Application_Group
|
2010-10-17 00:03:28 -07:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
|
|
|
* Set up the programs command-line arguments.
|
|
|
|
* @param argc The same as passed as argc to the programs main() function
|
|
|
|
* @param argv The same as passed as argv to the programs main() function
|
2008-11-29 03:23:17 -08:00
|
|
|
*
|
2003-09-23 01:09:32 -07:00
|
|
|
* A call to this function will store the programs command-line arguments
|
|
|
|
* for later use by ecore_app_restart() or ecore_app_args_get().
|
|
|
|
*/
|
2006-01-06 09:58:12 -08:00
|
|
|
EAPI void
|
2011-10-20 22:40:39 -07:00
|
|
|
ecore_app_args_set(int argc,
|
|
|
|
const char **argv)
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2011-08-09 01:50:47 -07:00
|
|
|
EINA_MAIN_LOOP_CHECK_RETURN;
|
2011-07-05 04:13:29 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
if ((argc < 1) ||
|
|
|
|
(!argv)) return;
|
|
|
|
app_argc = argc;
|
|
|
|
app_argv = (char **)argv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the programs stored command-line arguments.
|
|
|
|
* @param argc A pointer to the return value to hold argc
|
|
|
|
* @param argv A pointer to the return value to hold argv
|
2008-11-29 03:23:17 -08:00
|
|
|
*
|
2003-09-23 01:09:32 -07:00
|
|
|
* When called, this funciton returns the arguments for the program stored by
|
|
|
|
* ecore_app_args_set(). The integer pointed to by @p argc will be filled, if
|
|
|
|
* the pointer is not NULL, and the string array pointer @p argv will be filled
|
|
|
|
* also if the pointer is not NULL. The values they are filled with will be the
|
|
|
|
* same set by ecore_app_args_set().
|
|
|
|
*/
|
2006-01-06 09:58:12 -08:00
|
|
|
EAPI void
|
2011-10-20 22:40:39 -07:00
|
|
|
ecore_app_args_get(int *argc,
|
|
|
|
char ***argv)
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2011-08-09 01:50:47 -07:00
|
|
|
EINA_MAIN_LOOP_CHECK_RETURN;
|
2011-07-05 04:13:29 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
if (argc) *argc = app_argc;
|
|
|
|
if (argv) *argv = app_argv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restart the program executable with the command-line arguments stored.
|
2008-11-29 03:23:17 -08:00
|
|
|
*
|
2003-09-23 01:09:32 -07:00
|
|
|
* This function will restart & re-execute this program in place of itself
|
|
|
|
* using the command-line arguments stored by ecore_app_args_set(). This is
|
|
|
|
* an easy way for a program to restart itself for cleanup purposes,
|
|
|
|
* configuration reasons or in the event of a crash.
|
|
|
|
*/
|
2006-01-06 09:58:12 -08:00
|
|
|
EAPI void
|
2003-09-23 01:09:32 -07:00
|
|
|
ecore_app_restart(void)
|
|
|
|
{
|
2012-03-29 01:52:25 -07:00
|
|
|
EINA_MAIN_LOOP_CHECK_RETURN;
|
2011-09-18 14:57:47 -07:00
|
|
|
#ifdef HAVE_EXECVP
|
2006-08-20 01:16:34 -07:00
|
|
|
char *args[4096];
|
2004-11-24 20:07:54 -08:00
|
|
|
int i;
|
2008-11-29 03:23:17 -08:00
|
|
|
|
2004-11-24 20:07:54 -08:00
|
|
|
if ((app_argc < 1) || (!app_argv)) return;
|
2006-08-20 01:16:34 -07:00
|
|
|
if (app_argc >= 4096) return;
|
2004-11-24 20:07:54 -08:00
|
|
|
for (i = 0; i < app_argc; i++) args[i] = app_argv[i];
|
|
|
|
args[i] = NULL;
|
|
|
|
execvp(app_argv[0], args);
|
2011-09-18 14:57:47 -07:00
|
|
|
#endif
|
2003-09-23 01:09:32 -07:00
|
|
|
}
|
2010-10-17 00:03:28 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|