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
Showing
6 changed files
with
104 additions
and
3 deletions
... | @@ -691,10 +691,13 @@ AC_CHECK_SIZEOF(off_t) | ... | @@ -691,10 +691,13 @@ AC_CHECK_SIZEOF(off_t) |
691 | AC_CHECK_SIZEOF(long) | 691 | AC_CHECK_SIZEOF(long) |
692 | AC_CHECK_SIZEOF(long long) | 692 | AC_CHECK_SIZEOF(long long) |
693 | AC_SUBST(MU_OFF_TYPE) | 693 | AC_SUBST(MU_OFF_TYPE) |
694 | AC_SUBST(MU_PRI_OFF_T) | ||
694 | if test $ac_cv_sizeof_off_t -eq $ac_cv_sizeof_long; then | 695 | if test $ac_cv_sizeof_off_t -eq $ac_cv_sizeof_long; then |
695 | MU_OFF_TYPE=long | 696 | MU_OFF_TYPE=long |
697 | MU_PRI_OFF_T='ld' | ||
696 | elif test $ac_cv_sizeof_off_t -eq $ac_cv_sizeof_long_long; then | 698 | elif test $ac_cv_sizeof_off_t -eq $ac_cv_sizeof_long_long; then |
697 | MU_OFF_TYPE="long long" | 699 | MU_OFF_TYPE="long long" |
700 | MU_PRI_OFF_T='lld' | ||
698 | else | 701 | else |
699 | AC_MSG_ERROR([Cannot find ${ac_cv_sizeof_off_t}-byte type, suitable for mu_off_t]) | 702 | AC_MSG_ERROR([Cannot find ${ac_cv_sizeof_off_t}-byte type, suitable for mu_off_t]) |
700 | fi | 703 | fi |
... | @@ -1159,7 +1162,7 @@ GINT_INIT([gint],[1.8 with-guile], | ... | @@ -1159,7 +1162,7 @@ GINT_INIT([gint],[1.8 with-guile], |
1159 | [useguile=yes | 1162 | [useguile=yes |
1160 | AC_DEFINE([WITH_GUILE],1,[Enable Guile support]) | 1163 | AC_DEFINE([WITH_GUILE],1,[Enable Guile support]) |
1161 | GUILE_BINDIR=`guile-config info bindir` | 1164 | GUILE_BINDIR=`guile-config info bindir` |
1162 | if [ -z "$GUILE_BINDIR" ]; then | 1165 | if test -z "$GUILE_BINDIR"; then |
1163 | GUILE_BINDIR="`guile-config info prefix`/bin" | 1166 | GUILE_BINDIR="`guile-config info prefix`/bin" |
1164 | fi | 1167 | fi |
1165 | LIBMU_SCM=../libmu_scm/libmu_scm.la | 1168 | LIBMU_SCM=../libmu_scm/libmu_scm.la | ... | ... |
... | @@ -39,6 +39,7 @@ noinst_PROGRAMS = \ | ... | @@ -39,6 +39,7 @@ noinst_PROGRAMS = \ |
39 | lsf\ | 39 | lsf\ |
40 | mblconv\ | 40 | mblconv\ |
41 | mboxidx\ | 41 | mboxidx\ |
42 | mboxsize\ | ||
42 | msg-send\ | 43 | msg-send\ |
43 | mta\ | 44 | mta\ |
44 | mucat\ | 45 | mucat\ |
... | @@ -95,6 +96,18 @@ sfrom_LDADD =\ | ... | @@ -95,6 +96,18 @@ sfrom_LDADD =\ |
95 | @MU_AUTHLIBS@\ | 96 | @MU_AUTHLIBS@\ |
96 | ${MU_LIB_MAILUTILS} | 97 | ${MU_LIB_MAILUTILS} |
97 | 98 | ||
99 | mboxsize_LDADD =\ | ||
100 | ../lib/libmuaux.la\ | ||
101 | ${MU_LIB_MBOX}\ | ||
102 | ${MU_LIB_IMAP}\ | ||
103 | ${MU_LIB_POP}\ | ||
104 | ${MU_LIB_NNTP}\ | ||
105 | ${MU_LIB_MH}\ | ||
106 | ${MU_LIB_MAILDIR}\ | ||
107 | ${MU_LIB_AUTH}\ | ||
108 | @MU_AUTHLIBS@\ | ||
109 | ${MU_LIB_MAILUTILS} | ||
110 | |||
98 | nntpclient_LDADD = \ | 111 | nntpclient_LDADD = \ |
99 | ../lib/libmuaux.la\ | 112 | ../lib/libmuaux.la\ |
100 | ${MU_LIB_NNTP}\ | 113 | ${MU_LIB_NNTP}\ | ... | ... |
examples/mboxsize.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999-2005, 2007, 2010-2012, 2014-2016 Free Software | ||
3 | Foundation, Inc. | ||
4 | |||
5 | GNU Mailutils is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | GNU Mailutils is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #include <mailutils/mailutils.h> | ||
19 | |||
20 | struct mu_cli_setup cli = { | ||
21 | NULL, | ||
22 | NULL, | ||
23 | "compute mailbox size", | ||
24 | "MBOX" | ||
25 | }; | ||
26 | |||
27 | static char *capa[] = { | ||
28 | "debug", | ||
29 | NULL | ||
30 | }; | ||
31 | |||
32 | int | ||
33 | main (int argc, char **argv) | ||
34 | { | ||
35 | int rc; | ||
36 | mu_mailbox_t mbox; | ||
37 | mu_off_t size; | ||
38 | char *name; | ||
39 | |||
40 | mu_register_all_mbox_formats (); | ||
41 | |||
42 | mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv); | ||
43 | |||
44 | if (argc != 1) | ||
45 | { | ||
46 | mu_error ("wrong number of arguments"); | ||
47 | return 1; | ||
48 | } | ||
49 | name = argv[0]; | ||
50 | |||
51 | rc = mu_mailbox_create_default (&mbox, name); | ||
52 | if (rc) | ||
53 | { | ||
54 | mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_create_default", | ||
55 | name, rc); | ||
56 | return 1; | ||
57 | } | ||
58 | |||
59 | rc = mu_mailbox_open (mbox, MU_STREAM_READ); | ||
60 | if (rc) | ||
61 | { | ||
62 | mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_open", name, rc); | ||
63 | return 1; | ||
64 | } | ||
65 | |||
66 | rc = mu_mailbox_get_size (mbox, &size); | ||
67 | if (rc) | ||
68 | { | ||
69 | mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_get_size", name, rc); | ||
70 | return 1; | ||
71 | } | ||
72 | |||
73 | mu_printf ("%" MU_PRI_OFF_T "\n", size); | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | |||
79 | |||
80 |
... | @@ -21,7 +21,10 @@ errno.h: $(top_srcdir)/libmailutils/diag/errors errno.hin | ... | @@ -21,7 +21,10 @@ errno.h: $(top_srcdir)/libmailutils/diag/errors errno.hin |
21 | $(AM_V_GEN)$(AWK) -f $(mu_aux_dir)/generr.awk $(top_srcdir)/libmailutils/diag/errors errno.hin > errno.h | 21 | $(AM_V_GEN)$(AWK) -f $(mu_aux_dir)/generr.awk $(top_srcdir)/libmailutils/diag/errors errno.hin > errno.h |
22 | 22 | ||
23 | types.h: $(top_srcdir)/include/mailutils/types.hin Makefile | 23 | types.h: $(top_srcdir)/include/mailutils/types.hin Makefile |
24 | $(AM_V_GEN)sed 's/_MU_OFF_TYPE_/$(MU_OFF_TYPE)/;s/_MU_DEFAULT_RECORD_/$(MU_DEFAULT_RECORD)/' $(top_srcdir)/include/mailutils/types.hin > $@ | 24 | $(AM_V_GEN)sed -e 's/_MU_OFF_TYPE_/$(MU_OFF_TYPE)/' \ |
25 | -e 's/_MU_DEFAULT_RECORD_/$(MU_DEFAULT_RECORD)/' \ | ||
26 | -e 's/_MU_PRI_OFF_T_/$(MU_PRI_OFF_T)/' \ | ||
27 | $(top_srcdir)/include/mailutils/types.hin > $@ | ||
25 | DISTCLEANFILES = types.h | 28 | DISTCLEANFILES = types.h |
26 | 29 | ||
27 | pkginclude_HEADERS = \ | 30 | pkginclude_HEADERS = \ | ... | ... |
... | @@ -83,7 +83,8 @@ struct mu_sockaddr; /* defined in mailutils/sockaddr.h */ | ... | @@ -83,7 +83,8 @@ struct mu_sockaddr; /* defined in mailutils/sockaddr.h */ |
83 | struct mu_cidr; /* defined in mailutils/cidr.h */ | 83 | struct mu_cidr; /* defined in mailutils/cidr.h */ |
84 | 84 | ||
85 | typedef _MU_OFF_TYPE_ mu_off_t; | 85 | typedef _MU_OFF_TYPE_ mu_off_t; |
86 | 86 | #define MU_PRI_OFF_T "_MU_PRI_OFF_T_" | |
87 | |||
87 | typedef struct mu_address *mu_address_t; | 88 | typedef struct mu_address *mu_address_t; |
88 | typedef struct _mu_attribute *mu_attribute_t; | 89 | typedef struct _mu_attribute *mu_attribute_t; |
89 | typedef struct _mu_authority *mu_authority_t; | 90 | typedef struct _mu_authority *mu_authority_t; | ... | ... |
-
Please register or sign in to post a comment