/[libspopc]/parsing.c
ViewVC logotype

Contents of /parsing.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26 - (show annotations)
Thu Apr 12 15:51:16 2012 UTC (7 years, 1 month ago) by ben
File MIME type: text/plain
File size: 1730 byte(s)
fix dotline() since previous commit

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

  ViewVC Help
Powered by ViewVC 1.1.26