[go: up one dir, main page]

Menu

Diff of /libpop3.h [000000] .. [r1]  Maximize  Restore

Switch to side-by-side view

--- a
+++ b/libpop3.h
@@ -0,0 +1,66 @@
+/*
+  libpop3 is a simple POP3 library that allows to connect to a pop3
+  mailbox, and retrieve/remove messages. This library is using the
+  RFC1939 as reference, and uses most basic POP3 commands to provide
+  maximum compatibility across servers.
+
+   Copyright (C) 2012,2013,2014 Mateusz Viste
+   All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+
+  1. Redistributions of source code must retain the above copyright notice, this
+     list of conditions and the following disclaimer. 
+  2. Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef libpop3_mv_sentinel
+#define libpop3_mv_sentinel
+
+struct maillist {
+  int mailid;
+  int length;
+  struct maillist *nextmail;
+};
+
+
+/* Deallocates all memory used by the 'mlist' maillist. This will call free() on every node of the linked list. If 'mlist' is NULL, nothing will be done. */
+void libpop3_destroymlist(struct maillist *mlist);
+
+
+/* Connects to the 'server' POP3 server on port 'port', trying to authenticate using login 'login' and password 'pass'. The 'server' parameter can be a FQDN, or an IPv4/IPv6 IP address. The list of mails will be generated automatically, and the first mail of the linked list will be pointed by *mlist. *mlist will be set to NULL if no mail awaits on the server. Don't forget to call libpop3_destroymlist() on the new maillist when you are done!
+Returns a socket to the POP3 connection on success, and a negative number on failure. Failure codes can then be transformed into humanly readable error messages via the libpop3_strerr() function. */
+int libpop3_connect(char *server, int port, char *login, char *pass, struct maillist **mlist);
+
+
+/* Gets the content of the mail with id 'mailid' from server pointed by 'popconn'. The content of the mail is written into the memory space pointed by 'mailmsg', up to 'maxlen' bytes. the mail will be terminated with a NULL byte as a string terminator, therefore make sure to allocate at least 1 byte more than the actual expected length of the message.
+Returns the length of the fetched message on success, a negative value otherwise. The returned error code can be translated into an error message via libpop3_strerr(). */
+int libpop3_getmail(int popconn, int mailid, char *mailmsg, int maxlen);
+
+
+/* Removes the mail with id 'mailid' from the pop3 connection pointed by 'popconn'. Returns 0 on success, non-zero otherwise. The returned error code can be translated into an error message via libpop3_strerr(). */
+int libpop3_delmail(int popconn, int mailid);
+
+
+/* Closes the communication with the pop3 server pointed by 'popconn'. Returns 0 on success, non-zero otherwise. The returned error code can be translated into an error message via libpop3_strerr(). */
+int libpop3_disconnect(int popconn);
+
+
+/* Translates a libpop3 error code into a humanly readable error message. Takes the libpop3 error code as parameter, and returns a pointer to the error message string. */
+char *libpop3_strerr(int errcode);
+
+#endif