+enum CmdResult
+{
+ CMD_FAILURE = 0, /* Command exists, but failed */
+ CMD_SUCCESS = 1, /* Command exists, and succeeded */
+ CMD_INVALID = 2, /* Command doesnt exist at all! */
+ CMD_EPERM = 3 /* Command failed because of a permission check */
+};
+
+/** Flag for commands that are only allowed from servers */
+const char FLAG_SERVERONLY = 7; // technically anything nonzero below 'A' works
+
+/** Translation types for translation of parameters to UIDs.
+ * This allows the core commands to not have to be aware of how UIDs
+ * work (making it still possible to write other linking modules which
+ * do not use UID (but why would you want to?)
+ */
+enum TranslateType
+{
+ TR_END, /* End of known parameters, everything after this is TR_TEXT */
+ TR_TEXT, /* Raw text, leave as-is */
+ TR_NICK, /* Nickname, translate to UUID for server->server */
+ TR_CUSTOM /* Custom translation handled by EncodeParameter/DecodeParameter */
+};
+
+/** Routing types for a command. Any command which is created defaults
+ * to having its command broadcasted on success. This behaviour may be
+ * overridden to one of the route types shown below (see the #defines
+ * below for more information on each one's behaviour)
+ */
+enum RouteType
+{
+ ROUTE_TYPE_LOCALONLY,
+ ROUTE_TYPE_BROADCAST,
+ ROUTE_TYPE_UNICAST,
+ ROUTE_TYPE_MESSAGE,
+ ROUTE_TYPE_OPT_BCAST,
+ ROUTE_TYPE_OPT_UCAST
+};
+
+/** Defines routing information for a command, containing a destination
+ * server id (if applicable) and a routing type from the enum above.
+ */
+struct RouteDescriptor
+{
+ /** Routing type from the enum above
+ */
+ RouteType type;
+ /** For unicast, the destination server's name
+ */
+ std::string serverdest;
+
+ /** Create a RouteDescriptor
+ */
+ RouteDescriptor(RouteType t, const std::string &d)
+ : type(t), serverdest(d) { }
+};
+
+/** Do not route this command */
+#define ROUTE_LOCALONLY (RouteDescriptor(ROUTE_TYPE_LOCALONLY, ""))
+/** Route this command to all servers, fail if not understood */
+#define ROUTE_BROADCAST (RouteDescriptor(ROUTE_TYPE_BROADCAST, ""))
+/** Route this command to a single server (do nothing if own server name specified) */
+#define ROUTE_UNICAST(x) (RouteDescriptor(ROUTE_TYPE_UNICAST, x))
+/** Route this command as a message with the given target (any of user, #channel, @#channel, $servermask) */
+#define ROUTE_MESSAGE(x) (RouteDescriptor(ROUTE_TYPE_MESSAGE, x))
+/** Route this command to all servers wrapped via ENCAP, so ignored if not understood */
+#define ROUTE_OPT_BCAST (RouteDescriptor(ROUTE_TYPE_OPT_BCAST, ""))
+/** Route this command to a single server wrapped via ENCAP, so ignored if not understood */
+#define ROUTE_OPT_UCAST(x) (RouteDescriptor(ROUTE_TYPE_OPT_UCAST, x))
+
+/** A structure that defines a command. Every command available
+ * in InspIRCd must be defined as derived from Command.
+ */
+class CoreExport Command : public ServiceProvider