Exemple #1
0
install_t
install_socket()
{   nbio_init("socket");

    ATOM_reuseaddr        = PL_new_atom("reuseaddr");
    ATOM_bindtodevice     = PL_new_atom("bindtodevice");
    ATOM_broadcast        = PL_new_atom("broadcast");
    ATOM_nodelay	        = PL_new_atom("nodelay");
    ATOM_dispatch	        = PL_new_atom("dispatch");
    ATOM_nonblock	        = PL_new_atom("nonblock");
    ATOM_infinite	        = PL_new_atom("infinite");
    ATOM_as	        = PL_new_atom("as");
    ATOM_atom	        = PL_new_atom("atom");
    ATOM_string	        = PL_new_atom("string");
    ATOM_codes	        = PL_new_atom("codes");
    ATOM_max_message_size = PL_new_atom("max_message_size");

    FUNCTOR_socket1 = PL_new_functor(PL_new_atom("$socket"), 1);

    PL_register_foreign("tcp_accept",           3, pl_accept,           0);
    PL_register_foreign("tcp_bind",             2, pl_bind,             0);
    PL_register_foreign("tcp_connect",          2, pl_connect,	      0);
    PL_register_foreign("tcp_listen",           2, pl_listen,           0);
    PL_register_foreign("tcp_open_socket",      3, pl_open_socket,      0);
    PL_register_foreign("tcp_socket",           1, tcp_socket,          0);
    PL_register_foreign("tcp_close_socket",     1, pl_close_socket,     0);
    PL_register_foreign("tcp_setopt",           2, pl_setopt,           0);
    PL_register_foreign("tcp_host_to_address",  2, pl_host_to_address,  0);
    PL_register_foreign("gethostname",          1, pl_gethostname,      0);
    PL_register_foreign("tcp_select",           3, tcp_select,          0);

    PL_register_foreign("udp_socket",           1, udp_socket,          0);
    PL_register_foreign("udp_receive",	      4, udp_receive,	      0);
    PL_register_foreign("udp_send",	      4, udp_send,	      0);

#ifdef O_DEBUG
    PL_register_foreign("tcp_debug",	      1, pl_debug,	      0);
#endif
}
Exemple #2
0
install_t
install_tipc()
{ FILE *fp = fopen("/sys/module/tipc/version", "r");

  if(fp)
    { char buf[32];
      size_t n = fread(buf, sizeof(char), sizeof(buf), fp);

      if(n > 0)
         tipc_version = buf[0] - '0';

      fclose(fp);
    } 

  nbio_init("tipc");

  ATOM_scope	       = PL_new_atom("scope");
  ATOM_no_scope	       = PL_new_atom("no_scope");
  ATOM_node	       = PL_new_atom("node");
  ATOM_cluster	       = PL_new_atom("cluster");
  ATOM_zone	       = PL_new_atom("zone");
  ATOM_all	       = PL_new_atom("all");

  ATOM_importance      = PL_new_atom("importance");
  ATOM_low	       = PL_new_atom("low");
  ATOM_medium	       = PL_new_atom("medium");
  ATOM_high	       = PL_new_atom("high");
  ATOM_critical	       = PL_new_atom("critical");
  ATOM_src_droppable   = PL_new_atom("src_droppable");
  ATOM_dest_droppable  = PL_new_atom("dest_droppable");
  ATOM_conn_timeout    = PL_new_atom("conn_timeout");

  ATOM_socket_type     = PL_new_atom("socket_type");
  ATOM_dgram	       = PL_new_atom("dgram");
  ATOM_rdm	       = PL_new_atom("rdm");
  ATOM_seqpacket       = PL_new_atom("seqpacket");
  ATOM_stream	       = PL_new_atom("stream");

  ATOM_dispatch        = PL_new_atom("dispatch");
  ATOM_nodelay	       = PL_new_atom("nodelay");
  ATOM_nonblock	       = PL_new_atom("nonblock");
  ATOM_as	       = PL_new_atom("as");
  ATOM_atom	       = PL_new_atom("atom");
  ATOM_string	       = PL_new_atom("string");
  ATOM_codes	       = PL_new_atom("codes");

  FUNCTOR_tipc_socket1 = PL_new_functor(PL_new_atom("$tipc_socket"), 1);
  FUNCTOR_port_id      = PL_new_functor(PL_new_atom("port_id"), 2);
  FUNCTOR_name3	       = PL_new_functor(PL_new_atom("name"), 3);
  FUNCTOR_name_seq3    = PL_new_functor(PL_new_atom("name_seq"), 3);
  FUNCTOR_mcast3       = PL_new_functor(PL_new_atom("mcast"), 3);

  PL_register_foreign("tipc_socket",          2, tipc_socket,         0);
  PL_register_foreign("tipc_close_socket",    1, tipc_close_socket,   0);
  PL_register_foreign("tipc_setopt",          2, pl_tipc_setopt,      0);
  PL_register_foreign("tipc_bind",            3, pl_tipc_bind,        0);
  PL_register_foreign("tipc_listen",          2, tipc_listen,         0);
  PL_register_foreign("tipc_open_socket",     3, tipc_open_socket,    0);
  PL_register_foreign("tipc_accept",          3, pl_tipc_accept,      0);
  PL_register_foreign("tipc_connect",         2, pl_tipc_connect,     0);
  PL_register_foreign("tipc_get_name",        2, pl_tipc_get_name,    0);
  PL_register_foreign("tipc_get_peer_name",   2, pl_tipc_get_peer_name, 0);
  PL_register_foreign("tipc_receive",	      4, pl_tipc_receive,     0);
  PL_register_foreign("tipc_send",	          4, pl_tipc_send,	      0);
  PL_register_foreign("tipc_subscribe",	      5, pl_tipc_subscribe,   0);
  PL_register_foreign("tipc_receive_subscr_event", 2, pl_tipc_receive_subscr_event,     0);
}