home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / sysconf.c < prev    next >
C/C++ Source or Header  |  1991-10-19  |  2KB  |  76 lines

  1. /*
  2.  * sysconf() and pathconf() for TOS/MiNT (kinda POSIXy)
  3.  * Written by Dave Gymer and placed in the Public Domain
  4.  *
  5.  * NOTE: this file will have to be updated as and when MiNT gains
  6.  * new Sysconf() and Dpathconf() variables, as will unistd.h, so that
  7.  * TOS programs get the correct values back. (But who uses TOS? :-)
  8.  */
  9.  
  10. #include <unistd.h>
  11. #include <mintbind.h>
  12. #include <errno.h>
  13. #ifndef _COMPILER_H
  14. #include <compiler.h>        /* ++ ers */
  15. #endif
  16.  
  17. extern int __mint;
  18.  
  19. #define UNLIMITED    (0x7fffffffL)
  20.  
  21. long
  22. sysconf(var)
  23.     int var;
  24. {
  25.     if(__mint)
  26.         return Sysconf(var);
  27.  
  28.     switch(var) {
  29.     case _SC_LAST:
  30.         return 4;
  31.     case _SC_MEMR_MAX:
  32.         return UNLIMITED; /* not true for TOS < 1.4 :-( */
  33.     case _SC_ARG_MAX:
  34.         return 127; /* ignore this, cuz we can pass via the env */
  35.     case _SC_OPEN_MAX:
  36.         return 45; /* think I read this somewhere */
  37.     case _SC_NGROUPS_MAX:
  38.         return 0; /* this is bad news :-( */
  39.     case _SC_CHILD_MAX:
  40.         return UNLIMITED; /* good 'ol TOS :-) */
  41.     default:
  42.         return EINVAL;
  43.     }
  44. }
  45.  
  46. long
  47. pathconf(path, var)
  48.     const char *path;
  49.     int var;
  50. {
  51.     long r;
  52.  
  53.     if(__mint) {
  54.         r = Dpathconf(path, var);
  55.         if (var == _PC_NO_TRUNC)
  56.             return r ? -1 : 0;
  57.         return r;
  58.     }
  59.     switch(var) {
  60.     case _PC_LAST:
  61.         return 3;
  62.     case _PC_IOPEN_MAX:
  63.         return 45; /* -ish, maybe... */
  64.     case _PC_LINK_MAX:
  65.         return 1;
  66.     case _PC_PATH_MAX:
  67.         return 128; /* I'm sure I read that this is 64 in TOS 1.0 */
  68.     case _PC_NAME_MAX:
  69.         return 12;
  70.     case _PC_NO_TRUNC:
  71.         return -1;  /* file names are automatically truncated */
  72.     default: /* note that _PC_PIPE_BUF is invalid */
  73.         return EINVAL;
  74.     }
  75. }
  76.