[go: up one dir, main page]

Menu

[r30]: / trunk / man / libmail_mbox.3  Maximize  Restore  History

Download this file

124 lines (116 with data), 3.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
.\" This file is part of libmail.
.\"
.\" (c) 2009 - Dimitris Mandalidis <mandas@users.sourceforge.net>
.\"
.\" libmail 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 of the License, or
.\" (at your option) any later version.
.\"
.\" libmail 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 libmail. If not, see <http://www.gnu.org/licenses/>.
.TH LIBMAIL_MBOX 3 "2009-03-23" "version 0.2" "libmail - A mail handling library"
.SH NAME
mbox_check - libmail's mbox supporting functions
.SH SYNOPSIS
.nf
.B #include <libmail/libmail.h>
.B #include <libmail/mbox.h>
.sp
.BI "int mbox_check(mbox_server_t *" "server" ", int *" "n_new_messages" ", int *" "n_messages" );
.fi
.SH DESCRIPTION
.B mbox_check()
takes a pointer to
.B mbox_server_t
structure which identify the mailbox location. More specifically
.I mbox_server_t
is defined as follows :
.sp
.nf
typedef struct mbox_server_t {
char file[PATH_MAX+1];
} mbox_server_t;
.fi
.sp
In
.I file
the path of the local mailbox is specified.
.B mbox_check()
checks for messages filling the
.I n_messages
and
.I n_new_messages
with the number of total and new messages respectively.
.SH "RETURN VALUE"
.B mbox_check()
returns
.B LIBMAIL_SUCCESS
on success and
.B LIBMAIL_SYSERROR
otherwise (errno defined in <errno.h> is set).
.TP
You can retrieve a short description about a specific error through libmail_strerror()
.SH "SEE ALSO"
.BR "mbox" "(5)" "libmail_strerror" "(3)"
.SH "AUTHOR"
Dimitris Mandalidis <mandas AT users DOT sourceforge DOT net>
.SH "EXAMPLES"
For convenience,
.B endpeer_t
and
.B server_t
are defined as follows:
.sp
.nf
typedef union server_t {
pop3_server_t pop3_server;
imap4_server_t imap4_server;
mbox_server_t local_mbox;
} server_t;
typedef struct endpeer_t {
time_t last_checked_on;
short protocol;
int n_messages;
int n_new_messages;
server_t server;
} endpeer_t;
.fi
.sp
However they will never be used by libmail as arguments of return values of
functions. A short example on using libmail mbox support follows:
.sp
.nf
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <time.h>
#include <libmail/libmail.h>
#include <libmail/mbox.h>
int check_for_messages(endpeer_t *endpeer) {
int status;
if ((status = mbox_check(&endpeer->server.local_mbox, &endpeer->n_new_messages, &endpeer->n_messages)) != 0)
return status;
endpeer->last_checked_on = time(NULL);
return 0;
}
void mbox_test(void) {
endpeer_t endpeer;
mbox_server_t mbox_server;
strcpy(mbox_server.file, "/var/mail/mandas");
endpeer.protocol = MBOX_PROTO;
endpeer.server.local_mbox = mbox_server;
if (check_for_messages(&endpeer) != 0) {
printf("ERROR");
exit(EXIT_FAILURE);
}
printf("%d total messages and %d new messages", endpeer.n_messages, endpeer.n_new_messages);
return;
}
.fi