Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/scripting/script_server.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
script_server.c
Go to the documentation of this file.
1/*****************************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12*****************************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdarg.h>
19#include <stdlib.h>
20#include <time.h>
21
22/* dependencies/lua */
23#include "lua.h"
24#include "lualib.h"
25
26/* dependencies/tolua */
27#include "tolua.h"
28
29/* utility */
30#include "astring.h"
31#include "log.h"
32#include "mem.h"
33#include "registry.h"
34
35/* common/scriptcore */
36#include "api_game_specenum.h"
37#include "luascript.h"
38#include "luascript_signal.h"
39#include "luascript_func.h"
40#include "tolua_common_a_gen.h"
41#include "tolua_common_z_gen.h"
42#include "tolua_game_gen.h"
43#include "tolua_signal_gen.h"
44
45/* server */
46#include "console.h"
47#include "stdinhand.h"
48
49/* server/scripting */
50#include <tolua_server_gen.h> /* <> so looked from the build directory first. */
51
52#include "script_server.h"
53
54/***********************************************************************/
57 static struct fc_lua *fcl_main = NULL;
58 static struct fc_lua *fcl_unsafe = NULL;
59
60/***********************************************************************/
63 static char *script_server_code = NULL;
64
65static void script_server_vars_init(void);
66static void script_server_vars_free(void);
67static void script_server_vars_load(struct section_file *file);
68static void script_server_vars_save(struct section_file *file);
69static void script_server_code_init(void);
70static void script_server_code_free(void);
71static void script_server_code_load(struct section_file *file);
72static void script_server_code_save(struct section_file *file);
73
74static void script_server_signals_create(void);
75static void script_server_functions_define(void);
76
77static void script_server_cmd_reply(struct fc_lua *fcl, enum log_level level,
78 const char *format, ...)
79 fc__attribute((__format__ (__printf__, 3, 4)));
80
81/***********************************************************************/
85static bool script_server_do_string_shared(struct fc_lua *fcl,
86 struct connection *caller,
87 const char *str)
88{
89 int status;
90 struct connection *save_caller;
91 luascript_log_func_t save_output_fct;
92
93 /* Set a log callback function which allows to send the results of the
94 * command to the clients. */
95 save_caller = fcl->caller;
96 save_output_fct = fcl->output_fct;
97 fcl->output_fct = script_server_cmd_reply;
98 fcl->caller = caller;
99
100 status = luascript_do_string(fcl, str, "cmd");
101
102 /* Reset the changes. */
103 fcl->caller = save_caller;
104 fcl->output_fct = save_output_fct;
105
106 return (status == 0);
107}
108
109/***********************************************************************/
112 bool script_server_do_string(struct connection *caller, const char *str)
113{
114 return script_server_do_string_shared(fcl_main, caller, str);
115}
116
117/***********************************************************************/
120 bool script_server_unsafe_do_string(struct connection *caller,
121 const char *str)
122{
123 return script_server_do_string_shared(fcl_unsafe, caller, str);
124}
125
126/***********************************************************************/
129 bool script_server_load_file(const char *filename, char **buf)
130{
131 FILE *ffile;
132 struct stat stats;
133 char *buffer;
134
135 fc_stat(filename, &stats);
136 ffile = fc_fopen(filename, "r");
137
138 if (ffile != NULL) {
139 int len;
140
141 buffer = fc_malloc(stats.st_size + 1);
142
143 len = fread(buffer, 1, stats.st_size, ffile);
144
145 if (len == stats.st_size) {
146 buffer[len] = '\0';
147
148 *buf = buffer;
149 }
150 fclose(ffile);
151 }
152
153 return 1;
154}
155
156/***********************************************************************/
160 static bool script_server_do_file_shared(struct fc_lua *fcl,
161 struct connection *caller,
162 const char *filename)
163{
164 int status = 1;
165 struct connection *save_caller;
166 luascript_log_func_t save_output_fct;
167
168 /* Set a log callback function which allows to send the results of the
169 * command to the clients. */
170 save_caller = fcl->caller;
171 save_output_fct = fcl->output_fct;
172 fcl->output_fct = script_server_cmd_reply;
173 fcl->caller = caller;
174
175 status = luascript_do_file(fcl, filename);
176
177 /* Reset the changes. */
178 fcl->caller = save_caller;
179 fcl->output_fct = save_output_fct;
180
181 return (status == 0);
182}
183
184/***********************************************************************/
188 bool script_server_do_file(struct connection *caller, const char *filename)
189{
190 return script_server_do_file_shared(fcl_main, caller, filename);
191}
192
193/***********************************************************************/
196 bool script_server_unsafe_do_file(struct connection *caller,
197 const char *filename)
198{
199 return script_server_do_file_shared(fcl_unsafe, caller, filename);
200}
201
202/***********************************************************************/
207 void script_server_remove_exported_object(void *object)
208{
209 luascript_remove_exported_object(fcl_main, object);
210 luascript_remove_exported_object(fcl_unsafe, object);
211}
212
213/***********************************************************************/
216 static void script_server_vars_init(void)
217{
218 /* nothing */
219}
220
221/***********************************************************************/
224 static void script_server_vars_free(void)
225{
226 /* nothing */
227}
228
229/***********************************************************************/
232 static void script_server_vars_load(struct section_file *file)
233{
234 luascript_vars_load(fcl_main, file, "script.vars");
235}
236
237/***********************************************************************/
240 static void script_server_vars_save(struct section_file *file)
241{
242 luascript_vars_save(fcl_main, file, "script.vars");
243}
244
245/***********************************************************************/
248 static void script_server_code_init(void)
249{
250 script_server_code = NULL;
251}
252
253/***********************************************************************/
256 static void script_server_code_free(void)
257{
258 if (script_server_code) {
259 free(script_server_code);
260 script_server_code = NULL;
261 }
262}
263
264/***********************************************************************/
267 static void script_server_code_load(struct section_file *file)
268{
269 if (!script_server_code) {
270 const char *code;
271 const char *section = "script.code";
272
273 code = secfile_lookup_str_default(file, "", "%s", section);
274 script_server_code = fc_strdup(code);
275 luascript_do_string(fcl_main, script_server_code, section);
276 }
277}
278
279/***********************************************************************/
282 static void script_server_code_save(struct section_file *file)
283{
284 if (script_server_code) {
285 secfile_insert_str_noescape(file, script_server_code, "script.code");
286 }
287}
288
289/***********************************************************************/
292 bool script_server_init(void)
293{
294 if (fcl_main != NULL) {
295 fc_assert_ret_val(fcl_main->state != NULL, FALSE);
296
297 return TRUE;
298 }
299
300 fcl_main = luascript_new(NULL, TRUE);
301 if (fcl_main == NULL) {
302 luascript_destroy(fcl_main);
303 fcl_main = NULL;
304
305 return FALSE;
306 }
307
308 tolua_common_a_open(fcl_main->state);
309 api_specenum_open(fcl_main->state);
310 tolua_game_open(fcl_main->state);
311 tolua_signal_open(fcl_main->state);
312
313#ifdef MESON_BUILD
314 /* Tolua adds 'tolua_' prefix to _open() function names,
315 * and we can't pass it a basename where the original
316 * 'tolua_' has been stripped when generating from meson. */
317 tolua_tolua_server_open(fcl_main->state);
318#else /* MESON_BUILD */
319 tolua_server_open(fcl_main->state);
320#endif /* MESON_BUILD */
321
322 tolua_common_z_open(fcl_main->state);
323
324 script_server_code_init();
325 script_server_vars_init();
326
327 luascript_signal_init(fcl_main);
328 script_server_signals_create();
329
330 luascript_func_init(fcl_main);
331 script_server_functions_define();
332
333 /* Add the unsafe instance. */
334 fcl_unsafe = luascript_new(NULL, FALSE);
335 if (fcl_unsafe == NULL) {
336 luascript_destroy(fcl_unsafe);
337 fcl_unsafe = NULL;
338
339 return FALSE;
340 }
341
342 tolua_common_a_open(fcl_unsafe->state);
343 api_specenum_open(fcl_unsafe->state);
344 tolua_game_open(fcl_unsafe->state);
345
346#ifdef MESON_BUILD
347 /* Tolua adds 'tolua_' prefix to _open() function names,
348 * and we can't pass it a basename where the original
349 * 'tolua_' has been stripped when generating from meson. */
350 tolua_tolua_server_open(fcl_unsafe->state);
351#else /* MESON_BUILD */
352 tolua_server_open(fcl_unsafe->state);
353#endif /* MESON_BUILD */
354
355 tolua_common_z_open(fcl_unsafe->state);
356
357 luascript_signal_init(fcl_unsafe);
358 luascript_func_init(fcl_unsafe);
359
360 return TRUE;
361}
362
363/***********************************************************************/
366 void script_server_free(void)
367{
368 if (fcl_main != NULL) {
369 script_server_code_free();
370 script_server_vars_free();
371
372 /* luascript_signal_free() is called by luascript_destroy(). */
373 luascript_destroy(fcl_main);
374 fcl_main = NULL;
375 }
376
377 if (fcl_unsafe != NULL) {
378 /* luascript_signal_free() is called by luascript_destroy(). */
379 luascript_destroy(fcl_unsafe);
380 fcl_unsafe = NULL;
381 }
382}
383
384/***********************************************************************/
387 void script_server_state_load(struct section_file *file)
388{
389 script_server_code_load(file);
390
391 /* Variables must be loaded after code is loaded and executed,
392 * so we restore their saved state properly */
393 script_server_vars_load(file);
394}
395
396/***********************************************************************/
399 void script_server_state_save(struct section_file *file)
400{
401 script_server_code_save(file);
402 script_server_vars_save(file);
403}
404
405/***********************************************************************/
408 void script_server_signal_emit(const char *signal_name, ...)
409{
410 va_list args;
411
412 va_start(args, signal_name);
413 luascript_signal_emit_valist(fcl_main, signal_name, args);
414 va_end(args);
415}
416
417/***********************************************************************/
420 static void script_server_signals_create(void)
421{
422 signal_deprecator *depr;
423
424 luascript_signal_create(fcl_main, "turn_begin", 2,
425 API_TYPE_INT, API_TYPE_INT);
426
427 /* Deprecated form of the 'turn_begin' signal that counts real turns
428 * starting from 0. */
429 depr = luascript_signal_create(fcl_main, "turn_started", 2,
430 API_TYPE_INT, API_TYPE_INT);
431 deprecate_signal(depr, "turn_started", "turn_begin", "3.0");
432
433 luascript_signal_create(fcl_main, "player_phase_begin", 2,
434 API_TYPE_PLAYER, API_TYPE_BOOL);
435 luascript_signal_create(fcl_main, "player_alive_phase_end", 1,
436 API_TYPE_PLAYER);
437 luascript_signal_create(fcl_main, "player_phase_end", 1,
438 API_TYPE_PLAYER);
439
440 luascript_signal_create(fcl_main, "unit_moved", 3,
441 API_TYPE_UNIT, API_TYPE_TILE, API_TYPE_TILE);
442
443 /* Includes all newly-built cities. */
444 luascript_signal_create(fcl_main, "city_built", 1,
445 API_TYPE_CITY);
446
447 luascript_signal_create(fcl_main, "city_size_change", 3,
448 API_TYPE_CITY, API_TYPE_INT, API_TYPE_STRING);
449
450 /* Deprecated form of the 'city_size_change' signal for the case of growth. */
451 depr = luascript_signal_create(fcl_main, "city_growth", 2,
452 API_TYPE_CITY, API_TYPE_INT);
453 deprecate_signal(depr, "city_growth", "city_size_change", "2.6");
454
455 /* Only includes units built in cities, for now. */
456 luascript_signal_create(fcl_main, "unit_built", 2,
457 API_TYPE_UNIT, API_TYPE_CITY);
458 luascript_signal_create(fcl_main, "building_built", 2,
459 API_TYPE_BUILDING_TYPE, API_TYPE_CITY);
460
461 /* These can happen for various reasons; the third argument gives the
462 * reason (a simple string identifier). Example identifiers:
463 * "pop_cost", "need_tech", "need_building", "need_special",
464 * "need_terrain", "need_government", "need_nation", "never",
465 * "unavailable". */
466 luascript_signal_create(fcl_main, "unit_cant_be_built", 3,
467 API_TYPE_UNIT_TYPE, API_TYPE_CITY, API_TYPE_STRING);
468 luascript_signal_create(fcl_main, "building_cant_be_built", 3,
469 API_TYPE_BUILDING_TYPE, API_TYPE_CITY,
470 API_TYPE_STRING);
471
472 /* Third argument gives a reason; "landlocked", "cant_maintain", "obsolete",
473 * "sold", "disaster", "sabotaged", "razed", "city_destroyed",
474 * "conquered" (applicable for small wonders only)
475 * Fourth argument gives unit that caused that, applicable for "sabotaged"
476 */
477 luascript_signal_create(fcl_main, "building_lost", 4,
478 API_TYPE_CITY, API_TYPE_BUILDING_TYPE,
479 API_TYPE_STRING, API_TYPE_UNIT);
480
481 /* The third argument contains the source: "researched", "traded",
482 * "stolen", "hut". */
483 luascript_signal_create(fcl_main, "tech_researched", 3,
484 API_TYPE_TECH_TYPE, API_TYPE_PLAYER,
485 API_TYPE_STRING);
486
487 /* First player is city owner, second is enemy. */
488 luascript_signal_create(fcl_main, "city_destroyed", 3,
489 API_TYPE_CITY, API_TYPE_PLAYER, API_TYPE_PLAYER);
490
491 /* First player is former owner, second new one. */
492 luascript_signal_create(fcl_main, "city_transferred", 4,
493 API_TYPE_CITY, API_TYPE_PLAYER, API_TYPE_PLAYER,
494 API_TYPE_STRING);
495
496 /* Deprecated form of the 'city_transferred' signal for the case of
497 * conquest. */
498 depr = luascript_signal_create(fcl_main, "city_lost", 3,
499 API_TYPE_CITY, API_TYPE_PLAYER, API_TYPE_PLAYER);
500 deprecate_signal(depr, "city_lost", "city_transferred", "2.6");
501
502 luascript_signal_create(fcl_main, "hut_enter", 2,
503 API_TYPE_UNIT, API_TYPE_STRING);
504 luascript_signal_create(fcl_main, "hut_frighten", 2,
505 API_TYPE_UNIT, API_TYPE_STRING);
506
507 luascript_signal_create(fcl_main, "unit_lost", 3,
508 API_TYPE_UNIT, API_TYPE_PLAYER, API_TYPE_STRING);
509
510 luascript_signal_create(fcl_main, "disaster_occurred", 3,
511 API_TYPE_DISASTER, API_TYPE_CITY, API_TYPE_BOOL);
512
513 luascript_signal_create(fcl_main, "nuke_exploded", 2, API_TYPE_TILE,
514 API_TYPE_PLAYER);
515
516 /* Deprecated form of the 'disaster_occurred' signal without 'had_internal_effect'
517 * support. */
518 depr = luascript_signal_create(fcl_main, "disaster", 2,
519 API_TYPE_DISASTER, API_TYPE_CITY);
520 deprecate_signal(depr, "disaster", "disaster_occurred", "2.6");
521
522 luascript_signal_create(fcl_main, "achievement_gained", 3,
523 API_TYPE_ACHIEVEMENT, API_TYPE_PLAYER,
524 API_TYPE_BOOL);
525
526 luascript_signal_create(fcl_main, "map_generated", 0);
527
528 luascript_signal_create(fcl_main, "pulse", 0);
529
530 luascript_signal_create(fcl_main, "action_started_unit_unit", 3,
531 API_TYPE_ACTION,
532 API_TYPE_UNIT, API_TYPE_UNIT);
533
534 luascript_signal_create(fcl_main, "action_finished_unit_unit", 4,
535 API_TYPE_ACTION, API_TYPE_BOOL,
536 API_TYPE_UNIT, API_TYPE_UNIT);
537
538 luascript_signal_create(fcl_main, "action_started_unit_units", 3,
539 API_TYPE_ACTION,
540 API_TYPE_UNIT, API_TYPE_TILE);
541
542 luascript_signal_create(fcl_main, "action_finished_unit_units", 4,
543 API_TYPE_ACTION, API_TYPE_BOOL,
544 API_TYPE_UNIT, API_TYPE_TILE);
545
546 luascript_signal_create(fcl_main, "action_started_unit_city", 3,
547 API_TYPE_ACTION,
548 API_TYPE_UNIT, API_TYPE_CITY);
549
550 luascript_signal_create(fcl_main, "action_finished_unit_city", 4,
551 API_TYPE_ACTION, API_TYPE_BOOL,
552 API_TYPE_UNIT, API_TYPE_CITY);
553
554 luascript_signal_create(fcl_main, "action_started_unit_tile", 3,
555 API_TYPE_ACTION,
556 API_TYPE_UNIT, API_TYPE_TILE);
557
558 luascript_signal_create(fcl_main, "action_finished_unit_tile", 4,
559 API_TYPE_ACTION, API_TYPE_BOOL,
560 API_TYPE_UNIT, API_TYPE_TILE);
561
562 luascript_signal_create(fcl_main, "action_started_unit_extras", 3,
563 API_TYPE_ACTION,
564 API_TYPE_UNIT, API_TYPE_TILE);
565
566 luascript_signal_create(fcl_main, "action_finished_unit_extras", 4,
567 API_TYPE_ACTION, API_TYPE_BOOL,
568 API_TYPE_UNIT, API_TYPE_TILE);
569
570 luascript_signal_create(fcl_main, "action_started_unit_self", 2,
571 API_TYPE_ACTION,
572 API_TYPE_UNIT);
573
574 luascript_signal_create(fcl_main, "action_finished_unit_self", 3,
575 API_TYPE_ACTION, API_TYPE_BOOL,
576 API_TYPE_UNIT);
577}
578
579/***********************************************************************/
586 static void script_server_functions_define(void)
587{
588 luascript_func_add(fcl_main, "respawn_callback", FALSE, 1, 0,
589 API_TYPE_PLAYER);
590}
591
592/***********************************************************************/
595 bool script_server_call(const char *func_name, ...)
596{
597 bool success;
598
599 va_list args;
600 va_start(args, func_name);
601 success = luascript_func_call_valist(fcl_main, func_name, args);
602 va_end(args);
603
604 return success;
605}
606
607/***********************************************************************/
610 static void script_server_cmd_reply(struct fc_lua *fcl, enum log_level level,
611 const char *format, ...)
612{
613 va_list args;
614 enum rfc_status rfc_status = C_OK;
615 char buf[1024];
616
617 va_start(args, format);
618 fc_vsnprintf(buf, sizeof(buf), format, args);
619 va_end(args);
620
621 switch (level) {
622 case LOG_FATAL:
623 /* Special case - will quit the server. */
624 log_fatal("%s", buf);
625 break;
626 case LOG_ERROR:
627 case LOG_WARN:
628 rfc_status = C_WARNING;
629 break;
630 case LOG_NORMAL:
631 rfc_status = C_COMMENT;
632 break;
633 case LOG_VERBOSE:
634 rfc_status = C_LOG_BASE;
635 break;
636 case LOG_DEBUG:
637 rfc_status = C_DEBUG;
638 break;
639 }
640
641 cmd_reply(CMD_LUA, fcl->caller, rfc_status, "%s", buf);
642}
stats
struct @124::my_agent::@125 stats
api_specenum_open
int api_specenum_open(lua_State *L)
Definition api_game_specenum.c:98
api_game_specenum.h
str
#define str
Definition astring.c:76
astring.h
CMD_LUA
@ CMD_LUA
Definition commands.h:93
console.h
rfc_status
rfc_status
Definition console.h:35
C_DEBUG
@ C_DEBUG
Definition console.h:39
C_OK
@ C_OK
Definition console.h:41
C_LOG_BASE
@ C_LOG_BASE
Definition console.h:40
C_COMMENT
@ C_COMMENT
Definition console.h:37
C_WARNING
@ C_WARNING
Definition console.h:50
log.h
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
log_fatal
#define log_fatal(message,...)
Definition log.h:100
log_level
log_level
Definition log.h:28
LOG_ERROR
@ LOG_ERROR
Definition log.h:30
LOG_DEBUG
@ LOG_DEBUG
Definition log.h:34
LOG_NORMAL
@ LOG_NORMAL
Definition log.h:32
LOG_FATAL
@ LOG_FATAL
Definition log.h:29
LOG_VERBOSE
@ LOG_VERBOSE
Definition log.h:33
LOG_WARN
@ LOG_WARN
Definition log.h:31
luascript_remove_exported_object
void luascript_remove_exported_object(struct fc_lua *fcl, void *object)
Definition luascript.c:700
luascript_do_string
int luascript_do_string(struct fc_lua *fcl, const char *str, const char *name)
Definition luascript.c:617
luascript_do_file
int luascript_do_file(struct fc_lua *fcl, const char *filename)
Definition luascript.c:637
luascript_vars_load
void luascript_vars_load(struct fc_lua *fcl, struct section_file *file, const char *section)
Definition luascript.c:763
luascript_vars_save
void luascript_vars_save(struct fc_lua *fcl, struct section_file *file, const char *section)
Definition luascript.c:737
luascript_new
struct fc_lua * luascript_new(luascript_log_func_t output_fct, bool secured_environment)
Definition luascript.c:332
luascript_destroy
void luascript_destroy(struct fc_lua *fcl)
Definition luascript.c:386
luascript.h
luascript_log_func_t
void(* luascript_log_func_t)(struct fc_lua *fcl, enum log_level level, const char *format,...) fc__attribute((__format__(__printf__
Definition luascript.h:39
luascript_func_call_valist
bool luascript_func_call_valist(struct fc_lua *fcl, const char *func_name, va_list args)
Definition luascript_func.c:220
luascript_func_init
void luascript_func_init(struct fc_lua *fcl)
Definition luascript_func.c:203
luascript_func_add
void luascript_func_add(struct fc_lua *fcl, const char *func_name, bool required, int nargs, int nreturns,...)
Definition luascript_func.c:178
luascript_func.h
luascript_signal_init
void luascript_signal_init(struct fc_lua *fcl)
Definition luascript_signal.c:376
luascript_signal_emit_valist
void luascript_signal_emit_valist(struct fc_lua *fcl, const char *signal_name, va_list args)
Definition luascript_signal.c:165
deprecate_signal
void deprecate_signal(signal_deprecator *deprecator, char *signal_name, char *replacement, char *deprecated_since)
Definition luascript_signal.c:272
luascript_signal_create
signal_deprecator * luascript_signal_create(struct fc_lua *fcl, const char *signal_name, int nargs,...)
Definition luascript_signal.c:251
luascript_signal.h
signal_deprecator
char * signal_deprecator
Definition luascript_signal.h:25
mem.h
fc_strdup
#define fc_strdup(str)
Definition mem.h:43
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
len
int len
Definition packhand.c:125
registry.h
secfile_lookup_str_default
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
Definition registry_ini.c:2142
secfile_insert_str_noescape
#define secfile_insert_str_noescape(secfile, string, path,...)
Definition registry_ini.h:173
script_server_do_file_shared
static bool script_server_do_file_shared(struct fc_lua *fcl, struct connection *caller, const char *filename)
Definition script_server.c:160
script_server_unsafe_do_string
bool script_server_unsafe_do_string(struct connection *caller, const char *str)
Definition script_server.c:120
script_server_code
static char * script_server_code
Definition script_server.c:63
script_server_vars_free
static void script_server_vars_free(void)
Definition script_server.c:224
script_server_do_string_shared
static void static bool script_server_do_string_shared(struct fc_lua *fcl, struct connection *caller, const char *str)
Definition script_server.c:85
script_server_signal_emit
void script_server_signal_emit(const char *signal_name,...)
Definition script_server.c:408
script_server_do_string
bool script_server_do_string(struct connection *caller, const char *str)
Definition script_server.c:112
script_server_vars_load
static void script_server_vars_load(struct section_file *file)
Definition script_server.c:232
fcl_main
static struct fc_lua * fcl_main
Definition script_server.c:57
script_server_init
bool script_server_init(void)
Definition script_server.c:292
script_server_vars_init
static void script_server_vars_init(void)
Definition script_server.c:216
script_server_call
bool script_server_call(const char *func_name,...)
Definition script_server.c:595
script_server_code_save
static void script_server_code_save(struct section_file *file)
Definition script_server.c:282
script_server_code_init
static void script_server_code_init(void)
Definition script_server.c:248
script_server_cmd_reply
static void script_server_cmd_reply(struct fc_lua *fcl, enum log_level level, const char *format,...) fc__attribute((__format__(__printf__
Definition script_server.c:610
script_server_state_save
void script_server_state_save(struct section_file *file)
Definition script_server.c:399
script_server_vars_save
static void script_server_vars_save(struct section_file *file)
Definition script_server.c:240
script_server_code_free
static void script_server_code_free(void)
Definition script_server.c:256
script_server_state_load
void script_server_state_load(struct section_file *file)
Definition script_server.c:387
script_server_remove_exported_object
void script_server_remove_exported_object(void *object)
Definition script_server.c:207
fcl_unsafe
static struct fc_lua * fcl_unsafe
Definition script_server.c:58
script_server_functions_define
static void script_server_functions_define(void)
Definition script_server.c:586
script_server_code_load
static void script_server_code_load(struct section_file *file)
Definition script_server.c:267
script_server_unsafe_do_file
bool script_server_unsafe_do_file(struct connection *caller, const char *filename)
Definition script_server.c:196
script_server_signals_create
static void script_server_signals_create(void)
Definition script_server.c:420
script_server_load_file
bool script_server_load_file(const char *filename, char **buf)
Definition script_server.c:129
script_server_free
void script_server_free(void)
Definition script_server.c:366
script_server_do_file
bool script_server_do_file(struct connection *caller, const char *filename)
Definition script_server.c:188
script_server.h
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
cmd_reply
void cmd_reply(enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *format,...)
Definition stdinhand.c:418
stdinhand.h
connection
Definition connection.h:141
connection::status
enum auth_status status
Definition connection.h:222
fc_lua
Definition luascript.h:44
fc_lua::caller
struct connection * caller
Definition luascript.h:49
fc_lua::output_fct
luascript_log_func_t output_fct
Definition luascript.h:47
fc_lua::state
lua_State * state
Definition luascript.h:45
section_file
Definition section_file.h:36
section
Definition section_file.h:28
fc_vsnprintf
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:896
fc_fopen
FILE * fc_fopen(const char *filename, const char *opentype)
Definition support.c:506
fc_stat
int fc_stat(const char *filename, struct stat *buf)
Definition support.c:575
fc__attribute
#define fc__attribute(x)
Definition support.h:89
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tolua_common_a_open
TOLUA_API int tolua_common_a_open(lua_State *tolua_S)
Definition tolua_common_a_gen.c:717
tolua_common_a_gen.h
tolua_common_z_open
TOLUA_API int tolua_common_z_open(lua_State *tolua_S)
Definition tolua_common_z_gen.c:141
tolua_common_z_gen.h
tolua_game_open
TOLUA_API int tolua_game_open(lua_State *tolua_S)
Definition tolua_game_gen.c:5144
tolua_game_gen.h
tolua_server_open
TOLUA_API int tolua_server_open(lua_State *tolua_S)
Definition tolua_server_gen.c:2448
tolua_server_gen.h
tolua_signal_open
TOLUA_API int tolua_signal_open(lua_State *tolua_S)
Definition tolua_signal_gen.c:259
tolua_signal_gen.h