about'>summary'>refslog'>tree'>commit'>diffstats
diff options
context:
space:
mode:
authorBertrand Jacquin (Beber) <beber.mailing@gmail.com>2006-04-30 04:26:18 +0200
committerbeber <beber@meathook.melee>2006-04-30 04:26:18 +0200
commit94b16bcb2059b81b6fd05ab3b62577158d85ed59 (patch)
treead30c013423e308c39ad2c2a3817f3edc895d76e
parentindent macros (diff)
downloadespik-94b16bcb2059b81b6fd05ab3b62577158d85ed59.tar.gz
Rewrite m4 macros to be less bizarre, and make them work in 100 % case.
Add a dependance on readline Some code cleanup Some delete of unused code
-rw-r--r--CMakeLists.txt5
-rw-r--r--configure.in55
-rw-r--r--m4/vl_lib_ecore.m423
-rw-r--r--m4/vl_lib_ecore_con.m423
-rw-r--r--m4/vl_lib_ecore_config.m423
-rw-r--r--m4/vl_lib_readline.m445
-rw-r--r--src/Makefile.am6
-rw-r--r--src/espik.c17
-rw-r--r--src/espik.h20
-rw-r--r--src/espik_common_handler.c38
-rw-r--r--src/espik_net.c1
11 files changed, 144 insertions, 112 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64ea40b..cd0fdb6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,2 +1,7 @@
PROJECT(espik)
SUBDIRS(src)
+
+FIND_PACKAGE(Ecore)
+
+EXEC_PROGRAM(sh/git-version OUTPUT_VARIABLE GIT_VERSION)
+FILE(WRITE config.h $GIT_VERSION)
diff --git a/configure.in b/configure.in
index a1e64b6..202503e 100644
--- a/configure.in
+++ b/configure.in
@@ -21,57 +21,10 @@ AC_C_INLINE
dnl espik specific check (include in m4)
AC_C___ATTRIBUTE__
-AC_ARG_WITH(evas-config,
-[ --with-evas-config=EVAS_CONFIG use evas-config specified ],
-[
- EVAS_CONFIG=$withval;
- echo "using "$EVAS_CONFIG" for evas-config";
-],[
- PROG="evas-config";
- AC_PATH_PROG(EVAS_CONFIG, $PROG, "", $PATH)
-])
-evas_cflags=`$EVAS_CONFIG --cflags`
-evas_libs=`$EVAS_CONFIG --libs`
-AC_SUBST(evas_cflags)
-AC_SUBST(evas_libs)
-
-AC_ARG_WITH(ecore-config,
-[ --with-ecore-config=ECORE_CONFIG use ecore-config specified ],
-[
- ECORE_CONFIG=$withval;
- echo "using "$ECORE_CONFIG" for ecore-config";
-],[
- PROG="ecore-config";
- AC_PATH_PROG(ECORE_CONFIG, $PROG, "", $PATH)
-])
-ecore_cflags=`$ECORE_CONFIG --cflags`
-ecore_libs=`$ECORE_CONFIG --libs`
-AC_SUBST(ecore_cflags)
-AC_SUBST(ecore_libs)
-
-AC_ARG_WITH(edje-config,
-[ --with-edje-config=EDJE_CONFIG use edje-config specified ],
-[
- EDJE_CONFIG=$withval;
- echo "using "$EDJE_CONFIG" for edje-config";
-],[
- PROG="edje-config";
- AC_PATH_PROG(EDJE_CONFIG, $PROG, "", $PATH)
-])
-edje_cflags=`$EDJE_CONFIG --cflags`
-edje_libs=`$EDJE_CONFIG --libs`
-
-edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc"
-AC_ARG_WITH(edje-cc,
-[ --with-edje-cc=PATH specify a specific path to edje_cc],
-[
- v=$withval;
- edje_cc=$v
- echo " Enlightenment edje_cc explicitly set to "$edje_cc;
-],[
- edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc"
-])
-AC_SUBST(edje_cc)
+VL_LIB_READLINE
+VL_LIB_ECORE
+VL_LIB_ECORE_CON
+VL_LIB_ECORE_CONFIG
AC_OUTPUT([
Makefile
diff --git a/m4/vl_lib_ecore.m4 b/m4/vl_lib_ecore.m4
new file mode 100644
index 0000000..0172853
--- /dev/null
+++ b/m4/vl_lib_ecore.m4
@@ -0,0 +1,23 @@
+AC_DEFUN([VL_LIB_ECORE],
+[
+ AC_CACHE_CHECK([for Ecore],
+ vl_cv_lib_ecore,
+ [
+ ORIG_LIBS="$LIBS"
+ TRY_LIBS="-lecore"
+ LIBS="$ORIG_LIBS $TRY_LIBS"
+
+ AC_TRY_LINK_FUNC(ecore_init, vl_cv_lib_ecore="$TRY_LIBS")
+
+ if test -n "$vl_cv_lib_ecore"; then
+ LIBS="$ORIG_LIBS $TRY_LIBS"
+ else
+ LIBS="$ORIG_LIBS"
+ AC_MSG_ERROR([You need Ecore])
+ fi
+ ])
+
+ if test -n "$vl_cv_lib_ecore"; then
+ AC_CHECK_HEADERS(Ecore.h)
+ fi
+])
diff --git a/m4/vl_lib_ecore_con.m4 b/m4/vl_lib_ecore_con.m4
new file mode 100644
index 0000000..b8319b4
--- /dev/null
+++ b/m4/vl_lib_ecore_con.m4
@@ -0,0 +1,23 @@
+AC_DEFUN([VL_LIB_ECORE_CON],
+[
+ AC_CACHE_CHECK([for Ecore_Con],
+ vl_cv_lib_ecore_con,
+ [
+ ORIG_LIBS="$LIBS"
+ TRY_LIBS="-lecore_con"
+ LIBS="$ORIG_LIBS $TRY_LIBS"
+
+ AC_TRY_LINK_FUNC(ecore_con_init, vl_cv_lib_ecore_con="$TRY_LIBS")
+
+ if test -n "$vl_cv_lib_ecore_con"; then
+ LIBS="$ORIG_LIBS $TRY_LIBS"
+ else
+ LIBS="$ORIG_LIBS"
+ AC_MSG_ERROR([You need Ecore_Con])
+ fi
+ ])
+
+ if test -n "$vl_cv_lib_ecore_con"; then
+ AC_CHECK_HEADERS(Ecore_Con.h)
+ fi
+])
diff --git a/m4/vl_lib_ecore_config.m4 b/m4/vl_lib_ecore_config.m4
new file mode 100644
index 0000000..f612371
--- /dev/null
+++ b/m4/vl_lib_ecore_config.m4
@@ -0,0 +1,23 @@
+AC_DEFUN([VL_LIB_ECORE_CONFIG],
+[
+ AC_CACHE_CHECK([for Ecore_Config],
+ vl_cv_lib_ecore_config,
+ [
+ ORIG_LIBS="$LIBS"
+ TRY_LIBS="-lecore_config"
+ LIBS="$ORIG_LIBS $TRY_LIBS"
+
+ AC_TRY_LINK_FUNC(ecore_config_system_init, vl_cv_lib_ecore_config="$TRY_LIBS")
+
+ if test -n "$vl_cv_lib_ecore_config"; then
+ LIBS="$ORIG_LIBS $TRY_LIBS"
+ else
+ LIBS="$ORIG_LIBS"
+ AC_MSG_ERROR([You need Ecore_Config])
+ fi
+ ])
+
+ if test -n "$vl_cv_lib_ecore_config"; then
+ AC_CHECK_HEADERS(Ecore_Config.h)
+ fi
+])
diff --git a/m4/vl_lib_readline.m4 b/m4/vl_lib_readline.m4
new file mode 100644
index 0000000..9c3bbb8
--- /dev/null
+++ b/m4/vl_lib_readline.m4
@@ -0,0 +1,45 @@
+AC_DEFUN([VL_LIB_READLINE],
+[
+ AC_CACHE_CHECK([for readline],
+ vl_cv_lib_readline,
+ [
+ ORIG_LIBS="$LIBS"
+ for readline_lib in readline edit editline; do
+ for termcap_lib in "" termcap curses ncurses; do
+ if test -z "$termcap_lib"; then
+ TRY_LIB="-l$readline_lib"
+ else
+ TRY_LIB="-l$readline_lib -l$termcap_lib"
+ fi
+ LIBS="$ORIG_LIBS $TRY_LIB"
+ AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB")
+ if test -n "$vl_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -n "$vl_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -z "$vl_cv_lib_readline"; then
+ vl_cv_lib_readline="no"
+ LIBS="$ORIG_LIBS"
+ fi
+ ])
+
+ if test "$vl_cv_lib_readline" != "no"; then
+ AC_DEFINE(HAVE_LIBREADLINE, 1,
+ [Define if you have a readline compatible library])
+ AC_CHECK_HEADERS(readline.h readline/readline.h)
+ AC_CACHE_CHECK([whether readline supports history],
+ vl_cv_lib_readline_history, [
+ vl_cv_lib_readline_history="no"
+ AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history="yes")
+ ])
+ if test "$vl_cv_lib_readline_history" = "yes"; then
+ AC_DEFINE(HAVE_READLINE_HISTORY, 1,
+ [Define if your readline library has `add_history'])
+ AC_CHECK_HEADERS(history.h readline/history.h)
+ fi
+ fi
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 5f648b1..6af7dd4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,8 +4,7 @@ AM_CFLAGS = \
-g \
-W -Wall \
-Wdeclaration-after-statement \
- -Wundef -Wold-style-definition \
- @ecore_cflags@
+ -Wundef -Wold-style-definition
ESPIKHEADERS = \
espik.h \
@@ -25,7 +24,4 @@ espik_SOURCES = \
espik_net.c \
$(ESPIKHEADERS)
-espik_LDADD = \
- @ecore_libs@
-
bin_PROGRAMS = espik
diff --git a/src/espik.c b/src/espik.c
index 7f6ef72..96e1032 100644
--- a/src/espik.c
+++ b/src/espik.c
@@ -55,23 +55,6 @@ void espik_shutdown (void)
ecore_main_loop_quit();
}
-/* Use to replace EOL ('\n') with NULL ('\0') */
-int del_backslash (char *msg)
-{
- int i, count;
-
- for (i = 0, count = 0 ; msg[i] ; i++)
- {
- if (msg[i] == '\n')
- {
- msg[i] = '\0';
- count++;
- }
- }
-
- return (count);
-}
-
int main (int argc, char **argv)
{
Ecore_Fd_Handler *fd_kb;
diff --git a/src/espik.h b/src/espik.h
index 8ada989..d37a2b9 100644
--- a/src/espik.h
+++ b/src/espik.h
@@ -5,29 +5,27 @@
typedef struct
{
- char* host;
- unsigned short port;
+ char *host;
+ unsigned short port;
} t_servinfo;
typedef struct
{
- char* nickname;
- char* username;
- char* realname; /* gecos */
+ char *nickname;
+ char *username;
+ char *realname; /* gecos */
} t_userinfo;
typedef struct
{
- t_servinfo* server;
- t_userinfo* client;
+ t_servinfo *server;
+ t_userinfo *client;
} t_info;
-t_info a_infos;
+t_info a_infos;
Ecore_List *ptr_list;
void espik_free (void*);
-int del_backslash (char*);
-void espik_shutdown();
-int main (int, char**);
+void espik_shutdown ();
#endif /* ESPIK_H */
diff --git a/src/espik_common_handler.c b/src/espik_common_handler.c
index 479babd..db5780f 100644
--- a/src/espik_common_handler.c
+++ b/src/espik_common_handler.c
@@ -5,6 +5,8 @@
#include <Ecore.h>
+#include <readline/readline.h>
+
#include "espik_global.h"
#include "espik.h"
#include "espik_error.h"
@@ -15,11 +17,11 @@
static int count_num_recv = 0;
-int server_data (void* data __UNUSED__, int ev_type __UNUSED__,
- Ecore_Con_Event_Server_Data* ev)
+int server_data (void *data __UNUSED__, int ev_type __UNUSED__,
+ Ecore_Con_Event_Server_Data *ev)
{
- unsigned int i;
- char* msg;
+ unsigned int i;
+ char *msg;
msg = strdup((char*)ev->data);
//msg = convert_unicode_utf((const wchar_t*)ev->data);
@@ -53,37 +55,19 @@ int server_data (void* data __UNUSED__, int ev_type __UNUSED__,
return (0);
}
-int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
+int kb_get (void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
{
- char kb[INPUT_LENGHT];
- int count;
+ char *kb;
- do
- {
- memset (kb, 0, INPUT_LENGHT);
- count = read (ecore_main_fd_handler_fd_get (fd_handler), kb,
- INPUT_LENGHT - 2);
-
- if (count > 1)
- {
- del_backslash (kb);
- printf ("%s", kb);
- }
- }
- while (count >= INPUT_LENGHT - 2);
+ kb = readline ("> ");
- if (count == -1)
+ if (!kb)
{
- perror ("read");
espik_shutdown();
return (0);
}
- if (count == 0)
- {
- espik_shutdown();
- return (0);
- }
+ printf ("%s\n", kb);
return (1);
}
diff --git a/src/espik_net.c b/src/espik_net.c
index 67fd9af..b525811 100644
--- a/src/espik_net.c
+++ b/src/espik_net.c
@@ -126,7 +126,6 @@ void espik_con_shutdown (void)
void espik_raw_send (const char *msg)
{
buf_t buf;
- int i;
buf = make_buffer (strlen(msg) + 1); /* <MESSAGE>\r\n\0" */