Commit ed9454c6 ed9454c6df05b870395376ae5a200121f1755fdc by Sergey Poznyakoff

New example

* configure.ac (MU_PRI_OFF_T): Define to the printf
format spec suitable for printing mu_off_t.
Don't use [ ] instead of test.
* include/mailutils/types.hin (MU_PRI_OFF_T): New define.
* include/mailutils/Makefile.am (type.h): Pass MU_PRI_OFF_T

* examples/mboxsize.c: New file.
* examples/Makefile.am: Build mboxsize
1 parent eed8a3dc
......@@ -691,10 +691,13 @@ AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_SUBST(MU_OFF_TYPE)
AC_SUBST(MU_PRI_OFF_T)
if test $ac_cv_sizeof_off_t -eq $ac_cv_sizeof_long; then
MU_OFF_TYPE=long
MU_PRI_OFF_T='ld'
elif test $ac_cv_sizeof_off_t -eq $ac_cv_sizeof_long_long; then
MU_OFF_TYPE="long long"
MU_PRI_OFF_T='lld'
else
AC_MSG_ERROR([Cannot find ${ac_cv_sizeof_off_t}-byte type, suitable for mu_off_t])
fi
......@@ -1159,7 +1162,7 @@ GINT_INIT([gint],[1.8 with-guile],
[useguile=yes
AC_DEFINE([WITH_GUILE],1,[Enable Guile support])
GUILE_BINDIR=`guile-config info bindir`
if [ -z "$GUILE_BINDIR" ]; then
if test -z "$GUILE_BINDIR"; then
GUILE_BINDIR="`guile-config info prefix`/bin"
fi
LIBMU_SCM=../libmu_scm/libmu_scm.la
......
......@@ -16,6 +16,7 @@ lsf
mailcap
mblconv
mboxidx
mboxsize
mimetest
msg-send
mta
......
......@@ -39,6 +39,7 @@ noinst_PROGRAMS = \
lsf\
mblconv\
mboxidx\
mboxsize\
msg-send\
mta\
mucat\
......@@ -95,6 +96,18 @@ sfrom_LDADD =\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS}
mboxsize_LDADD =\
../lib/libmuaux.la\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
${MU_LIB_NNTP}\
${MU_LIB_MH}\
${MU_LIB_MAILDIR}\
${MU_LIB_AUTH}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS}
nntpclient_LDADD = \
../lib/libmuaux.la\
${MU_LIB_NNTP}\
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999-2005, 2007, 2010-2012, 2014-2016 Free Software
Foundation, Inc.
GNU Mailutils 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 3, or (at your option)
any later version.
GNU Mailutils 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#include <mailutils/mailutils.h>
struct mu_cli_setup cli = {
NULL,
NULL,
"compute mailbox size",
"MBOX"
};
static char *capa[] = {
"debug",
NULL
};
int
main (int argc, char **argv)
{
int rc;
mu_mailbox_t mbox;
mu_off_t size;
char *name;
mu_register_all_mbox_formats ();
mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
if (argc != 1)
{
mu_error ("wrong number of arguments");
return 1;
}
name = argv[0];
rc = mu_mailbox_create_default (&mbox, name);
if (rc)
{
mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_create_default",
name, rc);
return 1;
}
rc = mu_mailbox_open (mbox, MU_STREAM_READ);
if (rc)
{
mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_open", name, rc);
return 1;
}
rc = mu_mailbox_get_size (mbox, &size);
if (rc)
{
mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_get_size", name, rc);
return 1;
}
mu_printf ("%" MU_PRI_OFF_T "\n", size);
return 0;
}
......@@ -21,7 +21,10 @@ errno.h: $(top_srcdir)/libmailutils/diag/errors errno.hin
$(AM_V_GEN)$(AWK) -f $(mu_aux_dir)/generr.awk $(top_srcdir)/libmailutils/diag/errors errno.hin > errno.h
types.h: $(top_srcdir)/include/mailutils/types.hin Makefile
$(AM_V_GEN)sed 's/_MU_OFF_TYPE_/$(MU_OFF_TYPE)/;s/_MU_DEFAULT_RECORD_/$(MU_DEFAULT_RECORD)/' $(top_srcdir)/include/mailutils/types.hin > $@
$(AM_V_GEN)sed -e 's/_MU_OFF_TYPE_/$(MU_OFF_TYPE)/' \
-e 's/_MU_DEFAULT_RECORD_/$(MU_DEFAULT_RECORD)/' \
-e 's/_MU_PRI_OFF_T_/$(MU_PRI_OFF_T)/' \
$(top_srcdir)/include/mailutils/types.hin > $@
DISTCLEANFILES = types.h
pkginclude_HEADERS = \
......
......@@ -83,6 +83,7 @@ struct mu_sockaddr; /* defined in mailutils/sockaddr.h */
struct mu_cidr; /* defined in mailutils/cidr.h */
typedef _MU_OFF_TYPE_ mu_off_t;
#define MU_PRI_OFF_T "_MU_PRI_OFF_T_"
typedef struct mu_address *mu_address_t;
typedef struct _mu_attribute *mu_attribute_t;
......