lm_connection.c
changeset 45 1fcec4b012a7
parent 38 34a2b880615c
child 54 6bef2082e5f9
equal deleted inserted replaced
44:afe0184885a0 45:1fcec4b012a7
   151 /// Tries to authenticate against opened connection, then calls callback function.
   151 /// Tries to authenticate against opened connection, then calls callback function.
   152 /// A: string (username), string (password), string (resource), connection callback function
   152 /// A: string (username), string (password), string (resource), connection callback function
   153 /// R: lm connection object or nil, string (error message)
   153 /// R: lm connection object or nil, string (error message)
   154 static int authenticate_lm_connection (lua_State *L)
   154 static int authenticate_lm_connection (lua_State *L)
   155 {
   155 {
   156 	llm_connection_t *object = luaL_checklm_connection (L, 1);
   156 	llm_connection_t *object   = luaL_checklm_connection (L, 1);
   157 	const char *username = luaL_checkstring (L, 2);
   157 	const char       *username = luaL_checkstring (L, 2);
   158 	const char *password = luaL_checkstring (L, 3);
   158 	const char       *password = luaL_checkstring (L, 3);
   159 	const char *resource = luaL_checkstring (L, 4);
   159 	const char       *resource = luaL_checkstring (L, 4);
   160 	llm_callback_t *cb;
   160 	GError           *err      = NULL;
   161 	int status;
   161 	llm_callback_t   *cb;
   162 	GError *err = NULL;
       
   163 	luaL_argcheck (L, lua_isfunction (L, 5), 5, "function expected");
   162 	luaL_argcheck (L, lua_isfunction (L, 5), 5, "function expected");
   164 
   163 
   165 	cb = luaL_malloc (L, sizeof (llm_callback_t));
   164 	cb = luaL_malloc (L, sizeof (llm_callback_t));
   166 	cb->reference = luaL_ref (L, LUA_REGISTRYINDEX);
   165 	cb->reference = luaL_ref (L, LUA_REGISTRYINDEX);
   167 	cb->L         = L;
   166 	cb->L         = L;