/[libspopc]/parsing.c
ViewVC logotype

Annotation of /parsing.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (hide annotations)
Wed Apr 11 14:06:48 2012 UTC (8 years, 2 months ago) by ben
File MIME type: text/plain
File size: 1723 byte(s)
Removed old homepage reference in docs and headers

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     *
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 ben 24 int dotline(char* buf, int total_size){
27 ben 1 /* returns 1 if buf contains a "\r\n.\r\n" substring */
28 ben 24 int skip;
29 ben 1 char* ptr;
30    
31     if(!buf){
32     return(0);
33     }
34 ben 24 skip = total_size > TCPBUFLEN ? total_size - TCPBUFLEN : 0;
35     ptr = buf + skip;
36 ben 1 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 ben 6 DLLIMPORT int pop3_error(char* string){
47 ben 1 /* 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