Esempio n. 1
0
File: engine.c Progetto: bjorng/otp
char *get_key_password(ErlNifEnv *env, ERL_NIF_TERM key) {
    ERL_NIF_TERM tmp_term;
    ErlNifBinary pwd_bin;
    char *pwd = NULL;

    if (!enif_get_map_value(env, key, atom_password, &tmp_term))
        goto err;
    if (!enif_inspect_binary(env, tmp_term, &pwd_bin))
        goto err;
    if (!zero_terminate(pwd_bin, &pwd))
        goto err;

    return pwd;

 err:
    return NULL;
}
Esempio n. 2
0
void dbg_ngx_ptr(ngx_str_t* msg, ngx_pool_t* pool)
{
  if (msg == NULL)
  {
    dbg_cstr_nl("dbg_ngx_ptr ERROR: msg is null");
    return;
  }
  if (msg->data == NULL)
  {
    dbg_cstr_nl("dbg_ngx_ptr ERROR: data (null)");
    return;
  }
  if(msg->len == 0)
  {
    dbg_cstr_nl("dbg_ngx_ptr ERROR: 0 length string");
    return;
  }
  dbg_cstr_nl(zero_terminate(*msg, pool));
}
Esempio n. 3
0
File: engine.c Progetto: bjorng/otp
int get_engine_and_key_id(ErlNifEnv *env, ERL_NIF_TERM key, char ** id, ENGINE **e)
{
    ERL_NIF_TERM engine_res, key_id_term;
    struct engine_ctx *ctx;
    ErlNifBinary key_id_bin;

    if (!enif_get_map_value(env, key, atom_engine, &engine_res))
        goto err;
    if (!enif_get_resource(env, engine_res, engine_ctx_rtype, (void**)&ctx))
        goto err;
    if (!enif_get_map_value(env, key, atom_key_id, &key_id_term))
        goto err;
    if (!enif_inspect_binary(env, key_id_term, &key_id_bin))
        goto err;

    *e = ctx->engine;
    return zero_terminate(key_id_bin, id);

 err:
    return 0;
}
Esempio n. 4
0
Utf8String Buffer<Allocator>::utf8_str()
{
	zero_terminate();

	return Utf8String::from_utf8((char*) _start, _pos - _start);
}
Esempio n. 5
0
const char* Buffer<Allocator>::c_str()
{
	zero_terminate();

	return (const char*) _start;
}