PreviousUpNext

15.3.526  src/lib/std/src/psx/posix-id.api

## posix-id.api

# Compiled by:
#     src/lib/std/src/standard-core.sublib



# Api for POSIX 1003.1 process dictionary submodule



###        "One of my most productive days
###         was throwing away 1000 lines of code."
###
###                          -- Ken Thompson 



###        "Do not meddle with the affairs
###         of Wizards for they are subtle
###         and quick to anger."
###
###                      -- Gildor
###
###                   [J.R.R. Tolkein, "Lord of the Rings"]



###         "We don't have to protect the
###          environment -- the Second Coming
###          is at hand."
###
###                       -- James Watt



stipulate
    package i1w =  one_word_int;                                        # one_word_int                          is from   src/lib/std/types-only/basis-structs.pkg
    package hi  =  host_int;                                            # host_int                              is from   src/lib/std/src/psx/host-int.pkg
    package uh  =  host_unt;                                            # host_unt                              is from   src/lib/std/types-only/bind-largest32.pkg
    package tim =  time;                                                # time                                  is from   src/lib/std/types-only/basis-time.pkg
herein

    api Posix_Id {
        #
        eqtype Process_Id;
        eqtype File_Descriptor;

        eqtype User_Id;
        eqtype Group_Id;

        uid_to_unt:  User_Id -> uh::Unt;
        unt_to_uid:  uh::Unt -> User_Id;
        gid_to_unt:  Group_Id -> uh::Unt;
        unt_to_gid:  uh::Unt -> Group_Id;

        get_process_id:            Void -> hi::Int;          get_process_id':            Void -> Process_Id;
        get_parent_process_id:     Void -> hi::Int;          get_parent_process_id':     Void -> Process_Id;

        get_user_id:               Void -> hi::Int;          get_user_id':               Void -> User_Id;
        get_effective_user_id:     Void -> hi::Int;          get_effective_user_id':     Void -> User_Id;

        get_group_id:              Void -> hi::Int;          get_group_id':              Void -> Group_Id;
        get_effective_group_id:    Void -> hi::Int;          get_effective_group_id':    Void -> Group_Id;

        set_user_id:               hi::Int -> Void;          set_user_id':               User_Id  -> Void;
        set_group_id:              hi::Int -> Void;          set_group_id':              Group_Id -> Void;

        get_group_ids:             Void -> List( hi::Int );  get_group_ids':             Void -> List( Group_Id );

        get_login:                 Void -> String;

        get_process_group:         Void -> Int;                    get_process_group':         Void -> Process_Id;
        set_session_id:            Void -> Int;                    set_session_id':            Void -> Process_Id;

        set_process_group_id
            :
            (Int, Int)
            ->
            Void;

        set_process_group_id'
            :
            { pid:   Null_Or( Process_Id ),
              pgid:  Null_Or( Process_Id )
            }
            ->
            Void;

        get_kernel_info:  Void -> List ((String, String));

                                                                        # Note that while get_elapsed_seconds_since_1970()
                                                                        # is traditional (under the name 'time()'), it only measures
                                                                        # time to the resolution of seconds.
                                                                        # tim::now() is much more accurate.
                                                                        #     
        get_elapsed_seconds_since_1970:    Void -> i1w::Int;
        get_elapsed_seconds_since_1970':   Void -> tim::Time;

        times:  Void ->   { elapsed:  tim::Time,                        # Elapsed system time 
                            utime:    tim::Time,                        # User time of process 
                            stime:    tim::Time,                        # System time of process 
                            cutime:   tim::Time,                        # User time of terminated child processes 
                            cstime:   tim::Time                         # System time of terminated child processes 
                          };

        getenv:         String -> Null_Or( String );                    # E.g.,   getenv "HOME"   ->   THE "/home/cynbe"
        environment:    Void -> List( String );                         # E.g.,   environment ()  ->   [ "HOME=/home/cynbe", "LOGNAME=cynbe", "DISPLAY=:0.0", ... ]

        get_name_of_controlling_terminal:       Void            -> String;
        get_name_of_terminal:                   File_Descriptor -> String;
        is_a_terminal:                          File_Descriptor -> Bool;

        sysconf:  String -> uh::Unt;

        #######################################################################
        # Below stuff is intended only for one-time use during
        # booting, to switch from direct to indirect syscalls:                                                  # For background see Note[1]            in   src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg


             get_process_id__syscall:    Void -> hi::Int;
        set__get_process_id__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> hi::Int) } -> (Void -> hi::Int)) -> Void;

             get_parent_process_id__syscall:    Void -> hi::Int;
        set__get_parent_process_id__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> hi::Int) } -> (Void -> hi::Int)) -> Void;

             get_user_id__syscall:    Void -> hi::Int;
        set__get_user_id__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> hi::Int) } -> (Void -> hi::Int)) -> Void;

             get_effective_user_id__syscall:    Void -> hi::Int;
        set__get_effective_user_id__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> hi::Int) } -> (Void -> hi::Int)) -> Void;

             get_group_id__syscall:     Void -> hi::Int;
        set__get_group_id__ref:       ({ lib_name: String, fun_name: String, io_call: (Void -> hi::Int) } -> (Void -> hi::Int)) -> Void;

             get_effective_group_id__syscall:    Void -> hi::Int;
        set__get_effective_group_id__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> hi::Int) } -> (Void -> hi::Int)) -> Void;

             set_user_id__syscall:     hi::Int -> Void;
        set__set_user_id__ref:       ({ lib_name: String, fun_name: String, io_call: (hi::Int -> Void) } -> (hi::Int -> Void)) -> Void;

             set_group_id__syscall:    hi::Int -> Void;
        set__set_group_id__ref:      ({ lib_name: String, fun_name: String, io_call: (hi::Int -> Void) } -> (hi::Int -> Void)) -> Void;

             get_group_ids__syscall:    Void -> List( hi::Int );
        set__get_group_ids__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> List( hi::Int )) } -> (Void -> List( hi::Int ))) -> Void;

             get_login__syscall:    Void -> String;
        set__get_login__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> String) } -> (Void -> String)) -> Void;

             get_process_group__syscall:    Void -> hi::Int;
        set__get_process_group__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> hi::Int) } -> (Void -> hi::Int)) -> Void;

             set_session_id__syscall:    Void -> hi::Int;
        set__set_session_id__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> hi::Int) } -> (Void -> hi::Int)) -> Void;

             set_process_group_id__syscall:    (hi::Int, hi::Int) -> Void;
        set__set_process_group_id__ref:      ({ lib_name: String, fun_name: String, io_call: ((hi::Int, hi::Int) -> Void) } -> ((hi::Int, hi::Int) -> Void)) -> Void;

             get_kernel_info__syscall:    Void ->  List((String, String));
        set__get_kernel_info__ref:      ({ lib_name: String, fun_name: String, io_call: (Void ->  List((String, String))) } -> (Void ->  List((String, String)))) -> Void;

             get_elapsed_seconds_since_1970__syscall:    Void -> i1w::Int;
        set__get_elapsed_seconds_since_1970__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> i1w::Int) } -> (Void -> i1w::Int)) -> Void;

             times__syscall:    Void -> (i1w::Int, i1w::Int, i1w::Int, i1w::Int, i1w::Int);
        set__times__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> (i1w::Int, i1w::Int, i1w::Int, i1w::Int, i1w::Int)) } -> (Void -> (i1w::Int, i1w::Int, i1w::Int, i1w::Int, i1w::Int))) -> Void;

             getenv__syscall:    String -> Null_Or(String);
        set__getenv__ref:      ({ lib_name: String, fun_name: String, io_call: (String -> Null_Or(String)) } -> (String -> Null_Or(String))) -> Void;

             environment__syscall:    Void ->  List(String);
        set__environment__ref:      ({ lib_name: String, fun_name: String, io_call: (Void ->  List(String)) } -> (Void ->  List(String))) -> Void;

             get_name_of_controlling_terminal__syscall:    Void -> String;
        set__get_name_of_controlling_terminal__ref:      ({ lib_name: String, fun_name: String, io_call: (Void -> String) } -> (Void -> String)) -> Void;

             get_name_of_terminal__syscall:    hi::Int -> String;
        set__get_name_of_terminal__ref:      ({ lib_name: String, fun_name: String, io_call: (hi::Int -> String) } -> (hi::Int -> String)) -> Void;

             is_a_terminal__syscall:    hi::Int -> Bool;
        set__is_a_terminal__ref:      ({ lib_name: String, fun_name: String, io_call: (hi::Int -> Bool) } -> (hi::Int -> Bool)) -> Void;
    };                                                                                                          # api Posix_Id 
end;


## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext