libexec/bugfiler/reply.c
/*
 * reply --
 *	tell the user we got their silly little bug report
 */
reply
tell the user we got their silly little bug report
reply tell the user we got their silly little bug report
void
reply()
{
	register char	*C,			
			*to;			
	register int	afd,			
			rval;			
	FILE	*pf;				
	if (mailhead[RPLY_TAG].found) {
		for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;
		    *C != '\n' && (*C == ' ' || *C == '\t');++C);
		if (*C)
			goto gotone;
	}
	if (mailhead[FROM_TAG].found) {
		for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;
		    *C != '\n' && (*C == ' ' || *C == '\t');++C);
		if (*C)
			goto gotone;
	}
	if (mailhead[CFROM_TAG].found) {
		for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;
		     *C != '\n' && (*C == ' ' || *C == '\t');++C);
		if (*C)
			goto gotone;
	}
	return;
gotone:	if (to = strchr(C, '<'))
		for (C = ++to;
		    *C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C);
	else {
		to = C;
		for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C);
	}
	*C = EOS;
	if (!(pf = popen(MAIL_CMD, "w")))
		error("sendmail pipe failed.", CHN);
	fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n",
	    BUGS_HOME, BUGS_HOME, to);
	if (mailhead[SUBJ_TAG].found)
		fprintf(pf, "Subject: Re:%s",
		    mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len);
	else
		fputs("Subject: Bug report acknowledgement.\n", pf);
	if (mailhead[DATE_TAG].found)
		fprintf(pf, "In-Acknowledgement-Of: Your message of %s",
		    mailhead[DATE_TAG].line + mailhead[DATE_TAG].len);
	if (mailhead[MSG_TAG].found)
		fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line);
	fputs("Precedence: bulk\n\n", pf);	
	fflush(pf);
	(void)sprintf(bfr, "%s/%s", dir, ACK_FILE);
	if ((afd = open(bfr, O_RDONLY, 0)) >= 0) {
		while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval)
			(void)write(fileno(pf), bfr, rval);
		(void)close(afd);
	}
	pclose(pf);
}
void reply ( ) { register char * C , * to ; register int afd , rval ; FILE * pf ; if ( mailhead [ RPLY_TAG ] . found ) { for ( C = mailhead [ RPLY_TAG ] . line + mailhead [ RPLY_TAG ] . len ; * C != ' \n ' && ( * C == ' ' || * C == ' \t ' ) ; ++ C ) ; if ( * C ) goto gotone ; } if ( mailhead [ FROM_TAG ] . found ) { for ( C = mailhead [ FROM_TAG ] . line + mailhead [ FROM_TAG ] . len ; * C != ' \n ' && ( * C == ' ' || * C == ' \t ' ) ; ++ C ) ; if ( * C ) goto gotone ; } if ( mailhead [ CFROM_TAG ] . found ) { for ( C = mailhead [ CFROM_TAG ] . line + mailhead [ CFROM_TAG ] . len ; * C != ' \n ' && ( * C == ' ' || * C == ' \t ' ) ; ++ C ) ; if ( * C ) goto gotone ; } return ; gotone : if ( to = strchr ( C , ' ' ) ) for ( C = ++ to ; * C != ' \n ' && * C != ' ' && * C != ' \t ' && * C != ' ' ; ++ C ) ; else { to = C ; for ( to = C ++ ; * C != ' \n ' && * C != ' ' && * C != ' \t ' ; ++ C ) ; } * C = EOS ; if ( ! ( pf = popen ( MAIL_CMD , " " ) ) ) error ( " " , CHN ) ; fprintf ( pf , " \n \n \n " , BUGS_HOME , BUGS_HOME , to ) ; if ( mailhead [ SUBJ_TAG ] . found ) fprintf ( pf , " " , mailhead [ SUBJ_TAG ] . line + mailhead [ SUBJ_TAG ] . len ) ; else fputs ( " \n " , pf ) ; if ( mailhead [ DATE_TAG ] . found ) fprintf ( pf , " " , mailhead [ DATE_TAG ] . line + mailhead [ DATE_TAG ] . len ) ; if ( mailhead [ MSG_TAG ] . found ) fprintf ( pf , " \t \t " , mailhead [ MSG_TAG ] . line ) ; fputs ( " \n \n " , pf ) ; fflush ( pf ) ; ( void ) sprintf ( bfr , " " , dir , ACK_FILE ) ; if ( ( afd = open ( bfr , O_RDONLY , 0 ) ) >= 0 ) { while ( ( rval = read ( afd , bfr , sizeof ( bfr ) ) ) != ERR && rval ) ( void ) write ( fileno ( pf ) , bfr , rval ) ; ( void ) close ( afd ) ; } pclose ( pf ) ; }
reply
      tell the user we got their silly little bug report
reply tell the user we got their silly little bug report
/* traveling pointer */ /* who we're replying to */ /* ack file descriptor */ /* return value */ /* pipe pointer */ /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ /* vacation(1) uses this... */