X hits on this document

PDF document

February 10, 2006 - page 116 / 238

544 views

0 shares

0 downloads

0 comments

116 / 238

_ ipmi entity_t

*ent,

_ ipmi control_t

*control,

void

*cb_data);

104

CHAPTER 7. ENTITIES

As an example, the following code reports the sensor name and whether it was added, removed, or changed:

t y p e d e f v o i d ( * i p m i _ e n t i t y _ c o n t r o l _ c b ) ( e n u m i p m i _ u p d a t e _ e o p

,

The add functions should generally be called in the callback that reports the new entity, that way you will not miss any controls or sensors as they are added. On removal, both the handler and the cb data values must match the values in the add handler, the cb data value is not use for a callback but to find the specific item to remove.

Likewise, the following function are for controls:

i n t i p m i _ e n t i t y _ a d d _ c o n t r o l _ u p d a t e _ h a n d l e r ( i p m i _ e n t i *ent, t y _ t i p m i _ e n t i t y _ c o n t r o l _ c b h a n d l e r ,

void

* c b _ d a t a ) ;

i n t i p m i _ e n t i t y _ a d d _ s e n s o r _ u p d a t e _ h a n d l e r ( i p m i _ e n t i *ent, t y _ t i p m i _ e n t i t y _ s e n s o r _ c b h a n d l e r ,

void

* c b _ d a t a ) ;

*cb_data); *ent, void i n t i p m i _ e n t i t y _ r e m o v e _ c o n t r o l _ u p d a t e _ h a n d l e r ( i p m i _ e n t i t y _ t i p m i _ e n t i t y _ c o n t r o l _ c b h a n d l e r ,

*cb_data); *ent, void i n t i p m i _ e n t i t y _ r e m o v e _ s e n s o r _ u p d a t e _ h a n d l e r ( i p m i _ e n t i t y _ t i p m i _ e n t i t y _ s e n s o r _ c b h a n d l e r ,

char *name;

int

_ _ length = ipmi_sensor_get id length(sensor);

int

allocated = 0;

if (length == 0) name = "empty name"; else { name = malloc(length+1); if (!name) { /* Handle error */ return; } allocated = 1; l e n g t h = i p m i _ s e n s o r _ g e t _ i d ( s e n s o r , n a m e , l e n g t h ) ;

_ _ handle sensor(enum ipmi_update e op,

_ ipmi entity_t

*ent,

_ ipmi sensor_t

*sensor,

void

*cb_data)

static void

{

Document info
Document views544
Page views544
Page last viewedSun Dec 04 11:17:14 UTC 2016
Pages238
Paragraphs8090
Words85809

Comments