All pastes #98699 Raw Edit

Stuff

public c v1 · immutable
#98699 ·published 2006-07-24 18:55 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;}