Compare commits
252 Commits
Author | SHA1 | Date |
---|---|---|
Travis Burtrum | dbad9285b8 | |
Lee Watson | 73636a00b5 | |
TingPing | e7003ef9c6 | |
RichardHitt | 9664b1b7e3 | |
asarium | 422cce6f70 | |
TingPing | afd2135393 | |
TingPing | 94ef0fd294 | |
TingPing | ebe1f824a7 | |
RichardHitt | f7bea16e37 | |
tomek | ff9c0dbd5e | |
Arnavion | 29321c8660 | |
Arnavion | 0b40146b85 | |
TingPing | 9b2c560519 | |
TingPing | 3675302930 | |
TingPing | 925570aab1 | |
TingPing | 498f53b96a | |
TingPing | 5263887ac3 | |
TingPing | 73d865b243 | |
TingPing | a3c257bdb4 | |
TingPing | 6ad9419693 | |
TingPing | c5aa91a836 | |
TingPing | b10f94d5f6 | |
TingPing | 9a98de1f65 | |
TingPing | 7363bc03f2 | |
TingPing | 78e51a4f3f | |
TingPing | 174db0eb7f | |
TingPing | f64b61a1b9 | |
TingPing | a8392c7f95 | |
TingPing | 72d7f64f8b | |
TingPing | c86389f99b | |
TingPing | 66f2f3a84a | |
TingPing | f8c7ea3672 | |
TingPing | e313a82ab4 | |
TingPing | 9024a5c71b | |
TingPing | f03b6314b4 | |
TingPing | ae2e5ab092 | |
TingPing | 167eb11ea7 | |
TingPing | 1cc06f9301 | |
TingPing | 455fa24d63 | |
TingPing | dc69f24ae5 | |
TingPing | b4906f3d23 | |
TingPing | 4e338a2b70 | |
Arnavion | 98fefcd162 | |
Arnavion | fb422732f2 | |
bendem | 36a8ba126c | |
TingPing | 658f30ec43 | |
TingPing | 749e5b20da | |
TingPing | d78db5070a | |
TingPing | a5584c6b57 | |
Arnavion | 97bf0de016 | |
Arnavion | b6c4cfa2a3 | |
TingPing | ec12871e60 | |
TingPing | 0a29313fff | |
TingPing | b009084a52 | |
TingPing | 7e7e87600e | |
TingPing | c36d4859d7 | |
Arnavion | c1d06c7d63 | |
TingPing | 5e3355a6c3 | |
Arnavion | 363321dc33 | |
Arnavion | 4d44c17939 | |
Arnavion | 5b24c60def | |
TingPing | 96026b82c7 | |
Arnavion | e42da22716 | |
TingPing | 0a8248578f | |
TingPing | c87f559334 | |
RichardHitt | 8ca96d7ea3 | |
Arnavion | bbb81af550 | |
Arnavion | a22816fbbd | |
TingPing | b6877ccf5c | |
TingPing | 7063406d6c | |
Arnavion | 9858784eb6 | |
TingPing | 7e4a585611 | |
Arnavion | 5a87d814cf | |
TingPing | ac54a2ed45 | |
TingPing | 296fbaf94f | |
TingPing | 75c022c49f | |
TingPing | f4f27e438b | |
Berke Viktor | a216ed1df9 | |
TingPing | afee9fd42b | |
TingPing | 60fa7efbc8 | |
Arnavion | dc9a7d3a59 | |
Arnavion | 1d83610341 | |
Arnavion | 5dde0d7c6d | |
Arnavion | 9968bb31a4 | |
TingPing | 5fe2dda146 | |
TingPing | 85fd6f525e | |
TingPing | e5b65bbd69 | |
TingPing | a838cd9c07 | |
TingPing | 02470dffa5 | |
Arnavion | c5bbf75f5e | |
Arnavion | b783c827c8 | |
Arnavion | d1897c1602 | |
Arnavion | 6f8a6e66cc | |
Arnavion | 5749c53484 | |
Arnavion | 5569205d15 | |
Arnavion | 2e76a4e477 | |
Arnavion | ee17ec6b4f | |
Arnavion | 5a56f9ea01 | |
Arnavion | e400ed2855 | |
Arnavion | 1d316710ed | |
TingPing | aab243592f | |
TingPing | 13db2011e3 | |
tomek | 7739c99f3f | |
Arnavion | 99f74e8d94 | |
TingPing | 5ca87b3c8d | |
Arnavion | 62df565190 | |
Arnavion | 4f08b0b386 | |
Arnavion | 5b8cc683f3 | |
Arnavion | e758da5d28 | |
TingPing | 16d1fccf61 | |
TingPing | 086d4e3962 | |
TingPing | 9bd7405502 | |
TingPing | 2a28289314 | |
TingPing | 112632bb4e | |
TingPing | c5016e390f | |
TingPing | 63bb87fc93 | |
TingPing | 1fa4a000e7 | |
TingPing | 448cc962cd | |
TingPing | 6ef7298870 | |
TingPing | 9f7444baa2 | |
TingPing | fef580ed7f | |
TingPing | 3bb717a3b5 | |
TingPing | 5beaf15f21 | |
TingPing | 1b2bee37e4 | |
TingPing | 9cb73f839f | |
TingPing | 330e31c70f | |
TingPing | cbaa04905f | |
TingPing | 14d3a03f41 | |
TingPing | 95febd978c | |
TingPing | 3f855f07f5 | |
TingPing | 83032b1aa3 | |
TingPing | c4cb1b25ec | |
TingPing | 77ecaa6093 | |
TingPing | 664f6bf1e7 | |
TingPing | aeb5d15871 | |
TingPing | 76c2cfebc3 | |
TingPing | addefa9ef1 | |
TingPing | 7769bc99fe | |
TingPing | ce396b3ddb | |
TingPing | ebe0ad4cd5 | |
TingPing | bdb5c3eb9d | |
TingPing | c54a0c6db9 | |
TingPing | 46061f4f3c | |
Arnavion | ec7a0d6e13 | |
TingPing | a86b03e939 | |
TingPing | 35fd47da55 | |
TingPing | 2b1396add3 | |
TingPing | 0e4164ad0c | |
TingPing | 94568bc517 | |
TingPing | 226d54c90d | |
TingPing | 7e4c482737 | |
Arnavion | ac01ba9cb0 | |
TingPing | a537fa3ca7 | |
TingPing | f614a3c311 | |
TingPing | d6e3f740bc | |
TingPing | 72f82d096c | |
md_5 | 74ff67acd3 | |
leeter | 6aafc8e51d | |
TingPing | 10246f121a | |
TingPing | 025152ee53 | |
TingPing | 58e871696b | |
TingPing | 0ba8b922a2 | |
TingPing | b296839538 | |
TingPing | 5fb21a04ad | |
TingPing | fda692d250 | |
Arnavion | 99a1fff590 | |
Arnavion | 65c8494698 | |
Arnavion | 2b94011fdc | |
Arnavion | 2da5308fd2 | |
Arnavion | c1831cb19d | |
Arnavion | 65da34f19e | |
Arnavion | b7afcc3632 | |
TingPing | 73cd6487d0 | |
Arnavion | 5152040c17 | |
Arnavion | 985ea610e6 | |
Arnavion | 8062bce835 | |
Ivan | 3fbe5b876e | |
TingPing | e38f00775f | |
TingPing | 05a6097dc6 | |
TingPing | 85557f2416 | |
tomek | 0019af675a | |
TingPing | f03023297b | |
TingPing | c92b247878 | |
TingPing | 232096801b | |
TingPing | c0769397d5 | |
TingPing | c9b63f7f9b | |
TingPing | ebaaf466bf | |
TingPing | 4b6215051f | |
Campbell Barton | f83d78dd28 | |
Dan Molik | 9fb4eb5107 | |
TingPing | 3c89de48a8 | |
RichardHitt | 6653582f0a | |
TingPing | abaed2bda4 | |
Arnavion | e8fb2dde56 | |
Mikaela Suomalainen | 25c6638ce4 | |
TingPing | ce4e129849 | |
TingPing | ecd1aa226a | |
TingPing | 760d18b6e7 | |
TingPing | f389257403 | |
TingPing | 84df81f336 | |
Arnavion | a9a6cbda4e | |
TingPing | 7a4a0243bd | |
Arnavion | e209e55e59 | |
Arnavion | ad2300f236 | |
TingPing | 80bdd9ce11 | |
TingPing | 5f99d34c3b | |
TingPing | 2aa3eb8cfb | |
LightningW | d1b9118056 | |
Farow | fd95c729d5 | |
TingPing | d1c40196e3 | |
TingPing | 9716185edf | |
Arnavion | a38892ff3b | |
TingPing | dc18e3da07 | |
TingPing | 9127b510f2 | |
TingPing | 8f9ed6d942 | |
TingPing | 422edd8812 | |
TingPing | 345c8a29ad | |
TingPing | a854234c1f | |
TingPing | 4b549eeac8 | |
Arnavion | 7c2c8b1403 | |
TingPing | c2ecb4c68c | |
siniStar7boy | ea9dafcd43 | |
RichardHitt | 7a7b9c682d | |
RichardHitt | 0d3706e2ee | |
TingPing | 3c584e2cd5 | |
TingPing | 9372972ad4 | |
TingPing | 121cb8b88d | |
Campbell Barton | 93caf4c7b4 | |
TingPing | 21c0e47869 | |
TingPing | f1e853c1cb | |
hasufell | aa7291fc9c | |
laurinkus | 3de79bca10 | |
TingPing | 466646f84a | |
TingPing | e0f80e41bf | |
TingPing | 9a5977a9c9 | |
TingPing | c3c6b46230 | |
TingPing | 47b4b0da8a | |
TingPing | 45526205ab | |
TingPing | 3342af4185 | |
RichardHitt | 7374637d34 | |
Berke Viktor | 62209618e1 | |
Berke Viktor | 7bfa2ee8a7 | |
Berke Viktor | 73c914cca9 | |
TingPing | 77d9d421fb | |
TingPing | 59f3a65911 | |
TingPing | 9181ea068a | |
TingPing | c1d9aad546 | |
TingPing | 3cd8556c54 | |
TingPing | 9c981cfc6b | |
TingPing | 11e3ecc739 | |
TingPing | 5849a0588e | |
TingPing | b8c02f71d9 |
|
@ -2,11 +2,13 @@
|
||||||
# Unix generated files
|
# Unix generated files
|
||||||
.deps/
|
.deps/
|
||||||
.libs/
|
.libs/
|
||||||
|
.dirstamp
|
||||||
Makefile
|
Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
autom4te.cache/
|
autom4te.cache/
|
||||||
compile
|
compile
|
||||||
|
ar-lib
|
||||||
confdefs.h
|
confdefs.h
|
||||||
conftest
|
conftest
|
||||||
conftest.c
|
conftest.c
|
||||||
|
@ -68,6 +70,7 @@ stamp-h1
|
||||||
*.po~
|
*.po~
|
||||||
*.pot
|
*.pot
|
||||||
*.patch
|
*.patch
|
||||||
|
src/**/*.plist
|
||||||
# Win32 generated files
|
# Win32 generated files
|
||||||
plugins/wmpa/wmpa_h.h
|
plugins/wmpa/wmpa_h.h
|
||||||
plugins/wmpa/wmpa_i.c
|
plugins/wmpa/wmpa_i.c
|
||||||
|
@ -84,6 +87,7 @@ resource.h
|
||||||
*.sdf
|
*.sdf
|
||||||
*.suo
|
*.suo
|
||||||
*.user
|
*.user
|
||||||
|
*.exe
|
||||||
#OSX
|
#OSX
|
||||||
osx/HexChat.app
|
osx/HexChat.app
|
||||||
osx/.HexChat.app
|
osx/.HexChat.app
|
||||||
|
|
14
.travis.yml
14
.travis.yml
|
@ -1,14 +1,16 @@
|
||||||
language: c
|
language: c
|
||||||
compiler: gcc
|
compiler: clang
|
||||||
before_script:
|
before_script:
|
||||||
|
- sudo apt-get update
|
||||||
- sudo apt-get build-dep -qq xchat
|
- sudo apt-get build-dep -qq xchat
|
||||||
- sudo apt-get install -qq libnotify-dev libproxy-dev libpci-dev libcanberra-dev monodevelop gnome-common
|
- sudo apt-get install -qq libnotify-dev libproxy-dev libpci-dev libcanberra-dev monodevelop intltool
|
||||||
script:
|
script:
|
||||||
- ./autogen.sh
|
- ./autogen.sh --enable-textfe --with-theme-manager --enable-static-analysis
|
||||||
- ./configure --enable-textfe --with-theme-manager
|
- make V=1 -j$(nproc)
|
||||||
- make V=1
|
|
||||||
notifications:
|
notifications:
|
||||||
irc:
|
irc:
|
||||||
channels: "chat.freenode.net#hexchat-devel"
|
channels: "chat.freenode.net#hexchat-devel"
|
||||||
template: "Build #%{build_number} (%{commit}) by %{author}: %{message}"
|
template: "Build %{build_url} (%{commit} in %{branch}) by %{author}: %{message}"
|
||||||
on_success: change
|
on_success: change
|
||||||
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
|
|
25
autogen.sh
25
autogen.sh
|
@ -4,19 +4,24 @@
|
||||||
srcdir=`dirname $0`
|
srcdir=`dirname $0`
|
||||||
test -z "$srcdir" && srcdir=.
|
test -z "$srcdir" && srcdir=.
|
||||||
|
|
||||||
NOCONFIGURE=1
|
|
||||||
PKG_NAME="hexchat"
|
|
||||||
|
|
||||||
(test -f $srcdir/src/common/hexchat.c) || {
|
(test -f $srcdir/src/common/hexchat.c) || {
|
||||||
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
|
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the top-level directory"
|
||||||
echo " top-level $PKG_NAME directory"
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
which gnome-autogen.sh || {
|
aclocal --install -I m4 || exit 1
|
||||||
echo "You need to install gnome-common"
|
glib-gettextize --force --copy || exit 1
|
||||||
exit 1
|
intltoolize --force --copy --automake || exit 1
|
||||||
}
|
autoreconf --force --install -Wno-portability || exit 1
|
||||||
|
|
||||||
. gnome-autogen.sh
|
if [ "$NOCONFIGURE" = "" ]; then
|
||||||
|
$srcdir/configure "$@" || exit 1
|
||||||
|
|
||||||
|
if [ "$1" = "--help" ]; then exit 0 else
|
||||||
|
echo "Now type \`make\' to compile" || exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Skipping configure process."
|
||||||
|
fi
|
||||||
|
|
||||||
|
set +x
|
||||||
|
|
655
configure.ac
655
configure.ac
|
@ -1,8 +1,8 @@
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_INIT([HexChat],[2.10.0])
|
AC_INIT([HexChat],[2.11.0])
|
||||||
|
|
||||||
AC_PREREQ([2.60])
|
AC_PREREQ([2.64])
|
||||||
AC_COPYRIGHT([Copyright (C) 1998-2010 Peter Zelezny])
|
AC_COPYRIGHT([Copyright (C) 1998-2010 Peter Zelezny])
|
||||||
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
@ -10,18 +10,25 @@ AC_CONFIG_SRCDIR([configure.ac])
|
||||||
|
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.11 dist-bzip2 subdir-objects no-define foreign])
|
AM_INIT_AUTOMAKE([1.11.1 dist-bzip2 subdir-objects no-define foreign])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
|
AX_IS_RELEASE([minor-version])
|
||||||
|
AX_CHECK_ENABLE_DEBUG([yes])
|
||||||
|
AX_REQUIRE_DEFINED([PKG_PROG_PKG_CONFIG])
|
||||||
|
|
||||||
AC_USE_SYSTEM_EXTENSIONS
|
AC_USE_SYSTEM_EXTENSIONS
|
||||||
AM_MAINTAINER_MODE
|
AM_MAINTAINER_MODE([enable])
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
AC_PROG_CPP
|
AC_PROG_CPP
|
||||||
|
AC_PROG_OBJC
|
||||||
AM_PROG_AS
|
AM_PROG_AS
|
||||||
AM_DISABLE_STATIC
|
AM_PROG_AR
|
||||||
AC_PROG_LIBTOOL
|
LT_PREREQ([2.2.6])
|
||||||
|
LT_INIT([disable-static])
|
||||||
AC_PATH_PROG(MDTOOL, mdtool, no)
|
AC_PATH_PROG(MDTOOL, mdtool, no)
|
||||||
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
dnl -----------------------------------------------------------
|
dnl -----------------------------------------------------------
|
||||||
dnl Language Support
|
dnl Language Support
|
||||||
|
@ -37,14 +44,12 @@ AH_VERBATIM([OLD_PERL],[#undef OLD_PERL])
|
||||||
AH_VERBATIM([PREFIX],[#undef PREFIX])
|
AH_VERBATIM([PREFIX],[#undef PREFIX])
|
||||||
AH_VERBATIM([HEXCHATLIBDIR],[#undef HEXCHATLIBDIR])
|
AH_VERBATIM([HEXCHATLIBDIR],[#undef HEXCHATLIBDIR])
|
||||||
AH_VERBATIM([HEXCHATSHAREDIR],[#undef HEXCHATSHAREDIR])
|
AH_VERBATIM([HEXCHATSHAREDIR],[#undef HEXCHATSHAREDIR])
|
||||||
AH_VERBATIM([SOCKS],[#undef SOCKS])
|
|
||||||
AH_VERBATIM([USE_MSPROXY],[#undef USE_MSPROXY])
|
|
||||||
AH_VERBATIM([USE_LIBPROXY],[#undef USE_LIBPROXY])
|
AH_VERBATIM([USE_LIBPROXY],[#undef USE_LIBPROXY])
|
||||||
|
AH_VERBATIM([HAVE_LIBPCI],[#undef HAVE_LIBPCI])
|
||||||
AH_VERBATIM([HAVE_ISO_CODES],[#undef HAVE_ISO_CODES])
|
AH_VERBATIM([HAVE_ISO_CODES],[#undef HAVE_ISO_CODES])
|
||||||
AH_VERBATIM([HAVE_GTK_MAC],[#undef HAVE_GTK_MAC])
|
AH_VERBATIM([HAVE_GTK_MAC],[#undef HAVE_GTK_MAC])
|
||||||
AH_VERBATIM([USE_LIBNOTIFY],[#undef USE_LIBNOTIFY])
|
AH_VERBATIM([USE_LIBNOTIFY],[#undef USE_LIBNOTIFY])
|
||||||
AH_VERBATIM([USE_LIBCANBERRA],[#undef USE_LIBCANBERRA])
|
AH_VERBATIM([USE_LIBCANBERRA],[#undef USE_LIBCANBERRA])
|
||||||
AH_VERBATIM([USE_IPV6],[#undef USE_IPV6])
|
|
||||||
AH_VERBATIM([USE_OPENSSL],[#undef USE_OPENSSL])
|
AH_VERBATIM([USE_OPENSSL],[#undef USE_OPENSSL])
|
||||||
AH_VERBATIM([USE_PLUGIN],[#undef USE_PLUGIN])
|
AH_VERBATIM([USE_PLUGIN],[#undef USE_PLUGIN])
|
||||||
AH_VERBATIM([USE_SIGACTION],[#undef USE_SIGACTION])
|
AH_VERBATIM([USE_SIGACTION],[#undef USE_SIGACTION])
|
||||||
|
@ -54,37 +59,39 @@ AH_VERBATIM([socklen_t],[#undef socklen_t])
|
||||||
AH_VERBATIM([USE_DBUS],[#undef USE_DBUS])
|
AH_VERBATIM([USE_DBUS],[#undef USE_DBUS])
|
||||||
|
|
||||||
AC_PATH_PROG(sedpath, sed)
|
AC_PATH_PROG(sedpath, sed)
|
||||||
if test "_$sedpath" = _; then
|
AS_IF([test "_$sedpath" = _], [
|
||||||
AC_MSG_ERROR(Cannot find sed: I need it!)
|
AC_MSG_ERROR(Cannot find sed: I need it!)
|
||||||
fi
|
])
|
||||||
|
|
||||||
AC_PATH_PROG(unamepath, uname)
|
AC_PATH_PROG(unamepath, uname)
|
||||||
if test "_$unamepath" = _; then
|
AS_IF([test "_$unamepath" = _], [
|
||||||
system="unknown"
|
system="unknown"
|
||||||
else
|
], [
|
||||||
AC_MSG_CHECKING(system type)
|
AC_MSG_CHECKING(system type)
|
||||||
system=`$unamepath -s`
|
system=`$unamepath -s`
|
||||||
AC_MSG_RESULT($system)
|
AC_MSG_RESULT($system)
|
||||||
if test "$system" = "Linux"; then
|
AS_IF([test "$system" = "Linux"], [
|
||||||
AC_DEFINE(USING_LINUX)
|
AC_DEFINE(USING_LINUX)
|
||||||
fi
|
], [test "$system" = "FreeBSD"], [
|
||||||
if test "$system" = "FreeBSD"; then
|
|
||||||
AC_DEFINE(USING_FREEBSD)
|
AC_DEFINE(USING_FREEBSD)
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
|
platform_win32=no
|
||||||
|
platform_osx=no
|
||||||
|
AS_CASE([$host_os],
|
||||||
|
[*mingw*|*cygwin*|*msys*], [
|
||||||
|
platform_win32=yes
|
||||||
|
],
|
||||||
|
[darwin*], [
|
||||||
|
platform_osx=yes
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** configure switches ***********************************************
|
dnl ** configure switches ***********************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
AC_ARG_ENABLE(socks,
|
|
||||||
[AS_HELP_STRING([--enable-socks],[link with SOCKS5 library (default: no)])],
|
|
||||||
socks=$enableval, socks=no)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(ipv6,
|
|
||||||
[AS_HELP_STRING([--disable-ipv6],[disable IPv6])],
|
|
||||||
ipv6=$enableval, ipv6=yes)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(openssl,
|
AC_ARG_ENABLE(openssl,
|
||||||
[AS_HELP_STRING([--enable-openssl[=PATH]],[enable use of openSSL])],
|
[AS_HELP_STRING([--enable-openssl[=PATH]],[enable use of openSSL])],
|
||||||
openssl=$enableval, openssl=yes)
|
openssl=$enableval, openssl=yes)
|
||||||
|
@ -142,10 +149,6 @@ AC_ARG_ENABLE(libcanberra,
|
||||||
[AS_HELP_STRING([--disable-libcanberra],[disable libcanberra support])],
|
[AS_HELP_STRING([--disable-libcanberra],[disable libcanberra support])],
|
||||||
libcanberra=$enableval, libcanberra=yes)
|
libcanberra=$enableval, libcanberra=yes)
|
||||||
|
|
||||||
AC_ARG_ENABLE(ntlm,
|
|
||||||
[AS_HELP_STRING([--enable-ntlm],[enable Microsoft\'s NTLM auth (libntlm) library support (default: no)])],
|
|
||||||
ntlm=$enableval, ntlm=no)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(libproxy,
|
AC_ARG_ENABLE(libproxy,
|
||||||
[AS_HELP_STRING([--disable-libproxy],[disable libproxy support (default: auto)])],
|
[AS_HELP_STRING([--disable-libproxy],[disable libproxy support (default: auto)])],
|
||||||
libproxy=$enableval, libproxy=auto)
|
libproxy=$enableval, libproxy=auto)
|
||||||
|
@ -154,9 +157,9 @@ AC_ARG_ENABLE(isocodes,
|
||||||
[AS_HELP_STRING([--disable-isocodes],[disable iso-codes with spell-check])],
|
[AS_HELP_STRING([--disable-isocodes],[disable iso-codes with spell-check])],
|
||||||
isocodes=$enableval, isocodes=yes)
|
isocodes=$enableval, isocodes=yes)
|
||||||
|
|
||||||
AC_ARG_ENABLE(minimal-flags,
|
AC_ARG_ENABLE(static-analysis,
|
||||||
[AS_HELP_STRING([--enable-minimal-flags],[only add those CFLAGS that are really needed or not intrusive (default: no)])],
|
[AS_HELP_STRING([--enable-static-analysis],[if using clang run static analysis during build (default: no)])],
|
||||||
minimalflags=$enableval, minimalflags=no)
|
analyze=$enableval, analyze=no)
|
||||||
|
|
||||||
AC_ARG_WITH(theme-manager,
|
AC_ARG_WITH(theme-manager,
|
||||||
[AS_HELP_STRING([--with-theme-manager],[compile theme manager (needs monodevelop, default: off)])],
|
[AS_HELP_STRING([--with-theme-manager],[compile theme manager (needs monodevelop, default: off)])],
|
||||||
|
@ -167,163 +170,141 @@ AC_ARG_WITH(theme-manager,
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** THEME-MANAGER ****************************************************
|
dnl ** THEME-MANAGER ****************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
if test "x$theme_manager" != "xno" ; then
|
AS_IF([test "x$theme_manager" != "xno"], [
|
||||||
if test "x$MDTOOL" = "xno"; then
|
AS_IF([test "x$MDTOOL" = "xno"], [
|
||||||
AC_MSG_ERROR([No "mdtool" found, you need to install monodevelop!])
|
AC_MSG_ERROR([No "mdtool" found, you need to install monodevelop!])
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** GLIB *************************************************************
|
dnl ** GLIB *************************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
AM_PATH_GLIB_2_0(2.28.0, glib=yes, glib=no)
|
AM_PATH_GLIB_2_0([2.32.0], [], [AC_MSG_ERROR([Glib not found!])], [gmodule gobject gio])
|
||||||
if test "$glib" = no; then
|
COMMON_CFLAGS="$GLIB_CFLAGS -DG_DISABLE_SINGLE_INCLUDES"
|
||||||
AC_MSG_ERROR(Cannot find GLib!)
|
COMMON_LIBS="$GLIB_LIBS"
|
||||||
fi
|
AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_32], [Dont warn using older APIs])
|
||||||
|
AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32], [Prevents using newer APIs])
|
||||||
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0], [], [AC_MSG_ERROR(Cannot find gobject-2.0!)])
|
|
||||||
PKG_CHECK_MODULES([GIO], [gio-2.0], [], [AC_MSG_ERROR(Cannot find gio-2.0!)])
|
|
||||||
PKG_CHECK_MODULES([GMODULE], [gmodule-2.0], [], [AC_MSG_ERROR(Cannot find gmodule-2.0!)])
|
|
||||||
|
|
||||||
COMMON_CFLAGS="$GLIB_CFLAGS $GIO_CFLAGS $GOBJECT_CFLAGS $GMODULE_CFLAGS -DG_DISABLE_SINGLE_INCLUDES"
|
|
||||||
COMMON_LIBS="$GLIB_LIBS $GIO_LIBS $GOBJECT_LIBS $GMODULE_LIBS"
|
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** GTK **************************************************************
|
dnl ** GTK **************************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
# we might get undefined macro without this test
|
AS_IF([test "$gtkfe" = yes], [
|
||||||
if test "$gtkfe" = yes ; then
|
PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.24.0], [
|
||||||
AM_PATH_GTK_2_0(2.24.0, havegtk=yes, havegtk=no)
|
GUI_LIBS="$GUI_LIBS $GTK_LIBS"
|
||||||
|
GUI_CFLAGS="$GUI_CFLAGS $GTK_CFLAGS -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED"
|
||||||
if test "$havegtk" = no; then
|
], [
|
||||||
gtkfe=no
|
gtkfe=no
|
||||||
echo
|
])
|
||||||
echo Cannot find GTK\! Not building GTK FrontEnd.
|
])
|
||||||
echo
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
GUI_LIBS="$GUI_LIBS $GTK_LIBS"
|
|
||||||
GUI_CFLAGS="$GUI_CFLAGS $GTK_CFLAGS -DG_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED"
|
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** MAC_INTEGRATION **************************************************
|
dnl ** MAC_INTEGRATION **************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
_gdk_tgt=`$PKG_CONFIG --variable=target gdk-2.0`
|
_gdk_tgt=`$PKG_CONFIG --variable=target gdk-2.0`
|
||||||
if test "x$_gdk_tgt" = xquartz; then
|
AS_IF([test "x$_gdk_tgt" = xquartz], [
|
||||||
PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration, [
|
PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration-gtk2, [
|
||||||
GUI_LIBS="$GUI_LIBS $GTK_MAC_LIBS"
|
GUI_LIBS="$GUI_LIBS $GTK_MAC_LIBS"
|
||||||
GUI_CFLAGS="$GUI_CFLAGS $GTK_MAC_CFLAGS"
|
GUI_CFLAGS="$GUI_CFLAGS $GTK_MAC_CFLAGS"
|
||||||
AC_DEFINE(HAVE_GTK_MAC)
|
AC_DEFINE(HAVE_GTK_MAC)
|
||||||
])
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** PERL *************************************************************
|
dnl ** PERL *************************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "$perl" = yes; then
|
AS_IF([test "$perl" = yes], [
|
||||||
AC_MSG_CHECKING(for plugin interface used by Perl)
|
AC_MSG_CHECKING(for plugin interface used by Perl)
|
||||||
if test "$plugin" = yes; then
|
AS_IF([test "$plugin" = yes], [
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
AC_PATH_PROG(perlpath, perl)
|
|
||||||
AC_MSG_CHECKING(for Perl compile flags)
|
|
||||||
PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
|
|
||||||
if test "_$PERL_CFLAGS" = _ ; then
|
|
||||||
AC_MSG_RESULT([not found, building without perl.])
|
|
||||||
perl=no
|
|
||||||
else
|
|
||||||
PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts |$sedpath 's/-lgdbm //'`
|
|
||||||
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-ldb //'`
|
|
||||||
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lndbm //'`
|
|
||||||
if test "$system" = "Linux"; then
|
|
||||||
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lnsl //'`
|
|
||||||
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lposix //'`
|
|
||||||
fi
|
|
||||||
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lc //'`
|
|
||||||
AC_MSG_RESULT(ok)
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(for perl >= 5.8.0)
|
AX_PERL_EXT_FLAGS([PERL_CFLAGS], [PERL_LDFLAGS])
|
||||||
PERL_VER=`$perlpath -e 'print $]>= 5.008?"yes":"no"'`
|
original_cflags="$CFLAGS"
|
||||||
if test "$PERL_VER" = "yes"; then
|
original_ldflags="$LDFLAGS"
|
||||||
original_cflags="$CFLAGS"
|
CFLAGS="$PERL_CFLAGS"
|
||||||
original_ldflags="$LDFLAGS"
|
LDFLAGS="$PERL_LDFLAGS"
|
||||||
CFLAGS="$PERL_CFLAGS"
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||||
LDFLAGS="$PERL_LDFLAGS"
|
#define PERL_NO_INLINE_FUNCTIONS
|
||||||
AC_TRY_LINK([#include <EXTERN.h>
|
#include <EXTERN.h>
|
||||||
#include <perl.h>], [], perl_is_usable=yes, perl_is_usable=no)
|
#include <perl.h>
|
||||||
CFLAGS="$original_cflags"
|
]], [[]])],[perl_is_usable=yes],[perl_is_usable=no])
|
||||||
LDFLAGS="$original_ldflags"
|
CFLAGS="$original_cflags"
|
||||||
if test x$perl_is_usable = xno ; then
|
LDFLAGS="$original_ldflags"
|
||||||
AC_MSG_RESULT(no)
|
AS_IF([test "$perl_is_usable" = "no"], [
|
||||||
perl=no
|
AC_MSG_WARN([perl test failed to compile, disabling])
|
||||||
else
|
perl=no
|
||||||
AC_MSG_RESULT(yes)
|
], [
|
||||||
AC_MSG_CHECKING(if perl plugin will be backward compatible)
|
AC_MSG_CHECKING([if perl plugin will be backward compatible])
|
||||||
if test "$perl_old" = "yes"; then
|
AS_IF([test "$perl_old" = "yes"], [
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT([yes])
|
||||||
AC_DEFINE(OLD_PERL)
|
AC_DEFINE(OLD_PERL)
|
||||||
else
|
], [
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT([no])
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
else
|
], [
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
echo "perl version too old, building without perl."
|
|
||||||
perl=no
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Perl])
|
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Perl])
|
||||||
perl=no
|
perl=no
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** PYTHON ***********************************************************
|
dnl ** PYTHON ***********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "x$python" != xno ; then
|
AS_IF([test "x$python" != xno], [
|
||||||
AC_MSG_CHECKING(for plugin interface used by Python)
|
AC_MSG_CHECKING(for plugin interface used by Python)
|
||||||
if test "$plugin" = yes; then
|
AS_IF([test "$plugin" = yes], [
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
case $python in
|
AS_CASE([$python],
|
||||||
dnl set python2 default here
|
dnl set python2 default here
|
||||||
python2)
|
[python2], [
|
||||||
PKG_CHECK_MODULES([PY], [python-2.7], [], [AC_MSG_WARN(Cannot find python-2.7!)])
|
PKG_CHECK_MODULES([PY], [python-2.7],
|
||||||
PY_VER="`$PKG_CONFIG --modversion python-2.7`";;
|
[PY_VER="`$PKG_CONFIG --modversion python-2.7`"],
|
||||||
|
[true])
|
||||||
|
],
|
||||||
dnl set python3 default here
|
dnl set python3 default here
|
||||||
python3)
|
[python3], [
|
||||||
PKG_CHECK_MODULES([PY], [python-3.3], [], [AC_MSG_WARN(Cannot find python-3.3!)])
|
PKG_CHECK_MODULES([PY], [python-3.4],
|
||||||
PY_VER="`$PKG_CONFIG --modversion python-3.3`";;
|
[PY_VER="`$PKG_CONFIG --modversion python-3.4`"],
|
||||||
|
[true])
|
||||||
|
AS_IF([test "$PY_VER" = ""], [
|
||||||
|
PKG_CHECK_MODULES([PY], [python-3.3],
|
||||||
|
[PY_VER="`$PKG_CONFIG --modversion python-3.3`"],
|
||||||
|
[true])
|
||||||
|
])
|
||||||
|
],
|
||||||
dnl add broken versions here
|
dnl add broken versions here
|
||||||
python2.5|python2.6|python3.1|python3.2)
|
[python2.5|python2.6|python3.1|python3.2], [
|
||||||
AC_MSG_ERROR(Unsupported Python version ${python}!);;
|
AC_MSG_WARN(Unsupported Python version ${python}!)
|
||||||
python*)
|
],
|
||||||
|
[python*], [
|
||||||
python="python-${python#python}" # stay posix compliant
|
python="python-${python#python}" # stay posix compliant
|
||||||
PKG_CHECK_MODULES([PY], [${python}], [], [AC_MSG_WARN(Cannot find "${python}.pc"!)])
|
PKG_CHECK_MODULES([PY], [${python}],
|
||||||
PY_VER="`$PKG_CONFIG --modversion ${python}`";;
|
[PY_VER="`$PKG_CONFIG --modversion ${python}`"],
|
||||||
*)
|
[AC_MSG_WARN(Cannot find "${python}.pc"!)])
|
||||||
|
],[
|
||||||
AC_MSG_WARN(Unsupported Python ${python}!)
|
AC_MSG_WARN(Unsupported Python ${python}!)
|
||||||
esac
|
]
|
||||||
|
)
|
||||||
AC_MSG_CHECKING(Python version)
|
AC_MSG_CHECKING(Python version)
|
||||||
|
|
||||||
if test "$PY_VER"; then
|
AS_IF([test "$PY_VER"], [
|
||||||
AC_MSG_RESULT($PY_VER)
|
AC_MSG_RESULT($PY_VER)
|
||||||
python="python-${PY_VER}"
|
python="python-${PY_VER}"
|
||||||
else
|
], [
|
||||||
AC_MSG_RESULT(Not found)
|
AC_MSG_RESULT(Not found)
|
||||||
python=no
|
python=no
|
||||||
fi
|
])
|
||||||
else
|
], [
|
||||||
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Python])
|
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Python])
|
||||||
python=no
|
python=no
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** IPv6 *************************************************************
|
dnl ** IPv6 *************************************************************
|
||||||
|
@ -339,182 +320,175 @@ AC_CHECK_FUNC(select, ,
|
||||||
AC_MSG_WARN(i can not find select. you might need to help me)))))))
|
AC_MSG_WARN(i can not find select. you might need to help me)))))))
|
||||||
AC_CHECK_LIB(socket, select)
|
AC_CHECK_LIB(socket, select)
|
||||||
|
|
||||||
if test "$ipv6" = yes; then
|
AC_CHECK_FUNCS(getaddrinfo, have_getaddrinfo=yes)
|
||||||
AC_CHECK_FUNCS(getaddrinfo, have_getaddrinfo=yes)
|
AC_MSG_CHECKING(whether IPv6 is supported)
|
||||||
AC_MSG_CHECKING(whether to enable IPv6 support)
|
AS_IF([test "$have_getaddrinfo" = yes], [
|
||||||
if test "$have_getaddrinfo" = yes; then
|
AC_MSG_RESULT(yes)
|
||||||
AC_MSG_RESULT(yes)
|
], [
|
||||||
AC_DEFINE(USE_IPV6)
|
AC_MSG_RESULT(no)
|
||||||
else
|
AC_MSG_ERROR(ipv6 support not found!)
|
||||||
ipv6=no
|
])
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** OPENSSL **********************************************************
|
dnl ** OPENSSL **********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
retry=no
|
|
||||||
if test "$openssl" != no; then
|
|
||||||
AC_MSG_CHECKING(for openssl through pkg-config)
|
|
||||||
if $PKG_CONFIG openssl --exists; then
|
|
||||||
CPPFLAGS="$CPPFLAGS `$PKG_CONFIG openssl --cflags`"
|
|
||||||
LIBS="$LIBS `$PKG_CONFIG openssl --libs`"
|
|
||||||
AC_DEFINE(USE_OPENSSL)
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
openssl=yes
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
retry=yes
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$retry" = "yes"; then
|
AS_IF([test "$openssl" != no], [
|
||||||
unset openssl_path ac_cv_lib_ssl_SSL_new ac_cv_header_openssl_ssl_h
|
PKG_CHECK_MODULES(OPENSSL, [openssl], [
|
||||||
if test "$openssl" != yes; then
|
AC_DEFINE(USE_OPENSSL)
|
||||||
openssl_path=$openssl
|
openssl=yes
|
||||||
fi
|
COMMON_LIBS="$COMMON_LIBS $OPENSSL_LIBS"
|
||||||
openssl=no
|
COMMON_CFLAGS="$COMMON_CFLAGS $OPENSSL_CFLAGS"
|
||||||
SAVED_LIBS=$LIBS
|
], [
|
||||||
LIBS="$LIBS -lcrypto"
|
unset openssl_path ac_cv_lib_ssl_SSL_new ac_cv_header_openssl_ssl_h
|
||||||
if test -n "$openssl_path"; then
|
AS_IF([test "$openssl" != yes], [
|
||||||
LIBS="-L$openssl_path/lib $LIBS"
|
openssl_path=$openssl
|
||||||
fi
|
])
|
||||||
AC_CHECK_LIB(ssl, SSL_new, have_openssl=yes)
|
openssl=no
|
||||||
LIBS=$SAVED_LIBS
|
OPENSSL_LIBS="-lcrypto"
|
||||||
if test "$have_openssl" = yes; then
|
AS_IF([test -n "$openssl_path"], [
|
||||||
SAVED_CPPFLAGS=$CPPFLAGS
|
OPENSSL_LIBS="-L$openssl_path/lib $OPENSSL_LIBS"
|
||||||
if test -n "$openssl_path"; then
|
])
|
||||||
CPPFLAGS="-I$openssl_path/include $CPPFLAGS"
|
SAVED_LIBS=$LIBS
|
||||||
fi
|
LIBS="$LIBS $OPENSSL_LIBS"
|
||||||
AC_CHECK_HEADERS(openssl/ssl.h, have_openssl_h=yes)
|
AC_CHECK_LIB(ssl, SSL_new, [
|
||||||
if test "$have_openssl_h" = yes; then
|
AS_IF([test -n "$openssl_path"], [
|
||||||
openssl=yes
|
OPENSSL_CFLAGS="-I$openssl_path/include"
|
||||||
AC_DEFINE(USE_OPENSSL)
|
])
|
||||||
LIBS="$LIBS -lssl -lcrypto"
|
SAVED_CFLAGS=$CFLAGS
|
||||||
if test -n "$openssl_path"; then
|
CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
|
||||||
LIBS="-L$openssl_path/lib $LIBS"
|
AC_CHECK_HEADERS(openssl/ssl.h, [
|
||||||
fi
|
openssl=yes
|
||||||
else
|
AC_DEFINE(USE_OPENSSL)
|
||||||
CPPFLAGS=$SAVED_CPPFLAGS
|
OPENSSL_LIBS="$OPENSSL_LIBS -lssl"
|
||||||
fi
|
|
||||||
fi
|
COMMON_LIBS="$COMMON_LIBS $OPENSSL_LIBS"
|
||||||
fi
|
COMMON_CFLAGS="$COMMON_CFLAGS $OPENSSL_CFLAGS"
|
||||||
|
])
|
||||||
|
CFLAGS=$SAVED_CFLAGS
|
||||||
|
])
|
||||||
|
LIBS=$SAVED_LIBS
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** LIBPROXY *********************************************************
|
dnl ** LIBPROXY *********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "x$libproxy" = "xyes" -o "x$libproxy" = "xauto" ; then
|
AS_IF([test "x$libproxy" = "xyes" -o "x$libproxy" = "xauto"], [
|
||||||
PKG_CHECK_MODULES([LIBPROXY], [libproxy-1.0], [
|
PKG_CHECK_MODULES([LIBPROXY], [libproxy-1.0], [
|
||||||
COMMON_LIBS="$COMMON_LIBS $LIBPROXY_LIBS"
|
COMMON_LIBS="$COMMON_LIBS $LIBPROXY_LIBS"
|
||||||
COMMON_CFLAGS="$COMMON_CFLAGS $LIBPROXY_CFLAGS"
|
COMMON_CFLAGS="$COMMON_CFLAGS $LIBPROXY_CFLAGS"
|
||||||
AC_DEFINE(USE_LIBPROXY)
|
AC_DEFINE(USE_LIBPROXY)
|
||||||
libproxy=yes
|
libproxy=yes
|
||||||
], [
|
], [
|
||||||
if test "x$libproxy" = "xyes" ; then
|
AS_IF([test "x$libproxy" = "xyes"], [
|
||||||
AC_MSG_ERROR(Cannot find libproxy!)
|
AC_MSG_ERROR(Cannot find libproxy!)
|
||||||
fi
|
])
|
||||||
libproxy=no
|
libproxy=no
|
||||||
])
|
])
|
||||||
else
|
], [
|
||||||
libproxy=no
|
libproxy=no
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** PLUGIN ***********************************************************
|
dnl ** PLUGIN ***********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "$plugin" = yes; then
|
AS_IF([test "$plugin" = yes], [
|
||||||
AC_DEFINE(USE_PLUGIN)
|
AC_DEFINE(USE_PLUGIN)
|
||||||
fi
|
PLUGIN_LDFLAGS="-avoid-version"
|
||||||
|
AS_IF([test "$platform_win32" = yes], [
|
||||||
|
PLUGIN_LDFLAGS="$PLUGIN_LDFLAGS -no-undefined"
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** Checksum *********************************************************
|
dnl ** Checksum *********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "$checksum" != "no"; then
|
AS_IF([test "$checksum" != "no"], [
|
||||||
checksum=no
|
checksum=no
|
||||||
AC_MSG_CHECKING(for plugin interface used by Checksum)
|
AC_MSG_CHECKING(for plugin interface used by Checksum)
|
||||||
if test "$plugin" = yes; then
|
AS_IF([test "$plugin" = yes], [
|
||||||
|
checksum=yes
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
AC_MSG_CHECKING(for OpenSSL used by Checksum)
|
], [
|
||||||
if test "$openssl" = yes; then
|
|
||||||
checksum=yes
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT([OpenSSL cannot be found, use the --enable-openssl option])
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option])
|
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option])
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** DO AT ************************************************************
|
dnl ** DO AT ************************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "$doat" != "no"; then
|
AS_IF([test "$doat" != "no"], [
|
||||||
AC_MSG_CHECKING(for plugin interface used by Do At)
|
AC_MSG_CHECKING(for plugin interface used by Do At)
|
||||||
doat=no
|
doat=no
|
||||||
if test "$plugin" = yes; then
|
AS_IF([test "$plugin" = yes], [
|
||||||
doat=yes
|
doat=yes
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
else
|
], [
|
||||||
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Do At])
|
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Do At])
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** FiSHLiM **********************************************************
|
dnl ** FiSHLiM **********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "$fishlim" != "no"; then
|
AS_IF([test "$fishlim" != "no"], [
|
||||||
fishlim=no
|
fishlim=no
|
||||||
AC_MSG_CHECKING(for plugin interface used by FiSHLiM)
|
AC_MSG_CHECKING(for plugin interface used by FiSHLiM)
|
||||||
if test "$plugin" = yes; then
|
AS_IF([test "$plugin" = yes], [
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
AC_MSG_CHECKING(for OpenSSL used by FiSHLiM)
|
AC_MSG_CHECKING(for OpenSSL used by FiSHLiM)
|
||||||
if test "$openssl" = yes; then
|
AS_IF([test "$openssl" = yes], [
|
||||||
fishlim=yes
|
fishlim=yes
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
else
|
], [
|
||||||
AC_MSG_RESULT([OpenSSL cannot be found, use the --enable-openssl option])
|
AC_MSG_RESULT([OpenSSL cannot be found, use the --enable-openssl option])
|
||||||
fi
|
])
|
||||||
else
|
], [
|
||||||
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option])
|
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option])
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** SYSINFO **********************************************************
|
dnl ** SYSINFO **********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "$sysinfo" != "no"; then
|
AS_IF([test "$sysinfo" != "no"], [
|
||||||
AC_MSG_CHECKING(for plugin interface used by SysInfo)
|
AC_MSG_CHECKING(for plugin interface used by SysInfo)
|
||||||
if test "$plugin" = yes; then
|
AS_IF([test "$plugin" = yes], [
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
PKG_CHECK_MODULES(LIBPCI, libpci >= 3.0.0, [sysinfo=yes], [sysinfo=no])
|
AS_IF([test "$platform_osx" = yes], [
|
||||||
else
|
sysinfo=yes
|
||||||
|
], [
|
||||||
|
PKG_CHECK_MODULES(LIBPCI, libpci >= 3.0.0, [
|
||||||
|
sysinfo=yes
|
||||||
|
AC_DEFINE(HAVE_LIBPCI)
|
||||||
|
], [sysinfo=no])
|
||||||
|
])
|
||||||
|
], [
|
||||||
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for SysInfo])
|
AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for SysInfo])
|
||||||
sysinfo=no
|
sysinfo=no
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl #######################################################################
|
dnl #######################################################################
|
||||||
dnl # Check for DBUS libraries
|
dnl # Check for DBUS libraries
|
||||||
dnl #######################################################################
|
dnl #######################################################################
|
||||||
|
|
||||||
if test "x$dbus" = "xyes" ; then
|
AS_IF([test "x$dbus" = "xyes"], [
|
||||||
PKG_CHECK_MODULES(DBUS, [dbus-1 >= 0.60 dbus-glib-1 >= 0.60 gthread-2.0], dbus=yes, [
|
PKG_CHECK_MODULES(DBUS, [dbus-1 >= 0.60 dbus-glib-1 >= 0.60 gthread-2.0], dbus=yes, [
|
||||||
dbus=no
|
dbus=no
|
||||||
])
|
])
|
||||||
AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
|
AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
|
||||||
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal, no)
|
AS_IF([test "x$DBUS_BINDING_TOOL" = "xno" || test "x$dbus" = "xno"], [
|
||||||
if test "x$DBUS_BINDING_TOOL" = "xno" || test "x$GLIB_GENMARSHAL" = "xno" || test "x$dbus" = "xno" ; then
|
|
||||||
dbus="no"
|
dbus="no"
|
||||||
else
|
], [
|
||||||
COMMON_LIBS="$COMMON_LIBS $DBUS_LIBS"
|
COMMON_LIBS="$COMMON_LIBS $DBUS_LIBS"
|
||||||
COMMON_CFLAGS="$COMMON_CFLAGS $DBUS_CFLAGS"
|
COMMON_CFLAGS="$COMMON_CFLAGS $DBUS_CFLAGS"
|
||||||
AC_DEFINE(USE_DBUS)
|
AC_DEFINE(USE_DBUS)
|
||||||
|
@ -522,44 +496,44 @@ if test "x$dbus" = "xyes" ; then
|
||||||
AS_AC_EXPAND(DBUS_SERVICES_DIR, "$datadir/dbus-1/services")
|
AS_AC_EXPAND(DBUS_SERVICES_DIR, "$datadir/dbus-1/services")
|
||||||
AC_SUBST(DBUS_SERVICES_DIR)
|
AC_SUBST(DBUS_SERVICES_DIR)
|
||||||
AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for DBUS is])
|
AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for DBUS is])
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** LIBNOTIFY ********************************************************
|
dnl ** LIBNOTIFY ********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "x$libnotify" = "xyes" ; then
|
AS_IF([test "x$libnotify" = "xyes"], [
|
||||||
PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.4, [], [
|
PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.4, [], [
|
||||||
libnotify=no
|
libnotify=no
|
||||||
])
|
])
|
||||||
if test "$libnotify" != "no" ; then
|
AS_IF([test "$libnotify" != "no"], [
|
||||||
GUI_LIBS="$GUI_LIBS $LIBNOTIFY_LIBS"
|
GUI_LIBS="$GUI_LIBS $LIBNOTIFY_LIBS"
|
||||||
GUI_CFLAGS="$GUI_CFLAGS $LIBNOTIFY_CFLAGS"
|
GUI_CFLAGS="$GUI_CFLAGS $LIBNOTIFY_CFLAGS"
|
||||||
AC_DEFINE(USE_LIBNOTIFY)
|
AC_DEFINE(USE_LIBNOTIFY)
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** LIBCANBERRA ******************************************************
|
dnl ** LIBCANBERRA ******************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "x$libcanberra" = "xyes" ; then
|
AS_IF([test "x$libcanberra" = "xyes"], [
|
||||||
PKG_CHECK_MODULES(LIBCANBERRA, libcanberra >= 0.22, [], [
|
PKG_CHECK_MODULES(LIBCANBERRA, libcanberra >= 0.22, [], [
|
||||||
libcanberra=no
|
libcanberra=no
|
||||||
])
|
])
|
||||||
if test "$libcanberra" != "no" ; then
|
AS_IF([test "$libcanberra" != "no"], [
|
||||||
COMMON_LIBS="$COMMON_LIBS $LIBCANBERRA_LIBS"
|
COMMON_LIBS="$COMMON_LIBS $LIBCANBERRA_LIBS"
|
||||||
COMMON_CFLAGS="$COMMON_CFLAGS $LIBCANBERRA_CFLAGS"
|
COMMON_CFLAGS="$COMMON_CFLAGS $LIBCANBERRA_CFLAGS"
|
||||||
AC_DEFINE(USE_LIBCANBERRA)
|
AC_DEFINE(USE_LIBCANBERRA)
|
||||||
fi
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** SPELL ************************************************************
|
dnl ** SPELL ************************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "x$isocodes" = "xyes" ; then
|
AS_IF([test "x$isocodes" = "xyes"], [
|
||||||
PKG_CHECK_MODULES(ISOCODES, "iso-codes", [
|
PKG_CHECK_MODULES(ISOCODES, "iso-codes", [
|
||||||
iso_codes_prefix=`$PKG_CONFIG --variable=prefix iso-codes 2>/dev/null || echo /usr`
|
iso_codes_prefix=`$PKG_CONFIG --variable=prefix iso-codes 2>/dev/null || echo /usr`
|
||||||
AC_MSG_NOTICE([iso-codes prefix: $iso_codes_prefix])
|
AC_MSG_NOTICE([iso-codes prefix: $iso_codes_prefix])
|
||||||
|
@ -570,7 +544,18 @@ if test "x$isocodes" = "xyes" ; then
|
||||||
isocodes=no
|
isocodes=no
|
||||||
AC_MSG_WARN(iso-codes not found!)
|
AC_MSG_WARN(iso-codes not found!)
|
||||||
])
|
])
|
||||||
fi
|
])
|
||||||
|
|
||||||
|
dnl *********************************************************************
|
||||||
|
dnl ** Static Analysis **************************************************
|
||||||
|
dnl *********************************************************************
|
||||||
|
|
||||||
|
AS_IF([test "x$analyze" = "xyes"], [
|
||||||
|
AS_IF([test "$CC" != "clang"], [
|
||||||
|
AC_MSG_WARN(CC is not clang for static analysis)
|
||||||
|
analyze=no
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** CONDITIONALS *****************************************************
|
dnl ** CONDITIONALS *****************************************************
|
||||||
|
@ -579,7 +564,6 @@ dnl *********************************************************************
|
||||||
AM_CONDITIONAL(USE_OPENSSL, test "x$openssl" = "xyes")
|
AM_CONDITIONAL(USE_OPENSSL, test "x$openssl" = "xyes")
|
||||||
AM_CONDITIONAL(USE_LIBNOTIFY, test "x$libnotify" = "xyes")
|
AM_CONDITIONAL(USE_LIBNOTIFY, test "x$libnotify" = "xyes")
|
||||||
AM_CONDITIONAL(USE_LIBCANBERRA, test "x$libcanberra" = "xyes")
|
AM_CONDITIONAL(USE_LIBCANBERRA, test "x$libcanberra" = "xyes")
|
||||||
AM_CONDITIONAL(USE_MSPROXY, test "x$ntlm" = "xyes")
|
|
||||||
AM_CONDITIONAL(DO_TEXT, test "x$textfe" = "xyes")
|
AM_CONDITIONAL(DO_TEXT, test "x$textfe" = "xyes")
|
||||||
AM_CONDITIONAL(DO_GTK, test "x$gtkfe" = "xyes")
|
AM_CONDITIONAL(DO_GTK, test "x$gtkfe" = "xyes")
|
||||||
AM_CONDITIONAL(DO_PERL, test "x$perl" = "xyes")
|
AM_CONDITIONAL(DO_PERL, test "x$perl" = "xyes")
|
||||||
|
@ -589,128 +573,30 @@ AM_CONDITIONAL(DO_CHECKSUM, test "x$checksum" = "xyes")
|
||||||
AM_CONDITIONAL(DO_DOAT, test "x$doat" = "xyes")
|
AM_CONDITIONAL(DO_DOAT, test "x$doat" = "xyes")
|
||||||
AM_CONDITIONAL(DO_FISHLIM, test "x$fishlim" = "xyes")
|
AM_CONDITIONAL(DO_FISHLIM, test "x$fishlim" = "xyes")
|
||||||
AM_CONDITIONAL(DO_SYSINFO, test "x$sysinfo" = "xyes")
|
AM_CONDITIONAL(DO_SYSINFO, test "x$sysinfo" = "xyes")
|
||||||
|
AM_CONDITIONAL(DO_STATIC_ANALYSIS, test "x$analyze" = "xyes")
|
||||||
AM_CONDITIONAL(USE_DBUS, test "x$dbus" = "xyes")
|
AM_CONDITIONAL(USE_DBUS, test "x$dbus" = "xyes")
|
||||||
AM_CONDITIONAL(HAVE_ISO_CODES, test "x$isocodes" = "xyes")
|
AM_CONDITIONAL(HAVE_ISO_CODES, test "x$isocodes" = "xyes")
|
||||||
|
AM_CONDITIONAL(HAVE_GTK_MAC, test "x$_gdk_tgt" = xquartz)
|
||||||
AM_CONDITIONAL(WITH_TM, test "x$theme_manager" != "xno")
|
AM_CONDITIONAL(WITH_TM, test "x$theme_manager" != "xno")
|
||||||
|
AM_CONDITIONAL(PLATFORM_OSX, test "x$platform_osx" == "xyes")
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** SOCKS5 ***********************************************************
|
dnl ** CFLAGS ***********************************************************
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
|
|
||||||
if test "$socks" = yes; then
|
CC_CHECK_FLAGS_APPEND([CFLAGS], [CFLAGS], [ \
|
||||||
socks=no
|
-pipe \
|
||||||
AC_CHECK_LIB(socks5, SOCKSconnect, have_socks=yes)
|
-funsigned-char \
|
||||||
if test "$have_socks" = yes; then
|
-Wall \
|
||||||
AC_CHECK_HEADERS(socks.h, have_socks_h=yes)
|
-Wextra \
|
||||||
if test "$have_socks_h" = yes; then
|
-Wno-unused-parameter \
|
||||||
socks=yes
|
-Wno-sign-compare \
|
||||||
AC_DEFINE(SOCKS)
|
-Wno-pointer-sign \
|
||||||
LIBS="$LIBS -lsocks5"
|
-Wno-missing-field-initializers \
|
||||||
fi
|
-Wno-unused-result \
|
||||||
fi
|
-Werror=format-security \
|
||||||
fi
|
-Werror=declaration-after-statement \
|
||||||
|
|
||||||
dnl *********************************************************************
|
|
||||||
dnl ** MS PROXY *********************************************************
|
|
||||||
dnl *********************************************************************
|
|
||||||
|
|
||||||
have_ntlm="no"
|
|
||||||
if test "x$ntlm" = "xyes" ; then
|
|
||||||
have_ntlm="no"
|
|
||||||
AC_CHECK_LIB(ntlm, ntlm_smb_encrypt, have_ntlm=yes)
|
|
||||||
if test "$have_ntlm" = yes; then
|
|
||||||
LIBS="$LIBS -lntlm"
|
|
||||||
AC_DEFINE(USE_MSPROXY)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl *********************************************************************
|
|
||||||
dnl ** GCC FLAGS ********************************************************
|
|
||||||
dnl *********************************************************************
|
|
||||||
|
|
||||||
dnl Only use -Wall and -pipe if we have gcc
|
|
||||||
if test "x$GCC" = "xyes"; then
|
|
||||||
if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
|
|
||||||
CFLAGS="$CFLAGS -Wall"
|
|
||||||
fi
|
|
||||||
dnl these flags might be unwanted
|
|
||||||
if test x$minimalflags != xyes; then
|
|
||||||
if test "$system" = "Linux" -o "$system" = "FreeBSD"; then
|
|
||||||
if test -z "`echo "$CFLAGS" | grep "\-pipe" 2> /dev/null`" ; then
|
|
||||||
CFLAGS="$CFLAGS -pipe"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test -z "`echo "$CFLAGS" | grep "\-g " 2> /dev/null`" ; then
|
|
||||||
CFLAGS="$CFLAGS -g"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl does this compiler support -Wno-pointer-sign ?
|
|
||||||
AC_MSG_CHECKING([if $CC accepts -Wno-pointer-sign ])
|
|
||||||
|
|
||||||
safe_CFLAGS=$CFLAGS
|
|
||||||
CFLAGS="-Wno-pointer-sign"
|
|
||||||
|
|
||||||
AC_TRY_COMPILE(, [
|
|
||||||
return 0;
|
|
||||||
],
|
|
||||||
[
|
|
||||||
no_pointer_sign=yes
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
], [
|
|
||||||
no_pointer_sign=no
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
])
|
])
|
||||||
CFLAGS=$safe_CFLAGS
|
|
||||||
|
|
||||||
if test x$no_pointer_sign = xyes; then
|
|
||||||
CFLAGS="$CFLAGS -Wno-pointer-sign"
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl does this compiler support -funsigned-char ?
|
|
||||||
AC_MSG_CHECKING([if $CC accepts -funsigned-char ])
|
|
||||||
|
|
||||||
safe_CFLAGS=$CFLAGS
|
|
||||||
CFLAGS="-funsigned-char"
|
|
||||||
|
|
||||||
AC_TRY_COMPILE(, [
|
|
||||||
return 0;
|
|
||||||
],
|
|
||||||
[
|
|
||||||
unsigned_char=yes
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
], [
|
|
||||||
unsigned_char=no
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
])
|
|
||||||
CFLAGS=$safe_CFLAGS
|
|
||||||
|
|
||||||
if test x$unsigned_char = xyes; then
|
|
||||||
CFLAGS="$CFLAGS -funsigned-char"
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl does this compiler support -Wno-unused-result ?
|
|
||||||
AC_MSG_CHECKING([if $CC accepts -Wno-unused-result ])
|
|
||||||
|
|
||||||
safe_CFLAGS=$CFLAGS
|
|
||||||
CFLAGS="-Wno-unused-result"
|
|
||||||
|
|
||||||
AC_TRY_COMPILE(, [
|
|
||||||
return 0;
|
|
||||||
],
|
|
||||||
[
|
|
||||||
no_unused_result=yes
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
], [
|
|
||||||
no_unused_result=no
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
])
|
|
||||||
CFLAGS=$safe_CFLAGS
|
|
||||||
|
|
||||||
if test x$no_unused_result = xyes; then
|
|
||||||
CFLAGS="$CFLAGS -Wno-unused-result"
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl *********************************************************************
|
dnl *********************************************************************
|
||||||
dnl ** FUNCTIONS/LIBS/CFLAGS ********************************************
|
dnl ** FUNCTIONS/LIBS/CFLAGS ********************************************
|
||||||
|
@ -719,19 +605,14 @@ dnl *********************************************************************
|
||||||
AC_MSG_CHECKING(for modern sigaction)
|
AC_MSG_CHECKING(for modern sigaction)
|
||||||
dnl libc5 on linux and FreeBSD 3.x doesn\'t have siginfo_t
|
dnl libc5 on linux and FreeBSD 3.x doesn\'t have siginfo_t
|
||||||
dnl and the sa_sigation field.
|
dnl and the sa_sigation field.
|
||||||
AC_TRY_COMPILE(
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[struct sigaction act;
|
||||||
[#include <signal.h>],
|
|
||||||
[struct sigaction act;
|
|
||||||
siginfo_t *si;
|
siginfo_t *si;
|
||||||
act.sa_sigaction = 0;],
|
act.sa_sigaction = 0;]])],[
|
||||||
[
|
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
AC_DEFINE(USE_SIGACTION)
|
AC_DEFINE(USE_SIGACTION)
|
||||||
],
|
],[AC_MSG_RESULT(no)])
|
||||||
AC_MSG_RESULT(no))
|
|
||||||
|
|
||||||
dnl if we don\'t have this, use g_snprintf instead
|
AC_CHECK_FUNCS(memrchr)
|
||||||
AC_CHECK_FUNCS(snprintf vsnprintf memrchr strtoull)
|
|
||||||
|
|
||||||
AC_CHECK_FUNC(gethostbyname, ,
|
AC_CHECK_FUNC(gethostbyname, ,
|
||||||
AC_CHECK_LIB(resolv, gethostbyname, ,
|
AC_CHECK_LIB(resolv, gethostbyname, ,
|
||||||
|
@ -753,9 +634,9 @@ AC_EGREP_CPP([socklen_t[^a-zA-Z_0-9]], [#include <sys/types.h>
|
||||||
ac_cv_type_socklen_t=yes,
|
ac_cv_type_socklen_t=yes,
|
||||||
ac_cv_type_socklen_t=no)
|
ac_cv_type_socklen_t=no)
|
||||||
])
|
])
|
||||||
if test $ac_cv_type_socklen_t = no; then
|
AS_IF([test $ac_cv_type_socklen_t = no], [
|
||||||
AC_DEFINE(socklen_t, int)
|
AC_DEFINE(socklen_t, int)
|
||||||
fi
|
])
|
||||||
|
|
||||||
dnl Mac OS X and Darwin use lookupd, which caches DNS queries by default
|
dnl Mac OS X and Darwin use lookupd, which caches DNS queries by default
|
||||||
AC_EGREP_CPP(lookupd, dnl
|
AC_EGREP_CPP(lookupd, dnl
|
||||||
|
@ -765,7 +646,6 @@ AC_EGREP_CPP(lookupd, dnl
|
||||||
|
|
||||||
dnl freebsd needs this
|
dnl freebsd needs this
|
||||||
LIBS="$LIBS $INTLLIBS"
|
LIBS="$LIBS $INTLLIBS"
|
||||||
CFLAGS="$CFLAGS $CPPFLAGS"
|
|
||||||
|
|
||||||
GUI_LIBS="$GUI_LIBS $COMMON_LIBS"
|
GUI_LIBS="$GUI_LIBS $COMMON_LIBS"
|
||||||
|
|
||||||
|
@ -780,15 +660,19 @@ AC_SUBST(PY_CFLAGS)
|
||||||
AC_SUBST(PY_LIBS)
|
AC_SUBST(PY_LIBS)
|
||||||
AC_SUBST(DBUS_CFLAGS)
|
AC_SUBST(DBUS_CFLAGS)
|
||||||
AC_SUBST(DBUS_LIBS)
|
AC_SUBST(DBUS_LIBS)
|
||||||
|
AC_SUBST(OPENSSL_LIBS)
|
||||||
|
AC_SUBST(OPENSSL_CFLAGS)
|
||||||
|
AC_SUBST(PLUGIN_LDFLAGS)
|
||||||
|
|
||||||
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig))
|
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig))
|
||||||
|
|
||||||
PLUGIN_INCLUDES='-I$(top_srcdir)/plugins'
|
|
||||||
AC_SUBST(PLUGIN_INCLUDES)
|
|
||||||
|
|
||||||
dnl for plugin.c and pixmaps.c
|
dnl for plugin.c and pixmaps.c
|
||||||
test "x$prefix" = xNONE && prefix="$ac_default_prefix"
|
AS_IF([test "x$prefix" = xNONE], [
|
||||||
test "x$exec_prefix" = xNONE && exec_prefix="$prefix"
|
prefix="$ac_default_prefix"
|
||||||
|
])
|
||||||
|
AS_IF([test "x$exec_prefix" = xNONE], [
|
||||||
|
exec_prefix="$prefix"
|
||||||
|
])
|
||||||
|
|
||||||
AC_DEFINE_UNQUOTED(PREFIX, "${prefix}")
|
AC_DEFINE_UNQUOTED(PREFIX, "${prefix}")
|
||||||
|
|
||||||
|
@ -843,9 +727,6 @@ echo D-Bus support ......... : $dbus
|
||||||
echo libnotify support ..... : $libnotify
|
echo libnotify support ..... : $libnotify
|
||||||
echo libcanberra support ... : $libcanberra
|
echo libcanberra support ... : $libcanberra
|
||||||
echo Plugin interface ...... : $plugin
|
echo Plugin interface ...... : $plugin
|
||||||
echo NLS/gettext ........... : $USE_NLS
|
|
||||||
echo IPv6 support .......... : $ipv6
|
|
||||||
echo MS Proxy NTLM \(ISA\) ... : $have_ntlm
|
|
||||||
echo libproxy support ...... : $libproxy
|
echo libproxy support ...... : $libproxy
|
||||||
echo
|
echo
|
||||||
echo Perl .................. : $perl
|
echo Perl .................. : $perl
|
||||||
|
@ -856,6 +737,8 @@ echo Do At ................. : $doat
|
||||||
echo FiSHLiM ............... : $fishlim
|
echo FiSHLiM ............... : $fishlim
|
||||||
echo SysInfo ............... : $sysinfo
|
echo SysInfo ............... : $sysinfo
|
||||||
echo
|
echo
|
||||||
|
echo Debug mode ............ : $enable_debug
|
||||||
|
echo
|
||||||
echo The binary will be installed in $prefix/bin
|
echo The binary will be installed in $prefix/bin
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
dnl Macros to check the presence of generic (non-typed) symbols.
|
||||||
|
dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
|
||||||
|
dnl Copyright (c) 2006-2008 xine project
|
||||||
|
dnl Copyright (c) 2012 Lucas De Marchi <lucas.de.marchi@gmail.com>
|
||||||
|
dnl
|
||||||
|
dnl This program is free software; you can redistribute it and/or modify
|
||||||
|
dnl it under the terms of the GNU General Public License as published by
|
||||||
|
dnl the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
dnl any later version.
|
||||||
|
dnl
|
||||||
|
dnl This program is distributed in the hope that it will be useful,
|
||||||
|
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
dnl GNU General Public License for more details.
|
||||||
|
dnl
|
||||||
|
dnl You should have received a copy of the GNU General Public License
|
||||||
|
dnl along with this program; if not, write to the Free Software
|
||||||
|
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
dnl 02110-1301, USA.
|
||||||
|
dnl
|
||||||
|
dnl As a special exception, the copyright owners of the
|
||||||
|
dnl macro gives unlimited permission to copy, distribute and modify the
|
||||||
|
dnl configure scripts that are the output of Autoconf when processing the
|
||||||
|
dnl Macro. You need not follow the terms of the GNU General Public
|
||||||
|
dnl License when using or distributing such scripts, even though portions
|
||||||
|
dnl of the text of the Macro appear in them. The GNU General Public
|
||||||
|
dnl License (GPL) does govern all other use of the material that
|
||||||
|
dnl constitutes the Autoconf Macro.
|
||||||
|
dnl
|
||||||
|
dnl This special exception to the GPL applies to versions of the
|
||||||
|
dnl Autoconf Macro released by this project. When you make and
|
||||||
|
dnl distribute a modified version of the Autoconf Macro, you may extend
|
||||||
|
dnl this special exception to the GPL to apply to your modified version as
|
||||||
|
dnl well.
|
||||||
|
|
||||||
|
dnl Check if FLAG in ENV-VAR is supported by compiler and append it
|
||||||
|
dnl to WHERE-TO-APPEND variable
|
||||||
|
dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG])
|
||||||
|
|
||||||
|
AC_DEFUN([CC_CHECK_FLAG_APPEND], [
|
||||||
|
AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2],
|
||||||
|
AS_TR_SH([cc_cv_$2_$3]),
|
||||||
|
[eval "AS_TR_SH([cc_save_$2])='${$2}'"
|
||||||
|
eval "AS_TR_SH([$2])='$3'"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a = 0; int main(void) { return a; } ])],
|
||||||
|
[eval "AS_TR_SH([cc_cv_$2_$3])='yes'"],
|
||||||
|
[eval "AS_TR_SH([cc_cv_$2_$3])='no'"])
|
||||||
|
eval "AS_TR_SH([$2])='$cc_save_$2'"])
|
||||||
|
|
||||||
|
AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes],
|
||||||
|
[eval "$1='${$1} $3'"])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2])
|
||||||
|
AC_DEFUN([CC_CHECK_FLAGS_APPEND], [
|
||||||
|
for flag in $3; do
|
||||||
|
CC_CHECK_FLAG_APPEND($1, $2, $flag)
|
||||||
|
done
|
||||||
|
])
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Check for the presence of an --enable-debug option to configure, with
|
||||||
|
# the specified default value used when the option is not present. Return
|
||||||
|
# the value in the variable $ax_enable_debug.
|
||||||
|
#
|
||||||
|
# Specifying 'yes' adds '-g -O0' to the compilation flags for all
|
||||||
|
# languages. Specifying 'info' adds '-g' to the compilation flags.
|
||||||
|
# Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to
|
||||||
|
# the linking flags. Otherwise, nothing is added.
|
||||||
|
#
|
||||||
|
# Define the variables listed in the second argument if debug is enabled,
|
||||||
|
# defaulting to no variables. Defines the variables listed in the third
|
||||||
|
# argument if debug is disabled, defaulting to NDEBUG. All lists of
|
||||||
|
# variables should be space-separated.
|
||||||
|
#
|
||||||
|
# If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
|
||||||
|
# Should be invoked prior to any AC_PROG_* compiler checks.
|
||||||
|
#
|
||||||
|
# IS-RELEASE can be used to change the default to 'no' when making a
|
||||||
|
# release. Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it
|
||||||
|
# uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE
|
||||||
|
# macro, there is no need to pass this parameter.
|
||||||
|
#
|
||||||
|
# AX_IS_RELEASE([git-directory])
|
||||||
|
# AX_CHECK_ENABLE_DEBUG()
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
|
||||||
|
# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved.
|
||||||
|
|
||||||
|
#serial 5
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
|
||||||
|
AC_BEFORE([$0],[AC_PROG_CC])dnl
|
||||||
|
AC_BEFORE([$0],[AC_PROG_CXX])dnl
|
||||||
|
AC_BEFORE([$0],[AC_PROG_F77])dnl
|
||||||
|
AC_BEFORE([$0],[AC_PROG_FC])dnl
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(whether to enable debugging)
|
||||||
|
|
||||||
|
ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))
|
||||||
|
ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],,
|
||||||
|
[$ax_is_release],
|
||||||
|
[$4])))
|
||||||
|
|
||||||
|
# If this is a release, override the default.
|
||||||
|
AS_IF([test "$ax_enable_debug_is_release" = "yes"],
|
||||||
|
[ax_enable_debug_default="no"])
|
||||||
|
|
||||||
|
m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))])
|
||||||
|
m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(debug,
|
||||||
|
[AS_HELP_STRING([--enable-debug=]@<:@yes/info/profile/no@:>@,[compile with debugging])],
|
||||||
|
[],enable_debug=$ax_enable_debug_default)
|
||||||
|
|
||||||
|
# empty mean debug yes
|
||||||
|
AS_IF([test "x$enable_debug" = "x"],
|
||||||
|
[enable_debug="yes"])
|
||||||
|
|
||||||
|
# case of debug
|
||||||
|
AS_CASE([$enable_debug],
|
||||||
|
[yes],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
CFLAGS="${CFLAGS} -g -O0"
|
||||||
|
CXXFLAGS="${CXXFLAGS} -g -O0"
|
||||||
|
FFLAGS="${FFLAGS} -g -O0"
|
||||||
|
FCFLAGS="${FCFLAGS} -g -O0"
|
||||||
|
OBJCFLAGS="${OBJCFLAGS} -g -O0"
|
||||||
|
],
|
||||||
|
[info],[
|
||||||
|
AC_MSG_RESULT(info)
|
||||||
|
CFLAGS="${CFLAGS} -g"
|
||||||
|
CXXFLAGS="${CXXFLAGS} -g"
|
||||||
|
FFLAGS="${FFLAGS} -g"
|
||||||
|
FCFLAGS="${FCFLAGS} -g"
|
||||||
|
OBJCFLAGS="${OBJCFLAGS} -g"
|
||||||
|
],
|
||||||
|
[profile],[
|
||||||
|
AC_MSG_RESULT(profile)
|
||||||
|
CFLAGS="${CFLAGS} -g -pg"
|
||||||
|
CXXFLAGS="${CXXFLAGS} -g -pg"
|
||||||
|
FFLAGS="${FFLAGS} -g -pg"
|
||||||
|
FCFLAGS="${FCFLAGS} -g -pg"
|
||||||
|
OBJCFLAGS="${OBJCFLAGS} -g -pg"
|
||||||
|
LDFLAGS="${LDFLAGS} -pg"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags
|
||||||
|
dnl by setting any unset environment flag variables
|
||||||
|
AS_IF([test "x${CFLAGS+set}" != "xset"],
|
||||||
|
[CFLAGS=""])
|
||||||
|
AS_IF([test "x${CXXFLAGS+set}" != "xset"],
|
||||||
|
[CXXFLAGS=""])
|
||||||
|
AS_IF([test "x${FFLAGS+set}" != "xset"],
|
||||||
|
[FFLAGS=""])
|
||||||
|
AS_IF([test "x${FCFLAGS+set}" != "xset"],
|
||||||
|
[FCFLAGS=""])
|
||||||
|
AS_IF([test "x${OBJCFLAGS+set}" != "xset"],
|
||||||
|
[OBJCFLAGS=""])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl Define various variables if debugging is disabled.
|
||||||
|
dnl assert.h is a NOP if NDEBUG is defined, so define it by default.
|
||||||
|
AS_IF([test "x$enable_debug" = "xyes"],
|
||||||
|
[m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])],
|
||||||
|
[m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])])
|
||||||
|
ax_enable_debug=$enable_debug
|
||||||
|
])
|
|
@ -0,0 +1,69 @@
|
||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_is_release.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_IS_RELEASE(POLICY)
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Determine whether the code is being configured as a release, or from
|
||||||
|
# git. Set the ax_is_release variable to 'yes' or 'no'.
|
||||||
|
#
|
||||||
|
# If building a release version, it is recommended that the configure
|
||||||
|
# script disable compiler errors and debug features, by conditionalising
|
||||||
|
# them on the ax_is_release variable. If building from git, these
|
||||||
|
# features should be enabled.
|
||||||
|
#
|
||||||
|
# The POLICY parameter specifies how ax_is_release is determined. It can
|
||||||
|
# take the following values:
|
||||||
|
#
|
||||||
|
# * git-directory: ax_is_release will be 'no' if a '.git' directory exists
|
||||||
|
# * minor-version: ax_is_release will be 'no' if the minor version number
|
||||||
|
# in $PACKAGE_VERSION is odd; this assumes
|
||||||
|
# $PACKAGE_VERSION follows the 'major.minor.micro' scheme
|
||||||
|
# * micro-version: ax_is_release will be 'no' if the micro version number
|
||||||
|
# in $PACKAGE_VERSION is odd; this assumes
|
||||||
|
# $PACKAGE_VERSION follows the 'major.minor.micro' scheme
|
||||||
|
# * always: ax_is_release will always be 'yes'
|
||||||
|
# * never: ax_is_release will always be 'no'
|
||||||
|
#
|
||||||
|
# Other policies may be added in future.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 Philip Withnall <philip@tecnocode.co.uk>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved.
|
||||||
|
|
||||||
|
#serial 3
|
||||||
|
|
||||||
|
AC_DEFUN([AX_IS_RELEASE],[
|
||||||
|
AC_BEFORE([AC_INIT],[$0])
|
||||||
|
|
||||||
|
m4_case([$1],
|
||||||
|
[git-directory],[
|
||||||
|
# $is_release = (.git directory does not exist)
|
||||||
|
AS_IF([test -d .git],[ax_is_release=no],[ax_is_release=yes])
|
||||||
|
],
|
||||||
|
[minor-version],[
|
||||||
|
# $is_release = ($minor_version is even)
|
||||||
|
minor_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
|
||||||
|
AS_IF([test "$(( $minor_version % 2 ))" -ne 0],
|
||||||
|
[ax_is_release=no],[ax_is_release=yes])
|
||||||
|
],
|
||||||
|
[micro-version],[
|
||||||
|
# $is_release = ($micro_version is even)
|
||||||
|
micro_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]]*\.[[^.]]*\.\([[^.]]*\).*/\1/'`
|
||||||
|
AS_IF([test "$(( $micro_version % 2 ))" -ne 0],
|
||||||
|
[ax_is_release=no],[ax_is_release=yes])
|
||||||
|
],
|
||||||
|
[always],[ax_is_release=yes],
|
||||||
|
[never],[ax_is_release=no],
|
||||||
|
[
|
||||||
|
AC_MSG_ERROR([Invalid policy. Valid policies: git-directory, minor-version.])
|
||||||
|
])
|
||||||
|
])
|
|
@ -0,0 +1,116 @@
|
||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_perl_ext_flags.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_PERL_EXT_FLAGS([CFLAGS-VARIABLE], [LDFLAGS-VARIABLE], [EXTRA-MODULES])
|
||||||
|
# AX_PERL_EXT_CFLAGS([CFLAGS-VARIABLE])
|
||||||
|
# AX_PERL_EXT_LDFLAGS([LDFLAGS-VARIABLE], [EXTRA-MODULES])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Fetches the linker flags and C compiler flags for compiling and linking
|
||||||
|
# programs that embed a Perl interpreter. If the EXTRA-MODULES argument is
|
||||||
|
# submitted, it is a space separated list of extra modules to link. The
|
||||||
|
# flags will be stored in the provided variables.
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
#
|
||||||
|
# AX_PERL_EXT_FLAGS([PERLXS_CFLAGS], [PERLXS_LDFLAGS])
|
||||||
|
# AC_SUBST([PERLXS_CFLAGS])
|
||||||
|
# AC_SUBST([PERLXS_LDFLAGS])
|
||||||
|
#
|
||||||
|
# AX_PERL_EXT_CFLAGS([PERLXS_CFLAGS])
|
||||||
|
# AC_SUBST([PERLXS_CFLAGS])
|
||||||
|
#
|
||||||
|
# AX_PERL_EXT_LDFLAGS([PERLXS_LDFLAGS], [-std Socket])
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 Mats Kindahl of Sun Microsystems <mats@sun.com>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are
|
||||||
|
# met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# 3. The name of the author may not be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#serial 5
|
||||||
|
|
||||||
|
AC_DEFUN([AX_PERL_EXT_CFLAGS],
|
||||||
|
[AC_CHECK_PROG(PERL,perl,perl)
|
||||||
|
_AX_PERL_EXT_MODULE_CHECK([ExtUtils::Embed], [have_embed=yes],
|
||||||
|
[have_embed=no])
|
||||||
|
AS_IF([test $have_embed = no],
|
||||||
|
AC_MSG_ERROR([Require ExtUtils::Embed to proceed]))
|
||||||
|
_AX_PERL_EXT_EMBED_CHECK([$1],[ccopts])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
AC_DEFUN([AX_PERL_EXT_LDFLAGS],
|
||||||
|
[AC_CHECK_PROG(PERL,perl,perl)
|
||||||
|
_AX_PERL_EXT_MODULE_CHECK([ExtUtils::Embed], [have_embed=yes],
|
||||||
|
[have_embed=no])
|
||||||
|
AS_IF([test $have_embed = no],
|
||||||
|
AC_MSG_ERROR([Require ExtUtils::Embed to proceed]))
|
||||||
|
_AX_PERL_EXT_EMBED_CHECK([$1],[ldopts],[$2])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
AC_DEFUN([AX_PERL_EXT_FLAGS],
|
||||||
|
[AC_CHECK_PROG(PERL,perl,perl)
|
||||||
|
_AX_PERL_EXT_MODULE_CHECK([ExtUtils::Embed], [have_embed=yes],
|
||||||
|
[have_embed=no])
|
||||||
|
AS_IF([test $have_embed = no],
|
||||||
|
AC_MSG_ERROR([Require ExtUtils::Embed to proceed]))
|
||||||
|
_AX_PERL_EXT_EMBED_CHECK([$1],[ccopts])
|
||||||
|
_AX_PERL_EXT_EMBED_CHECK([$2],[ldopts],[$3])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl _AX_PERL_EXT_MODULE_CHECK(MODULE-NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
|
||||||
|
dnl
|
||||||
|
dnl Check for the existance of the perl module given by MODULE-NAME.
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([_AX_PERL_EXT_MODULE_CHECK],
|
||||||
|
[AC_MSG_CHECKING([for perl module $1])
|
||||||
|
$PERL "-M$1" -e exit > /dev/null 2>&1
|
||||||
|
AS_IF([test $? -eq 0],
|
||||||
|
[AC_MSG_RESULT(yes)
|
||||||
|
$2],
|
||||||
|
[AC_MSG_RESULT(no)
|
||||||
|
$3])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl _AX_PERL_EXT_EMBED_CHECK(VARIABLE, COMMAND, [EXTRA-FLAGS]) Use
|
||||||
|
dnl
|
||||||
|
dnl ExtUtils::Embed fetch flags for embedding Perl in a C/C++
|
||||||
|
dnl application
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([_AX_PERL_EXT_EMBED_CHECK],
|
||||||
|
[AC_MSG_CHECKING([for perl $2 embed flags])
|
||||||
|
ax_c_perlxs_extras="$3"
|
||||||
|
$1=`$PERL -MExtUtils::Embed -e $2 ${ax_c_perlxs_extras:+"-- $3"}`
|
||||||
|
AC_MSG_RESULT($$1)
|
||||||
|
])
|
|
@ -0,0 +1,37 @@
|
||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_REQUIRE_DEFINED(MACRO)
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
|
||||||
|
# been defined and thus are available for use. This avoids random issues
|
||||||
|
# where a macro isn't expanded. Instead the configure script emits a
|
||||||
|
# non-fatal:
|
||||||
|
#
|
||||||
|
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
|
||||||
|
#
|
||||||
|
# It's like AC_REQUIRE except it doesn't expand the required macro.
|
||||||
|
#
|
||||||
|
# Here's an example:
|
||||||
|
#
|
||||||
|
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
|
# warranty.
|
||||||
|
|
||||||
|
#serial 1
|
||||||
|
|
||||||
|
AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
|
||||||
|
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
|
||||||
|
])dnl AX_REQUIRE_DEFINED
|
|
@ -0,0 +1,8 @@
|
||||||
|
analysis_verbose = $(analysis_verbose_$(V))
|
||||||
|
analysis_verbose_ = $(analysis_verbose_$(AM_DEFAULT_VERBOSITY))
|
||||||
|
analysis_verbose_0 = @echo " CCSA " $@; $(COMPILE) --analyze $< -o $@;
|
||||||
|
analysis_verbose_1 = $(COMPILE) --analyze $< -o $@;
|
||||||
|
|
||||||
|
%.plist: %.c
|
||||||
|
$(analysis_verbose)
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
<app-bundle>
|
<app-bundle>
|
||||||
|
|
||||||
<meta>
|
<meta>
|
||||||
<prefix name="default">${env:JHBUILD_PREFIX}</prefix>
|
<prefix name="default">/usr/local</prefix>
|
||||||
|
<prefix name="enchant">/usr/local/opt/enchant-applespell</prefix>
|
||||||
<destination overwrite="yes">${project}</destination>
|
<destination overwrite="yes">${project}</destination>
|
||||||
|
|
||||||
<run-install-name-tool/>
|
<run-install-name-tool/>
|
||||||
|
@ -21,25 +22,12 @@
|
||||||
</binary>
|
</binary>
|
||||||
|
|
||||||
<binary>
|
<binary>
|
||||||
${prefix}/lib/libenchant.dylib
|
${prefix:enchant}/lib/libenchant.dylib
|
||||||
</binary>
|
</binary>
|
||||||
<binary>
|
<binary>
|
||||||
${prefix}/lib/enchant/libenchant_applespell.so
|
${prefix:enchant}/lib/enchant/libenchant_applespell.so
|
||||||
</binary>
|
</binary>
|
||||||
|
|
||||||
<binary dest="${bundle}/Contents/MacOS">
|
|
||||||
${prefix}/bin/python
|
|
||||||
</binary>
|
|
||||||
<binary>
|
|
||||||
${prefix}/lib/libpython2.7.dylib
|
|
||||||
</binary>
|
|
||||||
<data>
|
|
||||||
${prefix}/lib/python2.7/
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
${prefix}/include/python2.7/pyconfig.h
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<binary>
|
<binary>
|
||||||
${prefix}/lib/${gtkdir}/modules/*.so
|
${prefix}/lib/${gtkdir}/modules/*.so
|
||||||
</binary>
|
</binary>
|
||||||
|
@ -59,7 +47,7 @@
|
||||||
${prefix}/lib/pango/${pkg:pango:pango_module_version}/modules/
|
${prefix}/lib/pango/${pkg:pango:pango_module_version}/modules/
|
||||||
</binary>
|
</binary>
|
||||||
<data>
|
<data>
|
||||||
${prefix}/share/themes/Mac/
|
${prefix}/share/themes/Mac/gtk-2.0-key/gtkrc
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<translations name="gtk20">
|
<translations name="gtk20">
|
||||||
|
@ -77,7 +65,4 @@
|
||||||
${project}/hexchat.icns
|
${project}/hexchat.icns
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<!-- icon-theme icons="none">
|
|
||||||
</icon-theme -->
|
|
||||||
|
|
||||||
</app-bundle>
|
</app-bundle>
|
||||||
|
|
|
@ -36,10 +36,6 @@ export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders"
|
||||||
export PANGO_LIBDIR="$bundle_lib"
|
export PANGO_LIBDIR="$bundle_lib"
|
||||||
export PANGO_SYSCONFDIR="$bundle_etc"
|
export PANGO_SYSCONFDIR="$bundle_etc"
|
||||||
|
|
||||||
export PYTHON="$bundle_contents/MacOS/python"
|
|
||||||
export PYTHONHOME="$bundle_res"
|
|
||||||
export PYTHONPATH="$bundle_lib/python2.7:$bundle_lib/python2.7/site-packages"
|
|
||||||
|
|
||||||
export OPENSSL_CONF="/System/Library/OpenSSL/openssl.cnf"
|
export OPENSSL_CONF="/System/Library/OpenSSL/openssl.cnf"
|
||||||
|
|
||||||
export HEXCHAT_LIBDIR="$bundle_lib/hexchat/plugins"
|
export HEXCHAT_LIBDIR="$bundle_lib/hexchat/plugins"
|
||||||
|
|
|
@ -1,24 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -z "$JHBUILD_PREFIX" ]; then
|
|
||||||
echo "You must run this within a jhbuild shell."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f $JHBUILD_PREFIX/bin/python ]; then
|
|
||||||
echo "You must install python with jhbuild."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf HexChat.app
|
rm -rf HexChat.app
|
||||||
rm -f *.app.zip
|
rm -f *.app.zip
|
||||||
|
|
||||||
$JHBUILD_PREFIX/bin/python $HOME/.local/bin/gtk-mac-bundler hexchat.bundle
|
python $HOME/.local/bin/gtk-mac-bundler hexchat.bundle
|
||||||
|
|
||||||
# These take up a lot of space in the bundle
|
|
||||||
echo "Cleaning up python files"
|
|
||||||
find ./HexChat.app/Contents/Resources/lib/python2.7 -name "*.pyc" -delete
|
|
||||||
find ./HexChat.app/Contents/Resources/lib/python2.7 -name "*.pyo" -delete
|
|
||||||
|
|
||||||
echo "Compressing bundle"
|
echo "Compressing bundle"
|
||||||
#hdiutil create -format UDBZ -srcdir HexChat.app -quiet HexChat-2.9.6.1-$(git rev-parse --short master).dmg
|
#hdiutil create -format UDBZ -srcdir HexChat.app -quiet HexChat-2.9.6.1-$(git rev-parse --short master).dmg
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
# Makefile stub for creating standalone plugin distributions.
|
|
||||||
|
|
||||||
plugin_dist: pg_dist pg_dist/config.status
|
|
||||||
pgi=`cd $(srcdir)/.. && pwd`; cd pg_dist; \
|
|
||||||
$(MAKE) $(AM_MAKEFLAGS) PLUGIN_INCLUDES=-I$$pgi distcheck dist
|
|
||||||
|
|
||||||
pg_dist: pg_distdir pg_dist/configure.in pg_dist/install-sh
|
|
||||||
cd pg_dist \
|
|
||||||
&& libtoolize --copy --force --automake \
|
|
||||||
&& automake --copy --add-missing --foreign \
|
|
||||||
&& autoconf -l ../$(top_srcdir)
|
|
||||||
|
|
||||||
pg_distdir: $(DISTFILES)
|
|
||||||
test -d pg_dist || mkdir pg_dist
|
|
||||||
for dfile in $(DISTFILES); do \
|
|
||||||
test -f $$dfile && cp $$dfile pg_dist \
|
|
||||||
|| test -f $(srcdir)/$$dfile && cp $(srcdir)/$$dfile pg_dist; done
|
|
||||||
sed '/Make.plugin/d' < $(srcdir)/Makefile.am > pg_dist/Makefile.am
|
|
||||||
|
|
||||||
pg_dist/configure.in: $(srcdir)/../plugin-conf.in
|
|
||||||
rm -f pg_dist/configure.in
|
|
||||||
test -f $(srcdir)/config.stub \
|
|
||||||
&& cat $(srcdir)/config.stub > pg_dist/configure.in || true
|
|
||||||
cat $(srcdir)/../plugin-conf.in | \
|
|
||||||
sed 's%@PLUGIN_VERSION@%$(PLUGIN_VERSION)%; \
|
|
||||||
s%@PLUGIN@%$(PLUGIN)%' >> pg_dist/configure.in
|
|
||||||
|
|
||||||
pg_dist/install-sh: pg_distdir
|
|
||||||
cp $(top_srcdir)/install-sh pg_dist
|
|
||||||
|
|
||||||
pg_dist/config.status: pg_dist/configure
|
|
||||||
cd pg_dist \
|
|
||||||
&& test -f config.status && $(SHELL) ./config.status --recheck \
|
|
||||||
|| $(SHELL) ./configure --enable-maintainer-mode
|
|
||||||
|
|
||||||
DISTCLEANFILES = pg_dist/* pg_dist
|
|
||||||
|
|
||||||
#
|
|
|
@ -2,6 +2,6 @@ libdir = $(hexchatlibdir)
|
||||||
|
|
||||||
lib_LTLIBRARIES = checksum.la
|
lib_LTLIBRARIES = checksum.la
|
||||||
checksum_la_SOURCES = checksum.c
|
checksum_la_SOURCES = checksum.c
|
||||||
checksum_la_LDFLAGS = -avoid-version -module
|
checksum_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
|
||||||
checksum_la_LIBADD =
|
checksum_la_LIBADD = $(GLIB_LIBS)
|
||||||
AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/../../src/common
|
checksum_la_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)/src/common
|
||||||
|
|
|
@ -20,131 +20,40 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#include "config.h"
|
||||||
#define __AVAILABILITYMACROS__
|
|
||||||
#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <openssl/sha.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#ifdef WIN32
|
#include <gio/gio.h>
|
||||||
#ifndef snprintf
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
#define stat _stat64
|
|
||||||
#else
|
|
||||||
/* for INT_MAX */
|
|
||||||
#include <limits.h>
|
|
||||||
#define __USE_LARGEFILE64
|
|
||||||
#define _LARGEFILE_SOURCE
|
|
||||||
#define _LARGEFILE64_SOURCE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
|
|
||||||
#define BUFSIZE 32768
|
#define BUFSIZE 32768
|
||||||
#define DEFAULT_LIMIT 256 /* default size is 256 MiB */
|
#define DEFAULT_LIMIT 256 /* default size is 256 MiB */
|
||||||
|
#define SHA256_DIGEST_LENGTH 32
|
||||||
|
#define SHA256_BUFFER_LENGTH 65
|
||||||
|
|
||||||
static hexchat_plugin *ph; /* plugin handle */
|
static hexchat_plugin *ph; /* plugin handle */
|
||||||
static char name[] = "Checksum";
|
static char name[] = "Checksum";
|
||||||
static char desc[] = "Calculate checksum for DCC file transfers";
|
static char desc[] = "Calculate checksum for DCC file transfers";
|
||||||
static char version[] = "3.1";
|
static char version[] = "3.1";
|
||||||
|
|
||||||
/* Use of OpenSSL SHA256 interface: http://adamlamers.com/?p=5 */
|
|
||||||
static void
|
static void
|
||||||
sha256_hash_string (unsigned char hash[SHA256_DIGEST_LENGTH], char outputBuffer[65])
|
set_limit (char *size)
|
||||||
{
|
{
|
||||||
int i;
|
int limit = atoi (size);
|
||||||
for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
|
|
||||||
|
if (limit > 0 && limit < INT_MAX)
|
||||||
{
|
{
|
||||||
sprintf (outputBuffer + (i * 2), "%02x", hash[i]);
|
if (hexchat_pluginpref_set_int (ph, "limit", limit))
|
||||||
}
|
hexchat_printf (ph, "Checksum: File size limit has successfully been set to: %d MiB\n", limit);
|
||||||
outputBuffer[64] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void
|
|
||||||
sha256 (char *string, char outputBuffer[65])
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
unsigned char hash[SHA256_DIGEST_LENGTH];
|
|
||||||
SHA256_CTX sha256;
|
|
||||||
|
|
||||||
SHA256_Init (&sha256);
|
|
||||||
SHA256_Update (&sha256, string, strlen (string));
|
|
||||||
SHA256_Final (hash, &sha256);
|
|
||||||
|
|
||||||
for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
|
|
||||||
{
|
|
||||||
sprintf (outputBuffer + (i * 2), "%02x", hash[i]);
|
|
||||||
}
|
|
||||||
outputBuffer[64] = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
|
||||||
sha256_file (char *path, char outputBuffer[65])
|
|
||||||
{
|
|
||||||
int bytesRead;
|
|
||||||
unsigned char *buffer;
|
|
||||||
unsigned char hash[SHA256_DIGEST_LENGTH];
|
|
||||||
SHA256_CTX sha256;
|
|
||||||
|
|
||||||
FILE *file = fopen (path, "rb");
|
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
return -534;
|
|
||||||
}
|
|
||||||
|
|
||||||
SHA256_Init (&sha256);
|
|
||||||
buffer = malloc (BUFSIZE);
|
|
||||||
bytesRead = 0;
|
|
||||||
|
|
||||||
if (!buffer)
|
|
||||||
{
|
|
||||||
fclose (file);
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((bytesRead = fread (buffer, 1, BUFSIZE, file)))
|
|
||||||
{
|
|
||||||
SHA256_Update (&sha256, buffer, bytesRead);
|
|
||||||
}
|
|
||||||
|
|
||||||
SHA256_Final (hash, &sha256);
|
|
||||||
sha256_hash_string (hash, outputBuffer);
|
|
||||||
|
|
||||||
fclose (file);
|
|
||||||
free (buffer);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
set_limit (char* size)
|
|
||||||
{
|
|
||||||
int buffer = atoi (size);
|
|
||||||
|
|
||||||
if (buffer > 0 && buffer < INT_MAX)
|
|
||||||
{
|
|
||||||
if (hexchat_pluginpref_set_int (ph, "limit", buffer))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "File size limit has successfully been set to: %d MiB\n", buffer);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
hexchat_printf (ph, "Checksum: File access error while saving!\n");
|
||||||
hexchat_printf (ph, "File access error while saving!\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hexchat_printf (ph, "Invalid input!\n");
|
hexchat_printf (ph, "Checksum: Invalid input!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,89 +62,152 @@ get_limit ()
|
||||||
{
|
{
|
||||||
int size = hexchat_pluginpref_get_int (ph, "limit");
|
int size = hexchat_pluginpref_get_int (ph, "limit");
|
||||||
|
|
||||||
if (size <= -1 || size >= INT_MAX)
|
if (size <= 0 || size >= INT_MAX)
|
||||||
{
|
|
||||||
return DEFAULT_LIMIT;
|
return DEFAULT_LIMIT;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return size;
|
return size;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
print_limit ()
|
check_limit (GFile *file)
|
||||||
{
|
{
|
||||||
hexchat_printf (ph, "File size limit for checksums: %d MiB", get_limit ());
|
GFileInfo *file_info;
|
||||||
|
goffset file_size;
|
||||||
|
|
||||||
|
file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
if (!file_info)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
file_size = g_file_info_get_size (file_info);
|
||||||
|
g_object_unref (file_info);
|
||||||
|
|
||||||
|
if (file_size > get_limit () * 1048576ll)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
sha256_from_stream (GFileInputStream *file_stream, char out_buf[])
|
||||||
|
{
|
||||||
|
GChecksum *checksum;
|
||||||
|
gssize bytes_read;
|
||||||
|
guint8 digest[SHA256_DIGEST_LENGTH];
|
||||||
|
gsize digest_len = sizeof(digest);
|
||||||
|
guchar buffer[BUFSIZE];
|
||||||
|
gsize i;
|
||||||
|
|
||||||
|
checksum = g_checksum_new (G_CHECKSUM_SHA256);
|
||||||
|
|
||||||
|
while ((bytes_read = g_input_stream_read (G_INPUT_STREAM (file_stream), buffer, sizeof (buffer), NULL, NULL)))
|
||||||
|
{
|
||||||
|
if (bytes_read == -1)
|
||||||
|
{
|
||||||
|
g_checksum_free (checksum);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_checksum_update (checksum, buffer, bytes_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_checksum_get_digest (checksum, digest, &digest_len);
|
||||||
|
g_checksum_free (checksum);
|
||||||
|
|
||||||
|
for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
|
||||||
|
{
|
||||||
|
/* out_buf will be exactly SHA256_BUFFER_LENGTH including null */
|
||||||
|
g_sprintf (out_buf + (i * 2), "%02x", digest[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
sha256_from_file (char *filename, char out_buf[])
|
||||||
|
{
|
||||||
|
GFileInputStream *file_stream;
|
||||||
|
char *filename_fs;
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
|
filename_fs = g_filename_from_utf8 (filename, -1, NULL, NULL, NULL);
|
||||||
|
if (!filename_fs)
|
||||||
|
{
|
||||||
|
hexchat_printf (ph, "Checksum: Invalid filename (%s)\n", filename);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
file = g_file_new_for_path (filename_fs);
|
||||||
|
g_free (filename_fs);
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
hexchat_printf (ph, "Checksum: Failed to open %s\n", filename);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!check_limit (file))
|
||||||
|
{
|
||||||
|
hexchat_printf (ph, "Checksum: %s is larger than size limit. You can increase it with /CHECKSUM SET.\n", filename);
|
||||||
|
g_object_unref (file);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_stream = g_file_read (file, NULL, NULL);
|
||||||
|
if (!file_stream)
|
||||||
|
{
|
||||||
|
hexchat_printf (ph, "Checksum: Failed to read file %s\n", filename);
|
||||||
|
g_object_unref (file);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sha256_from_stream (file_stream, out_buf))
|
||||||
|
{
|
||||||
|
hexchat_printf (ph, "Checksum: Failed to generate checksum for %s\n", filename);
|
||||||
|
g_object_unref (file_stream);
|
||||||
|
g_object_unref (file);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (file_stream);
|
||||||
|
g_object_unref (file);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dccrecv_cb (char *word[], void *userdata)
|
dccrecv_cb (char *word[], void *userdata)
|
||||||
{
|
{
|
||||||
int result;
|
const char *dcc_completed_dir;
|
||||||
struct stat buffer; /* buffer for storing file info */
|
char *filename, checksum[SHA256_BUFFER_LENGTH];
|
||||||
char sum[65]; /* buffer for checksum */
|
|
||||||
const char *file;
|
|
||||||
char *cfile;
|
|
||||||
|
|
||||||
if (hexchat_get_prefs (ph, "dcc_completed_dir", &file, NULL) == 1 && file[0] != 0)
|
/* Print in the privmsg tab of the sender */
|
||||||
{
|
hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3]));
|
||||||
cfile = g_strconcat (file, G_DIR_SEPARATOR_S, word[1], NULL);
|
|
||||||
}
|
if (hexchat_get_prefs (ph, "dcc_completed_dir", &dcc_completed_dir, NULL) == 1 && dcc_completed_dir[0] != '\0')
|
||||||
|
filename = g_build_filename (dcc_completed_dir, word[1], NULL);
|
||||||
else
|
else
|
||||||
|
filename = g_strdup (word[2]);
|
||||||
|
|
||||||
|
if (sha256_from_file (filename, checksum))
|
||||||
{
|
{
|
||||||
cfile = g_strdup(word[2]);
|
hexchat_printf (ph, "SHA-256 checksum for %s (local): %s\n", word[1], checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = stat (cfile, &buffer);
|
g_free (filename);
|
||||||
if (result == 0) /* stat returns 0 on success */
|
|
||||||
{
|
|
||||||
if (buffer.st_size <= (unsigned long long) get_limit () * 1048576)
|
|
||||||
{
|
|
||||||
sha256_file (cfile, sum); /* file is the full filename even if completed dir set */
|
|
||||||
/* try to print the checksum in the privmsg tab of the sender */
|
|
||||||
hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3]));
|
|
||||||
hexchat_printf (ph, "SHA-256 checksum for %s (local): %s\n", word[1], sum);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3]));
|
|
||||||
hexchat_printf (ph, "SHA-256 checksum for %s (local): (size limit reached, no checksum calculated, you can increase it with /CHECKSUM INC)\n", word[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "File access error!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (cfile);
|
|
||||||
return HEXCHAT_EAT_NONE;
|
return HEXCHAT_EAT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dccoffer_cb (char *word[], void *userdata)
|
dccoffer_cb (char *word[], void *userdata)
|
||||||
{
|
{
|
||||||
int result;
|
char checksum[SHA256_BUFFER_LENGTH];
|
||||||
struct stat buffer; /* buffer for storing file info */
|
|
||||||
char sum[65]; /* buffer for checksum */
|
|
||||||
|
|
||||||
result = stat (word[3], &buffer);
|
/* Print in the privmsg tab of the receiver */
|
||||||
if (result == 0) /* stat returns 0 on success */
|
hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3]));
|
||||||
|
|
||||||
|
if (sha256_from_file (word[3], checksum))
|
||||||
{
|
{
|
||||||
if (buffer.st_size <= (unsigned long long) get_limit () * 1048576)
|
hexchat_commandf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): %s", word[2], word[1], checksum);
|
||||||
{
|
|
||||||
sha256_file (word[3], sum); /* word[3] is the full filename */
|
|
||||||
hexchat_commandf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): %s", word[2], word[1], sum);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3]));
|
|
||||||
hexchat_printf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): (size limit reached, no checksum calculated)", word[2], word[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "File access error!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return HEXCHAT_EAT_NONE;
|
return HEXCHAT_EAT_NONE;
|
||||||
|
@ -246,7 +218,7 @@ checksum (char *word[], char *word_eol[], void *userdata)
|
||||||
{
|
{
|
||||||
if (!g_ascii_strcasecmp ("GET", word[2]))
|
if (!g_ascii_strcasecmp ("GET", word[2]))
|
||||||
{
|
{
|
||||||
print_limit ();
|
hexchat_printf (ph, "File size limit for checksums: %d MiB", get_limit ());
|
||||||
}
|
}
|
||||||
else if (!g_ascii_strcasecmp ("SET", word[2]))
|
else if (!g_ascii_strcasecmp ("SET", word[2]))
|
||||||
{
|
{
|
||||||
|
@ -259,7 +231,7 @@ checksum (char *word[], char *word_eol[], void *userdata)
|
||||||
hexchat_printf (ph, " SET <filesize> - set the maximum file size (in MiB) to be hashed\n");
|
hexchat_printf (ph, " SET <filesize> - set the maximum file size (in MiB) to be hashed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return HEXCHAT_EAT_NONE;
|
return HEXCHAT_EAT_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -277,7 +249,7 @@ hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **p
|
||||||
hexchat_pluginpref_set_int (ph, "limit", DEFAULT_LIMIT);
|
hexchat_pluginpref_set_int (ph, "limit", DEFAULT_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
hexchat_hook_command (ph, "CHECKSUM", HEXCHAT_PRI_NORM, checksum, "Usage: /CHECKSUM GET|SET", 0);
|
hexchat_hook_command (ph, "CHECKSUM", HEXCHAT_PRI_NORM, checksum, "Usage: /CHECKSUM GET|SET", NULL);
|
||||||
hexchat_hook_print (ph, "DCC RECV Complete", HEXCHAT_PRI_NORM, dccrecv_cb, NULL);
|
hexchat_hook_print (ph, "DCC RECV Complete", HEXCHAT_PRI_NORM, dccrecv_cb, NULL);
|
||||||
hexchat_hook_print (ph, "DCC Offer", HEXCHAT_PRI_NORM, dccoffer_cb, NULL);
|
hexchat_hook_print (ph, "DCC Offer", HEXCHAT_PRI_NORM, dccoffer_cb, NULL);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,57 +20,19 @@
|
||||||
<RootNamespace>checksum</RootNamespace>
|
<RootNamespace>checksum</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcchecksum</TargetName>
|
<TargetName>hcchecksum</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcchecksum</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CHECKSUM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CHECKSUM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>checksum.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>checksum.def</ModuleDefinitionFile>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
@ -77,19 +40,10 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;CHECKSUM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;CHECKSUM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>checksum.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>checksum.def</ModuleDefinitionFile>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
@ -102,6 +56,4 @@
|
||||||
<None Include="checksum.def" />
|
<None Include="checksum.def" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ libdir = $(hexchatlibdir)
|
||||||
|
|
||||||
lib_LTLIBRARIES = doat.la
|
lib_LTLIBRARIES = doat.la
|
||||||
doat_la_SOURCES = doat.c
|
doat_la_SOURCES = doat.c
|
||||||
doat_la_LDFLAGS = -avoid-version -module
|
doat_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
|
||||||
doat_la_LIBADD =
|
doat_la_LIBADD = $(GLIB_LIBS)
|
||||||
AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/../../src/common
|
doat_la_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)/src/common
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
* http://sam.zoy.org/wtfpl/COPYING or http://lwsitu.com/xchat/COPYING
|
* http://sam.zoy.org/wtfpl/COPYING or http://lwsitu.com/xchat/COPYING
|
||||||
* for more details. */
|
* for more details. */
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <glib.h>
|
||||||
#include "hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
|
|
||||||
static hexchat_plugin *ph;
|
static hexchat_plugin *ph;
|
||||||
|
@ -31,7 +34,7 @@ parse_command( char *word[], char *word_eol[], void *userdata ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = strdup( token );
|
channel = g_strdup( token );
|
||||||
|
|
||||||
delimiter = strchr( channel, '/' );
|
delimiter = strchr( channel, '/' );
|
||||||
|
|
||||||
|
@ -40,13 +43,13 @@ parse_command( char *word[], char *word_eol[], void *userdata ) {
|
||||||
*delimiter = '\0';
|
*delimiter = '\0';
|
||||||
|
|
||||||
if( strlen( delimiter + 1 ) > 0 ) {
|
if( strlen( delimiter + 1 ) > 0 ) {
|
||||||
server = strdup( delimiter + 1 );
|
server = g_strdup( delimiter + 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* /Network form */
|
/* /Network form */
|
||||||
if( strlen( channel ) == 0 ) {
|
if( strlen( channel ) == 0 ) {
|
||||||
free( channel );
|
g_free( channel );
|
||||||
channel = NULL;
|
channel = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,13 +61,8 @@ parse_command( char *word[], char *word_eol[], void *userdata ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( channel != NULL ) {
|
g_free( channel );
|
||||||
free( channel );
|
g_free( server );
|
||||||
}
|
|
||||||
|
|
||||||
if( server != NULL ) {
|
|
||||||
free( server );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
return HEXCHAT_EAT_HEXCHAT;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,75 +20,32 @@
|
||||||
<RootNamespace>doat</RootNamespace>
|
<RootNamespace>doat</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcdoat</TargetName>
|
<TargetName>hcdoat</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcdoat</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\common;$(HexChatLib);$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>doat.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>doat.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\common;$(HexChatLib);$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>doat.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>doat.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -98,6 +56,4 @@
|
||||||
<None Include="doat.def" />
|
<None Include="doat.def" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,75 +20,28 @@
|
||||||
<RootNamespace>exec</RootNamespace>
|
<RootNamespace>exec</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcexec</TargetName>
|
<TargetName>hcexec</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcexec</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;EXEC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;EXEC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>exec.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>exec.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;EXEC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;EXEC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>exec.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>exec.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -98,6 +52,4 @@
|
||||||
<ClCompile Include="exec.c" />
|
<ClCompile Include="exec.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ EXTRA_DIST = INSTALL LICENSE
|
||||||
libdir = $(hexchatlibdir)
|
libdir = $(hexchatlibdir)
|
||||||
|
|
||||||
lib_LTLIBRARIES = fishlim.la
|
lib_LTLIBRARIES = fishlim.la
|
||||||
fishlim_la_SOURCES = fish.c irc.c keystore.c misc.c plugin_hexchat.c
|
fishlim_la_SOURCES = fish.c irc.c keystore.c plugin_hexchat.c
|
||||||
fishlim_la_LDFLAGS = -avoid-version -module
|
fishlim_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
|
||||||
fishlim_la_LIBADD =
|
fishlim_la_LIBADD = $(GLIB_LIBS) $(OPENSSL_LIBS)
|
||||||
AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/../../src/common
|
fishlim_la_CFLAGS = $(GLIB_CFLAGS) $(OPENSSL_CFLAGS) -I$(top_srcdir)/src/common
|
||||||
|
|
|
@ -39,17 +39,17 @@ static const char fish_base64[64] = "./0123456789abcdefghijklmnopqrstuvwxyzABCDE
|
||||||
static const signed char fish_unbase64[256] = {
|
static const signed char fish_unbase64[256] = {
|
||||||
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB,
|
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB,
|
||||||
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB,
|
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB,
|
||||||
// ! " # $ % & ' ( ) * + , - . /
|
/* ! " # $ % & ' ( ) * + , - . / */
|
||||||
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB, 0, 1,
|
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB, 0, 1,
|
||||||
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
|
/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
|
||||||
2, 3, 4, 5, 6, 7, 8, 9, 10,11,IB,IB,IB,IB,IB,IB,
|
2, 3, 4, 5, 6, 7, 8, 9, 10,11,IB,IB,IB,IB,IB,IB,
|
||||||
// @ A B C D E F G H I J K L M N O
|
/* @ A B C D E F G H I J K L M N O */
|
||||||
IB,38,39,40,41,42,43,44, 45,46,47,48,49,50,51,52,
|
IB,38,39,40,41,42,43,44, 45,46,47,48,49,50,51,52,
|
||||||
// P Q R S T U V W X Y Z [ \ ] ^ _
|
/* P Q R S T U V W X Y Z [ \ ] ^ _*/
|
||||||
53,54,55,56,57,58,59,60, 61,62,63,IB,IB,IB,IB,IB,
|
53,54,55,56,57,58,59,60, 61,62,63,IB,IB,IB,IB,IB,
|
||||||
// ` a b c d e f g h i j k l m n o
|
/* ` a b c d e f g h i j k l m n o */
|
||||||
IB,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26,
|
IB,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26,
|
||||||
// p q r s t u v w x y z { | } ~ <del>
|
/* p q r s t u v w x y z { | } ~ <del> */
|
||||||
27,28,29,30,31,32,33,34, 35,36,37,IB,IB,IB,IB,IB,
|
27,28,29,30,31,32,33,34, 35,36,37,IB,IB,IB,IB,IB,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,12 +75,11 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) {
|
||||||
|
|
||||||
messagelen = strlen(message);
|
messagelen = strlen(message);
|
||||||
if (messagelen == 0) return NULL;
|
if (messagelen == 0) return NULL;
|
||||||
encrypted = malloc(((messagelen-1)/8)*12 + 12 + 1); // each 8-byte block becomes 12 bytes
|
encrypted = g_malloc(((messagelen - 1) / 8) * 12 + 12 + 1); /* each 8-byte block becomes 12 bytes */
|
||||||
end = encrypted;
|
end = encrypted;
|
||||||
if (!encrypted) return NULL;
|
|
||||||
|
|
||||||
while (*message) {
|
while (*message) {
|
||||||
// Read 8 bytes (a Blowfish block)
|
/* Read 8 bytes (a Blowfish block) */
|
||||||
BF_LONG binary[2] = { 0, 0 };
|
BF_LONG binary[2] = { 0, 0 };
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
|
@ -90,10 +89,10 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) {
|
||||||
}
|
}
|
||||||
message += 8;
|
message += 8;
|
||||||
|
|
||||||
// Encrypt block
|
/* Encrypt block */
|
||||||
BF_encrypt(binary, &bfkey);
|
BF_encrypt(binary, &bfkey);
|
||||||
|
|
||||||
// Emit FiSH-BASE64
|
/* Emit FiSH-BASE64 */
|
||||||
bit = 0;
|
bit = 0;
|
||||||
word = 1;
|
word = 1;
|
||||||
for (j = 0; j < 12; j++) {
|
for (j = 0; j < 12; j++) {
|
||||||
|
@ -106,7 +105,7 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop if a null terminator was found
|
/* Stop if a null terminator was found */
|
||||||
if (c == '\0') break;
|
if (c == '\0') break;
|
||||||
}
|
}
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
|
@ -124,12 +123,11 @@ char *fish_decrypt(const char *key, size_t keylen, const char *data) {
|
||||||
unsigned char d;
|
unsigned char d;
|
||||||
BF_set_key(&bfkey, keylen, (const unsigned char*)key);
|
BF_set_key(&bfkey, keylen, (const unsigned char*)key);
|
||||||
|
|
||||||
decrypted = malloc(strlen(data)+1);
|
decrypted = g_malloc(strlen(data) + 1);
|
||||||
end = decrypted;
|
end = decrypted;
|
||||||
if (!decrypted) return NULL;
|
|
||||||
|
|
||||||
while (*data) {
|
while (*data) {
|
||||||
// Convert from FiSH-BASE64
|
/* Convert from FiSH-BASE64 */
|
||||||
BF_LONG binary[2] = { 0, 0 };
|
BF_LONG binary[2] = { 0, 0 };
|
||||||
bit = 0;
|
bit = 0;
|
||||||
word = 1;
|
word = 1;
|
||||||
|
@ -144,10 +142,10 @@ char *fish_decrypt(const char *key, size_t keylen, const char *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrypt block
|
/* Decrypt block */
|
||||||
BF_decrypt(binary, &bfkey);
|
BF_decrypt(binary, &bfkey);
|
||||||
|
|
||||||
// Copy to buffer
|
/* Copy to buffer */
|
||||||
GET_BYTES(end, binary[0]);
|
GET_BYTES(end, binary[0]);
|
||||||
GET_BYTES(end, binary[1]);
|
GET_BYTES(end, binary[1]);
|
||||||
}
|
}
|
||||||
|
@ -165,14 +163,14 @@ char *fish_encrypt_for_nick(const char *nick, const char *data) {
|
||||||
char *key;
|
char *key;
|
||||||
char *encrypted;
|
char *encrypted;
|
||||||
|
|
||||||
// Look for key
|
/* Look for key */
|
||||||
key = keystore_get_key(nick);
|
key = keystore_get_key(nick);
|
||||||
if (!key) return NULL;
|
if (!key) return NULL;
|
||||||
|
|
||||||
// Encrypt
|
/* Encrypt */
|
||||||
encrypted = fish_encrypt(key, strlen(key), data);
|
encrypted = fish_encrypt(key, strlen(key), data);
|
||||||
|
|
||||||
free(key);
|
g_free(key);
|
||||||
return encrypted;
|
return encrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,14 +181,14 @@ char *fish_encrypt_for_nick(const char *nick, const char *data) {
|
||||||
char *fish_decrypt_from_nick(const char *nick, const char *data) {
|
char *fish_decrypt_from_nick(const char *nick, const char *data) {
|
||||||
char *key;
|
char *key;
|
||||||
char *decrypted;
|
char *decrypted;
|
||||||
// Look for key
|
/* Look for key */
|
||||||
key = keystore_get_key(nick);
|
key = keystore_get_key(nick);
|
||||||
if (!key) return NULL;
|
if (!key) return NULL;
|
||||||
|
|
||||||
// Decrypt
|
/* Decrypt */
|
||||||
decrypted = fish_decrypt(key, strlen(key), data);
|
decrypted = fish_decrypt(key, strlen(key), data);
|
||||||
|
|
||||||
free(key);
|
g_free(key);
|
||||||
return decrypted;
|
return decrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,10 @@
|
||||||
#ifndef FISH_H
|
#ifndef FISH_H
|
||||||
#define FISH_H
|
#define FISH_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
char *fish_encrypt(const char *key, size_t keylen, const char *message);
|
char *fish_encrypt(const char *key, size_t keylen, const char *message);
|
||||||
char *fish_decrypt(const char *key, size_t keylen, const char *data);
|
char *fish_decrypt(const char *key, size_t keylen, const char *data);
|
||||||
char *fish_encrypt_for_nick(const char *nick, const char *data);
|
char *fish_encrypt_for_nick(const char *nick, const char *data);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,57 +20,19 @@
|
||||||
<RootNamespace>fishlim</RootNamespace>
|
<RootNamespace>fishlim</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcfishlim</TargetName>
|
<TargetName>hcfishlim</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcfishlim</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>fishlim.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>fishlim.def</ModuleDefinitionFile>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
@ -77,19 +40,10 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>fishlim.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>fishlim.def</ModuleDefinitionFile>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
@ -103,17 +57,13 @@
|
||||||
<ClInclude Include="fish.h" />
|
<ClInclude Include="fish.h" />
|
||||||
<ClInclude Include="irc.h" />
|
<ClInclude Include="irc.h" />
|
||||||
<ClInclude Include="keystore.h" />
|
<ClInclude Include="keystore.h" />
|
||||||
<ClInclude Include="misc.h" />
|
|
||||||
<ClInclude Include="plugin_hexchat.h" />
|
<ClInclude Include="plugin_hexchat.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="fish.c" />
|
<ClCompile Include="fish.c" />
|
||||||
<ClCompile Include="irc.c" />
|
<ClCompile Include="irc.c" />
|
||||||
<ClCompile Include="keystore.c" />
|
<ClCompile Include="keystore.c" />
|
||||||
<ClCompile Include="misc.c" />
|
|
||||||
<ClCompile Include="plugin_hexchat.c" />
|
<ClCompile Include="plugin_hexchat.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -32,9 +32,6 @@
|
||||||
<ClInclude Include="keystore.h">
|
<ClInclude Include="keystore.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="misc.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="plugin_hexchat.h">
|
<ClInclude Include="plugin_hexchat.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -49,9 +46,6 @@
|
||||||
<ClCompile Include="keystore.c">
|
<ClCompile Include="keystore.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="misc.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="plugin_hexchat.c">
|
<ClCompile Include="plugin_hexchat.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include "config.h"
|
||||||
#include <string.h>
|
|
||||||
|
#include <glib.h>
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,26 +32,26 @@
|
||||||
* at spaces. The prefix and command is extracted from the message, and
|
* at spaces. The prefix and command is extracted from the message, and
|
||||||
* parameters_offset is set to the index of the first parameter.
|
* parameters_offset is set to the index of the first parameter.
|
||||||
*/
|
*/
|
||||||
bool irc_parse_message(const char *words[],
|
gboolean irc_parse_message(const char *words[],
|
||||||
const char **prefix, const char **command,
|
const char **prefix, const char **command,
|
||||||
size_t *parameters_offset) {
|
size_t *parameters_offset) {
|
||||||
size_t w = 1;
|
size_t w = 1;
|
||||||
if (prefix) *prefix = NULL;
|
if (prefix) *prefix = NULL;
|
||||||
if (command) *command = NULL;
|
if (command) *command = NULL;
|
||||||
|
|
||||||
// See if the message starts with a prefix (sender user)
|
/* See if the message starts with a prefix (sender user) */
|
||||||
if (words[w][0] == ':') {
|
if (words[w][0] == ':') {
|
||||||
if (prefix) *prefix = &words[w][1];
|
if (prefix) *prefix = &words[w][1];
|
||||||
w++;
|
w++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check command
|
/* Check command */
|
||||||
if (words[w][0] == '\0') return false;
|
if (words[w][0] == '\0') return FALSE;
|
||||||
if (command) *command = words[w];
|
if (command) *command = words[w];
|
||||||
w++;
|
w++;
|
||||||
|
|
||||||
*parameters_offset = w;
|
*parameters_offset = w;
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,48 +66,15 @@ bool irc_parse_message(const char *words[],
|
||||||
*/
|
*/
|
||||||
char *irc_prefix_get_nick(const char *prefix) {
|
char *irc_prefix_get_nick(const char *prefix) {
|
||||||
const char *end;
|
const char *end;
|
||||||
char *nick;
|
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
if (!prefix) return NULL;
|
if (!prefix) return NULL;
|
||||||
|
|
||||||
// Find end of nick
|
/* Find end of nick */
|
||||||
end = prefix;
|
end = prefix;
|
||||||
while (*end != '\0' && *end != '!' && *end != '@') end++;
|
while (*end != '\0' && *end != '!' && *end != '@') end++;
|
||||||
|
|
||||||
// Allocate string
|
/* Allocate string */
|
||||||
length = end - prefix;
|
length = end - prefix;
|
||||||
nick = malloc(length+1);
|
return g_strndup (prefix, length);
|
||||||
if (!nick) return NULL;
|
|
||||||
|
|
||||||
// Copy to string
|
|
||||||
memcpy(nick, prefix, length);
|
|
||||||
nick[length] = '\0';
|
|
||||||
return nick;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares two nick names. Return 0 if equal. Otherwise the return value is
|
|
||||||
* less than zero if a is less than b or greater than zero if a is greater
|
|
||||||
* than b.
|
|
||||||
*/
|
|
||||||
int irc_nick_cmp(const char *a, const char *b) {
|
|
||||||
char ac;
|
|
||||||
char bc;
|
|
||||||
char diff;
|
|
||||||
for (;;) {
|
|
||||||
ac = *(a++);
|
|
||||||
bc = *(b++);
|
|
||||||
|
|
||||||
// Change into IRC uppercase (see RFC 2812 section 2.2)
|
|
||||||
if (ac >= 'a' && ac <= '~') ac &= ~0x20;
|
|
||||||
if (bc >= 'a' && bc <= '~') bc &= ~0x20;
|
|
||||||
|
|
||||||
diff = ac - bc;
|
|
||||||
if (diff) return diff;
|
|
||||||
if (!ac) return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,13 @@
|
||||||
#ifndef IRC_H
|
#ifndef IRC_H
|
||||||
#define IRC_H
|
#define IRC_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
bool irc_parse_message(const char *words[],
|
gboolean irc_parse_message(const char *words[],
|
||||||
const char **prefix, const char **command,
|
const char **prefix, const char **command,
|
||||||
size_t *parameters_offset);
|
size_t *parameters_offset);
|
||||||
char *irc_prefix_get_nick(const char *prefix);
|
char *irc_prefix_get_nick(const char *prefix);
|
||||||
int irc_nick_cmp(const char *a, const char *b);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "fish.h"
|
#include "fish.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "keystore.h"
|
#include "keystore.h"
|
||||||
#include "plugin_hexchat.h"
|
#include "plugin_hexchat.h"
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ static GKeyFile *getConfigFile() {
|
||||||
static const char *get_keystore_password() {
|
static const char *get_keystore_password() {
|
||||||
return (keystore_password != NULL ?
|
return (keystore_password != NULL ?
|
||||||
keystore_password :
|
keystore_password :
|
||||||
// Silly default value...
|
/* Silly default value... */
|
||||||
"blowinikey");
|
"blowinikey");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,17 +88,17 @@ static gchar *get_nick_value(GKeyFile *keyfile, const char *nick, const char *it
|
||||||
* Extracts a key from the key store file.
|
* Extracts a key from the key store file.
|
||||||
*/
|
*/
|
||||||
char *keystore_get_key(const char *nick) {
|
char *keystore_get_key(const char *nick) {
|
||||||
// Get the key
|
/* Get the key */
|
||||||
GKeyFile *keyfile = getConfigFile();
|
GKeyFile *keyfile = getConfigFile();
|
||||||
gchar *value = get_nick_value(keyfile, nick, "key");
|
gchar *value = get_nick_value(keyfile, nick, "key");
|
||||||
g_key_file_free(keyfile);
|
g_key_file_free(keyfile);
|
||||||
if (!value) return NULL;
|
if (!value) return NULL;
|
||||||
|
|
||||||
if (strncmp(value, "+OK ", 4) != 0) {
|
if (strncmp(value, "+OK ", 4) != 0) {
|
||||||
// Key is stored in plaintext
|
/* Key is stored in plaintext */
|
||||||
return import_glib_string(value);
|
return value;
|
||||||
} else {
|
} else {
|
||||||
// Key is encrypted
|
/* Key is encrypted */
|
||||||
const char *encrypted = value+4;
|
const char *encrypted = value+4;
|
||||||
const char *password = get_keystore_password();
|
const char *password = get_keystore_password();
|
||||||
char *decrypted = fish_decrypt(password, strlen(password), encrypted);
|
char *decrypted = fish_decrypt(password, strlen(password), encrypted);
|
||||||
|
@ -109,10 +110,10 @@ char *keystore_get_key(const char *nick) {
|
||||||
/**
|
/**
|
||||||
* Deletes a nick and the associated key in the key store file.
|
* Deletes a nick and the associated key in the key store file.
|
||||||
*/
|
*/
|
||||||
static bool delete_nick(GKeyFile *keyfile, const char *nick) {
|
static gboolean delete_nick(GKeyFile *keyfile, const char *nick) {
|
||||||
gchar **group;
|
gchar **group;
|
||||||
gchar **groups = g_key_file_get_groups(keyfile, NULL);
|
gchar **groups = g_key_file_get_groups(keyfile, NULL);
|
||||||
bool ok = false;
|
gboolean ok = FALSE;
|
||||||
|
|
||||||
for (group = groups; *group != NULL; group++) {
|
for (group = groups; *group != NULL; group++) {
|
||||||
if (!irc_nick_cmp(*group, nick)) {
|
if (!irc_nick_cmp(*group, nick)) {
|
||||||
|
@ -125,58 +126,77 @@ static bool delete_nick(GKeyFile *keyfile, const char *nick) {
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !GLIB_CHECK_VERSION(2,40,0)
|
||||||
/**
|
/**
|
||||||
* Writes the key store file to disk.
|
* Writes the key store file to disk.
|
||||||
*/
|
*/
|
||||||
static bool save_keystore(GKeyFile *keyfile) {
|
static gboolean keyfile_save_to_file (GKeyFile *keyfile, char *filename) {
|
||||||
char *filename;
|
gboolean ok;
|
||||||
bool ok;
|
|
||||||
// Serialize
|
/* Serialize */
|
||||||
gsize file_length;
|
gsize file_length;
|
||||||
gchar *file_data = g_key_file_to_data(keyfile, &file_length, NULL);
|
gchar *file_data = g_key_file_to_data(keyfile, &file_length, NULL);
|
||||||
if (!file_data) return false;
|
if (!file_data)
|
||||||
|
return FALSE;
|
||||||
// Write to file
|
|
||||||
filename = get_config_filename();
|
/* Write to file */
|
||||||
ok = g_file_set_contents(filename, file_data, file_length, NULL);
|
ok = g_file_set_contents (filename, file_data, file_length, NULL);
|
||||||
g_free(filename);
|
|
||||||
g_free(file_data);
|
g_free(file_data);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the key store file to disk.
|
||||||
|
*/
|
||||||
|
static gboolean save_keystore(GKeyFile *keyfile) {
|
||||||
|
char *filename;
|
||||||
|
gboolean ok;
|
||||||
|
|
||||||
|
filename = get_config_filename();
|
||||||
|
#if !GLIB_CHECK_VERSION(2,40,0)
|
||||||
|
ok = keyfile_save_to_file (keyfile, filename);
|
||||||
|
#else
|
||||||
|
ok = g_key_file_save_to_file (keyfile, filename, NULL);
|
||||||
|
#endif
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a key in the key store file.
|
* Sets a key in the key store file.
|
||||||
*/
|
*/
|
||||||
bool keystore_store_key(const char *nick, const char *key) {
|
gboolean keystore_store_key(const char *nick, const char *key) {
|
||||||
const char *password;
|
const char *password;
|
||||||
char *encrypted;
|
char *encrypted;
|
||||||
char *wrapped;
|
char *wrapped;
|
||||||
bool ok = false;
|
gboolean ok = FALSE;
|
||||||
GKeyFile *keyfile = getConfigFile();
|
GKeyFile *keyfile = getConfigFile();
|
||||||
|
|
||||||
// Remove old key
|
/* Remove old key */
|
||||||
delete_nick(keyfile, nick);
|
delete_nick(keyfile, nick);
|
||||||
|
|
||||||
// Add new key
|
/* Add new key */
|
||||||
password = get_keystore_password();
|
password = get_keystore_password();
|
||||||
if (password) {
|
if (password) {
|
||||||
// Encrypt the password
|
/* Encrypt the password */
|
||||||
encrypted = fish_encrypt(password, strlen(password), key);
|
encrypted = fish_encrypt(password, strlen(password), key);
|
||||||
if (!encrypted) goto end;
|
if (!encrypted) goto end;
|
||||||
|
|
||||||
// Prepend "+OK "
|
/* Prepend "+OK " */
|
||||||
wrapped = g_strconcat("+OK ", encrypted, NULL);
|
wrapped = g_strconcat("+OK ", encrypted, NULL);
|
||||||
g_free(encrypted);
|
g_free(encrypted);
|
||||||
|
|
||||||
// Store encrypted in file
|
/* Store encrypted in file */
|
||||||
g_key_file_set_string(keyfile, nick, "key", wrapped);
|
g_key_file_set_string(keyfile, nick, "key", wrapped);
|
||||||
free(wrapped);
|
g_free(wrapped);
|
||||||
} else {
|
} else {
|
||||||
// Store unencrypted in file
|
/* Store unencrypted in file */
|
||||||
g_key_file_set_string(keyfile, nick, "key", key);
|
g_key_file_set_string(keyfile, nick, "key", key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save key store file
|
/* Save key store file */
|
||||||
ok = save_keystore(keyfile);
|
ok = save_keystore(keyfile);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
@ -187,23 +207,15 @@ bool keystore_store_key(const char *nick, const char *key) {
|
||||||
/**
|
/**
|
||||||
* Deletes a nick from the key store.
|
* Deletes a nick from the key store.
|
||||||
*/
|
*/
|
||||||
bool keystore_delete_nick(const char *nick) {
|
gboolean keystore_delete_nick(const char *nick) {
|
||||||
GKeyFile *keyfile = getConfigFile();
|
GKeyFile *keyfile = getConfigFile();
|
||||||
|
|
||||||
// Delete entry
|
/* Delete entry */
|
||||||
bool ok = delete_nick(keyfile, nick);
|
gboolean ok = delete_nick(keyfile, nick);
|
||||||
|
|
||||||
// Save
|
/* Save */
|
||||||
if (ok) save_keystore(keyfile);
|
if (ok) save_keystore(keyfile);
|
||||||
|
|
||||||
g_key_file_free(keyfile);
|
g_key_file_free(keyfile);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void keystore_secure_free(void *ptr, size_t size) {
|
|
||||||
secure_erase(ptr, size);
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,13 @@
|
||||||
#ifndef KEYSTORE_H
|
#ifndef KEYSTORE_H
|
||||||
#define KEYSTORE_H
|
#define KEYSTORE_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
char *keystore_get_key(const char *nick);
|
#include <glib.h>
|
||||||
bool keystore_store_key(const char *nick, const char *key);
|
|
||||||
bool keystore_delete_nick(const char *nick);
|
|
||||||
|
|
||||||
void keystore_secure_free(void *ptr, size_t size);
|
char *keystore_get_key(const char *nick);
|
||||||
|
gboolean keystore_store_key(const char *nick, const char *key);
|
||||||
|
gboolean keystore_delete_nick(const char *nick);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
void secure_erase(void *ptr, size_t size) {
|
|
||||||
// "volatile" prevents this code from being optimized away
|
|
||||||
volatile char* volptr = ptr;
|
|
||||||
while (size--) *volptr++ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Re-allocates a string with the native allocator.
|
|
||||||
*/
|
|
||||||
char *import_glib_string(gchar *gstr) {
|
|
||||||
size_t size;
|
|
||||||
char *native;
|
|
||||||
if (g_mem_is_system_malloc()) return gstr;
|
|
||||||
|
|
||||||
size = strlen(gstr)+1;
|
|
||||||
native = malloc(size);
|
|
||||||
memcpy(native, gstr, size);
|
|
||||||
|
|
||||||
secure_erase(gstr, size);
|
|
||||||
g_free(gstr);
|
|
||||||
return native;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MISC_H
|
|
||||||
#define MISC_H
|
|
||||||
|
|
||||||
void secure_erase(void *ptr, size_t size);
|
|
||||||
|
|
||||||
#ifdef __G_LIB_H__
|
|
||||||
char *import_glib_string(gchar *gstr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
@ -22,17 +22,14 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// #pragma GCC visibility push(default)
|
|
||||||
#include "hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
#define HEXCHAT_MAX_WORDS 32
|
#define HEXCHAT_MAX_WORDS 32
|
||||||
// #pragma GCC visibility pop
|
|
||||||
|
|
||||||
//#define EXPORT __attribute((visibility("default")))
|
|
||||||
//#define EXPORT
|
|
||||||
|
|
||||||
#include "fish.h"
|
#include "fish.h"
|
||||||
#include "keystore.h"
|
#include "keystore.h"
|
||||||
|
@ -52,27 +49,19 @@ static hexchat_plugin *ph;
|
||||||
* Returns the path to the key store file.
|
* Returns the path to the key store file.
|
||||||
*/
|
*/
|
||||||
gchar *get_config_filename() {
|
gchar *get_config_filename() {
|
||||||
return g_build_filename(hexchat_get_info(ph, "configdir"), "addon_fishlim.conf", NULL);
|
char *filename_fs, *filename_utf8;
|
||||||
|
|
||||||
|
filename_utf8 = g_build_filename(hexchat_get_info(ph, "configdir"), "addon_fishlim.conf", NULL);
|
||||||
|
filename_fs = g_filename_from_utf8 (filename_utf8, -1, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
g_free (filename_utf8);
|
||||||
|
return filename_fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
int irc_nick_cmp(const char *a, const char *b) {
|
||||||
* Appends data to a string. Returns true if there was sufficient memory.
|
return hexchat_nickcmp (ph, a, b);
|
||||||
* Frees *s and returns false if an error occurs.
|
|
||||||
*/
|
|
||||||
static bool append(char **s, size_t *length, const char *data) {
|
|
||||||
size_t datalen = strlen(data);
|
|
||||||
char *extended = realloc(*s, *length + datalen + 1);
|
|
||||||
if (!extended) {
|
|
||||||
free(*s);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(extended + *length, data, datalen + 1);
|
|
||||||
*s = extended;
|
|
||||||
*length += datalen;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*static int handle_debug(char *word[], char *word_eol[], void *userdata) {
|
/*static int handle_debug(char *word[], char *word_eol[], void *userdata) {
|
||||||
hexchat_printf(ph, "debug incoming: ");
|
hexchat_printf(ph, "debug incoming: ");
|
||||||
for (size_t i = 1; word[i] != NULL && word[i][0] != '\0'; i++) {
|
for (size_t i = 1; word[i] != NULL && word[i][0] != '\0'; i++) {
|
||||||
|
@ -87,26 +76,26 @@ static bool append(char **s, size_t *length, const char *data) {
|
||||||
*/
|
*/
|
||||||
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
||||||
const char *own_nick;
|
const char *own_nick;
|
||||||
// Encrypt the message if possible
|
/* Encrypt the message if possible */
|
||||||
const char *channel = hexchat_get_info(ph, "channel");
|
const char *channel = hexchat_get_info(ph, "channel");
|
||||||
char *encrypted = fish_encrypt_for_nick(channel, word_eol[1]);
|
char *encrypted = fish_encrypt_for_nick(channel, word_eol[1]);
|
||||||
if (!encrypted) return HEXCHAT_EAT_NONE;
|
if (!encrypted) return HEXCHAT_EAT_NONE;
|
||||||
|
|
||||||
// Display message
|
/* Display message */
|
||||||
own_nick = hexchat_get_info(ph, "nick");
|
own_nick = hexchat_get_info(ph, "nick");
|
||||||
hexchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL);
|
hexchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL);
|
||||||
|
|
||||||
// Send message
|
/* Send message */
|
||||||
hexchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted);
|
hexchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted);
|
||||||
|
|
||||||
free(encrypted);
|
g_free(encrypted);
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
return HEXCHAT_EAT_HEXCHAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a channel message or private message is received.
|
* Called when a channel message or private message is received.
|
||||||
*/
|
*/
|
||||||
static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
|
static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs *attrs, void *userdata) {
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
const char *command;
|
const char *command;
|
||||||
const char *recipient;
|
const char *recipient;
|
||||||
|
@ -114,20 +103,19 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
|
||||||
const char *peice;
|
const char *peice;
|
||||||
char *sender_nick;
|
char *sender_nick;
|
||||||
char *decrypted;
|
char *decrypted;
|
||||||
char *message;
|
|
||||||
size_t w;
|
size_t w;
|
||||||
size_t ew;
|
size_t ew;
|
||||||
size_t uw;
|
size_t uw;
|
||||||
size_t length;
|
|
||||||
char prefix_char = 0;
|
char prefix_char = 0;
|
||||||
|
GString *message;
|
||||||
|
|
||||||
if (!irc_parse_message((const char **)word, &prefix, &command, &w))
|
if (!irc_parse_message((const char **)word, &prefix, &command, &w))
|
||||||
return HEXCHAT_EAT_NONE;
|
return HEXCHAT_EAT_NONE;
|
||||||
|
|
||||||
// Topic (command 332) has an extra parameter
|
/* Topic (command 332) has an extra parameter */
|
||||||
if (!strcmp(command, "332")) w++;
|
if (!strcmp(command, "332")) w++;
|
||||||
|
|
||||||
// Look for encrypted data
|
/* Look for encrypted data */
|
||||||
for (ew = w+1; ew < HEXCHAT_MAX_WORDS-1; ew++) {
|
for (ew = w+1; ew < HEXCHAT_MAX_WORDS-1; ew++) {
|
||||||
const char *s = (ew == w+1 ? word[ew]+1 : word[ew]);
|
const char *s = (ew == w+1 ? word[ew]+1 : word[ew]);
|
||||||
if (*s && (s[1] == '+' || s[1] == 'm')) { prefix_char = *(s++); }
|
if (*s && (s[1] == '+' || s[1] == 'm')) { prefix_char = *(s++); }
|
||||||
|
@ -136,61 +124,70 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
|
||||||
}
|
}
|
||||||
return HEXCHAT_EAT_NONE;
|
return HEXCHAT_EAT_NONE;
|
||||||
has_encrypted_data: ;
|
has_encrypted_data: ;
|
||||||
// Extract sender nick and recipient nick/channel
|
/* Extract sender nick and recipient nick/channel */
|
||||||
sender_nick = irc_prefix_get_nick(prefix);
|
sender_nick = irc_prefix_get_nick(prefix);
|
||||||
recipient = word[w];
|
recipient = word[w];
|
||||||
|
|
||||||
// Try to decrypt with these (the keys are searched for in the key store)
|
/* Try to decrypt with these (the keys are searched for in the key store) */
|
||||||
encrypted = word[ew+1];
|
encrypted = word[ew+1];
|
||||||
decrypted = fish_decrypt_from_nick(recipient, encrypted);
|
decrypted = fish_decrypt_from_nick(recipient, encrypted);
|
||||||
if (!decrypted) decrypted = fish_decrypt_from_nick(sender_nick, encrypted);
|
if (!decrypted) decrypted = fish_decrypt_from_nick(sender_nick, encrypted);
|
||||||
|
|
||||||
// Check for error
|
/* Check for error */
|
||||||
if (!decrypted) goto decrypt_error;
|
if (!decrypted) goto decrypt_error;
|
||||||
|
|
||||||
// Build unecrypted message
|
/* Build unecrypted message */
|
||||||
message = NULL;
|
message = g_string_sized_new (100); /* TODO: more accurate estimation of size */
|
||||||
length = 0;
|
g_string_append (message, "RECV");
|
||||||
if (!append(&message, &length, "RECV")) goto decrypt_error;
|
|
||||||
|
if (attrs->server_time_utc)
|
||||||
|
{
|
||||||
|
GTimeVal tv = { (glong)attrs->server_time_utc, 0 };
|
||||||
|
char *timestamp = g_time_val_to_iso8601 (&tv);
|
||||||
|
|
||||||
|
g_string_append (message, " @time=");
|
||||||
|
g_string_append (message, timestamp);
|
||||||
|
g_free (timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
for (uw = 1; uw < HEXCHAT_MAX_WORDS; uw++) {
|
for (uw = 1; uw < HEXCHAT_MAX_WORDS; uw++) {
|
||||||
if (word[uw][0] != '\0' && !append(&message, &length, " ")) goto decrypt_error;
|
if (word[uw][0] != '\0')
|
||||||
|
g_string_append_c (message, ' ');
|
||||||
|
|
||||||
if (uw == ew) {
|
if (uw == ew) {
|
||||||
// Add the encrypted data
|
/* Add the encrypted data */
|
||||||
peice = decrypted;
|
peice = decrypted;
|
||||||
uw++; // Skip "OK+"
|
uw++; /* Skip "OK+" */
|
||||||
|
|
||||||
if (ew == w+1) {
|
if (ew == w+1) {
|
||||||
// Prefix with colon, which gets stripped out otherwise
|
/* Prefix with colon, which gets stripped out otherwise */
|
||||||
if (!append(&message, &length, ":")) goto decrypt_error;
|
g_string_append_c (message, ':');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefix_char) {
|
if (prefix_char) {
|
||||||
char prefix_str[2] = { prefix_char, '\0' };
|
g_string_append_c (message, prefix_char);
|
||||||
if (!append(&message, &length, prefix_str)) goto decrypt_error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Add unencrypted data (for example, a prefix from a bouncer or bot)
|
/* Add unencrypted data (for example, a prefix from a bouncer or bot) */
|
||||||
peice = word[uw];
|
peice = word[uw];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!append(&message, &length, peice)) goto decrypt_error;
|
g_string_append (message, peice);
|
||||||
}
|
}
|
||||||
free(decrypted);
|
g_free(decrypted);
|
||||||
|
|
||||||
// Simulate unencrypted message
|
/* Simulate unencrypted message */
|
||||||
//hexchat_printf(ph, "simulating: %s\n", message);
|
/* hexchat_printf(ph, "simulating: %s\n", message->str); */
|
||||||
hexchat_command(ph, message);
|
hexchat_command(ph, message->str);
|
||||||
|
|
||||||
free(message);
|
g_string_free (message, TRUE);
|
||||||
free(sender_nick);
|
g_free(sender_nick);
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
return HEXCHAT_EAT_HEXCHAT;
|
||||||
|
|
||||||
decrypt_error:
|
decrypt_error:
|
||||||
free(decrypted);
|
g_free(decrypted);
|
||||||
free(sender_nick);
|
g_free(sender_nick);
|
||||||
return HEXCHAT_EAT_NONE;
|
return HEXCHAT_EAT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,27 +198,27 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
|
||||||
const char *nick;
|
const char *nick;
|
||||||
const char *key;
|
const char *key;
|
||||||
|
|
||||||
// Check syntax
|
/* Check syntax */
|
||||||
if (*word[2] == '\0') {
|
if (*word[2] == '\0') {
|
||||||
hexchat_printf(ph, "%s\n", usage_setkey);
|
hexchat_printf(ph, "%s\n", usage_setkey);
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
return HEXCHAT_EAT_HEXCHAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*word[3] == '\0') {
|
if (*word[3] == '\0') {
|
||||||
// /setkey password
|
/* /setkey password */
|
||||||
nick = hexchat_get_info(ph, "channel");
|
nick = hexchat_get_info(ph, "channel");
|
||||||
key = word_eol[2];
|
key = word_eol[2];
|
||||||
} else {
|
} else {
|
||||||
// /setkey #channel password
|
/* /setkey #channel password */
|
||||||
nick = word[2];
|
nick = word[2];
|
||||||
key = word_eol[3];
|
key = word_eol[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set password
|
/* Set password */
|
||||||
if (keystore_store_key(nick, key)) {
|
if (keystore_store_key(nick, key)) {
|
||||||
hexchat_printf(ph, "Stored key for %s\n", nick);
|
hexchat_printf(ph, "Stored key for %s\n", nick);
|
||||||
} else {
|
} else {
|
||||||
hexchat_printf(ph, "\00305Failed to store key in addon_fishlim.conf\n", nick, key);
|
hexchat_printf(ph, "\00305Failed to store key in addon_fishlim.conf\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
return HEXCHAT_EAT_HEXCHAT;
|
||||||
|
@ -233,19 +230,19 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
|
||||||
static int handle_delkey(char *word[], char *word_eol[], void *userdata) {
|
static int handle_delkey(char *word[], char *word_eol[], void *userdata) {
|
||||||
const char *nick;
|
const char *nick;
|
||||||
|
|
||||||
// Check syntax
|
/* Check syntax */
|
||||||
if (*word[2] == '\0' || *word[3] != '\0') {
|
if (*word[2] == '\0' || *word[3] != '\0') {
|
||||||
hexchat_printf(ph, "%s\n", usage_delkey);
|
hexchat_printf(ph, "%s\n", usage_delkey);
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
return HEXCHAT_EAT_HEXCHAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nick = word_eol[2];
|
nick = g_strstrip (word_eol[2]);
|
||||||
|
|
||||||
// Delete the given nick from the key store
|
/* Delete the given nick from the key store */
|
||||||
if (keystore_delete_nick(nick)) {
|
if (keystore_delete_nick(nick)) {
|
||||||
hexchat_printf(ph, "Deleted key for %s\n", nick);
|
hexchat_printf(ph, "Deleted key for %s\n", nick);
|
||||||
} else {
|
} else {
|
||||||
hexchat_printf(ph, "\00305Failed to delete key in addon_fishlim.conf!\n", nick);
|
hexchat_printf(ph, "\00305Failed to delete key in addon_fishlim.conf!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
return HEXCHAT_EAT_HEXCHAT;
|
||||||
|
@ -282,11 +279,11 @@ int hexchat_plugin_init(hexchat_plugin *plugin_handle,
|
||||||
|
|
||||||
/* Add handlers */
|
/* Add handlers */
|
||||||
hexchat_hook_command(ph, "", HEXCHAT_PRI_NORM, handle_outgoing, NULL, NULL);
|
hexchat_hook_command(ph, "", HEXCHAT_PRI_NORM, handle_outgoing, NULL, NULL);
|
||||||
hexchat_hook_server(ph, "NOTICE", HEXCHAT_PRI_NORM, handle_incoming, NULL);
|
hexchat_hook_server_attrs(ph, "NOTICE", HEXCHAT_PRI_NORM, handle_incoming, NULL);
|
||||||
hexchat_hook_server(ph, "PRIVMSG", HEXCHAT_PRI_NORM, handle_incoming, NULL);
|
hexchat_hook_server_attrs(ph, "PRIVMSG", HEXCHAT_PRI_NORM, handle_incoming, NULL);
|
||||||
//hexchat_hook_server(ph, "RAW LINE", HEXCHAT_PRI_NORM, handle_debug, NULL);
|
/* hexchat_hook_server(ph, "RAW LINE", HEXCHAT_PRI_NORM, handle_debug, NULL); */
|
||||||
hexchat_hook_server(ph, "TOPIC", HEXCHAT_PRI_NORM, handle_incoming, NULL);
|
hexchat_hook_server_attrs(ph, "TOPIC", HEXCHAT_PRI_NORM, handle_incoming, NULL);
|
||||||
hexchat_hook_server(ph, "332", HEXCHAT_PRI_NORM, handle_incoming, NULL);
|
hexchat_hook_server_attrs(ph, "332", HEXCHAT_PRI_NORM, handle_incoming, NULL);
|
||||||
|
|
||||||
hexchat_printf(ph, "%s plugin loaded\n", plugin_name);
|
hexchat_printf(ph, "%s plugin loaded\n", plugin_name);
|
||||||
/* Return success */
|
/* Return success */
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#define PLUGIN_HEXCHAT_H
|
#define PLUGIN_HEXCHAT_H
|
||||||
|
|
||||||
gchar *get_config_filename();
|
gchar *get_config_filename();
|
||||||
|
int irc_nick_cmp (const char *, const char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "fish.h"
|
|
||||||
|
|
||||||
// We can't use the HexChat plugin API from here...
|
|
||||||
gchar *get_config_filename() {
|
|
||||||
const gchar *homedir = g_get_home_dir();
|
|
||||||
return g_build_filename(homedir, ".config", "hexchat", "blow.ini", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int decrypt(int nick_count, char *nicks[]) {
|
|
||||||
char encrypted[8192];
|
|
||||||
while (fgets(encrypted, sizeof(encrypted), stdin)) {
|
|
||||||
char *msg;
|
|
||||||
for (int i = 0; i < nick_count; i++) {
|
|
||||||
msg = fish_decrypt_from_nick(nicks[i], encrypted);
|
|
||||||
if (msg) goto success;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "None of the recipients were found in the key store!\n");
|
|
||||||
return 1;
|
|
||||||
success:
|
|
||||||
fprintf(stderr, "Decrypted text >>>%s<<<\n", msg);
|
|
||||||
free(msg);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int encrypt(int nick_count, char *nicks[]) {
|
|
||||||
char message[8192];
|
|
||||||
while (fgets(message, sizeof(message), stdin)) {
|
|
||||||
// Remove newline character
|
|
||||||
char *newline = strchr(message, '\n');
|
|
||||||
if (newline) *newline = '\0';
|
|
||||||
|
|
||||||
bool error = false;
|
|
||||||
for (int i = 0; i < nick_count; i++) {
|
|
||||||
char *encrypted = fish_encrypt_for_nick(nicks[i], message);
|
|
||||||
if (encrypted) {
|
|
||||||
fprintf(stderr, "Encrypted [%s]: >>>%s<<<\n", nicks[i], encrypted);
|
|
||||||
free(encrypted);
|
|
||||||
} else {
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
fprintf(stderr, "Some of the recipients were't found in the key store!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "usage: %s [-e] nick...\n", argv[0]);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(argv[1], "-e") == 0) {
|
|
||||||
return encrypt(argc-2, &argv[2]);
|
|
||||||
} else {
|
|
||||||
return decrypt(argc-1, &argv[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -14,54 +14,27 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
#include <glib.h>
|
||||||
typedef int (*MYPROC)(HWND,HWND,char*,char*,BOOL,BOOL);
|
|
||||||
|
|
||||||
int dllProc(char *name, char *data){
|
char *split(char *text, char separator)
|
||||||
HINSTANCE hinstLib;
|
|
||||||
hinstLib = LoadLibrary("mpcinfo");
|
|
||||||
//MYPROC proc;
|
|
||||||
int res;
|
|
||||||
if (hinstLib != NULL){
|
|
||||||
//proc = ;
|
|
||||||
if ((MYPROC) GetProcAddress(hinstLib, name)!=NULL){
|
|
||||||
res=(MYPROC)(NULL,NULL,data,NULL,TRUE,TRUE);
|
|
||||||
}
|
|
||||||
else{fprintf(stderr,"can't get proc: %s\n",name);res=-2;}
|
|
||||||
}
|
|
||||||
else{fprintf(stderr,"can't access dll\n");return -1;}
|
|
||||||
FreeLibrary(hinstLib);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
int dllProc(char *name, char *data)
|
|
||||||
{
|
{
|
||||||
static HMODULE lib = NULL;
|
int pos = -1;
|
||||||
if (!lib)
|
size_t i;
|
||||||
|
for (i = 0; i < strlen(text); i++)
|
||||||
{
|
{
|
||||||
lib = LoadLibraryA ("mpcinfo");
|
if (text[i] == separator) {
|
||||||
if (!lib)
|
pos = i;
|
||||||
{
|
i = strlen(text) + 1;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
FreeLibrary (lib);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
if (pos == -1)
|
||||||
}
|
{
|
||||||
*/
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
char *split(char *text, char seperator){
|
text[pos] = 0;
|
||||||
//if (DEBUG==1) putlog("splitting");
|
return &(text[pos + 1]);
|
||||||
int i;int pos=-1;
|
|
||||||
for (i=0;i<strlen(text);i++){
|
|
||||||
if (text[i]==seperator){pos=i;i=strlen(text)+1;}
|
|
||||||
}
|
|
||||||
if (pos==-1) return text;
|
|
||||||
text[pos]=0;
|
|
||||||
return &(text[pos+1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int endsWith(char *text, char *suffix){
|
int endsWith(char *text, char *suffix){
|
||||||
|
@ -71,21 +44,32 @@ int endsWith(char *text, char *suffix){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int inStr(char *s1, int sl1, char *s2){
|
int inStr(char *s1, size_t sl1, char *s2)
|
||||||
//if (DEBUG==1) putlog("checking instr");
|
{
|
||||||
int i;int j;
|
size_t i;
|
||||||
for(i=0;i<sl1-strlen(s2);i++){
|
for (i = 0; i < sl1 - strlen(s2); i++)
|
||||||
for (j=0;j<strlen(s2);j++){
|
{
|
||||||
if (s1[i+j]!=s2[j]) j=strlen(s2)+2;
|
size_t j;
|
||||||
|
for (j = 0; j < strlen(s2); j++)
|
||||||
|
{
|
||||||
|
if (s1[i + j] != s2[j])
|
||||||
|
{
|
||||||
|
j = strlen(s2) + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j == strlen(s2))
|
||||||
|
{
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
if (j==strlen(s2)) return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *subString(char *text, int first, int length, int spcKill){
|
static char *subString(char *text, int first, int length, int spcKill){
|
||||||
//if (DEBUG==1) putlog("creating substring");
|
//if (DEBUG==1) putlog("creating substring");
|
||||||
char *ret=(char*) calloc (length+1,sizeof(char)); //malloc(sizeof(char)*(length+1));
|
char *ret = g_new (char, length + 1);
|
||||||
int i;
|
int i;
|
||||||
ret[length]=0;
|
ret[length]=0;
|
||||||
for (i=0;i<length;i++){
|
for (i=0;i<length;i++){
|
||||||
|
@ -107,7 +91,7 @@ static char *substring(char *text, int first, int length){return subString(text,
|
||||||
|
|
||||||
char *readLine(FILE *f){
|
char *readLine(FILE *f){
|
||||||
//if (DEBUG==1) putlog("reading line from file");
|
//if (DEBUG==1) putlog("reading line from file");
|
||||||
char *buffer=(char*)calloc(1024,sizeof(char)); //malloc(sizeof(char)*1024);
|
char *buffer = g_new (char, 1024);
|
||||||
int pos=0;
|
int pos=0;
|
||||||
int cc=0;
|
int cc=0;
|
||||||
while((cc!=EOF)&&(pos<1024)&&(cc!=10)){
|
while((cc!=EOF)&&(pos<1024)&&(cc!=10)){
|
||||||
|
@ -121,14 +105,19 @@ char *readLine(FILE *f){
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *toUpper(char *text){
|
char *toUpper(char *text)
|
||||||
//if (DEBUG==1) putlog("converting text to upper case");
|
{
|
||||||
char *ret=(char*) calloc(strlen(text)+1,sizeof(char));
|
char *ret = (char*) calloc(strlen(text) + 1, sizeof(char));
|
||||||
int i;
|
|
||||||
for (i=0;i<strlen(text);i++) ret[i]=toupper(text[i]);
|
size_t i;
|
||||||
ret[strlen(text)]=0;
|
for (i = 0; i < strlen(text); i++)
|
||||||
//if (DEBUG==1) putlog("uc done");
|
{
|
||||||
return ret;
|
ret[i] = toupper(text[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret[strlen(text)] = 0;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *str3cat(char *s1, char *s2, char *s3){
|
static char *str3cat(char *s1, char *s2, char *s3){
|
||||||
|
|
|
@ -75,62 +75,25 @@ static char MODES [][13]={"Stereo","Joint-Stereo","Dual-Channel","Mono"};
|
||||||
|
|
||||||
int iPow(int x, int y){return (int)(pow((double)x,(double) y));}
|
int iPow(int x, int y){return (int)(pow((double)x,(double) y));}
|
||||||
|
|
||||||
int str2int(char *text){
|
int str2int(char *text)
|
||||||
//if (DEBUG==1) putlog("converting string to int");
|
{
|
||||||
int i;
|
int ret = 0;
|
||||||
int ret=0;
|
|
||||||
for (i=1;i<=strlen(text);i++){
|
|
||||||
if ((text[strlen(text)-i]>57)||(text[strlen(text)-i]<48)){
|
|
||||||
hexchat_printf(ph,"invalid char in string: %i",text[strlen(text)-i]);
|
|
||||||
return 255;
|
|
||||||
}
|
|
||||||
ret+=((int)text[strlen(text)-i]-48)*iPow(10,i-1);
|
|
||||||
}
|
|
||||||
//hexchat_printf(ph, "str2int(%s)=%i",text,ret);
|
|
||||||
//if (DEBUG==1) putlog("int converted");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
static int getSize(char *file){
|
|
||||||
//if (DEBUG==1) putlog("reading filesize");
|
|
||||||
struct stat info;
|
|
||||||
if (stat(file,&info)!=0) return -1;
|
|
||||||
return info.st_size;
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
int inStr(char *s1, int sl1, char *s2){
|
|
||||||
//if (DEBUG==1) putlog("checking instr");
|
|
||||||
int i;int j;
|
|
||||||
for(i=0;i<sl1-strlen(s2);i++){
|
|
||||||
for (j=0;j<strlen(s2);j++){
|
|
||||||
if (s1[i+j]!=s2[j]) j=strlen(s2)+2;
|
|
||||||
}
|
|
||||||
if (j==strlen(s2)) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *subString(char *text, int first, int length, int spcKill){
|
size_t i;
|
||||||
//if (DEBUG==1) putlog("creating substring");
|
for (i = 1; i <= strlen(text); i++)
|
||||||
char *ret=(char*) calloc (length+1,sizeof(char)); //malloc(sizeof(char)*(length+1));
|
{
|
||||||
ret[length]=0;int i;
|
if ((text[strlen(text) - i] > 57) || (text[strlen(text) - i] < 48))
|
||||||
for (i=0;i<length;i++){
|
{
|
||||||
ret[i]=text[i+first];
|
hexchat_printf(ph, "invalid char in string: %i", (int) text[strlen(text) - i]);
|
||||||
//if (ret[i]==0) ret[i]='0';
|
return 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret += ((int) text[strlen(text) - i] - 48)*iPow(10, i - 1);
|
||||||
}
|
}
|
||||||
if (spcKill==1){
|
|
||||||
for (i=length-1;i>=0;i--){
|
|
||||||
if (ret[i]==32) ret[i]=0;
|
|
||||||
else i=-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if (DEBUG==1) putlog("substring created");
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *substring(char *text, int first, int length){return subString(text,first,length,0);} //1
|
|
||||||
*/
|
|
||||||
|
|
||||||
static char *tagExtract(char *tag, int tagLen, char* info){
|
static char *tagExtract(char *tag, int tagLen, char* info){
|
||||||
//if (DEBUG==1) putlog("extracting tag");
|
//if (DEBUG==1) putlog("extracting tag");
|
||||||
int pos, len, i;
|
int pos, len, i;
|
||||||
|
@ -204,23 +167,28 @@ struct tagInfo readID3V1(char *file){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *extractID3Genre(char *tag){
|
char *extractID3Genre(char *tag)
|
||||||
//if (DEBUG==1) putlog("extracting id3 genre");
|
{
|
||||||
if (tag[strlen(tag)-1]==')'){
|
if (tag[strlen(tag) - 1] == ')')
|
||||||
tag[strlen(tag)-1]=0;
|
{
|
||||||
tag=&tag[1];
|
tag[strlen(tag) - 1] = 0;
|
||||||
return GENRES[str2int(tag)];
|
tag = &tag[1];
|
||||||
//return tag;
|
return GENRES[str2int(tag)];
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
int i;
|
{
|
||||||
//hexchat_print(ph, "Using 2 criteria");
|
size_t i;
|
||||||
for (i=0;i<strlen(tag);i++){
|
for (i = 0; i < strlen(tag); i++)
|
||||||
if (tag[i]==')'){ tag=&tag[i]+1;return tag;}
|
{
|
||||||
//return tag;
|
if (tag[i] == ')')
|
||||||
}
|
{
|
||||||
}
|
tag = &tag[i] + 1;
|
||||||
return "[152] failed";
|
return tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "[152] failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tagInfo readID3V2(char *file){
|
struct tagInfo readID3V2(char *file){
|
||||||
|
|
|
@ -48,12 +48,20 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
|
||||||
HWND hwnd = FindWindow("MediaPlayerClassicW",NULL);
|
HWND hwnd = FindWindow("MediaPlayerClassicW",NULL);
|
||||||
if (hwnd==0) {hexchat_print(ph, randomLine(notRunTheme));return HEXCHAT_EAT_ALL;}
|
if (hwnd==0) {hexchat_print(ph, randomLine(notRunTheme));return HEXCHAT_EAT_ALL;}
|
||||||
|
|
||||||
tTitle=(char*)malloc(sizeof(char)*1024);
|
tTitle = g_new(char, 1024);
|
||||||
GetWindowText(hwnd, tTitle, 1024);
|
GetWindowText(hwnd, tTitle, 1024);
|
||||||
zero=strstr(tTitle," - Media Player Classic");
|
zero = strstr (tTitle, " - Media Player Classic");
|
||||||
if (zero!=NULL) zero[0]=0;
|
if (zero != NULL)
|
||||||
else hexchat_print(ph,"pattern not found");
|
{
|
||||||
|
zero[0] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_free(tTitle);
|
||||||
|
hexchat_print(ph, "pattern not found");
|
||||||
|
return HEXCHAT_EAT_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((tTitle[1]==':')&&(tTitle[2]=='\\')){
|
if ((tTitle[1]==':')&&(tTitle[2]=='\\')){
|
||||||
//hexchat_print(ph,"seams to be full path");
|
//hexchat_print(ph,"seams to be full path");
|
||||||
if (endsWith(tTitle,".mp3")==1){
|
if (endsWith(tTitle,".mp3")==1){
|
||||||
|
@ -82,7 +90,8 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
|
||||||
//mp3Line=intReplace(mp3Line,"%perc",perc);
|
//mp3Line=intReplace(mp3Line,"%perc",perc);
|
||||||
//mp3Line=replace(mp3Line,"%plTitle",title);
|
//mp3Line=replace(mp3Line,"%plTitle",title);
|
||||||
mp3Line=replace(mp3Line,"%file",tTitle);
|
mp3Line=replace(mp3Line,"%file",tTitle);
|
||||||
hexchat_command(ph, mp3Line);
|
g_free(tTitle);
|
||||||
|
hexchat_command(ph, mp3Line);
|
||||||
return HEXCHAT_EAT_ALL;
|
return HEXCHAT_EAT_ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,14 +120,16 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
|
||||||
//oggLine=intReplace(oggLine,"%perc",perc);
|
//oggLine=intReplace(oggLine,"%perc",perc);
|
||||||
//oggLine=replace(oggLine,"%plTitle",title);
|
//oggLine=replace(oggLine,"%plTitle",title);
|
||||||
oggLine=replace(oggLine,"%file",tTitle);
|
oggLine=replace(oggLine,"%file",tTitle);
|
||||||
hexchat_command(ph, oggLine);
|
g_free(tTitle);
|
||||||
|
hexchat_command(ph, oggLine);
|
||||||
return HEXCHAT_EAT_ALL;
|
return HEXCHAT_EAT_ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line=randomLine(titleTheme);
|
line=randomLine(titleTheme);
|
||||||
line=replace(line,"%title", tTitle);
|
line=replace(line,"%title", tTitle);
|
||||||
hexchat_command(ph,line);
|
g_free(tTitle);
|
||||||
|
hexchat_command(ph, line);
|
||||||
return HEXCHAT_EAT_ALL;
|
return HEXCHAT_EAT_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,75 +20,32 @@
|
||||||
<RootNamespace>mpcinfo</RootNamespace>
|
<RootNamespace>mpcinfo</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcmpcinfo</TargetName>
|
<TargetName>hcmpcinfo</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcmpcinfo</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -98,6 +56,4 @@
|
||||||
<ClCompile Include="mpcInfo.c" />
|
<ClCompile Include="mpcInfo.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -25,14 +25,18 @@ static int getOggInt(char *buff, int beg, int bytes){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *upperStr(char *text){
|
static char *upperStr(char *text)
|
||||||
//if (DEBUG==1) putlog("converting text to uc");
|
{
|
||||||
//printf("upperStr(%s)\n",text);
|
char *ret = (char*) malloc(sizeof(char)*(strlen(text) + 1));
|
||||||
int i;
|
|
||||||
char *ret=(char*) malloc(sizeof(char)*(strlen(text)+1));
|
size_t i;
|
||||||
ret[strlen(text)]=0;
|
for (i = 0; i < strlen(text); i++)
|
||||||
for (i=0;i<strlen(text);i++) ret[i]=toupper(text[i]);
|
{
|
||||||
//printf("Result: %s\n",ret);
|
ret[i] = toupper(text[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret[strlen(text)] = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,24 +49,32 @@ void printThemes(){
|
||||||
hexchat_printf(ph,"\nTitle-Theme:\n");printTheme(titleTheme);
|
hexchat_printf(ph,"\nTitle-Theme:\n");printTheme(titleTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbFix(char *line){
|
void cbFix(char *line)
|
||||||
//if (DEBUG==1) putlog("cbfix");
|
{
|
||||||
int i, j;
|
size_t i;
|
||||||
for (i=0;i<strlen(line);i++){
|
for (i = 0; i < strlen(line); i++)
|
||||||
if (line[i]=='%'){
|
{
|
||||||
if ((line[i+1]=='C')||(line[i+1]=='B')||(line[i+1]=='U')||(line[i+1]=='O')||(line[i+1]=='R')){
|
size_t j;
|
||||||
if(line[i+1]=='C') line[i]=3;
|
|
||||||
if(line[i+1]=='B') line[i]=2;
|
|
||||||
if(line[i+1]=='U') line[i]=37;
|
|
||||||
if(line[i+1]=='O') line[i]=17;
|
|
||||||
if(line[i+1]=='R') line[i]=26;
|
|
||||||
|
|
||||||
for (j=i+1;j<strlen(line)-1;j++) line[j]=line[j+1];
|
if (line[i] == '%')
|
||||||
line[strlen(line)-1]=0;
|
{
|
||||||
}
|
if ((line[i + 1] == 'C') || (line[i + 1] == 'B') || (line[i + 1] == 'U') || (line[i + 1] == 'O') || (line[i + 1] == 'R'))
|
||||||
}
|
{
|
||||||
}
|
if (line[i + 1] == 'C') line[i] = 3;
|
||||||
//if (DEBUG==1) putlog("cbfix done");
|
if (line[i + 1] == 'B') line[i] = 2;
|
||||||
|
if (line[i + 1] == 'U') line[i] = 37;
|
||||||
|
if (line[i + 1] == 'O') line[i] = 17;
|
||||||
|
if (line[i + 1] == 'R') line[i] = 26;
|
||||||
|
|
||||||
|
for (j = i + 1; j < strlen(line) - 1; j++)
|
||||||
|
{
|
||||||
|
line[j] = line[j + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
line[strlen(line) - 1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct theme themeAdd(struct theme data, char *info){
|
struct theme themeAdd(struct theme data, char *info){
|
||||||
|
|
|
@ -6,13 +6,14 @@ libdir = $(hexchatlibdir)
|
||||||
|
|
||||||
lib_LTLIBRARIES = perl.la
|
lib_LTLIBRARIES = perl.la
|
||||||
perl_la_SOURCES = perl.c
|
perl_la_SOURCES = perl.c
|
||||||
perl_la_LDFLAGS = -avoid-version -module
|
perl_la_LDFLAGS = $(PERL_LDFLAGS) $(PLUGIN_LDFLAGS) -module
|
||||||
perl_la_LIBADD = $(PERL_LDFLAGS)
|
perl_la_LIBADD = $(GLIB_LIBS)
|
||||||
|
perl_la_CFLAGS = $(PERL_CFLAGS) $(GLIB_CFLAGS) -I$(top_srcdir)/src/common
|
||||||
|
|
||||||
BUILT_SOURCES = hexchat.pm.h irc.pm.h
|
BUILT_SOURCES = hexchat.pm.h irc.pm.h
|
||||||
#CFLAGS = @CFLAGS@ -Wno-unused
|
CLEANFILES = $(BUILT_SOURCES)
|
||||||
AM_CPPFLAGS = $(PERL_CFLAGS) $(COMMON_CFLAGS) -I$(srcdir)/../../src/common
|
|
||||||
CLEANFILES = hexchat.pm.h irc.pm.h
|
|
||||||
hexchat.pm.h irc.pm.h: lib/HexChat.pm lib/Xchat.pm lib/HexChat/Embed.pm \
|
hexchat.pm.h irc.pm.h: lib/HexChat.pm lib/Xchat.pm lib/HexChat/Embed.pm \
|
||||||
lib/HexChat/List/Network.pm lib/HexChat/List/Network/Entry.pm \
|
lib/HexChat/List/Network.pm lib/HexChat/List/Network/Entry.pm \
|
||||||
lib/HexChat/List/Network/AutoJoin.pm lib/IRC.pm
|
lib/HexChat/List/Network/AutoJoin.pm lib/IRC.pm
|
||||||
perl generate_header
|
cd $(srcdir); perl generate_header
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -31,12 +33,10 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#undef PACKAGE
|
#undef PACKAGE
|
||||||
#ifdef WIN32
|
|
||||||
#include "../../config-win32.h" /* for #define OLD_PERL */
|
|
||||||
#else
|
|
||||||
#include "../../config.h"
|
|
||||||
#endif
|
|
||||||
#include "hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
|
|
||||||
static hexchat_plugin *ph; /* plugin handle */
|
static hexchat_plugin *ph; /* plugin handle */
|
||||||
|
@ -78,37 +78,26 @@ thread_mbox (char *str)
|
||||||
static void
|
static void
|
||||||
perl_auto_load_from_path (const char *path)
|
perl_auto_load_from_path (const char *path)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA find_data;
|
char *search_path = g_build_filename (path, "*.pl", NULL);
|
||||||
HANDLE find_handle;
|
WIN32_FIND_DATAA find_data;
|
||||||
char *search_path;
|
HANDLE find_handle = FindFirstFileA (search_path, &find_data);
|
||||||
int path_len = strlen (path);
|
|
||||||
|
|
||||||
/* +6 for \*.pl and \0 */
|
|
||||||
search_path = malloc(path_len + 6);
|
|
||||||
sprintf (search_path, "%s\\*.pl", path);
|
|
||||||
|
|
||||||
find_handle = FindFirstFile (search_path, &find_data);
|
|
||||||
|
|
||||||
if (find_handle != INVALID_HANDLE_VALUE)
|
if (find_handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
|
if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 && (find_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0)
|
||||||
||find_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
|
|
||||||
{
|
{
|
||||||
char *full_path =
|
char *full_path = g_build_filename (path, find_data.cFileName, NULL);
|
||||||
malloc (path_len + strlen (find_data.cFileName) + 2);
|
|
||||||
sprintf (full_path, "%s\\%s", path, find_data.cFileName);
|
|
||||||
|
|
||||||
perl_load_file (full_path);
|
perl_load_file (full_path);
|
||||||
free (full_path);
|
g_free (full_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (FindNextFile (find_handle, &find_data) != 0);
|
while (FindNextFileA (find_handle, &find_data) != 0);
|
||||||
FindClose (find_handle);
|
FindClose (find_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
free (search_path);
|
g_free (search_path);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void
|
static void
|
||||||
|
@ -118,14 +107,16 @@ perl_auto_load_from_path (const char *path)
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
|
|
||||||
dir = opendir (path);
|
dir = opendir (path);
|
||||||
if (dir) {
|
if (dir)
|
||||||
while ((ent = readdir (dir))) {
|
{
|
||||||
|
while ((ent = readdir (dir)))
|
||||||
|
{
|
||||||
int len = strlen (ent->d_name);
|
int len = strlen (ent->d_name);
|
||||||
if (len > 3 && strcasecmp (".pl", ent->d_name + len - 3) == 0) {
|
if (len > 3 && strcasecmp (".pl", ent->d_name + len - 3) == 0)
|
||||||
char *file = malloc (len + strlen (path) + 2);
|
{
|
||||||
sprintf (file, "%s/%s", path, ent->d_name);
|
char *file = g_build_filename (path, ent->d_name, NULL);
|
||||||
perl_load_file (file);
|
perl_load_file (file);
|
||||||
free (file);
|
g_free (file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir (dir);
|
closedir (dir);
|
||||||
|
@ -148,31 +139,10 @@ perl_auto_load (void *unused)
|
||||||
|
|
||||||
/* don't pollute the filesystem with script files, this only causes misuse of the folders
|
/* don't pollute the filesystem with script files, this only causes misuse of the folders
|
||||||
* only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */
|
* only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */
|
||||||
#if 0
|
sub_dir = g_build_filename (xdir, "addons", NULL);
|
||||||
/* autoload from ~/.config/hexchat/ or %APPDATA%\HexChat\ on win32 */
|
|
||||||
perl_auto_load_from_path (xdir);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sub_dir = malloc (strlen (xdir) + 8);
|
|
||||||
strcpy (sub_dir, xdir);
|
|
||||||
strcat (sub_dir, "/addons");
|
|
||||||
perl_auto_load_from_path (sub_dir);
|
perl_auto_load_from_path (sub_dir);
|
||||||
free (sub_dir);
|
g_free (sub_dir);
|
||||||
|
|
||||||
#if 0
|
|
||||||
#ifdef WIN32
|
|
||||||
/* autoload from C:\Program Files\HexChat\plugins\ */
|
|
||||||
sub_dir = malloc (1025 + 9);
|
|
||||||
copied = GetModuleFileName( 0, sub_dir, 1024 );
|
|
||||||
sub_dir[copied] = '\0';
|
|
||||||
slash = strrchr( sub_dir, '\\' );
|
|
||||||
if( slash != NULL ) {
|
|
||||||
*slash = '\0';
|
|
||||||
}
|
|
||||||
perl_auto_load_from_path ( strncat (sub_dir, "\\plugins", 9));
|
|
||||||
free (sub_dir);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +261,19 @@ list_item_to_sv ( hexchat_list *list, const char *const *fields )
|
||||||
field_value = newSVuv (hexchat_list_int (ph, list, field_name));
|
field_value = newSVuv (hexchat_list_int (ph, list, field_name));
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
field_value = newSVnv (hexchat_list_time (ph, list, field_name));
|
/* From perldoc for Perl's own timelocal() and timegm():
|
||||||
|
* <quote>
|
||||||
|
* On perl versions older than 5.12.0, the range of dates that can be actually be handled depends on the size of time_t (usually a signed integer) on the given platform.
|
||||||
|
* As of version 5.12.0, perl has stopped using the underlying time library of the operating system it's running on and has its own implementation of those routines with a
|
||||||
|
* safe range of at least +/ 2**52 (about 142 million years).
|
||||||
|
* </quote>
|
||||||
|
*
|
||||||
|
* This is further confirmed from looking at the source for Time::Local - it's a Perl module and the implementations of timelocal() and timegm() use simple addition and
|
||||||
|
* subtraction of numbers. Perl automatically promotes numbers from int32_t (IV) to uint32_t (UV) to 64-bit IEEE754 double (NV) as required.
|
||||||
|
*
|
||||||
|
* This means that using a double (NV) for our own time_t suffers from the same assumptions that Perl's own functions do.
|
||||||
|
*/
|
||||||
|
field_value = newSVnv ((const NV) hexchat_list_time (ph, list, field_name));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
field_value = &PL_sv_undef;
|
field_value = &PL_sv_undef;
|
||||||
|
@ -375,7 +357,7 @@ fd_cb (int fd, int flags, void *userdata)
|
||||||
if (data->userdata) {
|
if (data->userdata) {
|
||||||
SvREFCNT_dec (data->userdata);
|
SvREFCNT_dec (data->userdata);
|
||||||
}
|
}
|
||||||
free (data);
|
g_free (data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +721,7 @@ XS (XS_HexChat_send_modes)
|
||||||
if (SvROK (ST (0))) {
|
if (SvROK (ST (0))) {
|
||||||
p_targets = (AV*) SvRV (ST (0));
|
p_targets = (AV*) SvRV (ST (0));
|
||||||
target_count = av_len (p_targets) + 1;
|
target_count = av_len (p_targets) + 1;
|
||||||
targets = malloc (target_count * sizeof (char *));
|
targets = g_new (const char *, target_count);
|
||||||
for (i = 0; i < target_count; i++ ) {
|
for (i = 0; i < target_count; i++ ) {
|
||||||
elem = av_fetch (p_targets, i, 0);
|
elem = av_fetch (p_targets, i, 0);
|
||||||
|
|
||||||
|
@ -750,13 +732,13 @@ XS (XS_HexChat_send_modes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else{
|
} else{
|
||||||
targets = malloc (sizeof (char *));
|
targets = g_new (const char *, 1);
|
||||||
targets[0] = SvPV_nolen (ST (0));
|
targets[0] = SvPV_nolen (ST (0));
|
||||||
target_count = 1;
|
target_count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target_count == 0) {
|
if (target_count == 0) {
|
||||||
free (targets);
|
g_free ((char**) targets);
|
||||||
XSRETURN_EMPTY;
|
XSRETURN_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,7 +750,7 @@ XS (XS_HexChat_send_modes)
|
||||||
}
|
}
|
||||||
|
|
||||||
hexchat_send_modes (ph, targets, target_count, modes_per_line, sign, mode);
|
hexchat_send_modes (ph, targets, target_count, modes_per_line, sign, mode);
|
||||||
free (targets);
|
g_free ((char**) targets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static
|
static
|
||||||
|
@ -886,11 +868,7 @@ XS (XS_HexChat_hook_server)
|
||||||
userdata = ST (3);
|
userdata = ST (3);
|
||||||
package = ST (4);
|
package = ST (4);
|
||||||
data = NULL;
|
data = NULL;
|
||||||
data = malloc (sizeof (HookData));
|
data = g_new (HookData, 1);
|
||||||
if (data == NULL) {
|
|
||||||
XSRETURN_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->callback = newSVsv (callback);
|
data->callback = newSVsv (callback);
|
||||||
data->userdata = newSVsv (userdata);
|
data->userdata = newSVsv (userdata);
|
||||||
data->depth = 0;
|
data->depth = 0;
|
||||||
|
@ -935,11 +913,7 @@ XS (XS_HexChat_hook_command)
|
||||||
package = ST (5);
|
package = ST (5);
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
|
||||||
data = malloc (sizeof (HookData));
|
data = g_new (HookData, 1);
|
||||||
if (data == NULL) {
|
|
||||||
XSRETURN_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->callback = newSVsv (callback);
|
data->callback = newSVsv (callback);
|
||||||
data->userdata = newSVsv (userdata);
|
data->userdata = newSVsv (userdata);
|
||||||
data->depth = 0;
|
data->depth = 0;
|
||||||
|
@ -975,11 +949,7 @@ XS (XS_HexChat_hook_print)
|
||||||
userdata = ST (3);
|
userdata = ST (3);
|
||||||
package = ST (4);
|
package = ST (4);
|
||||||
|
|
||||||
data = malloc (sizeof (HookData));
|
data = g_new (HookData, 1);
|
||||||
if (data == NULL) {
|
|
||||||
XSRETURN_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->callback = newSVsv (callback);
|
data->callback = newSVsv (callback);
|
||||||
data->userdata = newSVsv (userdata);
|
data->userdata = newSVsv (userdata);
|
||||||
data->depth = 0;
|
data->depth = 0;
|
||||||
|
@ -1013,11 +983,7 @@ XS (XS_HexChat_hook_timer)
|
||||||
userdata = ST (2);
|
userdata = ST (2);
|
||||||
package = ST (3);
|
package = ST (3);
|
||||||
|
|
||||||
data = malloc (sizeof (HookData));
|
data = g_new (HookData, 1);
|
||||||
if (data == NULL) {
|
|
||||||
XSRETURN_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->callback = newSVsv (callback);
|
data->callback = newSVsv (callback);
|
||||||
data->userdata = newSVsv (userdata);
|
data->userdata = newSVsv (userdata);
|
||||||
data->ctx = hexchat_get_context (ph);
|
data->ctx = hexchat_get_context (ph);
|
||||||
|
@ -1067,11 +1033,7 @@ XS (XS_HexChat_hook_fd)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data = malloc (sizeof (HookData));
|
data = g_new (HookData, 1);
|
||||||
if (data == NULL) {
|
|
||||||
XSRETURN_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->callback = newSVsv (callback);
|
data->callback = newSVsv (callback);
|
||||||
data->userdata = newSVsv (userdata);
|
data->userdata = newSVsv (userdata);
|
||||||
data->depth = 0;
|
data->depth = 0;
|
||||||
|
@ -1111,7 +1073,7 @@ XS (XS_HexChat_unhook)
|
||||||
SvREFCNT_dec (userdata->package);
|
SvREFCNT_dec (userdata->package);
|
||||||
}
|
}
|
||||||
|
|
||||||
free (userdata);
|
g_free (userdata);
|
||||||
}
|
}
|
||||||
XSRETURN (retCount);
|
XSRETURN (retCount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,66 +20,28 @@
|
||||||
<RootNamespace>perl520</RootNamespace>
|
<RootNamespace>perl520</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<TargetName>hcperl</TargetName>
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>$(PerlOutput)</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>$(PerlOutput)</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PERL520_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PERL520_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(PerlPath)\lib\CORE;$(IntDir);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(IntDir);..\..\src\common;$(HexChatLib);$(PerlPath)\lib\CORE;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<AdditionalLibraryDirectories>$(IntDir);$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<AdditionalDependencies>$(PerlLib).lib;$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<AdditionalDependencies>$(PerlLib).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
|
||||||
<DelayLoadDLLs>$(PerlLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>$(PerlLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
<Command>"$(GendefPath)\gendef" "$(PerlPath)\bin\$(PerlLib).dll"
|
<Command>"$(GendefPath)\gendef" "$(PerlPath)\bin\$(PerlLib).dll"
|
||||||
move $(PerlLib).def "$(IntDir)"
|
move $(PerlLib).def "$(IntDir)"
|
||||||
lib /nologo /machine:x86 "/def:$(IntDir)$(PerlLib).def" "/out:$(OutDir)\$(PerlLib).lib"
|
lib /nologo /machine:x86 "/def:$(IntDir)$(PerlLib).def" "/out:$(IntDir)\$(PerlLib).lib"
|
||||||
"$(PerlPath)\bin\perl.exe" generate_header
|
"$(PerlPath)\bin\perl.exe" generate_header
|
||||||
move irc.pm.h "$(IntDir)"
|
move irc.pm.h "$(IntDir)"
|
||||||
move hexchat.pm.h "$(IntDir)"</Command>
|
move hexchat.pm.h "$(IntDir)"</Command>
|
||||||
|
@ -86,28 +49,19 @@ move hexchat.pm.h "$(IntDir)"</Command>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PERL520_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PERL520_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(PerlPath)\lib\CORE;$(IntDir);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(IntDir);..\..\src\common;$(HexChatLib);$(PerlPath)\lib\CORE;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<AdditionalLibraryDirectories>$(IntDir);$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<AdditionalDependencies>$(PerlLib).lib;$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<AdditionalDependencies>$(PerlLib).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
|
||||||
<DelayLoadDLLs>$(PerlLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>$(PerlLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
<Command>"$(GendefPath)\gendef" "$(PerlPath)\bin\$(PerlLib).dll"
|
<Command>"$(GendefPath)\gendef" "$(PerlPath)\bin\$(PerlLib).dll"
|
||||||
move $(PerlLib).def "$(IntDir)"
|
move $(PerlLib).def "$(IntDir)"
|
||||||
lib /nologo /machine:x64 "/def:$(IntDir)$(PerlLib).def" "/out:$(OutDir)\$(PerlLib).lib"
|
lib /nologo /machine:x64 "/def:$(IntDir)$(PerlLib).def" "/out:$(IntDir)\$(PerlLib).lib"
|
||||||
"$(PerlPath)\bin\perl.exe" generate_header
|
"$(PerlPath)\bin\perl.exe" generate_header
|
||||||
move irc.pm.h "$(IntDir)"
|
move irc.pm.h "$(IntDir)"
|
||||||
move hexchat.pm.h "$(IntDir)"</Command>
|
move hexchat.pm.h "$(IntDir)"</Command>
|
||||||
|
@ -120,6 +74,4 @@ move hexchat.pm.h "$(IntDir)"</Command>
|
||||||
<ClCompile Include="perl.c" />
|
<ClCompile Include="perl.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
AC_INIT(@PLUGIN@-config.h.in)
|
|
||||||
AM_CONFIG_HEADER(@PLUGIN@-config.h)
|
|
||||||
AM_INIT_AUTOMAKE(hexchat-@PLUGIN@, @PLUGIN_VERSION@)
|
|
||||||
AM_MAINTAINER_MODE
|
|
||||||
AM_DISABLE_STATIC
|
|
||||||
AM_PROG_LIBTOOL
|
|
||||||
|
|
||||||
AC_ARG_WITH(plugin-includes,
|
|
||||||
[ --with-plugin-includes directory containing hexchat-plugin.h],
|
|
||||||
PLUGIN_INCLUDES=$enableval)
|
|
||||||
|
|
||||||
AC_SUBST(PLUGIN_INCLUDES)
|
|
||||||
|
|
||||||
hexchatlibdir=${libdir}/hexchat
|
|
||||||
AC_SUBST(hexchatlibdir)
|
|
||||||
|
|
||||||
AC_OUTPUT(
|
|
||||||
Makefile
|
|
||||||
)
|
|
|
@ -1,10 +1,8 @@
|
||||||
EXTRA_DIST =
|
|
||||||
|
|
||||||
libdir = $(hexchatlibdir)
|
libdir = $(hexchatlibdir)
|
||||||
|
|
||||||
lib_LTLIBRARIES = python.la
|
lib_LTLIBRARIES = python.la
|
||||||
python_la_SOURCES = python.c
|
python_la_SOURCES = python.c
|
||||||
python_la_LDFLAGS = -avoid-version -module
|
python_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
|
||||||
python_la_LIBADD = $(PY_LIBS)
|
python_la_LIBADD = $(PY_LIBS) $(GLIB_LIBS)
|
||||||
AM_CPPFLAGS = $(PY_CFLAGS) $(COMMON_CFLAGS) -I$(srcdir)/../../src/common
|
python_la_CFLAGS = $(PY_CFLAGS) $(GLIB_CFLAGS) -I$(top_srcdir)/src/common
|
||||||
|
|
||||||
|
|
|
@ -51,23 +51,24 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <glib/gstdio.h>
|
|
||||||
#include "../../src/dirent/dirent-win32.h"
|
|
||||||
#include "../../config-win32.h"
|
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
#undef _POSIX_C_SOURCE /* Avoid warning: also in /usr/include/features.h from glib.h */
|
#undef _POSIX_C_SOURCE /* Avoid warnings from /usr/include/features.h */
|
||||||
|
#undef _XOPEN_SOURCE
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <structmember.h>
|
#include <structmember.h>
|
||||||
#include <pythread.h>
|
#include <pythread.h>
|
||||||
|
@ -415,6 +416,9 @@ Util_BuildEOLList(char *word[])
|
||||||
PyObject *list;
|
PyObject *list;
|
||||||
int listsize = 31;
|
int listsize = 31;
|
||||||
int i;
|
int i;
|
||||||
|
char *accum = NULL;
|
||||||
|
char *last = NULL;
|
||||||
|
|
||||||
/* Find the last valid array member; there may be intermediate NULLs that
|
/* Find the last valid array member; there may be intermediate NULLs that
|
||||||
* would otherwise cause us to drop some members. */
|
* would otherwise cause us to drop some members. */
|
||||||
while (listsize > 0 &&
|
while (listsize > 0 &&
|
||||||
|
@ -425,10 +429,9 @@ Util_BuildEOLList(char *word[])
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
char *accum = NULL;
|
|
||||||
char *last = NULL;
|
|
||||||
for (i = listsize; i > 0; i--) {
|
for (i = listsize; i > 0; i--) {
|
||||||
char *part = word[i];
|
char *part = word[i];
|
||||||
|
PyObject *uni_part;
|
||||||
if (accum == NULL) {
|
if (accum == NULL) {
|
||||||
accum = g_strdup (part);
|
accum = g_strdup (part);
|
||||||
} else if (part != NULL && part[0] != 0) {
|
} else if (part != NULL && part[0] != 0) {
|
||||||
|
@ -444,14 +447,12 @@ Util_BuildEOLList(char *word[])
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PyObject *uni_part = PyUnicode_FromString(accum);
|
uni_part = PyUnicode_FromString(accum);
|
||||||
PyList_SetItem(list, i - 1, uni_part);
|
PyList_SetItem(list, i - 1, uni_part);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last)
|
g_free (last);
|
||||||
g_free (last);
|
g_free (accum);
|
||||||
if (accum)
|
|
||||||
g_free (accum);
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -459,26 +460,31 @@ Util_BuildEOLList(char *word[])
|
||||||
static void
|
static void
|
||||||
Util_Autoload_from (const char *dir_name)
|
Util_Autoload_from (const char *dir_name)
|
||||||
{
|
{
|
||||||
#ifndef PATH_MAX
|
gchar *oldcwd;
|
||||||
#define PATH_MAX 1024 /* Hurd doesn't define it */
|
const char *entry_name;
|
||||||
#endif
|
GDir *dir;
|
||||||
char oldcwd[PATH_MAX];
|
|
||||||
struct dirent *ent;
|
oldcwd = g_get_current_dir ();
|
||||||
DIR *dir;
|
if (oldcwd == NULL)
|
||||||
if (getcwd(oldcwd, PATH_MAX) == NULL)
|
|
||||||
return;
|
return;
|
||||||
if (chdir(dir_name) != 0)
|
if (g_chdir(dir_name) != 0)
|
||||||
|
{
|
||||||
|
g_free (oldcwd);
|
||||||
return;
|
return;
|
||||||
dir = opendir(".");
|
|
||||||
if (dir == NULL)
|
|
||||||
return;
|
|
||||||
while ((ent = readdir(dir))) {
|
|
||||||
int len = strlen(ent->d_name);
|
|
||||||
if (len > 3 && strcmp(".py", ent->d_name+len-3) == 0)
|
|
||||||
Command_PyLoad(ent->d_name);
|
|
||||||
}
|
}
|
||||||
closedir(dir);
|
dir = g_dir_open (".", 0, NULL);
|
||||||
chdir(oldcwd);
|
if (dir == NULL)
|
||||||
|
{
|
||||||
|
g_free (oldcwd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while ((entry_name = g_dir_read_name (dir)))
|
||||||
|
{
|
||||||
|
if (g_str_has_suffix (entry_name, ".py"))
|
||||||
|
Command_PyLoad((char*)entry_name);
|
||||||
|
}
|
||||||
|
g_dir_close (dir);
|
||||||
|
g_chdir (oldcwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -486,7 +492,7 @@ Util_Autoload()
|
||||||
{
|
{
|
||||||
const char *xdir;
|
const char *xdir;
|
||||||
char *sub_dir;
|
char *sub_dir;
|
||||||
/* we need local filesystem encoding for chdir, opendir etc */
|
/* we need local filesystem encoding for g_chdir, g_dir_open etc */
|
||||||
|
|
||||||
xdir = hexchat_get_info(ph, "configdir");
|
xdir = hexchat_get_info(ph, "configdir");
|
||||||
|
|
||||||
|
@ -796,9 +802,7 @@ Callback_ThreadTimer(void *userdata)
|
||||||
/* We keep this information global, so we can reset it when the
|
/* We keep this information global, so we can reset it when the
|
||||||
* deinit function is called. */
|
* deinit function is called. */
|
||||||
/* XXX This should be somehow bound to the printing context. */
|
/* XXX This should be somehow bound to the printing context. */
|
||||||
static char *xchatout_buffer = NULL;
|
static GString *xchatout_buffer = NULL;
|
||||||
static int xchatout_buffer_size = 0;
|
|
||||||
static int xchatout_buffer_pos = 0;
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
XChatOut_New()
|
XChatOut_New()
|
||||||
|
@ -822,76 +826,42 @@ XChatOut_dealloc(PyObject *self)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
XChatOut_write(PyObject *self, PyObject *args)
|
XChatOut_write(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int new_buffer_pos, data_size, print_limit, add_space;
|
gboolean add_space;
|
||||||
char *data, *pos;
|
char *data, *pos;
|
||||||
if (!PyArg_ParseTuple(args, "s#:write", &data, &data_size))
|
|
||||||
|
if (!PyArg_ParseTuple(args, "s:write", &data))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!data_size) {
|
if (!data || !*data) {
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
BEGIN_XCHAT_CALLS(RESTORE_CONTEXT|ALLOW_THREADS);
|
BEGIN_XCHAT_CALLS(RESTORE_CONTEXT|ALLOW_THREADS);
|
||||||
if (((XChatOutObject *)self)->softspace) {
|
if (((XChatOutObject *)self)->softspace) {
|
||||||
add_space = 1;
|
add_space = TRUE;
|
||||||
((XChatOutObject *)self)->softspace = 0;
|
((XChatOutObject *)self)->softspace = 0;
|
||||||
} else {
|
} else {
|
||||||
add_space = 0;
|
add_space = FALSE;
|
||||||
}
|
}
|
||||||
if (xchatout_buffer_size-xchatout_buffer_pos < data_size+add_space) {
|
|
||||||
char *new_buffer;
|
g_string_append (xchatout_buffer, data);
|
||||||
/* This buffer grows whenever needed, and does not
|
|
||||||
* shrink. If we ever implement unloading of the
|
/* If not end of line add space to continue buffer later */
|
||||||
* python interface, we must find some way to free
|
if (add_space && xchatout_buffer->str[xchatout_buffer->len - 1] != '\n')
|
||||||
* this buffer as well. */
|
{
|
||||||
xchatout_buffer_size += data_size*2+16;
|
g_string_append_c (xchatout_buffer, ' ');
|
||||||
new_buffer = g_realloc(xchatout_buffer, xchatout_buffer_size);
|
}
|
||||||
if (new_buffer == NULL) {
|
|
||||||
hexchat_print(ph, "Not enough memory to print");
|
/* If there is an end of line print up to that */
|
||||||
/* The system is out of resources. Let's help. */
|
if ((pos = strrchr (xchatout_buffer->str, '\n')))
|
||||||
g_free(xchatout_buffer);
|
{
|
||||||
xchatout_buffer = NULL;
|
*pos = '\0';
|
||||||
xchatout_buffer_size = 0;
|
hexchat_print (ph, xchatout_buffer->str);
|
||||||
xchatout_buffer_pos = 0;
|
|
||||||
/* Return something valid, since we have
|
/* Then remove it from buffer */
|
||||||
* already warned the user, and he probably
|
g_string_erase (xchatout_buffer, 0, pos - xchatout_buffer->str + 1);
|
||||||
* won't be able to notice this exception. */
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
xchatout_buffer = new_buffer;
|
|
||||||
}
|
|
||||||
memcpy(xchatout_buffer+xchatout_buffer_pos, data, data_size);
|
|
||||||
print_limit = new_buffer_pos = xchatout_buffer_pos+data_size;
|
|
||||||
pos = xchatout_buffer+print_limit;
|
|
||||||
if (add_space && *(pos-1) != '\n') {
|
|
||||||
*pos = ' ';
|
|
||||||
*(pos+1) = 0;
|
|
||||||
new_buffer_pos++;
|
|
||||||
}
|
|
||||||
while (*pos != '\n' && print_limit > xchatout_buffer_pos) {
|
|
||||||
pos--;
|
|
||||||
print_limit--;
|
|
||||||
}
|
|
||||||
if (*pos == '\n') {
|
|
||||||
/* Crop it, inserting the string limiter there. */
|
|
||||||
*pos = 0;
|
|
||||||
hexchat_print(ph, xchatout_buffer);
|
|
||||||
if (print_limit < new_buffer_pos) {
|
|
||||||
/* There's still data to be printed. */
|
|
||||||
print_limit += 1; /* Include the limiter. */
|
|
||||||
xchatout_buffer_pos = new_buffer_pos-print_limit;
|
|
||||||
memmove(xchatout_buffer, xchatout_buffer+print_limit,
|
|
||||||
xchatout_buffer_pos);
|
|
||||||
} else {
|
|
||||||
xchatout_buffer_pos = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
xchatout_buffer_pos = new_buffer_pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
|
||||||
END_XCHAT_CALLS();
|
END_XCHAT_CALLS();
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OFF(x) offsetof(XChatOutObject, x)
|
#define OFF(x) offsetof(XChatOutObject, x)
|
||||||
|
@ -1043,8 +1013,7 @@ Context_set(ContextObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *plugin = Plugin_GetCurrent();
|
PyObject *plugin = Plugin_GetCurrent();
|
||||||
Plugin_SetContext(plugin, self->context);
|
Plugin_SetContext(plugin, self->context);
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1057,8 +1026,7 @@ Context_command(ContextObject *self, PyObject *args)
|
||||||
hexchat_set_context(ph, self->context);
|
hexchat_set_context(ph, self->context);
|
||||||
hexchat_command(ph, text);
|
hexchat_command(ph, text);
|
||||||
END_XCHAT_CALLS();
|
END_XCHAT_CALLS();
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1071,8 +1039,7 @@ Context_prnt(ContextObject *self, PyObject *args)
|
||||||
hexchat_set_context(ph, self->context);
|
hexchat_set_context(ph, self->context);
|
||||||
hexchat_print(ph, text);
|
hexchat_print(ph, text);
|
||||||
END_XCHAT_CALLS();
|
END_XCHAT_CALLS();
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1117,8 +1084,7 @@ Context_get_info(ContextObject *self, PyObject *args)
|
||||||
info = hexchat_get_info(ph, name);
|
info = hexchat_get_info(ph, name);
|
||||||
END_XCHAT_CALLS();
|
END_XCHAT_CALLS();
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
return PyUnicode_FromString(info);
|
return PyUnicode_FromString(info);
|
||||||
}
|
}
|
||||||
|
@ -1401,11 +1367,7 @@ static Hook *
|
||||||
Plugin_AddHook(int type, PyObject *plugin, PyObject *callback,
|
Plugin_AddHook(int type, PyObject *plugin, PyObject *callback,
|
||||||
PyObject *userdata, char *name, void *data)
|
PyObject *userdata, char *name, void *data)
|
||||||
{
|
{
|
||||||
Hook *hook = (Hook *) g_malloc(sizeof(Hook));
|
Hook *hook = g_new(Hook, 1);
|
||||||
if (hook == NULL) {
|
|
||||||
PyErr_NoMemory();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
hook->type = type;
|
hook->type = type;
|
||||||
hook->plugin = plugin;
|
hook->plugin = plugin;
|
||||||
Py_INCREF(callback);
|
Py_INCREF(callback);
|
||||||
|
@ -1459,8 +1421,7 @@ Plugin_RemoveHook(PyObject *plugin, Hook *hook)
|
||||||
hook));
|
hook));
|
||||||
Py_DECREF(hook->callback);
|
Py_DECREF(hook->callback);
|
||||||
Py_DECREF(hook->userdata);
|
Py_DECREF(hook->userdata);
|
||||||
if (hook->name)
|
g_free(hook->name);
|
||||||
g_free(hook->name);
|
|
||||||
g_free(hook);
|
g_free(hook);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1479,8 +1440,7 @@ Plugin_RemoveAllHooks(PyObject *plugin)
|
||||||
}
|
}
|
||||||
Py_DECREF(hook->callback);
|
Py_DECREF(hook->callback);
|
||||||
Py_DECREF(hook->userdata);
|
Py_DECREF(hook->userdata);
|
||||||
if (hook->name)
|
g_free(hook->name);
|
||||||
g_free(hook->name);
|
|
||||||
g_free(hook);
|
g_free(hook);
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
|
@ -1709,8 +1669,7 @@ Module_hexchat_command(PyObject *self, PyObject *args)
|
||||||
BEGIN_XCHAT_CALLS(RESTORE_CONTEXT|ALLOW_THREADS);
|
BEGIN_XCHAT_CALLS(RESTORE_CONTEXT|ALLOW_THREADS);
|
||||||
hexchat_command(ph, text);
|
hexchat_command(ph, text);
|
||||||
END_XCHAT_CALLS();
|
END_XCHAT_CALLS();
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1722,8 +1681,7 @@ Module_xchat_prnt(PyObject *self, PyObject *args)
|
||||||
BEGIN_XCHAT_CALLS(RESTORE_CONTEXT|ALLOW_THREADS);
|
BEGIN_XCHAT_CALLS(RESTORE_CONTEXT|ALLOW_THREADS);
|
||||||
hexchat_print(ph, text);
|
hexchat_print(ph, text);
|
||||||
END_XCHAT_CALLS();
|
END_XCHAT_CALLS();
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1766,8 +1724,7 @@ Module_hexchat_get_info(PyObject *self, PyObject *args)
|
||||||
info = hexchat_get_info(ph, name);
|
info = hexchat_get_info(ph, name);
|
||||||
END_XCHAT_CALLS();
|
END_XCHAT_CALLS();
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
if (strcmp (name, "gtkwin_ptr") == 0)
|
if (strcmp (name, "gtkwin_ptr") == 0)
|
||||||
return PyUnicode_FromFormat("%p", info); /* format as pointer */
|
return PyUnicode_FromFormat("%p", info); /* format as pointer */
|
||||||
|
@ -1820,8 +1777,7 @@ Module_hexchat_get_context(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
ctxobj = Context_FromContext(Plugin_GetContext(plugin));
|
ctxobj = Context_FromContext(Plugin_GetContext(plugin));
|
||||||
if (ctxobj == NULL) {
|
if (ctxobj == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
return ctxobj;
|
return ctxobj;
|
||||||
}
|
}
|
||||||
|
@ -1838,8 +1794,7 @@ Module_hexchat_find_context(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
return NULL;
|
return NULL;
|
||||||
ctxobj = Context_FromServerAndChannel(server, channel);
|
ctxobj = Context_FromServerAndChannel(server, channel);
|
||||||
if (ctxobj == NULL) {
|
if (ctxobj == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
return ctxobj;
|
return ctxobj;
|
||||||
}
|
}
|
||||||
|
@ -1885,7 +1840,7 @@ Module_hexchat_pluginpref_get(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "s:get_pluginpref", &var))
|
if (!PyArg_ParseTuple(args, "s:get_pluginpref", &var))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// This will always return numbers as integers.
|
/* This will always return numbers as integers. */
|
||||||
BEGIN_XCHAT_CALLS(NONE);
|
BEGIN_XCHAT_CALLS(NONE);
|
||||||
result = hexchat_pluginpref_get_str(prefph, var, retstr);
|
result = hexchat_pluginpref_get_str(prefph, var, retstr);
|
||||||
END_XCHAT_CALLS();
|
END_XCHAT_CALLS();
|
||||||
|
@ -2219,8 +2174,7 @@ Module_hexchat_unhook(PyObject *self, PyObject *args)
|
||||||
Plugin_RemoveHook(plugin, hook);
|
Plugin_RemoveHook(plugin, hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -2528,11 +2482,8 @@ IInterp_Exec(char *command)
|
||||||
}
|
}
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
len = strlen(command);
|
len = strlen(command);
|
||||||
buffer = (char *) g_malloc(len+2);
|
|
||||||
if (buffer == NULL) {
|
buffer = g_malloc(len + 2);
|
||||||
hexchat_print(ph, "Not enough memory for command buffer");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
memcpy(buffer, command, len);
|
memcpy(buffer, command, len);
|
||||||
buffer[len] = '\n';
|
buffer[len] = '\n';
|
||||||
buffer[len+1] = 0;
|
buffer[len+1] = 0;
|
||||||
|
@ -2778,6 +2729,7 @@ hexchat_plugin_init(hexchat_plugin *plugin_handle,
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
PySys_SetArgv(1, argv);
|
PySys_SetArgv(1, argv);
|
||||||
|
|
||||||
|
xchatout_buffer = g_string_new (NULL);
|
||||||
xchatout = XChatOut_New();
|
xchatout = XChatOut_New();
|
||||||
if (xchatout == NULL) {
|
if (xchatout == NULL) {
|
||||||
hexchat_print(ph, "Can't allocate xchatout object");
|
hexchat_print(ph, "Can't allocate xchatout object");
|
||||||
|
@ -2848,10 +2800,8 @@ hexchat_plugin_deinit()
|
||||||
plugin_list = NULL;
|
plugin_list = NULL;
|
||||||
|
|
||||||
/* Reset xchatout buffer. */
|
/* Reset xchatout buffer. */
|
||||||
g_free(xchatout_buffer);
|
g_string_free (xchatout_buffer, TRUE);
|
||||||
xchatout_buffer = NULL;
|
xchatout_buffer = NULL;
|
||||||
xchatout_buffer_size = 0;
|
|
||||||
xchatout_buffer_pos = 0;
|
|
||||||
|
|
||||||
if (interp_plugin) {
|
if (interp_plugin) {
|
||||||
Py_DECREF(interp_plugin);
|
Py_DECREF(interp_plugin);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,80 +20,33 @@
|
||||||
<RootNamespace>python2</RootNamespace>
|
<RootNamespace>python2</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>$(Python2Output)</TargetName>
|
<TargetName>$(Python2Output)</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>$(Python2Output)</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(Glib);$(Python2Path)\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(Glib);$(Python2Path)\include;..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
|
||||||
<AdditionalDependencies>"$(Python2Lib).lib";$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>"$(Python2Lib).lib";$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(OutDir);$(Python2Path)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(Python2Path)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(Glib);$(Python2Path)\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(Glib);$(Python2Path)\include;..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
|
||||||
<AdditionalDependencies>"$(Python2Lib).lib";$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>"$(Python2Lib).lib";$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(OutDir);$(Python2Path)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(Python2Path)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -102,6 +56,4 @@
|
||||||
<ClCompile Include="python.c" />
|
<ClCompile Include="python.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,80 +20,33 @@
|
||||||
<RootNamespace>python3</RootNamespace>
|
<RootNamespace>python3</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>$(Python3Output)</TargetName>
|
<TargetName>$(Python3Output)</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>$(Python3Output)</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(Glib);$(Python3Path)\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(Glib);$(Python3Path)\include;..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
|
||||||
<AdditionalDependencies>"$(Python3Lib).lib";$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>"$(Python3Lib).lib";$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(OutDir);$(Python3Path)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(Python3Path)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(Glib);$(Python3Path)\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(Glib);$(Python3Path)\include;..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
|
||||||
<AdditionalDependencies>"$(Python3Lib).lib";$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>"$(Python3Lib).lib";$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(OutDir);$(Python3Path)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(Python3Path)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -102,6 +56,4 @@
|
||||||
<ClCompile Include="python.c" />
|
<ClCompile Include="python.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -1,7 +1,17 @@
|
||||||
libdir = $(hexchatlibdir)
|
libdir = $(hexchatlibdir)
|
||||||
|
|
||||||
|
sources = sysinfo.c format.c shared/df.c
|
||||||
|
|
||||||
|
if PLATFORM_OSX
|
||||||
|
sources += osx/backend.m
|
||||||
|
else
|
||||||
|
sources += unix/backend.c unix/match.c unix/parse.c unix/pci.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST = osx unix win32 shared format.h sysinfo.h sysinfo-backend.h
|
||||||
|
|
||||||
lib_LTLIBRARIES = sysinfo.la
|
lib_LTLIBRARIES = sysinfo.la
|
||||||
sysinfo_la_SOURCES = hwmon.c match.c parse.c pci.c xsys.c
|
sysinfo_la_SOURCES = $(sources)
|
||||||
sysinfo_la_LDFLAGS = -avoid-version -module
|
sysinfo_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
|
||||||
sysinfo_la_LIBADD = -lpci
|
sysinfo_la_LIBADD = $(LIBPCI_LIBS) $(GLIB_LIBS)
|
||||||
AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/../../src/common
|
AM_CPPFLAGS = $(LIBPCI_CFLAGS) $(GLIB_CFLAGS) -I$(top_srcdir)/src/common -I$(srcdir)/shared
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* SysInfo - sysinfo plugin for HexChat
|
||||||
|
* Copyright (c) 2015 Patrick Griffis.
|
||||||
|
*
|
||||||
|
* This program is free software you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_format_uptime (gint64 uptime)
|
||||||
|
{
|
||||||
|
char buffer[128];
|
||||||
|
|
||||||
|
gint64 weeks = uptime / 604800;
|
||||||
|
int days = (uptime / 86400) % 7;
|
||||||
|
int hours = (uptime / 3600) % 24;
|
||||||
|
int minutes = (uptime / 60) % 60;
|
||||||
|
int seconds = uptime % 60;
|
||||||
|
|
||||||
|
if (weeks != 0)
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, sizeof(buffer), "%" G_GINT64_FORMAT "w %dd %dh %dm %ds", weeks, days, hours, minutes, seconds);
|
||||||
|
}
|
||||||
|
else if (days != 0)
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, sizeof(buffer), "%dd %dh %dm %ds", days, hours, minutes, seconds);
|
||||||
|
}
|
||||||
|
else if (hours != 0)
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, sizeof(buffer), "%dh %dm %ds", hours, minutes, seconds);
|
||||||
|
}
|
||||||
|
else if (minutes != 0)
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, sizeof(buffer), "%dm %ds", minutes, seconds);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, sizeof(buffer), "%ds", seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_format_memory (guint64 totalmem, guint64 freemem)
|
||||||
|
{
|
||||||
|
char *total_fmt, *free_fmt, *ret;
|
||||||
|
|
||||||
|
total_fmt = g_format_size_full (totalmem, G_FORMAT_SIZE_IEC_UNITS);
|
||||||
|
free_fmt = g_format_size_full (freemem, G_FORMAT_SIZE_IEC_UNITS);
|
||||||
|
ret = g_strdup_printf ("%s Total (%s Free)", total_fmt, free_fmt);
|
||||||
|
|
||||||
|
g_free (total_fmt);
|
||||||
|
g_free (free_fmt);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_format_disk (guint64 total, guint64 free)
|
||||||
|
{
|
||||||
|
char *total_fmt, *free_fmt, *used_fmt, *ret;
|
||||||
|
GFormatSizeFlags format_flags = G_FORMAT_SIZE_DEFAULT;
|
||||||
|
|
||||||
|
#ifdef WIN32 /* Windows uses IEC size (with SI format) */
|
||||||
|
format_flags = G_FORMAT_SIZE_IEC_UNITS;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
total_fmt = g_format_size_full (total, format_flags);
|
||||||
|
free_fmt = g_format_size_full (free, format_flags);
|
||||||
|
used_fmt = g_format_size_full (total - free, format_flags);
|
||||||
|
ret = g_strdup_printf ("%s / %s (%s Free)", used_fmt, total_fmt, free_fmt);
|
||||||
|
|
||||||
|
g_free (total_fmt);
|
||||||
|
g_free (free_fmt);
|
||||||
|
g_free (used_fmt);
|
||||||
|
return ret;
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* xsys.h - X-Sys general parameters header
|
* SysInfo - sysinfo plugin for HexChat
|
||||||
* Copyright (C) 2005 Gustavo Zacarias
|
* Copyright (c) 2015 Patrick Griffis.
|
||||||
* Copyright (C) 2006, 2007 Tony Vroon
|
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,14 +18,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _XSYS_H_
|
#ifndef FORMAT_H
|
||||||
#define _XSYS_H_
|
#define FORMAT_H
|
||||||
|
|
||||||
#define bsize 1024
|
char *sysinfo_format_uptime(gint64 uptime);
|
||||||
#define delims ":="
|
char *sysinfo_format_memory(guint64 totalmem, guint64 freemem);
|
||||||
|
char *sysinfo_format_disk(guint64 total, guint64 free);
|
||||||
int sysinfo_get_percent ();
|
|
||||||
void sysinfo_get_pciids (char *dest);
|
|
||||||
void sysinfo_print_error (const char* msg);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* hwmon.c - Hardware monitoring functions for X-Sys
|
|
||||||
* Copyright (C) 2005 Tony Vroon
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "xsys.h"
|
|
||||||
|
|
||||||
int hwmon_chip_present()
|
|
||||||
{
|
|
||||||
FILE *fp = fopen("/sys/class/hwmon/hwmon0/device/name", "r");
|
|
||||||
if(fp != NULL) {
|
|
||||||
fclose(fp);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
void get_hwmon_chip_name(char *name)
|
|
||||||
{
|
|
||||||
char *position, buffer[bsize];
|
|
||||||
FILE *fp = fopen("/sys/class/hwmon/hwmon0/device/name", "r");
|
|
||||||
if(fp != NULL) {
|
|
||||||
if(fgets(buffer, bsize, fp) != NULL) {
|
|
||||||
position = strstr(buffer, "\n");
|
|
||||||
*(position) = '\0';
|
|
||||||
snprintf(name, sizeof(name), "%s", buffer);
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void get_hwmon_temp(unsigned int *value, unsigned int *sensor)
|
|
||||||
{
|
|
||||||
char buffer[bsize];
|
|
||||||
snprintf(buffer, bsize, "/sys/class/hwmon/hwmon0/device/temp%i_input", *sensor);
|
|
||||||
FILE *fp = fopen(buffer, "r");
|
|
||||||
if(fp != NULL) {
|
|
||||||
if(fgets(buffer, bsize, fp) != NULL)
|
|
||||||
*value = atoi(buffer);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,240 +0,0 @@
|
||||||
/*
|
|
||||||
* match.c - matching functions for X-Sys
|
|
||||||
* Copyright (C) 2005, 2006, 2007 Tony Vroon
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "xsys.h"
|
|
||||||
|
|
||||||
float percentage(unsigned long long *free, unsigned long long *total)
|
|
||||||
{
|
|
||||||
unsigned long long result = (*free) * (unsigned long long)1000 / (*total);
|
|
||||||
return result / 10.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned long long *total_k)
|
|
||||||
{
|
|
||||||
char *result, **quantity;
|
|
||||||
double free_space, total_space;
|
|
||||||
free_space = *free_k;
|
|
||||||
total_space = *total_k;
|
|
||||||
result = malloc(bsize * sizeof(char));
|
|
||||||
char *quantities[] = { "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", 0 };
|
|
||||||
if (total_space == 0)
|
|
||||||
{
|
|
||||||
snprintf(result, bsize, "%s: none", desc);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
quantity = quantities;
|
|
||||||
while (total_space > 1023 && *(quantity + 1))
|
|
||||||
{
|
|
||||||
quantity++;
|
|
||||||
free_space = free_space / 1024;
|
|
||||||
total_space = total_space / 1024;
|
|
||||||
}
|
|
||||||
if (sysinfo_get_percent () != 0)
|
|
||||||
snprintf(result, bsize, "%s: %.1f%s, %.1f%% free",
|
|
||||||
desc, total_space, *quantity,
|
|
||||||
percentage(free_k, total_k));
|
|
||||||
else
|
|
||||||
snprintf(result, bsize, "%s: %.1f%s/%.1f%s free",
|
|
||||||
desc, free_space, *quantity, total_space, *quantity);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void remove_leading_whitespace(char *buffer)
|
|
||||||
{
|
|
||||||
char *buffer2 = NULL;
|
|
||||||
int i = 0, j = 0, ews = 0;
|
|
||||||
|
|
||||||
buffer2 = (char*)malloc(strlen(buffer) * sizeof(char));
|
|
||||||
if (buffer2 == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
memset (buffer2, (char)0, strlen(buffer));
|
|
||||||
while (i < strlen(buffer))
|
|
||||||
{
|
|
||||||
/* count tabs, spaces as whitespace. */
|
|
||||||
if (!(buffer[i] == (char)32 || buffer[i] == (char)9) || ews == 1)
|
|
||||||
{
|
|
||||||
ews = 1;
|
|
||||||
buffer2[j] = buffer[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
memset (buffer, (char)0, strlen(buffer));
|
|
||||||
strcpy (buffer, buffer2);
|
|
||||||
free (buffer2);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *decruft_filename(char *buffer)
|
|
||||||
{
|
|
||||||
char *match, *match_end;
|
|
||||||
|
|
||||||
while ((match = strstr(buffer, "%20")))
|
|
||||||
{
|
|
||||||
match_end = match + 3;
|
|
||||||
*match++ = ' ';
|
|
||||||
while (*match_end)
|
|
||||||
*match++ = *match_end++;
|
|
||||||
*match = 0;
|
|
||||||
}
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void find_match_char(char *buffer, char *match, char *result)
|
|
||||||
{
|
|
||||||
char *position;
|
|
||||||
remove_leading_whitespace(buffer);
|
|
||||||
if(strstr(buffer, match) == strstr(buffer, buffer))
|
|
||||||
{
|
|
||||||
position = strpbrk(buffer, delims);
|
|
||||||
if (position != NULL) {
|
|
||||||
position += 1;
|
|
||||||
strcpy(result, position);
|
|
||||||
position = strstr(result, "\n");
|
|
||||||
*(position) = '\0';
|
|
||||||
remove_leading_whitespace(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
strcpy(result, "\0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void find_match_double(char *buffer, char *match, double *result)
|
|
||||||
{
|
|
||||||
char *position;
|
|
||||||
remove_leading_whitespace(buffer);
|
|
||||||
if(strstr(buffer, match) == strstr(buffer, buffer))
|
|
||||||
{
|
|
||||||
position = strpbrk(buffer, delims);
|
|
||||||
if (position != NULL) {
|
|
||||||
position += 1;
|
|
||||||
*result = strtod(position, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*result = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void find_match_double_hex(char *buffer, char *match, double *result)
|
|
||||||
{
|
|
||||||
char *position;
|
|
||||||
remove_leading_whitespace(buffer);
|
|
||||||
if(strstr(buffer, match) == strstr(buffer, buffer))
|
|
||||||
{
|
|
||||||
position = strpbrk(buffer, delims);
|
|
||||||
if (position != NULL) {
|
|
||||||
memcpy(position,"0x",2);
|
|
||||||
*result = strtod(position,NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*result = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void find_match_int(char *buffer, char *match, unsigned int *result)
|
|
||||||
{
|
|
||||||
char *position;
|
|
||||||
remove_leading_whitespace(buffer);
|
|
||||||
if(strstr(buffer, match) == strstr(buffer, buffer))
|
|
||||||
{
|
|
||||||
position = strpbrk(buffer, delims);
|
|
||||||
if (position != NULL) {
|
|
||||||
position += 1;
|
|
||||||
*result = atoi(position);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*result = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void find_match_ll(char *buffer, char *match, unsigned long long *result)
|
|
||||||
{
|
|
||||||
char *position;
|
|
||||||
remove_leading_whitespace(buffer);
|
|
||||||
if(strstr(buffer, match) == strstr(buffer, buffer))
|
|
||||||
{
|
|
||||||
position = strpbrk(buffer, delims);
|
|
||||||
if (position != NULL) {
|
|
||||||
position += 1;
|
|
||||||
*result = strtoll(position, NULL, 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*result = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void format_output(const char *arg, char *string, char *format)
|
|
||||||
{
|
|
||||||
char *pos1, *pos2, buffer[bsize];
|
|
||||||
pos1 = &format[0];
|
|
||||||
strncpy(buffer, string, bsize);
|
|
||||||
string[0] = '\0';
|
|
||||||
|
|
||||||
while((pos2 = strstr(pos1, "%")) != NULL)
|
|
||||||
{
|
|
||||||
strncat(string, pos1, (size_t)(pos2-pos1));
|
|
||||||
if(*(pos2+1) == '1')
|
|
||||||
strcat(string, arg);
|
|
||||||
else if(*(pos2+1) == '2')
|
|
||||||
strcat(string, buffer);
|
|
||||||
else if(*(pos2+1) == 'C' || *(pos2+1) == 'c')
|
|
||||||
strcat(string, "\003");
|
|
||||||
else if(*(pos2+1) == 'B' || *(pos2+1) == 'b')
|
|
||||||
strcat(string, "\002");
|
|
||||||
else if(*(pos2+1) == 'R' || *(pos2+1) == 'r')
|
|
||||||
strcat(string, "\026");
|
|
||||||
else if(*(pos2+1) == 'O' || *(pos2+1) == 'o')
|
|
||||||
strcat(string, "\017");
|
|
||||||
else if(*(pos2+1) == 'U' || *(pos2+1) == 'u')
|
|
||||||
strcat(string, "\037");
|
|
||||||
else if(*(pos2+1) == '%')
|
|
||||||
strcat(string, "%");
|
|
||||||
pos1=pos2+2;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcat(string, pos1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void flat_format_output(const char *arg, char *string, char *format)
|
|
||||||
{
|
|
||||||
char *pos1, *pos2, buffer[bsize];
|
|
||||||
pos1 = &format[0];
|
|
||||||
strncpy(buffer, string, bsize);
|
|
||||||
string[0] = '\0';
|
|
||||||
|
|
||||||
while((pos2 = strstr(pos1, "%")) != NULL)
|
|
||||||
{
|
|
||||||
strncat(string, pos1, (size_t)(pos2-pos1));
|
|
||||||
if(*(pos2+1) == '1')
|
|
||||||
strcat(string, arg);
|
|
||||||
else if(*(pos2+1) == '2')
|
|
||||||
strcat(string, buffer);
|
|
||||||
else if(*(pos2+1) == '%')
|
|
||||||
strcat(string, "%");
|
|
||||||
pos1=pos2+2;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcat(string, pos1);
|
|
||||||
}
|
|
|
@ -0,0 +1,263 @@
|
||||||
|
/*
|
||||||
|
* SysInfo - sysinfo plugin for HexChat
|
||||||
|
* Copyright (c) 2015 Patrick Griffis.
|
||||||
|
*
|
||||||
|
* This program is free software you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some snippets based upon Textual's System Profiler plugin.
|
||||||
|
* https://github.com/Codeux-Software/Textual
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#include <mach/mach_host.h>
|
||||||
|
#include <mach/host_info.h>
|
||||||
|
#include <mach/mach_vm.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "format.h"
|
||||||
|
#include "df.h"
|
||||||
|
|
||||||
|
static char *
|
||||||
|
get_os (void)
|
||||||
|
{
|
||||||
|
NSDictionary *systemversion = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
|
||||||
|
NSString *build = [systemversion objectForKey:@"ProductBuildVersion"];
|
||||||
|
if (!build)
|
||||||
|
return NULL;
|
||||||
|
NSString *version = [systemversion objectForKey:@"ProductUserVisibleVersion"];
|
||||||
|
if (!version)
|
||||||
|
{
|
||||||
|
[build release];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSDictionary *profiler = [NSDictionary dictionaryWithContentsOfFile:[@"~/Library/Preferences/com.apple.SystemProfiler.plist" stringByExpandingTildeInPath]];
|
||||||
|
NSDictionary *names = [profiler objectForKey:@"OS Names"];
|
||||||
|
NSString *os_name = nil;
|
||||||
|
|
||||||
|
for (NSString *name in names)
|
||||||
|
{
|
||||||
|
if ([name hasPrefix:build])
|
||||||
|
{
|
||||||
|
os_name = [names objectForKey:name];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[build release];
|
||||||
|
|
||||||
|
if (!os_name)
|
||||||
|
{
|
||||||
|
[version release];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *ret = g_strdup_printf ("%s %s", [os_name UTF8String], [version UTF8String]);
|
||||||
|
[version release];
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
get_os_fallback (void)
|
||||||
|
{
|
||||||
|
NSProcessInfo *info = [NSProcessInfo processInfo];
|
||||||
|
NSOperatingSystemVersion version = [info operatingSystemVersion];
|
||||||
|
|
||||||
|
return g_strdup_printf ("OS X %ld.%ld.%ld", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||||
|
}
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_os(void)
|
||||||
|
{
|
||||||
|
static char *os_str = NULL;
|
||||||
|
if (!os_str)
|
||||||
|
{
|
||||||
|
os_str = get_os();
|
||||||
|
if (!os_str)
|
||||||
|
os_str = get_os_fallback();
|
||||||
|
}
|
||||||
|
return g_strdup (os_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_disk(void)
|
||||||
|
{
|
||||||
|
gint64 total, free_space;
|
||||||
|
|
||||||
|
if (xs_parse_df (&total, &free_space))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sysinfo_format_disk (total, free_space);
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint64
|
||||||
|
get_free_memory (void)
|
||||||
|
{
|
||||||
|
mach_msg_type_number_t infoCount = (sizeof(vm_statistics_data_t) / sizeof(natural_t));
|
||||||
|
|
||||||
|
vm_size_t pagesize;
|
||||||
|
vm_statistics_data_t vm_stat;
|
||||||
|
|
||||||
|
host_page_size(mach_host_self(), &pagesize);
|
||||||
|
|
||||||
|
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vm_stat, &infoCount) == KERN_SUCCESS)
|
||||||
|
return ((vm_stat.inactive_count + vm_stat.free_count) * pagesize);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_memory(void)
|
||||||
|
{
|
||||||
|
NSProcessInfo *info = [NSProcessInfo processInfo];
|
||||||
|
guint64 totalmem, freemem;
|
||||||
|
|
||||||
|
totalmem = [info physicalMemory];
|
||||||
|
|
||||||
|
if ((freemem = get_free_memory()) == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return sysinfo_format_memory (totalmem, freemem);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_cpu(void)
|
||||||
|
{
|
||||||
|
guint64 cpu_clock_uint = 0;
|
||||||
|
double cpu_clock;
|
||||||
|
char cpu_string[256];
|
||||||
|
gsize len;
|
||||||
|
gboolean giga = FALSE;
|
||||||
|
|
||||||
|
len = sizeof(cpu_string);
|
||||||
|
if (sysctlbyname ("machdep.cpu.brand_string", cpu_string, &len, NULL, 0) != 0)
|
||||||
|
return NULL;
|
||||||
|
cpu_string[sizeof(cpu_string) - 1] = '\0';
|
||||||
|
|
||||||
|
len = sizeof(cpu_clock_uint);
|
||||||
|
if (sysctlbyname("hw.cpufrequency", &cpu_clock_uint, &len, NULL, 0) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cpu_clock = cpu_clock_uint / 1000000;
|
||||||
|
if (cpu_clock > 1000)
|
||||||
|
{
|
||||||
|
cpu_clock /= 1000;
|
||||||
|
giga = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (giga)
|
||||||
|
return g_strdup_printf ("%s (%.2fGHz)", cpu_string, cpu_clock);
|
||||||
|
else
|
||||||
|
return g_strdup_printf ("%s (%.0fMHz)", cpu_string, cpu_clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
get_gpu(void)
|
||||||
|
{
|
||||||
|
CFMutableDictionaryRef pciDevices = IOServiceMatching("IOPCIDevice");
|
||||||
|
io_iterator_t entry_iterator, serviceObject;
|
||||||
|
|
||||||
|
if (IOServiceGetMatchingServices(kIOMasterPortDefault, pciDevices, &entry_iterator) != kIOReturnSuccess)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
GString *gpu_list = g_string_new(NULL);
|
||||||
|
while ((serviceObject = IOIteratorNext(entry_iterator)))
|
||||||
|
{
|
||||||
|
CFMutableDictionaryRef serviceDictionary;
|
||||||
|
|
||||||
|
kern_return_t status = IORegistryEntryCreateCFProperties(serviceObject, &serviceDictionary,
|
||||||
|
kCFAllocatorDefault, kNilOptions);
|
||||||
|
|
||||||
|
if (status != kIOReturnSuccess)
|
||||||
|
{
|
||||||
|
IOObjectRelease(serviceObject);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void *class = CFDictionaryGetValue(serviceDictionary, @"class-code");
|
||||||
|
if (!class || *(guint32*)CFDataGetBytePtr(class) != 0x30000) /* DISPLAY_VGA */
|
||||||
|
{
|
||||||
|
CFRelease(serviceDictionary);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void *model = CFDictionaryGetValue(serviceDictionary, @"model");
|
||||||
|
if (model)
|
||||||
|
{
|
||||||
|
if (CFGetTypeID(model) == CFDataGetTypeID() && CFDataGetLength(model) > 1)
|
||||||
|
{
|
||||||
|
if (gpu_list->len != 0)
|
||||||
|
g_string_append (gpu_list, ", ");
|
||||||
|
g_string_append_len (gpu_list, (const char*)CFDataGetBytePtr(model), CFDataGetLength(model) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CFRelease(serviceDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gpu_list->len == 0)
|
||||||
|
{
|
||||||
|
g_string_free (gpu_list, TRUE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The string may contain nul-chars we must replace */
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < gpu_list->len; i++)
|
||||||
|
{
|
||||||
|
if (gpu_list->str[i] == '\0')
|
||||||
|
gpu_list->str[i] = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_string_free (gpu_list, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_gpu(void)
|
||||||
|
{
|
||||||
|
static char *gpu_str = NULL;
|
||||||
|
if (!gpu_str)
|
||||||
|
gpu_str = get_gpu();
|
||||||
|
|
||||||
|
return g_strdup (gpu_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_sound(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_uptime(void)
|
||||||
|
{
|
||||||
|
NSProcessInfo *info = [NSProcessInfo processInfo];
|
||||||
|
double uptime = [info systemUptime];
|
||||||
|
|
||||||
|
return sysinfo_format_uptime ((gint64)uptime);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_network(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
|
@ -1,156 +0,0 @@
|
||||||
/*
|
|
||||||
* pci.c - PCI functions for X-Sys
|
|
||||||
* Copyright (C) 1997-1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz> [PCI routines from lspci]
|
|
||||||
* Copyright (C) 2000 Tom Rini <trini@kernel.crashing.org> [XorgAutoConfig pci.c, based on lspci]
|
|
||||||
* Copyright (C) 2005, 2006 Tony Vroon
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pci/pci.h>
|
|
||||||
#include "xsys.h"
|
|
||||||
|
|
||||||
static struct pci_filter filter; /* Device filter */
|
|
||||||
static struct pci_access *pacc;
|
|
||||||
int bus, dev, func; /* Location of the card */
|
|
||||||
|
|
||||||
struct device {
|
|
||||||
struct device *next;
|
|
||||||
struct pci_dev *dev;
|
|
||||||
unsigned int config_cnt;
|
|
||||||
u8 config[256];
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct device *first_dev;
|
|
||||||
|
|
||||||
static struct device *scan_device(struct pci_dev *p)
|
|
||||||
{
|
|
||||||
int how_much = 64;
|
|
||||||
struct device *d;
|
|
||||||
|
|
||||||
if (!pci_filter_match(&filter, p))
|
|
||||||
return NULL;
|
|
||||||
d = malloc(sizeof(struct device));
|
|
||||||
bzero(d, sizeof(*d));
|
|
||||||
d->dev = p;
|
|
||||||
if (!pci_read_block(p, 0, d->config, how_much))
|
|
||||||
exit(1);
|
|
||||||
if (how_much < 128 && (d->config[PCI_HEADER_TYPE] & 0x7f) == PCI_HEADER_TYPE_CARDBUS) {
|
|
||||||
/* For cardbus bridges, we need to fetch 64 bytes more to get the full standard header... */
|
|
||||||
if (!pci_read_block(p, 64, d->config+64, 64))
|
|
||||||
exit(1);
|
|
||||||
how_much = 128;
|
|
||||||
}
|
|
||||||
d->config_cnt = how_much;
|
|
||||||
pci_setup_cache(p, d->config, d->config_cnt);
|
|
||||||
pci_fill_info(p, PCI_FILL_IDENT);
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void scan_devices(void)
|
|
||||||
{
|
|
||||||
struct device *d;
|
|
||||||
struct pci_dev *p;
|
|
||||||
|
|
||||||
pci_scan_bus(pacc);
|
|
||||||
for(p=pacc->devices; p; p=p->next)
|
|
||||||
if ((d = scan_device(p))) {
|
|
||||||
d->next = first_dev;
|
|
||||||
first_dev = d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static u16 get_conf_word(struct device *d, unsigned int pos)
|
|
||||||
{
|
|
||||||
return d->config[pos] | (d->config[pos+1] << 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pci_find_by_class(u16 *class, char *vendor, char *device)
|
|
||||||
{
|
|
||||||
struct device *d;
|
|
||||||
struct pci_dev *p;
|
|
||||||
int nomatch = 1;
|
|
||||||
|
|
||||||
pacc = pci_alloc();
|
|
||||||
pci_filter_init(pacc, &filter);
|
|
||||||
pci_init(pacc);
|
|
||||||
scan_devices();
|
|
||||||
|
|
||||||
for(d=first_dev; d; d=d->next) {
|
|
||||||
p = d->dev;
|
|
||||||
/* Acquire vendor & device ID if the class matches */
|
|
||||||
if(get_conf_word(d, PCI_CLASS_DEVICE) == *class) {
|
|
||||||
nomatch = 0;
|
|
||||||
snprintf(vendor,7,"%04x",p->vendor_id);
|
|
||||||
snprintf(device,7,"%04x",p->device_id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pci_cleanup(pacc);
|
|
||||||
return nomatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pci_find_fullname(char *fullname, char *vendor, char *device)
|
|
||||||
{
|
|
||||||
char buffer[bsize];
|
|
||||||
char vendorname[bsize/2] = "";
|
|
||||||
char devicename[bsize/2] = "";
|
|
||||||
char *position;
|
|
||||||
int cardfound = 0;
|
|
||||||
|
|
||||||
sysinfo_get_pciids (buffer);
|
|
||||||
FILE *fp = fopen (buffer, "r");
|
|
||||||
|
|
||||||
if(fp == NULL) {
|
|
||||||
snprintf(fullname, bsize, "%s:%s", vendor, device);
|
|
||||||
sysinfo_print_error ("pci.ids file not found! You might want to adjust your pciids setting with /SYSINFO SET pciids (you can query its current value with /SYSINFO LIST).\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL) {
|
|
||||||
if (!isspace(buffer[0]) && strstr(buffer, vendor) != NULL) {
|
|
||||||
position = strstr(buffer, vendor);
|
|
||||||
position += 6;
|
|
||||||
strncpy(vendorname, position, bsize/2);
|
|
||||||
position = strstr(vendorname, "\n");
|
|
||||||
*(position) = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL) {
|
|
||||||
if(strstr(buffer, device) != NULL) {
|
|
||||||
position = strstr(buffer, device);
|
|
||||||
position += 6;
|
|
||||||
strncpy(devicename, position, bsize/2);
|
|
||||||
position = strstr(devicename, " (");
|
|
||||||
if (position == NULL)
|
|
||||||
position = strstr(devicename, "\n");
|
|
||||||
*(position) = '\0';
|
|
||||||
cardfound = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cardfound == 1)
|
|
||||||
snprintf(fullname, bsize, "%s %s", vendorname, devicename);
|
|
||||||
else
|
|
||||||
snprintf(fullname, bsize, "%s:%s", vendor, device);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "sysinfo.h"
|
||||||
|
|
||||||
|
int xs_parse_df(gint64 *out_total, gint64 *out_free)
|
||||||
|
{
|
||||||
|
FILE *pipe;
|
||||||
|
char buffer[bsize];
|
||||||
|
|
||||||
|
pipe = popen("df -k -l -P", "r");
|
||||||
|
if(pipe==NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
*out_total = *out_free = 0;
|
||||||
|
|
||||||
|
while(fgets(buffer, bsize, pipe) != NULL)
|
||||||
|
{
|
||||||
|
long long int avail, total;
|
||||||
|
|
||||||
|
/* Filesystem 1024-blocks Used Available Capacity Mounted-on */
|
||||||
|
if (sscanf (buffer, "%*s %lld %*s %lld %*s %*s", &total, &avail) == 2)
|
||||||
|
{
|
||||||
|
*out_total += total;
|
||||||
|
*out_free += avail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert to bytes */
|
||||||
|
*out_total *= 1000;
|
||||||
|
*out_free *= 1000;
|
||||||
|
|
||||||
|
pclose(pipe);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,7 +1,4 @@
|
||||||
/* HexChat
|
/*
|
||||||
* Copyright (C) 1998-2010 Peter Zelezny.
|
|
||||||
* Copyright (C) 2009-2013 Berke Viktor.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
@ -17,9 +14,10 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HEXCHAT_IDENTD_H
|
|
||||||
#define HEXCHAT_IDENTD_H
|
|
||||||
|
|
||||||
void identd_start (char *username);
|
#ifndef SYSINFO_SHARED_H
|
||||||
|
#define SYSINFO_SHARED_H
|
||||||
|
|
||||||
|
int xs_parse_df(gint64 *total_bytes, gint64 *free_bytes);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* SysInfo - sysinfo plugin for HexChat
|
||||||
|
* Copyright (c) 2015 Patrick Griffis.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SYSINFO_BACKEND_H
|
||||||
|
#define SYSINFO_BACKEND_H
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_os(void);
|
||||||
|
char *sysinfo_backend_get_disk(void);
|
||||||
|
char *sysinfo_backend_get_memory(void);
|
||||||
|
char *sysinfo_backend_get_cpu(void);
|
||||||
|
char *sysinfo_backend_get_gpu(void);
|
||||||
|
char *sysinfo_backend_get_sound(void);
|
||||||
|
char *sysinfo_backend_get_uptime(void);
|
||||||
|
char *sysinfo_backend_get_network(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,277 @@
|
||||||
|
/*
|
||||||
|
* SysInfo - sysinfo plugin for HexChat
|
||||||
|
* Copyright (c) 2012 Berke Viktor.
|
||||||
|
*
|
||||||
|
* xsys.c - main functions for X-Sys 2
|
||||||
|
* by mikeshoup
|
||||||
|
* Copyright (C) 2003, 2004, 2005 Michael Shoup
|
||||||
|
* Copyright (C) 2005, 2006, 2007 Tony Vroon
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "hexchat-plugin.h"
|
||||||
|
#include "sysinfo-backend.h"
|
||||||
|
#include "sysinfo.h"
|
||||||
|
|
||||||
|
#define _(x) hexchat_gettext(ph,x)
|
||||||
|
#define DEFAULT_ANNOUNCE TRUE
|
||||||
|
|
||||||
|
static hexchat_plugin *ph;
|
||||||
|
|
||||||
|
static char name[] = "Sysinfo";
|
||||||
|
static char desc[] = "Display info about your hardware and OS";
|
||||||
|
static char version[] = "1.0";
|
||||||
|
static char sysinfo_help[] = "SysInfo Usage:\n /SYSINFO [-e|-o] [CLIENT|OS|CPU|RAM|DISK|VGA|SOUND|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n /SYSINFO SET <variable>\n";
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *name; /* Lower case name used for prefs */
|
||||||
|
const char *title; /* Used for the end formatting */
|
||||||
|
char *(*callback) (void);
|
||||||
|
gboolean def; /* Hide by default? */
|
||||||
|
} hwinfo;
|
||||||
|
|
||||||
|
static char *
|
||||||
|
get_client (void)
|
||||||
|
{
|
||||||
|
return g_strdup_printf ("HexChat %s", hexchat_get_info(ph, "version"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static hwinfo hwinfos[] = {
|
||||||
|
{"client", "Client", get_client},
|
||||||
|
{"os", "OS", sysinfo_backend_get_os},
|
||||||
|
{"cpu", "CPU", sysinfo_backend_get_cpu},
|
||||||
|
{"memory", "Memory", sysinfo_backend_get_memory},
|
||||||
|
{"storage", "Storage", sysinfo_backend_get_disk},
|
||||||
|
{"vga", "VGA", sysinfo_backend_get_gpu},
|
||||||
|
{"sound", "Sound", sysinfo_backend_get_sound, TRUE},
|
||||||
|
{"ethernet", "Ethernet", sysinfo_backend_get_network, TRUE},
|
||||||
|
{"uptime", "Uptime", sysinfo_backend_get_uptime},
|
||||||
|
{NULL, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
static gboolean sysinfo_get_bool_pref (const char *pref, gboolean def);
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
should_show_info (hwinfo info)
|
||||||
|
{
|
||||||
|
char hide_pref[32];
|
||||||
|
|
||||||
|
g_snprintf (hide_pref, sizeof(hide_pref), "hide_%s", info.name);
|
||||||
|
return !sysinfo_get_bool_pref (hide_pref, info.def);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_summary (gboolean announce)
|
||||||
|
{
|
||||||
|
char **strings = g_new0 (char*, G_N_ELEMENTS(hwinfos));
|
||||||
|
int i, x;
|
||||||
|
char *output;
|
||||||
|
|
||||||
|
for (i = 0, x = 0; hwinfos[i].name != NULL; i++)
|
||||||
|
{
|
||||||
|
if (should_show_info (hwinfos[i]))
|
||||||
|
{
|
||||||
|
char *str = hwinfos[i].callback();
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
strings[x++] = g_strdup_printf ("\002%s\002: %s", hwinfos[i].title, str);
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output = g_strjoinv (" \002\342\200\242\002 ", strings);
|
||||||
|
hexchat_commandf (ph, "%s %s", announce ? "SAY" : "ECHO", output);
|
||||||
|
|
||||||
|
g_strfreev (strings);
|
||||||
|
g_free (output);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_info (char *info, gboolean announce)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; hwinfos[i].name != NULL; i++)
|
||||||
|
{
|
||||||
|
if (!g_ascii_strcasecmp (info, hwinfos[i].name))
|
||||||
|
{
|
||||||
|
char *str = hwinfos[i].callback();
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
hexchat_commandf (ph, "%s \002%s\002: %s", announce ? "SAY" : "ECHO",
|
||||||
|
hwinfos[i].title, str);
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hexchat_print (ph, _("Sysinfo: Failed to get info. Either not supported or error."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hexchat_print (ph, _("Sysinfo: No info by that name\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Simple wrapper for backend specific options.
|
||||||
|
* Ensure dest >= 512.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
sysinfo_get_str_pref (const char *pref, char *dest)
|
||||||
|
{
|
||||||
|
return hexchat_pluginpref_get_str (ph, pref, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
sysinfo_get_bool_pref (const char *pref, gboolean def)
|
||||||
|
{
|
||||||
|
int value = hexchat_pluginpref_get_int (ph, pref);
|
||||||
|
|
||||||
|
if (value != -1)
|
||||||
|
return value;
|
||||||
|
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysinfo_set_pref_real (const char *pref, char *value, gboolean def)
|
||||||
|
{
|
||||||
|
if (value && value[0])
|
||||||
|
{
|
||||||
|
guint64 i = g_ascii_strtoull (value, NULL, 0);
|
||||||
|
hexchat_pluginpref_set_int (ph, pref, i != 0);
|
||||||
|
hexchat_printf (ph, _("Sysinfo: %s is set to: %d\n"), pref, i != 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hexchat_printf (ph, _("Sysinfo: %s is set to: %d\n"), pref,
|
||||||
|
sysinfo_get_bool_pref(pref, def));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysinfo_set_pref (char *key, char *value)
|
||||||
|
{
|
||||||
|
if (!key || !key[0])
|
||||||
|
{
|
||||||
|
hexchat_print (ph, _("Sysinfo: Valid settings are: announce and hide_* for each piece of information. e.g. hide_os. Without a value it will show current (or default) setting.\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp (key, "announce"))
|
||||||
|
{
|
||||||
|
sysinfo_set_pref_real (key, value, DEFAULT_ANNOUNCE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_LIBPCI
|
||||||
|
else if (!strcmp (key, "pciids"))
|
||||||
|
{
|
||||||
|
if (value && value[0])
|
||||||
|
{
|
||||||
|
hexchat_pluginpref_set_str (ph, "pciids", value);
|
||||||
|
hexchat_printf (ph, _("Sysinfo: pciids is set to: %s\n"), value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char buf[512];
|
||||||
|
if (hexchat_pluginpref_get_str (ph, "pciids", buf) == 0)
|
||||||
|
strcpy (buf, DEFAULT_PCIIDS);
|
||||||
|
hexchat_printf (ph, _("Sysinfo: pciids is set to: %s\n"), buf);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else if (g_str_has_prefix (key, "hide_"))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; hwinfos[i].name != NULL; i++)
|
||||||
|
{
|
||||||
|
if (!strcmp (key + 5, hwinfos[i].name))
|
||||||
|
{
|
||||||
|
sysinfo_set_pref_real (key, value, hwinfos[i].def);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hexchat_print (ph, _("Sysinfo: Invalid variable name\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sysinfo_cb (char *word[], char *word_eol[], void *userdata)
|
||||||
|
{
|
||||||
|
gboolean announce = sysinfo_get_bool_pref("announce", DEFAULT_ANNOUNCE);
|
||||||
|
int offset = 0, channel_type;
|
||||||
|
char *cmd;
|
||||||
|
|
||||||
|
/* Allow overriding global announce setting */
|
||||||
|
if (!strcmp ("-e", word[2]))
|
||||||
|
{
|
||||||
|
announce = FALSE;
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
else if (!strcmp ("-o", word[2]))
|
||||||
|
{
|
||||||
|
announce = TRUE;
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cannot send to server tab */
|
||||||
|
channel_type = hexchat_list_int (ph, NULL, "type");
|
||||||
|
if (channel_type != 2 /* SESS_CHANNEL */ && channel_type != 3 /* SESS_DIALOG */)
|
||||||
|
announce = FALSE;
|
||||||
|
|
||||||
|
cmd = word[2+offset];
|
||||||
|
if (!g_ascii_strcasecmp ("SET", cmd))
|
||||||
|
sysinfo_set_pref (word[3+offset], word_eol[4+offset]);
|
||||||
|
else if (!cmd || !cmd[0])
|
||||||
|
print_summary (announce);
|
||||||
|
else
|
||||||
|
print_info (cmd, announce);
|
||||||
|
|
||||||
|
return HEXCHAT_EAT_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
|
||||||
|
{
|
||||||
|
ph = plugin_handle;
|
||||||
|
*plugin_name = name;
|
||||||
|
*plugin_desc = desc;
|
||||||
|
*plugin_version = version;
|
||||||
|
|
||||||
|
hexchat_hook_command (ph, "SYSINFO", HEXCHAT_PRI_NORM, sysinfo_cb, sysinfo_help, NULL);
|
||||||
|
|
||||||
|
hexchat_command (ph, "MENU ADD \"Window/Send System Info\" \"SYSINFO\"");
|
||||||
|
hexchat_printf (ph, _("%s plugin loaded\n"), name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hexchat_plugin_deinit (void)
|
||||||
|
{
|
||||||
|
hexchat_command (ph, "MENU DEL \"Window/Display System Info\"");
|
||||||
|
hexchat_printf (ph, _("%s plugin unloaded\n"), name);
|
||||||
|
return 1;
|
||||||
|
}
|
|
@ -1,416 +0,0 @@
|
||||||
/* HexChat
|
|
||||||
* Copyright (c) 2011-2012 Berke Viktor.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <comutil.h>
|
|
||||||
#include <wbemidl.h>
|
|
||||||
|
|
||||||
#include "hexchat-plugin.h"
|
|
||||||
|
|
||||||
static hexchat_plugin *ph; /* plugin handle */
|
|
||||||
static char name[] = "SysInfo";
|
|
||||||
static char desc[] = "Display info about your hardware and OS";
|
|
||||||
static char version[] = "1.1";
|
|
||||||
static char helptext[] = "USAGE: /sysinfo - Sends info about your hardware and OS to current channel.";
|
|
||||||
static int firstRun;
|
|
||||||
static char *wmiOs;
|
|
||||||
static char *wmiCpu;
|
|
||||||
static char *wmiVga;
|
|
||||||
|
|
||||||
static int
|
|
||||||
getCpuArch (void)
|
|
||||||
{
|
|
||||||
OSVERSIONINFOEX osvi;
|
|
||||||
SYSTEM_INFO si;
|
|
||||||
|
|
||||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
|
||||||
GetVersionEx ((LPOSVERSIONINFOW) &osvi);
|
|
||||||
|
|
||||||
GetSystemInfo (&si);
|
|
||||||
|
|
||||||
if (si.wProcessorArchitecture == 9)
|
|
||||||
{
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 86;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* use WMI instead, wProcessorArchitecture displays current binary arch instead of OS arch anyway */
|
|
||||||
static char *
|
|
||||||
getOsName (void)
|
|
||||||
{
|
|
||||||
static char winver[32];
|
|
||||||
double mhz;
|
|
||||||
OSVERSIONINFOEX osvi;
|
|
||||||
SYSTEM_INFO si;
|
|
||||||
|
|
||||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
|
||||||
GetVersionEx ((LPOSVERSIONINFOW) &osvi);
|
|
||||||
|
|
||||||
GetSystemInfo (&si);
|
|
||||||
|
|
||||||
strcpy (winver, "Windows ");
|
|
||||||
|
|
||||||
switch (osvi.dwMajorVersion)
|
|
||||||
{
|
|
||||||
case 5:
|
|
||||||
switch (osvi.dwMinorVersion)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
strcat (winver, "XP");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
|
||||||
{
|
|
||||||
strcat (winver, "XP x64 Edition");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (GetSystemMetrics(SM_SERVERR2) == 0)
|
|
||||||
{
|
|
||||||
strcat (winver, "Server 2003");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat (winver, "Server 2003 R2");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
switch (osvi.dwMinorVersion)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
|
||||||
{
|
|
||||||
strcat (winver, "Vista");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat (winver, "Server 2008");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
|
||||||
{
|
|
||||||
strcat (winver, "7");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat (winver, "Server 2008 R2");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
|
||||||
{
|
|
||||||
strcat (winver, "8");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat (winver, "8 Server");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (si.wProcessorArchitecture == 9)
|
|
||||||
{
|
|
||||||
strcat (winver, " (x64)");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat (winver, " (x86)");
|
|
||||||
}
|
|
||||||
|
|
||||||
return winver;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* x86-only, SDK-only, use WMI instead */
|
|
||||||
static char *
|
|
||||||
getCpuName (void)
|
|
||||||
{
|
|
||||||
// Get extended ids.
|
|
||||||
unsigned int nExIds;
|
|
||||||
unsigned int i;
|
|
||||||
int CPUInfo[4] = {-1};
|
|
||||||
static char CPUBrandString[128];
|
|
||||||
|
|
||||||
__cpuid (CPUInfo, 0x80000000);
|
|
||||||
nExIds = CPUInfo[0];
|
|
||||||
|
|
||||||
/* Get the information associated with each extended ID. */
|
|
||||||
for (i=0x80000000; i <= nExIds; ++i)
|
|
||||||
{
|
|
||||||
__cpuid (CPUInfo, i);
|
|
||||||
|
|
||||||
if (i == 0x80000002)
|
|
||||||
{
|
|
||||||
memcpy (CPUBrandString, CPUInfo, sizeof (CPUInfo));
|
|
||||||
}
|
|
||||||
else if (i == 0x80000003)
|
|
||||||
{
|
|
||||||
memcpy( CPUBrandString + 16, CPUInfo, sizeof (CPUInfo));
|
|
||||||
}
|
|
||||||
else if (i == 0x80000004)
|
|
||||||
{
|
|
||||||
memcpy (CPUBrandString + 32, CPUInfo, sizeof (CPUInfo));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CPUBrandString;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char *
|
|
||||||
getCpuMhz (void)
|
|
||||||
{
|
|
||||||
HKEY hKey;
|
|
||||||
int result;
|
|
||||||
int data;
|
|
||||||
int dataSize;
|
|
||||||
double cpuspeed;
|
|
||||||
static char buffer[16];
|
|
||||||
const char *cpuspeedstr;
|
|
||||||
|
|
||||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, TEXT("Hardware\\Description\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
dataSize = sizeof (data);
|
|
||||||
result = RegQueryValueEx (hKey, TEXT("~MHz"), 0, 0, (LPBYTE)&data, (LPDWORD)&dataSize);
|
|
||||||
RegCloseKey (hKey);
|
|
||||||
if (result == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
cpuspeed = ( data > 1000 ) ? data / 1000 : data;
|
|
||||||
cpuspeedstr = ( data > 1000 ) ? "GHz" : "MHz";
|
|
||||||
sprintf (buffer, "%.2f %s", cpuspeed, cpuspeedstr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
getMemoryInfo (void)
|
|
||||||
{
|
|
||||||
static char buffer[32];
|
|
||||||
MEMORYSTATUSEX meminfo;
|
|
||||||
|
|
||||||
meminfo.dwLength = sizeof (meminfo);
|
|
||||||
GlobalMemoryStatusEx (&meminfo);
|
|
||||||
|
|
||||||
sprintf (buffer, "%I64d MB Total (%I64d MB Free)", meminfo.ullTotalPhys / 1024 / 1024, meminfo.ullAvailPhys / 1024 / 1024);
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
getWmiInfo (int mode)
|
|
||||||
{
|
|
||||||
/* for more details about this wonderful API, see
|
|
||||||
http://msdn.microsoft.com/en-us/site/aa394138
|
|
||||||
http://msdn.microsoft.com/en-us/site/aa390423
|
|
||||||
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394138%28v=vs.85%29.aspx
|
|
||||||
http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/d6420012-e432-4964-8506-6f6b65e5a451
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *buffer = (char *) malloc (128);
|
|
||||||
HRESULT hres;
|
|
||||||
HRESULT hr;
|
|
||||||
IWbemLocator *pLoc = NULL;
|
|
||||||
IWbemServices *pSvc = NULL;
|
|
||||||
IEnumWbemClassObject *pEnumerator = NULL;
|
|
||||||
IWbemClassObject *pclsObj;
|
|
||||||
ULONG uReturn = 0;
|
|
||||||
|
|
||||||
hres = CoInitializeEx (0, COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY);
|
|
||||||
|
|
||||||
if (FAILED (hres))
|
|
||||||
{
|
|
||||||
strcpy (buffer, "Error Code 0");
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
hres = CoInitializeSecurity (NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
|
|
||||||
|
|
||||||
/* mysteriously failing after the first execution, but only when used as a plugin, skip it */
|
|
||||||
/*if (FAILED (hres))
|
|
||||||
{
|
|
||||||
CoUninitialize ();
|
|
||||||
strcpy (buffer, "Error Code 1");
|
|
||||||
return buffer;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
hres = CoCreateInstance (CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
|
|
||||||
|
|
||||||
if (FAILED (hres))
|
|
||||||
{
|
|
||||||
CoUninitialize ();
|
|
||||||
strcpy (buffer, "Error Code 2");
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
hres = pLoc->ConnectServer (_bstr_t (L"root\\CIMV2"), NULL, NULL, 0, NULL, 0, 0, &pSvc);
|
|
||||||
|
|
||||||
if (FAILED (hres))
|
|
||||||
{
|
|
||||||
pLoc->Release ();
|
|
||||||
CoUninitialize ();
|
|
||||||
strcpy (buffer, "Error Code 3");
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
hres = CoSetProxyBlanket (pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
|
|
||||||
|
|
||||||
if (FAILED (hres))
|
|
||||||
{
|
|
||||||
pSvc->Release ();
|
|
||||||
pLoc->Release ();
|
|
||||||
CoUninitialize ();
|
|
||||||
strcpy (buffer, "Error Code 4");
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
hres = pSvc->ExecQuery (_bstr_t ("WQL"), _bstr_t ("SELECT * FROM Win32_OperatingSystem"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
hres = pSvc->ExecQuery (_bstr_t ("WQL"), _bstr_t ("SELECT * FROM Win32_Processor"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
hres = pSvc->ExecQuery (_bstr_t ("WQL"), _bstr_t ("SELECT * FROM Win32_VideoController"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FAILED (hres))
|
|
||||||
{
|
|
||||||
pSvc->Release ();
|
|
||||||
pLoc->Release ();
|
|
||||||
CoUninitialize ();
|
|
||||||
strcpy (buffer, "Error Code 5");
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (pEnumerator)
|
|
||||||
{
|
|
||||||
hr = pEnumerator->Next (WBEM_INFINITE, 1, &pclsObj, &uReturn);
|
|
||||||
if (0 == uReturn)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
VARIANT vtProp;
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
hr = pclsObj->Get (L"Caption", 0, &vtProp, 0, 0);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
hr = pclsObj->Get (L"Name", 0, &vtProp, 0, 0);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
hr = pclsObj->Get (L"Name", 0, &vtProp, 0, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
WideCharToMultiByte (CP_ACP, 0, vtProp.bstrVal, -1, buffer, SysStringLen (vtProp.bstrVal)+1, NULL, NULL);
|
|
||||||
VariantClear (&vtProp);
|
|
||||||
}
|
|
||||||
|
|
||||||
pSvc->Release ();
|
|
||||||
pLoc->Release ();
|
|
||||||
pEnumerator->Release ();
|
|
||||||
pclsObj->Release ();
|
|
||||||
CoUninitialize ();
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
printInfo (char *word[], char *word_eol[], void *user_data)
|
|
||||||
{
|
|
||||||
/* query WMI info only at the first time SysInfo is called, then cache it to save time */
|
|
||||||
if (firstRun)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s first execution, querying and caching WMI info...\n", name);
|
|
||||||
wmiOs = getWmiInfo (0);
|
|
||||||
wmiCpu = getWmiInfo (1);
|
|
||||||
wmiVga = getWmiInfo (2);
|
|
||||||
firstRun = 0;
|
|
||||||
}
|
|
||||||
if (hexchat_list_int (ph, NULL, "type") >= 2)
|
|
||||||
{
|
|
||||||
/* uptime will work correctly for up to 50 days, should be enough */
|
|
||||||
hexchat_commandf (ph, "ME ** SysInfo ** Client: HexChat %s (x%d) ** OS: %s ** CPU: %s (%s) ** RAM: %s ** VGA: %s ** Uptime: %.2f Hours **",
|
|
||||||
hexchat_get_info (ph, "version"),
|
|
||||||
getCpuArch (),
|
|
||||||
wmiOs,
|
|
||||||
wmiCpu,
|
|
||||||
getCpuMhz (),
|
|
||||||
getMemoryInfo (),
|
|
||||||
wmiVga, (float) GetTickCount() / 1000 / 60 / 60);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, " * Client: HexChat %s (x%d)\n", hexchat_get_info (ph, "version"), getCpuArch ());
|
|
||||||
hexchat_printf (ph, " * OS: %s\n", wmiOs);
|
|
||||||
hexchat_printf (ph, " * CPU: %s (%s)\n", wmiCpu, getCpuMhz ());
|
|
||||||
hexchat_printf (ph, " * RAM: %s\n", getMemoryInfo ());
|
|
||||||
hexchat_printf (ph, " * VGA: %s\n", wmiVga);
|
|
||||||
hexchat_printf (ph, " * Uptime: %.2f Hours\n", (float) GetTickCount() / 1000 / 60 / 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
|
|
||||||
{
|
|
||||||
ph = plugin_handle;
|
|
||||||
|
|
||||||
*plugin_name = name;
|
|
||||||
*plugin_desc = desc;
|
|
||||||
*plugin_version = version;
|
|
||||||
|
|
||||||
firstRun = 1;
|
|
||||||
|
|
||||||
hexchat_hook_command (ph, "SYSINFO", HEXCHAT_PRI_NORM, printInfo, helptext, NULL);
|
|
||||||
hexchat_command (ph, "MENU -ishare\\system.png ADD \"Window/Send System Info\" \"SYSINFO\"");
|
|
||||||
|
|
||||||
hexchat_printf (ph, "%s plugin loaded\n", name);
|
|
||||||
|
|
||||||
return 1; /* return 1 for success */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
hexchat_plugin_deinit (void)
|
|
||||||
{
|
|
||||||
hexchat_command (ph, "MENU DEL \"Window/Display System Info\"");
|
|
||||||
hexchat_printf (ph, "%s plugin unloaded\n", name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* hwmon.h - Hardware monitoring header for X-Sys
|
* SysInfo - sysinfo plugin for HexChat
|
||||||
* Copyright (C) 2005 Tony Vroon
|
* Copyright (c) 2015 Patrick Griffis.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,11 +18,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _HWMON_H_
|
#ifndef SYSINFO_H
|
||||||
#define _HWMON_H_
|
#define SYSINFO_H
|
||||||
|
|
||||||
int hwmon_chip_present();
|
#define bsize 1024
|
||||||
void get_hwmon_chip_name(char *name);
|
#define DEFAULT_PCIIDS "/usr/share/hwdata/pci.ids"
|
||||||
void get_hwmon_temp(unsigned int *value, unsigned int *sensor);
|
|
||||||
|
int sysinfo_get_str_pref (const char *name, char *dest);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -2,6 +2,8 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,91 +21,51 @@
|
||||||
<RootNamespace>sysinfo</RootNamespace>
|
<RootNamespace>sysinfo</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcsysinfo</TargetName>
|
<TargetName>hcsysinfo</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcsysinfo</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SYSINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SYSINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\common;$(DepsRoot)\include;$(Glib);$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<AdditionalDependencies>wbemuuid.lib;comsupp.lib;$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>sysinfo.def</ModuleDefinitionFile>
|
|
||||||
<AdditionalDependencies>wbemuuid.lib;comsupp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<IgnoreSpecificDefaultLibraries>comsupp.lib</IgnoreSpecificDefaultLibraries>
|
<IgnoreSpecificDefaultLibraries>comsupp.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
<ModuleDefinitionFile>sysinfo.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;SYSINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;SYSINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\common;$(DepsRoot)\include;$(Glib);$(HexChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<AdditionalDependencies>wbemuuid.lib;comsupp.lib;$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>sysinfo.def</ModuleDefinitionFile>
|
|
||||||
<AdditionalDependencies>wbemuuid.lib;comsupp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<IgnoreSpecificDefaultLibraries>comsupp.lib</IgnoreSpecificDefaultLibraries>
|
<IgnoreSpecificDefaultLibraries>comsupp.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
<ModuleDefinitionFile>sysinfo.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="sysinfo.def" />
|
<None Include="sysinfo.def" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="sysinfo.cpp" />
|
<ClCompile Include="format.c" />
|
||||||
|
<ClCompile Include="sysinfo.c" />
|
||||||
|
<ClCompile Include="win32\backend.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="format.h" />
|
||||||
|
<ClInclude Include="sysinfo-backend.h" />
|
||||||
|
<ClInclude Include="sysinfo.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{c873eb6b-aca6-434d-8ec9-199838b80838}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="sysinfo.def">
|
<None Include="sysinfo.def">
|
||||||
|
@ -16,8 +19,25 @@
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="sysinfo.cpp">
|
<ClCompile Include="sysinfo.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="win32\backend.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="format.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="sysinfo.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sysinfo-backend.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="format.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,170 @@
|
||||||
|
/*
|
||||||
|
* SysInfo - sysinfo plugin for HexChat
|
||||||
|
* Copyright (c) 2015 Patrick Griffis.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include "parse.h"
|
||||||
|
#include "match.h"
|
||||||
|
#include "sysinfo.h"
|
||||||
|
#include "format.h"
|
||||||
|
#include "df.h"
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_os(void)
|
||||||
|
{
|
||||||
|
char name[bsize];
|
||||||
|
|
||||||
|
if (xs_parse_distro (name) != 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_disk(void)
|
||||||
|
{
|
||||||
|
gint64 total, free;
|
||||||
|
|
||||||
|
if (xs_parse_df (&total, &free))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sysinfo_format_disk (total, free);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_memory(void)
|
||||||
|
{
|
||||||
|
unsigned long long mem_total;
|
||||||
|
unsigned long long mem_free;
|
||||||
|
unsigned long long swap_total;
|
||||||
|
unsigned long long swap_free;
|
||||||
|
char *swap_fmt = NULL, *mem_fmt, *ret;
|
||||||
|
|
||||||
|
if (xs_parse_meminfo (&mem_total, &mem_free, 0) == 1)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (xs_parse_meminfo (&swap_total, &swap_free, 1) != 1)
|
||||||
|
{
|
||||||
|
swap_fmt = sysinfo_format_memory (swap_total, swap_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
mem_fmt = sysinfo_format_memory (mem_total, mem_free);
|
||||||
|
|
||||||
|
if (swap_fmt)
|
||||||
|
{
|
||||||
|
ret = g_strdup_printf ("Physical: %s Swap: %s", mem_fmt, swap_fmt);
|
||||||
|
g_free (mem_fmt);
|
||||||
|
g_free (swap_fmt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = mem_fmt;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_cpu(void)
|
||||||
|
{
|
||||||
|
char model[bsize];
|
||||||
|
char vendor[bsize];
|
||||||
|
char buffer[bsize];
|
||||||
|
double freq;
|
||||||
|
int giga = 0;
|
||||||
|
|
||||||
|
if (xs_parse_cpu (model, vendor, &freq) != 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (freq > 1000)
|
||||||
|
{
|
||||||
|
freq /= 1000;
|
||||||
|
giga = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (giga)
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, bsize, "%s (%.2fGHz)", model, freq);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, bsize, "%s (%.0fMHz)", model, freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_gpu(void)
|
||||||
|
{
|
||||||
|
char vid_card[bsize];
|
||||||
|
char agp_bridge[bsize];
|
||||||
|
char buffer[bsize];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if ((ret = xs_parse_video (vid_card)) != 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xs_parse_agpbridge (agp_bridge) != 0)
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, bsize, "%s", vid_card);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_snprintf (buffer, bsize, "%s @ %s", vid_card, agp_bridge);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_sound(void)
|
||||||
|
{
|
||||||
|
char sound[bsize];
|
||||||
|
|
||||||
|
if (xs_parse_sound (sound) != 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return g_strdup (sound);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_uptime(void)
|
||||||
|
{
|
||||||
|
gint64 uptime;
|
||||||
|
|
||||||
|
if ((uptime = xs_parse_uptime ()) == 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sysinfo_format_uptime (uptime);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sysinfo_backend_get_network(void)
|
||||||
|
{
|
||||||
|
char ethernet_card[bsize];
|
||||||
|
|
||||||
|
if (xs_parse_ether (ethernet_card))
|
||||||
|
{
|
||||||
|
g_strlcpy (ethernet_card, "None found", bsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup (ethernet_card);
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* match.c - matching functions for X-Sys
|
||||||
|
* Copyright (C) 2005, 2006, 2007 Tony Vroon
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include "sysinfo.h"
|
||||||
|
|
||||||
|
#define delims ":="
|
||||||
|
|
||||||
|
void find_match_char(char *buffer, char *match, char *result)
|
||||||
|
{
|
||||||
|
char *position;
|
||||||
|
g_strchug(buffer);
|
||||||
|
if(strstr(buffer, match) == strstr(buffer, buffer))
|
||||||
|
{
|
||||||
|
position = strpbrk(buffer, delims);
|
||||||
|
if (position != NULL)
|
||||||
|
{
|
||||||
|
position += 1;
|
||||||
|
strcpy(result, position);
|
||||||
|
position = strstr(result, "\n");
|
||||||
|
*(position) = '\0';
|
||||||
|
g_strchug(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcpy(result, "\0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void find_match_double(char *buffer, char *match, double *result)
|
||||||
|
{
|
||||||
|
char *position;
|
||||||
|
g_strchug(buffer);
|
||||||
|
if(strstr(buffer, match) == strstr(buffer, buffer))
|
||||||
|
{
|
||||||
|
position = strpbrk(buffer, delims);
|
||||||
|
if (position != NULL)
|
||||||
|
{
|
||||||
|
position += 1;
|
||||||
|
*result = strtod(position, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*result = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void find_match_double_hex(char *buffer, char *match, double *result)
|
||||||
|
{
|
||||||
|
char *position;
|
||||||
|
g_strchug(buffer);
|
||||||
|
if(strstr(buffer, match) == strstr(buffer, buffer))
|
||||||
|
{
|
||||||
|
position = strpbrk(buffer, delims);
|
||||||
|
if (position != NULL)
|
||||||
|
{
|
||||||
|
memcpy(position,"0x",2);
|
||||||
|
*result = strtod(position,NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*result = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void find_match_ll(char *buffer, char *match, unsigned long long *result)
|
||||||
|
{
|
||||||
|
char *position;
|
||||||
|
g_strchug(buffer);
|
||||||
|
if(strstr(buffer, match) == strstr(buffer, buffer))
|
||||||
|
{
|
||||||
|
position = strpbrk(buffer, delims);
|
||||||
|
if (position != NULL)
|
||||||
|
{
|
||||||
|
position += 1;
|
||||||
|
*result = strtoll(position, NULL, 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*result = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,13 +23,7 @@
|
||||||
void find_match_char(char *buffer, char *match, char *result);
|
void find_match_char(char *buffer, char *match, char *result);
|
||||||
void find_match_double(char *buffer, char *match, double *result);
|
void find_match_double(char *buffer, char *match, double *result);
|
||||||
void find_match_double_hex(char *buffer, char *match, double *result);
|
void find_match_double_hex(char *buffer, char *match, double *result);
|
||||||
void find_match_int(char *buffer, char *match, unsigned int *result);
|
|
||||||
void find_match_ll(char *buffer, char *match, unsigned long long *result);
|
void find_match_ll(char *buffer, char *match, unsigned long long *result);
|
||||||
void format_output(const char *arg, char *string, char *format);
|
|
||||||
void flat_format_output(const char *arg, char *string, char *format);
|
|
||||||
float percentage(unsigned long long *free, unsigned long long *total);
|
|
||||||
char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned long long *total_k);
|
|
||||||
void remove_leading_whitespace(char *buffer);
|
void remove_leading_whitespace(char *buffer);
|
||||||
char *decruft_filename(char *buffer);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -23,19 +23,19 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <pci/header.h>
|
#include <pci/header.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#ifdef __sparc__
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
#include "match.h"
|
#include "match.h"
|
||||||
#include "hwmon.h"
|
#include "parse.h"
|
||||||
#include "xsys.h"
|
#include "sysinfo.h"
|
||||||
|
|
||||||
int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned int *count)
|
int xs_parse_cpu(char *model, char *vendor, double *freq)
|
||||||
{
|
{
|
||||||
#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__alpha__) || defined(__ia64__) || defined(__parisc__) || defined(__sparc__)
|
#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__alpha__) || defined(__ia64__) || defined(__parisc__) || defined(__sparc__)
|
||||||
char buffer[bsize];
|
char buffer[bsize];
|
||||||
|
@ -46,8 +46,6 @@ int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned
|
||||||
FILE *fp = fopen("/proc/cpuinfo", "r");
|
FILE *fp = fopen("/proc/cpuinfo", "r");
|
||||||
if(fp == NULL)
|
if(fp == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
if(count != NULL) *count = 0;
|
|
||||||
strcpy(cache,"unknown\0");
|
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
|
@ -55,10 +53,7 @@ int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned
|
||||||
find_match_char(buffer, "model name", model);
|
find_match_char(buffer, "model name", model);
|
||||||
find_match_char(buffer, "vendor_id", vendor);
|
find_match_char(buffer, "vendor_id", vendor);
|
||||||
find_match_double(buffer, "cpu MHz", freq);
|
find_match_double(buffer, "cpu MHz", freq);
|
||||||
find_match_char(buffer, "cache size", cache);
|
|
||||||
find_match_int(buffer, "processor", count);
|
|
||||||
}
|
}
|
||||||
*count = *count + 1;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef __powerpc__
|
#ifdef __powerpc__
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
|
@ -66,10 +61,7 @@ int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned
|
||||||
find_match_char(buffer, "cpu", model);
|
find_match_char(buffer, "cpu", model);
|
||||||
find_match_char(buffer, "machine", vendor);
|
find_match_char(buffer, "machine", vendor);
|
||||||
find_match_double(buffer, "clock", freq);
|
find_match_double(buffer, "clock", freq);
|
||||||
find_match_char(buffer, "L2 cache", cache);
|
|
||||||
find_match_int(buffer, "processor", count);
|
|
||||||
}
|
}
|
||||||
*count = *count + 1;
|
|
||||||
pos = strstr(model, ",");
|
pos = strstr(model, ",");
|
||||||
if (pos != NULL) *pos = '\0';
|
if (pos != NULL) *pos = '\0';
|
||||||
#endif
|
#endif
|
||||||
|
@ -79,8 +71,6 @@ int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned
|
||||||
find_match_char(buffer, "cpu model", model);
|
find_match_char(buffer, "cpu model", model);
|
||||||
find_match_char(buffer, "system type", vendor);
|
find_match_char(buffer, "system type", vendor);
|
||||||
find_match_double(buffer, "cycle frequency [Hz]", freq);
|
find_match_double(buffer, "cycle frequency [Hz]", freq);
|
||||||
find_match_char(buffer, "L2 cache", cache);
|
|
||||||
find_match_int(buffer, "cpus detected", count);
|
|
||||||
}
|
}
|
||||||
*freq = *freq / 1000000;
|
*freq = *freq / 1000000;
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,20 +80,15 @@ int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned
|
||||||
find_match_char(buffer, "model", model);
|
find_match_char(buffer, "model", model);
|
||||||
find_match_char(buffer, "vendor", vendor);
|
find_match_char(buffer, "vendor", vendor);
|
||||||
find_match_double(buffer, "cpu MHz", freq);
|
find_match_double(buffer, "cpu MHz", freq);
|
||||||
find_match_int(buffer, "processor", count);
|
|
||||||
}
|
}
|
||||||
*count = *count + 1;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef __parisc__
|
#ifdef __parisc__
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
find_match_char(buffer, "cpu ", model);
|
find_match_char(buffer, "cpu ", model);
|
||||||
find_match_char(buffer, "cpu family", vendor);
|
find_match_char(buffer, "cpu family", vendor);
|
||||||
find_match_char(buffer, "D-cache", cache);
|
|
||||||
find_match_double(buffer, "cpu MHz", freq);
|
find_match_double(buffer, "cpu MHz", freq);
|
||||||
find_match_int(buffer, "processor", count);
|
|
||||||
}
|
}
|
||||||
*count = *count + 1;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef __sparc__
|
#ifdef __sparc__
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
|
@ -113,22 +98,8 @@ int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned
|
||||||
{
|
{
|
||||||
find_match_char(buffer, "cpu ", model);
|
find_match_char(buffer, "cpu ", model);
|
||||||
find_match_char(buffer, "type ", vendor);
|
find_match_char(buffer, "type ", vendor);
|
||||||
find_match_int(buffer, "ncpus active", count);
|
|
||||||
find_match_double_hex(buffer, "Cpu0ClkTck", freq);
|
find_match_double_hex(buffer, "Cpu0ClkTck", freq);
|
||||||
}
|
}
|
||||||
/* Cache is tricky, only implemented for sparc64 */
|
|
||||||
if ((dir = opendir("/proc/openprom")) != NULL)
|
|
||||||
while ((entry = readdir(dir)) != NULL)
|
|
||||||
if (strncmp(entry->d_name,"SUNW,UltraSPARC",15) == 0)
|
|
||||||
{
|
|
||||||
snprintf(buffer,bsize,"/proc/openprom/%s/ecache-size",entry->d_name);
|
|
||||||
fp2 = fopen(buffer, "r");
|
|
||||||
if (fp2 == NULL) break;
|
|
||||||
fscanf(fp2,"%16s",cache);
|
|
||||||
fclose(fp2);
|
|
||||||
sprintf(buffer,"0x%s",cache);
|
|
||||||
sprintf(cache,"%0.0f KB",strtod(buffer,NULL)/1024);
|
|
||||||
}
|
|
||||||
*freq = *freq / 1000000;
|
*freq = *freq / 1000000;
|
||||||
#endif
|
#endif
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -136,43 +107,20 @@ int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_uptime(int *weeks, int *days, int *hours, int *minutes, int *seconds)
|
gint64 xs_parse_uptime(void)
|
||||||
{
|
{
|
||||||
char buffer[bsize];
|
char buffer[bsize];
|
||||||
long long uptime = 0;
|
gint64 uptime = 0;
|
||||||
FILE *fp = fopen("/proc/uptime", "r");
|
FILE *fp = fopen("/proc/uptime", "r");
|
||||||
if(fp == NULL)
|
if(fp == NULL)
|
||||||
return 1;
|
return 0;
|
||||||
|
|
||||||
if(fgets(buffer, bsize, fp) != NULL)
|
if(fgets(buffer, bsize, fp) != NULL)
|
||||||
uptime = strtol(buffer, NULL, 0);
|
uptime = g_ascii_strtoll(buffer, NULL, 0);
|
||||||
|
|
||||||
*seconds = uptime%60;
|
|
||||||
*minutes = (uptime/60)%60;
|
|
||||||
*hours = (uptime/3600)%24;
|
|
||||||
*days = (uptime/86400)%7;
|
|
||||||
*weeks = uptime/604800;
|
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return 0;
|
return uptime;
|
||||||
}
|
|
||||||
|
|
||||||
int xs_parse_os(char *user, char *host, char *kernel)
|
|
||||||
{
|
|
||||||
struct utsname osinfo;
|
|
||||||
char hostn[bsize], *usern = getenv("USER");
|
|
||||||
|
|
||||||
if(uname(&osinfo)<0)
|
|
||||||
return 1;
|
|
||||||
if(gethostname(hostn, bsize)<0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
strncpy(user, usern, bsize);
|
|
||||||
strcpy(host, hostn);
|
|
||||||
snprintf(kernel, bsize, "%s %s %s", osinfo.sysname, osinfo.release, osinfo.machine);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_sound(char *snd_card)
|
int xs_parse_sound(char *snd_card)
|
||||||
|
@ -181,12 +129,13 @@ int xs_parse_sound(char *snd_card)
|
||||||
u16 class = PCI_CLASS_MULTIMEDIA_AUDIO;
|
u16 class = PCI_CLASS_MULTIMEDIA_AUDIO;
|
||||||
|
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
if((fp = fopen("/proc/asound/cards", "r"))== NULL) {
|
if((fp = fopen("/proc/asound/cards", "r"))== NULL)
|
||||||
|
{
|
||||||
if (pci_find_by_class(&class, vendor, device) == 0)
|
if (pci_find_by_class(&class, vendor, device) == 0)
|
||||||
{
|
{
|
||||||
pci_find_fullname(snd_card, vendor, device);
|
pci_find_fullname(snd_card, vendor, device);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -197,13 +146,13 @@ int xs_parse_sound(char *snd_card)
|
||||||
if(isdigit(buffer[0]) || isdigit(buffer[1]))
|
if(isdigit(buffer[0]) || isdigit(buffer[1]))
|
||||||
{
|
{
|
||||||
char card_buf[bsize];
|
char card_buf[bsize];
|
||||||
long card_id = 0;
|
gint64 card_id = 0;
|
||||||
pos = strstr(buffer, ":");
|
pos = strstr(buffer, ":");
|
||||||
card_id = strtoll(buffer, NULL, 0);
|
card_id = g_ascii_strtoll(buffer, NULL, 0);
|
||||||
if (card_id == 0)
|
if (card_id == 0)
|
||||||
snprintf(card_buf, bsize, "%s", pos+2);
|
g_snprintf(card_buf, bsize, "%s", pos+2);
|
||||||
else
|
else
|
||||||
snprintf(card_buf, bsize, "%ld: %s", card_id, pos+2);
|
g_snprintf(card_buf, bsize, "%"G_GINT64_FORMAT": %s", card_id, pos+2);
|
||||||
pos = strstr(card_buf, "\n");
|
pos = strstr(card_buf, "\n");
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
strcat(cards, card_buf);
|
strcat(cards, card_buf);
|
||||||
|
@ -249,129 +198,42 @@ int xs_parse_agpbridge(char *agp_bridge)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_netdev(const char *device, unsigned long long *bytes_recv, unsigned long long *bytes_sent)
|
|
||||||
{
|
|
||||||
FILE *fp;
|
|
||||||
char buffer[bsize], *pos;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
fp=fopen("/proc/net/dev", "r");
|
|
||||||
if(fp==NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
|
||||||
{
|
|
||||||
for(i=0; isspace(buffer[i]); i++);
|
|
||||||
if(strncmp(device, &buffer[i], strlen(device)) == 0) break;
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
pos = strstr(buffer, ":");
|
|
||||||
pos++;
|
|
||||||
*bytes_recv = strtoull(pos, &pos, 0);
|
|
||||||
|
|
||||||
for(i=0;i<7;i++) strtoull(pos, &pos, 0);
|
|
||||||
|
|
||||||
*bytes_sent = strtoull(pos, NULL, 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int xs_parse_df(const char *mount_point, char *result)
|
|
||||||
{
|
|
||||||
FILE *pipe;
|
|
||||||
char buffer[bsize], *pos;
|
|
||||||
unsigned long long total_k=0, free_k=0;
|
|
||||||
int i=0;
|
|
||||||
|
|
||||||
pipe = popen("df -k -l -P", "r");
|
|
||||||
if(pipe==NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
while(fgets(buffer, bsize, pipe) != NULL)
|
|
||||||
{
|
|
||||||
/* Skip over pseudo-filesystems and description line */
|
|
||||||
if(isalpha(buffer[0]))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for(pos=buffer; !isspace(*pos); pos++);
|
|
||||||
for(;isspace(*pos);pos++);
|
|
||||||
if(mount_point == NULL)
|
|
||||||
{
|
|
||||||
total_k += strtoull(pos, &pos, 0);
|
|
||||||
strtoull(pos, &pos, 0);
|
|
||||||
free_k += strtoull(pos, &pos, 0);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
total_k = strtoull(pos, &pos, 0);
|
|
||||||
strtoull(pos, &pos, 0);
|
|
||||||
free_k = strtoull(pos, &pos, 0);
|
|
||||||
strtoull(pos, &pos, 0);
|
|
||||||
for(;isspace(*pos);pos++);
|
|
||||||
for(;*pos!='/';pos++);
|
|
||||||
for(i=0;*(buffer+i)!='\n';i++);
|
|
||||||
*(buffer+i)='\0';
|
|
||||||
|
|
||||||
if(strncasecmp(mount_point, "ALL", 3)==0)
|
|
||||||
{
|
|
||||||
char *tmp_buf = pretty_freespace(pos, &free_k, &total_k);
|
|
||||||
strcat(tmp_buf, " | ");
|
|
||||||
strcat(result, tmp_buf);
|
|
||||||
free(tmp_buf);
|
|
||||||
}
|
|
||||||
else if(strncmp(mount_point, pos, strlen(mount_point)) == 0)
|
|
||||||
{
|
|
||||||
char *tmp_buf = pretty_freespace(mount_point, &free_k, &total_k);
|
|
||||||
strncpy(result, tmp_buf, bsize);
|
|
||||||
free(tmp_buf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else snprintf(result, bsize, "Mount point %s not found!", mount_point);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mount_point != NULL && strncasecmp(mount_point, "ALL", 3)==0)
|
|
||||||
*(result+strlen(result)-3) = '\0';
|
|
||||||
|
|
||||||
if(mount_point == NULL)
|
|
||||||
{
|
|
||||||
char *tmp_buf = pretty_freespace("Total", &free_k, &total_k);
|
|
||||||
strncpy(result, tmp_buf, bsize);
|
|
||||||
free(tmp_buf);
|
|
||||||
}
|
|
||||||
pclose(pipe);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int xs_parse_meminfo(unsigned long long *mem_tot, unsigned long long *mem_free, int swap)
|
int xs_parse_meminfo(unsigned long long *mem_tot, unsigned long long *mem_free, int swap)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buffer[bsize];
|
char buffer[bsize];
|
||||||
unsigned long long freemem = 0, buffers = 0, cache = 0;
|
unsigned long long freemem = 0, buffers = 0, cache = 0;
|
||||||
*mem_tot = 0;
|
*mem_tot = 0;
|
||||||
*mem_free = 0;
|
*mem_free = 0;
|
||||||
|
|
||||||
if((fp = fopen("/proc/meminfo", "r")) == NULL)
|
if((fp = fopen("/proc/meminfo", "r")) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
if(!swap)
|
if(!swap)
|
||||||
{
|
{
|
||||||
find_match_ll(buffer, "MemTotal:", mem_tot);
|
find_match_ll(buffer, "MemTotal:", mem_tot);
|
||||||
find_match_ll(buffer, "MemFree:", &freemem);
|
find_match_ll(buffer, "MemFree:", &freemem);
|
||||||
find_match_ll(buffer, "Buffers:", &buffers);
|
find_match_ll(buffer, "Buffers:", &buffers);
|
||||||
find_match_ll(buffer, "Cached:", &cache);
|
find_match_ll(buffer, "Cached:", &cache);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
find_match_ll(buffer, "SwapTotal:", mem_tot);
|
find_match_ll(buffer, "SwapTotal:", mem_tot);
|
||||||
find_match_ll(buffer, "SwapFree:", mem_free);
|
find_match_ll(buffer, "SwapFree:", mem_free);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!swap) {
|
if (!swap)
|
||||||
|
{
|
||||||
*mem_free = freemem + buffers + cache;
|
*mem_free = freemem + buffers + cache;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
|
||||||
|
/* Convert to bytes */
|
||||||
|
*mem_free *= 1000;
|
||||||
|
*mem_tot *= 1000;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_distro(char *name)
|
int xs_parse_distro(char *name)
|
||||||
|
@ -387,9 +249,9 @@ int xs_parse_distro(char *name)
|
||||||
find_match_char(buffer, "ACCEPT_KEYWORDS", keywords);
|
find_match_char(buffer, "ACCEPT_KEYWORDS", keywords);
|
||||||
/* cppcheck-suppress uninitvar */
|
/* cppcheck-suppress uninitvar */
|
||||||
if (strstr(keywords, "\"") == NULL)
|
if (strstr(keywords, "\"") == NULL)
|
||||||
snprintf(buffer, bsize, "Gentoo Linux (stable)");
|
g_snprintf(buffer, bsize, "Gentoo Linux (stable)");
|
||||||
else
|
else
|
||||||
snprintf(buffer, bsize, "Gentoo Linux %s", keywords);
|
g_snprintf(buffer, bsize, "Gentoo Linux %s", keywords);
|
||||||
}
|
}
|
||||||
else if((fp = fopen("/etc/redhat-release", "r")) != NULL)
|
else if((fp = fopen("/etc/redhat-release", "r")) != NULL)
|
||||||
fgets(buffer, bsize, fp);
|
fgets(buffer, bsize, fp);
|
||||||
|
@ -404,7 +266,7 @@ int xs_parse_distro(char *name)
|
||||||
else if((fp = fopen("/etc/turbolinux-release", "r")) != NULL)
|
else if((fp = fopen("/etc/turbolinux-release", "r")) != NULL)
|
||||||
fgets(buffer, bsize, fp);
|
fgets(buffer, bsize, fp);
|
||||||
else if((fp = fopen("/etc/arch-release", "r")) != NULL)
|
else if((fp = fopen("/etc/arch-release", "r")) != NULL)
|
||||||
snprintf(buffer, bsize, "ArchLinux");
|
g_snprintf(buffer, bsize, "ArchLinux");
|
||||||
else if((fp = fopen("/etc/lsb-release", "r")) != NULL)
|
else if((fp = fopen("/etc/lsb-release", "r")) != NULL)
|
||||||
{
|
{
|
||||||
char id[bsize], codename[bsize], release[bsize];
|
char id[bsize], codename[bsize], release[bsize];
|
||||||
|
@ -417,45 +279,22 @@ int xs_parse_distro(char *name)
|
||||||
find_match_char(buffer, "DISTRIB_CODENAME", codename);
|
find_match_char(buffer, "DISTRIB_CODENAME", codename);
|
||||||
find_match_char(buffer, "DISTRIB_RELEASE", release);
|
find_match_char(buffer, "DISTRIB_RELEASE", release);
|
||||||
}
|
}
|
||||||
snprintf(buffer, bsize, "%s \"%s\" %s", id, codename, release);
|
g_snprintf(buffer, bsize, "%s \"%s\" %s", id, codename, release);
|
||||||
}
|
}
|
||||||
else if((fp = fopen("/etc/debian_version", "r")) != NULL)
|
else if((fp = fopen("/etc/debian_version", "r")) != NULL)
|
||||||
{
|
{
|
||||||
char release[bsize];
|
char release[bsize];
|
||||||
fgets(release, bsize, fp);
|
fgets(release, bsize, fp);
|
||||||
snprintf(buffer, bsize, "Debian %s", release);
|
g_snprintf(buffer, bsize, "Debian %s", release);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snprintf(buffer, bsize, "Unknown Distro");
|
g_snprintf(buffer, bsize, "Unknown Distro");
|
||||||
if(fp != NULL) fclose(fp);
|
if(fp != NULL)
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
pos=strchr(buffer, '\n');
|
pos=strchr(buffer, '\n');
|
||||||
if(pos != NULL) *pos = '\0';
|
if(pos != NULL)
|
||||||
|
*pos = '\0';
|
||||||
strcpy(name, buffer);
|
strcpy(name, buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_hwmon_chip(char *chip)
|
|
||||||
{
|
|
||||||
if (!hwmon_chip_present())
|
|
||||||
return 1;
|
|
||||||
#if 0
|
|
||||||
else
|
|
||||||
get_hwmon_chip_name(chip);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int xs_parse_hwmon_temp(char *temp, unsigned int *sensor)
|
|
||||||
{
|
|
||||||
unsigned int value;
|
|
||||||
float celsius;
|
|
||||||
|
|
||||||
if (!hwmon_chip_present())
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
get_hwmon_temp(&value, sensor);
|
|
||||||
celsius = (float)value;
|
|
||||||
snprintf(temp, bsize, "%.1fC", celsius/1000.0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -23,18 +23,13 @@
|
||||||
#ifndef _PARSE_H_
|
#ifndef _PARSE_H_
|
||||||
#define _PARSE_H_
|
#define _PARSE_H_
|
||||||
|
|
||||||
int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned int *count);
|
int xs_parse_cpu(char *model, char *vendor, double *freq);
|
||||||
int xs_parse_uptime(int *weeks, int *days, int *hours, int *minutes, int *seconds);
|
gint64 xs_parse_uptime(void);
|
||||||
int xs_parse_os(char *user, char *host, char *kernel);
|
|
||||||
int xs_parse_sound(char *snd_card);
|
int xs_parse_sound(char *snd_card);
|
||||||
int xs_parse_netdev(const char *device, unsigned long long *bytes_recv, unsigned long long *bytes_sent);
|
|
||||||
int xs_parse_df(const char *mount_point, char *string);
|
|
||||||
int xs_parse_meminfo(unsigned long long *mem_tot, unsigned long long *mem_free, int swap);
|
int xs_parse_meminfo(unsigned long long *mem_tot, unsigned long long *mem_free, int swap);
|
||||||
int xs_parse_video(char *vid_card);
|
int xs_parse_video(char *vid_card);
|
||||||
int xs_parse_agpbridge(char *agp_bridge);
|
int xs_parse_agpbridge(char *agp_bridge);
|
||||||
int xs_parse_ether(char *ethernet_card);
|
int xs_parse_ether(char *ethernet_card);
|
||||||
int xs_parse_distro(char *name);
|
int xs_parse_distro(char *name);
|
||||||
int xs_parse_hwmon_chip(char *chip);
|
|
||||||
int xs_parse_hwmon_temp(char *temp, unsigned int *sensor);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,169 @@
|
||||||
|
/*
|
||||||
|
* pci.c - PCI functions for X-Sys
|
||||||
|
* Copyright (C) 1997-1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz> [PCI routines from lspci]
|
||||||
|
* Copyright (C) 2000 Tom Rini <trini@kernel.crashing.org> [XorgAutoConfig pci.c, based on lspci]
|
||||||
|
* Copyright (C) 2005, 2006 Tony Vroon
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <pci/pci.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "sysinfo.h"
|
||||||
|
|
||||||
|
static struct pci_filter filter; /* Device filter */
|
||||||
|
static struct pci_access *pacc;
|
||||||
|
int bus, dev, func; /* Location of the card */
|
||||||
|
|
||||||
|
struct device {
|
||||||
|
struct device *next;
|
||||||
|
struct pci_dev *dev;
|
||||||
|
unsigned int config_cnt;
|
||||||
|
u8 config[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct device *first_dev;
|
||||||
|
|
||||||
|
static struct device *scan_device(struct pci_dev *p)
|
||||||
|
{
|
||||||
|
int how_much = 64;
|
||||||
|
struct device *d;
|
||||||
|
|
||||||
|
if (!pci_filter_match(&filter, p))
|
||||||
|
return NULL;
|
||||||
|
d = g_new0 (struct device, 1);
|
||||||
|
d->dev = p;
|
||||||
|
if (!pci_read_block(p, 0, d->config, how_much))
|
||||||
|
exit(1);
|
||||||
|
if (how_much < 128 && (d->config[PCI_HEADER_TYPE] & 0x7f) == PCI_HEADER_TYPE_CARDBUS)
|
||||||
|
{
|
||||||
|
/* For cardbus bridges, we need to fetch 64 bytes more to get the full standard header... */
|
||||||
|
if (!pci_read_block(p, 64, d->config+64, 64))
|
||||||
|
exit(1);
|
||||||
|
how_much = 128;
|
||||||
|
}
|
||||||
|
d->config_cnt = how_much;
|
||||||
|
pci_setup_cache(p, d->config, d->config_cnt);
|
||||||
|
pci_fill_info(p, PCI_FILL_IDENT);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void scan_devices(void)
|
||||||
|
{
|
||||||
|
struct device *d;
|
||||||
|
struct pci_dev *p;
|
||||||
|
|
||||||
|
pci_scan_bus(pacc);
|
||||||
|
for(p=pacc->devices; p; p=p->next)
|
||||||
|
{
|
||||||
|
if ((d = scan_device(p)))
|
||||||
|
{
|
||||||
|
d->next = first_dev;
|
||||||
|
first_dev = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static u16 get_conf_word(struct device *d, unsigned int pos)
|
||||||
|
{
|
||||||
|
return d->config[pos] | (d->config[pos+1] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int pci_find_by_class(u16 *class, char *vendor, char *device)
|
||||||
|
{
|
||||||
|
struct device *d;
|
||||||
|
struct pci_dev *p;
|
||||||
|
int nomatch = 1;
|
||||||
|
|
||||||
|
pacc = pci_alloc();
|
||||||
|
pci_filter_init(pacc, &filter);
|
||||||
|
pci_init(pacc);
|
||||||
|
scan_devices();
|
||||||
|
|
||||||
|
for(d=first_dev; d; d=d->next)
|
||||||
|
{
|
||||||
|
p = d->dev;
|
||||||
|
/* Acquire vendor & device ID if the class matches */
|
||||||
|
if(get_conf_word(d, PCI_CLASS_DEVICE) == *class)
|
||||||
|
{
|
||||||
|
nomatch = 0;
|
||||||
|
g_snprintf(vendor,7,"%04x",p->vendor_id);
|
||||||
|
g_snprintf(device,7,"%04x",p->device_id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pci_cleanup(pacc);
|
||||||
|
return nomatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pci_find_fullname(char *fullname, char *vendor, char *device)
|
||||||
|
{
|
||||||
|
char buffer[bsize];
|
||||||
|
char vendorname[bsize/2] = "";
|
||||||
|
char devicename[bsize/2] = "";
|
||||||
|
char *position;
|
||||||
|
int cardfound = 0;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
if (!sysinfo_get_str_pref ("pciids", buffer))
|
||||||
|
strcpy (buffer, DEFAULT_PCIIDS);
|
||||||
|
|
||||||
|
fp = fopen (buffer, "r");
|
||||||
|
if(fp == NULL)
|
||||||
|
{
|
||||||
|
g_snprintf(fullname, bsize, "%s:%s", vendor, device);
|
||||||
|
//sysinfo_print_error ("pci.ids file not found! You might want to adjust your pciids setting with /SYSINFO SET pciids (you can query its current value with /SYSINFO LIST).\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
|
{
|
||||||
|
if (!isspace(buffer[0]) && strstr(buffer, vendor) != NULL)
|
||||||
|
{
|
||||||
|
position = strstr(buffer, vendor);
|
||||||
|
position += 6;
|
||||||
|
strncpy(vendorname, position, bsize/2);
|
||||||
|
position = strstr(vendorname, "\n");
|
||||||
|
*(position) = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
|
{
|
||||||
|
if(strstr(buffer, device) != NULL)
|
||||||
|
{
|
||||||
|
position = strstr(buffer, device);
|
||||||
|
position += 6;
|
||||||
|
strncpy(devicename, position, bsize/2);
|
||||||
|
position = strstr(devicename, " (");
|
||||||
|
if (position == NULL)
|
||||||
|
position = strstr(devicename, "\n");
|
||||||
|
*(position) = '\0';
|
||||||
|
cardfound = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cardfound == 1)
|
||||||
|
g_snprintf(fullname, bsize, "%s %s", vendorname, devicename);
|
||||||
|
else
|
||||||
|
g_snprintf(fullname, bsize, "%s:%s", vendor, device);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
|
@ -0,0 +1,493 @@
|
||||||
|
/* HexChat
|
||||||
|
* Copyright (c) 2011-2012 Berke Viktor.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wbemidl.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "../format.h"
|
||||||
|
|
||||||
|
/* Cache the info for subsequent invocations of /SYSINFO */
|
||||||
|
static int cpu_arch = 0;
|
||||||
|
static char *os_name = NULL;
|
||||||
|
static char *cpu_info = NULL;
|
||||||
|
static char *vga_name = NULL;
|
||||||
|
|
||||||
|
static int command_callback (char *word[], char *word_eol[], void *user_data);
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
QUERY_WMI_OS,
|
||||||
|
QUERY_WMI_CPU,
|
||||||
|
QUERY_WMI_VGA,
|
||||||
|
QUERY_WMI_HDD,
|
||||||
|
} QueryWmiType;
|
||||||
|
|
||||||
|
void print_info (void);
|
||||||
|
int get_cpu_arch (void);
|
||||||
|
char *query_wmi (QueryWmiType mode);
|
||||||
|
char *read_os_name (IWbemClassObject *object);
|
||||||
|
char *read_cpu_info (IWbemClassObject *object);
|
||||||
|
char *read_vga_name (IWbemClassObject *object);
|
||||||
|
|
||||||
|
guint64 hdd_capacity;
|
||||||
|
guint64 hdd_free_space;
|
||||||
|
char *read_hdd_info (IWbemClassObject *object);
|
||||||
|
|
||||||
|
char *get_memory_info (void);
|
||||||
|
char *bstr_to_utf8 (BSTR bstr);
|
||||||
|
guint64 variant_to_uint64 (VARIANT *variant);
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_sound (void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_network (void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_uptime (void)
|
||||||
|
{
|
||||||
|
return sysinfo_format_uptime (GetTickCount64 () / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_disk (void)
|
||||||
|
{
|
||||||
|
char *hdd_info;
|
||||||
|
|
||||||
|
/* HDD information is always loaded dynamically since it includes the current amount of free space */
|
||||||
|
hdd_capacity = 0;
|
||||||
|
hdd_free_space = 0;
|
||||||
|
hdd_info = query_wmi (QUERY_WMI_HDD);
|
||||||
|
if (hdd_info)
|
||||||
|
return sysinfo_format_disk (hdd_capacity, hdd_free_space);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_cpu (void)
|
||||||
|
{
|
||||||
|
if (cpu_info == NULL)
|
||||||
|
cpu_info = query_wmi (QUERY_WMI_CPU);
|
||||||
|
|
||||||
|
return g_strdup (cpu_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_memory (void)
|
||||||
|
{
|
||||||
|
/* Memory information is always loaded dynamically since it includes the current amount of free memory */
|
||||||
|
return get_memory_info ();
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_gpu (void)
|
||||||
|
{
|
||||||
|
if (vga_name == NULL)
|
||||||
|
vga_name = query_wmi (QUERY_WMI_VGA);
|
||||||
|
|
||||||
|
return g_strdup (vga_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_os (void)
|
||||||
|
{
|
||||||
|
if (os_name == NULL)
|
||||||
|
os_name = query_wmi (QUERY_WMI_OS);
|
||||||
|
|
||||||
|
if (cpu_arch == 0)
|
||||||
|
cpu_arch = get_cpu_arch ();
|
||||||
|
|
||||||
|
return g_strdup_printf ("%s (x%d)", os_name, cpu_arch);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_cpu_arch (void)
|
||||||
|
{
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
|
||||||
|
GetNativeSystemInfo (&si);
|
||||||
|
|
||||||
|
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
|
||||||
|
{
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 86;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* http://msdn.microsoft.com/en-us/site/aa390423 */
|
||||||
|
static char *query_wmi (QueryWmiType type)
|
||||||
|
{
|
||||||
|
GString *result = NULL;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
IWbemLocator *locator = NULL;
|
||||||
|
BSTR namespaceName = NULL;
|
||||||
|
BSTR queryLanguageName = NULL;
|
||||||
|
BSTR query = NULL;
|
||||||
|
IWbemServices *namespace = NULL;
|
||||||
|
IUnknown *namespaceUnknown = NULL;
|
||||||
|
IEnumWbemClassObject *enumerator = NULL;
|
||||||
|
int i;
|
||||||
|
gboolean atleast_one_appended = FALSE;
|
||||||
|
|
||||||
|
hr = CoCreateInstance (&CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (LPVOID *) &locator);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespaceName = SysAllocString (L"root\\CIMV2");
|
||||||
|
|
||||||
|
hr = locator->lpVtbl->ConnectServer (locator, namespaceName, NULL, NULL, NULL, 0, NULL, NULL, &namespace);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
goto release_locator;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = namespace->lpVtbl->QueryInterface (namespace, &IID_IUnknown, &namespaceUnknown);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
goto release_namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = CoSetProxyBlanket (namespaceUnknown, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
goto release_namespaceUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
queryLanguageName = SysAllocString (L"WQL");
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case QUERY_WMI_OS:
|
||||||
|
query = SysAllocString (L"SELECT Caption FROM Win32_OperatingSystem");
|
||||||
|
break;
|
||||||
|
case QUERY_WMI_CPU:
|
||||||
|
query = SysAllocString (L"SELECT Name, MaxClockSpeed FROM Win32_Processor");
|
||||||
|
break;
|
||||||
|
case QUERY_WMI_VGA:
|
||||||
|
query = SysAllocString (L"SELECT Name FROM Win32_VideoController");
|
||||||
|
break;
|
||||||
|
case QUERY_WMI_HDD:
|
||||||
|
query = SysAllocString (L"SELECT Name, Capacity, FreeSpace FROM Win32_Volume");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto release_queryLanguageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = namespace->lpVtbl->ExecQuery (namespace, queryLanguageName, query, WBEM_FLAG_FORWARD_ONLY, NULL, &enumerator);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
goto release_query;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = g_string_new ("");
|
||||||
|
|
||||||
|
for (i = 0;; i++)
|
||||||
|
{
|
||||||
|
ULONG numReturned = 0;
|
||||||
|
IWbemClassObject *object;
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
hr = enumerator->lpVtbl->Next (enumerator, WBEM_INFINITE, 1, &object, &numReturned);
|
||||||
|
if (FAILED (hr) || numReturned == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case QUERY_WMI_OS:
|
||||||
|
line = read_os_name (object);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QUERY_WMI_CPU:
|
||||||
|
line = read_cpu_info (object);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QUERY_WMI_VGA:
|
||||||
|
line = read_vga_name (object);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QUERY_WMI_HDD:
|
||||||
|
line = read_hdd_info (object);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
object->lpVtbl->Release (object);
|
||||||
|
|
||||||
|
if (line != NULL)
|
||||||
|
{
|
||||||
|
if (atleast_one_appended)
|
||||||
|
{
|
||||||
|
g_string_append (result, ", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_string_append (result, line);
|
||||||
|
|
||||||
|
g_free (line);
|
||||||
|
|
||||||
|
atleast_one_appended = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enumerator->lpVtbl->Release (enumerator);
|
||||||
|
|
||||||
|
release_query:
|
||||||
|
SysFreeString (query);
|
||||||
|
|
||||||
|
release_queryLanguageName:
|
||||||
|
SysFreeString (queryLanguageName);
|
||||||
|
|
||||||
|
release_namespaceUnknown:
|
||||||
|
namespaceUnknown->lpVtbl->Release (namespaceUnknown);
|
||||||
|
|
||||||
|
release_namespace:
|
||||||
|
namespace->lpVtbl->Release (namespace);
|
||||||
|
|
||||||
|
release_locator:
|
||||||
|
locator->lpVtbl->Release (locator);
|
||||||
|
SysFreeString (namespaceName);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
if (result == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_string_free (result, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *read_os_name (IWbemClassObject *object)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
VARIANT caption_variant;
|
||||||
|
char *caption_utf8;
|
||||||
|
|
||||||
|
hr = object->lpVtbl->Get (object, L"Caption", 0, &caption_variant, NULL, NULL);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
caption_utf8 = bstr_to_utf8 (caption_variant.bstrVal);
|
||||||
|
|
||||||
|
VariantClear(&caption_variant);
|
||||||
|
|
||||||
|
if (caption_utf8 == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_strchomp (caption_utf8);
|
||||||
|
|
||||||
|
return caption_utf8;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *read_cpu_info (IWbemClassObject *object)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
VARIANT name_variant;
|
||||||
|
char *name_utf8;
|
||||||
|
VARIANT max_clock_speed_variant;
|
||||||
|
guint cpu_freq_mhz;
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
hr = object->lpVtbl->Get (object, L"Name", 0, &name_variant, NULL, NULL);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
name_utf8 = bstr_to_utf8 (name_variant.bstrVal);
|
||||||
|
|
||||||
|
VariantClear (&name_variant);
|
||||||
|
|
||||||
|
if (name_utf8 == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = object->lpVtbl->Get (object, L"MaxClockSpeed", 0, &max_clock_speed_variant, NULL, NULL);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
g_free (name_utf8);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpu_freq_mhz = max_clock_speed_variant.uintVal;
|
||||||
|
|
||||||
|
VariantClear (&max_clock_speed_variant);
|
||||||
|
|
||||||
|
if (cpu_freq_mhz > 1000)
|
||||||
|
{
|
||||||
|
result = g_strdup_printf ("%s (%.2fGHz)", name_utf8, cpu_freq_mhz / 1000.f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = g_strdup_printf ("%s (%" G_GUINT32_FORMAT "MHz)", name_utf8, cpu_freq_mhz);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (name_utf8);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *read_vga_name (IWbemClassObject *object)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
VARIANT name_variant;
|
||||||
|
char *name_utf8;
|
||||||
|
|
||||||
|
hr = object->lpVtbl->Get (object, L"Name", 0, &name_variant, NULL, NULL);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
name_utf8 = bstr_to_utf8 (name_variant.bstrVal);
|
||||||
|
|
||||||
|
VariantClear (&name_variant);
|
||||||
|
|
||||||
|
if (name_utf8 == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strchomp (name_utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *read_hdd_info (IWbemClassObject *object)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
VARIANT name_variant;
|
||||||
|
BSTR name_bstr;
|
||||||
|
gsize name_len;
|
||||||
|
VARIANT capacity_variant;
|
||||||
|
guint64 capacity;
|
||||||
|
VARIANT free_space_variant;
|
||||||
|
guint64 free_space;
|
||||||
|
|
||||||
|
hr = object->lpVtbl->Get (object, L"Name", 0, &name_variant, NULL, NULL);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
name_bstr = name_variant.bstrVal;
|
||||||
|
name_len = SysStringLen (name_variant.bstrVal);
|
||||||
|
|
||||||
|
if (name_len >= 4 && name_bstr[0] == L'\\' && name_bstr[1] == L'\\' && name_bstr[2] == L'?' && name_bstr[3] == L'\\')
|
||||||
|
{
|
||||||
|
// This is not a named volume. Skip it.
|
||||||
|
VariantClear (&name_variant);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
VariantClear (&name_variant);
|
||||||
|
|
||||||
|
hr = object->lpVtbl->Get (object, L"Capacity", 0, &capacity_variant, NULL, NULL);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
capacity = variant_to_uint64 (&capacity_variant);
|
||||||
|
|
||||||
|
VariantClear (&capacity_variant);
|
||||||
|
|
||||||
|
if (capacity == 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = object->lpVtbl->Get (object, L"FreeSpace", 0, &free_space_variant, NULL, NULL);
|
||||||
|
if (FAILED (hr))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
free_space = variant_to_uint64 (&free_space_variant);
|
||||||
|
|
||||||
|
VariantClear (&free_space_variant);
|
||||||
|
|
||||||
|
if (free_space == 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hdd_capacity += capacity;
|
||||||
|
hdd_free_space += free_space;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *get_memory_info (void)
|
||||||
|
{
|
||||||
|
MEMORYSTATUSEX meminfo = { 0 };
|
||||||
|
meminfo.dwLength = sizeof (meminfo);
|
||||||
|
|
||||||
|
if (!GlobalMemoryStatusEx (&meminfo))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sysinfo_format_memory (meminfo.ullTotalPhys, meminfo.ullAvailPhys);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *bstr_to_utf8 (BSTR bstr)
|
||||||
|
{
|
||||||
|
return g_utf16_to_utf8 (bstr, SysStringLen (bstr), NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint64 variant_to_uint64 (VARIANT *variant)
|
||||||
|
{
|
||||||
|
switch (V_VT (variant))
|
||||||
|
{
|
||||||
|
case VT_UI8:
|
||||||
|
return variant->ullVal;
|
||||||
|
|
||||||
|
case VT_BSTR:
|
||||||
|
return wcstoull (variant->bstrVal, NULL, 10);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,116 +0,0 @@
|
||||||
v2.2.0
|
|
||||||
* (Thomas Cort) Report L2 cache info for Alpha CPUs
|
|
||||||
* (Tony Vroon) Drop XMMS, port audacious features to D-Bus, make dependency mandatory
|
|
||||||
* (Tony Vroon) Use pretty_freespace for memory & swap reporting as well as disk space
|
|
||||||
* (Tony Vroon) Make pretty_freespace report none if total_size is 0, thanks to Emopig <andrew@nelless.net> for the report
|
|
||||||
* (Tony Vroon) Make pretty_freespace aware of terabytes, petabytes, exabytes, zettabytes & yottabytes
|
|
||||||
* (Tony Vroon) Remove xchatdirfs workaround
|
|
||||||
|
|
||||||
v2.1.0
|
|
||||||
Removals & pending removal:
|
|
||||||
* (Tony Vroon) Remove support for BMP, it is an abandoned project. Suggested upgrade path: audacious
|
|
||||||
* (Tony Vroon) Remove /uname & /euname; the OS part of sysinfo displays similar info without requiring a process pipe
|
|
||||||
* (Tony Vroon) Added a note that the xchatdirfs workaround is due for removal as X-Chat Gnome has fixed the bug
|
|
||||||
|
|
||||||
Bugfixes:
|
|
||||||
* (Tony Vroon) Actually show the vendor that we retrieve in cpuinfo
|
|
||||||
* (Tony Vroon) Display Gentoo Linux as stable or ~arch, the baselayout version doesn't really interest anyone
|
|
||||||
* (Tony Vroon) Match framework: Make remove_leading_whitespace actually work
|
|
||||||
* (Tony Vroon) Match framework: Do not assume that a delimiter is always followed by a space
|
|
||||||
|
|
||||||
Code improvements:
|
|
||||||
* (Tony Vroon) PCI framework: We were requesting more info then we actually return to the caller
|
|
||||||
* (Tony Vroon) Match framework: Consolidate delimiters in a single define & use 1 strpbrk instead of 2 strstr's
|
|
||||||
* (Tony Vroon) Display the machine string instead of the pmac-generation as vendor info for PPC machines
|
|
||||||
|
|
||||||
New features
|
|
||||||
* (Tony Vroon) Show memory capacity in gigabytes instead of in megabytes when appropriate
|
|
||||||
* (Tony Vroon) Cut cpu name at comma (so overly long other info such as "altivec supported" is no longer displayed)
|
|
||||||
* (Tony Vroon) Now Playing: Report time played as well as the song length
|
|
||||||
* (Tony Vroon) Now Playing: Support reporting as an action; configurable at runtime
|
|
||||||
* (Tony Vroon) Check LSB release data, prefer above all others; based on a code sample submitted by Thomas Winwood
|
|
||||||
|
|
||||||
v2.0.9
|
|
||||||
* (Tony Vroon) Protect the matching framework against spurious matches (bug reported by Harm Geerts)
|
|
||||||
* (Tony Vroon) Unexporting unnecessary symbols for PCI framework
|
|
||||||
* (Tony Vroon) Deal with incompatible header changes in pciutils
|
|
||||||
* (Tony Vroon) Begin implementing hardware monitoring support, not yet activated
|
|
||||||
* (Tony Vroon) Add support for Audacious, a BMP fork
|
|
||||||
|
|
||||||
v2.0.8
|
|
||||||
* (Tony Vroon) Make XMMS interface actually work, thanks to a patch from Morten Cools
|
|
||||||
* (Tony Vroon) Use percentages for df information as well
|
|
||||||
* (Gustavo Zacarias) Add support for Sparc architecture, cache size detection on sparc64 only
|
|
||||||
* (Gustavo Zacarias) Consolidate buffer sizes into a single define
|
|
||||||
|
|
||||||
v2.0.7
|
|
||||||
* (Tony Vroon) Have df parser ignore pseudo-filesystems; deal with other locales more gracefully
|
|
||||||
* (Tony Vroon) Change default formatstring not to use mIRC color codes
|
|
||||||
* (Tony Vroon) Add fallback to ~/.xchat2 for xchat-gnome which does not report xchatdirfs properly
|
|
||||||
* (Tony Vroon) Revert to beepctrl.h style calls as infopipe is too unreliable
|
|
||||||
|
|
||||||
v2.0.6
|
|
||||||
* (Tony Vroon) Rewrote PCI framework, no longer depends on sysfs, kernel 2.4 and lower will work now
|
|
||||||
* (Tony Vroon) Made percentages configurable, can be set at runtime (feature request by Halcy0n)
|
|
||||||
* (Tony Vroon) Abstract out all pointer voodoo from xsys.c
|
|
||||||
* (Tony Vroon) Do not return XCHAT_EAT_NONE, causes spurious "unknown command" errors
|
|
||||||
* (Tony Vroon) Deal more gracefully with a missing soundcard or unknown linux distribution
|
|
||||||
* (Tony Vroon) Add error handling to the matching framework
|
|
||||||
|
|
||||||
v2.0.5
|
|
||||||
* (Tony Vroon) Added support for parisc/hppa & ia64 architectures
|
|
||||||
* (Tony Vroon) Proper report of L2 cache as "unknown" instead of showing bits of unitialized memory
|
|
||||||
* (Tony Vroon) Upped PCI parser yield for ppc64 architecture, has high bus number for AGP card
|
|
||||||
* (Tony Vroon) Use percentages in memory/swap information
|
|
||||||
|
|
||||||
v2.0.4
|
|
||||||
* (Tony Vroon) /sound uses ALSA if possible, PCI now fallback (false positives reported with PCI code)
|
|
||||||
* (Tony Vroon) Remove 0 prefix from first ALSA card; 1: and up will be shown for extra cards
|
|
||||||
* (Tony Vroon) Matching code rewritten and separated out from other code
|
|
||||||
* (Tony Vroon) Use new matching framework where possible
|
|
||||||
* (Tony Vroon) Added support for Alpha architecture, thanks to Bert (bert@ev6.net)
|
|
||||||
|
|
||||||
v2.0.3
|
|
||||||
* (Tony Vroon) Fix buttons, XMMS -> NP
|
|
||||||
* (Tony Vroon) PCI functions separated out from other code; fully rewritten
|
|
||||||
* (Tony Vroon) Use new PCI framework for sound detection; ALSA is now fallback
|
|
||||||
* (Tony Vroon) Implement /ether
|
|
||||||
* (Tony Vroon) /video now reports video card @ AGP bridge; resolution info dropped
|
|
||||||
|
|
||||||
v2.0.2
|
|
||||||
* (Tony Vroon) XMMS/BMP: Delete XMMS/BMP detection; it just got obsoleted by a BMP bugfix
|
|
||||||
* (Tony Vroon) XMMS/BMP: Change to /np & /enp as commands (np -> now playing)
|
|
||||||
* (Tony Vroon) Allow customization of now_playing with /playing
|
|
||||||
* (Tony Vroon) Separate out the length field for now_playing
|
|
||||||
* (Tony Vroon) Better configuration file handling
|
|
||||||
* (Tony Vroon) Set homepage to http://dev.gentoo.org/~chainsaw/xsys
|
|
||||||
* (Tony Vroon) Make channel buttons optional, not everyone appreciates them
|
|
||||||
* (Tony Vroon) Fix cpuinfo parsing on x86_64, a necessary define was missing
|
|
||||||
|
|
||||||
v2.0.1
|
|
||||||
* (Tony Vroon) XMMS/BMP: Report "stream" if song length is -1
|
|
||||||
* (Tony Vroon) XMMS/BMP: Determine whether XMMS or BMP is playing
|
|
||||||
* (Tony Vroon) Better errorhandling if pci.ids parsing fails; at least mention raw PCI ID of card
|
|
||||||
* (Tony Vroon) Remove AGP from video card messages; we detect plain PCI cards too
|
|
||||||
* (Tony Vroon) Fix Debian release detector
|
|
||||||
|
|
||||||
v2.0.0
|
|
||||||
* (mikeshoup) Clean up of code for 2.0.0 release
|
|
||||||
* (Tony Vroon) Added PowerPC /proc/cpuinfo support
|
|
||||||
* (Tony Vroon) Changed LSPCI to SYSFS
|
|
||||||
|
|
||||||
v1.9.3
|
|
||||||
* (mikeshoup) Introduced distro function
|
|
||||||
* (mikeshoup, Tony Vroon's suggestion) Removed bitrate from /XMMS
|
|
||||||
|
|
||||||
v1.9.2
|
|
||||||
* 2005/01/14 (mikeshoup) Put in the userlist buttons
|
|
||||||
* 2005/01/10 (mikeshoup) Added XMMS/BMP Support
|
|
||||||
|
|
||||||
v1.9.1
|
|
||||||
* 2004/12/20 (mikeshoup) Added a dynamic formatting scheme
|
|
||||||
* 2004/12/19 (mikeshoup) Changed some commands
|
|
||||||
* 2004/12/18 (mikeshoup) Reintroducted /VIDEO
|
|
||||||
|
|
||||||
v1.9.0
|
|
||||||
* 2004/12/17 (mikeshoup) Initial Release
|
|
|
@ -1,15 +0,0 @@
|
||||||
INSTALLATION
|
|
||||||
============
|
|
||||||
Installation is straightforward. You need Audacious 1.4 or higher and D-Bus.
|
|
||||||
Open up the Makefile, check to make sure PCIIDS points to your pci.ids file.
|
|
||||||
(Symptom if you get it wrong: raw PCI ID's (XXXX:XXXX) emitted by /VIDEO and friends).
|
|
||||||
|
|
||||||
Run: make
|
|
||||||
Run: make install
|
|
||||||
|
|
||||||
Voila!
|
|
||||||
|
|
||||||
NOTES:
|
|
||||||
`make install' copies the compiled library (something like xsys-v.v.v.so) to
|
|
||||||
$HOME/.xchat2/xsys-plugin.so for autoloading. If $HOME/.xchat2/xsys-plugin.so
|
|
||||||
exists, it is removed first.
|
|
|
@ -1,38 +0,0 @@
|
||||||
#### SET THIS VALUE TO THE LOCATION OF THE `pci.ids` file ####
|
|
||||||
PCIIDS = /usr/share/misc/pci.ids
|
|
||||||
|
|
||||||
#### UNCOMMENT THIS IF YOU WANT THE BUTTONS ####
|
|
||||||
#BUTTON = -Dbuttonbar
|
|
||||||
|
|
||||||
#### SHOULD NOT NEED TO EDIT BELOW THIS LINE ####
|
|
||||||
VER_MAJOR = 2
|
|
||||||
VER_MINOR = 2
|
|
||||||
VER_PATCH = 0
|
|
||||||
CC = gcc
|
|
||||||
CFLAGS += -O2 -Wall -fPIC
|
|
||||||
CFLAGS += -DVER_MINOR=$(VER_MINOR) -DVER_MAJOR=$(VER_MAJOR) -DVER_PATCH=$(VER_PATCH) \
|
|
||||||
-DVER_STRING=\"$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)\" -DPCIIDS=\"$(PCIIDS)\" $(BUTTON)
|
|
||||||
LDFLAGS = $(CFLAGS) -shared
|
|
||||||
LIBRARY = xsys-$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).so
|
|
||||||
OBJECTS = xsys.o parse.o pci.o match.o hwmon.o
|
|
||||||
|
|
||||||
ALL : $(LIBRARY)
|
|
||||||
|
|
||||||
$(LIBRARY) : $(OBJECTS)
|
|
||||||
$(CC) $(LDFLAGS) -o $(LIBRARY) $(OBJECTS) -lpci
|
|
||||||
|
|
||||||
xsys.o : xsys.c
|
|
||||||
parse.o : parse.c
|
|
||||||
pci.o : pci.c
|
|
||||||
match.o : match.c
|
|
||||||
hwmon.o : hwmon.c
|
|
||||||
|
|
||||||
.PHONY : clean
|
|
||||||
clean :
|
|
||||||
rm -rf *.o *.so *~
|
|
||||||
|
|
||||||
.PHONY : install
|
|
||||||
install : $(LIBRARY)
|
|
||||||
rm -f $(HOME)/.xchat2/xsys-plugin.so
|
|
||||||
cp ./$(LIBRARY) $(HOME)/.xchat2/xsys-plugin.so
|
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
X-Sys README
|
|
||||||
============
|
|
||||||
What is X-Sys?
|
|
||||||
|
|
||||||
X-Sys is a plugin for X-Chat that allows you to display your current system statistics in
|
|
||||||
a channel, private conversation or just in an echo to yourself for testing purposes.
|
|
||||||
It is supported on Linux, running on various architectures. Right now x86, ppc, ppc64, sparc,
|
|
||||||
sparc64 and alpha are supported, with parisc and ia64 implemented but awaiting testing.
|
|
||||||
|
|
||||||
---------------
|
|
||||||
Who wrote this?
|
|
||||||
|
|
||||||
X-Sys is originally a Mike Shoup creation, from the very first alpha releases to the open-source
|
|
||||||
version 1 releases. But then, things stalled. For a few months (more like a year almost)
|
|
||||||
Mike didn't work on X-Sys. The last version that had been written was 1.0.5.
|
|
||||||
The website was gone, and I (Tony) couldn't find Mike. So, I took over and improved it to my liking.
|
|
||||||
It turned out that Mike was still around, though, he contacted me and started development again,
|
|
||||||
now called version 2, a complete rewrite. Various 1.9 betas came out that I contributed patches to,
|
|
||||||
and starting with version 2.0.0 I'm maintaining xchat-xsys again, this time with Mike's blessing.
|
|
||||||
|
|
||||||
---------------
|
|
||||||
What do I need?
|
|
||||||
|
|
||||||
- X-Chat (regular or Gnome version)
|
|
||||||
- Audacious 1.4 or higher
|
|
||||||
- D-Bus (for communication with Audacious)
|
|
||||||
- a working toolchain (compiler, binutils, etc).
|
|
||||||
|
|
||||||
------------------------------------------------
|
|
||||||
What if I get errors about u8 not being defined?
|
|
||||||
|
|
||||||
Sorry to hear that, it appears your linux distribution neglected to install essential headers on your
|
|
||||||
system. On Debian & Ubuntu, apt-get install pciutils-dev should make it happy.
|
|
||||||
|
|
||||||
========
|
|
||||||
COMMANDS
|
|
||||||
|
|
||||||
X-Sys 2 has the following implemented commands:
|
|
||||||
/XSYS & /EXSYS - Output current version, either to channel or echoed on screen.
|
|
||||||
/CPUINFO & /ECPUINFO - Echoes or says current cpu statistics
|
|
||||||
/SYSUPTIME & /ESYSUPTIME - Echoes or says current uptime
|
|
||||||
/OSINFO & /EOSINFO - Echoes or says various OS statistics
|
|
||||||
/SOUND & /ESOUND - Echoes or says the current sound card, as determined by ALSA
|
|
||||||
/NETDATA & /ENETDATA - Echoes or says total amount transferred through a network
|
|
||||||
interface. Use like: `/netdata eth0' (where eth0 is a network interface)
|
|
||||||
/NETSTREAM & /ENETSTREAM - Echoes or says amount of bandwidth being used.
|
|
||||||
Use like: `/netstream eth0' (where eth0 is a network interface)
|
|
||||||
/DISKINFO & /EDISKINFO - Echoes or says free space on partitions. The DISK command has a
|
|
||||||
few arguments as follows:
|
|
||||||
ALL - Displays every partitions
|
|
||||||
/mount - Displays free space for that specific mount point
|
|
||||||
No arguments just displays total free space
|
|
||||||
/MEMINFO & /EMEMINFO - Echoes or says memory information.
|
|
||||||
/VIDEO & /EVIDEO - Echoes or says the current video card on the PCI bus
|
|
||||||
/ETHER & /EETHER - Echoes or says the current network card on the PCI bus
|
|
||||||
/DISTRO & /EDISTRO - Echoes or says which distro you're running
|
|
||||||
If this doesn't work for your distro, look for a *-release file or similar in /etc
|
|
||||||
E-mail this to chainsaw@gentoo.org
|
|
||||||
|
|
||||||
and the big one:
|
|
||||||
/SYSINFO & /ESYSINFO - Complete system information!
|
|
||||||
|
|
||||||
Two output control commands:
|
|
||||||
/XSYS2FORMAT , No arguments, it will print just the current formatting string.
|
|
||||||
It will take any arguments to it as the formatting string.
|
|
||||||
The formatting string can consist of any letter/numbers, and is used to format
|
|
||||||
the output. The following special symbols can be used:
|
|
||||||
|
|
||||||
%B : Bold
|
|
||||||
%Cnn : Foreground Color, where nn is a number corresponding to a mIRC color
|
|
||||||
%Cnn,nn : Foreground,Background Color
|
|
||||||
%R : Reverse Foreground/Background Colors
|
|
||||||
%O : Reset Color and Format (thats an 'oh' not a 'zero (0)')
|
|
||||||
%C : Reset Color
|
|
||||||
%U : Underline
|
|
||||||
|
|
||||||
/PLAYING will either print or allow you to set the text for /np.
|
|
||||||
The default is now_playing, but you can set this to whatever text you prefer.
|
|
||||||
|
|
||||||
/PERCENTAGES will allow you to set whether to use percentages in plugin output or not.
|
|
||||||
Percentages are enabled by default. Use a zero value to disable, and a non-zero value
|
|
||||||
to enable. If unsure, use 1.
|
|
||||||
|
|
||||||
/NP & /ENP - Reports what's currently playing in Audacious.
|
|
||||||
|
|
||||||
====
|
|
||||||
BUGS
|
|
||||||
(none known)
|
|
||||||
|
|
||||||
E-mail me your bug reports at chainsaw@gentoo.org
|
|
||||||
Please include the following information:
|
|
||||||
- what architecture you are using (amd64, ia64, parisc, ppc, ppc64, sparc, sparc64 or x86)
|
|
||||||
- what linux distribution you are using (Gentoo 2007.1, Fedora Core 8, etc)
|
|
||||||
- what compiler you have used to compile X-Sys, i.e. gcc (GCC) 4.1.2 (Gentoo 4.1.2)
|
|
||||||
- what version of X-Sys you are using
|
|
||||||
|
|
||||||
=======
|
|
||||||
Thanks!
|
|
||||||
Remember, everything here is:
|
|
||||||
(C) 2003, 2004, 2005 by Michael Shoup
|
|
||||||
(C) 2005, 2006, 2007 by Tony Vroon
|
|
||||||
All Rights Reserved.
|
|
||||||
Visit http://dev.gentoo.org/~chainsaw/xsys/ for release information.
|
|
||||||
|
|
||||||
Feel free to e-mail me for feature requests, or see if I'm online on irc.freenode.net
|
|
|
@ -1,923 +0,0 @@
|
||||||
/*
|
|
||||||
* SysInfo - sysinfo plugin for HexChat
|
|
||||||
* Copyright (c) 2012 Berke Viktor.
|
|
||||||
*
|
|
||||||
* xsys.c - main functions for X-Sys 2
|
|
||||||
* by mikeshoup
|
|
||||||
* Copyright (C) 2003, 2004, 2005 Michael Shoup
|
|
||||||
* Copyright (C) 2005, 2006, 2007 Tony Vroon
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "hexchat-plugin.h"
|
|
||||||
#include "parse.h"
|
|
||||||
#include "match.h"
|
|
||||||
#include "xsys.h"
|
|
||||||
|
|
||||||
#define DEFAULT_FORMAT "%B%1:%B %2 **"
|
|
||||||
#define DEFAULT_PERCENT 1
|
|
||||||
#define DEFAULT_ANNOUNCE 1
|
|
||||||
#define DEFAULT_PCIIDS "/usr/share/hwdata/pci.ids"
|
|
||||||
|
|
||||||
static hexchat_plugin *ph; /* plugin handle */
|
|
||||||
static int error_printed = 0; /* semaphore, make sure not to print the same error more than once during one execution */
|
|
||||||
|
|
||||||
static char name[] = "SysInfo";
|
|
||||||
static char desc[] = "Display info about your hardware and OS";
|
|
||||||
static char version[] = "3.0";
|
|
||||||
static char sysinfo_help[] = "SysInfo Usage:\n /SYSINFO [-e|-o] [OS|DISTRO|CPU|RAM|DISK|VGA|SOUND|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n /SYSINFO LIST, print current settings\n /SYSINFO SET <variable>, update given setting\n /SYSINFO RESET, reset settings to defaults\n /NETDATA <iface>, show transmitted data on given interface\n /NETSTREAM <iface>, show current bandwidth on given interface\n";
|
|
||||||
|
|
||||||
void
|
|
||||||
sysinfo_get_pciids (char* dest)
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_get_str (ph, "pciids", dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
sysinfo_get_percent ()
|
|
||||||
{
|
|
||||||
return hexchat_pluginpref_get_int (ph, "percent");
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
sysinfo_get_announce ()
|
|
||||||
{
|
|
||||||
return hexchat_pluginpref_get_int (ph, "announce");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
sysinfo_print_error (const char* msg)
|
|
||||||
{
|
|
||||||
if (!error_printed)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\t%s", name, msg);
|
|
||||||
}
|
|
||||||
error_printed++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_summary (int announce, char* format)
|
|
||||||
{
|
|
||||||
char sysinfo[bsize];
|
|
||||||
char buffer[bsize];
|
|
||||||
char cpu_model[bsize];
|
|
||||||
char cpu_cache[bsize];
|
|
||||||
char cpu_vendor[bsize];
|
|
||||||
char os_host[bsize];
|
|
||||||
char os_user[bsize];
|
|
||||||
char os_kernel[bsize];
|
|
||||||
unsigned long long mem_total;
|
|
||||||
unsigned long long mem_free;
|
|
||||||
unsigned int count;
|
|
||||||
double cpu_freq;
|
|
||||||
int giga = 0;
|
|
||||||
int weeks;
|
|
||||||
int days;
|
|
||||||
int hours;
|
|
||||||
int minutes;
|
|
||||||
int seconds;
|
|
||||||
sysinfo[0] = '\0';
|
|
||||||
|
|
||||||
snprintf (buffer, bsize, "%s", hexchat_get_info (ph, "version"));
|
|
||||||
format_output ("HexChat", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (sysinfo));
|
|
||||||
|
|
||||||
/* BEGIN OS PARSING */
|
|
||||||
if (xs_parse_os (os_user, os_host, os_kernel) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_os()", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf (buffer, bsize, "%s", os_kernel);
|
|
||||||
format_output ("OS", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (sysinfo));
|
|
||||||
|
|
||||||
/* BEGIN DISTRO PARSING */
|
|
||||||
if (xs_parse_distro (buffer) != 0)
|
|
||||||
{
|
|
||||||
strncpy (buffer, "Unknown", bsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Distro", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (sysinfo));
|
|
||||||
|
|
||||||
/* BEGIN CPU PARSING */
|
|
||||||
if (xs_parse_cpu (cpu_model, cpu_vendor, &cpu_freq, cpu_cache, &count) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_cpu()", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cpu_freq > 1000)
|
|
||||||
{
|
|
||||||
cpu_freq /= 1000;
|
|
||||||
giga = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (giga)
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%u x %s (%s) @ %.2fGHz", count, cpu_model, cpu_vendor, cpu_freq);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%u x %s (%s) @ %.0fMHz", count, cpu_model, cpu_vendor, cpu_freq);
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("CPU", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (sysinfo));
|
|
||||||
|
|
||||||
/* BEGIN MEMORY PARSING */
|
|
||||||
if (xs_parse_meminfo (&mem_total, &mem_free, 0) == 1)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_meminfo!", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf (buffer, bsize, "%s", pretty_freespace ("Physical", &mem_free, &mem_total));
|
|
||||||
format_output ("RAM", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (sysinfo));
|
|
||||||
|
|
||||||
/* BEGIN DISK PARSING */
|
|
||||||
if (xs_parse_df (NULL, buffer))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_df", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Disk", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (buffer));
|
|
||||||
|
|
||||||
/* BEGIN VIDEO PARSING */
|
|
||||||
if (xs_parse_video (buffer))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_video", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("VGA", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (buffer));
|
|
||||||
|
|
||||||
/* BEGIN SOUND PARSING */
|
|
||||||
if (xs_parse_sound (buffer))
|
|
||||||
{
|
|
||||||
strncpy (buffer, "Not present", bsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Sound", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (buffer));
|
|
||||||
|
|
||||||
/* BEGIN ETHERNET PARSING */
|
|
||||||
if (xs_parse_ether (buffer))
|
|
||||||
{
|
|
||||||
strncpy (buffer, "None found", bsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Ethernet", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (buffer));
|
|
||||||
|
|
||||||
/* BEGIN UPTIME PARSING */
|
|
||||||
if (xs_parse_uptime (&weeks, &days, &hours, &minutes, &seconds))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_uptime()", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minutes != 0 || hours != 0 || days != 0 || weeks != 0)
|
|
||||||
{
|
|
||||||
if (hours != 0 || days != 0 || weeks != 0)
|
|
||||||
{
|
|
||||||
if (days !=0 || weeks != 0)
|
|
||||||
{
|
|
||||||
if (weeks != 0)
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%dw %dd %dh %dm %ds", weeks, days, hours, minutes, seconds);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%dd %dh %dm %ds", days, hours, minutes, seconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%dh %dm %ds", hours, minutes, seconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%dm %ds", minutes, seconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Uptime", buffer, format);
|
|
||||||
strcat (sysinfo, "\017 ");
|
|
||||||
strncat (sysinfo, buffer, bsize - strlen (buffer));
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", sysinfo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", sysinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_os (int announce, char* format)
|
|
||||||
{
|
|
||||||
char buffer[bsize];
|
|
||||||
char user[bsize];
|
|
||||||
char host[bsize];
|
|
||||||
char kernel[bsize];
|
|
||||||
|
|
||||||
if (xs_parse_os (user, host, kernel) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_os()", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf (buffer, bsize, "%s@%s, %s", user, host, kernel);
|
|
||||||
format_output ("OS", buffer, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_distro (int announce, char* format)
|
|
||||||
{
|
|
||||||
char name[bsize];
|
|
||||||
|
|
||||||
if (xs_parse_distro (name) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_distro()!", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output("Distro", name, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", name);
|
|
||||||
}
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_cpu (int announce, char* format)
|
|
||||||
{
|
|
||||||
char model[bsize];
|
|
||||||
char vendor[bsize];
|
|
||||||
char cache[bsize];
|
|
||||||
char buffer[bsize];
|
|
||||||
unsigned int count;
|
|
||||||
double freq;
|
|
||||||
int giga = 0;
|
|
||||||
|
|
||||||
if (xs_parse_cpu (model, vendor, &freq, cache, &count) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_cpu()", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freq > 1000)
|
|
||||||
{
|
|
||||||
freq /= 1000;
|
|
||||||
giga = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (giga)
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%u x %s (%s) @ %.2fGHz w/ %s L2 Cache", count, model, vendor, freq, cache);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%u x %s (%s) @ %.0fMHz w/ %s L2 Cache", count, model, vendor, freq, cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("CPU", buffer, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_ram (int announce, char* format)
|
|
||||||
{
|
|
||||||
unsigned long long mem_total;
|
|
||||||
unsigned long long mem_free;
|
|
||||||
unsigned long long swap_total;
|
|
||||||
unsigned long long swap_free;
|
|
||||||
char string[bsize];
|
|
||||||
|
|
||||||
if (xs_parse_meminfo (&mem_total, &mem_free, 0) == 1)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_meminfo!", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
if (xs_parse_meminfo (&swap_total, &swap_free, 1) == 1)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_meminfo!", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf (string, bsize, "%s - %s", pretty_freespace ("Physical", &mem_free, &mem_total), pretty_freespace ("Swap", &swap_free, &swap_total));
|
|
||||||
format_output ("RAM", string, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", string);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_disk (int announce, char* format)
|
|
||||||
{
|
|
||||||
char string[bsize] = {0,};
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (*word == '\0')
|
|
||||||
{
|
|
||||||
if (xs_parse_df (NULL, string))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "ERROR in parse_df");
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (xs_parse_df (*word, string))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "ERROR in parse_df");
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (xs_parse_df (NULL, string))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_df", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Disk", string, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", string);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_vga (int announce, char* format)
|
|
||||||
{
|
|
||||||
char vid_card[bsize];
|
|
||||||
char agp_bridge[bsize];
|
|
||||||
char buffer[bsize];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if ((ret = xs_parse_video (vid_card)) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_video! %d", name, ret);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xs_parse_agpbridge (agp_bridge) != 0)
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%s", vid_card);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%s @ %s", vid_card, agp_bridge);
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("VGA", buffer, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_sound (int announce, char* format)
|
|
||||||
{
|
|
||||||
char sound[bsize];
|
|
||||||
|
|
||||||
if (xs_parse_sound (sound) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_asound()!", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Sound", sound, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", sound);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_ethernet (int announce, char* format)
|
|
||||||
{
|
|
||||||
char ethernet_card[bsize];
|
|
||||||
|
|
||||||
if (xs_parse_ether (ethernet_card))
|
|
||||||
{
|
|
||||||
strncpy (ethernet_card, "None found", bsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Ethernet", ethernet_card, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", ethernet_card);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", ethernet_card);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_uptime (int announce, char* format)
|
|
||||||
{
|
|
||||||
char buffer[bsize];
|
|
||||||
int weeks;
|
|
||||||
int days;
|
|
||||||
int hours;
|
|
||||||
int minutes;
|
|
||||||
int seconds;
|
|
||||||
|
|
||||||
if (xs_parse_uptime (&weeks, &days, &hours, &minutes, &seconds))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_uptime()", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minutes != 0 || hours != 0 || days != 0 || weeks != 0)
|
|
||||||
{
|
|
||||||
if (hours != 0 || days != 0 || weeks != 0)
|
|
||||||
{
|
|
||||||
if (days !=0 || weeks != 0)
|
|
||||||
{
|
|
||||||
if (weeks != 0)
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%dw %dd %dh %dm %ds", weeks, days, hours, minutes, seconds);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%dd %dh %dm %ds", days, hours, minutes, seconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%dh %dm %ds", hours, minutes, seconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buffer, bsize, "%dm %ds", minutes, seconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
format_output ("Uptime", buffer, format);
|
|
||||||
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
netdata_cb (char *word[], char *word_eol[], void *userdata)
|
|
||||||
{
|
|
||||||
char netdata[bsize];
|
|
||||||
char format[bsize];
|
|
||||||
unsigned long long bytes_recv;
|
|
||||||
unsigned long long bytes_sent;
|
|
||||||
|
|
||||||
if (*word[2] == '\0')
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tYou must specify a network device (e.g. /NETDATA eth0)!", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xs_parse_netdev (word[2], &bytes_recv, &bytes_sent) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_netdev", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes_recv /= 1024;
|
|
||||||
bytes_sent /= 1024;
|
|
||||||
|
|
||||||
snprintf (netdata, bsize, "%s: %.1f MB Received, %.1f MB Sent", word[2], (double)bytes_recv/1024.0, (double)bytes_sent/1024.0);
|
|
||||||
hexchat_pluginpref_get_str (ph, "format", format);
|
|
||||||
format_output ("Netdata", netdata, format);
|
|
||||||
|
|
||||||
if (hexchat_list_int (ph, NULL, "type") >= 2)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", netdata);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", netdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
netstream_cb (char *word[], char *word_eol[], void *userdata)
|
|
||||||
{
|
|
||||||
char netstream[bsize];
|
|
||||||
char mag_r[5];
|
|
||||||
char mag_s[5];
|
|
||||||
char format[bsize];
|
|
||||||
unsigned long long bytes_recv;
|
|
||||||
unsigned long long bytes_sent;
|
|
||||||
unsigned long long bytes_recv_p;
|
|
||||||
unsigned long long bytes_sent_p;
|
|
||||||
|
|
||||||
struct timespec ts = {1, 0};
|
|
||||||
|
|
||||||
if (*word[2] == '\0')
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tYou must specify a network device (e.g. /NETSTREAM eth0)!", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xs_parse_netdev(word[2], &bytes_recv, &bytes_sent) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_netdev", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (nanosleep (&ts, &ts) < 0);
|
|
||||||
|
|
||||||
if (xs_parse_netdev(word[2], &bytes_recv_p, &bytes_sent_p) != 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tERROR in parse_netdev", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes_recv = (bytes_recv_p - bytes_recv);
|
|
||||||
bytes_sent = (bytes_sent_p - bytes_sent);
|
|
||||||
|
|
||||||
if (bytes_recv > 1024)
|
|
||||||
{
|
|
||||||
bytes_recv /= 1024;
|
|
||||||
snprintf (mag_r, 5, "KB/s");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (mag_r, 5, "B/s");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bytes_sent > 1024)
|
|
||||||
{
|
|
||||||
bytes_sent /= 1024;
|
|
||||||
snprintf (mag_s, 5, "KB/s");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (mag_s, 5, "B/s");
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf (netstream, bsize, "%s: Receiving %llu %s, Sending %llu %s", word[2], bytes_recv, mag_r, bytes_sent, mag_s);
|
|
||||||
hexchat_pluginpref_get_str (ph, "format", format);
|
|
||||||
format_output ("Netstream", netstream, format);
|
|
||||||
|
|
||||||
if (hexchat_list_int (ph, NULL, "type") >= 2)
|
|
||||||
{
|
|
||||||
hexchat_commandf (ph, "SAY %s", netstream);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s", netstream);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
list_settings ()
|
|
||||||
{
|
|
||||||
char list[512];
|
|
||||||
char buffer[512];
|
|
||||||
char* token;
|
|
||||||
|
|
||||||
hexchat_pluginpref_list (ph, list);
|
|
||||||
hexchat_printf (ph, "%s\tCurrent Settings:", name);
|
|
||||||
token = strtok (list, ",");
|
|
||||||
|
|
||||||
while (token != NULL)
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_get_str (ph, token, buffer);
|
|
||||||
hexchat_printf (ph, "%s\t%s: %s\n", name, token, buffer);
|
|
||||||
token = strtok (NULL, ",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
reset_settings ()
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_str (ph, "pciids", DEFAULT_PCIIDS);
|
|
||||||
hexchat_pluginpref_set_str (ph, "format", DEFAULT_FORMAT);
|
|
||||||
hexchat_pluginpref_set_int (ph, "percent", DEFAULT_PERCENT);
|
|
||||||
hexchat_pluginpref_set_int (ph, "announce", DEFAULT_ANNOUNCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
sysinfo_cb (char *word[], char *word_eol[], void *userdata)
|
|
||||||
{
|
|
||||||
error_printed = 0;
|
|
||||||
int announce = sysinfo_get_announce ();
|
|
||||||
int offset = 0;
|
|
||||||
int buffer;
|
|
||||||
char format[bsize];
|
|
||||||
|
|
||||||
if (!hexchat_pluginpref_get_str (ph, "format", format))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tError reading config file!", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cannot send to server tab */
|
|
||||||
if (hexchat_list_int (ph, NULL, "type") == 1)
|
|
||||||
{
|
|
||||||
announce = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allow overriding global announce setting */
|
|
||||||
if (!strcmp ("-e", word[2]))
|
|
||||||
{
|
|
||||||
announce = 0;
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
else if (!strcmp ("-o", word[2]))
|
|
||||||
{
|
|
||||||
announce = 1;
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_ascii_strcasecmp ("HELP", word[2+offset]))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, sysinfo_help);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("LIST", word[2+offset]))
|
|
||||||
{
|
|
||||||
list_settings ();
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("SET", word[2+offset]))
|
|
||||||
{
|
|
||||||
if (!g_ascii_strcasecmp ("", word_eol[4+offset]))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tEnter a value!\n", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
if (!g_ascii_strcasecmp ("format", word[3+offset]))
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_str (ph, "format", word_eol[4+offset]);
|
|
||||||
hexchat_printf (ph, "%s\tformat is set to: %s\n", name, word_eol[4+offset]);
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("percent", word[3+offset]))
|
|
||||||
{
|
|
||||||
buffer = atoi (word[4+offset]); /* don't use word_eol, numbers must not contain spaces */
|
|
||||||
|
|
||||||
if (buffer > 0 && buffer < INT_MAX)
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_int (ph, "percent", buffer);
|
|
||||||
hexchat_printf (ph, "%s\tpercent is set to: %d\n", name, buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tInvalid input!\n", name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("announce", word[3+offset]))
|
|
||||||
{
|
|
||||||
buffer = atoi (word[4+offset]); /* don't use word_eol, numbers must not contain spaces */
|
|
||||||
|
|
||||||
if (buffer > 0)
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_int (ph, "announce", 1);
|
|
||||||
hexchat_printf (ph, "%s\tannounce is set to: On\n", name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_int (ph, "announce", 0);
|
|
||||||
hexchat_printf (ph, "%s\tannounce is set to: Off\n", name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("pciids", word[3+offset]))
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_str (ph, "pciids", word_eol[4+offset]);
|
|
||||||
hexchat_printf (ph, "%s\tpciids is set to: %s\n", name, word_eol[4+offset]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tInvalid variable name! Use 'pciids', 'format' or 'percent'!\n", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("RESET", word[2+offset]))
|
|
||||||
{
|
|
||||||
reset_settings ();
|
|
||||||
hexchat_printf (ph, "%s\tSettings have been restored to defaults.\n", name);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("OS", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_os (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("DISTRO", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_distro (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("CPU", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_cpu (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("RAM", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_ram (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("DISK", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_disk (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("VGA", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_vga (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("SOUND", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_sound (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("ETHERNET", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_ethernet (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("UPTIME", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_uptime (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("", word[2+offset]))
|
|
||||||
{
|
|
||||||
print_summary (announce, format);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, sysinfo_help);
|
|
||||||
return HEXCHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
|
|
||||||
{
|
|
||||||
ph = plugin_handle;
|
|
||||||
*plugin_name = name;
|
|
||||||
*plugin_desc = desc;
|
|
||||||
*plugin_version = version;
|
|
||||||
char buffer[bsize];
|
|
||||||
|
|
||||||
hexchat_hook_command (ph, "SYSINFO", HEXCHAT_PRI_NORM, sysinfo_cb, sysinfo_help, NULL);
|
|
||||||
hexchat_hook_command (ph, "NETDATA", HEXCHAT_PRI_NORM, netdata_cb, NULL, NULL);
|
|
||||||
hexchat_hook_command (ph, "NETSTREAM", HEXCHAT_PRI_NORM, netstream_cb, NULL, NULL);
|
|
||||||
|
|
||||||
/* this is required for the very first run */
|
|
||||||
if (hexchat_pluginpref_get_str (ph, "pciids", buffer) == 0)
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_str (ph, "pciids", DEFAULT_PCIIDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hexchat_pluginpref_get_str (ph, "format", buffer) == 0)
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_str (ph, "format", DEFAULT_FORMAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hexchat_pluginpref_get_int (ph, "percent") == -1)
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_int (ph, "percent", DEFAULT_PERCENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hexchat_pluginpref_get_int (ph, "announce") == -1)
|
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_int (ph, "announce", DEFAULT_ANNOUNCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
hexchat_command (ph, "MENU ADD \"Window/Send System Info\" \"SYSINFO\"");
|
|
||||||
hexchat_printf (ph, "%s plugin loaded\n", name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
hexchat_plugin_deinit (void)
|
|
||||||
{
|
|
||||||
hexchat_command (ph, "MENU DEL \"Window/Display System Info\"");
|
|
||||||
hexchat_printf (ph, "%s plugin unloaded\n", name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -20,260 +20,50 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <winsparkle.h>
|
||||||
#include <wininet.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
|
|
||||||
#define DEFAULT_DELAY 30 /* 30 seconds */
|
#define APPCAST_URL "https://dl.hexchat.net/appcast.xml"
|
||||||
#define DEFAULT_FREQ 360 /* 6 hours */
|
|
||||||
#define DOWNLOAD_URL "http://dl.hexchat.net/hexchat"
|
|
||||||
|
|
||||||
static hexchat_plugin *ph; /* plugin handle */
|
static hexchat_plugin *ph; /* plugin handle */
|
||||||
static char name[] = "Update Checker";
|
static char name[] = "Update Checker";
|
||||||
static char desc[] = "Check for HexChat updates automatically";
|
static char desc[] = "Check for HexChat updates automatically";
|
||||||
static char version[] = "4.0";
|
static char version[] = "5.0";
|
||||||
static const char upd_help[] = "Update Checker Usage:\n /UPDCHK, check for HexChat updates\n /UPDCHK SET delay|freq, set startup delay or check frequency\n";
|
static const char upd_help[] = "Update Checker Usage:\n /UPDCHK, check for HexChat updates\n";
|
||||||
|
|
||||||
static char*
|
|
||||||
check_version ()
|
|
||||||
{
|
|
||||||
HINTERNET hOpen, hConnect, hResource;
|
|
||||||
|
|
||||||
hOpen = InternetOpen (TEXT ("Update Checker"),
|
|
||||||
INTERNET_OPEN_TYPE_PRECONFIG,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0);
|
|
||||||
if (!hOpen)
|
|
||||||
{
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
hConnect = InternetConnect (hOpen,
|
|
||||||
TEXT ("raw.github.com"),
|
|
||||||
INTERNET_DEFAULT_HTTPS_PORT,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
INTERNET_SERVICE_HTTP,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
if (!hConnect)
|
|
||||||
{
|
|
||||||
InternetCloseHandle (hOpen);
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
hResource = HttpOpenRequest (hConnect,
|
|
||||||
TEXT ("GET"),
|
|
||||||
TEXT ("/hexchat/hexchat/master/win32/version.txt"),
|
|
||||||
TEXT ("HTTP/1.0"),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
INTERNET_FLAG_SECURE | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_AUTH,
|
|
||||||
0);
|
|
||||||
if (!hResource)
|
|
||||||
{
|
|
||||||
InternetCloseHandle (hConnect);
|
|
||||||
InternetCloseHandle (hOpen);
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static char buffer[1024];
|
|
||||||
char infobuffer[32];
|
|
||||||
int statuscode;
|
|
||||||
|
|
||||||
DWORD dwRead;
|
|
||||||
DWORD infolen = sizeof(infobuffer);
|
|
||||||
|
|
||||||
HttpAddRequestHeaders (hResource, TEXT ("Connection: close\r\n"), -1L, HTTP_ADDREQ_FLAG_ADD); /* workaround for GC bug */
|
|
||||||
HttpSendRequest (hResource, NULL, 0, NULL, 0);
|
|
||||||
|
|
||||||
while (InternetReadFile (hResource, buffer, 1023, &dwRead))
|
|
||||||
{
|
|
||||||
if (dwRead == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
buffer[dwRead] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpQueryInfo(hResource,
|
|
||||||
HTTP_QUERY_STATUS_CODE,
|
|
||||||
&infobuffer,
|
|
||||||
&infolen,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
InternetCloseHandle (hResource);
|
|
||||||
InternetCloseHandle (hConnect);
|
|
||||||
InternetCloseHandle (hOpen);
|
|
||||||
|
|
||||||
statuscode = atoi(infobuffer);
|
|
||||||
if (statuscode == 200)
|
|
||||||
return buffer;
|
|
||||||
else
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
print_version (char *word[], char *word_eol[], void *userdata)
|
check_cmd (char *word[], char *word_eol[], void *userdata)
|
||||||
{
|
{
|
||||||
char *version;
|
win_sparkle_check_update_with_ui ();
|
||||||
int prevbuf;
|
|
||||||
int convbuf;
|
|
||||||
|
|
||||||
if (!g_ascii_strcasecmp ("HELP", word[2]))
|
return HEXCHAT_EAT_ALL;
|
||||||
{
|
|
||||||
hexchat_printf (ph, upd_help);
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("SET", word[2]))
|
|
||||||
{
|
|
||||||
if (!g_ascii_strcasecmp ("", word_eol[4]))
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tEnter a value!\n", name);
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
|
||||||
}
|
|
||||||
if (!g_ascii_strcasecmp ("delay", word[3]))
|
|
||||||
{
|
|
||||||
convbuf = atoi (word[4]); /* don't use word_eol, numbers must not contain spaces */
|
|
||||||
|
|
||||||
if (convbuf > 0 && convbuf < INT_MAX)
|
|
||||||
{
|
|
||||||
prevbuf = hexchat_pluginpref_get_int (ph, "delay");
|
|
||||||
hexchat_pluginpref_set_int (ph, "delay", convbuf);
|
|
||||||
hexchat_printf (ph, "%s\tUpdate check startup delay is set to %d seconds (from %d).\n", name, convbuf, prevbuf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tInvalid input!\n", name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("freq", word[3]))
|
|
||||||
{
|
|
||||||
convbuf = atoi (word[4]); /* don't use word_eol, numbers must not contain spaces */
|
|
||||||
|
|
||||||
if (convbuf > 0 && convbuf < INT_MAX)
|
|
||||||
{
|
|
||||||
prevbuf = hexchat_pluginpref_get_int (ph, "freq");
|
|
||||||
hexchat_pluginpref_set_int (ph, "freq", convbuf);
|
|
||||||
hexchat_printf (ph, "%s\tUpdate check frequency is set to %d minutes (from %d).\n", name, convbuf, prevbuf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tInvalid input!\n", name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tInvalid variable name! Use 'delay' or 'freq'!\n", name);
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("", word[2]))
|
|
||||||
{
|
|
||||||
version = check_version ();
|
|
||||||
|
|
||||||
if (strcmp (version, hexchat_get_info (ph, "version")) == 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tYou have the latest version of HexChat installed!\n", name);
|
|
||||||
}
|
|
||||||
else if (strcmp (version, "Unknown") == 0)
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, "%s\tUnable to check for HexChat updates!\n", name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef _WIN64 /* use this approach, the wProcessorArchitecture method always returns 0 (=x86) for some reason */
|
|
||||||
hexchat_printf (ph, "%s:\tA HexChat update is available! You can download it from here:\n%s/HexChat%%20%s%%20x64.exe\n", name, DOWNLOAD_URL, version);
|
|
||||||
#else
|
|
||||||
hexchat_printf (ph, "%s:\tA HexChat update is available! You can download it from here:\n%s/HexChat%%20%s%%20x86.exe\n", name, DOWNLOAD_URL, version);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hexchat_printf (ph, upd_help);
|
|
||||||
return HEXCHAT_EAT_HEXCHAT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_version_quiet (void *userdata)
|
|
||||||
{
|
|
||||||
char *version = check_version ();
|
|
||||||
|
|
||||||
/* if it's not the current version AND not network error */
|
|
||||||
if (!(strcmp (version, hexchat_get_info (ph, "version")) == 0) && !(strcmp (version, "Unknown") == 0))
|
|
||||||
{
|
|
||||||
#ifdef _WIN64 /* use this approach, the wProcessorArchitecture method always returns 0 (=x86) for plugins for some reason */
|
|
||||||
hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\n%s/HexChat%%20%s%%20x64.exe\n", name, DOWNLOAD_URL, version);
|
|
||||||
#else
|
|
||||||
hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\n%s/HexChat%%20%s%%20x86.exe\n", name, DOWNLOAD_URL, version);
|
|
||||||
#endif
|
|
||||||
/* print update url once, then stop the timer */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* keep checking */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
delayed_check (void *userdata)
|
|
||||||
{
|
|
||||||
int freq = hexchat_pluginpref_get_int (ph, "freq");
|
|
||||||
|
|
||||||
/* only start the timer if there's no update available during startup */
|
|
||||||
if (print_version_quiet (NULL))
|
|
||||||
{
|
|
||||||
/* check for updates, every 6 hours by default */
|
|
||||||
hexchat_hook_timer (ph, freq * 1000 * 60, print_version_quiet, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; /* run delayed_check() only once */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
|
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
|
||||||
{
|
{
|
||||||
int delay;
|
|
||||||
ph = plugin_handle;
|
ph = plugin_handle;
|
||||||
|
|
||||||
*plugin_name = name;
|
*plugin_name = name;
|
||||||
*plugin_desc = desc;
|
*plugin_desc = desc;
|
||||||
*plugin_version = version;
|
*plugin_version = version;
|
||||||
|
|
||||||
/* these are required for the very first run */
|
win_sparkle_set_appcast_url (APPCAST_URL);
|
||||||
delay = hexchat_pluginpref_get_int (ph, "delay");
|
win_sparkle_init ();
|
||||||
if (delay == -1)
|
|
||||||
{
|
|
||||||
delay = DEFAULT_DELAY;
|
|
||||||
hexchat_pluginpref_set_int (ph, "delay", DEFAULT_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hexchat_pluginpref_get_int (ph, "freq") == -1)
|
hexchat_hook_command (ph, "UPDCHK", HEXCHAT_PRI_NORM, check_cmd, upd_help, NULL);
|
||||||
{
|
|
||||||
hexchat_pluginpref_set_int (ph, "freq", DEFAULT_FREQ);
|
|
||||||
}
|
|
||||||
|
|
||||||
hexchat_hook_command (ph, "UPDCHK", HEXCHAT_PRI_NORM, print_version, upd_help, NULL);
|
|
||||||
hexchat_hook_timer (ph, delay * 1000, delayed_check, NULL);
|
|
||||||
hexchat_command (ph, "MENU -ishare\\download.png ADD \"Help/Check for Updates\" \"UPDCHK\"");
|
hexchat_command (ph, "MENU -ishare\\download.png ADD \"Help/Check for Updates\" \"UPDCHK\"");
|
||||||
hexchat_printf (ph, "%s plugin loaded\n", name);
|
hexchat_printf (ph, "%s plugin loaded\n", name);
|
||||||
|
|
||||||
return 1; /* return 1 for success */
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
hexchat_plugin_deinit (void)
|
hexchat_plugin_deinit (void)
|
||||||
{
|
{
|
||||||
|
win_sparkle_cleanup ();
|
||||||
|
|
||||||
hexchat_command (ph, "MENU DEL \"Help/Check for updates\"");
|
hexchat_command (ph, "MENU DEL \"Help/Check for updates\"");
|
||||||
hexchat_printf (ph, "%s plugin unloaded\n", name);
|
hexchat_printf (ph, "%s plugin unloaded\n", name);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,80 +20,33 @@
|
||||||
<RootNamespace>upd</RootNamespace>
|
<RootNamespace>upd</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcupd</TargetName>
|
<TargetName>hcupd</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcupd</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;UPD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</PrecompiledHeader>
|
<AdditionalIncludeDirectories>..\..\src\common;$(WinSparklePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;UPD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>upd.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>upd.def</ModuleDefinitionFile>
|
||||||
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(DepLibs);WinSparkle.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(WinSparklePath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;UPD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;UPD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<AdditionalIncludeDirectories>..\..\src\common;$(WinSparklePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>upd.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>upd.def</ModuleDefinitionFile>
|
||||||
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(DepLibs);WinSparkle.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(WinSparklePath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -102,6 +56,4 @@
|
||||||
<ClCompile Include="upd.c" />
|
<ClCompile Include="upd.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</Project>
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include "hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
|
|
||||||
|
@ -21,163 +22,127 @@
|
||||||
|
|
||||||
static hexchat_plugin *ph; /* plugin handle */
|
static hexchat_plugin *ph; /* plugin handle */
|
||||||
|
|
||||||
BOOL winamp_found = FALSE;
|
|
||||||
|
|
||||||
int status = 0;
|
|
||||||
|
|
||||||
/* Slightly modified from X-Chat's log_escape_strcpy */
|
|
||||||
static char *
|
|
||||||
song_strcpy (char *dest, char *src)
|
|
||||||
{
|
|
||||||
while (*src)
|
|
||||||
{
|
|
||||||
*dest = *src;
|
|
||||||
dest++;
|
|
||||||
src++;
|
|
||||||
|
|
||||||
if (*src == '%')
|
|
||||||
{
|
|
||||||
dest[0] = '%';
|
|
||||||
dest++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dest[0] = 0;
|
|
||||||
return dest - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
winamp(char *word[], char *word_eol[], void *userdata)
|
winamp(char *word[], char *word_eol[], void *userdata)
|
||||||
{
|
{
|
||||||
|
HWND hwndWinamp = FindWindowW(L"Winamp v1.x",NULL);
|
||||||
|
|
||||||
char current_play[2048], *p;
|
if (hwndWinamp)
|
||||||
char p_esc[2048];
|
|
||||||
char cur_esc[2048];
|
|
||||||
char truc[2048];
|
|
||||||
HWND hwndWinamp = FindWindow("Winamp v1.x",NULL);
|
|
||||||
|
|
||||||
if (hwndWinamp)
|
|
||||||
{
|
{
|
||||||
{
|
if (!stricmp("PAUSE", word[2]))
|
||||||
if (!stricmp("PAUSE", word[2]))
|
{
|
||||||
|
if (SendMessage(hwndWinamp,WM_USER, 0, 104))
|
||||||
{
|
{
|
||||||
if (SendMessage(hwndWinamp,WM_USER, 0, 104))
|
SendMessage(hwndWinamp, WM_COMMAND, 40046, 0);
|
||||||
{
|
|
||||||
SendMessage(hwndWinamp, WM_COMMAND, 40046, 0);
|
|
||||||
|
|
||||||
if (SendMessage(hwndWinamp, WM_USER, 0, 104) == PLAYING)
|
if (SendMessage(hwndWinamp, WM_USER, 0, 104) == PLAYING)
|
||||||
hexchat_printf(ph, "Winamp: playing");
|
hexchat_printf(ph, "Winamp: playing");
|
||||||
else
|
else
|
||||||
hexchat_printf(ph, "Winamp: paused");
|
hexchat_printf(ph, "Winamp: paused");
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (!stricmp("STOP", word[2]))
|
|
||||||
{
|
|
||||||
SendMessage(hwndWinamp, WM_COMMAND, 40047, 0);
|
|
||||||
hexchat_printf(ph, "Winamp: stopped");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (!stricmp("PLAY", word[2]))
|
|
||||||
{
|
|
||||||
SendMessage(hwndWinamp, WM_COMMAND, 40045, 0);
|
|
||||||
hexchat_printf(ph, "Winamp: playing");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
|
|
||||||
if (!stricmp("NEXT", word[2]))
|
|
||||||
{
|
|
||||||
SendMessage(hwndWinamp, WM_COMMAND, 40048, 0);
|
|
||||||
hexchat_printf(ph, "Winamp: next playlist entry");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
|
|
||||||
if (!stricmp("PREV", word[2]))
|
|
||||||
{
|
|
||||||
SendMessage(hwndWinamp, WM_COMMAND, 40044, 0);
|
|
||||||
hexchat_printf(ph, "Winamp: previous playlist entry");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
|
|
||||||
if (!stricmp("START", word[2]))
|
|
||||||
{
|
|
||||||
SendMessage(hwndWinamp, WM_COMMAND, 40154, 0);
|
|
||||||
hexchat_printf(ph, "Winamp: playlist start");
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
if (!word_eol[2][0])
|
|
||||||
{
|
|
||||||
GetWindowText(hwndWinamp, current_play, sizeof(current_play));
|
|
||||||
|
|
||||||
if (strchr(current_play, '-'))
|
|
||||||
{
|
|
||||||
|
|
||||||
p = current_play + strlen(current_play) - 8;
|
|
||||||
while (p >= current_play)
|
|
||||||
{
|
|
||||||
if (!strnicmp(p, "- Winamp", 8)) break;
|
|
||||||
p--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p >= current_play) p--;
|
|
||||||
|
|
||||||
while (p >= current_play && *p == ' ') p--;
|
|
||||||
*++p=0;
|
|
||||||
|
|
||||||
|
|
||||||
p = strchr(current_play, '.') + 1;
|
|
||||||
|
|
||||||
song_strcpy(p_esc, p);
|
|
||||||
song_strcpy(cur_esc, current_play);
|
|
||||||
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
sprintf(truc, "me is now playing:%s", p_esc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(truc, "me is now playing:%s", cur_esc);
|
|
||||||
}
|
|
||||||
|
|
||||||
hexchat_commandf(ph, truc);
|
|
||||||
|
|
||||||
}
|
|
||||||
else hexchat_print(ph, "Winamp: Nothing being played.");
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
hexchat_printf(ph, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START]\n");
|
else if (!stricmp("STOP", word[2]))
|
||||||
}
|
{
|
||||||
|
SendMessage(hwndWinamp, WM_COMMAND, 40047, 0);
|
||||||
|
hexchat_printf(ph, "Winamp: stopped");
|
||||||
|
}
|
||||||
|
else if (!stricmp("PLAY", word[2]))
|
||||||
|
{
|
||||||
|
SendMessage(hwndWinamp, WM_COMMAND, 40045, 0);
|
||||||
|
hexchat_printf(ph, "Winamp: playing");
|
||||||
|
}
|
||||||
|
else if (!stricmp("NEXT", word[2]))
|
||||||
|
{
|
||||||
|
SendMessage(hwndWinamp, WM_COMMAND, 40048, 0);
|
||||||
|
hexchat_printf(ph, "Winamp: next playlist entry");
|
||||||
|
}
|
||||||
|
else if (!stricmp("PREV", word[2]))
|
||||||
|
{
|
||||||
|
SendMessage(hwndWinamp, WM_COMMAND, 40044, 0);
|
||||||
|
hexchat_printf(ph, "Winamp: previous playlist entry");
|
||||||
|
}
|
||||||
|
else if (!stricmp("START", word[2]))
|
||||||
|
{
|
||||||
|
SendMessage(hwndWinamp, WM_COMMAND, 40154, 0);
|
||||||
|
hexchat_printf(ph, "Winamp: playlist start");
|
||||||
|
}
|
||||||
|
else if (!word_eol[2][0])
|
||||||
|
{
|
||||||
|
wchar_t wcurrent_play[2048];
|
||||||
|
char *current_play, *p;
|
||||||
|
int len = GetWindowTextW(hwndWinamp, wcurrent_play, G_N_ELEMENTS(wcurrent_play));
|
||||||
|
|
||||||
|
current_play = g_utf16_to_utf8 (wcurrent_play, len, NULL, NULL, NULL);
|
||||||
|
if (!current_play)
|
||||||
|
{
|
||||||
|
hexchat_print (ph, "Winamp: Error getting song information.");
|
||||||
|
return HEXCHAT_EAT_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strchr(current_play, '-'))
|
||||||
|
{
|
||||||
|
/* Remove any trailing text and whitespace */
|
||||||
|
p = current_play + strlen(current_play) - 8;
|
||||||
|
while (p >= current_play)
|
||||||
|
{
|
||||||
|
if (!strnicmp(p, "- Winamp", 8))
|
||||||
|
break;
|
||||||
|
p--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p >= current_play)
|
||||||
|
p--;
|
||||||
|
|
||||||
|
while (p >= current_play && *p == ' ')
|
||||||
|
p--;
|
||||||
|
*++p = '\0';
|
||||||
|
|
||||||
|
/* Ignore any leading track number */
|
||||||
|
p = strstr (current_play, ". ");
|
||||||
|
if (p)
|
||||||
|
p += 2;
|
||||||
|
else
|
||||||
|
p = current_play;
|
||||||
|
|
||||||
|
if (*p != '\0')
|
||||||
|
hexchat_commandf (ph, "me is now playing: %s", p);
|
||||||
|
else
|
||||||
|
hexchat_print (ph, "Winamp: No song information found.");
|
||||||
|
g_free (current_play);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hexchat_print(ph, "Winamp: Nothing being played.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hexchat_printf(ph, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START]\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hexchat_print(ph, "Winamp not found.\n");
|
hexchat_print(ph, "Winamp not found.\n");
|
||||||
}
|
}
|
||||||
return HEXCHAT_EAT_ALL;
|
return HEXCHAT_EAT_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
hexchat_plugin_init(hexchat_plugin *plugin_handle,
|
hexchat_plugin_init(hexchat_plugin *plugin_handle,
|
||||||
char **plugin_name,
|
char **plugin_name,
|
||||||
char **plugin_desc,
|
char **plugin_desc,
|
||||||
char **plugin_version,
|
char **plugin_version,
|
||||||
char *arg)
|
char *arg)
|
||||||
{
|
{
|
||||||
/* we need to save this for use with any hexchat_* functions */
|
/* we need to save this for use with any hexchat_* functions */
|
||||||
ph = plugin_handle;
|
ph = plugin_handle;
|
||||||
|
|
||||||
*plugin_name = "Winamp";
|
*plugin_name = "Winamp";
|
||||||
*plugin_desc = "Winamp plugin for HexChat";
|
*plugin_desc = "Winamp plugin for HexChat";
|
||||||
*plugin_version = "0.5";
|
*plugin_version = "0.6";
|
||||||
|
|
||||||
hexchat_hook_command (ph, "WINAMP", HEXCHAT_PRI_NORM, winamp, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START] - control Winamp or show what's currently playing", 0);
|
hexchat_hook_command (ph, "WINAMP", HEXCHAT_PRI_NORM, winamp, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START] - control Winamp or show what's currently playing", 0);
|
||||||
hexchat_command (ph, "MENU -ishare\\music.png ADD \"Window/Display Current Song (Winamp)\" \"WINAMP\"");
|
hexchat_command (ph, "MENU -ishare\\music.png ADD \"Window/Display Current Song (Winamp)\" \"WINAMP\"");
|
||||||
|
|
||||||
hexchat_print (ph, "Winamp plugin loaded\n");
|
hexchat_print (ph, "Winamp plugin loaded\n");
|
||||||
|
|
||||||
return 1; /* return 1 for success */
|
return 1; /* return 1 for success */
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -19,76 +20,31 @@
|
||||||
<RootNamespace>winamp</RootNamespace>
|
<RootNamespace>winamp</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcwinamp</TargetName>
|
<TargetName>hcwinamp</TargetName>
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
<OutDir>$(HexChatRel)plugins\</OutDir>
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<TargetName>hcwinamp</TargetName>
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINAMP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINAMP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>winamp.def</ModuleDefinitionFile>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;WINAMP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;WINAMP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
</ClCompile>
|
||||||
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>winamp.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>winamp.def</ModuleDefinitionFile>
|
||||||
|
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -98,6 +54,4 @@
|
||||||
<ClCompile Include="winamp.c" />
|
<ClCompile Include="winamp.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
</Project>
|
|
@ -10,6 +10,8 @@ src/common/inbound.c
|
||||||
src/common/notify.c
|
src/common/notify.c
|
||||||
src/common/outbound.c
|
src/common/outbound.c
|
||||||
src/common/plugin.c
|
src/common/plugin.c
|
||||||
|
src/common/plugin-identd.c
|
||||||
|
src/common/plugin-timer.c
|
||||||
src/common/server.c
|
src/common/server.c
|
||||||
src/common/servlist.c
|
src/common/servlist.c
|
||||||
src/common/textevents.h
|
src/common/textevents.h
|
||||||
|
@ -30,6 +32,7 @@ src/fe-gtk/joind.c
|
||||||
src/fe-gtk/maingui.c
|
src/fe-gtk/maingui.c
|
||||||
src/fe-gtk/menu.c
|
src/fe-gtk/menu.c
|
||||||
src/fe-gtk/notifygui.c
|
src/fe-gtk/notifygui.c
|
||||||
|
src/fe-gtk/plugin-notification.c
|
||||||
src/fe-gtk/plugin-tray.c
|
src/fe-gtk/plugin-tray.c
|
||||||
src/fe-gtk/plugingui.c
|
src/fe-gtk/plugingui.c
|
||||||
src/fe-gtk/rawlog.c
|
src/fe-gtk/rawlog.c
|
||||||
|
@ -40,3 +43,4 @@ src/fe-gtk/textgui.c
|
||||||
src/fe-gtk/urlgrab.c
|
src/fe-gtk/urlgrab.c
|
||||||
src/fe-gtk/userlistgui.c
|
src/fe-gtk/userlistgui.c
|
||||||
src/fe-text/fe-text.c
|
src/fe-text/fe-text.c
|
||||||
|
plugins/sysinfo/sysinfo.c
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# HexChat [![Build Status](https://travis-ci.org/hexchat/hexchat.png)](https://travis-ci.org/hexchat/hexchat) [![Build Status](http://nekomimi.cloudapp.net:8080/job/hexchat/badge/icon)](http://nekomimi.cloudapp.net:8080/job/hexchat/) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/hexchat/hexchat/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
# HexChat [![Build Status](http://img.shields.io/travis/hexchat/hexchat.svg?style=flat)](https://travis-ci.org/hexchat/hexchat) [![Build Status](http://img.shields.io/jenkins/s/http/nekomimi.cloudapp.net:8080/hexchat.svg?style=flat)](http://nekomimi.cloudapp.net:8080/job/hexchat/)
|
||||||
|
|
||||||
HexChat is an IRC client for Windows and UNIX-like operating systems.
|
HexChat is an IRC client for Windows and UNIX-like operating systems.
|
||||||
See [IRCHelp.org](http://irchelp.org) for information about IRC in general.
|
See [IRCHelp.org](http://irchelp.org) for information about IRC in general.
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
include $(top_srcdir)/m4/clang-analyze.am
|
||||||
|
|
||||||
noinst_LIBRARIES = libhexchatcommon.a
|
noinst_LIBRARIES = libhexchatcommon.a
|
||||||
|
|
||||||
AM_CPPFLAGS = $(COMMON_CFLAGS)
|
AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(top_srcdir)
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
cfgfiles.h \
|
cfgfiles.h \
|
||||||
|
@ -14,17 +16,16 @@ EXTRA_DIST = \
|
||||||
hexchatc.h \
|
hexchatc.h \
|
||||||
hexchat-plugin.h \
|
hexchat-plugin.h \
|
||||||
history.h \
|
history.h \
|
||||||
identd.c \
|
|
||||||
ignore.h \
|
ignore.h \
|
||||||
inbound.h \
|
inbound.h \
|
||||||
inet.h \
|
inet.h \
|
||||||
make-te.c \
|
make-te.c \
|
||||||
modes.h \
|
modes.h \
|
||||||
msproxy.h \
|
|
||||||
network.h \
|
network.h \
|
||||||
notify.h \
|
notify.h \
|
||||||
outbound.h \
|
outbound.h \
|
||||||
plugin.h \
|
plugin.h \
|
||||||
|
plugin-identd.h \
|
||||||
plugin-timer.h \
|
plugin-timer.h \
|
||||||
proto-irc.h \
|
proto-irc.h \
|
||||||
server.h \
|
server.h \
|
||||||
|
@ -32,6 +33,7 @@ EXTRA_DIST = \
|
||||||
ssl.h \
|
ssl.h \
|
||||||
ssl.c \
|
ssl.c \
|
||||||
text.h \
|
text.h \
|
||||||
|
typedef.h \
|
||||||
textenums.h \
|
textenums.h \
|
||||||
textevents.h \
|
textevents.h \
|
||||||
textevents.in \
|
textevents.in \
|
||||||
|
@ -44,10 +46,6 @@ if USE_OPENSSL
|
||||||
ssl_c = ssl.c
|
ssl_c = ssl.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if USE_MSPROXY
|
|
||||||
msproxy_c = msproxy.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
if USE_DBUS
|
if USE_DBUS
|
||||||
dbusdir = dbus
|
dbusdir = dbus
|
||||||
libhexchatcommon_a_LIBADD = \
|
libhexchatcommon_a_LIBADD = \
|
||||||
|
@ -62,23 +60,29 @@ endif
|
||||||
noinst_PROGRAMS = make-te
|
noinst_PROGRAMS = make-te
|
||||||
|
|
||||||
libhexchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c hexchat.c \
|
libhexchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c hexchat.c \
|
||||||
history.c ignore.c inbound.c marshal.c modes.c $(msproxy_c) network.c notify.c \
|
history.c ignore.c inbound.c marshal.c modes.c network.c notify.c \
|
||||||
outbound.c plugin.c plugin-timer.c proto-irc.c server.c servlist.c \
|
outbound.c plugin.c plugin-identd.c plugin-timer.c proto-irc.c server.c servlist.c \
|
||||||
$(ssl_c) text.c tree.c url.c userlist.c util.c
|
$(ssl_c) text.c tree.c url.c userlist.c util.c
|
||||||
libhexchatcommon_a_CFLAGS = $(LIBPROXY_CFLAGS)
|
libhexchatcommon_a_CFLAGS = $(LIBPROXY_CFLAGS)
|
||||||
|
|
||||||
textenums.h: textevents.h
|
textenums.h: textevents.h
|
||||||
|
|
||||||
textevents.h: textevents.in make-te
|
textevents.h: $(srcdir)/textevents.in make-te
|
||||||
$(AM_V_GEN) ./make-te < textevents.in > textevents.h 2> textenums.h
|
$(AM_V_GEN) ./make-te < $< > $@ 2> textenums.h
|
||||||
|
|
||||||
marshal.h: marshalers.list
|
marshal.h: $(srcdir)/marshalers.list
|
||||||
$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_hexchat_marshal --header $(srcdir)/marshalers.list > $@
|
$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_hexchat_marshal --header $< > $@
|
||||||
|
|
||||||
marshal.c: marshalers.list
|
marshal.c: $(srcdir)/marshalers.list
|
||||||
$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_hexchat_marshal --body $(srcdir)/marshalers.list > $@
|
$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_hexchat_marshal --body $< > $@
|
||||||
|
|
||||||
|
|
||||||
|
if DO_STATIC_ANALYSIS
|
||||||
|
analyze_plists = $(libhexchatcommon_a_SOURCES:%.c=%.plist)
|
||||||
|
all-local: $(analyze_plists)
|
||||||
|
MOSTLYCLEANFILES = $(analyze_plists)
|
||||||
|
endif
|
||||||
|
|
||||||
BUILT_SOURCES = textenums.h textevents.h marshal.c marshal.h
|
BUILT_SOURCES = textenums.h textevents.h marshal.c marshal.h
|
||||||
|
|
||||||
CLEANFILES = $(BUILT_SOURCES)
|
CLEANFILES = $(BUILT_SOURCES)
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEF_FONT "Monospace 9"
|
#define DEF_FONT "Monospace 9"
|
||||||
#define DEF_FONT_ALTER "Arial Unicode MS,Lucida Sans Unicode,MS Gothic,Unifont"
|
#define DEF_FONT_ALTER "Arial Unicode MS,Segoe UI Emoji,Lucida Sans Unicode,Meiryo,Symbola,Unifont"
|
||||||
|
|
||||||
const char * const languages[LANGUAGES_LENGTH] = {
|
const char * const languages[LANGUAGES_LENGTH] = {
|
||||||
"af", "sq", "am", "ast", "az", "eu", "be", "bg", "ca", "zh_CN", /* 0 .. 9 */
|
"af", "sq", "am", "ast", "az", "eu", "be", "bg", "ca", "zh_CN", /* 0 .. 9 */
|
||||||
|
@ -57,15 +57,11 @@ list_addentry (GSList ** list, char *cmd, char *name)
|
||||||
size_t name_len;
|
size_t name_len;
|
||||||
size_t cmd_len = 1;
|
size_t cmd_len = 1;
|
||||||
|
|
||||||
/* remove <2.8.0 stuff */
|
|
||||||
if (!strcmp (cmd, "away") && !strcmp (name, "BACK"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (cmd)
|
if (cmd)
|
||||||
cmd_len = strlen (cmd) + 1;
|
cmd_len = strlen (cmd) + 1;
|
||||||
name_len = strlen (name) + 1;
|
name_len = strlen (name) + 1;
|
||||||
|
|
||||||
pop = malloc (sizeof (struct popup) + cmd_len + name_len);
|
pop = g_malloc (sizeof (struct popup) + cmd_len + name_len);
|
||||||
pop->name = (char *) pop + sizeof (struct popup);
|
pop->name = (char *) pop + sizeof (struct popup);
|
||||||
pop->cmd = pop->name + name_len;
|
pop->cmd = pop->name + name_len;
|
||||||
|
|
||||||
|
@ -137,13 +133,13 @@ list_loadconf (char *file, GSList ** list, char *defaultconf)
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
|
|
||||||
ibuf = malloc (st.st_size);
|
ibuf = g_malloc (st.st_size);
|
||||||
read (fd, ibuf, st.st_size);
|
read (fd, ibuf, st.st_size);
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
list_load_from_data (list, ibuf, st.st_size);
|
list_load_from_data (list, ibuf, st.st_size);
|
||||||
|
|
||||||
free (ibuf);
|
g_free (ibuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -153,7 +149,7 @@ list_free (GSList ** list)
|
||||||
while (*list)
|
while (*list)
|
||||||
{
|
{
|
||||||
data = (void *) (*list)->data;
|
data = (void *) (*list)->data;
|
||||||
free (data);
|
g_free (data);
|
||||||
*list = g_slist_remove (*list, data);
|
*list = g_slist_remove (*list, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +166,7 @@ list_delentry (GSList ** list, char *name)
|
||||||
if (!g_ascii_strcasecmp (name, pop->name))
|
if (!g_ascii_strcasecmp (name, pop->name))
|
||||||
{
|
{
|
||||||
*list = g_slist_remove (*list, pop);
|
*list = g_slist_remove (*list, pop);
|
||||||
free (pop);
|
g_free (pop);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
alist = alist->next;
|
alist = alist->next;
|
||||||
|
@ -211,10 +207,10 @@ cfg_get_str (char *cfg, const char *var, char *dest, int dest_len)
|
||||||
while (*cfg != 0 && *cfg != '\n')
|
while (*cfg != 0 && *cfg != '\n')
|
||||||
cfg++;
|
cfg++;
|
||||||
if (*cfg == 0)
|
if (*cfg == 0)
|
||||||
return 0;
|
return NULL;
|
||||||
cfg++;
|
cfg++;
|
||||||
if (*cfg == 0)
|
if (*cfg == 0)
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,18 +220,18 @@ cfg_put_str (int fh, char *var, char *value)
|
||||||
char buf[512];
|
char buf[512];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
snprintf (buf, sizeof buf, "%s = %s\n", var, value);
|
g_snprintf (buf, sizeof buf, "%s = %s\n", var, value);
|
||||||
len = strlen (buf);
|
len = strlen (buf);
|
||||||
return (write (fh, buf, len) == len);
|
return (write (fh, buf, len) == len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cfg_put_color (int fh, int r, int g, int b, char *var)
|
cfg_put_color (int fh, guint16 r, guint16 g, guint16 b, char *var)
|
||||||
{
|
{
|
||||||
char buf[400];
|
char buf[400];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
snprintf (buf, sizeof buf, "%s = %04x %04x %04x\n", var, r, g, b);
|
g_snprintf (buf, sizeof buf, "%s = %04hx %04hx %04hx\n", var, r, g, b);
|
||||||
len = strlen (buf);
|
len = strlen (buf);
|
||||||
return (write (fh, buf, len) == len);
|
return (write (fh, buf, len) == len);
|
||||||
}
|
}
|
||||||
|
@ -249,20 +245,20 @@ cfg_put_int (int fh, int value, char *var)
|
||||||
if (value == -1)
|
if (value == -1)
|
||||||
value = 1;
|
value = 1;
|
||||||
|
|
||||||
snprintf (buf, sizeof buf, "%s = %d\n", var, value);
|
g_snprintf (buf, sizeof buf, "%s = %d\n", var, value);
|
||||||
len = strlen (buf);
|
len = strlen (buf);
|
||||||
return (write (fh, buf, len) == len);
|
return (write (fh, buf, len) == len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cfg_get_color (char *cfg, char *var, int *r, int *g, int *b)
|
cfg_get_color (char *cfg, char *var, guint16 *r, guint16 *g, guint16 *b)
|
||||||
{
|
{
|
||||||
char str[128];
|
char str[128];
|
||||||
|
|
||||||
if (!cfg_get_str (cfg, var, str, sizeof (str)))
|
if (!cfg_get_str (cfg, var, str, sizeof (str)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sscanf (str, "%04x %04x %04x", r, g, b);
|
sscanf (str, "%04hx %04hx %04hx", r, g, b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,14 +308,9 @@ get_xdir (void)
|
||||||
|
|
||||||
if (portable_mode () || SHGetKnownFolderPath (&FOLDERID_RoamingAppData, 0, NULL, &roaming_path_wide) != S_OK)
|
if (portable_mode () || SHGetKnownFolderPath (&FOLDERID_RoamingAppData, 0, NULL, &roaming_path_wide) != S_OK)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path = g_win32_get_package_installation_directory_of_module (NULL);
|
||||||
char file[MAX_PATH];
|
if (path)
|
||||||
HMODULE hModule;
|
|
||||||
|
|
||||||
hModule = GetModuleHandle (NULL);
|
|
||||||
if (GetModuleFileName (hModule, file, sizeof(file)))
|
|
||||||
{
|
{
|
||||||
path = g_path_get_dirname (file);
|
|
||||||
xdir = g_build_filename (path, "config", NULL);
|
xdir = g_build_filename (path, "config", NULL);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
@ -443,6 +434,7 @@ const struct prefs vars[] =
|
||||||
{"gui_tab_dots", P_OFFINT (hex_gui_tab_dots), TYPE_BOOL},
|
{"gui_tab_dots", P_OFFINT (hex_gui_tab_dots), TYPE_BOOL},
|
||||||
{"gui_tab_icons", P_OFFINT (hex_gui_tab_icons), TYPE_BOOL},
|
{"gui_tab_icons", P_OFFINT (hex_gui_tab_icons), TYPE_BOOL},
|
||||||
{"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT},
|
{"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT},
|
||||||
|
{"gui_tab_middleclose", P_OFFINT (hex_gui_tab_middleclose), TYPE_BOOL},
|
||||||
{"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT},
|
{"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT},
|
||||||
{"gui_tab_pos", P_OFFINT (hex_gui_tab_pos), TYPE_INT},
|
{"gui_tab_pos", P_OFFINT (hex_gui_tab_pos), TYPE_INT},
|
||||||
{"gui_tab_scrollchans", P_OFFINT (hex_gui_tab_scrollchans), TYPE_BOOL},
|
{"gui_tab_scrollchans", P_OFFINT (hex_gui_tab_scrollchans), TYPE_BOOL},
|
||||||
|
@ -485,11 +477,11 @@ const struct prefs vars[] =
|
||||||
{"gui_win_width", P_OFFINT (hex_gui_win_width), TYPE_INT},
|
{"gui_win_width", P_OFFINT (hex_gui_win_width), TYPE_INT},
|
||||||
|
|
||||||
{"identd", P_OFFINT (hex_identd), TYPE_BOOL},
|
{"identd", P_OFFINT (hex_identd), TYPE_BOOL},
|
||||||
|
{"identd_port", P_OFFINT (hex_identd_port), TYPE_INT},
|
||||||
|
|
||||||
{"input_balloon_chans", P_OFFINT (hex_input_balloon_chans), TYPE_BOOL},
|
{"input_balloon_chans", P_OFFINT (hex_input_balloon_chans), TYPE_BOOL},
|
||||||
{"input_balloon_hilight", P_OFFINT (hex_input_balloon_hilight), TYPE_BOOL},
|
{"input_balloon_hilight", P_OFFINT (hex_input_balloon_hilight), TYPE_BOOL},
|
||||||
{"input_balloon_priv", P_OFFINT (hex_input_balloon_priv), TYPE_BOOL},
|
{"input_balloon_priv", P_OFFINT (hex_input_balloon_priv), TYPE_BOOL},
|
||||||
{"input_balloon_time", P_OFFINT (hex_input_balloon_time), TYPE_INT},
|
|
||||||
{"input_beep_chans", P_OFFINT (hex_input_beep_chans), TYPE_BOOL},
|
{"input_beep_chans", P_OFFINT (hex_input_beep_chans), TYPE_BOOL},
|
||||||
{"input_beep_hilight", P_OFFINT (hex_input_beep_hilight), TYPE_BOOL},
|
{"input_beep_hilight", P_OFFINT (hex_input_beep_hilight), TYPE_BOOL},
|
||||||
{"input_beep_priv", P_OFFINT (hex_input_beep_priv), TYPE_BOOL},
|
{"input_beep_priv", P_OFFINT (hex_input_beep_priv), TYPE_BOOL},
|
||||||
|
@ -593,10 +585,10 @@ const struct prefs vars[] =
|
||||||
{0, 0, 0},
|
{0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
convert_with_fallback (const char *str, const char *fallback)
|
convert_with_fallback (const char *str, const char *fallback)
|
||||||
{
|
{
|
||||||
char *utf;
|
const char *utf;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
/* On non-Windows, g_get_user_name and g_get_real_name return a string in system locale, so convert it to utf-8. */
|
/* On non-Windows, g_get_user_name and g_get_real_name return a string in system locale, so convert it to utf-8. */
|
||||||
|
@ -655,7 +647,7 @@ get_default_language (void)
|
||||||
|
|
||||||
if (lang_no >= 0)
|
if (lang_no >= 0)
|
||||||
{
|
{
|
||||||
free (lang);
|
g_free (lang);
|
||||||
return lang_no;
|
return lang_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,7 +656,7 @@ get_default_language (void)
|
||||||
|
|
||||||
lang_no = find_language_number (lang);
|
lang_no = find_language_number (lang);
|
||||||
|
|
||||||
free (lang);
|
g_free (lang);
|
||||||
|
|
||||||
return lang_no >= 0 ? lang_no : find_language_number ("en");
|
return lang_no >= 0 ? lang_no : find_language_number ("en");
|
||||||
}
|
}
|
||||||
|
@ -706,8 +698,8 @@ get_default_spell_languages (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (last != NULL)
|
|
||||||
g_free(last);
|
g_free (last);
|
||||||
|
|
||||||
if (lang_list[0])
|
if (lang_list[0])
|
||||||
return g_strdup (ret);
|
return g_strdup (ret);
|
||||||
|
@ -768,6 +760,7 @@ load_default_config(void)
|
||||||
prefs.hex_gui_tab_chans = 1;
|
prefs.hex_gui_tab_chans = 1;
|
||||||
prefs.hex_gui_tab_dialogs = 1;
|
prefs.hex_gui_tab_dialogs = 1;
|
||||||
prefs.hex_gui_tab_icons = 1;
|
prefs.hex_gui_tab_icons = 1;
|
||||||
|
prefs.hex_gui_tab_middleclose = 1;
|
||||||
prefs.hex_gui_tab_server = 1;
|
prefs.hex_gui_tab_server = 1;
|
||||||
prefs.hex_gui_tab_sort = 1;
|
prefs.hex_gui_tab_sort = 1;
|
||||||
prefs.hex_gui_topicbar = 1;
|
prefs.hex_gui_topicbar = 1;
|
||||||
|
@ -779,12 +772,12 @@ load_default_config(void)
|
||||||
prefs.hex_gui_ulist_resizable = 1;
|
prefs.hex_gui_ulist_resizable = 1;
|
||||||
prefs.hex_gui_ulist_style = 1;
|
prefs.hex_gui_ulist_style = 1;
|
||||||
prefs.hex_gui_win_save = 1;
|
prefs.hex_gui_win_save = 1;
|
||||||
prefs.hex_identd = 1;
|
|
||||||
prefs.hex_input_flash_hilight = 1;
|
prefs.hex_input_flash_hilight = 1;
|
||||||
prefs.hex_input_flash_priv = 1;
|
prefs.hex_input_flash_priv = 1;
|
||||||
prefs.hex_input_tray_hilight = 1;
|
prefs.hex_input_tray_hilight = 1;
|
||||||
prefs.hex_input_tray_priv = 1;
|
prefs.hex_input_tray_priv = 1;
|
||||||
prefs.hex_irc_cap_server_time = 1;
|
prefs.hex_irc_cap_server_time = 1;
|
||||||
|
prefs.hex_irc_logging = 1;
|
||||||
prefs.hex_irc_who_join = 1; /* Can kick with inordinate amount of channels, required for some of our features though, TODO: add cap like away check? */
|
prefs.hex_irc_who_join = 1; /* Can kick with inordinate amount of channels, required for some of our features though, TODO: add cap like away check? */
|
||||||
prefs.hex_irc_whois_front = 1;
|
prefs.hex_irc_whois_front = 1;
|
||||||
prefs.hex_net_auto_reconnect = 1;
|
prefs.hex_net_auto_reconnect = 1;
|
||||||
|
@ -834,7 +827,6 @@ load_default_config(void)
|
||||||
prefs.hex_gui_ulist_pos = 3;
|
prefs.hex_gui_ulist_pos = 3;
|
||||||
prefs.hex_gui_win_height = 400;
|
prefs.hex_gui_win_height = 400;
|
||||||
prefs.hex_gui_win_width = 640;
|
prefs.hex_gui_win_width = 640;
|
||||||
prefs.hex_input_balloon_time = 20;
|
|
||||||
prefs.hex_irc_ban_type = 1;
|
prefs.hex_irc_ban_type = 1;
|
||||||
prefs.hex_irc_join_delay = 5;
|
prefs.hex_irc_join_delay = 5;
|
||||||
prefs.hex_net_reconnect_delay = 10;
|
prefs.hex_net_reconnect_delay = 10;
|
||||||
|
@ -849,7 +841,7 @@ load_default_config(void)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (portable_mode () || SHGetKnownFolderPath (&FOLDERID_Downloads, 0, NULL, &roaming_path_wide) != S_OK)
|
if (portable_mode () || SHGetKnownFolderPath (&FOLDERID_Downloads, 0, NULL, &roaming_path_wide) != S_OK)
|
||||||
{
|
{
|
||||||
snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\downloads", get_xdir ());
|
g_snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\downloads", get_xdir ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -863,34 +855,36 @@ load_default_config(void)
|
||||||
#else
|
#else
|
||||||
if (g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD))
|
if (g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD))
|
||||||
{
|
{
|
||||||
strcpy (prefs.hex_dcc_dir, g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD));
|
safe_strcpy (prefs.hex_dcc_dir, g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD), sizeof(prefs.hex_dcc_dir));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy (prefs.hex_dcc_dir, g_build_filename (g_get_home_dir (), "Downloads", NULL));
|
char *download_dir = g_build_filename (g_get_home_dir (), "Downloads", NULL);
|
||||||
|
safe_strcpy (prefs.hex_dcc_dir, download_dir, sizeof(prefs.hex_dcc_dir));
|
||||||
|
g_free (download_dir);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
strcpy (prefs.hex_gui_ulist_doubleclick, "QUERY %s");
|
strcpy (prefs.hex_gui_ulist_doubleclick, "QUERY %s");
|
||||||
strcpy (prefs.hex_input_command_char, "/");
|
strcpy (prefs.hex_input_command_char, "/");
|
||||||
strcpy (prefs.hex_irc_logmask, g_build_filename ("%n", "%c.log", NULL));
|
strcpy (prefs.hex_irc_logmask, "%n"G_DIR_SEPARATOR_S"%c.log");
|
||||||
strcpy (prefs.hex_irc_nick1, username);
|
safe_strcpy (prefs.hex_irc_nick1, username, sizeof(prefs.hex_irc_nick1));
|
||||||
strcpy (prefs.hex_irc_nick2, username);
|
safe_strcpy (prefs.hex_irc_nick2, username, sizeof(prefs.hex_irc_nick2));
|
||||||
strcat (prefs.hex_irc_nick2, "_");
|
g_strlcat (prefs.hex_irc_nick2, "_", sizeof(prefs.hex_irc_nick2));
|
||||||
strcpy (prefs.hex_irc_nick3, username);
|
safe_strcpy (prefs.hex_irc_nick3, username, sizeof(prefs.hex_irc_nick3));
|
||||||
strcat (prefs.hex_irc_nick3, "__");
|
g_strlcat (prefs.hex_irc_nick3, "__", sizeof(prefs.hex_irc_nick3));
|
||||||
strcpy (prefs.hex_irc_no_hilight, "NickServ,ChanServ,InfoServ,N,Q");
|
strcpy (prefs.hex_irc_no_hilight, "NickServ,ChanServ,InfoServ,N,Q");
|
||||||
strcpy (prefs.hex_irc_part_reason, _("Leaving"));
|
safe_strcpy (prefs.hex_irc_part_reason, _("Leaving"), sizeof(prefs.hex_irc_part_reason));
|
||||||
strcpy (prefs.hex_irc_quit_reason, prefs.hex_irc_part_reason);
|
safe_strcpy (prefs.hex_irc_quit_reason, prefs.hex_irc_part_reason, sizeof(prefs.hex_irc_quit_reason));
|
||||||
strcpy (prefs.hex_irc_real_name, realname);
|
safe_strcpy (prefs.hex_irc_real_name, realname, sizeof(prefs.hex_irc_real_name));
|
||||||
strcpy (prefs.hex_irc_user_name, username);
|
safe_strcpy (prefs.hex_irc_user_name, username, sizeof(prefs.hex_irc_user_name));
|
||||||
strcpy (prefs.hex_stamp_log_format, "%b %d %H:%M:%S ");
|
strcpy (prefs.hex_stamp_log_format, "%b %d %H:%M:%S ");
|
||||||
strcpy (prefs.hex_stamp_text_format, "[%H:%M:%S] ");
|
strcpy (prefs.hex_stamp_text_format, "[%H:%M:%S] ");
|
||||||
|
|
||||||
font = fe_get_default_font ();
|
font = fe_get_default_font ();
|
||||||
if (font)
|
if (font)
|
||||||
{
|
{
|
||||||
strcpy (prefs.hex_text_font, font);
|
safe_strcpy (prefs.hex_text_font, font, sizeof(prefs.hex_text_font));
|
||||||
strcpy (prefs.hex_text_font_main, font);
|
safe_strcpy (prefs.hex_text_font_main, font, sizeof(prefs.hex_text_font_main));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -900,7 +894,7 @@ load_default_config(void)
|
||||||
|
|
||||||
strcpy (prefs.hex_text_font_alternative, DEF_FONT_ALTER);
|
strcpy (prefs.hex_text_font_alternative, DEF_FONT_ALTER);
|
||||||
langs = get_default_spell_languages ();
|
langs = get_default_spell_languages ();
|
||||||
strcpy (prefs.hex_text_spell_langs, langs);
|
safe_strcpy (prefs.hex_text_spell_langs, langs, sizeof(prefs.hex_text_spell_langs));
|
||||||
|
|
||||||
|
|
||||||
/* private variables */
|
/* private variables */
|
||||||
|
@ -1230,7 +1224,7 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
if (erase || *val)
|
if (erase || *val)
|
||||||
{
|
{
|
||||||
/* save the previous value until we print it out */
|
/* save the previous value until we print it out */
|
||||||
prev_string = (char*) malloc (vars[i].len + 1);
|
prev_string = g_malloc (vars[i].len + 1);
|
||||||
strncpy (prev_string, (char *) &prefs + vars[i].offset, vars[i].len);
|
strncpy (prev_string, (char *) &prefs + vars[i].offset, vars[i].len);
|
||||||
|
|
||||||
/* update the variable */
|
/* update the variable */
|
||||||
|
@ -1242,7 +1236,7 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
PrintTextf (sess, "%s set to: %s (was: %s)\n", var, (char *) &prefs + vars[i].offset, prev_string);
|
PrintTextf (sess, "%s set to: %s (was: %s)\n", var, (char *) &prefs + vars[i].offset, prev_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
free (prev_string);
|
g_free (prev_string);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1317,7 +1311,7 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
hexchat_open_file (char *file, int flags, int mode, int xof_flags)
|
hexchat_open_file (const char *file, int flags, int mode, int xof_flags)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -1353,7 +1347,7 @@ hexchat_fopen_file (const char *file, const char *mode, int xof_flags)
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
|
|
||||||
if (xof_flags & XOF_FULLPATH)
|
if (xof_flags & XOF_FULLPATH)
|
||||||
return fopen (file, mode);
|
return g_fopen (file, mode);
|
||||||
|
|
||||||
buf = g_build_filename (get_xdir (), file, NULL);
|
buf = g_build_filename (get_xdir (), file, NULL);
|
||||||
fh = g_fopen (buf, mode);
|
fh = g_fopen (buf, mode);
|
||||||
|
|
|
@ -34,8 +34,8 @@ int cfg_get_bool (char *var);
|
||||||
int cfg_get_int_with_result (char *cfg, char *var, int *result);
|
int cfg_get_int_with_result (char *cfg, char *var, int *result);
|
||||||
int cfg_get_int (char *cfg, char *var);
|
int cfg_get_int (char *cfg, char *var);
|
||||||
int cfg_put_int (int fh, int value, char *var);
|
int cfg_put_int (int fh, int value, char *var);
|
||||||
int cfg_get_color (char *cfg, char *var, int *r, int *g, int *b);
|
int cfg_get_color (char *cfg, char *var, guint16 *r, guint16 *g, guint16 *b);
|
||||||
int cfg_put_color (int fh, int r, int g, int b, char *var);
|
int cfg_put_color (int fh, guint16 r, guint16 g, guint16 b, char *var);
|
||||||
char *get_xdir (void);
|
char *get_xdir (void);
|
||||||
int check_config_dir (void);
|
int check_config_dir (void);
|
||||||
void load_default_config (void);
|
void load_default_config (void);
|
||||||
|
@ -48,7 +48,7 @@ void list_loadconf (char *file, GSList ** list, char *defaultconf);
|
||||||
int list_delentry (GSList ** list, char *name);
|
int list_delentry (GSList ** list, char *name);
|
||||||
void list_addentry (GSList ** list, char *cmd, char *name);
|
void list_addentry (GSList ** list, char *cmd, char *name);
|
||||||
int cmd_set (session *sess, char *tbuf, char *word[], char *word_eol[]);
|
int cmd_set (session *sess, char *tbuf, char *word[], char *word_eol[]);
|
||||||
int hexchat_open_file (char *file, int flags, int mode, int xof_flags);
|
int hexchat_open_file (const char *file, int flags, int mode, int xof_flags);
|
||||||
FILE *hexchat_fopen_file (const char *file, const char *mode, int xof_flags);
|
FILE *hexchat_fopen_file (const char *file, const char *mode, int xof_flags);
|
||||||
|
|
||||||
#define XOF_DOMODE 1
|
#define XOF_DOMODE 1
|
||||||
|
|
|
@ -119,7 +119,7 @@ chanopt_command (session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
PrintTextf (sess, "\002Network\002: %s \002Channel\002: %s\n",
|
PrintTextf (sess, "\002Network\002: %s \002Channel\002: %s\n",
|
||||||
sess->server->network ? server_get_network (sess->server, TRUE) : _("<none>"),
|
sess->server->network ? server_get_network (sess->server, TRUE) : _("<none>"),
|
||||||
sess->channel[0] ? sess->channel : _("<none>"));
|
sess->session_name[0] ? sess->session_name : _("<none>"));
|
||||||
|
|
||||||
while (i < sizeof (chanopt) / sizeof (channel_options))
|
while (i < sizeof (chanopt) / sizeof (channel_options))
|
||||||
{
|
{
|
||||||
|
@ -208,7 +208,7 @@ chanopt_find (char *network, char *channel, gboolean add_new)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* allocate a new one */
|
/* allocate a new one */
|
||||||
co = g_malloc0 (sizeof (chanopt_in_memory));
|
co = g_new0 (chanopt_in_memory, 1);
|
||||||
co->channel = g_strdup (channel);
|
co->channel = g_strdup (channel);
|
||||||
co->network = g_strdup (network);
|
co->network = g_strdup (network);
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ chanopt_load (session *sess)
|
||||||
chanopt_in_memory *co;
|
chanopt_in_memory *co;
|
||||||
char *network;
|
char *network;
|
||||||
|
|
||||||
if (sess->channel[0] == 0)
|
if (sess->session_name[0] == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
network = server_get_network (sess->server, FALSE);
|
network = server_get_network (sess->server, FALSE);
|
||||||
|
@ -311,7 +311,7 @@ chanopt_load (session *sess)
|
||||||
chanopt_load_all ();
|
chanopt_load_all ();
|
||||||
}
|
}
|
||||||
|
|
||||||
co = chanopt_find (network, sess->channel, FALSE);
|
co = chanopt_find (network, sess->session_name, FALSE);
|
||||||
if (!co)
|
if (!co)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ chanopt_save (session *sess)
|
||||||
chanopt_in_memory *co;
|
chanopt_in_memory *co;
|
||||||
char *network;
|
char *network;
|
||||||
|
|
||||||
if (sess->channel[0] == 0)
|
if (sess->session_name[0] == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
network = server_get_network (sess->server, FALSE);
|
network = server_get_network (sess->server, FALSE);
|
||||||
|
@ -343,7 +343,7 @@ chanopt_save (session *sess)
|
||||||
|
|
||||||
/* 2. reconcile sess with what we loaded from disk */
|
/* 2. reconcile sess with what we loaded from disk */
|
||||||
|
|
||||||
co = chanopt_find (network, sess->channel, TRUE);
|
co = chanopt_find (network, sess->session_name, TRUE);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < sizeof (chanopt) / sizeof (channel_options))
|
while (i < sizeof (chanopt) / sizeof (channel_options))
|
||||||
|
@ -368,10 +368,10 @@ chanopt_save_one_channel (chanopt_in_memory *co, int fh)
|
||||||
char buf[256];
|
char buf[256];
|
||||||
guint8 val;
|
guint8 val;
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf), "%s = %s\n", "network", co->network);
|
g_snprintf (buf, sizeof (buf), "%s = %s\n", "network", co->network);
|
||||||
write (fh, buf, strlen (buf));
|
write (fh, buf, strlen (buf));
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf), "%s = %s\n", "channel", co->channel);
|
g_snprintf (buf, sizeof (buf), "%s = %s\n", "channel", co->channel);
|
||||||
write (fh, buf, strlen (buf));
|
write (fh, buf, strlen (buf));
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -380,7 +380,7 @@ chanopt_save_one_channel (chanopt_in_memory *co, int fh)
|
||||||
val = G_STRUCT_MEMBER (guint8, co, chanopt[i].offset);
|
val = G_STRUCT_MEMBER (guint8, co, chanopt[i].offset);
|
||||||
if (val != SET_DEFAULT)
|
if (val != SET_DEFAULT)
|
||||||
{
|
{
|
||||||
snprintf (buf, sizeof (buf), "%s = %d\n", chanopt[i].name, val);
|
g_snprintf (buf, sizeof (buf), "%s = %d\n", chanopt[i].name, val);
|
||||||
write (fh, buf, strlen (buf));
|
write (fh, buf, strlen (buf));
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
@ -20,16 +21,15 @@
|
||||||
<ClInclude Include="dcc.h" />
|
<ClInclude Include="dcc.h" />
|
||||||
<ClInclude Include="fe.h" />
|
<ClInclude Include="fe.h" />
|
||||||
<ClInclude Include="history.h" />
|
<ClInclude Include="history.h" />
|
||||||
<ClInclude Include="identd.h" />
|
|
||||||
<ClInclude Include="ignore.h" />
|
<ClInclude Include="ignore.h" />
|
||||||
<ClInclude Include="inbound.h" />
|
<ClInclude Include="inbound.h" />
|
||||||
<ClInclude Include="inet.h" />
|
<ClInclude Include="inet.h" />
|
||||||
<ClInclude Include="marshal.h" />
|
<ClInclude Include="$(HexChatLib)marshal.h" />
|
||||||
<ClInclude Include="modes.h" />
|
<ClInclude Include="modes.h" />
|
||||||
<ClInclude Include="msproxy.h" />
|
|
||||||
<ClInclude Include="network.h" />
|
<ClInclude Include="network.h" />
|
||||||
<ClInclude Include="notify.h" />
|
<ClInclude Include="notify.h" />
|
||||||
<ClInclude Include="outbound.h" />
|
<ClInclude Include="outbound.h" />
|
||||||
|
<ClInclude Include="plugin-identd.h" />
|
||||||
<ClInclude Include="plugin-timer.h" />
|
<ClInclude Include="plugin-timer.h" />
|
||||||
<ClInclude Include="plugin.h" />
|
<ClInclude Include="plugin.h" />
|
||||||
<ClInclude Include="proto-irc.h" />
|
<ClInclude Include="proto-irc.h" />
|
||||||
|
@ -37,8 +37,8 @@
|
||||||
<ClInclude Include="servlist.h" />
|
<ClInclude Include="servlist.h" />
|
||||||
<ClInclude Include="ssl.h" />
|
<ClInclude Include="ssl.h" />
|
||||||
<ClInclude Include="text.h" />
|
<ClInclude Include="text.h" />
|
||||||
<ClInclude Include="textenums.h" />
|
<ClInclude Include="$(HexChatLib)textenums.h" />
|
||||||
<ClInclude Include="textevents.h" />
|
<ClInclude Include="$(HexChatLib)textevents.h" />
|
||||||
<ClInclude Include="tree.h" />
|
<ClInclude Include="tree.h" />
|
||||||
<ClInclude Include="typedef.h" />
|
<ClInclude Include="typedef.h" />
|
||||||
<ClInclude Include="url.h" />
|
<ClInclude Include="url.h" />
|
||||||
|
@ -54,12 +54,11 @@
|
||||||
<ClCompile Include="ctcp.c" />
|
<ClCompile Include="ctcp.c" />
|
||||||
<ClCompile Include="dcc.c" />
|
<ClCompile Include="dcc.c" />
|
||||||
<ClCompile Include="history.c" />
|
<ClCompile Include="history.c" />
|
||||||
<ClCompile Include="identd.c" />
|
<ClCompile Include="plugin-identd.c" />
|
||||||
<ClCompile Include="ignore.c" />
|
<ClCompile Include="ignore.c" />
|
||||||
<ClCompile Include="inbound.c" />
|
<ClCompile Include="inbound.c" />
|
||||||
<ClCompile Include="marshal.c" />
|
<ClCompile Include="$(HexChatLib)marshal.c" />
|
||||||
<ClCompile Include="modes.c" />
|
<ClCompile Include="modes.c" />
|
||||||
<ClCompile Include="msproxy.c" />
|
|
||||||
<ClCompile Include="network.c" />
|
<ClCompile Include="network.c" />
|
||||||
<ClCompile Include="notify.c" />
|
<ClCompile Include="notify.c" />
|
||||||
<ClCompile Include="outbound.c" />
|
<ClCompile Include="outbound.c" />
|
||||||
|
@ -77,8 +76,8 @@
|
||||||
<ClCompile Include="hexchat.c" />
|
<ClCompile Include="hexchat.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\config-win32.h.tt" />
|
<None Include="..\..\win32\config.h.tt" />
|
||||||
<ClInclude Include="..\..\config-win32.h" />
|
<ClInclude Include="$(HexChatLib)config.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{87554B59-006C-4D94-9714-897B27067BA3}</ProjectGuid>
|
<ProjectGuid>{87554B59-006C-4D94-9714-897B27067BA3}</ProjectGuid>
|
||||||
|
@ -86,85 +85,36 @@
|
||||||
<RootNamespace>common</RootNamespace>
|
<RootNamespace>common</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
<Import Project="..\..\win32\hexchat.props" />
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<OutDir>$(HexChatLib)</OutDir>
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\..\win32\hexchat.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<OutDir>$(HexChatBin)</OutDir>
|
|
||||||
<IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(HexChatLib);$(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(HexChatLib);$(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<DisableSpecificWarnings>4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
<Command><![CDATA[
|
<Command><![CDATA[
|
||||||
SET SOLUTIONDIR=$(SolutionDir)..\
|
SET SOLUTIONDIR=$(SolutionDir)..\
|
||||||
powershell -File "$(SolutionDir)..\version-template.ps1" "$(SolutionDir)..\config-win32.h.tt" "$(SolutionDir)..\config-win32.h"
|
"$(HexChatLib)make-te.exe" < "$(ProjectDir)textevents.in" > "$(HexChatLib)textevents.h" 2> "$(HexChatLib)textenums.h"
|
||||||
"$(DepsRoot)\bin\glib-genmarshal.exe" --prefix=_hexchat_marshal --header "$(ProjectDir)marshalers.list" > "$(ProjectDir)marshal.h"
|
powershell -File "$(SolutionDir)..\win32\version-template.ps1" "$(SolutionDir)..\win32\config.h.tt" "$(HexChatLib)config.h"
|
||||||
"$(DepsRoot)\bin\glib-genmarshal.exe" --prefix=_hexchat_marshal --body "$(ProjectDir)marshalers.list" > "$(ProjectDir)marshal.c"
|
"$(DepsRoot)\bin\glib-genmarshal.exe" --prefix=_hexchat_marshal --header "$(ProjectDir)marshalers.list" > "$(HexChatLib)marshal.h"
|
||||||
|
"$(DepsRoot)\bin\glib-genmarshal.exe" --prefix=_hexchat_marshal --body "$(ProjectDir)marshalers.list" > "$(HexChatLib)marshal.c"
|
||||||
|
|
||||||
]]></Command>
|
]]></Command>
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -29,9 +29,6 @@
|
||||||
<ClInclude Include="history.h">
|
<ClInclude Include="history.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="identd.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ignore.h">
|
<ClInclude Include="ignore.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -44,9 +41,6 @@
|
||||||
<ClInclude Include="modes.h">
|
<ClInclude Include="modes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="msproxy.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="network.h">
|
<ClInclude Include="network.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -77,10 +71,10 @@
|
||||||
<ClInclude Include="text.h">
|
<ClInclude Include="text.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="textenums.h">
|
<ClInclude Include="$(HexChatLib)textenums.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="textevents.h">
|
<ClInclude Include="$(HexChatLib)textevents.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="tree.h">
|
<ClInclude Include="tree.h">
|
||||||
|
@ -104,13 +98,16 @@
|
||||||
<ClInclude Include="hexchat-plugin.h">
|
<ClInclude Include="hexchat-plugin.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\config-win32.h">
|
<ClInclude Include="$(HexChatLib)config.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="typedef.h">
|
<ClInclude Include="typedef.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="marshal.h">
|
<ClInclude Include="$(HexChatLib)marshal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="plugin-identd.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -130,9 +127,6 @@
|
||||||
<ClCompile Include="history.c">
|
<ClCompile Include="history.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="identd.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ignore.c">
|
<ClCompile Include="ignore.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -142,9 +136,6 @@
|
||||||
<ClCompile Include="modes.c">
|
<ClCompile Include="modes.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="msproxy.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="network.c">
|
<ClCompile Include="network.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -190,11 +181,14 @@
|
||||||
<ClCompile Include="hexchat.c">
|
<ClCompile Include="hexchat.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="marshal.c">
|
<ClCompile Include="$(HexChatLib)marshal.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="plugin-identd.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\config-win32.h.tt" />
|
<None Include="..\..\win32\config.h.tt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -44,12 +44,12 @@ ctcp_reply (session *sess, char *nick, char *word[], char *word_eol[],
|
||||||
{
|
{
|
||||||
char tbuf[4096]; /* can receive 2048 from IRC, so this is enough */
|
char tbuf[4096]; /* can receive 2048 from IRC, so this is enough */
|
||||||
|
|
||||||
conf = strdup (conf);
|
conf = g_strdup (conf);
|
||||||
/* process %C %B etc */
|
/* process %C %B etc */
|
||||||
check_special_chars (conf, TRUE);
|
check_special_chars (conf, TRUE);
|
||||||
auto_insert (tbuf, sizeof (tbuf), conf, word, word_eol, "", "", word_eol[5],
|
auto_insert (tbuf, sizeof (tbuf), conf, word, word_eol, "", "", word_eol[5],
|
||||||
server_get_network (sess->server, TRUE), "", "", nick, "");
|
server_get_network (sess->server, TRUE), "", "", nick, "");
|
||||||
free (conf);
|
g_free (conf);
|
||||||
handle_command (sess, tbuf, FALSE);
|
handle_command (sess, tbuf, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,10 +139,10 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
|
||||||
if (!g_ascii_strcasecmp (msg, "VERSION") && !prefs.hex_irc_hide_version)
|
if (!g_ascii_strcasecmp (msg, "VERSION") && !prefs.hex_irc_hide_version)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" [x%d] / %s",
|
g_snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" [x%d] / %s",
|
||||||
get_cpu_arch (), get_sys_str (1));
|
get_cpu_arch (), get_sys_str (1));
|
||||||
#else
|
#else
|
||||||
snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" / %s",
|
g_snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" / %s",
|
||||||
get_sys_str (1));
|
get_sys_str (1));
|
||||||
#endif
|
#endif
|
||||||
serv->p_nctcp (serv, nick, outbuf);
|
serv->p_nctcp (serv, nick, outbuf);
|
||||||
|
|
|
@ -15,7 +15,7 @@ BUILT_SOURCES = \
|
||||||
|
|
||||||
CLEANFILES = $(BUILT_SOURCES)
|
CLEANFILES = $(BUILT_SOURCES)
|
||||||
|
|
||||||
AM_CPPFLAGS = $(COMMON_CFLAGS) $(DBUS_CFLAGS)
|
AM_CPPFLAGS = $(COMMON_CFLAGS) $(DBUS_CFLAGS) -I$(top_srcdir)/src/common
|
||||||
|
|
||||||
noinst_PROGRAMS = example
|
noinst_PROGRAMS = example
|
||||||
example_SOURCES = example.c
|
example_SOURCES = example.c
|
||||||
|
|
|
@ -19,11 +19,13 @@
|
||||||
* xclaesse@gmail.com
|
* xclaesse@gmail.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
#include "dbus-client.h"
|
#include "dbus-client.h"
|
||||||
#include "../hexchat.h"
|
#include "hexchat.h"
|
||||||
#include "../hexchatc.h"
|
#include "hexchatc.h"
|
||||||
|
|
||||||
#define DBUS_SERVICE "org.hexchat.service"
|
#define DBUS_SERVICE "org.hexchat.service"
|
||||||
#define DBUS_REMOTE "/org/hexchat/Remote"
|
#define DBUS_REMOTE "/org/hexchat/Remote"
|
||||||
|
@ -91,7 +93,7 @@ hexchat_remote (void)
|
||||||
g_object_unref (dbus);
|
g_object_unref (dbus);
|
||||||
|
|
||||||
if (!hexchat_running) {
|
if (!hexchat_running) {
|
||||||
//dbus_g_connection_unref (connection);
|
/* dbus_g_connection_unref (connection); */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
#include <dbus/dbus-glib-lowlevel.h>
|
#include <dbus/dbus-glib-lowlevel.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include "../hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
|
#include "dbus-plugin.h"
|
||||||
|
|
||||||
#define PNAME _("remote access")
|
#define PNAME _("remote access")
|
||||||
#define PDESC _("plugin for remote access using DBUS")
|
#define PDESC _("plugin for remote access using DBUS")
|
||||||
|
@ -365,6 +366,7 @@ remote_object_connect (RemoteObject *obj,
|
||||||
static guint count = 0;
|
static guint count = 0;
|
||||||
char *sender, *path;
|
char *sender, *path;
|
||||||
RemoteObject *remote_object;
|
RemoteObject *remote_object;
|
||||||
|
gchar count_buffer[15];
|
||||||
|
|
||||||
sender = dbus_g_method_get_sender (context);
|
sender = dbus_g_method_get_sender (context);
|
||||||
remote_object = g_hash_table_lookup (clients, sender);
|
remote_object = g_hash_table_lookup (clients, sender);
|
||||||
|
@ -373,7 +375,8 @@ remote_object_connect (RemoteObject *obj,
|
||||||
g_free (sender);
|
g_free (sender);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
path = g_build_filename (DBUS_OBJECT_PATH, count++, NULL);
|
g_snprintf(count_buffer, sizeof(count_buffer), "%u", count++);
|
||||||
|
path = g_build_filename (DBUS_OBJECT_PATH, count_buffer, NULL);
|
||||||
remote_object = g_object_new (REMOTE_TYPE_OBJECT, NULL);
|
remote_object = g_object_new (REMOTE_TYPE_OBJECT, NULL);
|
||||||
remote_object->dbus_path = path;
|
remote_object->dbus_path = path;
|
||||||
remote_object->filename = g_path_get_basename (filename);
|
remote_object->filename = g_path_get_basename (filename);
|
||||||
|
|
|
@ -33,7 +33,7 @@ guint command_id;
|
||||||
guint server_id;
|
guint server_id;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_error (char *message,
|
write_error (const char *message,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
if (error == NULL || *error == NULL) {
|
if (error == NULL || *error == NULL) {
|
||||||
|
|
606
src/common/dcc.c
606
src/common/dcc.c
File diff suppressed because it is too large
Load Diff
|
@ -39,17 +39,6 @@
|
||||||
|
|
||||||
#define CPS_AVG_WINDOW 10
|
#define CPS_AVG_WINDOW 10
|
||||||
|
|
||||||
/* can we do 64-bit dcc? */
|
|
||||||
#if defined(G_GINT64_FORMAT) && defined(HAVE_STRTOULL)
|
|
||||||
#define USE_DCC64
|
|
||||||
/* we really get only 63 bits, since st_size is signed */
|
|
||||||
#define DCC_SIZE gint64
|
|
||||||
#define DCC_SFMT G_GINT64_FORMAT
|
|
||||||
#else
|
|
||||||
#define DCC_SIZE unsigned int
|
|
||||||
#define DCC_SFMT "u"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct DCC
|
struct DCC
|
||||||
{
|
{
|
||||||
struct server *serv;
|
struct server *serv;
|
||||||
|
@ -62,21 +51,21 @@ struct DCC
|
||||||
int wiotag; /* writing/sending io tag */
|
int wiotag; /* writing/sending io tag */
|
||||||
int port;
|
int port;
|
||||||
int pasvid; /* mIRC's passive DCC id */
|
int pasvid; /* mIRC's passive DCC id */
|
||||||
int cps;
|
gint64 cps;
|
||||||
int resume_error;
|
int resume_error;
|
||||||
int resume_errno;
|
int resume_errno;
|
||||||
|
|
||||||
GTimeVal lastcpstv, firstcpstv;
|
GTimeVal lastcpstv, firstcpstv;
|
||||||
DCC_SIZE lastcpspos;
|
goffset lastcpspos;
|
||||||
int maxcps;
|
gint64 maxcps;
|
||||||
|
|
||||||
unsigned char ack_buf[4]; /* buffer for reading 4-byte ack */
|
unsigned char ack_buf[4]; /* buffer for reading 4-byte ack */
|
||||||
int ack_pos;
|
int ack_pos;
|
||||||
|
|
||||||
DCC_SIZE size;
|
guint64 size;
|
||||||
DCC_SIZE resumable;
|
guint64 resumable;
|
||||||
DCC_SIZE ack;
|
guint64 ack;
|
||||||
DCC_SIZE pos;
|
guint64 pos;
|
||||||
time_t starttime;
|
time_t starttime;
|
||||||
time_t offertime;
|
time_t offertime;
|
||||||
time_t lasttime;
|
time_t lasttime;
|
||||||
|
@ -125,7 +114,7 @@ void dcc_check_timeouts (void);
|
||||||
void dcc_change_nick (server *serv, char *oldnick, char *newnick);
|
void dcc_change_nick (server *serv, char *oldnick, char *newnick);
|
||||||
void dcc_notify_kill (struct server *serv);
|
void dcc_notify_kill (struct server *serv);
|
||||||
struct DCC *dcc_write_chat (char *nick, char *text);
|
struct DCC *dcc_write_chat (char *nick, char *text);
|
||||||
void dcc_send (struct session *sess, char *to, char *file, int maxcps, int passive);
|
void dcc_send (struct session *sess, char *to, char *file, gint64 maxcps, int passive);
|
||||||
struct DCC *find_dcc (char *nick, char *file, int type);
|
struct DCC *find_dcc (char *nick, char *file, int type);
|
||||||
void dcc_get_nick (struct session *sess, char *nick);
|
void dcc_get_nick (struct session *sess, char *nick);
|
||||||
void dcc_chat (session *sess, char *nick, int passive);
|
void dcc_chat (session *sess, char *nick, int passive);
|
||||||
|
|
|
@ -88,11 +88,10 @@ void fe_progressbar_start (struct session *sess);
|
||||||
void fe_progressbar_end (struct server *serv);
|
void fe_progressbar_end (struct server *serv);
|
||||||
void fe_print_text (struct session *sess, char *text, time_t stamp,
|
void fe_print_text (struct session *sess, char *text, time_t stamp,
|
||||||
gboolean no_activity);
|
gboolean no_activity);
|
||||||
void fe_userlist_insert (struct session *sess, struct User *newuser, int row, int sel);
|
void fe_userlist_insert (struct session *sess, struct User *newuser, gboolean sel);
|
||||||
int fe_userlist_remove (struct session *sess, struct User *user);
|
int fe_userlist_remove (struct session *sess, struct User *user);
|
||||||
void fe_userlist_rehash (struct session *sess, struct User *user);
|
void fe_userlist_rehash (struct session *sess, struct User *user);
|
||||||
void fe_userlist_update (struct session *sess, struct User *user);
|
void fe_userlist_update (struct session *sess, struct User *user);
|
||||||
void fe_userlist_move (struct session *sess, struct User *user, int new_row);
|
|
||||||
void fe_userlist_numbers (struct session *sess);
|
void fe_userlist_numbers (struct session *sess);
|
||||||
void fe_userlist_clear (struct session *sess);
|
void fe_userlist_clear (struct session *sess);
|
||||||
void fe_userlist_set_selected (struct session *sess);
|
void fe_userlist_set_selected (struct session *sess);
|
||||||
|
@ -179,7 +178,6 @@ typedef enum
|
||||||
} feicon;
|
} feicon;
|
||||||
void fe_tray_set_icon (feicon icon);
|
void fe_tray_set_icon (feicon icon);
|
||||||
void fe_tray_set_tooltip (const char *text);
|
void fe_tray_set_tooltip (const char *text);
|
||||||
void fe_tray_set_balloon (const char *title, const char *text);
|
|
||||||
void fe_open_chan_list (server *serv, char *filter, int do_refresh);
|
void fe_open_chan_list (server *serv, char *filter, int do_refresh);
|
||||||
const char *fe_get_default_font ();
|
const char *fe_get_default_font ();
|
||||||
|
|
||||||
|
|
|
@ -88,11 +88,19 @@ struct _hexchat_plugin
|
||||||
void (*hexchat_print) (hexchat_plugin *ph,
|
void (*hexchat_print) (hexchat_plugin *ph,
|
||||||
const char *text);
|
const char *text);
|
||||||
void (*hexchat_printf) (hexchat_plugin *ph,
|
void (*hexchat_printf) (hexchat_plugin *ph,
|
||||||
const char *format, ...);
|
const char *format, ...)
|
||||||
|
#ifdef __GNUC__
|
||||||
|
__attribute__((format(printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
void (*hexchat_command) (hexchat_plugin *ph,
|
void (*hexchat_command) (hexchat_plugin *ph,
|
||||||
const char *command);
|
const char *command);
|
||||||
void (*hexchat_commandf) (hexchat_plugin *ph,
|
void (*hexchat_commandf) (hexchat_plugin *ph,
|
||||||
const char *format, ...);
|
const char *format, ...)
|
||||||
|
#ifdef __GNUC__
|
||||||
|
__attribute__((format(printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
int (*hexchat_nickcmp) (hexchat_plugin *ph,
|
int (*hexchat_nickcmp) (hexchat_plugin *ph,
|
||||||
const char *s1,
|
const char *s1,
|
||||||
const char *s2);
|
const char *s2);
|
||||||
|
@ -254,7 +262,11 @@ hexchat_print (hexchat_plugin *ph,
|
||||||
|
|
||||||
void
|
void
|
||||||
hexchat_printf (hexchat_plugin *ph,
|
hexchat_printf (hexchat_plugin *ph,
|
||||||
const char *format, ...);
|
const char *format, ...)
|
||||||
|
#ifdef __GNUC__
|
||||||
|
__attribute__((format(printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
void
|
void
|
||||||
hexchat_command (hexchat_plugin *ph,
|
hexchat_command (hexchat_plugin *ph,
|
||||||
|
@ -262,7 +274,11 @@ hexchat_command (hexchat_plugin *ph,
|
||||||
|
|
||||||
void
|
void
|
||||||
hexchat_commandf (hexchat_plugin *ph,
|
hexchat_commandf (hexchat_plugin *ph,
|
||||||
const char *format, ...);
|
const char *format, ...)
|
||||||
|
#ifdef __GNUC__
|
||||||
|
__attribute__((format(printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
int
|
int
|
||||||
hexchat_nickcmp (hexchat_plugin *ph,
|
hexchat_nickcmp (hexchat_plugin *ph,
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
#include "chanopt.h"
|
#include "chanopt.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
#include "hexchat-plugin.h"
|
#include "hexchat-plugin.h"
|
||||||
|
#include "inbound.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
#include "plugin-identd.h"
|
||||||
#include "plugin-timer.h"
|
#include "plugin-timer.h"
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
@ -55,15 +57,6 @@
|
||||||
#include <glib-object.h> /* for g_type_init() */
|
#include <glib-object.h> /* for g_type_init() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
|
||||||
#include <openssl/ssl.h> /* SSL_() */
|
|
||||||
#include "ssl.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_MSPROXY
|
|
||||||
#include "msproxy.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_LIBPROXY
|
#ifdef USE_LIBPROXY
|
||||||
#include <proxy.h>
|
#include <proxy.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -118,10 +111,6 @@ struct session *current_tab;
|
||||||
struct session *current_sess = 0;
|
struct session *current_sess = 0;
|
||||||
struct hexchatprefs prefs;
|
struct hexchatprefs prefs;
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
|
||||||
SSL_CTX *ctx = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_LIBPROXY
|
#ifdef USE_LIBPROXY
|
||||||
pxProxyFactory *libproxy_factory;
|
pxProxyFactory *libproxy_factory;
|
||||||
#endif
|
#endif
|
||||||
|
@ -221,7 +210,7 @@ find_dialog (server *serv, char *nick)
|
||||||
}
|
}
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
session *
|
session *
|
||||||
|
@ -232,14 +221,14 @@ find_channel (server *serv, char *chan)
|
||||||
while (list)
|
while (list)
|
||||||
{
|
{
|
||||||
sess = list->data;
|
sess = list->data;
|
||||||
if ((!serv || serv == sess->server) && sess->type == SESS_CHANNEL)
|
if ((serv == sess->server) && sess->type == SESS_CHANNEL)
|
||||||
{
|
{
|
||||||
if (!serv->p_cmp (chan, sess->channel))
|
if (!serv->p_cmp (chan, sess->channel))
|
||||||
return sess;
|
return sess;
|
||||||
}
|
}
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -269,7 +258,7 @@ lag_check (void)
|
||||||
unsigned long tim;
|
unsigned long tim;
|
||||||
char tbuf[128];
|
char tbuf[128];
|
||||||
time_t now = time (0);
|
time_t now = time (0);
|
||||||
int lag;
|
time_t lag;
|
||||||
|
|
||||||
tim = make_ping_time ();
|
tim = make_ping_time ();
|
||||||
|
|
||||||
|
@ -279,16 +268,17 @@ lag_check (void)
|
||||||
if (serv->connected && serv->end_of_motd)
|
if (serv->connected && serv->end_of_motd)
|
||||||
{
|
{
|
||||||
lag = now - serv->ping_recv;
|
lag = now - serv->ping_recv;
|
||||||
if (prefs.hex_net_ping_timeout && lag > prefs.hex_net_ping_timeout && lag > 0)
|
if (prefs.hex_net_ping_timeout != 0 && lag > prefs.hex_net_ping_timeout && lag > 0)
|
||||||
{
|
{
|
||||||
sprintf (tbuf, "%d", lag);
|
sprintf (tbuf, "%" G_GINT64_FORMAT, (gint64) lag);
|
||||||
EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL,
|
EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL,
|
||||||
NULL, NULL, 0);
|
NULL, NULL, 0);
|
||||||
if (prefs.hex_net_auto_reconnect)
|
if (prefs.hex_net_auto_reconnect)
|
||||||
serv->auto_reconnect (serv, FALSE, -1);
|
serv->auto_reconnect (serv, FALSE, -1);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim);
|
g_snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim);
|
||||||
serv->p_ping (serv, "", tbuf);
|
serv->p_ping (serv, "", tbuf);
|
||||||
|
|
||||||
if (!serv->lag_sent)
|
if (!serv->lag_sent)
|
||||||
|
@ -368,9 +358,6 @@ static int
|
||||||
hexchat_misc_checks (void) /* this gets called every 1/2 second */
|
hexchat_misc_checks (void) /* this gets called every 1/2 second */
|
||||||
{
|
{
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
#ifdef USE_MSPROXY
|
|
||||||
static int count2 = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
|
@ -386,15 +373,6 @@ hexchat_misc_checks (void) /* this gets called every 1/2 second */
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MSPROXY
|
|
||||||
count2++;
|
|
||||||
if (count2 >= 720) /* 720 every 6 minutes */
|
|
||||||
{
|
|
||||||
msproxy_keepalive ();
|
|
||||||
count2 = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,7 +383,6 @@ irc_init (session *sess)
|
||||||
{
|
{
|
||||||
static int done_init = FALSE;
|
static int done_init = FALSE;
|
||||||
char *buf;
|
char *buf;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (done_init)
|
if (done_init)
|
||||||
return;
|
return;
|
||||||
|
@ -413,6 +390,7 @@ irc_init (session *sess)
|
||||||
done_init = TRUE;
|
done_init = TRUE;
|
||||||
|
|
||||||
plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE);
|
plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE);
|
||||||
|
plugin_add (sess, NULL, NULL, identd_plugin_init, identd_plugin_deinit, NULL, FALSE);
|
||||||
|
|
||||||
#ifdef USE_PLUGIN
|
#ifdef USE_PLUGIN
|
||||||
if (!arg_skip_plugins)
|
if (!arg_skip_plugins)
|
||||||
|
@ -440,7 +418,8 @@ irc_init (session *sess)
|
||||||
|
|
||||||
if (arg_urls != NULL)
|
if (arg_urls != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < g_strv_length(arg_urls); i++)
|
guint i;
|
||||||
|
for (i = 0; i < g_strv_length (arg_urls); i++)
|
||||||
{
|
{
|
||||||
buf = g_strdup_printf ("%s %s", i==0? "server" : "newserver", arg_urls[i]);
|
buf = g_strdup_printf ("%s %s", i==0? "server" : "newserver", arg_urls[i]);
|
||||||
handle_command (sess, buf, FALSE);
|
handle_command (sess, buf, FALSE);
|
||||||
|
@ -464,12 +443,7 @@ session_new (server *serv, char *from, int type, int focus)
|
||||||
{
|
{
|
||||||
session *sess;
|
session *sess;
|
||||||
|
|
||||||
sess = malloc (sizeof (struct session));
|
sess = g_new0 (struct session, 1);
|
||||||
if (sess == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
memset (sess, 0, sizeof (struct session));
|
|
||||||
|
|
||||||
sess->server = serv;
|
sess->server = serv;
|
||||||
sess->logfd = -1;
|
sess->logfd = -1;
|
||||||
|
@ -488,7 +462,10 @@ session_new (server *serv, char *from, int type, int focus)
|
||||||
sess->lastact_idx = LACT_NONE;
|
sess->lastact_idx = LACT_NONE;
|
||||||
|
|
||||||
if (from != NULL)
|
if (from != NULL)
|
||||||
safe_strcpy (sess->channel, from, CHANLEN);
|
{
|
||||||
|
safe_strcpy(sess->channel, from, CHANLEN);
|
||||||
|
safe_strcpy(sess->session_name, from, CHANLEN);
|
||||||
|
}
|
||||||
|
|
||||||
sess_list = g_slist_prepend (sess_list, sess);
|
sess_list = g_slist_prepend (sess_list, sess);
|
||||||
|
|
||||||
|
@ -515,7 +492,6 @@ new_ircwindow (server *serv, char *name, int type, int focus)
|
||||||
break;
|
break;
|
||||||
case SESS_DIALOG:
|
case SESS_DIALOG:
|
||||||
sess = session_new (serv, name, type, focus);
|
sess = session_new (serv, name, type, focus);
|
||||||
log_open_or_close (sess);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* case SESS_CHANNEL:
|
/* case SESS_CHANNEL:
|
||||||
|
@ -530,6 +506,16 @@ new_ircwindow (server *serv, char *name, int type, int focus)
|
||||||
scrollback_load (sess);
|
scrollback_load (sess);
|
||||||
if (sess->scrollwritten && sess->scrollback_replay_marklast)
|
if (sess->scrollwritten && sess->scrollback_replay_marklast)
|
||||||
sess->scrollback_replay_marklast (sess);
|
sess->scrollback_replay_marklast (sess);
|
||||||
|
if (type == SESS_DIALOG)
|
||||||
|
{
|
||||||
|
struct User *user;
|
||||||
|
|
||||||
|
log_open_or_close (sess);
|
||||||
|
|
||||||
|
user = userlist_find_global (serv, name);
|
||||||
|
if (user && user->hostname)
|
||||||
|
set_topic (sess, user->hostname, user->hostname);
|
||||||
|
}
|
||||||
plugin_emit_dummy_print (sess, "Open Context");
|
plugin_emit_dummy_print (sess, "Open Context");
|
||||||
|
|
||||||
return sess;
|
return sess;
|
||||||
|
@ -548,9 +534,8 @@ exec_notify_kill (session * sess)
|
||||||
waitpid (re->childpid, NULL, WNOHANG);
|
waitpid (re->childpid, NULL, WNOHANG);
|
||||||
fe_input_remove (re->iotag);
|
fe_input_remove (re->iotag);
|
||||||
close (re->myfd);
|
close (re->myfd);
|
||||||
if (re->linebuf)
|
g_free(re->linebuf);
|
||||||
free(re->linebuf);
|
g_free (re);
|
||||||
free (re);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -656,10 +641,8 @@ session_free (session *killsess)
|
||||||
send_quit_or_part (killsess);
|
send_quit_or_part (killsess);
|
||||||
|
|
||||||
history_free (&killsess->history);
|
history_free (&killsess->history);
|
||||||
if (killsess->topic)
|
g_free (killsess->topic);
|
||||||
free (killsess->topic);
|
g_free (killsess->current_modes);
|
||||||
if (killsess->current_modes)
|
|
||||||
free (killsess->current_modes);
|
|
||||||
|
|
||||||
fe_session_callback (killsess);
|
fe_session_callback (killsess);
|
||||||
|
|
||||||
|
@ -670,7 +653,7 @@ session_free (session *killsess)
|
||||||
current_sess = sess_list->data;
|
current_sess = sess_list->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
free (killsess);
|
g_free (killsess);
|
||||||
|
|
||||||
if (!sess_list && !in_hexchat_exit)
|
if (!sess_list && !in_hexchat_exit)
|
||||||
hexchat_exit (); /* sess_list is empty, quit! */
|
hexchat_exit (); /* sess_list is empty, quit! */
|
||||||
|
@ -784,20 +767,15 @@ static void
|
||||||
xchat_init (void)
|
xchat_init (void)
|
||||||
{
|
{
|
||||||
char buf[3068];
|
char buf[3068];
|
||||||
const char *cs = NULL;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
WSADATA wsadata;
|
WSADATA wsadata;
|
||||||
|
|
||||||
#ifdef USE_IPV6
|
|
||||||
if (WSAStartup(0x0202, &wsadata) != 0)
|
if (WSAStartup(0x0202, &wsadata) != 0)
|
||||||
{
|
{
|
||||||
MessageBox (NULL, "Cannot find winsock 2.2+", "Error", MB_OK);
|
MessageBox (NULL, "Cannot find winsock 2.2+", "Error", MB_OK);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
WSAStartup(0x0101, &wsadata);
|
|
||||||
#endif /* !USE_IPV6 */
|
|
||||||
#endif /* !WIN32 */
|
#endif /* !WIN32 */
|
||||||
|
|
||||||
#ifdef USE_SIGACTION
|
#ifdef USE_SIGACTION
|
||||||
|
@ -826,15 +804,12 @@ xchat_init (void)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (g_get_charset (&cs))
|
|
||||||
prefs.utf8_locale = TRUE;
|
|
||||||
|
|
||||||
load_text_events ();
|
load_text_events ();
|
||||||
sound_load ();
|
sound_load ();
|
||||||
notify_load ();
|
notify_load ();
|
||||||
ignore_load ();
|
ignore_load ();
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf),
|
g_snprintf (buf, sizeof (buf),
|
||||||
"NAME %s~%s~\n" "CMD query %%s\n\n"\
|
"NAME %s~%s~\n" "CMD query %%s\n\n"\
|
||||||
"NAME %s~%s~\n" "CMD send %%s\n\n"\
|
"NAME %s~%s~\n" "CMD send %%s\n\n"\
|
||||||
"NAME %s~%s~\n" "CMD whois %%s %%s\n\n"\
|
"NAME %s~%s~\n" "CMD whois %%s %%s\n\n"\
|
||||||
|
@ -890,7 +865,7 @@ xchat_init (void)
|
||||||
|
|
||||||
list_loadconf ("popup.conf", &popup_list, buf);
|
list_loadconf ("popup.conf", &popup_list, buf);
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf),
|
g_snprintf (buf, sizeof (buf),
|
||||||
"NAME %s\n" "CMD part\n\n"
|
"NAME %s\n" "CMD part\n\n"
|
||||||
"NAME %s\n" "CMD getstr # join \"%s\"\n\n"
|
"NAME %s\n" "CMD getstr # join \"%s\"\n\n"
|
||||||
"NAME %s\n" "CMD quote LINKS\n\n"
|
"NAME %s\n" "CMD quote LINKS\n\n"
|
||||||
|
@ -904,7 +879,7 @@ xchat_init (void)
|
||||||
_("Hide Version"));
|
_("Hide Version"));
|
||||||
list_loadconf ("usermenu.conf", &usermenu_list, buf);
|
list_loadconf ("usermenu.conf", &usermenu_list, buf);
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf),
|
g_snprintf (buf, sizeof (buf),
|
||||||
"NAME %s\n" "CMD op %%a\n\n"
|
"NAME %s\n" "CMD op %%a\n\n"
|
||||||
"NAME %s\n" "CMD deop %%a\n\n"
|
"NAME %s\n" "CMD deop %%a\n\n"
|
||||||
"NAME %s\n" "CMD ban %%s\n\n"
|
"NAME %s\n" "CMD ban %%s\n\n"
|
||||||
|
@ -921,7 +896,7 @@ xchat_init (void)
|
||||||
_("Dialog"));
|
_("Dialog"));
|
||||||
list_loadconf ("buttons.conf", &button_list, buf);
|
list_loadconf ("buttons.conf", &button_list, buf);
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf),
|
g_snprintf (buf, sizeof (buf),
|
||||||
"NAME %s\n" "CMD whois %%s %%s\n\n"
|
"NAME %s\n" "CMD whois %%s %%s\n\n"
|
||||||
"NAME %s\n" "CMD send %%s\n\n"
|
"NAME %s\n" "CMD send %%s\n\n"
|
||||||
"NAME %s\n" "CMD dcc chat %%s\n\n"
|
"NAME %s\n" "CMD dcc chat %%s\n\n"
|
||||||
|
@ -991,47 +966,12 @@ hexchat_exit (void)
|
||||||
fe_exit ();
|
fe_exit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
|
|
||||||
static int
|
|
||||||
child_handler (gpointer userdata)
|
|
||||||
{
|
|
||||||
int pid = GPOINTER_TO_INT (userdata);
|
|
||||||
|
|
||||||
if (waitpid (pid, 0, WNOHANG) == pid)
|
|
||||||
return 0; /* remove timeout handler */
|
|
||||||
return 1; /* keep the timeout handler */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
hexchat_exec (const char *cmd)
|
hexchat_exec (const char *cmd)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
|
||||||
util_exec (cmd);
|
util_exec (cmd);
|
||||||
#else
|
|
||||||
int pid = util_exec (cmd);
|
|
||||||
if (pid != -1)
|
|
||||||
/* zombie avoiding system. Don't ask! it has to be like this to work
|
|
||||||
with zvt (which overrides the default handler) */
|
|
||||||
fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
hexchat_execv (char * const argv[])
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
util_execv (argv);
|
|
||||||
#else
|
|
||||||
int pid = util_execv (argv);
|
|
||||||
if (pid != -1)
|
|
||||||
/* zombie avoiding system. Don't ask! it has to be like this to work
|
|
||||||
with zvt (which overrides the default handler) */
|
|
||||||
fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_locale (void)
|
set_locale (void)
|
||||||
|
@ -1056,29 +996,37 @@ main (int argc, char *argv[])
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
srand (time (0)); /* CL: do this only once! */
|
#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.
|
/* 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
|
* 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()
|
* know the language which is set in the config. The code below is copy-pasted from fe_args()
|
||||||
* for the most part. */
|
* for the most part. */
|
||||||
if (argc >= 3)
|
if (argc >= 2)
|
||||||
{
|
{
|
||||||
for (i = 1; i < argc - 1; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (strcmp (argv[i], "-d") == 0)
|
if ((strcmp (argv[i], "-d") == 0 || strcmp (argv[i], "--cfgdir") == 0)
|
||||||
|
&& i + 1 < argc)
|
||||||
{
|
{
|
||||||
if (xdir)
|
xdir = g_strdup (argv[i + 1]);
|
||||||
{
|
}
|
||||||
g_free (xdir);
|
else if (strncmp (argv[i], "--cfgdir=", 9) == 0)
|
||||||
}
|
{
|
||||||
|
xdir = g_strdup (argv[i] + 9);
|
||||||
xdir = strdup (argv[i + 1]);
|
}
|
||||||
|
|
||||||
|
if (xdir != NULL)
|
||||||
|
{
|
||||||
if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
|
if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
|
||||||
{
|
{
|
||||||
xdir[strlen (xdir) - 1] = 0;
|
xdir[strlen (xdir) - 1] = 0;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1102,10 +1050,6 @@ main (int argc, char *argv[])
|
||||||
/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
|
/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
|
||||||
set_locale ();
|
set_locale ();
|
||||||
|
|
||||||
#ifdef SOCKS
|
|
||||||
SOCKSinit (argv[0]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = fe_args (argc, argv);
|
ret = fe_args (argc, argv);
|
||||||
if (ret != -1)
|
if (ret != -1)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1118,6 +1062,14 @@ main (int argc, char *argv[])
|
||||||
libproxy_factory = px_proxy_factory_new();
|
libproxy_factory = px_proxy_factory_new();
|
||||||
#endif
|
#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 ();
|
fe_init ();
|
||||||
|
|
||||||
/* This is done here because cfgfiles.c is too early in
|
/* This is done here because cfgfiles.c is too early in
|
||||||
|
@ -1145,19 +1097,17 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
fe_main ();
|
fe_main ();
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
if (SUCCEEDED (coinit_result))
|
||||||
|
{
|
||||||
|
CoUninitialize ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_LIBPROXY
|
#ifdef USE_LIBPROXY
|
||||||
px_proxy_factory_free(libproxy_factory);
|
px_proxy_factory_free(libproxy_factory);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
|
||||||
if (ctx)
|
|
||||||
_SSL_context_free (ctx);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_DEBUG
|
|
||||||
hexchat_mem_list ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
WSACleanup ();
|
WSACleanup ();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,14 +17,12 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WIN32
|
#include "config.h"
|
||||||
#include "../../config-win32.h"
|
|
||||||
#else
|
|
||||||
#include "../../config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#include <time.h> /* need time_t */
|
#include <time.h> /* need time_t */
|
||||||
|
|
||||||
|
@ -39,33 +37,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
|
#include "tree.h"
|
||||||
#ifndef HAVE_SNPRINTF
|
|
||||||
#define snprintf g_snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_VSNPRINTF
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_DEBUG
|
|
||||||
#define malloc(n) hexchat_malloc(n, __FILE__, __LINE__)
|
|
||||||
#define realloc(n, m) hexchat_realloc(n, m, __FILE__, __LINE__)
|
|
||||||
#define free(n) hexchat_dfree(n, __FILE__, __LINE__)
|
|
||||||
#define strdup(n) hexchat_strdup(n, __FILE__, __LINE__)
|
|
||||||
void *hexchat_malloc (int size, char *file, int line);
|
|
||||||
void *hexchat_strdup (char *str, char *file, int line);
|
|
||||||
void hexchat_dfree (void *buf, char *file, int line);
|
|
||||||
void *hexchat_realloc (char *old, int len, char *file, int line);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SOCKS
|
|
||||||
#ifdef __sgi
|
|
||||||
#include <sys/time.h>
|
|
||||||
#define INCLUDE_PROTOTYPES 1
|
|
||||||
#endif
|
|
||||||
#include <socks.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
#include <openssl/ssl.h> /* SSL_() */
|
#include <openssl/ssl.h> /* SSL_() */
|
||||||
|
@ -80,9 +52,7 @@ void *hexchat_realloc (char *old, int len, char *file, int line);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* force a 32bit CMP.L */
|
/* force a 32bit CMP.L */
|
||||||
#define CMPL(a, c0, c1, c2, c3) (a == (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24)))
|
|
||||||
#define WORDL(c0, c1, c2, c3) (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24))
|
#define WORDL(c0, c1, c2, c3) (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24))
|
||||||
#define WORDW(c0, c1) (guint16)(c0 | (c1 << 8))
|
|
||||||
|
|
||||||
#ifdef WIN32 /* for win32 */
|
#ifdef WIN32 /* for win32 */
|
||||||
#define OFLAGS O_BINARY
|
#define OFLAGS O_BINARY
|
||||||
|
@ -109,20 +79,6 @@ void *hexchat_realloc (char *old, int len, char *file, int line);
|
||||||
#define USERNAMELEN 10
|
#define USERNAMELEN 10
|
||||||
#define HIDDEN_CHAR 8 /* invisible character for xtext */
|
#define HIDDEN_CHAR 8 /* invisible character for xtext */
|
||||||
|
|
||||||
#if defined(ENABLE_NLS) && !defined(_)
|
|
||||||
# include <libintl.h>
|
|
||||||
# define _(x) gettext(x)
|
|
||||||
# ifdef gettext_noop
|
|
||||||
# define N_(String) gettext_noop (String)
|
|
||||||
# else
|
|
||||||
# define N_(String) (String)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(_)
|
|
||||||
# define N_(String) (String)
|
|
||||||
# define _(x) (x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct nbexec
|
struct nbexec
|
||||||
{
|
{
|
||||||
int myfd;
|
int myfd;
|
||||||
|
@ -292,6 +248,7 @@ struct hexchatprefs
|
||||||
int hex_gui_search_pos;
|
int hex_gui_search_pos;
|
||||||
int hex_gui_slist_select;
|
int hex_gui_slist_select;
|
||||||
int hex_gui_tab_layout;
|
int hex_gui_tab_layout;
|
||||||
|
int hex_gui_tab_middleclose;
|
||||||
int hex_gui_tab_newtofront;
|
int hex_gui_tab_newtofront;
|
||||||
int hex_gui_tab_pos;
|
int hex_gui_tab_pos;
|
||||||
int hex_gui_tab_small;
|
int hex_gui_tab_small;
|
||||||
|
@ -307,7 +264,7 @@ struct hexchatprefs
|
||||||
int hex_gui_win_state;
|
int hex_gui_win_state;
|
||||||
int hex_gui_win_top;
|
int hex_gui_win_top;
|
||||||
int hex_gui_win_width;
|
int hex_gui_win_width;
|
||||||
int hex_input_balloon_time;
|
int hex_identd_port;
|
||||||
int hex_irc_ban_type;
|
int hex_irc_ban_type;
|
||||||
int hex_irc_join_delay;
|
int hex_irc_join_delay;
|
||||||
int hex_irc_notice_pos;
|
int hex_irc_notice_pos;
|
||||||
|
@ -359,7 +316,6 @@ struct hexchatprefs
|
||||||
guint32 dcc_ip;
|
guint32 dcc_ip;
|
||||||
|
|
||||||
unsigned int wait_on_exit; /* wait for logs to be flushed to disk IF we're connected */
|
unsigned int wait_on_exit; /* wait for logs to be flushed to disk IF we're connected */
|
||||||
unsigned int utf8_locale;
|
|
||||||
|
|
||||||
/* Tells us if we need to save, only when they've been edited.
|
/* Tells us if we need to save, only when they've been edited.
|
||||||
This is so that we continue using internal defaults (which can
|
This is so that we continue using internal defaults (which can
|
||||||
|
@ -412,12 +368,12 @@ typedef struct session
|
||||||
guint8 text_strip;
|
guint8 text_strip;
|
||||||
|
|
||||||
struct server *server;
|
struct server *server;
|
||||||
void *usertree_alpha; /* pure alphabetical tree */
|
tree *usertree; /* alphabetical tree */
|
||||||
void *usertree; /* ordered with Ops first */
|
|
||||||
struct User *me; /* points to myself in the usertree */
|
struct User *me; /* points to myself in the usertree */
|
||||||
char channel[CHANLEN];
|
char channel[CHANLEN];
|
||||||
char waitchannel[CHANLEN]; /* waiting to join channel (/join sent) */
|
char waitchannel[CHANLEN]; /* waiting to join channel (/join sent) */
|
||||||
char willjoinchannel[CHANLEN]; /* will issue /join for this channel */
|
char willjoinchannel[CHANLEN]; /* will issue /join for this channel */
|
||||||
|
char session_name[CHANLEN]; /* the name of the session, should not modified */
|
||||||
char channelkey[64]; /* XXX correct max length? */
|
char channelkey[64]; /* XXX correct max length? */
|
||||||
int limit; /* channel user limit */
|
int limit; /* channel user limit */
|
||||||
int logfd;
|
int logfd;
|
||||||
|
@ -464,14 +420,6 @@ typedef struct session
|
||||||
void (*scrollback_replay_marklast) (struct session *sess);
|
void (*scrollback_replay_marklast) (struct session *sess);
|
||||||
} session;
|
} session;
|
||||||
|
|
||||||
struct msproxy_state_t
|
|
||||||
{
|
|
||||||
gint32 clientid;
|
|
||||||
gint32 serverid;
|
|
||||||
unsigned char seq_recv; /* seq number of last packet recv. */
|
|
||||||
unsigned char seq_sent; /* seq number of last packet sent. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* SASL Mechanisms */
|
/* SASL Mechanisms */
|
||||||
#define MECH_PLAIN 0
|
#define MECH_PLAIN 0
|
||||||
#define MECH_BLOWFISH 1
|
#define MECH_BLOWFISH 1
|
||||||
|
@ -529,9 +477,9 @@ typedef struct server
|
||||||
int proxy_sok; /* Additional information for MS Proxy beast */
|
int proxy_sok; /* Additional information for MS Proxy beast */
|
||||||
int proxy_sok4;
|
int proxy_sok4;
|
||||||
int proxy_sok6;
|
int proxy_sok6;
|
||||||
struct msproxy_state_t msp_state;
|
|
||||||
int id; /* unique ID number (for plugin API) */
|
int id; /* unique ID number (for plugin API) */
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
|
SSL_CTX *ctx;
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
int ssl_do_connect_tag;
|
int ssl_do_connect_tag;
|
||||||
#else
|
#else
|
||||||
|
@ -584,7 +532,10 @@ typedef struct server
|
||||||
time_t ping_recv; /* when we last got a ping reply */
|
time_t ping_recv; /* when we last got a ping reply */
|
||||||
time_t away_time; /* when we were marked away */
|
time_t away_time; /* when we were marked away */
|
||||||
|
|
||||||
char *encoding; /* NULL for system */
|
char *encoding;
|
||||||
|
GIConv read_converter; /* iconv converter for converting from server encoding to UTF-8. */
|
||||||
|
GIConv write_converter; /* iconv converter for converting from UTF-8 to server encoding. */
|
||||||
|
|
||||||
GSList *favlist; /* list of channels & keys to join */
|
GSList *favlist; /* list of channels & keys to join */
|
||||||
|
|
||||||
unsigned int motd_skipped:1;
|
unsigned int motd_skipped:1;
|
||||||
|
@ -617,8 +568,6 @@ typedef struct server
|
||||||
unsigned int have_except:1; /* ban exemptions +e */
|
unsigned int have_except:1; /* ban exemptions +e */
|
||||||
unsigned int have_invite:1; /* invite exemptions +I */
|
unsigned int have_invite:1; /* invite exemptions +I */
|
||||||
unsigned int have_cert:1; /* have loaded a cert */
|
unsigned int have_cert:1; /* have loaded a cert */
|
||||||
unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */
|
|
||||||
unsigned int using_irc:1; /* encoding is "IRC" (CP1252/UTF-8 hybrid)? */
|
|
||||||
unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */
|
unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */
|
||||||
unsigned int sasl_mech; /* mechanism for sasl auth */
|
unsigned int sasl_mech; /* mechanism for sasl auth */
|
||||||
unsigned int sent_saslauth:1; /* have sent AUTHENICATE yet */
|
unsigned int sent_saslauth:1; /* have sent AUTHENICATE yet */
|
||||||
|
@ -661,7 +610,4 @@ struct popup
|
||||||
/* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */
|
/* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */
|
||||||
#define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n)))
|
#define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n)))
|
||||||
|
|
||||||
#define hexchat_filename_from_utf8 g_filename_from_utf8
|
|
||||||
#define hexchat_filename_to_utf8 g_filename_to_utf8
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue