PreviousUpNext

15.4.1175  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
herein

    package   net_service_db
    : (weak)  Net_Service_Db                                            # Net_Service_Db                        is from   src/lib/std/src/socket/net-service-db.api
    {
        fun netdb_fun  fun_name
            =
            ci::find_c_function { lib_name => "socket",  fun_name };

        Entry =
            SERVENT
              {
                name:      String,
                aliases:   List( String ),
                port:      Int,
                protocol:  String
              };

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

        # Server DB query functions:
        #
        stipulate
            Servent = ((String, List( String ), Int, String));
            fun get_serv_ent NULL => NULL;
               get_serv_ent (THE (name, aliases, port, protocol)) => THE (SERVENT {
                    name, aliases, port, protocol
                  } ); end;

            my get_service_by_name' : (String, Null_Or( String )) -> Null_Or( Servent )
               =
               netdb_fun "get_service_by_name";                                                 # "get_service_by_name" def in    src/c/lib/socket/get-service-by-name.c

            my get_service_by_port' : (Int, Null_Or( String )) -> Null_Or( Servent )
               =
               netdb_fun "get_service_by_port";                                                 # "get_service_by_port" def in    src/c/lib/socket/get-service-by-port.c
        herein
            get_by_name = get_serv_ent o get_service_by_name';
            get_by_port = get_serv_ent o get_service_by_port';
        end; #  local 

    };
end;


## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext