JunkBox_Lib 1.10.1
Loading...
Searching...
No Matches
smtp_tool.h File Reference

SMTPツールプログラム ヘッダ More...

#include "protocol.h"
Include dependency graph for smtp_tool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __JBXL_SMTP_TOLLS_H_
 

Functions

char * get_smtp_rcpt (char *mesg)
 
char * get_smtp_mailbox (char *mesg)
 
int is_smtp_onecommand (char *mesg, char *com)
 
int smtp_check_dot (char *mesg)
 

Detailed Description

Author
Fumi.Iseki (C)
Date
2005 12/25

Definition in file smtp_tool.h.

Macro Definition Documentation

◆ __JBXL_SMTP_TOLLS_H_

#define __JBXL_SMTP_TOLLS_H_

Definition at line 2 of file smtp_tool.h.

Function Documentation

◆ get_smtp_mailbox()

char * get_smtp_mailbox ( char * mesg)

char* get_smtp_mailbox(char* mesg)

<forward-path> から <mailbox> を返す.see RFC821
RFC821の <mailbox> とは,通常のメールアドレスのこと.

後ろの文字から探索し,(':' || '<' || ' ') 〜 !(' ' && '>' && CR && LF) を取り出す

Definition at line 62 of file smtp_tool.c.

63{
64 int i, j, k, l;
65 char* mb;
66
67 i = strlen((const char*)mesg);
68 mb = (char*)malloc(i+1);
69 if (mb==NULL) return NULL;
70 memset(mb, 0, i+1);
71
72 i--;
73 while(i>=0) {
74 if (mesg[i]!=' ' && mesg[i]!='>' && mesg[i]!=CHAR_CR && mesg[i]!=CHAR_LF) break;
75 i--;
76 }
77 l = i;
78
79 while(i>=0) {
80 if (mesg[i]==':' || mesg[i]=='<' || mesg[i]==' ') break;
81 i--;
82 }
83 k = i + 1;
84
85 for (i=k, j=0; i<=l; i++) mb[j++] = mesg[i];
86
87 return mb;
88}
#define CHAR_CR
改行
Definition tools.h:78
#define CHAR_LF
ラインフィード
Definition tools.h:79

References CHAR_CR, and CHAR_LF.

Referenced by get_smtp_rcpt().

Here is the caller graph for this function:

◆ get_smtp_rcpt()

char * get_smtp_rcpt ( char * mesg)

char* get_smtp_rcpt(char* mesg)

mesg から RCPT TO: コマンドを検索し,配送先のメールアドレスを返す.

Definition at line 22 of file smtp_tool.c.

23{
24 char* pp;
25 char* pt;
26 char* pc;
27 char* pa = NULL;
28
29 pp = awk(mesg, ':', 1);
30 pc = pack_char(pp, ' ');
31 freeNull(pp);
32 if (pc==NULL) return NULL;
33
34 if (!strcasecmp("RCPT TO", pc)) {
35 pp = (char*)malloc(strlen((const char*)mesg)+1);
36 pt = strstr(mesg, ":");
37 if (pp==NULL || pt==NULL) {
38 if (pc!=NULL) freeNull(pc);
39 if (pp!=NULL) freeNull(pp);
40 return NULL;
41 }
42 memset(pp, 0, strlen((const char*)mesg)+1);
43 memcpy(pp, pt, strlen((const char*)pt));
44
45 pa = get_smtp_mailbox(pp);
46 freeNull(pp);
47 }
48
49 freeNull(pc);
50 return pa;
51}
char * get_smtp_mailbox(char *mesg)
Definition smtp_tool.c:62
char * awk(char *buf, char cc, int n)
ccを区切り記号として, strのバッファ内の n番目の項目を返す.要 free()
Definition tools.c:567
#define freeNull(p)
Definition tools.h:201
#define pack_char(s, c)
pack_char_len()
Definition tools.h:236

References awk(), freeNull, get_smtp_mailbox(), and pack_char.

Here is the call graph for this function:

◆ is_smtp_onecommand()

int is_smtp_onecommand ( char * mesg,
char * com )

int is_smtp_onecommand(char* mesg, char* com)

DATA, RSETなどの空白無し,引数なしのコマンドを識別する.

Definition at line 96 of file smtp_tool.c.

97{
98 int ret = FALSE;
99 char* pp;
100 char* pc;
101
102 pp = pack_char(mesg, ' ');
103 pc = awk(pp, ' ', 1);
104 freeNull(pp);
105 if (pc==NULL) return FALSE;
106
107 if (!strncasecmp(com, pc, strlen((const char*)com))) ret = TRUE;
108
109 freeNull(pc);
110 return ret;
111}
#define TRUE
Definition common.h:226
#define FALSE
Definition common.h:223

References awk(), FALSE, freeNull, pack_char, and TRUE.

Here is the call graph for this function:

◆ smtp_check_dot()

int smtp_check_dot ( char * mesg)

int smtp_check_dot(char* mesg)

メールの終わり "@\r@\n.@\r@\n" を探す.

Returns
\r\n.\r\n を見つけたら TRUE, 無かったら FALSE

Definition at line 121 of file smtp_tool.c.

122{
123 static int preDot = OFF;
124 char* p = mesg;
125
126 if (preDot==ON) { // 文頭で ".\r\n" を探す.
127 if (!strncmp(".\r\n", mesg, 3)) {
128 preDot = OFF;
129 return TRUE;
130 }
131 preDot = OFF;
132 }
133
134 while(*p!='\0') {
135 if (!strncmp("\r\n", p, 2)) { // 文中で "\r\n" を探す.
136 if (p[2]=='\0') { // 文末で "\r\n" を探す.
137 preDot = ON;
138 return FALSE;
139 }
140 else if (!strncmp("\r\n.\r\n", p, 5)) { // 文中で "\r\n.\r\n" を探す.
141 preDot = OFF;
142 return TRUE;
143 }
144 }
145 p++;
146 }
147 return FALSE;
148}
#define OFF
Definition common.h:231
#define ON
Definition common.h:230

References FALSE, OFF, ON, and TRUE.