1 |
ben |
1 |
/* this is parsing.c file, part of the libspopc library sources |
2 |
|
|
* copyright © 2002- Benoit Rouits <brouits@free.fr> |
3 |
|
|
* released under the terms of the GNU Lesser General Public Licence. |
4 |
|
|
* |
5 |
|
|
* libspopc offers simple API for a pop3 client. |
6 |
|
|
* See RFC 1725 for pop3 specifications. |
7 |
ben |
2 |
* more information on http://herewe.servebeer.com/libspopc/ |
8 |
ben |
1 |
* |
9 |
|
|
* This library is free software; you can redistribute it and/or |
10 |
|
|
* modify it under the terms of the GNU Lesser General Public |
11 |
|
|
* License as published by the Free Software Foundation; either |
12 |
|
|
* version 2.1 of the License, or (at your option) any later version. |
13 |
|
|
* |
14 |
|
|
* This library is distributed in the hope that it will be useful, |
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 |
|
|
* Lesser General Public License for more details. |
18 |
|
|
* |
19 |
|
|
* You should have received a copy of the GNU Lesser General Public |
20 |
|
|
* License along with this library; if not, write to the Free Software |
21 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#include <string.h> |
25 |
|
|
#include "libspopc.h" |
26 |
|
|
|
27 |
ben |
24 |
int dotline(char* buf, int total_size){ |
28 |
ben |
1 |
/* returns 1 if buf contains a "\r\n.\r\n" substring */ |
29 |
ben |
24 |
int skip; |
30 |
ben |
1 |
char* ptr; |
31 |
|
|
|
32 |
|
|
if(!buf){ |
33 |
|
|
return(0); |
34 |
|
|
} |
35 |
ben |
24 |
skip = total_size > TCPBUFLEN ? total_size - TCPBUFLEN : 0; |
36 |
|
|
ptr = buf + skip; |
37 |
ben |
1 |
while((ptr = strchr(ptr,'\r'))){ |
38 |
|
|
/* RFC1939 specifies that the termination line is "CRLF.CRLF" */ |
39 |
|
|
if((ptr[1] == '\n') && (ptr[2] == '.') && (ptr[3] == '\r') && (ptr[4] == '\n')){ |
40 |
|
|
return(1); |
41 |
|
|
} |
42 |
|
|
ptr++; |
43 |
|
|
} |
44 |
|
|
return(0); |
45 |
|
|
} |
46 |
|
|
|
47 |
ben |
6 |
DLLIMPORT int pop3_error(char* string){ |
48 |
ben |
1 |
/* returns 1 if string is a pop server error reply (i.e : -ERR ...) or NULL, 0 else */ |
49 |
|
|
return(string?(!strncmp(string,"-ERR",(size_t)4)):1); |
50 |
|
|
} |