All pastes #97369 Raw Edit

Someone

public c v1 · immutable
#97369 ·published 2006-07-23 17:23 UTC
rendered paste body
#include <stdio.h>#include <string.h>#include <ffi.h>static voidclosure (ffi_cif* cif, void* resp, void** args, void* userdata){  printf ("arg: %s\n", (char *) args[0]);  * (char *) resp = * strdup("test dos");}typedef char * (*callback_type) (char *);intmain (void){  ffi_cif cif;  ffi_closure cl;  ffi_type *args[1];  char *res, *tmp;  args[0] = &ffi_type_pointer;  if (FFI_OK != ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_pointer, args)) {    printf ("couldn't prepare cif\n");    return 1;  }  if (FFI_OK != ffi_prep_closure(&cl, &cif, closure, NULL)) {    printf ("couldn't prepare closure\n");    return 1;  }  res = ((callback_type) &cl) ("test uno");  printf("res: %s\n", res);  return 0;}