In my infinite wisdom I attached the wrong bloody file.  The one
attached here is the most recent attempt.

Sorry for the confusion
-- 
AKK~
http://trmk.org/~adam/blog
//
// PosixProcess.cs
// Process Environment functions:
//      getpid, getppid, getuid, geteuid, getgid, getegid
//      setuid, setgid, setpgid, setsid
//      getgroups, getlogin, getpgrp
//      uname, time, times, getenv, ctermid, ttyname, isatty, sysconf
//
// Author:
//    Adam Keys ([EMAIL PROTECTED])
//
// (C) 2002 Adam Keys
//

using System.Runtime.InteropServices;

// these are "typedef'd" for lack of a better thing to do
using pid_t = System.Int32;
using gid_t = System.Int32;
using uid_t = System.Int32;
using time_t = System.Int32;
using size_t = System.Int32;
using clock_t = System.Int32;

namespace POSIX {

class utsname {
        string _sysname;
        string _nodename;
        string _release;
        string _version;
        string _machine;
        string _domainname;

        public string sysname {
                get { return _sysname; }
        }

        public string nodename {
                get { return _nodename; }
        }

        public string release {
                get { return _release; }
        }

        public string version {
                get { return _version; }
        }

        public string machine {
                get { return _machine; }
        }

        public string domainname {
                get { return _domainname; }
        }
}

class tms {
        clock_t _tms_utime; // user time
        clock_t _tms_stime; // system time
        clock_t _tms_cutime; // children's user time
        clock_t _tms_cstime; // children's system time

        public clock_t tms_utime {
                get { return _tms_utime; }
        }

        public clock_t tms_stime {
                get { return _tms_stime; }
        }

        public clock_t tms_cutime {
                get { return _tms_cutime; }
        }

        public clock_t tms_cstime {
                get { return _tms_cstime; }
        }
}

class POSIX {

        // These all return int right now, but in reality they return a typedef
        // which may be kernel-dependent.  Should these return a struct instead?
        // Will that matter once they become internal calls?  Do we care?

        [DllImport("libc", EntryPoint="getpid")]
        public static extern pid_t getpid();

        [DllImport("libc", EntryPoint="getppid")]
        public static extern pid_t getppid();

        [DllImport("libc", EntryPoint="getuid")]
        public static extern uid_t getuid();

        [DllImport("libc", EntryPoint="geteuid")]
        public static extern uid_t geteuid();

        [DllImport("libc", EntryPoint="getgid")]
        public static extern gid_t getgid();

        [DllImport("libc", EntryPoint="getegid")]
        public static extern gid_t getegid();

        [DllImport("libc", EntryPoint="setuid")]
        public static extern int setuid(uid_t uid);

        [DllImport("libc", EntryPoint="setgid")]
        public static extern int setgid(gid_t gid);

        [DllImport("libc", EntryPoint="setpgid")]
        public static extern int setpgid(gid_t pgid);

        [DllImport("libc", EntryPoint="setsid")]
        public static extern pid_t setsid();

        [DllImport("libc", EntryPoint="getgroups")]
        public static extern int getgroups(int size, gid_t[] list);

        [DllImport("libc", EntryPoint="setgroups")]
        public static extern int setgroups(size_t size, gid_t[] list);

        [DllImport("libc", EntryPoint="getlogin")]
        public static extern string getlogin();

        [DllImport("libc", EntryPoint="getpgrp")]
        public static extern int getpgrp();

        [DllImport("libc", EntryPoint="uname")]
        public static extern int uname(utsname buf);

        [DllImport("libc", EntryPoint="time")]
        public static extern time_t time(time_t t);

        [DllImport("libc", EntryPoint="times")]
        public static extern clock_t times(tms buf);

        [DllImport("libc", EntryPoint="getenv")]
        public static extern string getenv(string name);

        [DllImport("libc", EntryPoint="ctermid")]
        public static extern string ctermid(string s);

        [DllImport("libc", EntryPoint="ttyname")]
        public static extern string ttyname(int desc);

        [DllImport("libc", EntryPoint="isatty")]
        public static extern int isatty(int desc);

        [DllImport("libc", EntryPoint="sysconf")]
        public static extern long sysconf(int name);
}
}

Reply via email to