Remove system info from CTCP VERSION
This is a common complaint and its honestly totally useless noise. This also removes it from user commands which was also not very useful and it was a decent chunk of not portable code.
This commit is contained in:
parent
38f8cc8e0c
commit
779d373e1d
@ -139,11 +139,10 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
|
||||
if (!g_ascii_strcasecmp (msg, "VERSION") && !prefs.hex_irc_hide_version)
|
||||
{
|
||||
#ifdef WIN32
|
||||
g_snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" [x%d] / %s",
|
||||
get_cpu_arch (), get_sys_str (1));
|
||||
g_snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" [x%d]",
|
||||
get_cpu_arch ());
|
||||
#else
|
||||
g_snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" / %s",
|
||||
get_sys_str (1));
|
||||
g_snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION);
|
||||
#endif
|
||||
serv->p_nctcp (serv, nick, outbuf);
|
||||
}
|
||||
|
@ -758,7 +758,6 @@ static char defaultconf_commands[] =
|
||||
"NAME SPING\n" "CMD ping\n\n"\
|
||||
"NAME SQUERY\n" "CMD quote SQUERY %2 :&3\n\n"\
|
||||
"NAME SSLSERVER\n" "CMD server -ssl &2\n\n"\
|
||||
"NAME SV\n" "CMD echo HexChat %v %m\n\n"\
|
||||
"NAME UMODE\n" "CMD mode %n &2\n\n"\
|
||||
"NAME UPTIME\n" "CMD quote STATS u\n\n"\
|
||||
"NAME VER\n" "CMD ctcp %2 VERSION\n\n"\
|
||||
|
@ -4298,7 +4298,7 @@ auto_insert (char *dest, gsize destlen, unsigned char *src, char *word[],
|
||||
case 'h':
|
||||
utf = h; break;
|
||||
case 'm':
|
||||
utf = get_sys_str (1); break;
|
||||
utf = ""; break; /* Used to be machine info */
|
||||
case 'n':
|
||||
utf = n; break;
|
||||
case 's':
|
||||
|
@ -360,173 +360,12 @@ strip_hidden_attribute (char *src, char *dst)
|
||||
return len;
|
||||
}
|
||||
|
||||
#if defined (__linux__) || defined (__FreeBSD__) || defined (__APPLE__) || defined (__CYGWIN__)
|
||||
|
||||
static void
|
||||
get_cpu_info (double *mhz, int *cpus)
|
||||
{
|
||||
|
||||
#if defined(__linux__) || defined (__CYGWIN__)
|
||||
|
||||
char buf[256];
|
||||
int fh;
|
||||
|
||||
*mhz = 0;
|
||||
*cpus = 0;
|
||||
|
||||
fh = open ("/proc/cpuinfo", O_RDONLY); /* linux 2.2+ only */
|
||||
if (fh == -1)
|
||||
{
|
||||
*cpus = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (waitline (fh, buf, sizeof buf, FALSE) < 0)
|
||||
break;
|
||||
if (!strncmp (buf, "cycle frequency [Hz]\t:", 22)) /* alpha */
|
||||
{
|
||||
*mhz = atoi (buf + 23) / 1000000;
|
||||
} else if (!strncmp (buf, "cpu MHz\t\t:", 10)) /* i386 */
|
||||
{
|
||||
*mhz = atof (buf + 11) + 0.5;
|
||||
} else if (!strncmp (buf, "clock\t\t:", 8)) /* PPC */
|
||||
{
|
||||
*mhz = atoi (buf + 9);
|
||||
} else if (!strncmp (buf, "processor\t", 10))
|
||||
{
|
||||
(*cpus)++;
|
||||
}
|
||||
}
|
||||
close (fh);
|
||||
if (!*cpus)
|
||||
*cpus = 1;
|
||||
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
|
||||
int mib[2], ncpu;
|
||||
u_long freq;
|
||||
size_t len;
|
||||
|
||||
freq = 0;
|
||||
*mhz = 0;
|
||||
*cpus = 0;
|
||||
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_NCPU;
|
||||
|
||||
len = sizeof(ncpu);
|
||||
sysctl(mib, 2, &ncpu, &len, NULL, 0);
|
||||
|
||||
len = sizeof(freq);
|
||||
sysctlbyname("machdep.tsc_freq", &freq, &len, NULL, 0);
|
||||
|
||||
*cpus = ncpu;
|
||||
*mhz = (freq / 1000000);
|
||||
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
|
||||
int mib[2], ncpu;
|
||||
unsigned long long freq;
|
||||
size_t len;
|
||||
|
||||
freq = 0;
|
||||
*mhz = 0;
|
||||
*cpus = 0;
|
||||
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_NCPU;
|
||||
|
||||
len = sizeof(ncpu);
|
||||
sysctl(mib, 2, &ncpu, &len, NULL, 0);
|
||||
|
||||
len = sizeof(freq);
|
||||
sysctlbyname("hw.cpufrequency", &freq, &len, NULL, 0);
|
||||
|
||||
*cpus = ncpu;
|
||||
*mhz = (freq / 1000000);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
int
|
||||
get_cpu_arch (void)
|
||||
{
|
||||
return sysinfo_get_build_arch ();
|
||||
}
|
||||
|
||||
char *
|
||||
get_sys_str (int with_cpu)
|
||||
{
|
||||
static char *without_cpu_buffer = NULL;
|
||||
static char *with_cpu_buffer = NULL;
|
||||
|
||||
if (with_cpu == 0)
|
||||
{
|
||||
if (without_cpu_buffer == NULL)
|
||||
{
|
||||
without_cpu_buffer = sysinfo_get_os ();
|
||||
}
|
||||
|
||||
return without_cpu_buffer;
|
||||
}
|
||||
|
||||
if (with_cpu_buffer == NULL)
|
||||
{
|
||||
char *os = sysinfo_get_os ();
|
||||
char *cpu = sysinfo_get_cpu ();
|
||||
with_cpu_buffer = g_strconcat (os, " [", cpu, "]", NULL);
|
||||
g_free (cpu);
|
||||
g_free (os);
|
||||
}
|
||||
|
||||
return with_cpu_buffer;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
char *
|
||||
get_sys_str (int with_cpu)
|
||||
{
|
||||
#if defined (__linux__) || defined (__FreeBSD__) || defined (__APPLE__) || defined (__CYGWIN__)
|
||||
double mhz;
|
||||
#endif
|
||||
int cpus = 1;
|
||||
struct utsname un;
|
||||
static char *buf = NULL;
|
||||
|
||||
if (buf)
|
||||
return buf;
|
||||
|
||||
uname (&un);
|
||||
|
||||
#if defined (__linux__) || defined (__FreeBSD__) || defined (__APPLE__) || defined (__CYGWIN__)
|
||||
get_cpu_info (&mhz, &cpus);
|
||||
if (mhz && with_cpu)
|
||||
{
|
||||
double cpuspeed = ( mhz > 1000 ) ? mhz / 1000 : mhz;
|
||||
const char *cpuspeedstr = ( mhz > 1000 ) ? "GHz" : "MHz";
|
||||
buf = g_strdup_printf (
|
||||
(cpus == 1) ? "%s %s [%s/%.2f%s]" : "%s %s [%s/%.2f%s/SMP]",
|
||||
un.sysname, un.release, un.machine,
|
||||
cpuspeed, cpuspeedstr);
|
||||
}
|
||||
else
|
||||
buf = g_strdup_printf ("%s %s", un.sysname, un.release);
|
||||
#else
|
||||
buf = g_strdup_printf ("%s %s", un.sysname, un.release);
|
||||
#endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
|
@ -50,7 +50,6 @@ int buf_get_line (char *, char **, int *, int len);
|
||||
char *nocasestrstr (const char *text, const char *tofind);
|
||||
char *country (char *);
|
||||
void country_search (char *pattern, void *ud, void (*print)(void *, char *, ...));
|
||||
char *get_sys_str (int with_cpu);
|
||||
void util_exec (const char *cmd);
|
||||
#define STRIP_COLOR 1
|
||||
#define STRIP_ATTRIB 2
|
||||
|
@ -1470,7 +1470,6 @@ menu_noplugin_info (void)
|
||||
#define usercommands_help _("User Commands - Special codes:\n\n"\
|
||||
"%c = current channel\n"\
|
||||
"%e = current network name\n"\
|
||||
"%m = machine info\n"\
|
||||
"%n = your nick\n"\
|
||||
"%t = time/date\n"\
|
||||
"%v = HexChat version\n"\
|
||||
@ -1488,7 +1487,6 @@ menu_noplugin_info (void)
|
||||
"%c = current channel\n"\
|
||||
"%e = current network name\n"\
|
||||
"%h = selected nick's hostname\n"\
|
||||
"%m = machine info\n"\
|
||||
"%n = your nick\n"\
|
||||
"%s = selected nick\n"\
|
||||
"%t = time/date\n"\
|
||||
@ -1499,7 +1497,6 @@ menu_noplugin_info (void)
|
||||
"%c = current channel\n"\
|
||||
"%e = current network name\n"\
|
||||
"%h = selected nick's hostname\n"\
|
||||
"%m = machine info\n"\
|
||||
"%n = your nick\n"\
|
||||
"%s = selected nick\n"\
|
||||
"%t = time/date\n"\
|
||||
@ -1508,7 +1505,6 @@ menu_noplugin_info (void)
|
||||
#define ctcp_help _("CTCP Replies - Special codes:\n\n"\
|
||||
"%d = data (the whole ctcp)\n"\
|
||||
"%e = current network name\n"\
|
||||
"%m = machine info\n"\
|
||||
"%s = nick who sent the ctcp\n"\
|
||||
"%t = time/date\n"\
|
||||
"%2 = word 2\n"\
|
||||
@ -1714,7 +1710,6 @@ static void
|
||||
menu_about (GtkWidget *wid, gpointer sess)
|
||||
{
|
||||
GtkAboutDialog *dialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new());
|
||||
char comment[512];
|
||||
char *license = "This program is free software; you can redistribute it and/or modify\n" \
|
||||
"it under the terms of the GNU General Public License as published by\n" \
|
||||
"the Free Software Foundation; version 2.\n\n" \
|
||||
@ -1725,17 +1720,15 @@ menu_about (GtkWidget *wid, gpointer sess)
|
||||
"You should have received a copy of the GNU General Public License\n" \
|
||||
"along with this program. If not, see <http://www.gnu.org/licenses/>";
|
||||
|
||||
g_snprintf (comment, sizeof(comment), ""
|
||||
#ifdef WIN32
|
||||
"Portable Mode: %s\n"
|
||||
"Build Type: x%d\n"
|
||||
{
|
||||
char comment[512];
|
||||
g_snprintf (comment, sizeof(comment), "Portable Mode: %s\nBuild Type: x%d\n"
|
||||
(portable_mode () ? "Yes" : "No"),
|
||||
get_cpu_arch ());
|
||||
gtk_about_dialog_set_comments (dialog, comment);
|
||||
}
|
||||
#endif
|
||||
"OS: %s",
|
||||
#ifdef WIN32
|
||||
(portable_mode () ? "Yes" : "No"),
|
||||
get_cpu_arch (),
|
||||
#endif
|
||||
get_sys_str (0));
|
||||
|
||||
gtk_about_dialog_set_program_name (dialog, _(DISPLAY_NAME));
|
||||
gtk_about_dialog_set_version (dialog, PACKAGE_VERSION);
|
||||
@ -1744,7 +1737,6 @@ menu_about (GtkWidget *wid, gpointer sess)
|
||||
gtk_about_dialog_set_website_label (dialog, "Website");
|
||||
gtk_about_dialog_set_logo (dialog, pix_hexchat);
|
||||
gtk_about_dialog_set_copyright (dialog, "\302\251 1998-2010 Peter \305\275elezn\303\275\n\302\251 2009-2014 Berke Viktor");
|
||||
gtk_about_dialog_set_comments (dialog, comment);
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(parent_window));
|
||||
g_signal_connect (G_OBJECT(dialog), "response", G_CALLBACK(about_dialog_close), NULL);
|
||||
|
@ -78,8 +78,6 @@ static int done_intro = 0;
|
||||
void
|
||||
fe_new_window (struct session *sess, int focus)
|
||||
{
|
||||
char buf[512];
|
||||
|
||||
current_sess = sess;
|
||||
|
||||
if (!sess->server->front_session)
|
||||
@ -93,13 +91,7 @@ fe_new_window (struct session *sess, int focus)
|
||||
return;
|
||||
done_intro = 1;
|
||||
|
||||
g_snprintf (buf, sizeof (buf),
|
||||
"\n"
|
||||
" \017HexChat-Text \00310"PACKAGE_VERSION"\n"
|
||||
" \017Running on \00310%s\n",
|
||||
get_sys_str (1));
|
||||
fe_print_text (sess, buf, 0, FALSE);
|
||||
|
||||
fe_print_text (sess, "\n \017HexChat-Text \00310"PACKAGE_VERSION"\n", 0, FALSE);
|
||||
fe_print_text (sess, "\n\nCompiled in Features\0032:\017 "
|
||||
#ifdef USE_PLUGIN
|
||||
"Plugin "
|
||||
|
Loading…
Reference in New Issue
Block a user