home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / sysconf.c < prev    next >
C/C++ Source or Header  |  1993-02-28  |  2KB  |  80 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. #include <limits.h>
  14. #ifndef _COMPILER_H
  15. #include <compiler.h>        /* ++ ers */
  16. #endif
  17. #include "lib.h"
  18.  
  19. extern int __mint;
  20.  
  21. #define UNLIMITED    (0x7fffffffL)
  22.  
  23. long
  24. sysconf(var)
  25.     int var;
  26. {
  27.     if(__mint)
  28.         return Sysconf(var);
  29.  
  30.     switch(var) {
  31.     case _SC_LAST:
  32.         return 4;
  33.     case _SC_MEMR_MAX:
  34.         return UNLIMITED; /* not true for TOS < 1.4 :-( */
  35.     case _SC_ARG_MAX:
  36.         return 127; /* ignore this, cuz we can pass via the env */
  37.     case _SC_OPEN_MAX:
  38.         return 45; /* think I read this somewhere */
  39.     case _SC_NGROUPS_MAX:
  40.         return 0; /* this is bad news :-( */
  41.     case _SC_CHILD_MAX:
  42.         return UNLIMITED; /* good 'ol TOS :-) */
  43.     default:
  44.         return EINVAL;
  45.     }
  46. }
  47.  
  48. long
  49. pathconf(_path, var)
  50.     const char *_path;
  51.     int var;
  52. {
  53.     long r;
  54.     char path[PATH_MAX];
  55.  
  56.     if(__mint) {
  57.         _unx2dos (_path, path);
  58.         r = Dpathconf(path, var);
  59.         if (var == _PC_NO_TRUNC)
  60.             return r ? -1 : 0;
  61.         return r;
  62.     }
  63.     switch(var) {
  64.     case _PC_LAST:
  65.         return 3;
  66.     case _PC_IOPEN_MAX:
  67.         return 45; /* -ish, maybe... */
  68.     case _PC_LINK_MAX:
  69.         return 1;
  70.     case _PC_PATH_MAX:
  71.         return 128; /* I'm sure I read that this is 64 in TOS 1.0 */
  72.     case _PC_NAME_MAX:
  73.         return 12;
  74.     case _PC_NO_TRUNC:
  75.         return -1;  /* file names are automatically truncated */
  76.     default: /* note that _PC_PIPE_BUF is invalid */
  77.         return EINVAL;
  78.     }
  79. }
  80.