/* Copyright (C) 2005 Christoffer Soop * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * 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, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #define BUF_SIZE 1024 #define MAX_PARAMS 4 #define TRUE_RESULT 0x01 #define FALSE_RESULT 0x00 int main() { char buf[BUF_SIZE + 1]; // Allow for string termination char c; char* param[MAX_PARAMS]; param[0] = &buf[0]; // this won't change... short len; int i,j; int result; openlog( "ejabberd", LOG_NDELAY, LOG_AUTH ); syslog( LOG_INFO, "Starting ejabberd check_vpopmail" ); while( 1 ) { // read first two bytes from stdin // convert bytes to integer len i=0; while( i<2 ) { c = getchar(); if( c == EOF ) return 0; buf[i++] = c; } len = buf[0]*256 + buf[1]; if( len == 0 ) { syslog( LOG_WARNING, "Packet length is zero" ); // try again continue; } else if( len < 0 ) { syslog( LOG_ERR, "Negative packet length; exiting" ); return 1; } else if( len > BUF_SIZE ) { syslog( LOG_ERR, "Packet length of %d larger than buffer of size %d", len, BUF_SIZE ); return 1; } //syslog( LOG_DEBUG, "packet length %d", len ); // read packet of len bytes from stdin to buffer // note: packet is on the form [auth|setpass|isuser]::: // example: 36auth:christoffer:jabberwocky.se:test i=0; j=0; while( i