home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / library / rcs / posixconf.c,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  3.1 KB  |  180 lines

  1. head    1.2;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ *  @;
  7.  
  8.  
  9. 1.2
  10. date    92.07.04.22.08.39;    author mwild;    state Exp;
  11. branches;
  12. next    1.1;
  13.  
  14. 1.1
  15. date    92.05.22.01.50.03;    author mwild;    state Exp;
  16. branches;
  17. next    ;
  18.  
  19.  
  20. desc
  21. @sysconf,[f]pathconf for POSIX compliance
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @machlimits is now limits...
  28. @
  29. text
  30. @/*
  31.  *  This file is part of ixemul.library for the Amiga.
  32.  *  Copyright (C) 1991, 1992  Markus M. Wild
  33.  *
  34.  *  This library is free software; you can redistribute it and/or
  35.  *  modify it under the terms of the GNU Library General Public
  36.  *  License as published by the Free Software Foundation; either
  37.  *  version 2 of the License, or (at your option) any later version.
  38.  *
  39.  *  This library is distributed in the hope that it will be useful,
  40.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  41.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  42.  *  Library General Public License for more details.
  43.  *
  44.  *  You should have received a copy of the GNU Library General Public
  45.  *  License along with this library; if not, write to the Free
  46.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  47.  *
  48.  *  $Id: posixconf.c,v 1.1 1992/05/22 01:50:03 mwild Exp $
  49.  *
  50.  *  $Log: posixconf.c,v $
  51.  *  Revision 1.1  1992/05/22  01:50:03  mwild
  52.  *  Initial revision
  53.  *
  54.  */
  55.  
  56. #define KERNEL
  57. #include "ixemul.h"
  58. #include <unistd.h>
  59. #include <sys/syslimits.h>
  60. #include <machine/limits.h>
  61.  
  62. long
  63. sysconf (int name)
  64. {
  65.   switch (name)
  66.     {
  67.     case _SC_ARG_MAX:
  68.       return ARG_MAX;
  69.       
  70.     case _SC_CHILD_MAX:
  71.       return CHILD_MAX;
  72.       
  73.     case _SC_CLK_TCK:
  74.       return CLK_TCK;
  75.       
  76.     case _SC_NGROUPS_MAX:
  77.       return NGROUPS_MAX;
  78.       
  79.     case _SC_OPEN_MAX:
  80.       return OPEN_MAX;
  81.  
  82.     case _SC_JOB_CONTROL:
  83.       return _POSIX_JOB_CONTROL;
  84.     
  85.     case _SC_SAVED_IDS:
  86.       return _POSIX_SAVED_IDS;
  87.  
  88.     case _SC_VERSION:
  89.       return _POSIX_VERSION;
  90.       
  91.     default:
  92.       errno = EINVAL;
  93.       return -1;
  94.     }
  95. }
  96.  
  97.  
  98. long
  99. fpathconf (int fd, int name)
  100. {
  101.   struct file *f = u.u_ofile[fd];
  102.  
  103.   if ((unsigned)fd >= NOFILE || !f)
  104.     {
  105.       errno = EBADF;
  106.       return -1;
  107.     }
  108.  
  109.   switch (name)
  110.     {
  111.     case _PC_LINK_MAX:
  112.       return LINK_MAX;
  113.       
  114.     case _PC_MAX_CANON:
  115.       return MAX_CANON;
  116.       
  117.     case _PC_MAX_INPUT:
  118.       return MAX_INPUT;
  119.       
  120.     case _PC_NAME_MAX:
  121.       return NAME_MAX;    /* or 32 on AmigaDOS? What about NFS ? */
  122.       
  123.     case _PC_PATH_MAX:
  124.       return PATH_MAX;
  125.       
  126.     case _PC_PIPE_BUF:
  127.       return PIPE_BUF;
  128.       
  129.     case _PC_CHOWN_RESTRICTED:
  130.       return _POSIX_CHOWN_RESTRICTED;
  131.       
  132.     case _PC_NO_TRUNC:
  133.       return _POSIX_NO_TRUNC;
  134.     
  135.     case _PC_VDISABLE:
  136.       return _POSIX_VDISABLE;
  137.  
  138.     default:
  139.       errno = EINVAL;
  140.       return -1;
  141.     }
  142. }
  143.  
  144.  
  145. long
  146. pathconf (const char *file, int name)
  147. {
  148.   int fd = open (file, 0);
  149.   
  150.   if (fd >= 0)
  151.     {
  152.       int err, res;
  153.       res = fpathconf (fd, name);
  154.       err = errno;
  155.       close (fd);
  156.       errno = err;
  157.       return res;
  158.     }
  159.  
  160.   return -1;
  161. }
  162. @
  163.  
  164.  
  165. 1.1
  166. log
  167. @Initial revision
  168. @
  169. text
  170. @d19 1
  171. a19 1
  172.  *  $Id$
  173. d21 4
  174. a24 1
  175.  *  $Log$
  176. d31 1
  177. a31 1
  178. #include <machine/machlimits.h>
  179. @
  180.