aboutsummaryrefslogtreecommitdiff
path: root/src/verb.h
blob: 89139629a4ecf5e1da7404d2f028092fdb54b6c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 *   NetCosm - a MUD server
 *   Copyright (C) 2016 Franklin Wei
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "globals.h"

#include "room.h"
#include "server.h"

/* the verb API is modeled after that of obj_*, this allows for
 * dynamic creation/deletion of verbs, but is also easily
 * serializable.
 *
 * so, all verbs are part of a verb class, which has all of its
 * callbacks.
 */

struct verb_t;
struct verb_class_t {
    const char *class_name;

    void (*hook_exec)(struct verb_t*, char *args, user_t *user);
};

struct verb_t {
    char *name;

    struct verb_class_t *class;
};

struct verb_t *verb_new(const char *class);

void verb_write(int fd, struct verb_t*);

struct verb_t *verb_read(int fd);

void verb_free(void *verb);

/* free the verb_ module's internal data structures */
void verb_shutdown(void);