4 * Copyright 2010 Martin Quinson, Mehdi Fekari
7 * This program is free software; you can redistribute
8 * it and/or modify it under the terms of the license
9 *(GNU LGPL) which comes with this package.
11 #include "rb_msg_host.h"
14 void host_free(m_host_t ht) {
18 // New Method : return a Host
19 static VALUE host_get_by_name(VALUE class, VALUE name)
22 const char * h_name = RSTRING(name)->ptr;
23 m_host_t host = MSG_get_host_by_name(h_name);
25 rb_raise(rb_eRuntimeError,"MSG_get_host_by_name() failled");
27 return Data_Wrap_Struct(class,0,host_free,host);
32 static VALUE host_name(VALUE class,VALUE host)
35 // Wrap Ruby Value to m_host_t struct
37 Data_Get_Struct(host, m_host_t, ht);
38 return rb_str_new2(MSG_host_get_name(*ht));
43 static VALUE host_number(VALUE class)
46 return INT2NUM(MSG_get_host_number());
50 // Host Speed ( Double )
51 static VALUE host_speed(VALUE class,VALUE host)
54 Data_Get_Struct(host,m_host_t,ht);
55 return MSG_get_host_speed(*ht);
60 static void host_set_data(VALUE class,VALUE host,VALUE data)
66 static VALUE host_get_data(VALUE class,VALUE host)
73 static VALUE host_is_avail(VALUE class,VALUE host)
77 Data_Get_Struct(host,m_host_t,ht);
80 rb_raise(rb_eRuntimeError,"Host not Bound");
84 if(MSG_host_is_avail(*ht))