/*
- * dropsbr.c -- create/read/manipulate mail drops
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** dropsbr.c -- create/read/manipulate mail drops
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/nmh.h>
#include <h/utils.h>
#include <fcntl.h>
/*
- * static prototypes
- */
+** static prototypes
+*/
static int mbx_chk_mbox (int);
static int mbx_chk_mmdf (int);
static int map_open (char *, int);
/*
- * Main entry point to open/create and lock
- * a file or maildrop.
- */
+** Main entry point to open/create and lock
+** a file or maildrop.
+*/
int
mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
errno = j;
/*
- * Return if we still failed after 4 attempts,
- * or we just want to skip the sanity checks.
- */
+ ** Return if we still failed after 4 attempts,
+ ** or we just want to skip the sanity checks.
+ */
if (fd == NOTOK || mbx_style == OTHER_FORMAT)
return fd;
/*
- * Do sanity checks on maildrop.
- */
+ ** Do sanity checks on maildrop.
+ */
if (fstat (fd, &st) == NOTOK) {
/*
- * The stat failed. So we make sure file
- * has right ownership/modes
- */
+ ** The stat failed. So we make sure file
+ ** has right ownership/modes
+ */
chown (file, uid, gid);
chmod (file, mode);
} else if (st.st_size > (off_t) 0) {
/*
- * Check/prepare MBOX style maildrop for appending.
- */
+** Check/prepare MBOX style maildrop for appending.
+*/
static int
mbx_chk_mbox (int fd)
/*
- * Check/prepare MMDF style maildrop for appending.
- */
+** Check/prepare MMDF style maildrop for appending.
+*/
static int
mbx_chk_mmdf (int fd)
/*
- * Append message to end of file or maildrop.
- */
+** Append message to end of file or maildrop.
+*/
int
mbx_copy (char *mailbox, int mbx_style, int md, int fd,
for (j = 0; fgets (buffer, sizeof(buffer), fp) != NULL; j++) {
/*
- * Check the first line, and make some changes.
- */
+ ** Check the first line, and make some changes.
+ */
if (j == 0 && !text) {
/*
- * Change the "Return-Path:" field (if in first line)
- * back to "From ".
- */
+ ** Change the "Return-Path:" field
+ ** (if in first line) back to "From ".
+ */
if (!strncmp (buffer, "Return-Path:", 12)) {
char tmpbuffer[BUFSIZ];
char *tp, *ep, *fp;
(int)(fp - ep), ep, tp);
} else if (!strncmp (buffer, "X-Envelope-From:", 16)) {
/*
- * Change the "X-Envelope-From:" field
- * (if first line) back to "From ".
- */
+ ** Change the "X-Envelope-From:"
+ ** field (if first line) back
+ ** to "From ".
+ */
char tmpbuffer[BUFSIZ];
char *ep;
snprintf (buffer, sizeof(buffer), "From %s", ep);
} else if (strncmp (buffer, "From ", 5)) {
/*
- * If there is already a "From " line,
- * then leave it alone. Else we add one.
- */
+ ** If there is already a "From "
+ ** line, then leave it alone.
+ ** Else we add one.
+ */
char tmpbuffer[BUFSIZ];
char *tp, *ep;
}
/*
- * If this is not first line, and begins with
- * "From ", then prepend line with ">".
- */
+ ** If this is not first line, and begins with
+ ** "From ", then prepend line with ">".
+ */
if (j != 0 && strncmp (buffer, "From ", 5) == 0) {
write (md, ">", 1);
size++;
lseek (fd, (off_t) 0, SEEK_END);
stop = lseek (md, (off_t) 0, SEEK_CUR);
if (mapping)
- map_write (mailbox, md, 0, (long) 0, start, stop, pos, size, noisy);
+ map_write (mailbox, md, 0, (long) 0, start,
+ stop, pos, size, noisy);
return OK;
}
/*
- * Close and unlock file/maildrop.
- */
+** Close and unlock file/maildrop.
+*/
int
mbx_close (char *mailbox, int md)
/*
- * This function is performed implicitly by getbbent.c:
- * bb->bb_map = map_name (bb->bb_file);
- */
+** This function is performed implicitly by getbbent.c:
+** bb->bb_map = map_name (bb->bb_file);
+*/
char *
map_name (char *file)