Example #1
0
int main(int argc, char **argv){
	static struct app app; 
	
	// first thing is to fork off all services
	if(app_load_services(&app, UBUS_SERVICE_ROOT) != 0){
		fprintf(stderr, "***** ERROR ***** there were errors while loading lua services!\n"); 
		//app_destroy(&app); 
		//return -1; 
	}

	app_init(&app); 
	if(app_connect_to_ubus(&app, NULL) != 0){
		DEBUG("failed to connect to ubus!\n"); 
		return -1; 
	}
	
	if(app_load_scripts(&app, UBUS_ROOT) != 0){ 
		fprintf(stderr, "***** ERROR ******* there were errors while loading ubus scripts\n"); 
		fprintf(stderr, "***** some ubus rpc call may not be available!\n"); 
		//app_destroy(&app); 
		//return -1; 
	}

	app_run(&app); 
	
	app_destroy(&app); 

	return 0; 
}
Example #2
0
void system_run(void)
{	
	// Inicjacja wyprowadzeñ
	DDR(LCD_CTRLPORT) = (1<<LCD_E | 1<<LCD_RW | 1<<LCD_RS | 1<<LCD_LED); 
	PORT(LCD_CTRLPORT) = ~(1<<LCD_E | 1<<LCD_LED); 
	PORT(SW_PORT) = 1<<SW1 | 1<<SW2;
	// Inicjacja wyœwietlacza
	lcd_Init();
	lcd_SetStatus(LCD_STATUS_DISP);
	// Inicjacja timera systemowego
	TCCR2 = 1<<WGM21 /*CTC*/ | 1<<CS22 | 1<<CS21 | 1<<CS20 /*clk:1024*/;
	OCR2 = 78; // oko³o 10ms
	
	// Przerwania
	TIMSK = 1<<OCIE2 /*porównania z timera 2*/;
	sei();

	// Wyœwietlenie zapytania o jêzyk
	fputs_P(PSTR("S1 - "), lcd_GetFile());
	fputs_P(langsys_GetLangName(0), lcd_GetFile());
	lcd_GoTo(0, 1);
	fputs_P(PSTR("S2 - "), lcd_GetFile());
	fputs_P(langsys_GetLangName(1), lcd_GetFile());
	lcd_Update();
	
	// Oczekiwanie na przycisk 
	
	
	// Wywo³anie aplikacji
	app_run();
}
Example #3
0
void main()
{
	app_init();
	
	app_run();
	
	app_Exit();
}
Example #4
0
/* this is the main function of the service. when this function returns the
 * service will be terminated by the SCM */
