home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ixemul-45.0-src.tgz / tar.out / contrib / ixemul / library / posixconf.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  145 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  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.  *  posixconf.c,v 1.1.1.1 1994/04/04 04:30:59 amiga Exp
  20.  *
  21.  *  posixconf.c,v
  22.  * Revision 1.1.1.1  1994/04/04  04:30:59  amiga
  23.  * Initial CVS check in.
  24.  *
  25.  *  Revision 1.2  1992/07/04  22:08:39  mwild
  26.  *  machlimits is now limits...
  27.  *
  28.  *  Revision 1.1  1992/05/22  01:50:03  mwild
  29.  *  Initial revision
  30.  *
  31.  */
  32.  
  33. #define _KERNEL
  34. #include "ixemul.h"
  35. #include "kprintf.h"
  36. #include <unistd.h>
  37. #include <time.h>
  38. #include <sys/syslimits.h>
  39. #include <machine/limits.h>
  40.  
  41. long
  42. sysconf (int name)
  43. {
  44.   switch (name)
  45.     {
  46.     case _SC_ARG_MAX:
  47.       return ARG_MAX;
  48.       
  49.     case _SC_CHILD_MAX:
  50.       return CHILD_MAX;
  51.       
  52.     case _SC_CLK_TCK:
  53.       return CLK_TCK;
  54.       
  55.     case _SC_NGROUPS_MAX:
  56.       return NGROUPS_MAX;
  57.       
  58.     case _SC_OPEN_MAX:
  59.       return OPEN_MAX;
  60.  
  61.     case _SC_JOB_CONTROL:
  62.       return _POSIX_JOB_CONTROL;
  63.     
  64.     case _SC_SAVED_IDS:
  65.       return _POSIX_SAVED_IDS;
  66.  
  67.     case _SC_VERSION:
  68.       return _POSIX_VERSION;
  69.       
  70.     default:
  71.       errno = EINVAL;
  72.       KPRINTF (("&errno = %lx, errno = %ld\n", &errno, errno));
  73.       return -1;
  74.     }
  75. }
  76.  
  77.  
  78. long
  79. fpathconf (int fd, int name)
  80. {
  81.   struct file *f = u.u_ofile[fd];
  82.  
  83.   if ((unsigned)fd >= NOFILE || !f)
  84.     {
  85.       errno = EBADF;
  86.       KPRINTF (("&errno = %lx, errno = %ld\n", &errno, errno));
  87.       return -1;
  88.     }
  89.  
  90.   switch (name)
  91.     {
  92.     case _PC_LINK_MAX:
  93.       return LINK_MAX;
  94.       
  95.     case _PC_MAX_CANON:
  96.       return MAX_CANON;
  97.       
  98.     case _PC_MAX_INPUT:
  99.       return MAX_INPUT;
  100.       
  101.     case _PC_NAME_MAX:
  102.       return NAME_MAX;    /* or 32 on AmigaOS? What about NFS ? */
  103.       
  104.     case _PC_PATH_MAX:
  105.       return PATH_MAX;
  106.       
  107.     case _PC_PIPE_BUF:
  108.       return PIPE_BUF;
  109.       
  110.     case _PC_CHOWN_RESTRICTED:
  111.       return _POSIX_CHOWN_RESTRICTED;
  112.       
  113.     case _PC_NO_TRUNC:
  114.       return _POSIX_NO_TRUNC;
  115.     
  116.     case _PC_VDISABLE:
  117.       return _POSIX_VDISABLE;
  118.  
  119.     default:
  120.       errno = EINVAL;
  121.       KPRINTF (("&errno = %lx, errno = %ld\n", &errno, errno));
  122.       return -1;
  123.     }
  124. }
  125.  
  126.  
  127. long
  128. pathconf (const char *file, int name)
  129. {
  130.   int fd = syscall(SYS_open, file, 0);
  131.   
  132.   if (fd >= 0)
  133.     {
  134.       int err, res;
  135.       res = fpathconf (fd, name);
  136.       err = errno;
  137.       close (fd);
  138.       errno = err;
  139.       KPRINTF (("&errno = %lx, errno = %ld\n", &errno, errno));
  140.       return res;
  141.     }
  142.  
  143.   return -1;
  144. }
  145.