home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ixemul-45.0-src.tgz / tar.out / contrib / ixemul / ixnet / group.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  2KB  |  109 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 "kprintf.h"
  28. #include <grp.h>
  29. #include <unistd.h>
  30. #include <stdarg.h>
  31.  
  32. int getgroups(int gidsetlen, int *gidset)
  33. {
  34.     int err = -1;
  35.     struct ixnet *p = (struct ixnet *)u.u_ixnet;
  36.  
  37.     switch (p->u_networkprotocol) {
  38.     case IX_NETWORK_AMITCP:
  39.         err = UG_getgroups(gidsetlen,gidset);
  40.  
  41.         if (err == -1) {
  42.         errno = ug_GetErr();
  43.         }
  44.     break;
  45.  
  46.     case IX_NETWORK_AS225:
  47.         err = SOCK_getgroups(gidsetlen,gidset);
  48.     break;
  49.     }
  50.     return err;
  51. }
  52.  
  53. gid_t
  54. getgid(void)
  55. {
  56.     register struct ixnet *p = (struct ixnet *)u.u_ixnet;
  57.     register int network_protocol = p->u_networkprotocol;
  58.     gid_t retval;
  59.  
  60.     switch(network_protocol) {
  61.     case IX_NETWORK_AMITCP:
  62.         retval = UG_getgid();
  63.     break;
  64.  
  65.     default: /* case IX_NETWORK_AS225: */
  66.         retval = SOCK_getgid();
  67.     break;
  68.     }
  69.     return retval;
  70. }
  71.  
  72. gid_t
  73. getegid(void)
  74. {
  75.     register struct ixnet *p = (struct ixnet *)u.u_ixnet;
  76.     register int network_protocol = p->u_networkprotocol;
  77.  
  78.     switch(network_protocol) {
  79.     case IX_NETWORK_AMITCP:
  80.         return UG_getegid();
  81.  
  82.     default: /* case IX_NETWORK_AS225: */
  83.         return SOCK_getgid();
  84.     }
  85. }
  86.  
  87. int setregid(int rgid, int egid)
  88. {
  89.   struct ixnet *p = (struct ixnet *)u.u_ixnet;
  90.  
  91.   if (p->u_networkprotocol == IX_NETWORK_AMITCP)
  92.     return UG_setregid(rgid, egid);
  93.   return 0;
  94. }
  95.  
  96. int setgid(gid_t gid)
  97. {
  98.   struct ixnet *p = (struct ixnet *)u.u_ixnet;
  99.  
  100.   if (p->u_networkprotocol == IX_NETWORK_AMITCP)
  101.     return UG_setgid(gid);
  102.   return 0;
  103. }
  104.  
  105. int setegid(gid_t gid)
  106. {
  107.   return setregid(getgid(),gid);
  108. }
  109.