⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bb_wtmail.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef	POP/* bb_wtmail.c - write mail to a BBoard */#else	POP/* po_wtmail.c - write mail for a POP subscriber */#endif	POP#ifndef	lintstatic char Id[] = "@(#)$Id: bb_wtmail.c,v 1.3 1993/08/25 17:43:26 jromine Exp $";#endif#include "util.h"#include "mmdf.h"#include "bboards.h"#include "cnvtdate.h"#include "ch.h"#include "phs.h"#include <pwd.h>#include <sys/stat.h>/*  */#ifndef	RP_DOK#define	submitopts	"vmth%s*"#else	RP_DOK#define	submitopts	"vkmth%s*"#endif	RP_DOK#ifndef	POP#define	RP_NOPE	RP_AOK#define	MBXMODE	BBMODE#else	POP#define	RP_NOPE	RP_USER#define	MBXMODE	sentprotectextern int   sentprotect;#endif	POPint	err_fd = NOTOK;int     ds_address ();extern int  errno;int    bbrduid, bbrdgid;char   *chnlname,        chnlinfo[LINESIZE];#ifndef	POPchar	bbrdaddr[LINESIZE],        bbrdfrom[LINESIZE],        bbrdheader[LINESIZE],	bbrdhome[LINESIZE],        bbrdtime[LINESIZE];#endif	not POPextern char *qu_msgfile,            *delim1,            *delim2,	    *lckdfldir,            *locdomain,            *locmachine,            *locname,	    *sitesignature,	    *supportaddr;struct bboard  *curbb;extern LLog *logptr;FILE *lk_fopen();off_t    lseek ();char   *index (), *rindex (), *sprintf ();struct passwd  *getpwnam ();/*  */bb_init (chanptr)Chan * chanptr;{    int     uid,            eid;    struct passwd *pw;#ifdef DEBUG    ll_log (logptr, LLOGBTR, "bb_init(chanptr=%s)", chanptr -> ch_name);#endif    chnlname = chanptr -> ch_name;#ifndef	notdef    sprintf (chnlinfo, submitopts, chnlname);#else	notdef			/* the following is probably a BAD idea */    if (chanptr -> ch_host == NULL)	chnlinfo[0] = NULL;	/* local delivery ONLY */    else	sprintf (chnlinfo, submitopts, chanptr -> ch_host);#endif	notdef#ifndef	POP    if ((pw = getpwnam (BBOARDS)) == NULL)	err_abrt (RP_BHST, "no passwd entry for '%s'", BBOARDS);#else	POP    if ((pw = getpwnam (POPUID)) == NULL)	err_abrt (RP_BHST, "no passwd entry for '%s'", POPUID);#endif	POP    bbrduid = pw -> pw_uid;    bbrdgid = pw -> pw_gid;#ifndef	POP    if (isstr (locmachine))	sprintf (bbrdfrom, "%s@%s.%s.%s", pw -> pw_name, locmachine, locname,		locdomain);    else	sprintf (bbrdfrom, "%s@%s.%s", pw -> pw_name, locname, locdomain);#ifdef DEBUG    ll_log (logptr, LLOGGEN, "distributing as '%s'", bbrdfrom);#endif    sprintf (bbrdhome, pw -> pw_dir);#endif	not POP#ifndef	POP    if (!setbbent ())	err_abrt (RP_BHST, "setbbent() failed");#else	POP    if (!setpwinfo (pw, POPDB, 1))	err_abrt (RP_BHST, "setbbinfo(%s, %s, 1) failed",		pw -> pw_name, POPDB);#endif	POP    getwho (&uid, &eid);    if (eid != 0)	err_abrt (RP_BHST, "not running as root");    return RP_OK;}bb_end (result)short   result;{#ifdef DEBUG    ll_log (logptr, LLOGBTR, "bb_end(result=0%o)", result);#endif    return RP_OK;}/*  */bb_sbinit () {#ifdef DEBUG    ll_log (logptr, LLOGBTR, "bb_sbinit()");#endif    return RP_OK;}bb_sbend () {#ifdef DEBUG    ll_log (logptr, LLOGBTR, "bb_sbend()");#endif    return RP_OK;}/*  */bb_winit (info, sender)char   *info,       *sender;{#ifdef DEBUG    ll_log (logptr, LLOGBTR, "bb_winit(info='%s',sender='%s')",	    info, sender);#endif    return RP_OK;}/*  */bb_wtadr (host, adr)char   *host,       *adr;{    short   count,            result;    int     len,	    md,            offset,	    size;    long    start,            stop,            pos;    char   *cp,            buffer[BUFSIZ];#ifdef DEBUG    ll_log (logptr, LLOGBTR, "bb_wtadr(host=%s,adr=%s)", host, adr);#endif    if ((cp = index (adr, '@')) != NULL)	*cp = NULL;    make_lower (adr, adr);    if ((curbb = getbbnam (adr)) == NULL)	return RP_USER;#ifndef	POP    if (isstr (locmachine))	sprintf (bbrdaddr, "local-%s-request@%s.%s.%s", curbb -> bb_name,		locmachine, locname, locdomain);    else	sprintf (bbrdaddr, "local-%s-request@%s.%s", curbb -> bb_name, locname,		locdomain);#endif	not POP#ifdef DEBUG    ll_log (logptr, LLOGGEN, "=> BBoard %s: file='%s' info='%s'",	    curbb -> bb_name, curbb -> bb_file, curbb -> bb_info);#endif    if (curbb -> bb_file == NULL || *curbb -> bb_file == NULL)	return RP_NOPE;#ifdef DEBUG    ll_log (logptr, LLOGGEN, "begin local delivery...");#endif    printx ("\r\nperforming local delivery to file %s...\n",	    curbb -> bb_file);    qu_rtinit (0L);    if ((md = mbx_open (curbb -> bb_file, bbrduid, bbrdgid, MBXMODE)) == NOTOK)	return RP_FIO;#ifndef	POP    if (rp_isbad (result = mbx_init ())) {	mbx_close (curbb -> bb_file, md);	return result;    }#endif	not POP    pos = (long) lseek (md, (off_t)0, 1);    count = strlen (delim1);    if (write (md, delim1, count) != count) {	ll_log (logptr, LLOGTMP, "error writing delim1");	result = NOTOK;	goto clean_up;    }    start = (long) lseek (md, (off_t)0, 1);    size = 0;#ifndef	POP    count = strlen (bbrdheader);    if (write (md, bbrdheader, count) != count) {	ll_log (logptr, LLOGTMP, "error writing BBoard information");	result = NOTOK;	goto clean_up;    }    for (cp = bbrdheader; *cp; cp++, size++)	if (*cp == '\n')	    size++;#endif	not POP    for (len = BUFSIZ;	    rp_gval (result = qu_rtxt (buffer, &len)) == RP_OK;	    len = BUFSIZ) {	for (offset = 0;		(offset = strindex (delim1, buffer)) >= 0;		buffer[offset]++)	    continue;	for (offset = 0;		(offset = strindex (delim2, buffer)) >= 0;		buffer[offset]++)	    continue;	if (write (md, buffer, len) != len) {	    ll_log (logptr, LLOGTMP, "error writing to file '%s'",		    curbb -> bb_file);	    result = NOTOK;	    goto clean_up;	}	for (offset = 0, cp = buffer; offset < len; offset++, size++)	    if (*cp++ == '\n')		size++;    }    if (result < 0)	ll_log (logptr, LLOGTMP, "error reading from message file '%s'",		qu_msgfile);clean_up: ;    stop = (long) lseek (md, (off_t)0, 1);    count = strlen (delim2);    if (write (md, delim2, count) != count)	ll_log (logptr, LLOGTMP, "error writing delim2");    map_write (curbb -> bb_file, md, curbb -> bb_maxima, start, stop, pos,	size, 0);#ifdef DEBUG    ll_log (logptr, LLOGGEN, "end local delivery...");#endif    if (result < 0)	mbx_close (curbb -> bb_file, md);    else	result = mbx_close (curbb -> bb_file, md);    return (result != NOTOK ? RP_OK : RP_FIO);}/*  */bb_txtcpy () {#ifndef	POP    short   result;#ifdef	DEBUG    ll_log (logptr, LLOGBTR, "bb_txtcpy()");#endif    if (curbb -> bb_dist == NULL	    || *curbb -> bb_dist == NULL	    || chnlinfo[0] == NULL)	return RP_MOK;#ifdef DEBUG    ll_log (logptr, LLOGGEN, "begin distribution...");#endif    if (curbb -> bb_file == NULL || *curbb -> bb_file == NULL)	printx ("\r\n");    printx("\rperforming remote distribution\n");    if (rp_isbad (result = dist_init ())	    || rp_isbad (result = dist_adrs ())	    || rp_isbad (result = dist_text ())	    || rp_isbad (result = dist_end ()))	return dist_lose (result);#ifdef DEBUG    ll_log (logptr, LLOGGEN, "end distribution...");#endif    if (err_fd != NOTOK)	dist_lose (RP_MOK);    else	printx ("\rmessage distributed\n");#endif	not POP    return RP_MOK;}/*  */#ifndef	POP/* **************** (dist_)  BBOARD DISTRIBUTION **************** */dist_init () {    short   result;#ifdef	RP_NS    int	    len;    struct rp_bufstruct reply;#endif	RP_NS#ifdef DEBUG    ll_log (logptr, LLOGBTR, "dist_init()");#endif    if (rp_isbad (result = mm_init ()))	return ds_log (result, LLOGFAT, "mm_init() failed [%s]",		rp_valstr (result));    if (rp_isbad (result = mm_sbinit ()))	return ds_log (result, LLOGFAT, "mm_sbinit() failed [%s]",		rp_valstr (result));    if (rp_isbad (result = mm_winit (chnlname, chnlinfo, bbrdaddr)))	return ds_log (result, LLOGFAT,		"mm_winit('%s','%s','%s') failed [%s]",		chnlname, chnlinfo, bbrdaddr, rp_valstr (result));#ifdef	RP_NS	if (rp_isbad (result = mm_rrply (&reply, &len)))	    return ds_log (result, LLOGFAT, "problem with sender address [%s]",		    rp_valstr (result));#endif	RP_NS    return result;}/*  */dist_adrs (){    short   result;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -