static int process_sensors(int level, picl_nodehdl_t nodeh) { picl_nodehdl_t childh; picl_nodehdl_t nexth; char propname[PICL_PROPNAMELEN_MAX]; char propclass[PICL_CLASSNAMELEN_MAX]; picl_errno_t error_code; level++; DEBUGMSGTL(("ucd-snmp/lmSensors","in process_sensors() level %d\n",level)); /* look up first child node */ error_code = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD, &childh, sizeof (picl_nodehdl_t)); if (error_code != PICL_SUCCESS) { DEBUGMSGTL(("ucd-snmp/lmSensors", "picl_get_propval_by_name(%s) %d\n", PICL_PROP_CHILD, error_code)); return (error_code); } /* step through child nodes, get the name first */ while (error_code == PICL_SUCCESS) { error_code = picl_get_propval_by_name(childh, PICL_PROP_NAME, propname, (PICL_PROPNAMELEN_MAX - 1)); if (error_code != PICL_SUCCESS) { /*we found a node with no name. Impossible.! */ DEBUGMSGTL(("ucd-snmp/lmSensors", "picl_get_propval_by_name(%s) = %d\n", PICL_PROP_NAME, error_code)); return (error_code); } error_code = picl_get_propval_by_name(childh, PICL_PROP_CLASSNAME, propclass, sizeof (propclass)); if (error_code != PICL_SUCCESS) { /*we found a node with no class. Impossible.! */ DEBUGMSGTL(("ucd-snmp/lmSensors", "picl_get_propval_by_name(%s) = %d\n", PICL_PROP_CLASSNAME, error_code)); return (error_code); } DEBUGMSGTL(("ucd-snmp/lmSensors","found %s of class %s\n",propname,propclass)); if (strstr(propclass,"fan-tachometer")) process_individual_fan(childh,propname); else if (strstr(propclass,"fan")) process_newtype_fan(childh,propname); else if (strstr(propclass,"temperature-sensor")) process_temperature_sensor(childh,propname); else if (strstr(propclass,"voltage-sensor")) process_voltage_sensor(childh,propname); else if (strstr(propclass,"digital-sensor")) process_digital_sensor(childh,propname); else if (strstr(propclass,"switch")) process_switch(childh,propname); else if (strstr(propclass,"led")) process_led(childh,propname); else if (strstr(propclass,"i2c")) process_i2c(childh,propname); /* else if (strstr(propclass,"gpio")) process_gpio(childh,propname); */ /* look for children of children (note, this is recursive) */ if (!(strstr(propclass,"picl") && (strstr(propname,"frutree") || strstr(propname,"obp")))) { error_code = process_sensors(level,childh); DEBUGMSGTL(("ucd-snmp/lmSensors", "process_sensors(%s) returned %d\n", propname, error_code)); } /* get next child node at this level*/ error_code = picl_get_propval_by_name(childh, PICL_PROP_PEER, &nexth, sizeof (picl_nodehdl_t)); if (error_code != PICL_SUCCESS) {/* no more children - buh bye*/ DEBUGMSGTL(("ucd-snmp/lmSensors","Process sensors is out of children! Returning...\n")); return (error_code); } childh = nexth; } /* while */ return (error_code); } /* process sensors */
static int process_sensors(picl_nodehdl_t nodeh) { picl_nodehdl_t childh; picl_nodehdl_t nexth; char propname[PICL_PROPNAMELEN_MAX]; char propclass[PICL_CLASSNAMELEN_MAX]; picl_errno_t error_code; /* look up first child node */ error_code = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD, &childh, sizeof (picl_nodehdl_t)); if (error_code != PICL_SUCCESS) { return (error_code); } /* step through child nodes, get the name first */ while (error_code == PICL_SUCCESS) { error_code = picl_get_propval_by_name(childh, PICL_PROP_NAME, propname, (PICL_PROPNAMELEN_MAX - 1)); if (error_code != PICL_SUCCESS) { /*we found a node with no name. Impossible.! */ return (error_code); } if (strcmp(propname,PICL_NODE_PLATFORM)==0){ /*end of the chain*/ return (255); } error_code = picl_get_propval_by_name(childh, PICL_PROP_CLASSNAME, propclass, sizeof (propclass)); if (error_code != PICL_SUCCESS) { /*we found a node with no class. Impossible.! */ return (error_code); } /* DEBUGMSGTL(("ucd-snmp/lmSensors","found %s of class %s\n",propname,propclass)); */ if (strstr(propclass,"fan-tachometer")) process_individual_fan(childh,propname); if (strstr(propclass,"temperature-sensor")) process_temperature_sensor(childh,propname); if (strstr(propclass,"digital-sensor")) process_digital_sensor(childh,propname); if (strstr(propclass,"switch")) process_switch(childh,propname); if (strstr(propclass,"led")) process_led(childh,propname); if (strstr(propclass,"i2c")) process_i2c(childh,propname); /* if (strstr(propclass,"gpio")) process_gpio(childh,propname); */ /* look for children of children (note, this is recursive) */ if (process_sensors(childh) == PICL_SUCCESS) { return (PICL_SUCCESS); } /* get next child node at this level*/ error_code = picl_get_propval_by_name(childh, PICL_PROP_PEER, &nexth, sizeof (picl_nodehdl_t)); if (error_code != PICL_SUCCESS) {/* no more children - buh bye*/ return (error_code); } childh = nexth; } /* while */ return (error_code); } /* process sensors */