* refactoring: split src/ into mu/ and lib/

This commit is contained in:
djcb 2012-05-20 17:41:18 +03:00
parent 605657d4de
commit 46f10cfde9
143 changed files with 160 additions and 279 deletions

View File

@ -35,7 +35,7 @@ else
emacs= emacs=
endif endif
SUBDIRS=m4 man src $(widgets) $(guile) $(emacs) contrib toys SUBDIRS=m4 man lib $(widgets) $(guile) mu $(emacs) contrib toys
ACLOCAL_AMFLAGS=-I m4 ACLOCAL_AMFLAGS=-I m4

View File

@ -16,7 +16,7 @@
AC_INIT([mu],[0.9.8.5-dev2],[http://code.google.com/p/mu0/issues/list],[mu]) AC_INIT([mu],[0.9.8.5-dev2],[http://code.google.com/p/mu0/issues/list],[mu])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([src/mu.cc]) AC_CONFIG_SRCDIR([mu/mu.cc])
# libtoolize wants to put some stuff in here; if you have an old # libtoolize wants to put some stuff in here; if you have an old
# autotools/libtool setup. you can try to comment this out # autotools/libtool setup. you can try to comment this out
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
@ -291,8 +291,10 @@ AS_IF([test "x$PMCCABE" = "xno"],[
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile
src/Makefile mu/Makefile
src/tests/Makefile mu/tests/Makefile
lib/Makefile
lib/tests/Makefile
widgets/Makefile widgets/Makefile
emacs/Makefile emacs/Makefile
emacs/mu4e-meta.el emacs/mu4e-meta.el

View File

@ -25,7 +25,7 @@ AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
# note, we need top_builddir for snarfing with 'make distcheck' (ie., # note, we need top_builddir for snarfing with 'make distcheck' (ie.,
# with separate builddir) # with separate builddir)
SUBDIRS= . mu examples SUBDIRS= . mu examples
INCLUDES=-I. -I${top_builddir} -I${top_srcdir}/src ${GUILE_CFLAGS} ${GLIB_CFLAGS} INCLUDES=-I. -I${top_builddir} -I${top_srcdir}/lib ${GUILE_CFLAGS} ${GLIB_CFLAGS}
# don't use -Werror, as it might break on other compilers # don't use -Werror, as it might break on other compilers
# use -Wno-unused-parameters, because some callbacks may not # use -Wno-unused-parameters, because some callbacks may not
@ -41,7 +41,7 @@ libguile_mu_la_SOURCES= \
mu-guile-message.h mu-guile-message.h
libguile_mu_la_LIBADD= \ libguile_mu_la_LIBADD= \
${top_builddir}/src/libmu.la \ ${top_builddir}/lib/libmu.la \
${GUILE_LIBS} ${GUILE_LIBS}
XFILES= \ XFILES= \

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2011-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** 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 ** under the terms of the GNU General Public License as published by the

View File

@ -32,32 +32,12 @@ INCLUDES=$(XAPIAN_CXXFLAGS) $(GMIME_CFLAGS) $(GLIB_CFLAGS)
AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement -pedantic -Wno-variadic-macros AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement -pedantic -Wno-variadic-macros
AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
bin_PROGRAMS= \
mu
noinst_LTLIBRARIES= \ noinst_LTLIBRARIES= \
libmu.la libmu.la
# note, mu.cc is only '.cc' and not '.c' because libmu must explicitly
# be linked as c++, not c.
mu_SOURCES= \
mu.cc
mu_LDADD= \
libmu.la
libmu_la_SOURCES= \ libmu_la_SOURCES= \
mu-bookmarks.c \ mu-bookmarks.c \
mu-bookmarks.h \ mu-bookmarks.h \
mu-cmd-cfind.c \
mu-cmd-extract.c \
mu-cmd-find.c \
mu-cmd-index.c \
mu-cmd-server.c \
mu-cmd.c \
mu-cmd.h \
mu-config.c \
mu-config.h \
mu-contacts.c \ mu-contacts.c \
mu-contacts.h \ mu-contacts.h \
mu-container.c \ mu-container.c \

View File

@ -229,6 +229,15 @@ struct _PartInfo {
typedef struct _PartInfo PartInfo; typedef struct _PartInfo PartInfo;
/* like the elvis operator,
* http://colinharrington.net/blog/2008/10/groovy-elvis-operator/
*/
static const char*
elvis (const char *s1, const char *s2)
{
return s1 ? s1 : s2;
}
static void static void
each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo) each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
{ {
@ -236,34 +245,31 @@ each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
char *name, *tmp; char *name, *tmp;
char *tmpfile; char *tmpfile;
fname = mu_msg_part_file_name (part); if (!(fname = mu_msg_part_file_name (part)))
if (!fname)
fname = mu_msg_part_description (part); fname = mu_msg_part_description (part);
if (fname) if (fname)
name = mu_str_escape_c_literal (fname, TRUE); name = mu_str_escape_c_literal (fname, TRUE);
else else
name = g_strdup_printf name = g_strdup_printf ("\"%s-%s-%d\"",
("\"%s-%s-%d\"", elvis (part->type, "application"),
part->type ? part->type : "application", elvis (part->subtype, "octet-stream"),
part->subtype ? part->subtype : "octet-stream", part->index);
part->index);
tmpfile = NULL; tmpfile = NULL;
if (pinfo->want_images && g_ascii_strcasecmp (part->type, "image") == 0) { if (pinfo->want_images && g_ascii_strcasecmp (part->type, "image") == 0) {
char *tmp; char *tmp;
tmp = get_temp_file (msg, part->index); if ((tmp = get_temp_file (msg, part->index))) {
if (tmp) {
tmpfile = mu_str_escape_c_literal (tmp, TRUE); tmpfile = mu_str_escape_c_literal (tmp, TRUE);
g_free (tmp); g_free (tmp);
} }
} }
tmp = g_strdup_printf tmp = g_strdup_printf
("%s(:index %d :name %s :mime-type \"%s/%s\"%s%s :attachment %s :size %i)", ("%s(:index %d :name %s :mime-type \"%s/%s\"%s%s "
pinfo->parts ? pinfo->parts : "", part->index, name, ":attachment %s :size %i)",
part->type ? part->type : "application", elvis (pinfo->parts, ""), part->index, name,
part->subtype ? part->subtype : "octet-stream", elvis (part->type, "application"),
elvis (part->subtype, "octet-stream"),
tmpfile ? " :temp" : "", tmpfile ? tmpfile : "", tmpfile ? " :temp" : "", tmpfile ? tmpfile : "",
mu_msg_part_looks_like_attachment (part, TRUE) ? "t" : "nil", mu_msg_part_looks_like_attachment (part, TRUE) ? "t" : "nil",
(int)part->size); (int)part->size);
@ -338,10 +344,6 @@ mu_msg_to_sexp (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti,
if (docid != 0) if (docid != 0)
g_string_append_printf (gstr, "\t:docid %u\n", docid); g_string_append_printf (gstr, "\t:docid %u\n", docid);
if (!header_only) /* force loading of file... should do this a bit
* more elegantly */
mu_msg_get_header (msg, "Reply-To");
append_sexp_contacts (gstr, msg); append_sexp_contacts (gstr, msg);
if (ti) if (ti)
@ -351,8 +353,7 @@ mu_msg_to_sexp (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti,
t = mu_msg_get_date (msg); t = mu_msg_get_date (msg);
/* weird time format for emacs 29-bit ints...*/ /* weird time format for emacs 29-bit ints...*/
g_string_append_printf (gstr, g_string_append_printf (gstr,"\t:date (%u %u 0)\n", (unsigned)(t >> 16),
"\t:date (%u %u 0)\n", (unsigned)(t >> 16),
(unsigned)(t & 0xffff)); (unsigned)(t & 0xffff));
g_string_append_printf (gstr, "\t:size %u\n", g_string_append_printf (gstr, "\t:size %u\n",
(unsigned) mu_msg_get_size (msg)); (unsigned) mu_msg_get_size (msg));
@ -366,7 +367,6 @@ mu_msg_to_sexp (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti,
append_sexp_flags (gstr, msg); append_sexp_flags (gstr, msg);
/* headers are retrieved from the database, views from the message file /* headers are retrieved from the database, views from the message file
*
* file attr things can only be gotten from the file (ie., mu * file attr things can only be gotten from the file (ie., mu
* view), not from the database (mu find). */ * view), not from the database (mu find). */
if (!header_only) { if (!header_only) {
@ -375,6 +375,5 @@ mu_msg_to_sexp (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti,
} }
g_string_append (gstr, ")\n"); g_string_append (gstr, ")\n");
return g_string_free (gstr, FALSE); return g_string_free (gstr, FALSE);
} }

View File

@ -26,9 +26,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <mu-msg.h> #include "mu-msg.h"
#include "mu-config.h"
#include "mu-log.h" #include "mu-log.h"
#include "mu-util.h" #include "mu-util.h"
@ -41,7 +39,6 @@
struct _MuRuntimeData { struct _MuRuntimeData {
gchar *_str[MU_RUNTIME_PATH_NUM]; gchar *_str[MU_RUNTIME_PATH_NUM];
MuConfig *_config;
gchar *_name; /* e.g., 'mu', 'mug' */ gchar *_name; /* e.g., 'mu', 'mug' */
}; };
typedef struct _MuRuntimeData MuRuntimeData; typedef struct _MuRuntimeData MuRuntimeData;
@ -116,48 +113,6 @@ mu_runtime_init (const char* muhome_arg, const char *name)
return _initialized = TRUE; return _initialized = TRUE;
} }
gboolean
mu_runtime_init_from_cmdline (int *pargc, char ***pargv, const char *name)
{
g_return_val_if_fail (!_initialized, FALSE);
g_return_val_if_fail (name, FALSE);
setlocale (LC_ALL, "");
g_type_init ();
_data = g_new0 (MuRuntimeData, 1);
_data->_config = mu_config_init (pargc, pargv);
if (!_data->_config) {
runtime_free ();
return FALSE;
}
if (!mu_util_create_dir_maybe (_data->_config->muhome, 0700, TRUE)) {
g_printerr ("mu: invalid mu homedir specified;"
" use --muhome=<dir>\n");
runtime_free ();
return FALSE;
}
_data->_name = g_strdup (name);
_data->_str[MU_RUNTIME_PATH_MUHOME] =
g_strdup (_data->_config->muhome);
init_paths (_data->_str[MU_RUNTIME_PATH_MUHOME], _data);
if (!init_log (runtime_path(MU_RUNTIME_PATH_MUHOME), name,
_data->_config->log_stderr,
_data->_config->quiet,
_data->_config->debug)) {
runtime_free ();
return FALSE;
}
return _initialized = TRUE;
}
static void static void
runtime_free (void) runtime_free (void)
{ {
@ -168,7 +123,7 @@ runtime_free (void)
g_free (_data->_name); g_free (_data->_name);
mu_config_uninit (_data->_config); /* mu_config_uninit (_data->_config); */
mu_log_uninit(); mu_log_uninit();
@ -252,10 +207,3 @@ mu_runtime_path (MuRuntimePath path)
return runtime_path (path); return runtime_path (path);
} }
MuConfig*
mu_runtime_config (void)
{
g_return_val_if_fail (_initialized, NULL);
return _data->_config;
}

View File

@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
** **
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
@ -21,18 +21,17 @@
#define __MU_RUNTIME_H__ #define __MU_RUNTIME_H__
#include <glib.h> #include <glib.h>
#include <mu-config.h>
G_BEGIN_DECLS G_BEGIN_DECLS
/** /**
* initialize the mu runtime system; initializes logging and other * initialize the mu runtime system; initializes logging and other
* systems. To uninitialize, use mu_runtime_uninit * systems. To uninitialize, use mu_runtime_uninit
* *
* @param muhome path where to find the mu home directory (typicaly, ~/.mu) * @param muhome path where to find the mu home directory (typicaly, ~/.mu)
* @param name of the main program, ie. 'mu', 'mug' or * @param name of the main program, ie. 'mu', 'mug' or
* 'procmule'. this influences the name of the e.g. the logfile * 'procmule'. this influences the name of the e.g. the logfile
* *
* @return TRUE if succeeded, FALSE in case of error * @return TRUE if succeeded, FALSE in case of error
*/ */
gboolean mu_runtime_init (const char *muhome, const char *name); gboolean mu_runtime_init (const char *muhome, const char *name);
@ -43,12 +42,12 @@ gboolean mu_runtime_init (const char *muhome, const char *name);
* will parse the command line assuming the parameters of the 'mu' * will parse the command line assuming the parameters of the 'mu'
* program. Initializes logging and other systems. To uninitialize, * program. Initializes logging and other systems. To uninitialize,
* use mu_runtime_uninit * use mu_runtime_uninit
* *
* @param ptr to the param count (typically, argc) * @param ptr to the param count (typically, argc)
* @param ptr to the params (typically, argv) * @param ptr to the params (typically, argv)
* @param name of the main program, ie. 'mu', 'mug' or * @param name of the main program, ie. 'mu', 'mug' or
* 'procmule'. this influences the name of the e.g. the logfile * 'procmule'. this influences the name of the e.g. the logfile
* *
* @return TRUE if succeeded, FALSE in case of error * @return TRUE if succeeded, FALSE in case of error
*/ */
gboolean mu_runtime_init_from_cmdline (int *pargc, char ***pargv, gboolean mu_runtime_init_from_cmdline (int *pargc, char ***pargv,
@ -56,8 +55,8 @@ gboolean mu_runtime_init_from_cmdline (int *pargc, char ***pargv,
/** /**
* free all resources * free all resources
* *
*/ */
void mu_runtime_uninit (void); void mu_runtime_uninit (void);
@ -76,21 +75,12 @@ typedef enum _MuRuntimePath MuRuntimePath;
/** /**
* get a file system path to some 'special' file or directory * get a file system path to some 'special' file or directory
* *
* @return ma string which should be not be modified/freed, or NULL in * @return ma string which should be not be modified/freed, or NULL in
* case of error. * case of error.
*/ */
const char* mu_runtime_path (MuRuntimePath path); const char* mu_runtime_path (MuRuntimePath path);
/**
* get the mu configuration options (ie., the parsed command line
* parameters)
*
* @return the configuration options
*/
MuConfig* mu_runtime_config (void);
G_END_DECLS G_END_DECLS
#endif /*__MU_RUNTIME_H__*/ #endif /*__MU_RUNTIME_H__*/

View File

@ -25,8 +25,8 @@
#include <time.h> #include <time.h>
#include <sys/types.h> #include <sys/types.h>
#include <mu-msg.h> #include "lib/mu-msg.h"
#include <mu-flags.h> #include "lib/mu-flags.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -19,11 +19,11 @@ include $(top_srcdir)/gtest.mk
INCLUDES=$(XAPIAN_CXXFLAGS) \ INCLUDES=$(XAPIAN_CXXFLAGS) \
$(GMIME_CFLAGS) \ $(GMIME_CFLAGS) \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
-I ${top_srcdir} -I ${top_srcdir}/src \ -I ${top_srcdir} \
-I ${top_srcdir}/lib \
-DMU_TESTMAILDIR=\"${abs_srcdir}/testdir\" \ -DMU_TESTMAILDIR=\"${abs_srcdir}/testdir\" \
-DMU_TESTMAILDIR2=\"${abs_srcdir}/testdir2\" \ -DMU_TESTMAILDIR2=\"${abs_srcdir}/testdir2\" \
-DMU_TESTMAILDIR3=\"${abs_srcdir}/testdir3\" \ -DMU_TESTMAILDIR3=\"${abs_srcdir}/testdir3\" \
-DMU_PROGRAM=\"${abs_top_builddir}/src/mu\" \
-DABS_CURDIR=\"${abs_builddir}\" \ -DABS_CURDIR=\"${abs_builddir}\" \
-DABS_SRCDIR=\"${abs_srcdir}\" -DABS_SRCDIR=\"${abs_srcdir}\"
@ -53,39 +53,14 @@ TEST_PROGS += test-mu-msg-fields
test_mu_msg_fields_SOURCES= test-mu-msg-fields.c dummy.cc test_mu_msg_fields_SOURCES= test-mu-msg-fields.c dummy.cc
test_mu_msg_fields_LDADD= libtestmucommon.la test_mu_msg_fields_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-query
test_mu_query_SOURCES= test-mu-query.c dummy.cc
test_mu_query_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-contacts
test_mu_contacts_SOURCES= test-mu-contacts.c dummy.cc
test_mu_contacts_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-cmd
test_mu_cmd_SOURCES= test-mu-cmd.c dummy.cc
test_mu_cmd_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-cmd-cfind
test_mu_cmd_cfind_SOURCES= test-mu-cmd-cfind.c dummy.cc
test_mu_cmd_cfind_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-msg TEST_PROGS += test-mu-msg
test_mu_msg_SOURCES= test-mu-msg.c dummy.cc test_mu_msg_SOURCES= test-mu-msg.c dummy.cc
test_mu_msg_LDADD= libtestmucommon.la test_mu_msg_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-runtime
test_mu_runtime_SOURCES= test-mu-runtime.c dummy.cc
test_mu_runtime_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-store TEST_PROGS += test-mu-store
test_mu_store_SOURCES= test-mu-store.c dummy.cc test_mu_store_SOURCES= test-mu-store.c dummy.cc
test_mu_store_LDADD= libtestmucommon.la test_mu_store_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-threads
test_mu_threads_SOURCES= test-mu-threads.c dummy.cc
test_mu_threads_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-date TEST_PROGS += test-mu-date
test_mu_date_SOURCES= test-mu-date.c dummy.cc test_mu_date_SOURCES= test-mu-date.c dummy.cc
test_mu_date_LDADD= libtestmucommon.la test_mu_date_LDADD= libtestmucommon.la
@ -94,22 +69,27 @@ TEST_PROGS += test-mu-flags
test_mu_flags_SOURCES= test-mu-flags.c dummy.cc test_mu_flags_SOURCES= test-mu-flags.c dummy.cc
test_mu_flags_LDADD= libtestmucommon.la test_mu_flags_LDADD= libtestmucommon.la
# we need to use dummy.cc to enforce c++ linking...
BUILT_SOURCES= \
dummy.cc
dummy.cc:
touch dummy.cc
# TEST_PROGS += test-mu-msg-file
# test_mu_msg_file_SOURCES= test-mu-msg-file.c dummy.cc
# test_mu_msg_file_LDADD= libtestmucommon.la
#
libtestmucommon_la_SOURCES= \ libtestmucommon_la_SOURCES= \
test-mu-common.c \ test-mu-common.c \
test-mu-common.h test-mu-common.h
libtestmucommon_la_LIBADD= ../libmu.la libtestmucommon_la_LIBADD= ../libmu.la
# note the question marks; make does not like files with ':', so we # note the question marks; make does not like files with ':', so we
# use the (also supported) version with '!' instead. We could escape # use the (also supported) version with '!' instead. We could escape
# the : with \: but automake does not recognize that.... # the : with \: but automake does not recognize that....
# 12 messages, the '.ignore' message should be ignored # test messages, the '.ignore' message should be ignored
# when indexing # when indexing
EXTRA_DIST= \ EXTRA_DIST= \
testdir/tmp/1220863087.12663.ignore \ testdir/tmp/1220863087.12663.ignore \
@ -145,30 +125,4 @@ EXTRA_DIST= \
testdir2/Foo/new/.noindex \ testdir2/Foo/new/.noindex \
testdir2/wom_bat/cur/atomic \ testdir2/wom_bat/cur/atomic \
testdir2/wom_bat/cur/rfc822.1 \ testdir2/wom_bat/cur/rfc822.1 \
testdir2/wom_bat/cur/rfc822.2 \ testdir2/wom_bat/cur/rfc822.2
testdir3/tree \
testdir3/tree/new \
testdir3/tree/new/.noindex \
testdir3/tree/cur \
testdir3/tree/cur/child0.1 \
testdir3/tree/cur/root1 \
testdir3/tree/cur/child3.0.0.0.0 \
testdir3/tree/cur/child0.0 \
testdir3/tree/cur/child4.1 \
testdir3/tree/cur/child4.0 \
testdir3/tree/cur/root2 \
testdir3/tree/cur/child0.1.0 \
testdir3/tree/cur/child2.0.0 \
testdir3/tree/cur/root0 \
testdir3/tree/tmp \
testdir3/tree/tmp/.noindex \
testdir3/cycle \
testdir3/cycle/new \
testdir3/cycle/new/.noindex \
testdir3/cycle/cur \
testdir3/cycle/cur/rogue0 \
testdir3/cycle/cur/cycle0 \
testdir3/cycle/cur/cycle0.0.0 \
testdir3/cycle/cur/cycle0.0 \
testdir3/cycle/tmp \
testdir3/cycle/tmp/.noindex

View File

@ -1,6 +1,6 @@
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/ /* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
/* /*
** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
@ -15,8 +15,8 @@
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, ** along with this program; if not, write to the Free Software Foundation,
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
** **
*/ */
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@ -31,7 +31,7 @@
#include <locale.h> #include <locale.h>
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-date.h" #include "mu-date.h"
static void static void
@ -41,7 +41,7 @@ test_mu_date_str (void)
char buf[64]; char buf[64];
gchar *tmp; gchar *tmp;
time_t some_time; time_t some_time;
some_time = 1234567890; some_time = 1234567890;
tmbuf = localtime (&some_time); tmbuf = localtime (&some_time);
strftime (buf, 64, "%x", tmbuf); strftime (buf, 64, "%x", tmbuf);
@ -54,9 +54,9 @@ test_mu_date_str (void)
tmbuf = localtime (&some_time); tmbuf = localtime (&some_time);
strftime (buf, 64, "%c", tmbuf); strftime (buf, 64, "%c", tmbuf);
tmp = mu_date_str ("%c", some_time); tmp = mu_date_str ("%c", some_time);
g_assert_cmpstr (tmp, ==, buf); g_assert_cmpstr (tmp, ==, buf);
g_free (tmp); g_free (tmp);
} }
@ -73,7 +73,7 @@ test_mu_date_parse_hdwmy (void)
diff = time(NULL) - mu_date_parse_hdwmy ("5y"); diff = time(NULL) - mu_date_parse_hdwmy ("5y");
g_assert (diff > 0); g_assert (diff > 0);
g_assert_cmpuint (5 * 365 * 24 * 60 * 60 - diff, <=, 1); g_assert_cmpuint (5 * 365 * 24 * 60 * 60 - diff, <=, 1);
diff = time(NULL) - mu_date_parse_hdwmy ("3m"); diff = time(NULL) - mu_date_parse_hdwmy ("3m");
g_assert (diff > 0); g_assert (diff > 0);
g_assert_cmpuint (3 * 30 * 24 * 60 * 60 - diff, <=, 1); g_assert_cmpuint (3 * 30 * 24 * 60 * 60 - diff, <=, 1);
@ -81,13 +81,13 @@ test_mu_date_parse_hdwmy (void)
diff = time(NULL) - mu_date_parse_hdwmy ("21d"); diff = time(NULL) - mu_date_parse_hdwmy ("21d");
g_assert (diff > 0); g_assert (diff > 0);
g_assert_cmpuint (21 * 24 * 60 * 60 - diff, <=, 1); g_assert_cmpuint (21 * 24 * 60 * 60 - diff, <=, 1);
diff = time(NULL) - mu_date_parse_hdwmy ("2w"); diff = time(NULL) - mu_date_parse_hdwmy ("2w");
g_assert (diff > 0); g_assert (diff > 0);
g_assert_cmpuint (2 * 7 * 24 * 60 * 60 - diff, <=, 1); g_assert_cmpuint (2 * 7 * 24 * 60 * 60 - diff, <=, 1);
g_assert_cmpint (mu_date_parse_hdwmy("-1y"),==, (time_t)-1); g_assert_cmpint (mu_date_parse_hdwmy("-1y"),==, (time_t)-1);
} }
@ -95,9 +95,9 @@ static void
test_mu_date_complete_begin (void) test_mu_date_complete_begin (void)
{ {
g_assert_cmpstr (mu_date_complete_s("2000", TRUE), ==, g_assert_cmpstr (mu_date_complete_s("2000", TRUE), ==,
"20000101000000"); "20000101000000");
g_assert_cmpstr (mu_date_complete_s("2", TRUE), ==, g_assert_cmpstr (mu_date_complete_s("2", TRUE), ==,
"20000101000000"); "20000101000000");
g_assert_cmpstr (mu_date_complete_s ("", TRUE), ==, g_assert_cmpstr (mu_date_complete_s ("", TRUE), ==,
"00000101000000"); "00000101000000");
g_assert_cmpstr (mu_date_complete_s ("201007", TRUE), ==, g_assert_cmpstr (mu_date_complete_s ("201007", TRUE), ==,
@ -113,9 +113,9 @@ static void
test_mu_date_complete_end (void) test_mu_date_complete_end (void)
{ {
g_assert_cmpstr (mu_date_complete_s ("2000", FALSE), ==, g_assert_cmpstr (mu_date_complete_s ("2000", FALSE), ==,
"20001231235959"); "20001231235959");
g_assert_cmpstr (mu_date_complete_s ("2", FALSE), ==, g_assert_cmpstr (mu_date_complete_s ("2", FALSE), ==,
"29991231235959"); "29991231235959");
g_assert_cmpstr (mu_date_complete_s ("", FALSE), ==, g_assert_cmpstr (mu_date_complete_s ("", FALSE), ==,
"99991231235959"); "99991231235959");
g_assert_cmpstr (mu_date_complete_s ("201007", FALSE), ==, g_assert_cmpstr (mu_date_complete_s ("201007", FALSE), ==,
@ -134,7 +134,7 @@ test_mu_date_interpret_begin (void)
{ {
time_t now; time_t now;
now = time (NULL); now = time (NULL);
g_assert_cmpstr (mu_date_interpret_s ("now", TRUE) , ==, g_assert_cmpstr (mu_date_interpret_s ("now", TRUE) , ==,
mu_date_str_s("%Y%m%d%H%M%S", now)); mu_date_str_s("%Y%m%d%H%M%S", now));
@ -147,7 +147,7 @@ test_mu_date_interpret_end (void)
{ {
time_t now; time_t now;
now = time (NULL); now = time (NULL);
g_assert_cmpstr (mu_date_interpret_s ("now", FALSE) , ==, g_assert_cmpstr (mu_date_interpret_s ("now", FALSE) , ==,
mu_date_str_s("%Y%m%d%H%M%S", now)); mu_date_str_s("%Y%m%d%H%M%S", now));
@ -167,7 +167,7 @@ main (int argc, char *argv[])
/* mu_str_date */ /* mu_str_date */
g_test_add_func ("/mu-str/mu-date-str", g_test_add_func ("/mu-str/mu-date-str",
test_mu_date_str); test_mu_date_str);
g_test_add_func ("/mu-str/mu_date_parse_hdwmy", g_test_add_func ("/mu-str/mu_date_parse_hdwmy",
test_mu_date_parse_hdwmy); test_mu_date_parse_hdwmy);
g_test_add_func ("/mu-str/mu_date_complete_begin", g_test_add_func ("/mu-str/mu_date_complete_begin",
@ -180,10 +180,10 @@ main (int argc, char *argv[])
g_test_add_func ("/mu-str/mu_date_interpret_end", g_test_add_func ("/mu-str/mu_date_interpret_end",
test_mu_date_interpret_end); test_mu_date_interpret_end);
g_log_set_handler (NULL, g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole, NULL); (GLogFunc)black_hole, NULL);
return g_test_run (); return g_test_run ();
} }

View File

@ -23,7 +23,7 @@
#endif /*HAVE_CONFIG_H*/ #endif /*HAVE_CONFIG_H*/
#include <glib.h> #include <glib.h>
#include "src/mu-flags.h" #include "mu-flags.h"
#include "test-mu-common.h" #include "test-mu-common.h"

View File

@ -29,8 +29,8 @@
#include <string.h> #include <string.h>
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-maildir.h" #include "mu-maildir.h"
#include "src/mu-util.h" #include "mu-util.h"
static void static void
test_mu_maildir_mkdir_01 (void) test_mu_maildir_mkdir_01 (void)

View File

@ -1,4 +1,4 @@
/* /*
** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
@ -13,8 +13,8 @@
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, ** along with this program; if not, write to the Free Software Foundation,
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
** **
*/ */
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@ -29,7 +29,7 @@
#include <locale.h> #include <locale.h>
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-msg-fields.h" #include "mu-msg-fields.h"
static void static void
test_mu_msg_field_body (void) test_mu_msg_field_body (void)
@ -37,11 +37,11 @@ test_mu_msg_field_body (void)
MuMsgFieldId field; MuMsgFieldId field;
field = MU_MSG_FIELD_ID_BODY_TEXT; field = MU_MSG_FIELD_ID_BODY_TEXT;
g_assert_cmpstr (mu_msg_field_name(field),==, "body"); g_assert_cmpstr (mu_msg_field_name(field),==, "body");
g_assert_cmpuint (mu_msg_field_shortcut(field),==, 'b'); g_assert_cmpuint (mu_msg_field_shortcut(field),==, 'b');
g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'B'); g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'B');
g_assert_cmpuint (mu_msg_field_is_numeric(field), ==, FALSE); g_assert_cmpuint (mu_msg_field_is_numeric(field), ==, FALSE);
} }
@ -51,11 +51,11 @@ test_mu_msg_field_subject (void)
MuMsgFieldId field; MuMsgFieldId field;
field = MU_MSG_FIELD_ID_SUBJECT; field = MU_MSG_FIELD_ID_SUBJECT;
g_assert_cmpstr (mu_msg_field_name(field),==, "subject"); g_assert_cmpstr (mu_msg_field_name(field),==, "subject");
g_assert_cmpuint (mu_msg_field_shortcut(field),==, 's'); g_assert_cmpuint (mu_msg_field_shortcut(field),==, 's');
g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'S'); g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'S');
g_assert_cmpuint (mu_msg_field_is_numeric(field), ==,FALSE); g_assert_cmpuint (mu_msg_field_is_numeric(field), ==,FALSE);
} }
@ -65,7 +65,7 @@ test_mu_msg_field_to (void)
MuMsgFieldId field; MuMsgFieldId field;
field = MU_MSG_FIELD_ID_TO; field = MU_MSG_FIELD_ID_TO;
g_assert_cmpstr (mu_msg_field_name(field),==, "to"); g_assert_cmpstr (mu_msg_field_name(field),==, "to");
g_assert_cmpuint (mu_msg_field_shortcut(field),==, 't'); g_assert_cmpuint (mu_msg_field_shortcut(field),==, 't');
g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'T'); g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'T');
@ -80,7 +80,7 @@ test_mu_msg_field_prio (void)
MuMsgFieldId field; MuMsgFieldId field;
field = MU_MSG_FIELD_ID_PRIO; field = MU_MSG_FIELD_ID_PRIO;
g_assert_cmpstr (mu_msg_field_name(field),==, "prio"); g_assert_cmpstr (mu_msg_field_name(field),==, "prio");
g_assert_cmpuint (mu_msg_field_shortcut(field),==, 'p'); g_assert_cmpuint (mu_msg_field_shortcut(field),==, 'p');
g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'P'); g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'P');
@ -94,12 +94,12 @@ test_mu_msg_field_flags (void)
MuMsgFieldId field; MuMsgFieldId field;
field = MU_MSG_FIELD_ID_FLAGS; field = MU_MSG_FIELD_ID_FLAGS;
g_assert_cmpstr (mu_msg_field_name(field),==, "flag"); g_assert_cmpstr (mu_msg_field_name(field),==, "flag");
g_assert_cmpuint (mu_msg_field_shortcut(field),==, 'g'); g_assert_cmpuint (mu_msg_field_shortcut(field),==, 'g');
g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'G'); g_assert_cmpuint (mu_msg_field_xapian_prefix(field),==, 'G');
g_assert_cmpuint (mu_msg_field_is_numeric(field),==, TRUE); g_assert_cmpuint (mu_msg_field_is_numeric(field),==, TRUE);
} }
@ -124,11 +124,11 @@ main (int argc, char *argv[])
/* FIXME: add tests for mu_msg_str_flags; but note the /* FIXME: add tests for mu_msg_str_flags; but note the
* function simply calls mu_msg_field_str */ * function simply calls mu_msg_field_str */
g_log_set_handler (NULL, g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
G_LOG_FLAG_RECURSION, G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole, NULL); (GLogFunc)black_hole, NULL);
return g_test_run (); return g_test_run ();
} }

View File

@ -30,8 +30,8 @@
#include <locale.h> #include <locale.h>
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-msg.h" #include "mu-msg.h"
#include "src/mu-str.h" #include "mu-str.h"
static gboolean static gboolean
check_contact_01 (MuMsgContact *contact, int *idx) check_contact_01 (MuMsgContact *contact, int *idx)

View File

@ -31,7 +31,7 @@
#include <locale.h> #include <locale.h>
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-store.h" #include "mu-store.h"
static void static void
test_mu_store_new_destroy (void) test_mu_store_new_destroy (void)

View File

@ -31,8 +31,8 @@
#include <locale.h> #include <locale.h>
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-str.h" #include "mu-str.h"
#include "src/mu-msg-prio.h" #include "mu-msg-prio.h"

View File

@ -29,7 +29,7 @@
#include <limits.h> #include <limits.h>
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-util.h" #include "lib/mu-util.h"
static void static void
test_mu_util_dir_expand_00 (void) test_mu_util_dir_expand_00 (void)

Some files were not shown because too many files have changed in this diff Show More