Exemple #1
0
static int openssl_new_xattrs(lua_State*L)
{
  size_t i;
  int idx = 1;
  STACK_OF(X509_ATTRIBUTE) *attrs  = sk_X509_ATTRIBUTE_new_null();
  luaL_checktable(L, idx);

  for (i = 0; i < lua_rawlen(L, idx); i++)
  {
    X509_ATTRIBUTE* a = NULL;
    const char* eprefix = NULL;
    lua_rawgeti(L, idx, i + 1);
    if (!lua_istable(L, -1))
    {
      lua_pushfstring(L, "value at %d is not table", i + 1);
      luaL_argerror(L, idx, lua_tostring(L, -1));
    }
    lua_pushfstring(L, "table %d at argument #%d:", idx, i + 1);
    eprefix = lua_tostring(L, -1);
    lua_pop(L, 1);

    a = openssl_new_xattribute(L, &a, lua_gettop(L), eprefix);
    if (a)
    {
      sk_X509_ATTRIBUTE_push(attrs, a);
    }
    lua_pop(L, 1);
  }
  PUSH_OBJECT(attrs, "openssl.stack_of_x509_attribute");
  return 1;
}
Exemple #2
0
static int openssl_new_xattrs(lua_State*L)
{
  size_t i;
  int idx = 1;
  int utf8 = lua_isnoneornil(L, 2) ? 1 : lua_toboolean(L, 2);
  STACK_OF(X509_ATTRIBUTE) *attrs  = sk_X509_ATTRIBUTE_new_null();
  luaL_checktable(L, idx);

  for(i=0; i<lua_rawlen(L, idx); i++)
  {
    X509_ATTRIBUTE* a = NULL;
    lua_rawgeti(L, idx, i+1);
    a = openssl_new_xattribute(L, &a, -1,utf8);
    if(a) {
      sk_X509_ATTRIBUTE_push(attrs,a);
    }
    lua_pop(L,1);
  }
  PUSH_OBJECT(attrs, "openssl.stack_of_x509_attribute");
  return 1;
}