コード例 #1
0
ファイル: xchat.c プロジェクト: BackupTheBerlios/vertigo
int
main (int argc, char *argv[])
{

#ifdef SOCKS
	SOCKSinit (argv[0]);
#endif

	if (!fe_args (argc, argv))
		return 0;

	load_config ();

	fe_init ();

	xchat_init ();

	fe_main ();

#ifdef USE_OPENSSL
	if (ctx)
		_SSL_context_free (ctx);
#endif

#ifdef USE_DEBUG
	xchat_mem_list ();
#endif

#ifdef WIN32
	WSACleanup ();
#endif

	return 0;
}
コード例 #2
0
ファイル: xchat.c プロジェクト: ArdaXi/XChat
int
main (int argc, char *argv[])
{
	int ret;
	
	srand (time (0));	/* CL: do this only once! */

#ifdef SOCKS
	SOCKSinit (argv[0]);
#endif

	ret = fe_args (argc, argv);
	if (ret != -1)
		return ret;
	
#ifdef USE_DBUS
	xchat_remote ();
#endif

	load_config ();

#ifdef USE_LIBPROXY
	libproxy_factory = px_proxy_factory_new();
#endif

	fe_init ();

	xchat_init ();

	fe_main ();

#ifdef USE_LIBPROXY
	px_proxy_factory_free(libproxy_factory);
#endif

#ifdef USE_OPENSSL
	if (ctx)
		_SSL_context_free (ctx);
#endif

#ifdef USE_DEBUG
	xchat_mem_list ();
#endif

#ifdef WIN32
	WSACleanup ();
#endif

	return 0;
}
コード例 #3
0
ファイル: xchat.c プロジェクト: arinity/gchat2
int
main (int argc, char *argv[])
{
	int ret;

	g_thread_init(NULL);
	mowgli_init();

#ifdef _WIN32
	conspire_init_winsock();
#endif

#ifdef GNUTLS
	gnutls_global_init ();
#endif

	srand (time (0));	/* CL: do this only once! */

#ifdef SOCKS
	SOCKSinit (argv[0]);
#endif

	ret = fe_args (argc, argv);
	if (ret != -1)
		return ret;

	load_config ();

	fe_init ();

	xchat_init ();

	fe_main ();

#ifdef GNUTLS
	gnutls_global_deinit ();
#endif

#ifdef USE_DEBUG
	xchat_mem_list ();
#endif

	return 0;
}
コード例 #4
0
ファイル: xchat.c プロジェクト: arinity/gchat
int
main (int argc, char *argv[])
{
    int ret;

    srand (time (0));           /* CL: do this only once! */

#ifdef SOCKS
    SOCKSinit (argv[0]);
#endif

    ret = fe_args (argc, argv);
    if (ret != -1)
        return ret;

#ifdef USE_DBUS
    xchat_remote ();
#endif

    load_config ();

    fe_init ();

    xchat_init ();

    fe_main ();

#ifdef USE_OPENSSL
    if (ctx)
        _SSL_context_free (ctx);
#endif

#ifdef USE_DEBUG
    xchat_mem_list ();
#endif

    return 0;
}
コード例 #5
0
ファイル: hexchat.c プロジェクト: GalliumOS/hexchat
int
main (int argc, char *argv[])
{
	int i;
	int ret;

	srand (time (0));	/* CL: do this only once! */

	/* We must check for the config dir parameter, otherwise load_config() will behave incorrectly.
	 * load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to
	 * know the language which is set in the config. The code below is copy-pasted from fe_args()
	 * for the most part. */
	if (argc >= 3)
	{
		for (i = 1; i < argc - 1; i++)
		{
			if (strcmp (argv[i], "-d") == 0)
			{
				if (xdir)
				{
					g_free (xdir);
				}

				xdir = strdup (argv[i + 1]);

				if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
				{
					xdir[strlen (xdir) - 1] = 0;
				}
			}
		}
	}

#if ! GLIB_CHECK_VERSION (2, 36, 0)
	g_type_init ();
#endif

	if (check_config_dir () == 0)
	{
		if (load_config () != 0)
			load_default_config ();
	} else
	{
		/* this is probably the first run */
		load_default_config ();
		make_config_dirs ();
		make_dcc_dirs ();
	}

	/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
	set_locale ();

#ifdef SOCKS
	SOCKSinit (argv[0]);
#endif

	ret = fe_args (argc, argv);
	if (ret != -1)
		return ret;
	
#ifdef USE_DBUS
	hexchat_remote ();
#endif

#ifdef USE_LIBPROXY
	libproxy_factory = px_proxy_factory_new();
#endif

	fe_init ();

	/* This is done here because cfgfiles.c is too early in
	* the startup process to use gtk functions. */
	if (g_access (get_xdir (), W_OK) != 0)
	{
		char buf[2048];

		g_snprintf (buf, sizeof(buf),
			_("You do not have write access to %s. Nothing from this session can be saved."),
			get_xdir ());
		fe_message (buf, FE_MSG_ERROR);
	}

#ifndef WIN32
#ifndef __EMX__
	/* OS/2 uses UID 0 all the time */
	if (getuid () == 0)
		fe_message (_("* Running IRC as root is stupid! You should\n"
			      "  create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT);
#endif
#endif /* !WIN32 */

	xchat_init ();

	fe_main ();

#ifdef USE_LIBPROXY
	px_proxy_factory_free(libproxy_factory);
#endif

#ifdef WIN32
	WSACleanup ();
#endif

	return 0;
}
コード例 #6
0
ファイル: xchats.c プロジェクト: abrauchli/allnet
int main (int argc, char ** argv)
{
  log_to_output (get_option ('v', &argc, argv));
  if (argc < 2) {
    printf ("usage: %s contact-name [message]\n", argv [0]);
    printf ("   or: %s -k contact-name [hops [secret]] (hops defaults to 1)\n",
            argv [0]);
    return 1;
  }

  int sock = xchat_init (argv [0]);
  if (sock < 0)
    return 1;

  int ack_expected = 0;
  long long int seq = 0;
  char * contact = argv [1];  /* contact we send to, peer we receive from */

  char * kcontact = NULL;
  char * my_secret = NULL;
  char * peer_secret = NULL;
#define MAX_SECRET	15  /* including a terminating null character */
  char my_secret_buf [MAX_SECRET];
  char peer_secret_buf [200];
  int kmax_hops = 0;
  int wait_time = 5000;   /* 5 seconds to wait for acks and such */

  if (strcmp (contact, "-k") == 0) {   /* send a key */
    if ((argc != 3) && (argc != 4) && (argc != 5)) {
      printf ("usage: %s -k contact-name [hops [secret]] (%d)\n",
              argv [0], argc);
      return 1;
    }
    kcontact = argv [2];
    int hops = 1;
    if (argc >= 4) {
      char * end;
      int n = strtol (argv [3], &end, 10);
      if (end != argv [3])
        hops = n;
    }
    random_string (my_secret_buf, MAX_SECRET);
    if (hops <= 1)
      my_secret_buf [6] = '\0';   /* for direct contacts, truncate to 6 chars */
    printf ("%d hops, my secret string is '%s'", hops, my_secret_buf);
    normalize_secret (my_secret_buf);
    printf (" (or %s)\n", my_secret_buf);
    my_secret = my_secret_buf;
    if (argc >= 5) {
      snprintf (peer_secret_buf, sizeof (peer_secret_buf), "%s", argv [4]);
      printf ("peer secret string is '%s'", peer_secret_buf);
      normalize_secret (peer_secret_buf);
      printf (" (or %s)\n", peer_secret_buf);
      peer_secret = peer_secret_buf;
    }
    kmax_hops = hops;
    wait_time = 10 * 60 * 1000;   /* wait up to 10 minutes for a key */
    char * send_secret = my_secret;
    if (! create_contact_send_key (sock, kcontact, send_secret,
                                   peer_secret, hops))
      return 1;
  } else { /* send the data packet */
    int i;
    keyset * keys;
    int nkeys = all_keys (contact, &keys);
    if ((argc > 2) && (nkeys > 0)) {
      int max_key = 0;
      for (i = 0; i < nkeys; i++) {
        allnet_rsa_prvkey key;
        int ksize = get_my_privkey (keys [i], &key);
        if (ksize > max_key)
          max_key = ksize;
      }
      static char text [ALLNET_MTU];
      int size = sizeof (text) - CHAT_DESCRIPTOR_SIZE -
                 ALLNET_SIZE (ALLNET_TRANSPORT_ACK_REQ) -
                 max_key; /* the maximum size of a signature */
      char * p = text;
      int printed = 0;
      for (i = 2; i < argc; i++) {
        int n = snprintf (p, size, "%s%s", argv [i], (i + 1 < argc) ? " " : "");
        printed += n;
        p += n;
        size -= n;
      }
  /*  printf ("sending %d chars: '%s'\n", printed, text); */
      seq = send_data_message (sock, contact, text, printed);
      ack_expected = 1;
    } else if (nkeys == 0) {
      printf ("error: no keys for contact '%s'\n", contact);
    } else if (nkeys < 0) {
      printf ("error: contact '%s' does not exist\n", contact);
    }
  }

  struct timeval start, deadline;
  gettimeofday (&start, NULL);
  gettimeofday (&deadline, NULL);
  add_time (&deadline, wait_time);
  int max_wait = until_deadline (&deadline);
  int ack_seen = 0;
  while (max_wait > 0) {
    char * packet;
    int pipe, pri;
    int found = receive_pipe_message_any (max_wait, &packet, &pipe, &pri);
    if (found < 0) {
      printf ("xchats pipe closed, exiting\n");
      exit (1);
    }
    int verified, duplicate, broadcast;
    char * desc;
    char * message;
    char * peer = NULL;
    keyset kset = -1;
    int mlen = handle_packet (sock, packet, found, &peer, &kset,
                              &message, &desc, &verified, NULL, &duplicate,
                              &broadcast, kcontact, my_secret, peer_secret,
                              kmax_hops, NULL, NULL, 0);
    if (mlen > 0) {
      char * ver_mess = "";
      if (! verified)
        ver_mess = " (not verified)";
      char * dup_mess = "";
      if (duplicate)
        dup_mess = "duplicate ";
      char * bc_mess = "";
      if (broadcast) {
        bc_mess = "broacast ";
        dup_mess = "";
        desc = "";
      }
      printf ("from '%s'%s got %s%s%s\n  %s\n", peer, ver_mess, dup_mess, 
              bc_mess, desc, message);
    } else if (mlen == -1) {  /* successful key exchange */
      printf ("success!  got remote key for %s\n", kcontact);
      gettimeofday (&deadline, NULL);
      add_time (&deadline, 5000);  /* wait 5 more seconds */
    }
  /* handle_packet may change what has been acked */
    if ((ack_expected) && (! ack_seen) && (is_acked (contact, seq))) {
      struct timeval finish;
      gettimeofday (&finish, NULL);   /* how long did the ack take? */
      long long int delta = (finish.tv_sec  - start.tv_sec ) * 1000000LL +
                            (finish.tv_usec - start.tv_usec);
      printf ("got ack from %s in %lld.%06llds\n", contact,
              delta / 1000000, delta % 1000000);

      gettimeofday (&deadline, NULL); /* wait another second from now */
      add_time (&deadline, 1000);     /* for additional messages */
      ack_seen = 1;
    }
    if (mlen > 0) {
      free (peer);
      free (message);
      if (! broadcast)
        free (desc);
    }
    max_wait = until_deadline (&deadline);
  }
  return 0;
}
コード例 #7
0
ファイル: hexchat.c プロジェクト: brendenbus/hexchat
int
main (int argc, char *argv[])
{
	int i;
	int ret;

	srand (time (0));	/* CL: do this only once! */

	/* We must check for the config dir parameter, otherwise load_config() will behave incorrectly.
	 * load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to
	 * know the language which is set in the config. The code below is copy-pasted from fe_args()
	 * for the most part. */
	if (argc >= 3)
	{
		for (i = 1; i < argc - 1; i++)
		{
			if (strcmp (argv[i], "-d") == 0)
			{
				if (xdir)
				{
					g_free (xdir);
				}

				xdir = strdup (argv[i + 1]);

				if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
				{
					xdir[strlen (xdir) - 1] = 0;
				}
			}
		}
	}

#if ! GLIB_CHECK_VERSION (2, 36, 0)
	g_type_init ();
#endif

	if (check_config_dir () == 0)
	{
		if (load_config () != 0)
			load_default_config ();
	} else
	{
		/* this is probably the first run */
		load_default_config ();
		make_config_dirs (); /* FIXME: if this fail display an error (?) */
		make_dcc_dirs ();
	}

	/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
	set_locale ();

#ifdef SOCKS
	SOCKSinit (argv[0]);
#endif

	ret = fe_args (argc, argv);
	if (ret != -1)
		return ret;
	
#ifdef USE_DBUS
	hexchat_remote ();
#endif

#ifdef USE_LIBPROXY
	libproxy_factory = px_proxy_factory_new();
#endif

	fe_init ();

#ifndef WIN32
#ifndef __EMX__
	/* OS/2 uses UID 0 all the time */
	if (getuid () == 0)
		fe_message (_("* Running IRC as root is stupid! You should\n"
			      "  create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT);
#endif
#endif /* !WIN32 */

	xchat_init ();

	fe_main ();

#ifdef USE_LIBPROXY
	px_proxy_factory_free(libproxy_factory);
#endif

#ifdef USE_OPENSSL
	if (ctx)
		_SSL_context_free (ctx);
#endif

#ifdef USE_DEBUG
	hexchat_mem_list ();
#endif

#ifdef WIN32
	WSACleanup ();
#endif

	return 0;
}
コード例 #8
0
ファイル: hexchat.c プロジェクト: rfmcpherson/hexchat
int
main (int argc, char *argv[])
{
	int i;
	int ret;

        // BEGIN NEW CODE
        server *fake_serv;
        GIOChannel *channel;
        session *sess;
        // END NEW CODE

#ifdef WIN32
	HRESULT coinit_result;
#endif

	srand ((unsigned int) time (NULL)); /* CL: do this only once! */

	/* We must check for the config dir parameter, otherwise load_config() will behave incorrectly.
	 * load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to
	 * know the language which is set in the config. The code below is copy-pasted from fe_args()
	 * for the most part. */
	if (argc >= 2)
	{
		for (i = 1; i < argc; i++)
		{
			if ((strcmp (argv[i], "-d") == 0 || strcmp (argv[i], "--cfgdir") == 0)
				&& i + 1 < argc)
			{
				xdir = g_strdup (argv[i + 1]);
			}
			else if (strncmp (argv[i], "--cfgdir=", 9) == 0)
			{
				xdir = g_strdup (argv[i] + 9);
			}

			if (xdir != NULL)
			{
				if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
				{
					xdir[strlen (xdir) - 1] = 0;
				}
				break;
			}
		}
	}

#if ! GLIB_CHECK_VERSION (2, 36, 0)
        // RFM: Don't think we hit this
	g_type_init ();
#endif

	if (check_config_dir () == 0)
	{
		if (load_config () != 0)
			load_default_config ();
	} else
	{
		/* this is probably the first run */
		load_default_config ();
		make_config_dirs ();
		make_dcc_dirs ();
	}

	/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
	// RFM: Does nothing on *NIX
        set_locale ();

        // RFM: Parses some command line crap. Not important
	ret = fe_args (argc, argv);
	if (ret != -1)
		return ret;
	
#ifdef USE_DBUS
	hexchat_remote ();
#endif

#ifdef USE_LIBPROXY
        // RFM: Not using
	libproxy_factory = px_proxy_factory_new();
#endif

#ifdef WIN32
	coinit_result = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
	if (SUCCEEDED (coinit_result))
	{
		CoInitializeSecurity (NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
	}
#endif

        // RFM: Inits some fe-text stuff
	fe_init ();

        // RFM: Pretty sure this just allows us to save chats...
	/* This is done here because cfgfiles.c is too early in
	* the startup process to use gtk functions. */
	if (g_access (get_xdir (), W_OK) != 0)
	{
		char buf[2048];

		g_snprintf (buf, sizeof(buf),
			_("You do not have write access to %s. Nothing from this session can be saved."),
			get_xdir ());
		fe_message (buf, FE_MSG_ERROR);
	}

        // RFM: Checks if root on *NIX 
#ifndef WIN32
#ifndef __EMX__
	/* OS/2 uses UID 0 all the time */
	if (getuid () == 0)
		fe_message (_("* Running IRC as root is stupid! You should\n"
			      "  create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT);
#endif
#endif /* !WIN32 */

        // RFM: Loads a bunch of configure options
	xchat_init ();

        // BEGIN NEW CODE
        fake_serv = server_new();
        fake_serv->sok = STDIN_FILENO;
        //        fake_serv->pos = 0; //??? 
        sess = session_new(fake_serv, "fake_sess", SESS_CHANNEL, 0);
        fake_serv->server_session = sess;
        fake_serv->front_session = sess;
        channel = g_io_channel_unix_new(STDIN_FILENO);
        g_io_add_watch(channel, G_IO_IN, (GIOFunc)server_read, fake_serv);
        //g_io_add_watch(channel, G_IO_IN, (GIOFunc)io_callback, fake_serv);
        g_io_channel_unref(channel);
        // END NEW CODE

	fe_main ();

#ifdef WIN32
	if (SUCCEEDED (coinit_result))
	{
		CoUninitialize ();
	}
#endif

#ifdef USE_LIBPROXY
	px_proxy_factory_free(libproxy_factory);
#endif

#ifdef WIN32
	WSACleanup ();
#endif

	return 0;
}
コード例 #9
0
ファイル: hexchat.c プロジェクト: amalmurali47/hexchat
int
main (int argc, char *argv[])
{
	int i;
	int ret;

#ifdef WIN32
	char hexchat_lang[13];	/* LC_ALL= plus 5 chars of hex_gui_lang and trailing \0 */
#endif

	srand (time (0));	/* CL: do this only once! */

	/* We must check for the config dir parameter, otherwise load_config() will behave incorrectly.
	 * load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to
	 * know the language which is set in the config. The code below is copy-pasted from fe_args()
	 * for the most part. */
	if (argc >= 3)
	{
		for (i = 1; i < argc - 1; i++)
		{
			if (strcmp (argv[i], "-d") == 0)
			{
				if (xdir)
				{
					g_free (xdir);
				}

				xdir = strdup (argv[i + 1]);

				if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
				{
					xdir[strlen (xdir) - 1] = 0;
				}
			}
		}
	}

#if ! GLIB_CHECK_VERSION (2, 36, 0)
	g_type_init ();
#endif
	load_config ();

#ifdef WIN32
	/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
	strcpy (hexchat_lang, "LC_ALL=");

	/* this must be ordered EXACTLY as langsmenu[] */
	switch (prefs.hex_gui_lang)
	{
		case 0:
			strcat (hexchat_lang, "af");
			break;
		case 1:
			strcat (hexchat_lang, "sq");
			break;
		case 2:
			strcat (hexchat_lang, "am");
			break;
		case 3:
			strcat (hexchat_lang, "ast");
			break;
		case 4:
			strcat (hexchat_lang, "az");
			break;
		case 5:
			strcat (hexchat_lang, "eu");
			break;
		case 6:
			strcat (hexchat_lang, "be");
			break;
		case 7:
			strcat (hexchat_lang, "bg");
			break;
		case 8:
			strcat (hexchat_lang, "ca");
			break;
		case 9:
			strcat (hexchat_lang, "zh_CN");
			break;
		case 10:
			strcat (hexchat_lang, "zh_TW");
			break;
		case 11:
			strcat (hexchat_lang, "cs");
			break;
		case 12:
			strcat (hexchat_lang, "da");
			break;
		case 13:
			strcat (hexchat_lang, "nl");
			break;
		case 14:
			strcat (hexchat_lang, "en_GB");
			break;
		case 15:
			strcat (hexchat_lang, "en");
			break;
		case 16:
			strcat (hexchat_lang, "et");
			break;
		case 17:
			strcat (hexchat_lang, "fi");
			break;
		case 18:
			strcat (hexchat_lang, "fr");
			break;
		case 19:
			strcat (hexchat_lang, "gl");
			break;
		case 20:
			strcat (hexchat_lang, "de");
			break;
		case 21:
			strcat (hexchat_lang, "el");
			break;
		case 22:
			strcat (hexchat_lang, "gu");
			break;
		case 23:
			strcat (hexchat_lang, "hi");
			break;
		case 24:
			strcat (hexchat_lang, "hu");
			break;
		case 25:
			strcat (hexchat_lang, "id");
			break;
		case 26:
			strcat (hexchat_lang, "it");
			break;
		case 27:
			strcat (hexchat_lang, "ja");
			break;
		case 28:
			strcat (hexchat_lang, "kn");
			break;
		case 29:
			strcat (hexchat_lang, "rw");
			break;
		case 30:
			strcat (hexchat_lang, "ko");
			break;
		case 31:
			strcat (hexchat_lang, "lv");
			break;
		case 32:
			strcat (hexchat_lang, "lt");
			break;
		case 33:
			strcat (hexchat_lang, "mk");
			break;
		case 34:
			strcat (hexchat_lang, "ml");
			break;
		case 35:
			strcat (hexchat_lang, "ms");
			break;
		case 36:
			strcat (hexchat_lang, "nb");
			break;
		case 37:
			strcat (hexchat_lang, "no");
			break;
		case 38:
			strcat (hexchat_lang, "pl");
			break;
		case 39:
			strcat (hexchat_lang, "pt");
			break;
		case 40:
			strcat (hexchat_lang, "pt_BR");
			break;
		case 41:
			strcat (hexchat_lang, "pa");
			break;
		case 42:
			strcat (hexchat_lang, "ru");
			break;
		case 43:
			strcat (hexchat_lang, "sr");
			break;
		case 44:
			strcat (hexchat_lang, "sk");
			break;
		case 45:
			strcat (hexchat_lang, "sl");
			break;
		case 46:
			strcat (hexchat_lang, "es");
			break;
		case 47:
			strcat (hexchat_lang, "sv");
			break;
		case 48:
			strcat (hexchat_lang, "th");
			break;
		case 49:
			strcat (hexchat_lang, "uk");
			break;
		case 50:
			strcat (hexchat_lang, "vi");
			break;
		case 51:
			strcat (hexchat_lang, "wa");
			break;
		default:
			strcat (hexchat_lang, "en");
			break;
	}

	putenv (hexchat_lang);
#endif

#ifdef SOCKS
	SOCKSinit (argv[0]);
#endif

	ret = fe_args (argc, argv);
	if (ret != -1)
		return ret;
	
#ifdef USE_DBUS
	hexchat_remote ();
#endif

#ifdef USE_LIBPROXY
	libproxy_factory = px_proxy_factory_new();
#endif

	fe_init ();

	xchat_init ();

	fe_main ();

#ifdef USE_LIBPROXY
	px_proxy_factory_free(libproxy_factory);
#endif

#ifdef USE_OPENSSL
	if (ctx)
		_SSL_context_free (ctx);
#endif

#ifdef USE_DEBUG
	hexchat_mem_list ();
#endif

#ifdef WIN32
	WSACleanup ();
#endif

	return 0;
}
コード例 #10
0
ファイル: hexchat.c プロジェクト: DCBoland/hexchat
int
main (int argc, char *argv[])
{
	int i;
	int ret;

#ifdef WIN32
	HRESULT coinit_result;
#endif

	srand ((unsigned int) time (NULL)); /* CL: do this only once! */

	/* We must check for the config dir parameter, otherwise load_config() will behave incorrectly.
	 * load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to
	 * know the language which is set in the config. The code below is copy-pasted from fe_args()
	 * for the most part. */
	if (argc >= 2)
	{
		for (i = 1; i < argc; i++)
		{
			if ((strcmp (argv[i], "-d") == 0 || strcmp (argv[i], "--cfgdir") == 0)
				&& i + 1 < argc)
			{
				xdir = g_strdup (argv[i + 1]);
			}
			else if (strncmp (argv[i], "--cfgdir=", 9) == 0)
			{
				xdir = g_strdup (argv[i] + 9);
			}

			if (xdir != NULL)
			{
				if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
				{
					xdir[strlen (xdir) - 1] = 0;
				}
				break;
			}
		}
	}

#if ! GLIB_CHECK_VERSION (2, 36, 0)
	g_type_init ();
#endif

	if (check_config_dir () == 0)
	{
		if (load_config () != 0)
			load_default_config ();
	} else
	{
		/* this is probably the first run */
		load_default_config ();
		make_config_dirs ();
		make_dcc_dirs ();
	}

	/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
	set_locale ();

	ret = fe_args (argc, argv);
	if (ret != -1)
		return ret;
	
#ifdef USE_DBUS
	hexchat_remote ();
#endif

#ifdef USE_LIBPROXY
	libproxy_factory = px_proxy_factory_new();
#endif

#ifdef WIN32
	coinit_result = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
	if (SUCCEEDED (coinit_result))
	{
		CoInitializeSecurity (NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
	}
#endif

	fe_init ();

	/* This is done here because cfgfiles.c is too early in
	* the startup process to use gtk functions. */
	if (g_access (get_xdir (), W_OK) != 0)
	{
		char buf[2048];

		g_snprintf (buf, sizeof(buf),
			_("You do not have write access to %s. Nothing from this session can be saved."),
			get_xdir ());
		fe_message (buf, FE_MSG_ERROR);
	}

#ifndef WIN32
#ifndef __EMX__
	/* OS/2 uses UID 0 all the time */
	if (getuid () == 0)
		fe_message (_("* Running IRC as root is stupid! You should\n"
			      "  create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT);
#endif
#endif /* !WIN32 */

	xchat_init ();

	fe_main ();

#ifdef WIN32
	if (SUCCEEDED (coinit_result))
	{
		CoUninitialize ();
	}
#endif

#ifdef USE_LIBPROXY
	px_proxy_factory_free(libproxy_factory);
#endif

#ifdef WIN32
	WSACleanup ();
#endif

	return 0;
}
コード例 #11
0
ファイル: xchat.c プロジェクト: azkmedia/hexchat
int
main (int argc, char *argv[])
{
	int ret;

#ifdef WIN32
	char hexchat_lang[13];	/* LC_ALL= plus 5 chars of gui_lang and trailing \0 */
	HANDLE mutex;
#endif

	srand (time (0));	/* CL: do this only once! */

	load_config ();

#ifdef WIN32
	/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
	strcpy (hexchat_lang, "LC_ALL=");

	switch (prefs.gui_lang)
	{
		case 0:
			strcat (hexchat_lang, "sq");
			break;
		case 1:
			strcat (hexchat_lang, "am");
			break;
		case 2:
			strcat (hexchat_lang, "az");
			break;
		case 3:
			strcat (hexchat_lang, "eu");
			break;
		case 4:
			strcat (hexchat_lang, "be");
			break;
		case 5:
			strcat (hexchat_lang, "bg");
			break;
		case 6:
			strcat (hexchat_lang, "ca");
			break;
		case 7:
			strcat (hexchat_lang, "zh_CN");
			break;
		case 8:
			strcat (hexchat_lang, "zh_TW");
			break;
		case 9:
			strcat (hexchat_lang, "cs");
			break;
		case 10:
			strcat (hexchat_lang, "nl");
			break;
		case 11:
			strcat (hexchat_lang, "en_GB");
			break;
		case 12:
			strcat (hexchat_lang, "en_US");
			break;
		case 13:
			strcat (hexchat_lang, "et");
			break;
		case 14:
			strcat (hexchat_lang, "fi");
			break;
		case 15:
			strcat (hexchat_lang, "fr");
			break;
		case 16:
			strcat (hexchat_lang, "gl");
			break;
		case 17:
			strcat (hexchat_lang, "de");
			break;
		case 18:
			strcat (hexchat_lang, "el");
			break;
		case 19:
			strcat (hexchat_lang, "hi");
			break;
		case 20:
			strcat (hexchat_lang, "hu_HU");
			break;
		case 21:
			strcat (hexchat_lang, "it");
			break;
		case 22:
			strcat (hexchat_lang, "ja");
			break;
		case 23:
			strcat (hexchat_lang, "kn");
			break;
		case 24:
			strcat (hexchat_lang, "ko");
			break;
		case 25:
			strcat (hexchat_lang, "lv");
			break;
		case 26:
			strcat (hexchat_lang, "lt");
			break;
		case 27:
			strcat (hexchat_lang, "mk");
			break;
		case 28:
			strcat (hexchat_lang, "ms");
			break;
		case 29:
			strcat (hexchat_lang, "nb");
			break;
		case 30:
			strcat (hexchat_lang, "no");
			break;
		case 31:
			strcat (hexchat_lang, "pl");
			break;
		case 32:
			strcat (hexchat_lang, "pt");
			break;
		case 33:
			strcat (hexchat_lang, "pt_BR");
			break;
		case 34:
			strcat (hexchat_lang, "pa");
			break;
		case 35:
			strcat (hexchat_lang, "ru");
			break;
		case 36:
			strcat (hexchat_lang, "sr");
			break;
		case 37:
			strcat (hexchat_lang, "sk");
			break;
		case 38:
			strcat (hexchat_lang, "sl");
			break;
		case 39:
			strcat (hexchat_lang, "es");
			break;
		case 40:
			strcat (hexchat_lang, "sv");
			break;
		case 41:
			strcat (hexchat_lang, "th");
			break;
		case 42:
			strcat (hexchat_lang, "uk");
			break;
		case 43:
			strcat (hexchat_lang, "vi");
			break;
		case 44:
			strcat (hexchat_lang, "wa");
			break;
		default:
			strcat (hexchat_lang, "en_US");
			break;
	}

	putenv (hexchat_lang);

	if (prefs.gui_one_instance && !portable_mode ())
	{
		DWORD error;

		mutex = CreateMutex (NULL, TRUE, "Local\\hexchat");
		error = GetLastError ();

		if (error == ERROR_ALREADY_EXISTS || mutex == NULL)
		{
			/* restoring the XChat window from the tray via the taskbar icon
			 * only works correctly when X-Tray is used, but it's not a big deal
			 * since you can only minimize XChat to tray via the taskbar if you
			 * use X-Tray*/
			if (hextray_mode ())
			{
				/* FindWindow() doesn't support wildcards so we check all the open windows */
				EnumWindows (enum_windows_impl, NULL);
				return 0;
			}
			else
			{
				return 1;
			}
		}
	}
#endif

#ifdef SOCKS
	SOCKSinit (argv[0]);
#endif

	ret = fe_args (argc, argv);
	if (ret != -1)
		return ret;
	
#ifdef USE_DBUS
	xchat_remote ();
#endif

#ifdef USE_LIBPROXY
	libproxy_factory = px_proxy_factory_new();
#endif

	fe_init ();

	xchat_init ();

	fe_main ();

#ifdef USE_LIBPROXY
	px_proxy_factory_free(libproxy_factory);
#endif

#ifdef USE_OPENSSL
	if (ctx)
		_SSL_context_free (ctx);
#endif

#ifdef USE_DEBUG
	xchat_mem_list ();
#endif

#ifdef WIN32
	WSACleanup ();

	if (prefs.gui_one_instance && !portable_mode ())
	{
		ReleaseMutex (mutex);
		CloseHandle (mutex);
	}
#endif

	return 0;
}