/** * Object-to-Config function. * Creates a config-node (and subnodes) from a LedSetup model * @param c the current preferences context * @param n a freshly created prefs node that this function should fill with properties of obj * @param obj object of this class where preferences should be generated from * @result NFT_SUCCESS if everything went fine, NFT_FAILURE otherwise * @note you shouldn't call this function directly * It's used by nft_prefs_obj_to_node() etc. */ static NftResult _prefs_from_setup(NftPrefs * p, NftPrefsNode * n, void *obj, void *userptr) { if(!p || !n || !obj) NFT_LOG_NULL(NFT_FAILURE); /* "Setup" object */ LedSetup *s = obj; /* process all "hardware" objects */ LedHardware *h; for(h = led_setup_get_hardware(s); h; h = led_hardware_list_get_next(h)) { /* generate prefs for each hardware node */ NftPrefsNode *node; if(! (node = nft_prefs_obj_to_node(p, LED_HARDWARE_NAME, h, NULL))) return NFT_FAILURE; /* add hardware to this setup */ if(!(nft_prefs_node_add_child(n, node))) return NFT_FAILURE; } return NFT_SUCCESS; }
/** * generate LedPrefsNode from LedChain object * * @param p LedPrefs context * @param c LedChain object * @result newly created LedPrefsNode */ LedPrefsNode *led_prefs_chain_to_node(LedPrefs * p, LedChain * c) { if(!p || !c) NFT_LOG_NULL(NULL); return nft_prefs_obj_to_node(p, LED_CHAIN_NAME, c, NULL); }
/** * generate LedPrefsNode from LedSetup object * * @param p LedPrefs context * @param s LedSetup object * @result newly created LedPrefsNode */ LedPrefsNode *led_prefs_setup_to_node(LedPrefs * p, LedSetup * s) { if(!p || !s) NFT_LOG_NULL(NULL); return nft_prefs_obj_to_node(p, LED_SETUP_NAME, s, NULL); }
/** * generate LedPrefsNode from LedHardware object * * @param p LedPrefs context * @param h LedHardware object */ LedPrefsNode *led_prefs_hardware_to_node(LedPrefs * p, LedHardware * h) { return nft_prefs_obj_to_node(p, LED_HARDWARE_NAME, h, NULL); }