home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / compat / sys / resource / strlimit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  711 b   |  38 lines

  1. #include <errno.h>
  2. #include <stddef.h>
  3. #include <sys/resource.h>
  4.  
  5. extern struct rlimit __libc_limits[];
  6.  
  7. int
  8. setrlimit (int rltype, const struct rlimit *rlimitp)
  9. {
  10.   /* check argument range */
  11.   if (rlimitp->rlim_cur > rlimitp->rlim_max || rlimitp == NULL)
  12.     {
  13.       errno = EINVAL;
  14.       return -1;
  15.     }
  16.  
  17.   switch (rltype)
  18.     {
  19.     case RLIMIT_CPU:
  20.     case RLIMIT_FSIZE:
  21.     case RLIMIT_DATA:
  22.     case RLIMIT_STACK:
  23.     case RLIMIT_CORE:
  24.     case RLIMIT_RSS:
  25.     case RLIMIT_MEMLOCK:
  26.     case RLIMIT_NPROC:
  27.     case RLIMIT_NOFILE:
  28.       /* not supported */
  29.       errno = EPERM;
  30.       return -1;
  31.     default:
  32.       errno = EINVAL;
  33.       return -1;
  34.     }
  35.  
  36.   return 0;
  37. }
  38.