|
Was expecting something to the effect of {{},{},...} with this:int lua_proc_locate_name( lua_State *L ) {
int ret = EXIT_SUCCESS, underId = 0;
char const *name;
char I[sizeof(int)*CHAR_BIT] = {0};
nodes_t nodes = {0};
proc_notice_t *notice;
node_t i;
if ( lua_isinteger(L,2) || lua_isnumber(L,2) )
underId = lua_tonumber(L,2);
if ( !lua_isstring(L,1) ) {
lua_error_cb( L, "Invalid name" );
return 0;
}
name = lua_tostring(L,1);
notice = proc_locate_name( &ret, name, &nodes, underId );
lua_newtable( L );
for ( i = 0; i < nodes.count; ++i ) {
sprintf(I,"%lu",(unsigned long)i);
lua_newtable( L );
push_branch_obj( L, I );
push_branch_bool( L, "self", notice->self );
push_branch_int( L, "entryId", notice->entryId );
push_branch_int( L, "ownerId", notice->ownerId );
push_branch_str( L, "name", (char*)(notice->name.block) );
push_branch_str( L, "cmdl", (char*)(notice->cmdl.block) );
proc_notice_zero( notice + i );
}
free_nodes( proc_notice_t, &ret, &nodes );
return 1;
}While I do understand I've done something wrong I just don't see what I've done wrong
int lua_proc_locate_name( lua_State *L ) {
int ret = EXIT_SUCCESS, underId = 0;
char const *name;
nodes_t nodes = {0};
proc_notice_t *notice;
node_t i;
if ( lua_isinteger(L,2) || lua_isnumber(L,2) )
underId = lua_tonumber(L,2);
if ( !lua_isstring(L,1) ) {
lua_error_cb( L, "Invalid name" );
return 0;
}
name = lua_tostring(L,1);
notice = proc_locate_name( &ret, name, &nodes, underId );
lua_newtable( L );
for ( i = 0; i < nodes.count; ++i ) {
lua_pushinteger(L,i+1);
lua_newtable( L );
push_branch_bool( L, "self", notice->self );
push_branch_int( L, "entryId", notice->entryId );
push_branch_int( L, "ownerId", notice->ownerId );
push_branch_str( L, "name", (char*)(notice->name.block) );
push_branch_str( L, "cmdl", (char*)(notice->cmdl.block) );
lua_settable(L,-3);
proc_notice_zero( notice );
++notice;
}
free_nodes( proc_notice_t, &ret, &nodes );
return 1;
}