home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / ixnet / siglaunch.c < prev    next >
C/C++ Source or Header  |  1996-12-11  |  2KB  |  81 lines

  1. /*
  2.  *  This file is part of ixnet.library for the Amiga.
  3.  *  Copyright (C) 1996 Jeff Shepherd
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  $Id:$
  20.  *
  21.  *  $Log:$
  22.  *
  23.  */
  24.  
  25. #define _KERNEL
  26. #include "ixnet.h"
  27. #include "ixprotos.h"
  28. #include <sys/wait.h>
  29. #include <sys/stat.h>
  30. #include <sys/socket.h>
  31. #include <string.h>
  32. #include <unistd.h>
  33. #include <exec/execbase.h>
  34.  
  35. extern struct ExecBase *SysBase;
  36.  
  37. /* called from ixemul.library's siglaunch() */
  38. void _siglaunch(sigset_t newsigs)
  39. {
  40.     struct Task *me = SysBase->ThisTask;
  41.     struct ixnet *p = u.u_ixnet;
  42.  
  43.     int urgmask = 1 << p->u_sigurg;
  44.     int iomask    = 1 << p->u_sigio;
  45.  
  46.     if (newsigs & urgmask) {
  47.     if (! (u.p_sigignore & sigmask (SIGURG)))
  48.         _psignal (me, SIGURG);
  49.  
  50.     me->tc_SigRecvd &= ~urgmask;
  51.     u.u_lastrcvsig &= ~urgmask;
  52.     }
  53.  
  54.     if (newsigs & iomask) {
  55.     if (! (u.p_sigignore & sigmask (SIGIO)))
  56.         _psignal (me, SIGIO);
  57.  
  58.     me->tc_SigRecvd &= ~iomask;
  59.     u.u_lastrcvsig &= ~iomask;
  60.     }
  61. }
  62.  
  63. /* I found this code from the AmiTCP sdk. It *should* work with AS225 */
  64. int
  65. _fstat(struct file *fp, struct stat *sb)
  66. {
  67.     long value;
  68.     int size = sizeof(value);
  69.  
  70.     bzero(sb, sizeof(*sb));
  71.  
  72.     /* st->st_dev = ??? */
  73.     sb->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
  74.     sb->st_uid = geteuid();
  75.     sb->st_gid = getegid();
  76.  
  77.     if (_getsockopt(fp, SOL_SOCKET, SO_SNDBUF,(void *)&value,&size) == 0)
  78.     sb->st_blksize = value;
  79.     return 0;
  80. }
  81.