X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fgip.c;h=b1a5195383b4e57922beee50aa532c214cc53b13;hb=930f1b9b6effd9f1944a74487e835c721550be2f;hp=488d539793d0b379fdc1ca24b0b48343403098f4;hpb=00b4ed0ab0dace63e5824bc16d1e0cc414289bcc;p=egate.git diff --git a/util/gip.c b/util/gip.c index 488d539..b1a5195 100644 --- a/util/gip.c +++ b/util/gip.c @@ -1,8 +1,71 @@ +/* + * 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 kernel * Europagate, 1995 * * $Log: gip.c,v $ - * Revision 1.3 1995/04/20 15:12:42 adam + * Revision 1.9 1997/12/15 15:04:18 adam + * Changed name of member errno to errorno since some systems + * defines error as a preprocessor variable. + * + * Revision 1.8 1995/05/22 09:03:41 adam + * New argument, block, to cs_open. + * + * Revision 1.7 1995/05/16 09:40:52 adam + * LICENSE. + * + * Revision 1.6 1995/05/02 15:26:52 adam + * EINTR obvserved on reads and writes. + * + * Revision 1.5 1995/05/01 16:27:28 adam + * Various improvements. Close-on-exec and close on failure on either + * read or write FIFO. + * + * Revision 1.4 1995/04/21 16:38:07 adam + * Added more debugging logs. + * + * Revision 1.3 1995/04/20 15:12:42 adam * Minor hacks really. * * Revision 1.2 1995/03/27 12:52:18 adam @@ -24,6 +87,8 @@ #include #include +#include + #include GIP gip_initialize (const char *name) @@ -39,8 +104,9 @@ GIP gip_initialize (const char *name) } strcpy (gip->name, name); gip->ret = mknod (gip->name, S_IFIFO|0666, 0); - gip->errno = errno; + gip->errorno = errno; gip->rfd = gip->wfd = -1; + gw_log (GW_LOG_DEBUG, "gip", "Creating %s", gip->name); return gip; } @@ -48,6 +114,7 @@ int gip_destroy (GIP gip) { assert (gip); + unlink (gip->name); free (gip->name); free (gip); return 0; @@ -58,9 +125,14 @@ int gip_infileno (GIP gip) return gip->rfd; } +int gip_outfileno (GIP gip) +{ + return gip->wfd; +} + int gip_errno (GIP gip) { - return gip->errno; + return gip->errorno; } int gip_read (GIP gip, char *buf, size_t count) @@ -68,12 +140,17 @@ int gip_read (GIP gip, char *buf, size_t count) int r, no = 0; while (no < count) { - r = read (gip->rfd, buf+no, count-no); - if (r == -1) - { - gip->errno = errno; - return -1; - } + while (1) + { + r = read (gip->rfd, buf+no, count-no); + if (r != -1) + break; + if (errno != EINTR) + { + gip->errorno = errno; + return -1; + } + } no += r; } return 0; @@ -84,11 +161,16 @@ int gip_write (GIP gip, const char *buf, size_t count) int r, no = 0; while (no < count) { - r = write (gip->wfd, buf+no, count-no); - if (r == -1) - { - gip->errno = errno; - return -1; + while (1) + { + r = write (gip->wfd, buf+no, count-no); + if (r != -1) + break; + if (errno != EINTR) + { + gip->errorno = errno; + return -1; + } } no += r; }