/[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.11 - (show annotations) (download) (as text)
Tue Mar 26 01:06:22 2002 UTC (17 years, 7 months ago) by ite
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +0 -0 lines
File MIME type: text/x-csrc
FILE REMOVED
* moved script API to libeggdrop (without using the bot context)
* fixed a wrong function name in perlscript
* do not use the bot context in registry for now

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 /* Script events that get recorded in the script journal. */
7 enum {
8 SCRIPT_EVENT_LOAD_SCRIPT = 0,
9 SCRIPT_EVENT_SET_INT,
10 SCRIPT_EVENT_SET_STR,
11 SCRIPT_EVENT_LINK_INT,
12 SCRIPT_EVENT_UNLINK_INT,
13 SCRIPT_EVENT_LINK_STR,
14 SCRIPT_EVENT_UNLINK_STR,
15 SCRIPT_EVENT_CREATE_CMD,
16 SCRIPT_EVENT_DELETE_CMD,
17 SCRIPT_EVENT_MAX
18 };
19
20 /* Flags for commands. */
21 /* SCRIPT_PASS_CDATA means your callback wants its (void *)client_data passed
22 as its *first* arg.
23 SCRIPT_PASS_RETVAL will pass a (scriptvar_t *)retval so that you can return
24 complex types.
25 SCRIPT_PASS_ARRAY will pass all the args from the script in an array. It
26 actually causes 2 arguments: int argc and void *argv[].
27 SCRIPT_PASS_COUNT will pass the number of script arguments you're getting.
28 SCRIPT_VAR_ARGS means you accept variable number of args. The nargs field
29 of the command struct is the minimum number required, and the strlen of your
30 syntax field is the max number (unless it ends in * of course).
31 SCRIPT_VAR_FRONT means the variable args come from the front instead of the
32 back. This is useful for flags and stuff.
33 */
34 #define SCRIPT_PASS_CDATA 1
35 #define SCRIPT_PASS_RETVAL 2
36 #define SCRIPT_PASS_ARRAY 4
37 #define SCRIPT_PASS_COUNT 8
38 #define SCRIPT_VAR_ARGS 16
39 #define SCRIPT_VAR_FRONT 32
40
41 /* Flags for callbacks. */
42 /* SCRIPT_CALLBACK_ONCE means the callback will be automatically deleted after
43 its first use.
44 */
45 #define SCRIPT_CALLBACK_ONCE 1
46
47 /* Flags for linked variables. */
48 #define SCRIPT_READ_ONLY 1
49
50 /* Flags for variables. */
51 /* SCRIPT_FREE means we will call free(retval->value) (i.e. free a malloc'd
52 string or array base ptr.)
53 SCRIPT_FREE_VAR means we will call free(retval) (you may need this if you
54 build a complex list structure of (script_var_t *)'s).
55 SCRIPT_ARRAY means we interpret retval->value as an array of length
56 retval->len, of whatever basic type is specified in retval->type (flags
57 are ignored).
58 SCRIPT_ERROR means the interpreter will raise an error exception if it knows
59 how, with retval->value as the error information. Otherwise, it is ignored.
60 */
61 #define SCRIPT_FREE 256
62 #define SCRIPT_FREE_VAR 512
63 #define SCRIPT_ARRAY 1024
64 #define SCRIPT_ERROR 2048
65
66 /* Types for variables. */
67 #define SCRIPT_STRING ((int)'s')
68 #define SCRIPT_INTEGER ((int)'i')
69 #define SCRIPT_UNSIGNED ((int)'u')
70 #define SCRIPT_POINTER ((int)'p')
71 #define SCRIPT_CALLBACK ((int)'c')
72 #define SCRIPT_USER ((int)'U')
73 #define SCRIPT_BYTES ((int)'b')
74 #define SCRIPT_VAR ((int)'v')
75 #define SCRIPT_TYPE_MASK 255
76
77 typedef struct script_callback_b {
78 int (*callback)();
79 void *callback_data;
80 int (*delete)();
81 void *delete_data;
82 char *syntax;
83 char *name;
84 int flags;
85 } script_callback_t;
86
87 typedef struct script_var_b {
88 int type; /* Type of variable (int, str, etc). */
89 void *value; /* Value (needs to be cast to right type). */
90 int len; /* Length of string or array (when appropriate). */
91 } script_var_t;
92
93 typedef struct script_int_b {
94 char *class;
95 char *name;
96 int *ptr;
97 } script_int_t;
98
99 typedef struct script_str_b {
100 char *class;
101 char *name;
102 char **ptr;
103 } script_str_t;
104
105 typedef struct script_command_b {
106 char *class;
107 char *name;
108 Function callback;
109 void *client_data;
110 int nargs; /* Number of arguments the script wants. */
111 char *syntax; /* Argument types. */
112 char *syntax_error; /* Error to print when called incorrectly. */
113 int retval_type; /* Limited return value type, for simple stuff. */
114 int flags;
115 } script_command_t;
116
117 #endif

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23