From 648b51f417b79c0407580b2a60ad915dc9fafcda Mon Sep 17 00:00:00 2001 From: Kaian Date: Mon, 23 Feb 2015 23:31:11 +0100 Subject: [PATCH 1/2] Add support for wide character ncurses. #26 --- configure.ac | 8 ++++---- src/ui_manager.c | 3 +++ src/ui_manager.h | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index c591090..e14bf75 100644 --- a/configure.ac +++ b/configure.ac @@ -33,19 +33,19 @@ AC_CHECK_HEADER([ncurses.h], [], [ AC_MSG_ERROR([ You need to have ncurses development files installed to compile sngrep.]) ]) -AC_CHECK_LIB([ncurses], [initscr], [], [ +AC_CHECK_LIB([ncursesw], [initscr], [], [ AC_MSG_ERROR([ You need to have libncurses installed to compile sngrep.]) ]) -AC_CHECK_LIB([panel], [new_panel], [], [ +AC_CHECK_LIB([panelw], [new_panel], [], [ AC_MSG_ERROR([ You need to have ncurses panel library installed to compile sngrep.]) ]) -AC_CHECK_LIB([form], [new_form], [], [ +AC_CHECK_LIB([formw], [new_form], [], [ AC_MSG_ERROR([ You need to have ncurses forms library installed to compile sngrep.]) ]) -AC_CHECK_LIB([menu], [new_item], [], [ +AC_CHECK_LIB([menuw], [new_item], [], [ AC_MSG_ERROR([ You need to have ncurses menu library installed to compile sngrep.]) ]) diff --git a/src/ui_manager.c b/src/ui_manager.c index 4c05be4..65ae38e 100644 --- a/src/ui_manager.c +++ b/src/ui_manager.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "option.h" #include "ui_manager.h" #include "ui_call_list.h" @@ -122,6 +123,8 @@ int init_interface() { int bg, fg; + // Set Locale + setlocale(LC_CTYPE, ""); // Initialize curses if (!initscr()) { diff --git a/src/ui_manager.h b/src/ui_manager.h index c26275a..95fa35a 100644 --- a/src/ui_manager.h +++ b/src/ui_manager.h @@ -35,8 +35,8 @@ */ #ifndef __SNGREP_UI_MANAGER_H #define __SNGREP_UI_MANAGER_H - -#include +#define _X_OPEN_SOURCE_EXTENDED +#include #include #include "sip.h" #include "group.h" From 930b07eb71b337e038e6d995c8fa39465c406ea3 Mon Sep 17 00:00:00 2001 From: Kaian Date: Tue, 24 Feb 2015 15:32:54 +0100 Subject: [PATCH 2/2] Make Unicode support a configurable feature. #26 --- configure.ac | 69 +++++++++++++++++++++++++++++++++++------------- src/ui_manager.h | 4 +++ 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index e14bf75..bcbea32 100644 --- a/configure.ac +++ b/configure.ac @@ -33,20 +33,50 @@ AC_CHECK_HEADER([ncurses.h], [], [ AC_MSG_ERROR([ You need to have ncurses development files installed to compile sngrep.]) ]) -AC_CHECK_LIB([ncursesw], [initscr], [], [ - AC_MSG_ERROR([ You need to have libncurses installed to compile sngrep.]) -]) +# Check for Ncurses Wide character support +AC_ARG_ENABLE([unicode], + AC_HELP_STRING([--enable-unicode], [Enable Ncurses Unicode support]), + [AC_SUBST(UNICODE, $enableval)], + [AC_SUBST(UNICODE, no)] +) -AC_CHECK_LIB([panelw], [new_panel], [], [ - AC_MSG_ERROR([ You need to have ncurses panel library installed to compile sngrep.]) -]) +AS_IF([test "x$enable_unicode" == "xyes"], [ + # Ncurses with wide-character support + AC_DEFINE([WITH_UNICODE], [], [Compile With Unicode compatibility]) -AC_CHECK_LIB([formw], [new_form], [], [ - AC_MSG_ERROR([ You need to have ncurses forms library installed to compile sngrep.]) -]) + AC_CHECK_LIB([ncursesw], [initscr], [], [ + AC_MSG_ERROR([ You need to have libncursesw installed to compile sngrep.]) + ]) -AC_CHECK_LIB([menuw], [new_item], [], [ - AC_MSG_ERROR([ You need to have ncurses menu library installed to compile sngrep.]) + AC_CHECK_LIB([panelw], [new_panel], [], [ + AC_MSG_ERROR([ You need to have ncurses panelw library installed to compile sngrep.]) + ]) + + AC_CHECK_LIB([formw], [new_form], [], [ + AC_MSG_ERROR([ You need to have ncurses formsw library installed to compile sngrep.]) + ]) + + AC_CHECK_LIB([menuw], [new_item], [], [ + AC_MSG_ERROR([ You need to have ncurses menuw library installed to compile sngrep.]) + ]) + ], [ + + # Ncurses without wide-character support + AC_CHECK_LIB([ncurses], [initscr], [], [ + AC_MSG_ERROR([ You need to have libncurses installed to compile sngrep.]) + ]) + + AC_CHECK_LIB([panel], [new_panel], [], [ + AC_MSG_ERROR([ You need to have ncurses panel library installed to compile sngrep.]) + ]) + + AC_CHECK_LIB([form], [new_form], [], [ + AC_MSG_ERROR([ You need to have ncurses forms library installed to compile sngrep.]) + ]) + + AC_CHECK_LIB([menu], [new_item], [], [ + AC_MSG_ERROR([ You need to have ncurses menu library installed to compile sngrep.]) + ]) ]) AC_CHECK_LIB([pthread], [pthread_create], [], [ @@ -62,8 +92,11 @@ AC_CHECK_HEADER([pcap.h], [], [ # Check for SSL dependencies AC_ARG_ENABLE([openssl], - AC_HELP_STRING([--disable-openssl], [Disable TLS SIP Transport])) - + AC_HELP_STRING([--disable-openssl], [Disable SSL Support (TLS SIP Transport)]), + [AC_SUBST(OPENSSL, $enableval)], + [AC_SUBST(OPENSSL, yes)] +) + AS_IF([test "x$enable_openssl" != "xno"], [ AC_CHECK_LIB([ssl], [SSL_new], [], [ @@ -105,12 +138,12 @@ if test "x${silent}" != "xyes" ; then echo fi - AC_MSG_NOTICE -AC_MSG_NOTICE( ====================================================== ) -AC_MSG_NOTICE( sngrep configure finished ) -AC_MSG_NOTICE( ---------------------------------------------------- ) -AC_MSG_NOTICE( ====================================================== ) +AC_MSG_NOTICE( sngrep configure finished ) +AC_MSG_NOTICE( ====================================================== ) +AC_MSG_NOTICE( OpenSSL Support : ${OPENSSL} ) +AC_MSG_NOTICE( Unicode Support : ${UNICODE} ) +AC_MSG_NOTICE( ====================================================== ) AC_MSG_NOTICE diff --git a/src/ui_manager.h b/src/ui_manager.h index 95fa35a..d38562b 100644 --- a/src/ui_manager.h +++ b/src/ui_manager.h @@ -35,8 +35,12 @@ */ #ifndef __SNGREP_UI_MANAGER_H #define __SNGREP_UI_MANAGER_H +#ifdef WITH_UNICODE #define _X_OPEN_SOURCE_EXTENDED #include +#else +#include +#endif #include #include "sip.h" #include "group.h"