void WINAPI ServiceMain(DWORD argc, PTSTR *argv)
{
    SERVICE_STATUS *pSt = &ctx->status;

    /* register the service with the ServiceControlManager */
    ctx->hServiceStatus = RegisterServiceCtrlHandlerEx(ss_name, HandlerEx, ctx);
    dbg_err_if( ctx->hServiceStatus == 0 );

    /* init the status struct and update the service status */
    ZeroMemory(pSt, sizeof(SERVICE_STATUS));
    /* just one service in this exe */
    pSt->dwServiceType = SERVICE_WIN32_OWN_PROCESS; 
    /* action supported by the service */
    pSt->dwControlsAccepted = SERVICE_ACCEPT_STOP;
    /* error returned while starting/stopping */
    pSt->dwWin32ExitCode = NO_ERROR;          
    /* service specific exit code */
    pSt->dwServiceSpecificExitCode = 0;          
    /* we're still initializing */
    pSt->dwCurrentState = SERVICE_START_PENDING;
    /* for progress operation */
    pSt->dwCheckPoint = 1;
    /* wait hint */
    pSt->dwWaitHint = 1000;
    /* set status */
    dbg_err_if(SetServiceStatus(ctx->hServiceStatus, pSt) == 0);

    dbg_err_if(parse_opt(argc, argv));

    /* load config and initialize */
    dbg_err_if(app_init());

    /* this should happen after initialization but I don't want to
       mess main.c with win32-only code */

    /* notify the end of initialization */
    u_dbg("SERVICE_RUNNING");
    ctx->status.dwCurrentState = SERVICE_RUNNING;
    ctx->status.dwCheckPoint = ctx->status.dwWaitHint = 0;    
    dbg_err_if(!SetServiceStatus(ctx->hServiceStatus, &ctx->status));

    /* run the main loop */
    app_run();

    /* let the service terminate */
    ctx->status.dwCurrentState = SERVICE_STOPPED;
    dbg_err_if(!SetServiceStatus(ctx->hServiceStatus, &ctx->status));

    return;

err:
    warn_strerror(GetLastError());

    /* let the service terminate */
    ctx->status.dwCurrentState = SERVICE_STOPPED;
    dbg_err_if(!SetServiceStatus(ctx->hServiceStatus, &ctx->status));
}
Example #5
0
static void  heartbeat_handler(struct timer *ts){
    // restart timer
    run_loop_set_timer(ts, HEARTBEAT_PERIOD_MS);
    run_loop_add_timer(ts);

    counter++;
    update_client = 1;
    app_run();
} 
Example #6
0
int main()
{
	app_init();

	app_run();

	app_exit();

	return 0;
}
Example #7
0
static void
run_tui(void)
{
    struct app *app = app_alloc();
    
    struct result result = app_run(app);
    if (!result_is_success(result)) {
        result_print_error(result);
    }
    
    app_free(app);
}
int
main(int argc, char **argv)
{
   struct app_data data;

   if (app_init(&data, argc, argv)) {
      app_run(&data);
      app_fini(&data);
   }

   return 0;
}
Example #9
0
File: main.c Project: HARM67/Fdf
int	main(int ac, char **av)
{
	t_app	app;

	if (ac < 2)
		put_error();
	ft_bzero(&app, sizeof(t_app));
	app.ac = ac;
	app.av = av;
	app_init(&app);
	app_run(&app);
	return (0);
}
Example #10
0
int main(int argc, char **argv)
{
    setlinebuf(stdout);

    g_thread_init(NULL);

    app_t *app = (app_t*) calloc(1, sizeof(app_t));
    app->lcm = bot_lcm_get_global(NULL);
    app->ptr = new KinectPointCloudPub(argc, argv);

    app_run(app);
    app_destroy(app);

    return 0;
}
Example #11
0
int main(int argc, char **argv)
{
    int rc = 0;

    memset(ctx, 0, sizeof(context_t));

    /* parse command line parameters (and set ctx vars) */
    dbg_err_if(parse_opt(argc, argv));

    if(getenv("GATEWAY_INTERFACE"))
        ctx->cgi = 1;
        
    /* load config and initialize */
    warn_err_ifm(app_init(), "kloned init error (more info in the log file)");

#ifdef HAVE_FORK
    /* daemonize if not -F */
    if(ctx->daemon && !ctx->cgi)
        con_err_ifm(daemon(ctx->nochdir, 0), "daemon error");
#endif  /* HAVE_FORK */

    /* save the PID in a file */
    if(ctx->pid_file)
        dbg_err_if(u_savepid(ctx->pid_file));

    /* jump to the main loop */
    rc = app_run();

    dbg_err_if(app_term());

    /* if debugging then call exit(3) because it's needed to gprof to dump 
       its stats file (gmon.out) */
    if(ctx->debug)
        return rc;

    /* don't use return because exit(3) will be called and we don't want
       FILE* buffers to be automatically flushed (klog_file_t will write same 
       lines more times, once by the parent process and N times by any child
       created when FILE buffer was not empty) */
    _exit(rc);
err:
    app_term();
    if(ctx->debug)
        return ~0;
    _exit(EXIT_FAILURE);
}
Example #12
0
int
main(int argc, char *argv[])
{
    App *app;
    int ret = EXIT_FAILURE;

    if (argc == 1) {
        print_help(argv[0]);
        return EXIT_SUCCESS;
    }

    app = app_new();
    if (!app || !app_parse_options(app, argc, argv) || !app_run(app))
        goto cleanup;
    ret = EXIT_SUCCESS;

cleanup:
    app_free(app);
    return ret;
}
int
main (int argc, char *argv[])
{
  App *app;
  gint ret;

  if (!video_output_init (&argc, argv, g_options))
    g_error ("failed to initialize video output subsystem");

  app = app_new ();
  if (!app)
    g_error ("failed to create application context");

  ret = !app_run (app, argc, argv);

  app_free (app);
  g_free (g_codec_str);
  video_output_exit ();
  return ret;
}
Example #14
0
int main (int argc, char **argv)
{
    gtk_init (&argc, &argv);

    app_params_t params = {
        .foo = 1,
        .bar = NULL,
        .filename = NULL
    };

    GOptionEntry options[] = 
    {
        { "foo", 'f', 0, G_OPTION_ARG_INT, &params.foo, 
            "Example int parameter", "F" },
        { "bar", 'b', 0, G_OPTION_ARG_STRING, &params.filename, 
            "Example filename parameter", "B" },
        { NULL }
    };

    GError *opt_error = NULL;
    GOptionContext *opt_parser;

    opt_parser = g_option_context_new (" - BotGtkGlImageArea tester");
    g_option_context_add_main_entries (opt_parser, options, NULL);
    g_option_context_parse (opt_parser, &argc, &argv, &opt_error);
    g_option_context_free (opt_parser);

    if (argc < 2) {
        fprintf (stderr, "must specify filename\n");
        return 0;
    }
    params.filename = strdup (argv[1]);

    app_t *app = app_create (&params);
    if (app) {
        app_run (app);
        app_destroy (app);
    }

    return 0;
}
Example #15
0
int main(int argc, char **argv)
{
    if (argc != 6) {
        fprintf(stderr,
                "usage: %s poolname imagename username password monitor\n",
                argv[0]);
        return -1;
    }

    poolname = argv[1];
    imagename = argv[2];
    username = argv[3];
    password = argv[4];
    monitor = argv[5];

    if (app_rbd_open() == 0) {
        app_run();
        app_rbd_close();        
    }

    return 0;
}
int
main (int argc, char *argv[])
{
  App *app;
  int ret = EXIT_FAILURE;
  gchar *input_fn;

  if (!parse_options (&argc, argv))
    return EXIT_FAILURE;

  /* @TODO: iterate all the input files */
  input_fn = g_input_files ? g_input_files[0] : NULL;
  if (input_fn && !g_file_test (input_fn,
          G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
    g_warning ("input file \"%s\" doesn't exist", input_fn);
    goto bail;
  }

  app = app_new (input_fn, g_output_file_name);
  if (!app)
    goto bail;

  print_yuv_info (app);
  ret = app_run (app);
  print_num_frame (app);

  app_free (app);

bail:
  g_free (g_codec_str);
  g_free (g_output_file_name);
  g_strfreev (g_input_files);

  gst_deinit ();

  return ret;
}
Example #17
0
int main(int argc, char* argv[]) {
	if( argc < 2 ) {
		exit_usage(argv[0]);
	}

	int bit_rate = 0,
		fps = 60,
		port = 8080,
		width = 0,
		height = 0;

	// Parse command line options
	for( int i = 1; i < argc-1; i+=2 ) {
		if( strlen(argv[i]) < 2 || i >= argc-2 || argv[i][0] != '-' ) {
			exit_usage(argv[0]);
		}

		switch( argv[i][1] ) {
			case 'b': bit_rate = atoi(argv[i+1]) * 1000; break;
			case 'p': port = atoi(argv[i+1]); break;
			case 's': sscanf(argv[i+1], "%dx%d", &width, &height); break;
			case 'f': fps = atoi(argv[i+1]); break;
			default: exit_usage(argv[0]);
		}
	}

	// Find target window
	char *window_title = argv[argc-1];
	HWND window = NULL;
	if( strcmp(window_title, "desktop") == 0 ) {
		window = GetDesktopWindow();
	}
	else if( strcmp(window_title, "cursor") == 0 ) {
		POINT cursor;
		GetCursorPos(&cursor);
		window = WindowFromPoint(cursor);
	}
	else {
		window = window_with_prefix(window_title);
	}

	if( !window ) {
		printf("No window with title starting with \"%s\"\n", window_title);
		return 0;
	}

	// Start the app
	app_t *app = app_create(window, port, bit_rate, width, height);

	char real_window_title[56];
	GetWindowTextA(window, real_window_title, sizeof(real_window_title));
	printf(
		"Window 0x%08x: \"%s\"\n"
		"Window size: %dx%d, output size: %dx%d, bit rate: %d kb/s\n\n"
		"Server started on: http://%s:%d/\n\n",
		window, real_window_title,
		app->grabber->width, app->grabber->height,
		app->encoder->out_width, app->encoder->out_height,
		app->encoder->context->bit_rate / 1000,
		server_get_host_address(app->server), app->server->port
	);

	app_run(app, fps);

	app_destroy(app);	

	return 0;
}
Example #18
0
File: main.c Project: mardy/gimb
int
main (int    argc,
      char **argv)
{
  GOptionContext *context;
  GError         *error = NULL;
  const gchar    *abort_message;
  gchar          *basename;
  gint            i;

#if defined (__GNUC__) && defined (_WIN64)
  /* mingw-w64, at least the unstable build from late July 2008,
   * starts subsystem:windows programs in main(), but passes them
   * bogus argc and argv. __argc and __argv are OK, though, so just
   * use them.
   */
  argc = __argc;
  argv = __argv;
#endif

#ifdef G_OS_WIN32
  /* Reduce risks */
  {
    typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
    t_SetDllDirectoryA p_SetDllDirectoryA;

    p_SetDllDirectoryA = GetProcAddress (GetModuleHandle ("kernel32.dll"),
					 "SetDllDirectoryA");
    if (p_SetDllDirectoryA)
      (*p_SetDllDirectoryA) ("");
  }
#ifndef _WIN64
  {
    typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
    t_SetProcessDEPPolicy p_SetProcessDEPPolicy;

    p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"),
					    "SetProcessDEPPolicy");
    if (p_SetProcessDEPPolicy)
      (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
  }
#endif
#endif

#ifdef GIMP_UNSTABLE
  gimp_open_console_window ();
#endif

  gimp_init_malloc ();

  gimp_env_init (FALSE);

  gimp_log_init ();

  gimp_init_i18n ();

  g_set_application_name (GIMP_NAME);

  basename = g_path_get_basename (argv[0]);
  g_set_prgname (basename);
  g_free (basename);

  /* Check argv[] for "--verbose" first */
  for (i = 1; i < argc; i++)
    {
      const gchar *arg = argv[i];

      if (arg[0] != '-')
        continue;

      if ((strcmp (arg, "--verbose") == 0) || (strcmp (arg, "-v") == 0))
        {
          be_verbose = TRUE;
        }
    }

  /* Check argv[] for "--no-interface" before trying to initialize gtk+. */
  for (i = 1; i < argc; i++)
    {
      const gchar *arg = argv[i];

      if (arg[0] != '-')
        continue;

      if ((strcmp (arg, "--no-interface") == 0) || (strcmp (arg, "-i") == 0))
        {
          no_interface = TRUE;
        }
      else if ((strcmp (arg, "--version") == 0) || (strcmp (arg, "-v") == 0))
        {
          gimp_show_version_and_exit ();
        }
#if defined (G_OS_WIN32) && !defined (GIMP_CONSOLE_COMPILATION)
      else if ((strcmp (arg, "--help") == 0) ||
               (strcmp (arg, "-?") == 0) ||
               (strncmp (arg, "--help-", 7) == 0))
        {
          gimp_open_console_window ();
        }
#endif
    }

#ifdef GIMP_CONSOLE_COMPILATION
  no_interface = TRUE;
#endif

  context = g_option_context_new (_("[FILE|URI...]"));
  g_option_context_set_summary (context, GIMP_NAME);

  g_option_context_add_main_entries (context, main_entries, GETTEXT_PACKAGE);

  app_libs_init (context, no_interface);

  if (! g_option_context_parse (context, &argc, &argv, &error))
    {
      if (error)
        {
          gimp_open_console_window ();
          g_print ("%s\n", error->message);
          g_error_free (error);
        }
      else
        {
          g_print ("%s\n",
                   _("GIMP could not initialize the graphical user interface.\n"
                     "Make sure a proper setup for your display environment "
                     "exists."));
        }

      app_exit (EXIT_FAILURE);
    }

  if (no_interface || be_verbose || console_messages || batch_commands != NULL)
    gimp_open_console_window ();

  if (no_interface)
    new_instance = TRUE;

#ifndef GIMP_CONSOLE_COMPILATION
  if (! new_instance && gimp_unique_open (filenames, as_new))
    {
      if (be_verbose)
	g_print ("%s\n",
		 _("Another GIMP instance is already running."));

      gdk_notify_startup_complete ();

      return EXIT_SUCCESS;
    }
#endif

  abort_message = sanity_check ();
  if (abort_message)
    app_abort (no_interface, abort_message);

  gimp_init_signal_handlers (stack_trace_mode);

  app_run (argv[0],
           filenames,
           system_gimprc,
           user_gimprc,
           session_name,
           batch_interpreter,
           batch_commands,
           as_new,
           no_interface,
           no_data,
           no_fonts,
           no_splash,
           be_verbose,
           use_shm,
           use_cpu_accel,
           console_messages,
           use_debug_handler,
           stack_trace_mode,
           pdb_compat_mode);

  g_option_context_free (context);

  return EXIT_SUCCESS;
}
Example #19
0
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, 
    LPSTR lpCmdLine, int nCmdShow)
{
    SERVICE_TABLE_ENTRY ServiceTable[] = 
    {
        {   ss_name, ServiceMain }, 
        {   NULL, NULL }    /* end of list */
    };
    int rc = 0;
    const char *name, *desc;

    memset(ctx, 0, sizeof(context_t));

    /* parse command line parameters (and set ctx vars). NOTE: this work only 
       if launched by command line, for services see ServiceMain */
    dbg_err_if(parse_opt(__argc, __argv));

    if(ctx->serv_op)
    {
        /* load config and initialize */
        dbg_err_if(app_init());

        /* set up service name and description reading from the config file */
        name = u_config_get_subkey_value(ctx->config, "daemon.name");
        if(name)
            u_strlcpy(ss_name, name, sizeof ss_name);

        desc = u_config_get_subkey_value(ctx->config, "daemon.description");
        if(desc)
            u_strlcpy(ss_desc, desc, sizeof ss_desc);

        if(ctx->serv_op == SERV_INSTALL)
            dbg_err_if(InstallService());
        else    
            dbg_err_if(RemoveService());
    } else if(ctx->daemon) {
        u_dbg("Starting in service mode...");
        /* StartServiceCtrlDispatcher does not return until the service 
           has stopped running...  */
        if(!StartServiceCtrlDispatcher(ServiceTable))
            warn_strerror(GetLastError());
    } else {
        /* load config and initialize */
        dbg_err_if(app_init());

        rc = app_run();
    }

    dbg_err_if(app_term());

    /* if debugging then call exit(3) because it's needed to gprof to dump 
       its stats file (gmon.out) */
    if(ctx->debug)
        return rc;

    /* don't use return because exit(3) will be called and we don't want
       FILE* buffers to be automatically flushed (klog_file_t will write same 
       lines more times, once by the parent process and N times by any child
       created when FILE buffer was not empty) */
    _exit(rc); 
err:
    app_term();

    if(ctx->debug) 
        return rc;
    _exit(EXIT_FAILURE);
}
Example #20
0
int
main (int    argc,
      char **argv)
{
  GOptionContext *context;
  GError         *error = NULL;
  const gchar    *abort_message;
  gchar          *basename;
  GFile          *system_gimprc_file = NULL;
  GFile          *user_gimprc_file   = NULL;
  gint            i;

#if defined (__GNUC__) && defined (_WIN64)
  /* mingw-w64, at least the unstable build from late July 2008,
   * starts subsystem:windows programs in main(), but passes them
   * bogus argc and argv. __argc and __argv are OK, though, so just
   * use them.
   */
  argc = __argc;
  argv = __argv;
#endif

#ifdef G_OS_WIN32
  /* Reduce risks */
  {
    typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
    t_SetDllDirectoryA p_SetDllDirectoryA;

    p_SetDllDirectoryA =
      (t_SetDllDirectoryA) GetProcAddress (GetModuleHandle ("kernel32.dll"),
                                           "SetDllDirectoryA");
    if (p_SetDllDirectoryA)
      (*p_SetDllDirectoryA) ("");
  }

  /* On Windows, set DLL search path to $INSTALLDIR/bin so that .exe
     plug-ins in the plug-ins directory can find libgimp and file
     library DLLs without needing to set external PATH. */
  {
    const gchar *install_dir;
    gchar       *bin_dir;
    LPWSTR       w_bin_dir;
    int          n;

    w_bin_dir = NULL;
    install_dir = gimp_installation_directory ();
    bin_dir = g_build_filename (install_dir, "bin", NULL);

    n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
                             bin_dir, -1, NULL, 0);
    if (n == 0)
      goto out;

    w_bin_dir = g_malloc_n (n + 1, sizeof (wchar_t));
    n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
                             bin_dir, -1,
                             w_bin_dir, (n + 1) * sizeof (wchar_t));
    if (n == 0)
      goto out;

    SetDllDirectoryW (w_bin_dir);

  out:
    if (w_bin_dir)
      g_free (w_bin_dir);
    g_free (bin_dir);
  }

