libspopc.h   libspopc.h 
/* this is libspopc.h file, part of the libspopc library sources /* this is libspopc.h file, part of the libspopc library sources
* copyright * copyright
* released under the terms of the GNU Lesser General Public Licence. * released under the terms of the GNU Lesser General Public Licence.
* *
* libspopc offers simple API for a pop3 client. * libspopc offers simple API for a pop3 client.
* See RFC 1725 for pop3 specifications. * See RFC 1725 for pop3 specifications.
* more information on http://brouits.free.fr/libspopc/ * more information on http://herewe.servebeer.com/libspopc/
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
skipping to change at line 35 skipping to change at line 35
#define LIBSPOPC_H #define LIBSPOPC_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#ifdef WIN32 #ifdef WIN32
#include <winsock.h> #include <winsock.h>
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
#else #else
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netdb.h> #include <netdb.h>
#define DLLIMPORT
#endif #endif
/* thread-safe version of libspopc (>0.8) */ /* thread-safe version of libspopc (>0.8) */
/* call this function before to use any routine from libspopc */ /* call this function before to use any routine from libspopc */
int libspopc_init(void); DLLIMPORT int libspopc_init(void);
/* call this function when you do not use anymore libspopc routines */ /* call this function when you do not use anymore libspopc routines */
int libspopc_clean(void); DLLIMPORT int libspopc_clean(void);
#ifdef USE_SSL #ifdef USE_SSL
#include <openssl/ssl.h> #include <openssl/ssl.h>
/************************************************************************** **** /************************************************************************** ****
* If compiled with SSL support, the low-level functions will act on a * If compiled with SSL support, the low-level functions will act on a
* "pop3sock" structure, which contains the socket, SSL instance and contex t * "pop3sock" structure, which contains the socket, SSL instance and contex t
* for the connection. This structure is dynamically allocated and initiali zed * for the connection. This structure is dynamically allocated and initiali zed
* when you do pop3_prepare() or popbegin(), and is cleaned-up and destroye d in * when you do pop3_prepare() or popbegin(), and is cleaned-up and destroye d in
skipping to change at line 81 skipping to change at line 87
/************************************************************************** **** /************************************************************************** ****
* Use pop3_cert_setup() to specify the location of your SSL certificate * Use pop3_cert_setup() to specify the location of your SSL certificate
* bundle. If it is not set (or set to NULL), SSL connections can be still be * bundle. If it is not set (or set to NULL), SSL connections can be still be
* made, but certificates will not be verified! * made, but certificates will not be verified!
* This function sets a global variable, and should be called before * This function sets a global variable, and should be called before
* pop3_prepare() or popbegin() if you want to verify certs. * pop3_prepare() or popbegin() if you want to verify certs.
* *
* Hint: If you have a recent version of curl/libcurl installed, you can tr y * Hint: If you have a recent version of curl/libcurl installed, you can tr y
* setting this to the output of: "curl-config --ca" * setting this to the output of: "curl-config --ca"
************************************************************************** ****/ ************************************************************************** ****/
void pop3_cert_setup(const char *certfile); DLLIMPORT void pop3_cert_setup(const char *certfile);
/************************************************************************** **** /************************************************************************** ****
* pop3_ssl_never() disable the use of SSL on any port, even 995. * pop3_ssl_never() disable the use of SSL on any port, even 995.
* pop3_ssl_auto() enable the use of SSL only on port 995. (default) * pop3_ssl_auto() enable the use of SSL only on port 995. (default)
* pop3_ssl_always() enable the use of SSL on any port, even 110. * pop3_ssl_always() enable the use of SSL on any port, even 110.
* *
* These functions set a library-wide variable, and should be called before * These functions set a library-wide variable, and should be called before
* pop3_prepare() or popbegin() if you want to modify libspopc behaviour. * pop3_prepare() or popbegin() if you want to modify libspopc behaviour.
* By default, not calling any of these, the behaviour of libspopc follows * By default, not calling any of these, the behaviour of libspopc follows
* the same as pop3_ssl_auto() for backward compatibility reason. * the same as pop3_ssl_auto() for backward compatibility reason.
************************************************************************** ****/ ************************************************************************** ****/
void pop3_ssl_never(void); DLLIMPORT void pop3_ssl_never(void);
void pop3_ssl_auto(void); DLLIMPORT void pop3_ssl_auto(void);
void pop3_ssl_always(void); DLLIMPORT void pop3_ssl_always(void);
#else /* Non-SSL */ #else /* Non-SSL */
/************************************************************************** **** /************************************************************************** ****
* If the library is compiled without SSL, the "pop3sock_t" type is a simp le * If the library is compiled without SSL, the "pop3sock_t" type is a simp le
* integer (i.e. socket) and all the functions should work just as they di d * integer (i.e. socket) and all the functions should work just as they di d
* in previous libspopc versions (< 0.8). * in previous libspopc versions (< 0.8).
************************************************************************** ****/ ************************************************************************** ****/
typedef int pop3sock_t; typedef int pop3sock_t;
skipping to change at line 128 skipping to change at line 134
* Be careful, using the low-level API is uncompliant with using the high * Be careful, using the low-level API is uncompliant with using the high
* level API. Here, you make your choice. If you don't know the pop3 protoc ol * level API. Here, you make your choice. If you don't know the pop3 protoc ol
* or what a socket is, it is then warmly recommended to use the *high-leve l* * or what a socket is, it is then warmly recommended to use the *high-leve l*
* API if which is shown far below on this file. * API if which is shown far below on this file.
************************************************************************** ****/ ************************************************************************** ****/
/************** /**************
* connecting * * connecting *
**************/ **************/
pop3sock_t pop3_prepare(const char* servername, const int port, struct sock addr_in* connection, struct hostent* server); DLLIMPORT pop3sock_t pop3_prepare(const char* servername, const int port, s truct sockaddr_in* connection, struct hostent* server);
/* prepares the pop session and returns a socket descriptor, or BAD_SOCK on error */ /* prepares the pop session and returns a socket descriptor, or BAD_SOCK on error */
char* pop3_connect(pop3sock_t sock, struct sockaddr_in* connection); DLLIMPORT char* pop3_connect(pop3sock_t sock, struct sockaddr_in* connectio n);
/* connects to the server through the sock and returns server's welcome */ /* connects to the server through the sock and returns server's welcome */
void pop3_disconnect(pop3sock_t sock, struct hostent* server); DLLIMPORT void pop3_disconnect(pop3sock_t sock, struct hostent* server);
/* close socket and free server info */ /* close socket and free server info */
/**************** /****************
* pop3 queries * * pop3 queries *
****************/ ****************/
char* pop3_user(pop3sock_t sock, const char* name); DLLIMPORT char* pop3_user(pop3sock_t sock, const char* name);
/* performs "USER" pop query and returns server's <=512 bytes resp */ /* performs "USER" pop query and returns server's <=512 bytes resp */
char* pop3_pass(pop3sock_t sock, const char* pw); DLLIMPORT char* pop3_pass(pop3sock_t sock, const char* pw);
/* performs "PASS" pop query and return server's <=512 bytes resp */ /* performs "PASS" pop query and return server's <=512 bytes resp */
char* pop3_quit(pop3sock_t sock); DLLIMPORT char* pop3_quit(pop3sock_t sock);
/* performs "QUIT" pop query and returns server's <=512 bytes resp */ /* performs "QUIT" pop query and returns server's <=512 bytes resp */
char* pop3_stat(pop3sock_t sock); DLLIMPORT char* pop3_stat(pop3sock_t sock);
/* performs "STAT" pop query and returns server's <=512 bytes resp */ /* performs "STAT" pop query and returns server's <=512 bytes resp */
char* pop3_list(pop3sock_t sock, int id); DLLIMPORT char* pop3_list(pop3sock_t sock, int id);
/* performs a "LIST" pop query and returns server's (long) resp */ /* performs a "LIST" pop query and returns server's (long) resp */
char* pop3_retr(pop3sock_t sock, int id); DLLIMPORT char* pop3_retr(pop3sock_t sock, int id);
/* performs a "RETR" pop query and returns server's (long) resp */ /* performs a "RETR" pop query and returns server's (long) resp */
char* pop3_dele(pop3sock_t sock, int id); DLLIMPORT char* pop3_dele(pop3sock_t sock, int id);
/* performs a "DELE" pop query and returns server's <=512 bytes resp */ /* performs a "DELE" pop query and returns server's <=512 bytes resp */
char* pop3_noop(pop3sock_t sock); DLLIMPORT char* pop3_noop(pop3sock_t sock);
/* performs a "NOOP" pop query and returns server's <=512 bytes resp */ /* performs a "NOOP" pop query and returns server's <=512 bytes resp */
char* pop3_rset(pop3sock_t sock); DLLIMPORT char* pop3_rset(pop3sock_t sock);
/* performs a "RSET" pop query and returns server's <=512 bytes resp */ /* performs a "RSET" pop query and returns server's <=512 bytes resp */
char* pop3_top(pop3sock_t sock, int id, int lines); DLLIMPORT char* pop3_top(pop3sock_t sock, int id, int lines);
/* performs a "TOP" pop query and returns server's (long) resp */ /* performs a "TOP" pop query and returns server's (long) resp */
char* pop3_uidl(pop3sock_t sock, int id); DLLIMPORT char* pop3_uidl(pop3sock_t sock, int id);
/* performs a "UIDL" pop query and returns server's (long) resp */ /* performs a "UIDL" pop query and returns server's (long) resp */
char* pop3_apop(pop3sock_t sock, const char* name, const char* digest); DLLIMPORT char* pop3_apop(pop3sock_t sock, const char* name, const char* di gest);
/* performs a "APOP" secure pop query and returns server's <=512 bytes resp */ /* performs a "APOP" secure pop query and returns server's <=512 bytes resp */
/********************* /*********************
* parsing utilities * * parsing utilities *
*********************/ *********************/
#define DOTBEGIN(s) ((s)[0]=='\n'&&(s)[1]=='.') #define DOTBEGIN(s) ((s)[0]=='\n'&&(s)[1]=='.')
int dotline(char* buf); int dotline(char* buf);
/* returns 1 if 'buf' contains a "\n.\n" or "\n.\0" or \r.(etc) substring /* returns 1 if 'buf' contains a "\n.\n" or "\n.\0" or \r.(etc) substring
* buf must be terminated by '\0' */ * buf must be terminated by '\0' */
int pop3_error(char* string); DLLIMPORT int pop3_error(char* string);
/* returns 1 on pop server error (i.e : -ERR ...) or NULL reply */ /* returns 1 on pop server error (i.e : -ERR ...) or NULL reply */
/************************************ /************************************
* reply re-formatting, after query * * reply re-formatting, after query *
************************************/ ************************************/
char* nextline(char* string); DLLIMPORT char* nextline(char* string);
/* returns a pointer to the next line of given string */ /* returns a pointer to the next line of given string */
char* retr2msg(char* data); DLLIMPORT char* retr2msg(char* data);
/* returns formatted mail from a pop RETR X query /* returns formatted mail from a pop RETR X query
* must only be called on data returned by pop3_retr() */ * must only be called on data returned by pop3_retr() */
void freemsg(char* msg); DLLIMPORT void freemsg(char* msg);
/* free the message received by reetr2msg */ /* free the message received by reetr2msg */
int* list2array(char* poplist); DLLIMPORT int* list2array(char* poplist);
/* WARNING: must not be called after a mail deletion /* WARNING: must not be called after a mail deletion
* returns an int array of sizes of messages from a LIST pop query * returns an int array of sizes of messages from a LIST pop query
* array[0] holds id of the array's last element * array[0] holds id of the array's last element
* must only be called on data received by a pop3_list(sock,0) request */ * must only be called on data received by a pop3_list(sock,0) request */
void freelistarray(int* array); DLLIMPORT void freelistarray(int* array);
/* free the message sizes array created by list2array */ /* free the message sizes array created by list2array */
int listi2size(char* resp); DLLIMPORT int listi2size(char* resp);
/* grep the given size (in bytes) in resp after a pop3_list(sock,ID) reques t /* grep the given size (in bytes) in resp after a pop3_list(sock,ID) reques t
* do not use after a pop3_list(sock,0) ! */ * do not use after a pop3_list(sock,0) ! */
int stat2num(char* resp); DLLIMPORT int stat2num(char* resp);
/* returns the number of downloadable messages on pop server */ /* returns the number of downloadable messages on pop server */
int stat2bytes(char* resp); DLLIMPORT int stat2bytes(char* resp);
/* returns the sumsize in bytes of all stored messages on server /* returns the sumsize in bytes of all stored messages on server
* must only be called just after a pop3_stat() request */ * must only be called just after a pop3_stat() request */
char** uidl2array(char* resp); DLLIMPORT char** uidl2array(char* resp);
/* WARNING: mus not be called after a mail deletion /* WARNING: mus not be called after a mail deletion
* returns an array of unique strings for each message id * returns an array of unique strings for each message id
* array[0] gives array's last id * array[0] gives array's last id
* must only be called just after a pop3_uidl(sock,0) request */ * must only be called just after a pop3_uidl(sock,0) request */
void freeuidlarray(char** arrray); DLLIMPORT void freeuidlarray(char** arrray);
/* free the uidl array created by uidl2array */ /* free the uidl array created by uidl2array */
char* uidli2sig(char* resp); DLLIMPORT char* uidli2sig(char* resp);
/* grep the pop signature of *one* message signature reply /* grep the pop signature of *one* message signature reply
* should only be called on data received by a pop3_uidl(sock,ID) request * should only be called on data received by a pop3_uidl(sock,ID) request
* do not use it after a pop3_uidl(sock,0) ! */ * do not use it after a pop3_uidl(sock,0) ! */
/*************************************************** /***************************************************
* high-level API for a SIMPLE MDA/MUA * * high-level API for a SIMPLE MDA/MUA *
***************************************************/ ***************************************************/
/************************************************************************** **** /************************************************************************** ****
* This is the high-level API of libspopc and it is recommended to use it * This is the high-level API of libspopc and it is recommended to use it
skipping to change at line 281 skipping to change at line 287
* arg 's' is type 'popsession*' */ * arg 's' is type 'popsession*' */
#define popmsgsize(s,i) ((s)->list[(i)]) #define popmsgsize(s,i) ((s)->list[(i)])
/* gives the size of message 'i' for session 's' /* gives the size of message 'i' for session 's'
* args are type 'session*'(s) and 'int'(i) * args are type 'session*'(s) and 'int'(i)
* 'i' must *not* be 0 */ * 'i' must *not* be 0 */
#define popmsguid(s,i) ((s)->uidl[(i)]) #define popmsguid(s,i) ((s)->uidl[(i)])
/* points to the 'char*' uid (unique signature) of 'int'(i) message id */ /* points to the 'char*' uid (unique signature) of 'int'(i) message id */
int poplast(popsession* session); DLLIMPORT int poplast(popsession* session);
/* gives the id of the last message of the current session */ /* gives the id of the last message of the current session */
int popnum(popsession* session); DLLIMPORT int popnum(popsession* session);
/* gives the current number of stored message. it is != to poplast() */ /* gives the current number of stored message. it is != to poplast() */
char* popbegin(const char* servername,const char* user, const char* pass, p opsession** sp); DLLIMPORT char* popbegin(const char* servername,const char* user, const cha r* pass, popsession** sp);
/* prepares, connect and get lists of messages stored on pop server /* prepares, connect and get lists of messages stored on pop server
* you must give a valid servername, user and pass * you must give a valid servername, user and pass
* returns an error message if a problem occurs, else NULL */ * returns an error message if a problem occurs, else NULL */
char* popgethead(popsession* session, int id); DLLIMPORT char* popgethead(popsession* session, int id);
/* returns the header of a message (id between 1 and poplast()) or NULL on bad id */ /* returns the header of a message (id between 1 and poplast()) or NULL on bad id */
char* popgetmsg(popsession* session, int id); DLLIMPORT char* popgetmsg(popsession* session, int id);
/* returns a message (id between 1 and poplast()) or NULL on bad id */ /* returns a message (id between 1 and poplast()) or NULL on bad id */
int popdelmsg(popsession* session, int id); DLLIMPORT int popdelmsg(popsession* session, int id);
/* deletes message 'id' on pop server /* deletes message 'id' on pop server
* returns -1 on server error, 0 else */ * returns -1 on server error, 0 else */
int popchkmsg(popsession* session, int id); DLLIMPORT int popchkmsg(popsession* session, int id);
/* tells if a message is still accessible on the server (not deleted) /* tells if a message is still accessible on the server (not deleted)
* returns 1 of so, or 0 if message has been marked for deletion */ * returns 1 of so, or 0 if message has been marked for deletion */
int popcancel(popsession* session); DLLIMPORT int popcancel(popsession* session);
/* cancels all previous deletion on pop server /* cancels all previous deletion on pop server
* returns -1 on server error, 0 else */ * returns -1 on server error, 0 else */
int popsync(popsession* session); DLLIMPORT int popsync(popsession* session);
/* re-synchronize the session object from the server /* re-synchronize the session object from the server
* need to be called if session->sync is 0 * need to be called if session->sync is 0
* returns -1 on error, 0 else */ * returns -1 on error, 0 else */
void popend(popsession* session); DLLIMPORT void popend(popsession* session);
/* quit and destroys pop session */ /* quit and destroys pop session */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 44 change blocks. 
44 lines changed or deleted 50 lines changed or added


 mutex.h   mutex.h 
