X hits on this document

PDF document

February 10, 2006 - page 115 / 238

517 views

0 shares

0 downloads

0 comments

115 / 238

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 ) ;

So, for instance, if you wanted to print the name and entity id string of every sensor in an entity, you might have code that looks like:

{

} printf("Sensor %s\n"

if (allocated) free(name);

, name);

103

static void h a n d l e _ s e n s o r ( i p m i _ e n t i t y _ t * e n t , i p m i _ s e n s o r _ t * s e n s o r ,

void

* c b _ d a t a )

7.5. SENSOR AND CONTROLS IN AN ENTITY

void

* c b _ d a t a ) ;

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

void print_sensors(ipmi_entity_t *entity) {

i p m i _ e n t i t y _ i t e r a t e _ s e n s o r s ( e n t i t y , h a n d l e _ s e n s o r , N U L } L ) ;

However, you probably want to know about the sensors and controls as soon as they are created or destroyed. To do this, you can add callback functions to the entity to call you whenever a sensor or control is added to the entity or deleted from the entity. The following functions allow the user to watch sensors in a domain:

_ _ _ typedef void (*ipmi entity_sensor cb)(enum ipmi_update e op,

_ ipmi entity_t

*ent,

_ ipmi sensor_t

*sensor,

void

*cb_data);

Document info
Document views517
Page views517
Page last viewedSat Dec 03 07:16:02 UTC 2016
Pages238
Paragraphs8090
Words85809

Comments