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

📄 addrsbr.c.orig

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 ORIG
📖 第 1 页 / 共 2 页
字号:
	mp -> m_type = uleq (LocalName (), mp -> m_host)	    ? LOCALHOST : NETHOST;#ifdef	DUMB    else	mp -> m_type = uleq (LocalName (), mp -> m_host) ? LOCALHOST		: NETHOST;#else	not DUMB    else	if (pp = OfficialName (mp -> m_host)) {    got_real_host: ;	    free (mp -> m_host);	    mp -> m_host = getcpy (pp);	    mp -> m_type = uleq (LocalName (), mp -> m_host) ? LOCALHOST		    : NETHOST;	}	else {	    if (dp = index (mp -> m_host, '.')) {		*dp = NULL;		if (pp = OfficialName (mp -> m_host))		    goto got_real_host;		*dp = '.';	    }	    mp -> m_type = BADHOST;	}#endif	not DUMBgot_host: ;    if (route)	mp -> m_path = getcpy (route);    mp -> m_ingrp = ingrp;    if (grp)	mp -> m_gname = getcpy (grp);    if (note)	mp -> m_note = getcpy (note);#endif	not BERK    return mp;}/*  */void	mnfree (mp)register struct mailname *mp;{    if (!mp)	return;    if (mp -> m_text)	free (mp -> m_text);    if (mp -> m_pers)	free (mp -> m_pers);    if (mp -> m_mbox)	free (mp -> m_mbox);    if (mp -> m_host)	free (mp -> m_host);    if (mp -> m_path)	free (mp -> m_path);    if (mp -> m_gname)	free (mp -> m_gname);    if (mp -> m_note)	free (mp -> m_note);#ifdef	MHMTS    if (mp -> m_aka)	free (mp -> m_aka);#endif	MHMTS    free ((char *) mp);}/*  */char   *auxformat (mp, extras)register struct mailname   *mp;int	extras;{#ifndef	BERK#ifdef	MF    char   *up = UucpChan ();#endif	MF    static char addr[BUFSIZ];#endif	not BERK    static char buffer[BUFSIZ];#ifdef	BERK    /* this "if" is a crufty hack to handle "visible" aliases */    if (mp->m_pers && !extras)	(void) sprintf (buffer, "%s <%s>", mp->m_pers, mp->m_mbox);    else	(void) strcpy (buffer, mp -> m_text);#else	not BERK#ifdef	MF    if (up && mp -> m_type == UUCPHOST)#ifdef	MMDFMTS	(void) sprintf (addr, "%s!%s%%%s@%s", mp -> m_host, mp -> m_mbox,		up, LocalName ());#else	not MMDFMTS	(void) sprintf (addr, "%s@%s.%s", mp -> m_mbox, mp -> m_host, up);#endif	not MMDFMTS    else #endif	MF#ifdef	DUMB	if (mp -> m_nohost)	    (void) strcpy (addr, mp -> m_mbox ? mp -> m_mbox : "");	else#endif	DUMB#ifndef	BANG	if (mp -> m_type != UUCPHOST)	    (void) sprintf (addr, mp -> m_host ? "%s%s@%s" : "%s%s",		mp -> m_path ? mp -> m_path : "", mp -> m_mbox, mp -> m_host);	else#endif	not BANG	    (void) sprintf (addr, "%s!%s", mp -> m_host, mp -> m_mbox);    if (!extras)	return addr;    if (mp -> m_pers || mp -> m_path)	if (mp -> m_note)	    (void) sprintf (buffer, "%s %s <%s>",		    legal_person (mp -> m_pers ? mp -> m_pers : mp -> m_mbox),		    mp -> m_note, addr);	else	    (void) sprintf (buffer, "%s <%s>",		    legal_person (mp -> m_pers ? mp -> m_pers : mp -> m_mbox),		    addr);    else	if (mp -> m_note)	    (void) sprintf (buffer, "%s %s", addr, mp -> m_note);	else	    (void) strcpy (buffer, addr);#endif	not BERK    return buffer;}/*  */#if	defined(BERK) || (defined(DUMB) && !defined(MMDFMTS) && !defined(SMTP))#define	REALLYDUMB#else#undef	REALLYDUMB#endifchar   *adrsprintf (local, domain)char   *local,       *domain;{    static char addr[BUFSIZ];    if (local == NULL)#ifdef	REALLYDUMB	return getusr ();    else#endif	REALLYDUMB	local = getusr ();    if (domain == NULL)#ifdef	REALLYDUMB	return local;    else#endif	REALLYDUMB	domain = LocalName ();#ifndef	BANG    (void) sprintf (addr, "%s@%s", local, domain);#else	BANG    (void) sprintf (addr, "%s!%s", domain, local);#endif	BANG    return addr;}/*  */#define	W_NIL	0x0000#define	W_MBEG	0x0001#define	W_MEND	0x0002#define	W_MBOX	(W_MBEG | W_MEND)#define	W_HBEG	0x0004#define	W_HEND	0x0008#define	W_HOST	(W_HBEG | W_HEND)#define	WBITS	"\020\01MBEG\02MEND\03HBEG\04HEND"int	ismymbox (np)register struct mailname *np;{    int     oops;    register int    len,                    i;    register char  *cp;#ifndef	BERK    register char  *pp;    char    buffer[BUFSIZ];#endif	not BERK    register struct mailname   *mp;    static char *am = NULL;    static struct mailname  mq={NULL};#ifdef X400    extern char	need_x400_me;#endif X400    /* if this is the first call, init. alternate mailboxes list */    if (am == NULL) {	mq.m_next = NULL;	mq.m_mbox = getusr ();	if ((am = m_find ("alternate-mailboxes")) == NULL)	    am = getusr ();	else {	    mp = &mq;	    oops = 0;	    while (cp = getname (am))		if ((mp -> m_next = getm (cp, NULLCP, 0, AD_NAME, NULLCP))			== NULL)		    admonish (NULLCP, "illegal address: %s", cp), oops++;		else {		    mp = mp -> m_next;		    mp -> m_type = W_NIL;#ifdef	BERK		    /* check for wildcards on the mailbox name and		       set m_type accordingly. */		    mp -> m_ingrp = strlen (mp -> m_mbox);		    if (*(mp -> m_mbox) == '*') {			mp -> m_type |= W_MBEG;			mp -> m_mbox++;			--mp -> m_ingrp;		    }		    if (mp -> m_mbox[mp -> m_ingrp - 1] == '*') {			mp -> m_type |= W_MEND;			mp -> m_ingrp--;			mp -> m_mbox[mp -> m_ingrp] = NULL;		    }#else	not BERK		    /* owing to screwy munging, wildcarding is a great idea		       even under #ifndef BERK, so... */		    mp -> m_type = W_NIL;		    if (*mp -> m_mbox == '*')			mp -> m_type |= W_MBEG, mp -> m_mbox++;		    if (*(cp = mp -> m_mbox + strlen (mp -> m_mbox) - 1)			    == '*')			mp -> m_type |= W_MEND, *cp = NULL;		    if (mp -> m_host) {			if (*mp -> m_host == '*')			    mp -> m_type |= W_HBEG, mp -> m_host++;			if (*(cp = mp -> m_host + strlen (mp -> m_host) - 1)				== '*')			    mp -> m_type |= W_HEND, *cp = NULL;		    }		    if ((cp = getenv ("MHWDEBUG")) && *cp)			fprintf (stderr, "mbox=\"%s\" host=\"%s\" %s\n",			    mp -> m_mbox, mp -> m_host,			    sprintb (buffer, (unsigned) mp -> m_type, WBITS));#endif	not BERK		}	    if (oops)		advise (NULLCP, "please fix the %s: entry in your %s file",			"alternate-mailboxes", mh_profile);	}    }    if (np == NULL) /* XXX */	return 0;    #ifdef	BERK    cp = np -> m_mbox;#ifdef X400    if (need_x400_me == 1 && uleq(cp, mq.m_mbox))	return 1;#endif X400    if (strcmp (cp, mq.m_mbox) == 0)	return 1;#else	not BERK    switch (np -> m_type) {	case NETHOST:	    len = strlen (cp = LocalName ());	    if (!uprf (np -> m_host, cp) || np -> m_host[len] != '.')		break;	    goto local_test;	case UUCPHOST:	    if (!uleq (np -> m_host, SystemName ()))		break;		/* fall */	case LOCALHOST:local_test: ;	    if (uleq (np -> m_mbox, mq.m_mbox))		return 1;	    break;	default:	    break;    }#endif	not BERK#ifdef	BERK    len = strlen (cp);    for (mp = &mq; mp = mp -> m_next;)	if (len >= mp -> m_ingrp)	    switch (mp -> m_type) {		case W_NIL: 	/* no wildcards */		    if (strcmp (cp, mp -> m_mbox) == 0)			return 1;		    break;		case W_MBEG: 	/* wildcard at beginning */		    if (strcmp (&cp[len - mp -> m_ingrp], mp -> m_mbox) == 0)			return 1;		    break;		case W_MEND: 	/* wildcard at end */		    if (strncmp (cp, mp -> m_mbox, mp -> m_ingrp) == 0)			return 1;		    break;		case W_MBEG | W_MEND: /* wildcard at beginning & end */		    for (i = 0; i <= len - mp -> m_ingrp; i++)			if (strncmp (&cp[i], mp -> m_mbox, mp -> m_ingrp) == 0)			    return 1;	    }#else	not BERK    for (mp = &mq; mp = mp -> m_next;) {	if ((len = strlen (cp = np -> m_mbox))		< (i = strlen (pp = mp -> m_mbox)))	    continue;	switch (mp -> m_type & W_MBOX) {	    case W_NIL: 		if (!uleq (cp, pp))		    continue;		break;	    case W_MBEG: 		if (!uleq (cp + len - i, pp))		    continue;		break;	    case W_MEND: 		if (!uprf (cp, pp))		    continue;		break;	    case W_MBEG | W_MEND: 		if (stringdex (pp, cp) < 0)		    continue;		break;	}	if (mp -> m_nohost)	    return 1;	if ((len = strlen (cp = np -> m_host))		< (i = strlen (pp = mp -> m_host)))	    continue;	switch (mp -> m_type & W_HOST) {	    case W_NIL: 		if (!uleq (cp, pp))		    continue;		break;	    case W_HBEG: 		if (!uleq (cp + len - i, pp))		    continue;		break;	    case W_HEND: 		if (!uprf (cp, pp))		    continue;		break;	    case W_HBEG | W_HEND: 		if (stringdex (pp, cp) < 0)		    continue;		break;	}	return 1;    }#endif	not BERK    return 0;}/*  */#ifdef	WP#include <signal.h>static char *fredproc = NULL;char   *wp_expand (query, error)char   *query,       *error;{    register int    cc,		    i,		    vecp;    TYPESIG     (*istat) (), (*qstat) (), (*pstat) ();    register char  *bp,		   *cp;    char   *ep,	    buffer[BUFSIZ],	    fds[10],	   *vec[10];    static int child_id = NOTOK,	    pdi[2],	    pdo[2];    if (error)	(void) strcpy (error, "unable to expand WhitePages query: ");    if (child_id == NOTOK || kill (child_id, 0) == NOTOK) {	if (!isatty (fileno (stdout))) {	    if (error)		(void) strcat (error, "not a tty");	    return NULLCP;	}	if (fredproc == NULL && (fredproc = m_find ("fredproc")) == NULL)	    fredproc = "fred";	if (pipe (pdi) == NOTOK) {	    if (error)		(void) strcat (error, "unable to pipe");	    return NULLCP;	}	if (pipe (pdo) == NOTOK) {	    if (error)		(void) strcat (error, "unable to pipe");losing: ;	    (void) close (pdi[0]);	    (void) close (pdi[1]);	    return NULLCP;	}	for (i = 0; (child_id = vfork ()) == NOTOK && i < 5; i++)	    sleep (5);	switch (child_id) {	    case NOTOK:	        if (error)		    (void) strcat (error, "unable to fork");		(void) close (pdo[0]);		(void) close (pdo[1]);		goto losing;	    case OK:		(void) close (pdi[0]);		(void) close (pdo[1]);		(void) sprintf (fds, "%d %d", pdo[0], pdi[1]);		vecp = 0;		vec[vecp++] = r1bindex (fredproc, '/');		vec[vecp++] = "-q";		vec[vecp++] = fds;		vec[vecp] = NULL;		execvp (fredproc, vec);		_exit (-1);		/* NOTREACHED */	    default:		(void) close (pdi[1]);		(void) close (pdo[0]);		break;	}    }    istat = signal (SIGINT, SIG_IGN);    qstat = signal (SIGQUIT, SIG_IGN);    pstat = signal (SIGPIPE, SIG_IGN);    (void) sprintf (buffer, "%s\n", query);    cc = write (pdo[1], buffer, i = strlen (buffer));    (void) signal (SIGPIPE, pstat);    if (cc != i) {	if (error)	    (void) strcat (error, "write to pipe failed");lost_child: ;	(void) kill (child_id, SIGTERM);	(void) close (pdi[0]);	(void) close (pdo[1]);	child_id = NOTOK;	return NULLCP;    }    for (ep = (bp = buffer) + sizeof buffer - 1;	     (i = read (pdi[0], bp, ep - bp)) > 0; ) {	for (cp = bp + i; bp < cp; bp++)	    if (*bp == '\n')		break;	if (bp < cp)	    break;    }    (void) signal (SIGINT, istat);    (void) signal (SIGQUIT, qstat);    if (i == NOTOK) {	if (error)	    (void) strcat (error, "read from pipe failed");	goto lost_child;    }    if (i == 0) {	if (error)	    (void) sprintf (error + strlen (error), "%s exited prematurely",			    fredproc);	goto lost_child;    }    *bp = NULL;    if (error)	if (bp != buffer)	    error[0]  = NULL;	else	    (void) strcpy (error, "unable to expand WhitePages query");    return (*buffer ? getcpy (buffer) : NULLCP);}#endif

⌨️ 快捷键说明

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