diff -r 0b850238c588 -r dc2bb09d412c src/lua_irc.c --- a/src/lua_irc.c Sun Apr 19 04:35:29 2009 +0300 +++ b/src/lua_irc.c Sun Apr 19 04:52:12 2009 +0300 @@ -149,16 +149,17 @@ static int lua_client_set_defaults (lua_State *L) { + int nargs = lua_gettop(L); struct lua_client *lua_client = lua_obj_get_obj(L, __func__, "evirc.client"); // required args - lua_client->defaults.register_info.nickname = lua_arg_string(L, 2, "nickname", LUA_ARG_STRING_REQUIRED); - lua_client->defaults.register_info.username = lua_arg_string(L, 3, "username", LUA_ARG_STRING_REQUIRED); - lua_client->defaults.register_info.realname = lua_arg_string(L, 4, "realname", LUA_ARG_STRING_REQUIRED); + lua_client->defaults.register_info.nickname = lua_arg_string(L, nargs, 2, "nickname", LUA_ARG_STRING_REQUIRED); + lua_client->defaults.register_info.username = lua_arg_string(L, nargs, 3, "username", LUA_ARG_STRING_REQUIRED); + lua_client->defaults.register_info.realname = lua_arg_string(L, nargs, 4, "realname", LUA_ARG_STRING_REQUIRED); // optional args - lua_client->defaults.service = lua_arg_string(L, 5, "service", IRC_PORT); - lua_client->defaults.service_ssl = lua_arg_string(L, 6, "service_ssl", IRC_SSL_PORT); + lua_client->defaults.service = lua_arg_string(L, nargs, 5, "service", IRC_PORT); + lua_client->defaults.service_ssl = lua_arg_string(L, nargs, 6, "service_ssl", IRC_SSL_PORT); // invoke irc_client_set_defaults(lua_client->client, &lua_client->defaults); @@ -169,6 +170,7 @@ static int lua_client_connect (lua_State *L) { + int nargs = lua_gettop(L); struct lua_client *lua_client = lua_obj_get_obj(L, __func__, "evirc.client"); struct irc_net_info net_info; const char *ssl_cafile = NULL, *ssl_cert = NULL, *ssl_pkey = NULL; @@ -180,18 +182,18 @@ memset(&net_info, 0, sizeof(net_info)); // required args - net_info.network = lua_arg_string(L, 2, "network", LUA_ARG_STRING_REQUIRED); - net_info.hostname = lua_arg_string(L, 3, "hostname", LUA_ARG_STRING_REQUIRED); + net_info.network = lua_arg_string(L, nargs, 2, "network", LUA_ARG_STRING_REQUIRED); + net_info.hostname = lua_arg_string(L, nargs, 3, "hostname", LUA_ARG_STRING_REQUIRED); // optional args - net_info.service = lua_arg_string(L, 4, "service", NULL); + net_info.service = lua_arg_string(L, nargs, 4, "service", NULL); // ssl stuff - use_ssl = lua_arg_bool (L, 5, "use_ssl", false); - ssl_cafile = lua_arg_string(L, 6, "ssl_cafile", NULL); - ssl_verify = lua_arg_bool (L, 7, "ssl_verify", false); - ssl_cert = lua_arg_string(L, 8, "ssl_cert", NULL); - ssl_pkey = lua_arg_string(L, 9, "ssl_pkey", NULL); + use_ssl = lua_arg_bool (L, nargs, 5, "use_ssl", false); + ssl_cafile = lua_arg_string(L, nargs, 6, "ssl_cafile", NULL); + ssl_verify = lua_arg_bool (L, nargs, 7, "ssl_verify", false); + ssl_cert = lua_arg_string(L, nargs, 8, "ssl_cert", NULL); + ssl_pkey = lua_arg_string(L, nargs, 9, "ssl_pkey", NULL); // SSL? if (use_ssl || ssl_cafile || ssl_verify || ssl_cert || ssl_pkey) {