PreviousUpNext

15.4.1174  src/lib/std/src/socket/net-service-db.pkg

## net-service-db.pkg

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



###             "I am not young enough to know everything."
###                                       -- Oscar Wilde

  
stipulate
    package ci  =  mythryl_callable_c_library_interface;                # mythryl_callable_c_library_interface  is from   src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg
    #
    fun cfun  fun_name
        =
        ci::find_c_function'' { lib_name => "socket",  fun_name };
herein

    package   net_service_db
    : (weak)  Net_Service_Db                                            # Net_Service_Db                        is from   src/lib/std/src/socket/net-service-db.api
    {
        Entry = ENTRY { name:      String,
                        aliases:   List( String ),
                        port:      Int,
                        protocol:  String
                      };

        stipulate
            fun conc field' (ENTRY a) = field' a;
        herein
            name     = conc .name;
            aliases  = conc .aliases;
            port     = conc .port;
            protocol = conc .protocol;
        end;

        Servent = ((String, List( String ), Int, String));

        (cfun "get_service_by_name")                                                    # "get_service_by_name" def in    src/c/lib/socket/get-service-by-name.c
            ->
            (      get_service_by_name__syscall:    (String,  Null_Or(String)) -> Null_Or(Servent),
                   get_service_by_name__ref,
              set__get_service_by_name__ref
            );


        (cfun "get_service_by_port")                                                    # "get_service_by_port" def in    src/c/lib/socket/get-service-by-port.c
            ->
            (      get_service_by_port__syscall:    (Int,     Null_Or(String)) -> Null_Or(Servent),
                   get_service_by_port__ref,
              set__get_service_by_port__ref
            );

        # Server DB query functions:
        #
        stipulate

            fun get_serv_ent (THE (name, aliases, port, protocol))
                    =>
                    THE (ENTRY { name, aliases, port, protocol } );

                get_serv_ent NULL =>   NULL;
            end;
        herein

            fun get_by_name arg =  get_serv_ent (*get_service_by_name__ref arg);
            fun get_by_port arg =  get_serv_ent (*get_service_by_port__ref arg);
        end;                                                                                    # stipulate

    };
end;


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


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext