📄 handler.c
字号:
/*
* Embedded SMTP Server Handler Function Examples
*
* ./software/ch5/emsmtpd/handler.c
*
* mtj@cogitollc.com
*
* Copyright 2001,2002 M. Tim Jones <mtj@cogitollc.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General 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
* General Public License for more details.
*
*/
#include <unistd.h>
#include <stdio.h>
#include "server.h"
#include "client.h"
/*
* emitStatusResponse()
*
* Emits a "device status" response to the sender of the mail
* referenced by the passed argument 'mail'.
*
*/
int emitStatusResponse( parseMailType *mail )
{
struct mailHeader response;
char buffer[512];
memset(&response, 0, sizeof(struct mailHeader));
/* Make the sender the new recipient */
strcpy(response.recipient, mail->sender);
/* Acknowledge receipt of the message */
strcpy(response.subject, "Device Status");
strcpy(response.contentType, "text/plain");
response.contents = buffer;
memset(response.contents, 0, sizeof(buffer));
sprintf(response.contents,
"Received status request from %s.\n\n", mail->sender);
sendMail(&response);
return(0);
}
/*
* emitUpdateResponse()
*
* Emits an "update status" response to the sender of the mail
* referenced by the passed argument 'mail'.
*
*/
int emitUpdateResponse( parseMailType *mail )
{
struct mailHeader response;
char buffer[512];
memset(&response, 0, sizeof(struct mailHeader));
/* Make the sender the new recipient */
strcpy(response.recipient, mail->sender);
/* Acknowledge receipt of the message */
strcpy(response.subject, "Received Attachment");
strcpy(response.contentType, "text/plain");
response.contents = buffer;
if (mail->attachlen) {
sprintf(response.contents,
"Received email attachment from %s.\n\n", mail->sender );
sprintf(&response.contents[strlen(response.contents)],
"File was %s of size %d\n", mail->filename, mail->attachlen);
} else {
sprintf(response.contents,
"Error- Received no email attachment from %s.\n\n", mail->sender );
}
sendMail(&response);
return(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -