--- a/src/lua_objs.c Tue Mar 31 22:09:53 2009 +0300
+++ b/src/lua_objs.c Tue Mar 31 23:35:24 2009 +0300
@@ -218,8 +218,31 @@
*/
struct lua_client {
struct irc_client *client;
+
+ struct irc_client_defaults defaults;
};
+static int lua_client_set_defaults (lua_State *L)
+{
+ struct lua_client *lua_client = lua_obj_get_obj(L, __func__, "evirc.client");
+
+ // read the args
+ // XXX: need to copy these, really
+ lua_client->defaults.register_info.nickname = luaL_checkstring(L, 2);
+ lua_client->defaults.register_info.username = luaL_checkstring(L, 3);
+ lua_client->defaults.register_info.realname = luaL_checkstring(L, 4);
+
+ // set the non-args
+ lua_client->defaults.service = IRC_PORT;
+ lua_client->defaults.service_ssl = IRC_SSL_PORT;
+
+ // invoke
+ irc_client_set_defaults(lua_client->client, &lua_client->defaults);
+
+ // ok
+ return 0;
+}
+
static int lua_client_connect (lua_State *L)
{
struct lua_client *lua_client = lua_obj_get_obj(L, __func__, "evirc.client");
@@ -280,10 +303,11 @@
}
static const struct luaL_Reg lua_client_methods[] = {
- { "connect", &lua_client_connect },
- { "network", &lua_client_get_network },
- { "quit", &lua_client_quit },
- { NULL, NULL }
+ { "set_defaults", &lua_client_set_defaults },
+ { "connect", &lua_client_connect },
+ { "network", &lua_client_get_network },
+ { "quit", &lua_client_quit },
+ { NULL, NULL }
};
/**