##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: January 2017 # Modified: 2017-01-12/17:32-0500 ##+ # # cobffi.icn, test calling COBOL without wrapper with libffi # $include "natives.inc" procedure main() # will be RTLD_LAZY | RTLD_GLOBAL (so add to the search path) addLibrary := loadfunc("./uniffi.so", "addLibrary") # allow arbitrary C functions, marshalled by libffi native := loadfunc("./uniffi.so", "ffi") # add the testing functions to the dlsym search path, # the handle is somewhat irrelevant, but won't be soonish dlHandle := addLibrary("./cobolnative.so") # initialize GnuCOBOL native("cob_init", TYPEVOID) # pass two integers, get back a sum ans := native("cobolnative", TYPEINT, 40, 2) write("Unicon: called sample and got ", ans) # rundown the libcob runtime native("cob_tidy", TYPEVOID) end