X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=kernel%2Feti.c;h=de0634b6d013320257306a084e8b7bb8c6a85175;hb=25db261b6bbbfcc7bc26f679f195b51d31b9d7d7;hp=183f0e3d34fb98dcc9804920edbe61063d198ea4;hpb=c3d25c24fb405af98c6879fa7f5f619ccc895151;p=egate.git diff --git a/kernel/eti.c b/kernel/eti.c index 183f0e3..de0634b 100644 --- a/kernel/eti.c +++ b/kernel/eti.c @@ -1,8 +1,102 @@ -/* Gateway kernel +/* + * Copyright (c) 1995, the EUROPAGATE consortium (see below). + * + * The EUROPAGATE consortium members are: + * + * University College Dublin + * Danmarks Teknologiske Videnscenter + * An Chomhairle Leabharlanna + * Consejo Superior de Investigaciones Cientificas + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation, in whole or in part, for any purpose, is hereby granted, + * provided that: + * + * 1. This copyright and permission notice appear in all copies of the + * software and its documentation. Notices of copyright or attribution + * which appear at the beginning of any file must remain unchanged. + * + * 2. The names of EUROPAGATE or the project partners may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * 3. Users of this software (implementors and gateway operators) agree to + * inform the EUROPAGATE consortium of their use of the software. This + * information will be used to evaluate the EUROPAGATE project and the + * software, and to plan further developments. The consortium may use + * the information in later publications. + * + * 4. Users of this software agree to make their best efforts, when + * documenting their use of the software, to acknowledge the EUROPAGATE + * consortium, and the role played by the software in their work. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE + * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF + * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA + * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND + * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* Gateway Email Transport Interface * Europagate, 1995 * * $Log: eti.c,v $ - * Revision 1.2 1995/03/27 12:51:05 adam + * Revision 1.18 1996/03/01 14:25:28 adam + * Email gateway obeys 'Reply-To:' in header. + * + * Revision 1.17 1995/12/20 16:27:24 adam + * Extra parameter block to gw_db_open. + * + * Revision 1.16 1995/07/11 11:49:11 adam + * LINE_MAX renamed to STR_LINE_MAX. + * + * Revision 1.15 1995/07/03 12:59:28 adam + * New option for eti: -c dir to chdir before start. + * Setting change: gw.max.show defaults to 100. + * + * Revision 1.14 1995/05/19 13:25:59 adam + * Bug fixes. Better command line options. + * + * Revision 1.13 1995/05/16 09:40:41 adam + * LICENSE. Setting of CCL token names (and/or/not/set) in read_kernel_res. + * + * Revision 1.12 1995/05/03 07:37:35 adam + * CCL commands stop/continue implemented. New functions gw_res_{int,bool} + * are used when possible. + * + * Revision 1.11 1995/05/01 16:26:56 adam + * More work on resource monitor. + * + * Revision 1.10 1995/05/01 12:43:29 adam + * First work on resource monitor program. + * + * Revision 1.9 1995/04/21 16:37:43 adam + * Parent (eti) creates BOTH FIFOs. dtbsun is more happy now. + * + * Revision 1.8 1995/04/20 15:12:24 adam + * Minor hacks really. + * + * Revision 1.7 1995/04/19 16:01:57 adam + * Some hacks to get the FIFO communication work!! Isn't reliable. + * Resource gw.account added - default account info. + * + * Revision 1.6 1995/04/17 09:34:27 adam + * Timeout (idletime) adjustable. Minor changes in kernel. + * + * Revision 1.5 1995/03/31 09:43:13 adam + * Removed unused variable. + * + * Revision 1.4 1995/03/28 11:42:34 adam + * First use of string-queue utility. + * + * Revision 1.3 1995/03/28 08:01:23 adam + * FIFO existence is used to test for a running kernel. + * + * Revision 1.2 1995/03/27 12:51:05 adam * New log level in use: GW_LOG_ERRNO. * * Revision 1.1 1995/03/27 08:24:00 adam @@ -18,71 +112,195 @@ #include #include #include +#include +#include + +#include +#include #include #include +#include #include +#include -#define LINE_MAX 1024 -static char line_buf[LINE_MAX+1]; +#define STR_LINE_MAX 1024 static char *module = "eti"; +static jmp_buf retry_jmp; -static int email_header (FILE *inf, char *from_str, char *subject_str) +static void pipe_handle (int dummy) { + longjmp (retry_jmp, 1); +} + +static int email_header (struct str_queue *sq, + char *from_str, char *subject_str) +{ + char *msg; + int index = 0; + *from_str = '\0'; - *subject_str = '\0'; - while (fgets (line_buf, LINE_MAX, inf)) + *subject_str = '\0'; + while ((msg = str_queue_get (sq, index++))) { - if (line_buf[0] == '\n') + if (msg[0] == '\n') return 0; - if (strncmp (line_buf, "From ", 5) == 0) - sscanf (line_buf+4, "%s", from_str); - if (strncmp (line_buf, "Subject: ", 9) == 0 && - sscanf (line_buf+9, "%s", subject_str+1) == 1) - strcpy (subject_str, line_buf+9); + if (memcmp (msg, "From ", 5) == 0) + sscanf (msg+4, "%s", from_str); + if (memcmp (msg, "Reply-To: ", 10) == 0) + sscanf (msg+10, "%s", from_str); + if (memcmp (msg, "Subject: ", 9) == 0 && + sscanf (msg+9, "%s", subject_str+1) == 1) + strcpy (subject_str, msg+9); } return 1; } -static int kernel_active (int id) +static void start_kernel (int argc, char **argv, int id) { - char active_name[1024]; - int fd; - - sprintf (active_name, "kernel.pid.%d", id); - fd = open (active_name, O_RDONLY); - if (fd == -1) - return 0; - close (fd); - return 1; + pid_t pid; + int i; + char **argv_p; + char userid_option[20]; + + argv_p = malloc (sizeof(*argv_p)*(argc+2)); + if (!argv_p) + { + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, module, "malloc fail"); + exit (1); + } + argv_p[0] = "kernel"; + for (i = 1; i