Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
321044b0
...
321044b00bdb4347fff4966ede7d575c5acff483
authored
2001-04-24 07:20:29 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
use mu_error() everywhere.
1 parent
cfb7e728
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
210 additions
and
56 deletions
ChangeLog
include/mailutils/Makefile.am
include/mailutils/error.h
mailbox/Makefile.am
mailbox/file_stream.c
mailbox/folder_imap.c
mailbox/mapfile_stream.c
mailbox/mbx_default.c
mailbox/mbx_imap.c
mailbox/mbx_mbox.c
mailbox/mbx_pop.c
mailbox/message.c
mailbox/muerror.c
mailbox/stream.c
pop3d/pop3d.c
pop3d/pop3d.h
ChangeLog
View file @
321044b
2001-04-23 Alain Magloire
Sergey Poznyakoff noted: When the user's mailbox ha zeor size mmap
fails on Solaris. On GNU/Linux it reuturn NULL buf subsequet munmap
fails.
* mailbox/mapfile_stream.c: To take care of this will set
the mfs->ptr to NULL for len == 0;
2001-04-23 Sergey Poznyakoff
Several sources from mailbox subdirectory call fprintf(stderr,...)
to issue error messages. As the stderr usually gets connected to
the output socket, the client program receives all these error
messages and gets confused, since they do not start with
rfc-compliant +OK, -ERR keywords. So I have added a module
error.c and changed all these fprintf's to error()'s. Actual
function that ouputs the messages can be supplied by the
application using error_set_print() call.
2001-04-23 Alain Magloire
* pop3d/*.[ch]: Rename all the pop function pop3d_xx()
instead of pop3_xx() to be consistent with imap4d/*.
...
...
include/mailutils/Makefile.am
View file @
321044b
...
...
@@ -6,6 +6,7 @@ pkginclude_HEADERS = \
body.h
\
debug.h
\
envelope.h
\
error.h
\
filter.h
\
folder.h
\
header.h
\
...
...
include/mailutils/error.h
0 → 100644
View file @
321044b
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Library Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _MAILUTILS_ERROR_H
#define _MAILUTILS_ERROR_H
#include <stdarg.h>
#ifndef __P
#ifdef __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
#endif
/*__P */
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
int
(
*
error_pfn_t
)
__P
((
const
char
*
fmt
,
va_list
ap
));
extern
int
mu_error
__P
((
const
char
*
fmt
,
...));
extern
void
mu_error_set_print
__P
((
error_pfn_t
));
#ifdef __cplusplus
}
#endif
#endif
/* _MAILUTILS_ERROR_H */
mailbox/Makefile.am
View file @
321044b
...
...
@@ -45,6 +45,7 @@ memory_stream.c \
mime.c
\
misc.c
\
monitor.c
\
muerror.c
\
observer.c
\
parse822.c
\
property.c
\
...
...
mailbox/file_stream.c
View file @
321044b
...
...
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <mailutils/stream.h>
#include <mailutils/error.h>
struct
_file_stream
{
...
...
@@ -266,7 +267,7 @@ _file_open (stream_t stream, const char *filename, int port, int flags)
||
filebuf
.
st_nlink
!=
1
||
(
fdbuf
.
st_mode
&
S_IFMT
)
!=
S_IFREG
)
{
fprintf
(
stderr
,
"%s must be a plain file with one link
\n
"
,
filename
);
mu_error
(
"%s must be a plain file with one link
\n
"
,
filename
);
close
(
fd
);
return
EINVAL
;
}
...
...
mailbox/folder_imap.c
View file @
321044b
...
...
@@ -36,6 +36,7 @@
#endif
#include <imap0.h>
#include <mailutils/error.h>
/* Variable use for the registrar. */
static
struct
_record
_imap_record
=
...
...
@@ -1505,7 +1506,7 @@ imap_fetch (f_imap_t f_imap)
{
status
=
imap_rfc822_header
(
f_imap
,
&
sp
);
}
/* else
fprintf (stderr,
"not supported RFC822 option\n"); */
/* else
mu_error (
"not supported RFC822 option\n"); */
}
else
{
...
...
@@ -1516,7 +1517,7 @@ imap_fetch (f_imap_t f_imap)
{
status
=
imap_uid
(
f_imap
,
&
sp
);
}
/* else
fprintf (stderr,
"not supported FETCH command\n"); */
/* else
mu_error (
"not supported FETCH command\n"); */
}
return
status
;
}
...
...
@@ -1734,7 +1735,7 @@ imap_parse (f_imap_t f_imap)
}
#if 0
/* Comment out to see all reading traffic. */
fprintf (stderr,
"\t\t%s", f_imap->buffer);
mu_error (
"\t\t%s", f_imap->buffer);
#endif
/* We do not want to step over f_imap->buffer since it can be use
...
...
@@ -1775,7 +1776,7 @@ imap_parse (f_imap_t f_imap)
/* The human-readable text contains a special alert that
MUST be presented to the user in a fashion that calls
the user's attention to the message. */
fprintf
(
stderr
,
"ALERT: %s
\n
"
,
(
sp
)
?
sp
:
""
);
mu_error
(
"ALERT: %s
\n
"
,
(
sp
)
?
sp
:
""
);
}
else
if
(
strcasecmp
(
subtag
,
"BADCHARSET"
)
==
0
)
{
...
...
@@ -1882,18 +1883,18 @@ imap_parse (f_imap_t f_imap)
{
/* Not sure why we would get an untagged ok...but we do... */
/* Still should we be verbose about is ? */
fprintf
(
stderr
,
"Untagged OK: %s
\n
"
,
remainder
);
mu_error
(
"Untagged OK: %s
\n
"
,
remainder
);
}
}
else
if
(
strcasecmp
(
response
,
"NO"
)
==
0
)
{
/* This does not mean failure but rather a strong warning. */
fprintf
(
stderr
,
"Untagged NO: %s
\n
"
,
remainder
);
mu_error
(
"Untagged NO: %s
\n
"
,
remainder
);
}
else
if
(
strcasecmp
(
response
,
"BAD"
)
==
0
)
{
/* We're dead, protocol/syntax error. */
fprintf
(
stderr
,
"Untagged BAD: %s
\n
"
,
remainder
);
mu_error
(
"Untagged BAD: %s
\n
"
,
remainder
);
}
else
if
(
strcasecmp
(
response
,
"PREAUTH"
)
==
0
)
{
...
...
@@ -1953,7 +1954,7 @@ imap_parse (f_imap_t f_imap)
else
{
/* Once again, check for something strange. */
fprintf
(
stderr
,
"unknown untagged response:
\"
%s
\"
%s
\n
"
,
mu_error
(
"unknown untagged response:
\"
%s
\"
%s
\n
"
,
response
,
remainder
);
}
}
...
...
@@ -1977,7 +1978,7 @@ imap_parse (f_imap_t f_imap)
folder_get_observable
(
f_imap
->
folder
,
&
observable
);
observable_notify
(
observable
,
MU_EVT_AUTHORITY_FAILED
);
}
fprintf
(
stderr
,
"NO/Bad Tagged: %s %s
\n
"
,
response
,
remainder
);
mu_error
(
"NO/Bad Tagged: %s %s
\n
"
,
response
,
remainder
);
status
=
EINVAL
;
}
}
...
...
mailbox/mapfile_stream.c
View file @
321044b
...
...
@@ -53,6 +53,7 @@ _mapfile_destroy (stream_t stream)
if
(
mfs
->
ptr
!=
MAP_FAILED
)
{
if
(
mfs
->
ptr
)
munmap
(
mfs
->
ptr
,
mfs
->
size
);
close
(
mfs
->
fd
);
}
...
...
@@ -122,7 +123,7 @@ _mapfile_write (stream_t stream, const char *iptr, size_t isize,
/* Bigger we have to remmap. */
if
(
mfs
->
size
<
(
offset
+
isize
))
{
if
(
munmap
(
mfs
->
ptr
,
mfs
->
size
)
!=
0
)
if
(
m
fs
->
ptr
&&
m
unmap
(
mfs
->
ptr
,
mfs
->
size
)
!=
0
)
{
int
err
=
errno
;
mfs
->
ptr
=
MAP_FAILED
;
...
...
@@ -154,7 +155,7 @@ _mapfile_truncate (stream_t stream, off_t len)
if
(
mfs
->
ptr
==
MAP_FAILED
)
return
EINVAL
;
/* Remap. */
if
(
munmap
(
mfs
->
ptr
,
mfs
->
size
)
!=
0
)
if
(
m
fs
->
ptr
&&
m
unmap
(
mfs
->
ptr
,
mfs
->
size
)
!=
0
)
{
int
err
=
errno
;
mfs
->
ptr
=
MAP_FAILED
;
...
...
@@ -163,7 +164,7 @@ _mapfile_truncate (stream_t stream, off_t len)
}
if
(
ftruncate
(
mfs
->
fd
,
len
)
!=
0
)
return
errno
;
mfs
->
ptr
=
mmap
(
0
,
len
,
mfs
->
flags
,
MAP_SHARED
,
mfs
->
fd
,
0
)
;
mfs
->
ptr
=
(
len
)
?
mmap
(
0
,
len
,
mfs
->
flags
,
MAP_SHARED
,
mfs
->
fd
,
0
)
:
NULL
;
if
(
mfs
->
ptr
==
MAP_FAILED
)
{
int
err
=
errno
;
...
...
@@ -183,19 +184,28 @@ _mapfile_size (stream_t stream, off_t *psize)
if
(
mfs
->
ptr
==
MAP_FAILED
)
return
EINVAL
;
if
(
mfs
->
ptr
)
msync
(
mfs
->
ptr
,
mfs
->
size
,
MS_SYNC
);
if
(
fstat
(
mfs
->
fd
,
&
stbuf
)
!=
0
)
return
errno
;
if
(
mfs
->
size
!=
(
size_t
)
stbuf
.
st_size
)
{
if
(
munmap
(
mfs
->
ptr
,
mfs
->
size
)
==
0
)
if
(
mfs
->
ptr
)
err
=
munmap
(
mfs
->
ptr
,
mfs
->
size
);
if
(
err
==
0
)
{
mfs
->
size
=
stbuf
.
st_size
;
mfs
->
ptr
=
mmap
(
0
,
mfs
->
size
,
mfs
->
flags
,
MAP_SHARED
,
mfs
->
fd
,
0
);
if
(
mfs
->
size
)
{
mfs
->
ptr
=
mmap
(
0
,
mfs
->
size
,
mfs
->
flags
,
MAP_SHARED
,
mfs
->
fd
,
0
);
if
(
mfs
->
ptr
==
MAP_FAILED
)
err
=
errno
;
}
else
mfs
->
ptr
=
NULL
;
}
else
err
=
errno
;
}
if
(
err
!=
0
)
...
...
@@ -216,7 +226,9 @@ static int
_mapfile_flush
(
stream_t
stream
)
{
struct
_mapfile_stream
*
mfs
=
stream_get_owner
(
stream
);
if
(
mfs
->
ptr
!=
MAP_FAILED
&&
mfs
->
ptr
!=
NULL
)
return
msync
(
mfs
->
ptr
,
mfs
->
size
,
MS_SYNC
);
return
0
;
}
static
int
...
...
@@ -235,7 +247,7 @@ _mapfile_close (stream_t stream)
int
err
=
0
;
if
(
mfs
->
ptr
!=
MAP_FAILED
)
{
if
(
munmap
(
mfs
->
ptr
,
mfs
->
size
)
!=
0
)
if
(
m
fs
->
ptr
&&
m
unmap
(
mfs
->
ptr
,
mfs
->
size
)
!=
0
)
err
=
errno
;
if
(
close
(
mfs
->
fd
)
!=
0
)
err
=
errno
;
...
...
@@ -257,6 +269,7 @@ _mapfile_open (stream_t stream, const char *filename, int port, int flags)
/* Close any previous file. */
if
(
mfs
->
ptr
!=
MAP_FAILED
)
{
if
(
mfs
->
ptr
)
munmap
(
mfs
->
ptr
,
mfs
->
size
);
mfs
->
ptr
=
MAP_FAILED
;
}
...
...
@@ -277,7 +290,7 @@ _mapfile_open (stream_t stream, const char *filename, int port, int flags)
flg
=
O_RDWR
;
}
else
if
(
flags
&
MU_STREAM_CREAT
)
return
ENO
TSUP
;
return
ENO
SYS
;
else
/* default */
{
mflag
=
PROT_READ
;
...
...
@@ -294,6 +307,8 @@ _mapfile_open (stream_t stream, const char *filename, int port, int flags)
return
err
;
}
mfs
->
size
=
st
.
st_size
;
if
(
mfs
->
size
)
{
mfs
->
ptr
=
mmap
(
0
,
mfs
->
size
,
mflag
,
MAP_SHARED
,
mfs
->
fd
,
0
);
if
(
mfs
->
ptr
==
MAP_FAILED
)
{
...
...
@@ -302,6 +317,9 @@ _mapfile_open (stream_t stream, const char *filename, int port, int flags)
mfs
->
ptr
=
MAP_FAILED
;
return
err
;
}
}
else
mfs
->
ptr
=
NULL
;
mfs
->
flags
=
mflag
;
stream_set_flags
(
stream
,
flags
|
MU_STREAM_NO_CHECK
);
return
0
;
...
...
@@ -313,7 +331,7 @@ int
mapfile_stream_create
(
stream_t
*
stream
)
{
#ifndef _POSIX_MAPPED_FILES
return
ENO
TSUP
;
return
ENO
SYS
;
#else
struct
_mapfile_stream
*
fs
;
int
ret
;
...
...
mailbox/mbx_default.c
View file @
321044b
...
...
@@ -29,6 +29,7 @@
#endif
#include <mailutils/mailbox.h>
#include <mailutils/error.h>
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/usr/spool/mail"
...
...
@@ -69,7 +70,7 @@ mailbox_create_default (mailbox_t *pmbox, const char *mail)
user
=
(
getenv
(
"LOGNAME"
))
?
getenv
(
"LOGNAME"
)
:
getenv
(
"USER"
);
if
(
user
==
NULL
)
{
fprintf
(
stderr
,
"Who am I ?
\n
"
);
mu_error
(
"Who am I ?
\n
"
);
return
EINVAL
;
}
}
...
...
mailbox/mbx_imap.c
View file @
321044b
...
...
@@ -29,6 +29,7 @@
#include <time.h>
#include <mailutils/address.h>
#include <mailutils/error.h>
#include <mailbox0.h>
#include <registrar0.h>
#include <imap0.h>
...
...
@@ -636,7 +637,7 @@ imap_expunge (mailbox_t mailbox)
f_imap
->
state
=
IMAP_NO_STATE
;
default:
/*
fprintf (stderr,
"imap_expunge: unknow state\n"); */
/*
mu_error (
"imap_expunge: unknow state\n"); */
break
;
}
/* switch (state) */
}
/* message_get_attribute() */
...
...
@@ -742,7 +743,7 @@ static int
imap_append_message
(
mailbox_t
mailbox
,
message_t
msg
)
{
size_t
total
;
int
status
;
int
status
=
0
;
m_imap_t
m_imap
=
mailbox
->
data
;
f_imap_t
f_imap
=
m_imap
->
f_imap
;
...
...
@@ -859,7 +860,7 @@ imap_append_message (mailbox_t mailbox, message_t msg)
MAILBOX_DEBUG0
(
m_imap
->
mailbox
,
MU_DEBUG_PROT
,
f_imap
->
buffer
);
default:
/*
fprintf (stderr,
"imap_expunge: unknow state\n"); */
/*
mu_error (
"imap_expunge: unknow state\n"); */
break
;
}
f_imap
->
state
=
IMAP_NO_STATE
;
...
...
mailbox/mbx_mbox.c
View file @
321044b
...
...
@@ -53,6 +53,7 @@
#include <mailutils/body.h>
#include <mailutils/header.h>
#include <mailutils/attribute.h>
#include <mailutils/error.h>
#include <registrar0.h>
#include <mailbox0.h>
...
...
@@ -480,9 +481,9 @@ mbox_is_updated (mailbox_t mailbox)
{
observable_notify
(
mailbox
->
observable
,
MU_EVT_MAILBOX_CORRUPT
);
/* And be verbose. ? */
fprintf
(
stderr
,
"* BAD : Mailbox corrupted, shrank size
\n
"
);
mu_error
(
"* BAD : Mailbox corrupted, shrank size
\n
"
);
/* FIXME: should I crash. */
return
1
;
return
0
;
}
return
(
mud
->
size
==
size
);
}
...
...
@@ -590,7 +591,7 @@ mbox_expunge (mailbox_t mailbox)
{
if
(
tmpmboxname
)
free
(
tmpmboxname
);
fprintf
(
stderr
,
"Failed to create temporary file when expunging.
\n
"
);
mu_error
(
"Failed to create temporary file when expunging.
\n
"
);
return
errno
;
}
...
...
@@ -650,7 +651,7 @@ mbox_expunge (mailbox_t mailbox)
mailbox_destroy
(
&
tmpmailbox
);
remove
(
tmpmboxname
);
free
(
tmpmboxname
);
fprintf
(
stderr
,
"Failed to grab the lock
\n
"
);
mu_error
(
"Failed to grab the lock
\n
"
);
return
ENOLCK
;
}
...
...
@@ -702,7 +703,7 @@ mbox_expunge (mailbox_t mailbox)
status
=
mbox_get_message
(
mailbox
,
i
,
&
msg
);
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"Error expunge:%d: %s"
,
__LINE__
,
mu_error
(
"Error expunge:%d: %s"
,
__LINE__
,
strerror
(
status
));
goto
bailout0
;
}
...
...
@@ -711,7 +712,7 @@ mbox_expunge (mailbox_t mailbox)
&
total
,
1
,
(
i
==
save_imapbase
));
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"Error expunge:%d: %s"
,
__LINE__
,
mu_error
(
"Error expunge:%d: %s"
,
__LINE__
,
strerror
(
status
));
goto
bailout0
;
}
...
...
@@ -734,7 +735,7 @@ mbox_expunge (mailbox_t mailbox)
||
(
status
=
stream_write
(
tmpmailbox
->
stream
,
buffer
,
n
,
total
,
&
n
)
!=
0
))
{
fprintf
(
stderr
,
"Error expunge:%d: %s"
,
__LINE__
,
mu_error
(
"Error expunge:%d: %s"
,
__LINE__
,
strerror
(
status
));
goto
bailout0
;
}
...
...
@@ -746,7 +747,7 @@ mbox_expunge (mailbox_t mailbox)
status
=
stream_write
(
tmpmailbox
->
stream
,
"
\n
"
,
1
,
total
,
&
n
);
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"Error expunge:%d: %s"
,
__LINE__
,
mu_error
(
"Error expunge:%d: %s"
,
__LINE__
,
strerror
(
status
));
goto
bailout0
;
}
...
...
@@ -776,7 +777,7 @@ mbox_expunge (mailbox_t mailbox)
total
,
&
n
);
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"Error expunge:%d: %s"
,
__LINE__
,
mu_error
(
"Error expunge:%d: %s"
,
__LINE__
,
strerror
(
status
));
goto
bailout0
;
}
...
...
@@ -787,7 +788,7 @@ mbox_expunge (mailbox_t mailbox)
else
if
(
len
<
0
)
{
/* Corrupted mailbox. */
fprintf
(
stderr
,
"Error expunge:%d: %s"
,
__LINE__
,
mu_error
(
"Error expunge:%d: %s"
,
__LINE__
,
strerror
(
status
));
goto
bailout0
;
}
...
...
@@ -808,7 +809,7 @@ mbox_expunge (mailbox_t mailbox)
status
=
stream_write
(
mailbox
->
stream
,
buffer
,
n
,
offset
,
&
n
);
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"Error expunge:%d: %s
\n
"
,
__LINE__
,
mu_error
(
"Error expunge:%d: %s
\n
"
,
__LINE__
,
strerror
(
status
));
goto
bailout
;
}
...
...
@@ -822,7 +823,7 @@ mbox_expunge (mailbox_t mailbox)
status
=
stream_truncate
(
mailbox
->
stream
,
total
+
marker
);
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"Error expunging:%d: %s
\n
"
,
__LINE__
,
mu_error
(
"Error expunging:%d: %s
\n
"
,
__LINE__
,
strerror
(
status
));
goto
bailout
;
}
...
...
mailbox/mbx_pop.c
View file @
321044b
...
...
@@ -45,6 +45,7 @@
#include <mailutils/attribute.h>
#include <mailutils/url.h>
#include <mailutils/auth.h>
#include <mailutils/error.h>
#include <mailbox0.h>
#include <registrar0.h>
...
...
@@ -592,7 +593,7 @@ pop_open (mailbox_t mbox, int flags)
default:
/*
fprintf (stderr,
"pop_open unknown state\n");
mu_error (
"pop_open unknown state\n");
*/
break
;
}
/* End AUTHORISATION state. */
...
...
@@ -648,13 +649,13 @@ pop_close (mailbox_t mbox)
lets just be verbose about the error but close the connection
anyway. */
if
(
strncasecmp
(
mpd
->
buffer
,
"+OK"
,
3
)
!=
0
)
fprintf
(
stderr
,
"pop_close: %s
\n
"
,
mpd
->
buffer
);
mu_error
(
"pop_close: %s
\n
"
,
mpd
->
buffer
);
stream_close
(
mbox
->
stream
);
break
;
default:
/*
fprintf (stderr,
"pop_close unknow state");
mu_error (
"pop_close unknow state");
*/
break
;
}
/* UPDATE state. */
...
...
@@ -895,7 +896,7 @@ pop_messages_count (mailbox_t mbox, size_t *pcount)
default:
/*
fprintf (stderr,
"pop_messages_count: unknow state\n");
mu_error (
"pop_messages_count: unknow state\n");
*/
break
;
}
...
...
@@ -1010,7 +1011,7 @@ pop_expunge (mailbox_t mbox)
break
;
default:
/*
fprintf (stderr,
"pop_expunge: unknow state\n"); */
/*
mu_error (
"pop_expunge: unknow state\n"); */
break
;
}
/* switch (state) */
}
/* if attribute_is_deleted() */
...
...
@@ -1100,7 +1101,7 @@ pop_message_size (message_t msg, size_t *psize)
default:
/*
fprintf (stderr,
"pop_message_size state\n");
mu_error (
"pop_message_size state\n");
*/
break
;
}
...
...
@@ -1291,7 +1292,7 @@ pop_uidl (message_t msg, char *buffer, size_t buflen, size_t *pnwriten)
default:
/*
fprintf (stderr,
"pop_uidl state\n");
mu_error (
"pop_uidl state\n");
*/
break
;
}
...
...
@@ -1385,7 +1386,7 @@ pop_top (header_t header, char *buffer, size_t buflen,
MAILBOX_DEBUG0
(
mpd
->
mbox
,
MU_DEBUG_PROT
,
mpd
->
buffer
);
if
(
strncasecmp
(
mpd
->
buffer
,
"+OK"
,
3
)
!=
0
)
{
/*
fprintf (stderr,
"TOP not implemented\n"); */
/*
mu_error (
"TOP not implemented\n"); */
/* Fall back to RETR call. */
mpd
->
state
=
POP_NO_STATE
;
mpm
->
skip_header
=
0
;
...
...
@@ -1744,7 +1745,7 @@ pop_retr (pop_message_t mpm, char *buffer, size_t buflen, off_t offset,
/* A convenient break, this is here we can return 0, we're done. */
default:
/*
fprintf (stderr,
"pop_retr unknow state\n"); */
/*
mu_error (
"pop_retr unknow state\n"); */
break
;
}
/* Switch state. */
...
...
mailbox/message.c
View file @
321044b
...
...
@@ -258,7 +258,7 @@ message_set_header (message_t msg, header_t hdr, void *owner)
return
EINVAL
;
if
(
msg
->
owner
!=
owner
)
return
EACCES
;
/* Make sure we destoy the old if it was own by the mesg */
/* Make sure we dest
r
oy the old if it was own by the mesg */
/* FIXME: I do not know if somebody has already a ref on this ? */
if
(
msg
->
header
)
header_destroy
(
&
(
msg
->
header
),
msg
);
...
...
mailbox/muerror.c
0 → 100644
View file @
321044b
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Library Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <mailutils/error.h>
static
int
default_error_printer
(
const
char
*
fmt
,
va_list
ap
)
{
int
status
;
status
=
vfprintf
(
stderr
,
fmt
,
ap
);
if
(
status
>=
0
)
{
if
(
fputc
(
'\n'
,
stderr
)
!=
EOF
)
status
++
;
}
return
status
;
}
static
error_pfn_t
mu_error_printer
=
default_error_printer
;
int
mu_error
(
const
char
*
fmt
,
...)
{
int
status
;
va_list
ap
;
if
(
!
mu_error_printer
)
return
0
;
va_start
(
ap
,
fmt
);
status
=
(
*
mu_error_printer
)
(
fmt
,
ap
);
va_end
(
ap
);
return
status
;
}
void
mu_error_set_print
(
error_pfn_t
pfn
)
{
mu_error_printer
=
pfn
;
}
mailbox/stream.c
View file @
321044b
...
...
@@ -167,8 +167,8 @@ stream_read (stream_t is, char *buf, size_t count,
int
r
;
/* Fill the buffer, do not want to start empty hand. */
/
/ if (is->rbuffer.count <= 0 || offset < is->rbuffer.offset
/
/ || offset > (is->rbuffer.offset + is->rbuffer.count))
/
* if (is->rbuffer.count <= 0 || offset < is->rbuffer.offset */
/
* || offset > (is->rbuffer.offset + is->rbuffer.count)) */
if
(
is
->
rbuffer
.
count
<=
0
||
offset
!=
is
->
rbuffer
.
offset
)
{
status
=
refill
(
is
,
offset
);
...
...
@@ -286,8 +286,8 @@ stream_readline (stream_t is, char *buf, size_t count,
count
--
;
/* Leave space for the null. */
/* If out of range refill. */
/
/ if ((offset < is->rbuffer.offset
/
/ || offset > (is->rbuffer.offset + is->rbuffer.count)))
/
* if ((offset < is->rbuffer.offset */
/
* || offset > (is->rbuffer.offset + is->rbuffer.count))) */
if
(
offset
!=
is
->
rbuffer
.
offset
)
{
status
=
refill
(
is
,
offset
);
...
...
@@ -335,7 +335,6 @@ stream_readline (stream_t is, char *buf, size_t count,
(
void
)
memcpy
((
void
*
)
s
,
(
void
*
)
p
,
len
);
total
+=
len
;
s
[
len
]
=
0
;
//fprintf (stderr, ":%d %d:%s", len, total, s);
if
(
pnread
)
*
pnread
=
total
;
return
0
;
...
...
@@ -344,13 +343,11 @@ stream_readline (stream_t is, char *buf, size_t count,
is
->
rbuffer
.
ptr
+=
len
;
is
->
rbuffer
.
offset
+=
len
;
(
void
)
memcpy
((
void
*
)
s
,
(
void
*
)
p
,
len
);
//fprintf (stderr, "!:%d %d\n", len, total);
total
+=
len
;
s
+=
len
;
count
-=
len
;
}
*
s
=
0
;
//fprintf (stderr, "1:%s", s);
if
(
pnread
)
*
pnread
=
s
-
buf
;
}
...
...
@@ -627,10 +624,7 @@ refill (stream_t stream, off_t offset)
status
=
stream
->
_read
(
stream
,
stream
->
rbuffer
.
ptr
,
stream
->
rbuffer
.
bufsiz
,
offset
,
(
size_t
*
)
&
(
stream
->
rbuffer
.
count
));
//fprintf (stderr, "COUNT%d\n", stream->rbuffer.count);
//stream->rbuffer.ptr[stream->rbuffer.count] = 0;
//fprintf (stderr, "%s\n", stream->rbuffer.ptr);
return
status
;
}
return
ENO
TSUP
;
return
ENO
SYS
;
}
...
...
pop3d/pop3d.c
View file @
321044b
...
...
@@ -49,6 +49,8 @@ static struct option long_options[] =
const
char
*
short_options
=
"d::hip:t:v"
;
static
int
syslog_error_printer
__P
((
const
char
*
fmt
,
va_list
ap
));
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -143,7 +145,8 @@ main (int argc, char **argv)
chdir
(
"/"
);
/* Set up for syslog. */
openlog
(
"gnu-pop3d"
,
LOG_PID
,
LOG_MAIL
);
openlog
(
"gnu-pop3d"
,
LOG_PID
,
LOG_FACILITY
);
mu_error_set_print
(
syslog_error_printer
);
umask
(
S_IROTH
|
S_IWOTH
|
S_IXOTH
);
/* 007 */
...
...
@@ -422,3 +425,10 @@ pop3d_daemon (unsigned int maxchildren)
close
(
connfd
);
}
}
static
int
syslog_error_printer
(
const
char
*
fmt
,
va_list
ap
)
{
vsyslog
(
LOG_CRIT
,
fmt
,
ap
);
return
0
;
}
...
...
pop3d/pop3d.h
View file @
321044b
...
...
@@ -104,6 +104,7 @@
#include <mailutils/header.h>
#include <mailutils/body.h>
#include <mailutils/registrar.h>
#include <mailutils/error.h>
/* For Berkley DB2 APOP password file */
#ifdef HAVE_DB_H
...
...
Please
register
or
sign in
to post a comment