Esempio n. 1
0
static int
_upgrade_module(ErlNifEnv* env, void** priv_data, void** old_priv_data,
    ERL_NIF_TERM load_info)
{
  ErlNifResourceFlags flags;
  CAN_handle_type = enif_open_resource_type(env, MODULE, "CAN_handle_type",
      NULL, ERL_NIF_RT_TAKEOVER, &flags);
  enif_fprintf(stdout, "*** " MODULE " upgraded\n");
  return 0;
}
Esempio n. 2
0
static int
_load_module(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
{
  ErlNifResourceFlags flags;
  CAN_handle_type = enif_open_resource_type(env, MODULE, "CAN_handle_type",
      NULL, ERL_NIF_RT_CREATE, &flags);
  can_atom = make_atom(env, "can");
  enif_fprintf(stdout, "*** " MODULE " loaded\n");
  return 0;
}
Esempio n. 3
0
static ERL_NIF_TERM
_check_tuple (ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
  const ERL_NIF_TERM* items;
  int arity, i;
  enif_get_int(env, argv[0], &i);
  ERL_NIF_TERM head, tail, list;
  list = argv[1];
  while (enif_get_list_cell(env, list, &head, &tail))
    {
      list = tail;
      enif_get_tuple(env, head, &arity, &items);
      enif_fprintf(stdout, "arity: %i\n", arity);
      for (i = 0; i < arity; i++)
        {
          debug_enif_type(env, items[i]);
        }
    }
  return enif_make_int(env, arity);
}
Esempio n. 4
0
static void check_abort(unsigned line)
{
    enif_fprintf(stderr, "Test CHECK failed at %s:%u\r\n",
	    __FILE__, line);
    abort();
}
Esempio n. 5
0
static void
_unload_module(ErlNifEnv* env, void* priv_data)
{
  enif_fprintf(stdout, "*** " MODULE " unloaded\n");
}
Esempio n. 6
0
static int
_reload_module(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
{
  enif_fprintf(stdout, "*** " MODULE " reloaded\n");
  return 0;
}