/* this is mutex.h file, part of the libspopc library sources /* this is mutex.h file, part of the libspopc library sources
* copyright © 2002- Benoit Rouits <brouits@free.fr> * copyright © 2002- Benoit Rouits <brouits@free.fr>
* released under the terms of the GNU Lesser General Public Licence. * released under the terms of the GNU Lesser General Public Licence.
* *
* libspopc offers simple API for a pop3 client. * libspopc offers simple API for a pop3 client.
* See RFC 1725 for pop3 specifications. * See RFC 1725 for pop3 specifications.
* more information on http://brouits.free.fr/libspopc/ * more information on http://herewe.servebeer.com/libspopc/
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13 01 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13 01 USA
*/ */
#ifndef MUTEX_H #ifndef MUTEX_H
#define MUTEX_H #define MUTEX_H
#include <semaphore.h> #ifdef USE_SEM /* no posix thread mutex */
#include <semaphore.h>
typedef sem_t mutex; typedef sem_t mutex; /* use unix rt semaphores from librt */
#else
#ifdef USE_PMUTEX
#include <pthread.h>
typedef pthread_mutex_t mutex; /* use posix thread mutexes */
#else
typedef int mutex;
#endif
#endif
/* initializes a thread-wide mutex */ /* initializes a thread-wide mutex */
int mutex_init(mutex* id); int mutex_init(mutex* id);
/* acquire the given mutex to enter in a critical section */ /* acquire the given mutex to enter in a critical section */
int mutex_in (mutex* id); int mutex_in (mutex* id);
/* quit the critical section, by releasing the given mutex */ /* quit the critical section, by releasing the given mutex */
int mutex_out (mutex* id); int mutex_out (mutex* id);
 End of changes. 2 change blocks. 
4 lines changed or deleted 12 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/