/[libspopc]/libspopc.h
ViewVC logotype

Diff of /libspopc.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5 by ben, Thu Oct 8 15:37:49 2009 UTC revision 6 by ben, Sun Apr 18 11:05:58 2010 UTC
# Line 32  extern "C" { Line 32  extern "C" {
32    
33  #ifdef WIN32  #ifdef WIN32
34  #include <winsock.h>  #include <winsock.h>
35    #if BUILDING_DLL
36    # define DLLIMPORT __declspec (dllexport)
37    #else /* Not BUILDING_DLL */
38    # define DLLIMPORT __declspec (dllimport)
39    #endif /* Not BUILDING_DLL */
40  #else  #else
41  #include <sys/socket.h>  #include <sys/socket.h>
42  #include <netinet/in.h>  #include <netinet/in.h>
43  #include <netdb.h>  #include <netdb.h>
44    #define DLLIMPORT
45  #endif  #endif
46    
47  /* thread-safe version of libspopc (>0.8) */  /* thread-safe version of libspopc (>0.8) */
48    
49  /* call this function before to use any routine from libspopc */  /* call this function before to use any routine from libspopc */
50  int libspopc_init(void);  DLLIMPORT int libspopc_init(void);
51    
52  /* call this function when you do not use anymore libspopc routines */  /* call this function when you do not use anymore libspopc routines */
53  int libspopc_clean(void);  DLLIMPORT int libspopc_clean(void);
54    
55  #ifdef USE_SSL  #ifdef USE_SSL
56    
# Line 78  typedef pop3sock* pop3sock_t; Line 84  typedef pop3sock* pop3sock_t;
84   * Hint: If you have a recent version of curl/libcurl installed, you can try   * Hint: If you have a recent version of curl/libcurl installed, you can try
85   * setting this to the output of:  "curl-config --ca"   * setting this to the output of:  "curl-config --ca"
86   ******************************************************************************/   ******************************************************************************/
87  void pop3_cert_setup(const char *certfile);  DLLIMPORT void pop3_cert_setup(const char *certfile);
88    
89  /******************************************************************************  /******************************************************************************
90   * 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.
# Line 90  void pop3_cert_setup(const char *certfil Line 96  void pop3_cert_setup(const char *certfil
96   * By default, not calling any of these, the behaviour of libspopc follows   * By default, not calling any of these, the behaviour of libspopc follows
97   * the same as pop3_ssl_auto() for backward compatibility reason.   * the same as pop3_ssl_auto() for backward compatibility reason.
98   ******************************************************************************/   ******************************************************************************/
99  void pop3_ssl_never(void);  DLLIMPORT void pop3_ssl_never(void);
100  void pop3_ssl_auto(void);  DLLIMPORT void pop3_ssl_auto(void);
101  void pop3_ssl_always(void);  DLLIMPORT void pop3_ssl_always(void);
102    
103  #else /* Non-SSL */  #else /* Non-SSL */
104    
# Line 127  typedef int pop3sock_t; Line 133  typedef int pop3sock_t;
133   * connecting *   * connecting *
134   **************/   **************/
135    
136  pop3sock_t pop3_prepare(const char* servername, const int port, struct sockaddr_in* connection, struct hostent* server);  DLLIMPORT pop3sock_t pop3_prepare(const char* servername, const int port, struct sockaddr_in* connection, struct hostent* server);
137  /* 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 */
138    
139  char* pop3_connect(pop3sock_t sock, struct sockaddr_in* connection);  DLLIMPORT char* pop3_connect(pop3sock_t sock, struct sockaddr_in* connection);
140  /* connects to the server through the sock and returns server's welcome */  /* connects to the server through the sock and returns server's welcome */
141    
142  void pop3_disconnect(pop3sock_t sock, struct hostent* server);  DLLIMPORT void pop3_disconnect(pop3sock_t sock, struct hostent* server);
143  /* close socket and free server info */  /* close socket and free server info */
144    
145    
# Line 141  void pop3_disconnect(pop3sock_t sock, st Line 147  void pop3_disconnect(pop3sock_t sock, st
147   * pop3 queries *   * pop3 queries *
148   ****************/   ****************/
149    
150  char* pop3_user(pop3sock_t sock, const char* name);  DLLIMPORT char* pop3_user(pop3sock_t sock, const char* name);
151  /* performs "USER" pop query and returns server's <=512 bytes resp */  /* performs "USER" pop query and returns server's <=512 bytes resp */
152    
153  char* pop3_pass(pop3sock_t sock, const char* pw);  DLLIMPORT char* pop3_pass(pop3sock_t sock, const char* pw);
154  /* performs "PASS" pop query and return server's <=512 bytes resp */  /* performs "PASS" pop query and return server's <=512 bytes resp */
155    
156  char* pop3_quit(pop3sock_t sock);  DLLIMPORT char* pop3_quit(pop3sock_t sock);
157  /* performs "QUIT" pop query and returns server's <=512 bytes resp */  /* performs "QUIT" pop query and returns server's <=512 bytes resp */
158    
159  char* pop3_stat(pop3sock_t sock);  DLLIMPORT char* pop3_stat(pop3sock_t sock);
160  /* performs "STAT" pop query and returns server's <=512 bytes resp */  /* performs "STAT" pop query and returns server's <=512 bytes resp */
161    
162    
163  char* pop3_list(pop3sock_t sock, int id);  DLLIMPORT char* pop3_list(pop3sock_t sock, int id);
164  /* performs a "LIST" pop query and returns server's (long) resp */  /* performs a "LIST" pop query and returns server's (long) resp */
165    
166  char* pop3_retr(pop3sock_t sock, int id);  DLLIMPORT char* pop3_retr(pop3sock_t sock, int id);
167  /* performs a "RETR" pop query and returns server's (long) resp */  /* performs a "RETR" pop query and returns server's (long) resp */
168    
169  char* pop3_dele(pop3sock_t sock, int id);  DLLIMPORT char* pop3_dele(pop3sock_t sock, int id);
170  /* performs a "DELE" pop query and returns server's <=512 bytes resp */  /* performs a "DELE" pop query and returns server's <=512 bytes resp */
171    
172  char* pop3_noop(pop3sock_t sock);  DLLIMPORT char* pop3_noop(pop3sock_t sock);
173  /* performs a "NOOP" pop query and returns server's <=512 bytes resp */  /* performs a "NOOP" pop query and returns server's <=512 bytes resp */
174    
175  char* pop3_rset(pop3sock_t sock);  DLLIMPORT char* pop3_rset(pop3sock_t sock);
176  /* performs a "RSET" pop query and returns server's <=512 bytes resp */  /* performs a "RSET" pop query and returns server's <=512 bytes resp */
177    
178  char* pop3_top(pop3sock_t sock, int id, int lines);  DLLIMPORT char* pop3_top(pop3sock_t sock, int id, int lines);
179  /* performs a "TOP" pop query and returns server's (long) resp */  /* performs a "TOP" pop query and returns server's (long) resp */
180    
181  char* pop3_uidl(pop3sock_t sock, int id);  DLLIMPORT char* pop3_uidl(pop3sock_t sock, int id);
182  /* performs a "UIDL" pop query and returns server's (long) resp */  /* performs a "UIDL" pop query and returns server's (long) resp */
183    
184  char* pop3_apop(pop3sock_t sock, const char* name, const char* digest);  DLLIMPORT char* pop3_apop(pop3sock_t sock, const char* name, const char* digest);
185  /* 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 */
186    
187    
# Line 188  int dotline(char* buf); Line 194  int dotline(char* buf);
194  /* 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
195   * buf must be terminated by '\0' */   * buf must be terminated by '\0' */
196    
197  int pop3_error(char* string);  DLLIMPORT int pop3_error(char* string);
198  /* returns 1 on pop server error (i.e : -ERR ...) or NULL reply */  /* returns 1 on pop server error (i.e : -ERR ...) or NULL reply */
199    
200  /************************************  /************************************
201   * reply re-formatting, after query *   * reply re-formatting, after query *
202   ************************************/   ************************************/
203  char* nextline(char* string);  DLLIMPORT char* nextline(char* string);
204  /* returns a pointer to the next line of given string */  /* returns a pointer to the next line of given string */
205    
206  char* retr2msg(char* data);  DLLIMPORT char* retr2msg(char* data);
207  /* returns formatted mail from a pop RETR X query  /* returns formatted mail from a pop RETR X query
208   * must only be called on data returned by pop3_retr() */   * must only be called on data returned by pop3_retr() */
209    
210  void freemsg(char* msg);  DLLIMPORT void freemsg(char* msg);
211  /* free the message received by reetr2msg */  /* free the message received by reetr2msg */
212    
213  int* list2array(char* poplist);  DLLIMPORT int* list2array(char* poplist);
214  /* WARNING: must not be called after a mail deletion  /* WARNING: must not be called after a mail deletion
215   * 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
216   * array[0] holds id of the array's last element   * array[0] holds id of the array's last element
217   * 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 */
218    
219  void freelistarray(int* array);  DLLIMPORT void freelistarray(int* array);
220  /* free the message sizes array created by list2array */  /* free the message sizes array created by list2array */
221    
222  int listi2size(char* resp);  DLLIMPORT int listi2size(char* resp);
223  /* grep the given size (in bytes) in resp after a pop3_list(sock,ID) request  /* grep the given size (in bytes) in resp after a pop3_list(sock,ID) request
224   * do not use after a pop3_list(sock,0) ! */   * do not use after a pop3_list(sock,0) ! */
225    
226  int stat2num(char* resp);  DLLIMPORT int stat2num(char* resp);
227  /* returns the number of downloadable messages on pop server */  /* returns the number of downloadable messages on pop server */
228    
229  int stat2bytes(char* resp);  DLLIMPORT int stat2bytes(char* resp);
230  /* returns the sumsize in bytes of all stored messages on server  /* returns the sumsize in bytes of all stored messages on server
231   * must only be called just after a pop3_stat() request */   * must only be called just after a pop3_stat() request */
232    
233  char** uidl2array(char* resp);  DLLIMPORT char** uidl2array(char* resp);
234  /* WARNING: mus not be called after a mail deletion  /* WARNING: mus not be called after a mail deletion
235   * returns an array of unique strings for each message id   * returns an array of unique strings for each message id
236   * array[0] gives array's last id   * array[0] gives array's last id
237   * must only be called just after a pop3_uidl(sock,0) request */   * must only be called just after a pop3_uidl(sock,0) request */
238    
239  void freeuidlarray(char** arrray);  DLLIMPORT void freeuidlarray(char** arrray);
240  /* free the uidl array created by uidl2array */  /* free the uidl array created by uidl2array */
241    
242  char* uidli2sig(char* resp);  DLLIMPORT char* uidli2sig(char* resp);
243  /* grep the pop signature of *one* message signature reply  /* grep the pop signature of *one* message signature reply
244   * 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
245   * do not use it after a pop3_uidl(sock,0) ! */   * do not use it after a pop3_uidl(sock,0) ! */
# Line 284  typedef struct{ Line 290  typedef struct{
290  #define popmsguid(s,i) ((s)->uidl[(i)])  #define popmsguid(s,i) ((s)->uidl[(i)])
291  /* points to the 'char*' uid (unique signature) of 'int'(i) message id */  /* points to the 'char*' uid (unique signature) of 'int'(i) message id */
292    
293  int poplast(popsession* session);  DLLIMPORT int poplast(popsession* session);
294  /* gives the id of the last message of the current session */  /* gives the id of the last message of the current session */
295    
296  int popnum(popsession* session);  DLLIMPORT int popnum(popsession* session);
297  /* gives the current number of stored message. it is != to poplast() */  /* gives the current number of stored message. it is != to poplast() */
298    
299  char* popbegin(const char* servername,const char* user, const char* pass, popsession** sp);  DLLIMPORT char* popbegin(const char* servername,const char* user, const char* pass, popsession** sp);
300  /* prepares, connect and get lists of messages stored on pop server  /* prepares, connect and get lists of messages stored on pop server
301   * you must give a valid servername, user and pass   * you must give a valid servername, user and pass
302   * returns an error message if a problem occurs, else NULL */   * returns an error message if a problem occurs, else NULL */
303    
304  char* popgethead(popsession* session, int id);  DLLIMPORT char* popgethead(popsession* session, int id);
305  /* 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 */
306    
307  char* popgetmsg(popsession* session, int id);  DLLIMPORT char* popgetmsg(popsession* session, int id);
308  /* 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 */
309    
310  int popdelmsg(popsession* session, int id);  DLLIMPORT int popdelmsg(popsession* session, int id);
311  /* deletes message 'id' on pop server  /* deletes message 'id' on pop server
312   * returns -1 on server error, 0 else */   * returns -1 on server error, 0 else */
313    
314  int popchkmsg(popsession* session, int id);  DLLIMPORT int popchkmsg(popsession* session, int id);
315  /* tells if a message is still accessible on the server (not deleted)  /* tells if a message is still accessible on the server (not deleted)
316   * 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 */
317    
318  int popcancel(popsession* session);  DLLIMPORT int popcancel(popsession* session);
319  /* cancels all previous deletion on pop server  /* cancels all previous deletion on pop server
320   * returns -1 on server error, 0 else */   * returns -1 on server error, 0 else */
321    
322  int popsync(popsession* session);  DLLIMPORT int popsync(popsession* session);
323  /* re-synchronize the session object from the server  /* re-synchronize the session object from the server
324   * need to be called if session->sync is 0   * need to be called if session->sync is 0
325   * returns -1 on error, 0 else */   * returns -1 on error, 0 else */
326    
327  void popend(popsession* session);  DLLIMPORT void popend(popsession* session);
328  /* quit and destroys pop session */  /* quit and destroys pop session */
329    
330  #ifdef __cplusplus  #ifdef __cplusplus

Legend:
Removed from v.5  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.26