parsing.c

Go to the documentation of this file.
00001 /* this is parsing.c file.
00002  * this is part of the libspopc library sources
00003  * copyright © 2002 Benoit Rouits <brouits@free.fr>
00004  * released under the terms of GNU LGPL
00005  * (GNU Lesser General Public Licence).
00006  * libspopc offers simple API for a pop3 client (MTA).
00007  * See RFC 1725 for pop3 specifications.
00008  * more information on http://brouits.free.fr/libspopc/
00009  */
00010 
00011 #include <string.h>
00012 #ifdef EBUG
00013 #include <stdio.h>
00014 #endif
00015 #include "libspopc.h"
00016 
00017 int dotline(char* buf){
00018 /* returns 1 if buf contains a "\n.\n" or "\n.\r" substring */
00019 char* ptr;
00020 
00021    if(!buf){
00022 #ifdef EBUG
00023       fprintf(stderr,"<dotline>\nempty buf ?\n");
00024 #endif
00025       return(0);
00026    }
00027    ptr=buf;
00028    while((ptr=strchr(ptr,'.'))){
00029       if(
00030             ((*(ptr - 1) == '\n') || (*(ptr - 1) == '\r'))
00031             &&
00032             ((*(ptr + 1) == '\n') || (*(ptr + 1) == '\0') || 
00033              (*(ptr + 1) == '\r'))
00034         ){
00035          return(1);
00036       }
00037       ptr++;
00038    }
00039    return(0);
00040 }
00041             
00042 int pop3_error(char* string){
00043 /* returns 1 if pop server error reply (i.e : -ERR ...) */
00044         return(string?(!strncmp(string,"-ERR",(size_t)4)):1);
00045 }
Generated on Wed Feb 29 22:50:05 2012 for CXXUtilities by  doxygen 1.6.3