/* $Id$ * $URL$ * * Plugin to check POP3 mail accounts * * Copyright (C) 2004 Javi Garcia Dominguez (aka Stolz) * Based on code from pop3check (C) 1999 http://sourceforge.net/projects/pop3check * Simon Liddington is the pop3check current maintainer. * The pop3check original author is Steven Radack . * * Copyright (C) 2004 The LCD4Linux Team * * This file is a pluging for LCD4Linux. * * LCD4Linux is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * LCD4Linux is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "config.h" #include #include #include #include "debug.h" #include "plugin.h" #include "cfg.h" /*added */ #include #include /*#include */ #include #include /*#include */ #include #ifdef WITH_DMALLOC #include #endif /*POP 3 */ #define POPERR "-ERR" #define LOCKEDERR "-ERR account is locked by another session or for maintenance, try again." #define BUFSIZE 8192 #define POP3PORT 110 #define MAX_NUM_ACCOUNTS 3 struct check { int id; char *username; char *password; char *server; int port; int messages; struct check *next; }; /************************ PROTOTYPES ********************************/ /* list */ static struct check *check_node_alloc(void); static void check_node_add(struct check **head, struct check *new_check); static void check_destroy(struct check **head); /* pop3 */ static void pop3_check_messages(struct check *hi, int verbose); static void pop3_recv_crlf_terminated(int sockfd, char *buf, int size); /* socket */ static int tcp_connect(struct check *hi); /************************ GLOBAL ***********************************/ static char Section[] = "Plugin:POP3"; static struct check *head = NULL; /********************************************************************/ /************************ LIST ***********************************/ static struct check *check_node_alloc(void) { struct check *new_check; new_check = (struct check *) calloc(1, sizeof(struct check)); if (new_check == NULL) { error("[POP3] out of memory\n"); } return new_check; } static void check_node_add(struct check **head, struct check *new_check) { new_check->next = *head; *head = new_check; } static void check_destroy(struct check **head) { struct check *iter; while (*head) { iter = (*head)->next; free((*head)->username); free((*head)->password); free((*head)->server); free(*head); *head = iter; } *head = NULL; } /************************ POP3 ********************************/ static void pop3_check_messages(struct check *hi, int verbose) { char buf[BUFSIZE]; int sockfd; if ((sockfd = tcp_connect(hi)) < 0) { hi->messages = -1; return; } pop3_recv_crlf_terminated(sockfd, buf, sizeof(buf)); /* server greeting */ if (verbose) info("[POP3] %s -> %s\n", hi->server, buf); snprintf(buf, sizeof(buf), "USER %s\r\n", hi->username); write(sockfd, buf, strlen(buf)); buf[strlen(buf) - 1] = '\0'; if (verbose) info("[POP3] %s <- %s\n", hi->server, buf); pop3_recv_crlf_terminated(sockfd, buf, sizeof(buf)); /* response from USER command */ if (verbose) info("[POP3] %s -> %s\n", hi->server, buf); snprintf(buf, sizeof(buf), "PASS %s\r\n", hi->password); write(sockfd, buf, strlen(buf)); if (verbose) info("[POP3] %s <- PASS ???\n", hi->server); pop3_recv_crlf_terminated(sockfd, buf, sizeof(buf)); /* response from PASS command */ if (verbose) info("[POP3] %s -> %s\n", hi->server, buf); if (strncmp(buf, LOCKEDERR, strlen(LOCKEDERR)) == 0) { hi->messages = -2; close(sockfd); return; } if (strncmp(buf, POPERR, strlen(POPERR)) ==
#
# $Id: README.Drivers,v 1.4 2001/03/09 13:08:11 ltoetsch Exp $
#

How to write new display drivers for lcd4linux

If you plan to write a new display driver for lcd4linux, you should follow
this guidelines:

* use Skeleton.c as a start point.
  You might also have a look at Text.c

* create a new sourcefile <drivername>.c and add it to the bottom of
  Makefile.am

* add an entry to configure.in

* there's no need for a <drivername>.h

* create one (or more) unique display names (your driver will be selected by
  this name in the 'Display'-line of lcd4linux.conf).

* include "display.h" in your driver, to get the LCD structure and various 
  BAR_ definitions

* include "cfg.h" if you need to access settings in the config file.

* create a LCD table at the bottom of your driver, and fill it with the
  appropriate values. Take care that you specify the correct bar capabilities
  of your display or driver:

  BAR_L:  horizontal bars headed left
  BAR_R:  horizontal bars headed right
  BAR_H2: driver supports horizontal dual-bars
  BAR_U:  vertical bars bottom-up
  BAR_D:  vertical bars top-down
  BAR_V2: driver supports vertical dual-bars

* edit display.c and create a reference to your LCD table:

     external LCD YourDriver[];

* extend the FAMILY table in display.c with your driver:

     FAMILY Driver[] = {
       { "Skeleton",      Skeleton },
       { "MatrixOrbital", MatrixOrbital },
       { "YourFamily",    YourDriver },
       { "" }
     };

* write the correspondig init(), clear(), put(), bar(), quit() and
  flush()-functions. There's no need to use a framebuffer and display its
  contents with the flush()- call (as in MatrixOrbital.c), you can directly
  write to the display in the put()- and bar()-functions, and use an empty
  flush()-function. But if you have a limited number of user-defined
  characters, and therefore you have to do some sort of 'character reduction'
  or similar stuff, you will have to use a framebuffer and the flush()-call.