#ifdef HAVE_EXCHNDL
  /* Use Dr. Mingw (dumps backtrace on crash) if it is available. */
  {
    time_t t;
    gchar *filename;
    gchar *dir;
    gchar *path;

    /* This has to be the non-roaming directory (i.e., the local
       directory) as backtraces correspond to the binaries on this
       system. */
    dir = g_build_filename (g_get_user_data_dir (),
                            GIMPDIR, GIMP_USER_VERSION, "CrashLog",
                            NULL);
    /* Ensure the path exists. */
    g_mkdir_with_parents (dir, 0700);

    time (&t);
    filename = g_strdup_printf ("%s-crash-%" G_GUINT64_FORMAT ".txt",
                                g_get_prgname(), t);
    path = g_build_filename (dir, filename, NULL);
    g_free (filename);
    g_free (dir);

    ExcHndlInit ();
    ExcHndlSetLogFileNameA (path);

    g_free (path);
  }
#endif

#ifndef _WIN64
  {
    typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
    t_SetProcessDEPPolicy p_SetProcessDEPPolicy;

    p_SetProcessDEPPolicy =
      (t_SetProcessDEPPolicy) GetProcAddress (GetModuleHandle ("kernel32.dll"),
                                              "SetProcessDEPPolicy");
    if (p_SetProcessDEPPolicy)
      (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
  }
#endif

  /* Group all our windows together on the taskbar */
  {
    typedef HRESULT (WINAPI *t_SetCurrentProcessExplicitAppUserModelID) (PCWSTR lpPathName);
    t_SetCurrentProcessExplicitAppUserModelID p_SetCurrentProcessExplicitAppUserModelID;

    p_SetCurrentProcessExplicitAppUserModelID =
      (t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandle ("shell32.dll"),
                                                                  "SetCurrentProcessExplicitAppUserModelID");
    if (p_SetCurrentProcessExplicitAppUserModelID)
      (*p_SetCurrentProcessExplicitAppUserModelID) (L"gimp.GimpApplication");
  }
#endif

#ifdef GIMP_UNSTABLE
  gimp_open_console_window ();
#endif

  gimp_init_malloc ();

  gimp_env_init (FALSE);

  gimp_log_init ();

  gimp_init_i18n ();

  g_set_application_name (GIMP_NAME);

#ifdef G_OS_WIN32
  argv = g_win32_get_command_line ();
#else
  argv = g_strdupv (argv);
#endif

  basename = g_path_get_basename (argv[0]);
  g_set_prgname (basename);
  g_free (basename);

  /* Check argv[] for "--verbose" first */
  for (i = 1; i < argc; i++)
    {
      const gchar *arg = argv[i];

      if (arg[0] != '-')
        continue;

      if ((strcmp (arg, "--verbose") == 0) || (strcmp (arg, "-v") == 0))
        {
          be_verbose = TRUE;
        }
    }

  /* Check argv[] for "--no-interface" before trying to initialize gtk+. */
  for (i = 1; i < argc; i++)
    {
      const gchar *arg = argv[i];

      if (arg[0] != '-')
        continue;

      if ((strcmp (arg, "--no-interface") == 0) || (strcmp (arg, "-i") == 0))
        {
          no_interface = TRUE;
        }
      else if ((strcmp (arg, "--version") == 0) || (strcmp (arg, "-v") == 0))
        {
          gimp_show_version_and_exit ();
        }
#if defined (G_OS_WIN32) && !defined (GIMP_CONSOLE_COMPILATION)
      else if ((strcmp (arg, "--help") == 0) ||
               (strcmp (arg, "-?") == 0) ||
               (strncmp (arg, "--help-", 7) == 0))
        {
          gimp_open_console_window ();
        }
#endif
    }

#ifdef GIMP_CONSOLE_COMPILATION
  no_interface = TRUE;
#endif

  context = g_option_context_new (_("[FILE|URI...]"));
  g_option_context_set_summary (context, GIMP_NAME);

  g_option_context_add_main_entries (context, main_entries, GETTEXT_PACKAGE);

  app_libs_init (context, no_interface);

  if (! g_option_context_parse_strv (context, &argv, &error))
    {
      if (error)
        {
          gimp_open_console_window ();
          g_print ("%s\n", error->message);
          g_error_free (error);
        }
      else
        {
          g_print ("%s\n",
                   _("GIMP could not initialize the graphical user interface.\n"
                     "Make sure a proper setup for your display environment "
                     "exists."));
        }

      app_exit (EXIT_FAILURE);
    }

  if (no_interface || be_verbose || console_messages || batch_commands != NULL)
    gimp_open_console_window ();

  if (no_interface)
    new_instance = TRUE;

#ifndef GIMP_CONSOLE_COMPILATION
  if (! new_instance && gimp_unique_open (filenames, as_new))
    {
      if (be_verbose)
        g_print ("%s\n",
                 _("Another GIMP instance is already running."));

      if (batch_commands)
        gimp_unique_batch_run (batch_interpreter, batch_commands);

      gdk_notify_startup_complete ();

      return EXIT_SUCCESS;
    }
#endif

  abort_message = sanity_check ();
  if (abort_message)
    app_abort (no_interface, abort_message);

  gimp_init_signal_handlers (stack_trace_mode);

  if (system_gimprc)
    system_gimprc_file = g_file_new_for_commandline_arg (system_gimprc);

  if (user_gimprc)
    user_gimprc_file = g_file_new_for_commandline_arg (user_gimprc);

  app_run (argv[0],
           filenames,
           system_gimprc_file,
           user_gimprc_file,
           session_name,
           batch_interpreter,
           batch_commands,
           as_new,
           no_interface,
           no_data,
           no_fonts,
           no_splash,
           be_verbose,
           use_shm,
           use_cpu_accel,
           console_messages,
           use_debug_handler,
           show_playground,
           stack_trace_mode,
           pdb_compat_mode);

  if (system_gimprc_file)
    g_object_unref (system_gimprc_file);

  if (user_gimprc_file)
    g_object_unref (user_gimprc_file);

  g_strfreev (argv);

  g_option_context_free (context);

  return EXIT_SUCCESS;
}
Example #21
0
int main() {
    board_init();
    app_run();
    return 0;
}
Example #22
0
int main(void)
{
	app_init();
	for (;;) app_run();
}