The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
validation.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2008 by David White <dave@whitevine.net>
3  2008 - 2015 by Ignacio R. Morelle <shadowm2006@gmail.com>
4  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include <vector>
19 #include <string>
20 
21 class config;
22 
23 /**
24  * Default port number for the addon server.
25  *
26  * @note This might not be the best place to declare the variable, but it's
27  * one of the few files shared by the server and the game.
28  */
29 extern const unsigned short default_campaignd_port;
30 
31 /**
32  * Values used for add-on classification; UI-only
33  * at the moment, in the future it could be used for
34  * directory allocation too, removing the need for
35  * the ADDON_GROUP constants (TODO).
36  *
37  * @note If you change the order or content of these, you'll also need
38  * to update the @a addon_type_strings table found in validation.cpp.
39  */
40 enum ADDON_TYPE {
41  ADDON_UNKNOWN, /**< a.k.a. anything. */
42  ADDON_CORE, /**< Total Conversion Core. */
43  ADDON_SP_CAMPAIGN, /**< Single-player campaign. */
44  ADDON_SP_SCENARIO, /**< Single-player scenario. */
45  ADDON_SP_MP_CAMPAIGN, /**< Hybrid campaign. */
46  ADDON_MP_CAMPAIGN, /**< Multiplayer campaign. */
47  ADDON_MP_SCENARIO, /**< Multiplayer scenario. */
48  ADDON_MP_MAPS, /**< Multiplayer plain (no WML) map pack. */
49  ADDON_MP_ERA, /**< Multiplayer era. */
50  ADDON_MP_FACTION, /**< Multiplayer faction. */
51  // NOTE: following two still require proper engine support
52  ADDON_MP_MOD, /**< Modification of the game for MP. */
53  //ADDON_GUI, // GUI add-ons/themes.
54  ADDON_MEDIA, /**< Miscellaneous content/media (unit packs, terrain packs, music packs, etc.). */
55  ADDON_OTHER, /**< an add-on that fits in no other category */
57 };
58 
61 
62 /** Checks whether an add-on id/name is legal or not. */
63 bool addon_name_legal(const std::string& name);
64 /** Checks whether an add-on file name is legal or not. */
66 
67 /**
68  * Scans an add-on archive for illegal names.
69  *
70  * @param dir The WML container for the root [dir] node where the search
71  * should begin.
72  * @param badlist If provided and not null, any illegal names encountered will
73  * be added to this list. This also makes the archive scan more
74  * thorough instead of returning on the first illegal name
75  * encountered.
76  *
77  * @returns True if no illegal names were found.
78  */
79 bool check_names_legal(const config& dir, std::vector<std::string>* badlist = nullptr);
80 /**
81  * Scans an add-on archive for case-conflicts.
82  *
83  * Case conflicts may cause trouble on case-insensitive filesystems.
84  *
85  * @param dir The WML container for the root [dir] node where the search
86  * should begin.
87  * @param badlist If provided and not null, any case conflicts encountered will
88  * be added to this list. This also makes the archive scan more
89  * thorough instead of returning on the first conflict
90  * encountered.
91  *
92  * @returns True if no conflicts were found.
93  */
94 bool check_case_insensitive_duplicates(const config& dir, std::vector<std::string>* badlist = nullptr);
95 
98 bool needs_escaping(char c);
bool check_case_insensitive_duplicates(const config &dir, std::vector< std::string > *badlist=nullptr)
Scans an add-on archive for case-conflicts.
Definition: validation.cpp:231
Single-player scenario.
Definition: validation.hpp:44
std::vector< char_t > string
ADDON_TYPE get_addon_type(const std::string &str)
Definition: validation.cpp:235
ADDON_TYPE
Values used for add-on classification; UI-only at the moment, in the future it could be used for dire...
Definition: validation.hpp:40
an add-on that fits in no other category
Definition: validation.hpp:55
Total Conversion Core.
Definition: validation.hpp:42
bool addon_name_legal(const std::string &name)
Checks whether an add-on id/name is legal or not.
Definition: validation.cpp:90
bool needs_escaping(char c)
Definition: validation.cpp:261
const unsigned short default_campaignd_port
Default port number for the addon server.
Definition: validation.cpp:24
Multiplayer faction.
Definition: validation.hpp:50
std::string encode_binary(const std::string &str)
Definition: validation.cpp:273
bool check_names_legal(const config &dir, std::vector< std::string > *badlist=nullptr)
Scans an add-on archive for illegal names.
Definition: validation.cpp:222
std::string get_addon_type_string(ADDON_TYPE type)
Definition: validation.cpp:251
Modification of the game for MP.
Definition: validation.hpp:52
Miscellaneous content/media (unit packs, terrain packs, music packs, etc.).
Definition: validation.hpp:54
Multiplayer scenario.
Definition: validation.hpp:47
Multiplayer era.
Definition: validation.hpp:49
Multiplayer plain (no WML) map pack.
Definition: validation.hpp:48
std::string unencode_binary(const std::string &str)
Definition: validation.cpp:291
Hybrid campaign.
Definition: validation.hpp:45
static const char * name(const std::vector< SDL_Joystick * > &joysticks, const size_t index)
Definition: joystick.cpp:48
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
mock_char c
bool addon_filename_legal(const std::string &name)
Checks whether an add-on file name is legal or not.
Definition: validation.cpp:100
Single-player campaign.
Definition: validation.hpp:43
Multiplayer campaign.
Definition: validation.hpp:46