The discover_resources function

	prototype:
	static int *discover_resources(*hnd);
    

The discover_resources function is the function which reports the plug-in's findings of resources, sensors, controls, etc. to the infrastructure.

In most existing plug-ins, the code would retrieve RPT entries from the rptcache and format them into oh_event(s) structures and append them into the eventq. The infrastructure would retrieve these events from each plug-in defined in the config file and store them in the main RPT table of the infrastructure.

The oh_handler_state structure

So now is a good time to talk about the oh_handler_state

The oh_handler_state structure contains:

    struct oh_handler_state {
	RPTable *rptcache;
	GSList *eventq;
	GHashTable *config;
	void *data;
    };
    

The oh_handler_state happens to be the state structure of a plug-in. Meaning it holds the rptcache, eventq and config data of a plug-in as well as a pointer to private data which the plug-in owner may decide to hold private to the plug-in.

Part of the discover_resources function is to invoke routines which talk to the hardware and gather resource information and format them into HPI RPT (entries). Further, the discover_resources function formats the entries into an openhpi "event" union provided by (look at oh_plugin.h):

	struct oh_event {
        	enum {
                	OH_ET_RESOURCE,
                	OH_ET_RESOURCE_DEL,
	                OH_ET_RDR,
        	        OH_ET_RDR_DEL,
                	OH_ET_HPI
	        }type;
        	union {
                	struct oh_resource_event res_event;
	                struct oh_resource_del_event res_del_event;
        	        struct oh_rdr_event      rdr_event;
                	struct oh_rdr_del_event  rdr_del_event;
                	struct oh_hpi_event      hpi_event;
        	} u;
	};
    
and pushes these events into the oh_handler_stats's eventq (GSList) for later retrieval by the get_event() function.