lua.c
changeset 151 5d90caa7fb2c
parent 148 b222f4d111d9
child 152 0cf6c938ac03
equal deleted inserted replaced
150:c8514af9b449 151:5d90caa7fb2c
   194 	{ "yes",     1 },
   194 	{ "yes",     1 },
   195 	{ "no",      0 },
   195 	{ "no",      0 },
   196 	{ NULL,     -1 },
   196 	{ NULL,     -1 },
   197 };
   197 };
   198 
   198 
   199 /// main.yesno
   199 /// mcabber.yesno
   200 /// According to yes or no ansvers returns true or false.
   200 /// According to yes or no ansvers returns true or false.
   201 /// If ansver is not recognized, returns nil.
   201 /// If ansver is not recognized, returns nil.
   202 /// A: anything (string expected)
   202 /// A: anything (string expected)
   203 /// R: boolean or nil
   203 /// R: boolean or nil
   204 static int lua_main_yesno (lua_State *L)
   204 static int lua_main_yesno (lua_State *L)
   215 	else if (type != LUA_TBOOLEAN)
   215 	else if (type != LUA_TBOOLEAN)
   216 		lua_pushnil (L);
   216 		lua_pushnil (L);
   217 	return 1;
   217 	return 1;
   218 }
   218 }
   219 
   219 
   220 /// main.version
   220 /// mcabber.version
   221 /// Returns information about mcabber version
   221 /// Returns table with information about mcabber  version
   222 /// R: table
   222 /// R: table
   223 static int lua_main_version (lua_State *L)
   223 static int lua_main_version (lua_State *L)
   224 {
   224 {
   225 	lua_createtable (L, 0, 3);
   225 	lua_createtable (L, 0, 3);
   226 	lua_pushstring (L, mcabber_branch);
   226 	lua_pushstring (L, mcabber_branch);
   261 	{ "room",    ROSTER_TYPE_ROOM    },
   261 	{ "room",    ROSTER_TYPE_ROOM    },
   262 	{ "special", ROSTER_TYPE_SPECIAL },
   262 	{ "special", ROSTER_TYPE_SPECIAL },
   263 	{ NULL,      0                   },
   263 	{ NULL,      0                   },
   264 };
   264 };
   265 
   265 
   266 /// main.log
   266 /// mcabber.log
   267 /// Prints message to log.
   267 /// Prints message to log.
   268 /// Note: most likely you need notutf8 flag enabled.
   268 /// Note: most likely you need notutf8 flag enabled.
   269 /// A: log message type, message, message...
   269 /// A: log message type, message, message...
   270 static int lua_main_log (lua_State *L)
   270 static int lua_main_log (lua_State *L)
   271 {
   271 {
   285 	lua_pushstring (L, loc);
   285 	lua_pushstring (L, loc);
   286 	g_free (loc);
   286 	g_free (loc);
   287 	lua_settable (L, -3);
   287 	lua_settable (L, -3);
   288 }
   288 }
   289 
   289 
   290 /// main.option
   290 /// mcabber.option
   291 /// Sets or gets value of mcabber option.
   291 /// Sets or gets value of given mcabber config option.
   292 /// You can specify nil as a value to delete option.
   292 /// You can specify nil as a value to delete option.
   293 /// If you omit option name, it returns hash table of all options.
   293 /// If you omit option name, it returns hash table of all options.
   294 /// A: string (option name, optional), string (value, optional)
   294 /// A: string (option name, optional), string (value, optional)
   295 /// R: string (value, optional)
   295 /// R: string (value, optional)
   296 static int lua_main_option (lua_State *L)
   296 static int lua_main_option (lua_State *L)
   323 		settings_foreach (SETTINGS_TYPE_OPTION, (void (*)(char *key, char *val, void *ud)) lua_options_callback, L);
   323 		settings_foreach (SETTINGS_TYPE_OPTION, (void (*)(char *key, char *val, void *ud)) lua_options_callback, L);
   324 		return 1;
   324 		return 1;
   325 	}
   325 	}
   326 }
   326 }
   327 
   327 
   328 /// main.alias
   328 /// mcabber.alias
   329 /// Sets or gets alias.
   329 /// Sets or gets alias.
   330 /// You can specify nil as a command to delete alias.
   330 /// You can specify nil as a command to delete alias.
   331 /// If you omit alias name, it will return hash table of all aliases.
   331 /// If you omit alias name, it will return hash table of all aliases.
   332 /// A: string (alias name, optional), string (command, optional)
   332 /// A: string (alias name, optional), string (command, optional)
   333 /// R: string (command, optional)
   333 /// R: string (command, optional)
   364 		settings_foreach (SETTINGS_TYPE_ALIAS, (void (*)(char *key, char *val, void *ud)) lua_options_callback, L);
   364 		settings_foreach (SETTINGS_TYPE_ALIAS, (void (*)(char *key, char *val, void *ud)) lua_options_callback, L);
   365 		return 1;
   365 		return 1;
   366 	}
   366 	}
   367 }
   367 }
   368 
   368 
   369 /// main.bind
   369 /// mcabber.bind
   370 /// Sets or gets binding.
   370 /// Sets or gets binding.
   371 /// You can specify nil as a command to unbind key.
   371 /// You can specify nil as a command to unbind key.
   372 /// If you omit keycode, it will return hash table of all bindings.
   372 /// If you omit keycode, it will return hash table of all bindings.
   373 /// A: string (keycode, optional), string (command, optional)
   373 /// A: string (keycode, optional), string (command, optional)
   374 /// R: string (command, optional)
   374 /// R: string (command, optional)
   403 		settings_foreach (SETTINGS_TYPE_BINDING, (void (*)(char *key, char *val, void *ud)) lua_options_callback, L);
   403 		settings_foreach (SETTINGS_TYPE_BINDING, (void (*)(char *key, char *val, void *ud)) lua_options_callback, L);
   404 		return 1;
   404 		return 1;
   405 	}
   405 	}
   406 }
   406 }
   407 
   407 
   408 /// main.fileoption
   408 /// mcabber.fileoption
   409 /// Gets option, expanding it as filename.
   409 /// Gets option, expanding it as filename.
   410 /// A: string (option name)
   410 /// A: string (option name)
   411 /// R: string (expanded option value) or nil
   411 /// R: string (expanded option value) or nil
   412 static int lua_main_fileoption (lua_State *L)
   412 static int lua_main_fileoption (lua_State *L)
   413 {
   413 {
   419 		lua_pushnil (L);
   419 		lua_pushnil (L);
   420 	return 1;
   420 	return 1;
   421 }
   421 }
   422 
   422 
   423 #ifdef LLM_CONNECTION_ENABLE
   423 #ifdef LLM_CONNECTION_ENABLE
   424 /// main.connection
   424 /// mcabber.connection
   425 /// Returns lightuserdata of mcabber's loudmouth connection.
   425 /// Returns lightuserdata of mcabber's loudmouth connection.
   426 /// This can be very useful with lua-loudmouth, and not much otherwise.
   426 /// This can be very useful with lua-loudmouth, and not much otherwise.
   427 /// R: lightuserdata or nil
   427 /// R: lightuserdata or nil
   428 static int lua_main_connection (lua_State *L)
   428 static int lua_main_connection (lua_State *L)
   429 {
   429 {
   433 		lua_pushnil (L);
   433 		lua_pushnil (L);
   434 	return 1;
   434 	return 1;
   435 }
   435 }
   436 #endif
   436 #endif
   437 
   437 
   438 /// main.print_info
   438 /// mcabber.print_info
   439 /// Prints a system message to buddy's window.
   439 /// Prints a system message to buddy's window.
   440 /// A: string (jid), string (message)
   440 /// A: string (jid), string (message)
   441 static int lua_main_print_info (lua_State *L)
   441 static int lua_main_print_info (lua_State *L)
   442 {
   442 {
   443 	char *jid  = to_utf8 (luaL_checkstring (L, 1));
   443 	char *jid  = to_utf8 (luaL_checkstring (L, 1));
   448 	g_free (to);
   448 	g_free (to);
   449 	g_free (jid);
   449 	g_free (jid);
   450 	return 0;
   450 	return 0;
   451 }
   451 }
   452 
   452 
   453 /// main.beep
   453 /// mcabber.beep
   454 /// Beeps with system speaker.
   454 /// Beeps with system speaker.
   455 static int lua_main_beep (lua_State *L)
   455 static int lua_main_beep (lua_State *L)
   456 {
   456 {
   457 	scr_beep ();
   457 	scr_beep ();
   458 	return 0;
   458 	return 0;
   459 }
   459 }
   460 
   460 
   461 /// main.run
   461 /// mcabber.run
   462 /// Runs specified mcabber command.
   462 /// Executes given string as a mcabber  command.
       
   463 /// Note: You should omit '/' in the beginning.
   463 /// A: string
   464 /// A: string
   464 static int lua_main_run (lua_State *L)
   465 static int lua_main_run (lua_State *L)
   465 {
   466 {
   466 	process_command (luaL_checkstring (L, 1), TRUE);
   467 	process_command (luaL_checkstring (L, 1), TRUE);
   467 	return 0;
   468 	return 0;
   468 }
   469 }
   469 
   470 
   470 /// main.status
   471 /// mcabber.status
   471 /// Returns your current status.
   472 /// Returns your current status.
   472 /// R: string (status letter), string (status message)
   473 /// R: string (status letter), string (status message)
   473 static int lua_main_status (lua_State *L)
   474 static int lua_main_status (lua_State *L)
   474 {
   475 {
   475 	char *sm = from_utf8 (xmpp_getstatusmsg ());
   476 	char *sm = from_utf8 (xmpp_getstatusmsg ());
   487 	lua_pushstring (L, jid);
   488 	lua_pushstring (L, jid);
   488 	lua_settable (L, -3);
   489 	lua_settable (L, -3);
   489 	g_free (jid);
   490 	g_free (jid);
   490 }
   491 }
   491 
   492 
   492 /// main.roster
   493 /// mcabber.roster
   493 /// Returns array of jids of buddies in roster.
   494 /// Returns array of jids of buddies in roster.
   494 /// R: table
   495 /// R: table
   495 static int lua_main_roster (lua_State *L)
   496 static int lua_main_roster (lua_State *L)
   496 {
   497 {
   497 	lua_newtable (L);
   498 	lua_newtable (L);
   498 	foreach_buddy (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM, (void (*) (gpointer buddy, void *data)) lua_rosterlist_callback, L);
   499 	foreach_buddy (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM, (void (*) (gpointer buddy, void *data)) lua_rosterlist_callback, L);
   499 	return 1;
   500 	return 1;
   500 }
   501 }
   501 
   502 
   502 /// main.current_buddy
   503 /// mcabber.current_buddy
   503 /// Returns jid of current selected buddy or sets current buddy to buddy with specified jid.
   504 /// Returns jid of current selected buddy or sets current buddy to buddy with specified jid.
   504 /// A: string (optional)
   505 /// A: string (optional)
   505 /// R: string (optional)
   506 /// R: string (optional)
   506 static int lua_main_current_buddy (lua_State *L)
   507 static int lua_main_current_buddy (lua_State *L)
   507 {
   508 {
   518 		g_free (jid);
   519 		g_free (jid);
   519 		return 1;
   520 		return 1;
   520 	}
   521 	}
   521 }
   522 }
   522 
   523 
   523 /// main.full_jid
   524 /// mcabber.full_jid
   524 /// Returns full jid (with current resource) of specified buddy (or current, if not specified).
   525 /// Returns full jid (with current resource) of specified buddy (or current, if not specified).
   525 /// Note, that if there are no resources online, it will return just what it got.
   526 /// Note, that if there are no resources online, it will return just what it got.
   526 /// A: string (jid, optional)
   527 /// A: string (jid, optional)
   527 /// R: string (jid)
   528 /// R: string (jid)
   528 static int lua_main_full_jid (lua_State *L)
   529 static int lua_main_full_jid (lua_State *L)
   583 	lua_settable   (d->L, -3);
   584 	lua_settable   (d->L, -3);
   584 	lua_settable (d->L, -3);
   585 	lua_settable (d->L, -3);
   585 	g_free (resource);
   586 	g_free (resource);
   586 }
   587 }
   587 
   588 
   588 /// main.buddy_info
   589 /// mcabber.buddy_info
   589 /// Returns a hash table with information on specified buddy.
   590 /// Returns a hash table with information on specified buddy.
   590 /// Table contains fields type, name, onserver and resources (which points to resources table).
   591 /// Table contains fields type, name, onserver and resources (which points to resources table).
   591 /// A: string (jid)
   592 /// A: string (jid)
   592 /// R: table
   593 /// R: table
   593 static int lua_main_buddy_info (lua_State *L)
   594 static int lua_main_buddy_info (lua_State *L)
   631 
   632 
   632 // XMPP DISCO FEATURES
   633 // XMPP DISCO FEATURES
   633 
   634 
   634 GSList *lua_added_features = NULL;
   635 GSList *lua_added_features = NULL;
   635 
   636 
   636 /// main.add_feature
   637 /// mcabber.add_feature
   637 /// Adds xmlns to disco#info features list.
   638 /// Adds xmlns to disco#info features list.
   638 /// A: string (xmlns)
   639 /// A: string (xmlns)
   639 static int lua_main_add_feature (lua_State *L)
   640 static int lua_main_add_feature (lua_State *L)
   640 {
   641 {
   641 	char *xmlns = to_utf8 (luaL_checkstring (L, 1));
   642 	char *xmlns = to_utf8 (luaL_checkstring (L, 1));
   642 	xmpp_add_feature (xmlns);
   643 	xmpp_add_feature (xmlns);
   643 	lua_added_features = g_slist_prepend (lua_added_features, xmlns);
   644 	lua_added_features = g_slist_prepend (lua_added_features, xmlns);
   644 	return 0;
   645 	return 0;
   645 }
   646 }
   646 
   647 
   647 /// main.del_feature
   648 /// mcabber.del_feature
   648 /// Removes xmlns from disco#info features list.
   649 /// Removes xmlns from disco#info features list.
   649 /// A: stirng (xmlns)
   650 /// A: stirng (xmlns)
   650 static int lua_main_del_feature (lua_State *L)
   651 static int lua_main_del_feature (lua_State *L)
   651 {
   652 {
   652 	char   *xmlns = to_utf8 (luaL_checkstring (L, 1));
   653 	char   *xmlns = to_utf8 (luaL_checkstring (L, 1));
   711 		lua_events = g_slist_remove (lua_events, cb); // XXX
   712 		lua_events = g_slist_remove (lua_events, cb); // XXX
   712 		return FALSE;
   713 		return FALSE;
   713 	}
   714 	}
   714 }
   715 }
   715 
   716 
   716 /// main.event
   717 /// mcabber.event
   717 /// Creates new event. If called without arguments, returns event id list.
   718 /// Creates new event. If called without arguments, returns event id list.
   718 /// A: event function (optional), string (event id), string (description, optional), integer (expiration timeout, optional)
   719 /// A: event function (optional), string (event id), string (description, optional), integer (expiration timeout, optional)
   719 /// R: string (event id) or nothing (creation error) or table (list of event names)
   720 /// R: string (event id) or nothing (creation error) or table (list of event names)
   720 static int lua_main_event (lua_State *L)
   721 static int lua_main_event (lua_State *L)
   721 {
   722 {
   964 		scr_log_print (LPRINT_LOGNORM, "lua: Command execution error: %s", lua_tostring (cb->L, -1));
   965 		scr_log_print (LPRINT_LOGNORM, "lua: Command execution error: %s", lua_tostring (cb->L, -1));
   965 		lua_pop (cb->L, 1);
   966 		lua_pop (cb->L, 1);
   966 	}
   967 	}
   967 }
   968 }
   968 
   969 
   969 /// main.parse_args
   970 /// mcabber.parse_args
   970 /// Function to parse command argument string to command arguments table.
   971 /// Function to parse command argument string to command arguments table.
   971 /// A: string
   972 /// A: string
   972 /// R: table
   973 /// R: table
   973 static int lua_main_parse_args (lua_State *L)
   974 static int lua_main_parse_args (lua_State *L)
   974 {
   975 {
   975 	luaL_pushargs (L, luaL_checkstring (L, 1));
   976 	luaL_pushargs (L, luaL_checkstring (L, 1));
   976 	return 1;
   977 	return 1;
   977 }
   978 }
   978 
   979 
   979 /// main.add_category
   980 /// mcabber.add_category
   980 /// Adds completion category.
   981 /// Adds completion category.
   981 /// A: table (values are used as words for completion, optional), argument enum value (completion sorting order, optional)
   982 /// A: table (values are used as words for completion, optional), argument enum value (completion sorting order, optional)
   982 /// R: integer (category id, in fact completion type) or nil
   983 /// R: integer (category id, in fact completion type) or nil
   983 static int lua_main_add_category (lua_State *L)
   984 static int lua_main_add_category (lua_State *L)
   984 {
   985 {
  1011 		lua_pushnil ( L );
  1012 		lua_pushnil ( L );
  1012 
  1013 
  1013 	return 1;
  1014 	return 1;
  1014 }
  1015 }
  1015 
  1016 
  1016 /// main.del_category
  1017 /// mcabber.del_category
  1017 /// Removes completion category.
  1018 /// Removes completion category.
  1018 /// A: integer (category id)
  1019 /// A: integer (category id)
  1019 static int lua_main_del_category (lua_State *L)
  1020 static int lua_main_del_category (lua_State *L)
  1020 {
  1021 {
  1021 	guint cid = luaL_checkinteger (L, 1);
  1022 	guint cid = luaL_checkinteger (L, 1);
  1022 	compl_del_category (cid);
  1023 	compl_del_category (cid);
  1023 	lua_added_categories = g_slist_remove (lua_added_categories, (gpointer) ((gsize) cid));
  1024 	lua_added_categories = g_slist_remove (lua_added_categories, (gpointer) ((gsize) cid));
  1024 	return 0;
  1025 	return 0;
  1025 }
  1026 }
  1026 
  1027 
  1027 /// main.add_completion
  1028 /// mcabber.add_completion
  1028 /// Adds word to a completion list.
  1029 /// Adds word to a completion list.
  1029 /// A: integer (completion group id), string (word)
  1030 /// A: integer (completion group id), string (word)
  1030 static int lua_main_add_completion (lua_State *L)
  1031 static int lua_main_add_completion (lua_State *L)
  1031 {
  1032 {
  1032 	guint  cid  = luaL_checkinteger (L, 1);
  1033 	guint  cid  = luaL_checkinteger (L, 1);
  1034 	compl_add_category_word (cid, word);
  1035 	compl_add_category_word (cid, word);
  1035 	g_free (word);
  1036 	g_free (word);
  1036 	return 0;
  1037 	return 0;
  1037 }
  1038 }
  1038 
  1039 
  1039 /// main.del_completion
  1040 /// mcabber.del_completion
  1040 /// Removes word from a completion list.
  1041 /// Removes word from a completion list.
  1041 /// A: integer (completion group id), string (word)
  1042 /// A: integer (completion group id), string (word)
  1042 static int lua_main_del_completion (lua_State *L)
  1043 static int lua_main_del_completion (lua_State *L)
  1043 {
  1044 {
  1044 	guint  cid  = luaL_checkinteger (L, 1);
  1045 	guint  cid  = luaL_checkinteger (L, 1);
  1046 	compl_del_category_word (cid, word);
  1047 	compl_del_category_word (cid, word);
  1047 	g_free (word);
  1048 	g_free (word);
  1048 	return 0;
  1049 	return 0;
  1049 }
  1050 }
  1050 
  1051 
  1051 /// main.command
  1052 /// mcabber.command
  1052 /// Associates mcabber command name and lua function.
  1053 /// Associates mcabber  command name with given lua function.
  1053 /// As a completion you can also specify a string name (see completion type) instead of table, for non-builtin, you can just pass integer id.
  1054 /// As a completion you can also specify a string name (see completion type) instead of table.
       
  1055 /// For third-party completions you can just pass integer id.
  1054 /// Note, that for now there are no way to unregister completion group, so, resources can be exausted easily.
  1056 /// Note, that for now there are no way to unregister completion group, so, resources can be exausted easily.
  1055 /// Also note, that it ignores keys in a completion table.
  1057 /// Also note, that it ignores keys in a completion table.
  1056 /// A: string (command name), command function, boolean (parse args flag, optional), table (completions, optional)/completion type (or integer comletion group id, optional)
  1058 /// A: string (command name), command function, boolean (parse args flag, optional), table (completions, optional)/completion type (or integer comletion group id, optional)
  1057 /// R: userdata (command object)
  1059 /// R: userdata (command object)
  1058 static int lua_main_command (lua_State *L)
  1060 static int lua_main_command (lua_State *L)
  1204 	ret = lua_toboolean (cb->L, -1);
  1206 	ret = lua_toboolean (cb->L, -1);
  1205 	lua_pop (cb->L, 1);
  1207 	lua_pop (cb->L, 1);
  1206 	return ret;
  1208 	return ret;
  1207 }
  1209 }
  1208 
  1210 
  1209 /// main.timer
  1211 /// mcabber.timer
  1210 /// Creates new timer function, that will be called periodically.
  1212 /// Creates new timer function, that will be called periodically.
  1211 /// A: integer (interval, seconds), timer function
  1213 /// A: integer (interval, seconds), timer function
  1212 static int lua_main_timer (lua_State *L)
  1214 static int lua_main_timer (lua_State *L)
  1213 {
  1215 {
  1214 	int                   interval = luaL_checkinteger (L, 1);
  1216 	int                   interval = luaL_checkinteger (L, 1);
  1290 	}
  1292 	}
  1291 
  1293 
  1292 	return ret;
  1294 	return ret;
  1293 }
  1295 }
  1294 
  1296 
  1295 /// main.bgread
  1297 /// mcabber.bgread
  1296 /// Runs specified command and passes its output to a given function.
  1298 /// Runs specified command and passes its output to a given function.
  1297 /// A: string (command), background reading function
  1299 /// A: string (command), background reading function
  1298 static int lua_main_bgread (lua_State *L)
  1300 static int lua_main_bgread (lua_State *L)
  1299 {
  1301 {
  1300 	const char            *command = luaL_checkstring (L, 1);
  1302 	const char            *command = luaL_checkstring (L, 1);
  1420 	}
  1422 	}
  1421 
  1423 
  1422 	return ret;
  1424 	return ret;
  1423 }
  1425 }
  1424 
  1426 
  1425 /// main.hook_run
  1427 /// mcabber.hook_run
  1426 /// Runs handlers for given hook with supplied arguments.
  1428 /// Runs handlers for given hook with supplied arguments.
  1427 /// A: string (hook name), table (hook arguments)
  1429 /// A: string (hook name), table (hook arguments)
  1428 /// R: return enum field (hook handler result)
  1430 /// R: return enum field (hook handler result)
  1429 static int lua_main_hook_run ( lua_State *L )
  1431 static int lua_main_hook_run ( lua_State *L )
  1430 {
  1432 {
  1469 	luaL_free ( L, args );
  1471 	luaL_free ( L, args );
  1470 	luaL_pushenum ( L, ret, lua_hook_handler_result );
  1472 	luaL_pushenum ( L, ret, lua_hook_handler_result );
  1471 	return 1;
  1473 	return 1;
  1472 }
  1474 }
  1473 
  1475 
  1474 /// main.hook
  1476 /// mcabber.hook
  1475 /// Installs hook handler, returns an object, that you need to keep until
  1477 /// Installs hook handler, returns an object, that you need to keep until
  1476 /// hook handling is no more needed.
  1478 /// hook handling is no more needed.
  1477 /// A: string (hook name), hook function, integer (priority, optional)
  1479 /// A: string (hook name), hook function, integer (priority, optional)
  1478 /// R: userdata (hook object)
  1480 /// R: userdata (hook object)
  1479 static int lua_main_hook (lua_State *L)
  1481 static int lua_main_hook (lua_State *L)
  1593 		lua_pop ( L, 2 );
  1595 		lua_pop ( L, 2 );
  1594 		return result;
  1596 		return result;
  1595 	}
  1597 	}
  1596 }
  1598 }
  1597 
  1599 
  1598 /// main.add_guard
  1600 /// mcabber.add_guard
  1599 /// Installs option guard for given option.
  1601 /// Installs option guard for given option.
  1600 /// A: string ( option name ), guard function
  1602 /// A: string ( option name ), guard function
  1601 /// R: boolean ( success )
  1603 /// R: boolean ( success )
  1602 static int lua_main_add_guard ( lua_State *L )
  1604 static int lua_main_add_guard ( lua_State *L )
  1603 {
  1605 {
  1614 		lua_pushboolean ( L, 0 );
  1616 		lua_pushboolean ( L, 0 );
  1615 
  1617 
  1616 	return 1;
  1618 	return 1;
  1617 }
  1619 }
  1618 
  1620 
  1619 /// main.del_guard
  1621 /// mcabber.del_guard
  1620 /// Removes option guard from given option.
  1622 /// Removes option guard from given option.
  1621 /// By default, lua will refuse to remove guards, not installed
  1623 /// By default, lua will refuse to remove guards, not installed
  1622 /// by lua. Still, you can force guard removal.
  1624 /// by lua. Still, you can force guard removal.
  1623 /// A: string ( option name ), boolean ( force removal )
  1625 /// A: string ( option name ), boolean ( force removal )
  1624 /// R: boolean ( success )
  1626 /// R: boolean ( success )
  1777 {
  1779 {
  1778 	luaL_openlibs (lua);
  1780 	luaL_openlibs (lua);
  1779 
  1781 
  1780 	lua_newtable(lua);
  1782 	lua_newtable(lua);
  1781 	luaL_setfuncs (lua, lua_reg_main, 0);
  1783 	luaL_setfuncs (lua, lua_reg_main, 0);
       
  1784 #ifdef COMPAT_0_0_4
       
  1785 	lua_pushvalue (lua, -1);
  1782 	lua_setglobal (lua, "main");
  1786 	lua_setglobal (lua, "main");
       
  1787 #endif
       
  1788 	lua_setglobal (lua, "mcabber");
  1783 	lua_register (lua, "dopath", lua_global_dopath);
  1789 	lua_register (lua, "dopath", lua_global_dopath);
  1784 	lua_register (lua, "print",  lua_global_print );
  1790 	lua_register (lua, "print",  lua_global_print );
  1785 
  1791 
  1786 	{
  1792 	{
  1787 #ifdef MCABBER_API_HAVE_COMPL_FLAGS
  1793 #ifdef MCABBER_API_HAVE_COMPL_FLAGS