/[cvs]/eggdrop1.9/src/script_api.h
ViewVC logotype

Contents of /eggdrop1.9/src/script_api.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Mon Oct 15 09:27:08 2001 UTC (18 years, 1 month ago) by stdarg
Branch: MAIN
Changes since 1.2: +18 -13 lines
File MIME type: text/x-csrc
Updates to timer code.
Updates to tcl module.
Convenience functions for scripting.
Script journal for late scripting modules.
Got rid of anonymous union in script_var_t.

1 /* This file contains the stuff you need to use the scripting modules. */
2
3 #ifndef _SCRIPT_API_H_
4 #define _SCRIPT_API_H_
5
6 /* How about some macros for setting return values? */
7 #define SCRIPT_RETURN_INT(x) retval->type = SCRIPT_INTEGER, retval->intval = x
8 #define SCRIPT_RETURN_STR(s) retval->type = SCRIPT_STRING, retval->str = s
9
10 /* Script events that get recorded in the script journal. */
11 enum {
12 SCRIPT_EVENT_LOAD_SCRIPT = 0,
13 SCRIPT_EVENT_SET_INT,
14 SCRIPT_EVENT_SET_STR,
15 SCRIPT_EVENT_LINK_INT,
16 SCRIPT_EVENT_UNLINK_INT,
17 SCRIPT_EVENT_LINK_STR,
18 SCRIPT_EVENT_UNLINK_STR,
19 SCRIPT_EVENT_CREATE_CMD,
20 SCRIPT_EVENT_DELETE_CMD,
21 SCRIPT_EVENT_MAX
22 };
23
24 /* Flags for commands. */
25 #define SCRIPT_WANTS_CD 1
26 #define SCRIPT_COMPLEX 2
27
28 /* Flags for linked variables. */
29 #define SCRIPT_READ_ONLY 1
30
31 /* Flags for variables (check out struct script_var_t) */
32 #define SCRIPT_STATIC 1
33 #define SCRIPT_STRING 2
34 #define SCRIPT_INTEGER 4
35 #define SCRIPT_LIST 8
36 #define SCRIPT_ARRAY 16
37 #define SCRIPT_VARRAY 32
38 #define SCRIPT_POINTER 64
39 #define SCRIPT_CALLBACK 128
40
41 /* Eggdrop specific types. */
42 #define SCRIPT_USER 256
43
44 /* Error bit. */
45 #define SCRIPT_ERROR 512
46
47 typedef struct script_callback_b {
48 int (*callback)();
49 void *callback_data;
50 int (*delete)();
51 void *delete_data;
52 } script_callback_t;
53
54 typedef struct script_var_b {
55 int type; /* Type of variable (int, str, etc). */
56 void *value; /* Value (needs to be cast to right type). */
57 int len; /* Length of string of array (when appropriate). */
58 int flags; /* Not used right now. */
59 } script_var_t;
60
61 typedef struct script_int_b {
62 char *class;
63 char *name;
64 int *ptr;
65 } script_int_t;
66
67 typedef struct script_str_b {
68 char *class;
69 char *name;
70 char **ptr;
71 } script_str_t;
72
73 typedef struct script_command_b {
74 char *class;
75 char *name;
76 Function callback;
77 void *client_data;
78 int nargs; /* Number of arguments the script wants. */
79 int pass_array; /* Want an array of stuff? */
80 char *syntax; /* Argument types. */
81 char *syntax_error; /* Error to print when called incorrectly. */
82 int retval_type; /* Limited return value type, for simple stuff. */
83 int flags;
84 } script_command_t;
85
86 typedef struct script_simple_command_b {
87 char *name;
88 Function callback;
89 char *syntax;
90 char *syntax_error;
91 int retval_type;
92 } script_simple_command_t;
93
94 #endif

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23