93 ssl = lm_ssl_new (NULL, NULL, NULL, NULL); |
93 ssl = lm_ssl_new (NULL, NULL, NULL, NULL); |
94 else if (args == 1 && !lua_isfunction (L, 1)) { |
94 else if (args == 1 && !lua_isfunction (L, 1)) { |
95 gchar buffer[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
95 gchar buffer[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
96 const char *fingerprint = luaL_checkstring (L, 1); |
96 const char *fingerprint = luaL_checkstring (L, 1); |
97 |
97 |
98 if (lua_objlen (L, 1) > 46) |
98 if (lua_rawlen (L, 1) > 46) |
99 string2fingerprint (fingerprint, buffer); |
99 string2fingerprint (fingerprint, buffer); |
100 ssl = lm_ssl_new (buffer, NULL, NULL, NULL); |
100 ssl = lm_ssl_new (buffer, NULL, NULL, NULL); |
101 } else { |
101 } else { |
102 llm_callback_t *cb; |
102 llm_callback_t *cb; |
103 gchar buffer[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
103 gchar buffer[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
104 |
104 |
105 if (args > 1) { |
105 if (args > 1) { |
106 const char *fingerprint = luaL_checkstring (L, 1); |
106 const char *fingerprint = luaL_checkstring (L, 1); |
107 if (lua_objlen (L, 1) > 46) |
107 if (lua_rawlen (L, 1) > 46) |
108 string2fingerprint (fingerprint, buffer); |
108 string2fingerprint (fingerprint, buffer); |
109 luaL_argcheck (L, lua_isfunction (L, 2), 2, "function expected"); |
109 luaL_argcheck (L, lua_isfunction (L, 2), 2, "function expected"); |
110 } else |
110 } else |
111 luaL_argcheck (L, lua_isfunction (L, 1), 1, "function expected"); |
111 luaL_argcheck (L, lua_isfunction (L, 1), 1, "function expected"); |
112 |
112 |
222 int luaopen_lm_ssl (lua_State *L) |
222 int luaopen_lm_ssl (lua_State *L) |
223 { |
223 { |
224 luaL_newmetatable (L, "loudmouth.ssl"); |
224 luaL_newmetatable (L, "loudmouth.ssl"); |
225 lua_pushvalue (L, -1); |
225 lua_pushvalue (L, -1); |
226 lua_setfield (L, -2, "__index"); |
226 lua_setfield (L, -2, "__index"); |
227 luaL_register (L, NULL, reg_m_lm_ssl); |
227 luaL_setfuncs (L, reg_m_lm_ssl, 0); |
228 lua_pop (L, 1); |
228 lua_pop (L, 1); |
229 lua_newtable (L); // XXX we can specify here exact amount of fields |
229 lua_newtable (L); // XXX we can specify here exact amount of fields |
230 luaL_register (L, NULL, reg_f_lm_ssl); |
230 luaL_setfuncs (L, reg_f_lm_ssl, 0); |
231 return 1; |
231 return 1; |
232 } |
232 } |
233 |
233 |