Passing a pointer of function to a c function
- Posted by David Ryder <ryder7 at btinternet.com> Apr 02, 2007
- 546 views
Please could anyone help me to use this c function thanks. SWHANDLE SWModule_doSearch(SWHANDLE hmodule, const char *searchString, int type, int params ,void (*percent) (char, void *), void *percentUserData) it's the bit that points to a function that I am not sure how to get it to work in Euphoria: void (*percent) (char, void *) this is the euphoria that imports this function.
SWModSearch = define_c_func(swordLib, "SWModule_doSearch", {C_POINTER, C_CHAR, C_INT, C_INT, C_POINTER, C_POINTER}, C_POINTER) global function EuSWModSearch(atom mod, sequence searchString, atom searchType, atom params ,atom percent, atom percentUserData) atom listPtr, searchStringPtr, percentPtr, percentUserDataPtr sequence listKey, element searchStringPtr = allocate_string(searchString) percentPtr = allocate(4) percentUserDataPtr = allocate(4) listPtr = c_func(SWModSearch,{mod, searchStringPtr, searchType, params, percentPtr, percentUserDataPtr}) if listPtr != NULL then element = getListKeyVal(listPtr) while element != NULL do listKey = append(listKey, element) listKeyNext(listPtr) element = getListKeyVal(listPtr) end while end if return listKey end function Thanks for your help David