main.c
changeset 78 1253cacc0f21
parent 76 11bd9d10ee3b
child 80 c8271a839357
equal deleted inserted replaced
77:8a7f7829f4df 78:1253cacc0f21
   337 	} else
   337 	} else
   338 		lua_pushnil (L);
   338 		lua_pushnil (L);
   339 	return 1;
   339 	return 1;
   340 }
   340 }
   341 
   341 
       
   342 #ifdef LLM_CONNECTION_ENABLE
   342 /// main.connection
   343 /// main.connection
   343 /// Returns lightuserdata of mcabber's loudmouth connection.
   344 /// Returns lightuserdata of mcabber's loudmouth connection.
   344 /// This can be very useful with lua-loudmouth, and not much otherwise.
   345 /// This can be very useful with lua-loudmouth, and not much otherwise.
   345 /// R: lightuserdata
   346 /// R: lightuserdata
   346 static int lua_main_connection (lua_State *L)
   347 static int lua_main_connection (lua_State *L)
   347 {
   348 {
   348 	lua_pushlightuserdata (L, lconnection);
   349 	lua_pushlightuserdata (L, lconnection);
   349 	return 1;
   350 	return 1;
   350 }
   351 }
       
   352 #endif
   351 
   353 
   352 /// main.print_info
   354 /// main.print_info
   353 /// Prints a system message to buddy's window.
   355 /// Prints a system message to buddy's window.
   354 /// A: string (jid), string (message)
   356 /// A: string (jid), string (message)
   355 static int lua_main_print_info (lua_State *L)
   357 static int lua_main_print_info (lua_State *L)
  1072 
  1074 
  1073 	if (condition | G_IO_IN) { // data
  1075 	if (condition | G_IO_IN) { // data
  1074 		while (TRUE) {
  1076 		while (TRUE) {
  1075 			gsize read = 0;
  1077 			gsize read = 0;
  1076 			g_io_channel_read_chars (source, lua_bgread_buffer, MLUA_BGREAD_BUFFER, &read, NULL);
  1078 			g_io_channel_read_chars (source, lua_bgread_buffer, MLUA_BGREAD_BUFFER, &read, NULL);
  1077 			if (!read) // exausted
  1079 			if (!read) // exhausted
  1078 				break;
  1080 				break;
  1079 
  1081 
  1080 			lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference);
  1082 			lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference);
  1081 			lua_pushlstring (cb->L, lua_bgread_buffer, read);
  1083 			lua_pushlstring (cb->L, lua_bgread_buffer, read);
  1082 			if (lua_pcall (cb->L, 1, 1, 0)) {
  1084 			if (lua_pcall (cb->L, 1, 1, 0)) {