mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Tidied up code (apart from legacy.py, which got messed up), updated docs.
This commit is contained in:
+31
-22
@@ -1,8 +1,8 @@
|
||||
# Settings passed on the command line:
|
||||
#
|
||||
# LIBSTR_LIBS_DIR = the directory which all external libraries may be referenced from.
|
||||
# LIBSTR_ARCH = the build architecture
|
||||
# LIBSTR_LINK = whether to build a static or dynamic library.
|
||||
# PROJECT_LIBS_DIR = the directory which all external libraries may be referenced from.
|
||||
# PROJECT_ARCH = the build architecture
|
||||
# PROJECT_LINK = whether to build a static or dynamic library.
|
||||
|
||||
##############################
|
||||
# General Settings
|
||||
@@ -14,7 +14,8 @@ project (boss)
|
||||
set (BOSS_SRC "${CMAKE_SOURCE_DIR}/src/metadata.cpp" "${CMAKE_SOURCE_DIR}/src/game.cpp" "${CMAKE_SOURCE_DIR}/src/helpers.cpp" "${CMAKE_SOURCE_DIR}/src/plugin/ModFormat.cpp" "${CMAKE_SOURCE_DIR}/src/plugin/VersionRegex.cpp")
|
||||
|
||||
# Include source and library directories.
|
||||
include_directories ("${BOSS_LIBS_DIR}/alphanum" "${BOSS_LIBS_DIR}/utf8" "${BOSS_LIBS_DIR}/boost" "${BOSS_LIBS_DIR}/yaml-cpp/include" "${CMAKE_SOURCE_DIR}/src" "${BOSS_LIBS_DIR}/libloadorder/src")
|
||||
include_directories ("${PROJECT_LIBS_DIR}/alphanum" "${PROJECT_LIBS_DIR}/utf8" "${PROJECT_LIBS_DIR}/boost" "${PROJECT_LIBS_DIR}/yaml-cpp/include" "${CMAKE_SOURCE_DIR}/src" "${PROJECT_LIBS_DIR}/libloadorder/src")
|
||||
|
||||
|
||||
##############################
|
||||
# Platform-Specific Settings
|
||||
@@ -22,35 +23,43 @@ include_directories ("${BOSS_LIBS_DIR}/alphanum" "${BOSS_LIBS_DIR}/utf8" "${BOSS
|
||||
|
||||
# Settings when compiling for Windows.
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
#IF (${BOSS_LINK} MATCHES "STATIC")
|
||||
# add_definitions (-DBOSS_STATIC)
|
||||
#ELSE ()
|
||||
# add_definitions (-DBOSS_EXPORT)
|
||||
#ENDIF ()
|
||||
IF (${PROJECT_LINK} MATCHES "STATIC")
|
||||
add_definitions (-DLIBLO_STATIC)
|
||||
add_definitions (-DBOSS_STATIC)
|
||||
ELSE ()
|
||||
add_definitions (-DLIBLO_STATIC)
|
||||
add_definitions (-DBOSS_EXPORT)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
# Settings when compiling on Windows.
|
||||
IF (CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
|
||||
#set (BOSS_LIBS libboost_filesystem-vc110-mt-1_52 libboost_system-vc110-mt-1_52)
|
||||
set (CMAKE_CXX_FLAGS "/EHsc")
|
||||
# Settings when not cross-compiling.
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES CMAKE_HOST_SYSTEM_NAME)
|
||||
link_directories ("${PROJECT_LIBS_DIR}/boost/stage-${PROJECT_ARCH}/lib")
|
||||
ENDIF ()
|
||||
|
||||
link_directories ("${PROJECT_LIBS_DIR}/yaml-cpp/build")
|
||||
link_directories ("${PROJECT_LIBS_DIR}/libloadorder/build")
|
||||
|
||||
# Settings when compiling and cross-compiling on Linux.
|
||||
IF (CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
|
||||
set (BOSS_LIBS loadorder yaml-cpp boost_filesystem boost_system boost_regex)
|
||||
set (CMAKE_C_FLAGS "-m${BOSS_ARCH}")
|
||||
set (CMAKE_CXX_FLAGS "-m${BOSS_ARCH}")
|
||||
set (CMAKE_C_FLAGS "-m${PROJECT_ARCH}")
|
||||
set (CMAKE_CXX_FLAGS "-m${PROJECT_ARCH}")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static-libgcc")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++ -static-libgcc")
|
||||
set (CMAKE_MODULE_LINKER_FLAGS "-static-libstdc++ -static-libgcc")
|
||||
|
||||
link_directories ("${BOSS_LIBS_DIR}/yaml-cpp/build")
|
||||
link_directories ("${BOSS_LIBS_DIR}/libloadorder/build")
|
||||
link_directories ("${BOSS_LIBS_DIR}/boost/stage-${BOSS_ARCH}/lib")
|
||||
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
link_directories ("${BOSS_LIBS_DIR}/boost/stage-mingw-${BOSS_ARCH}/lib")
|
||||
link_directories ("${PROJECT_LIBS_DIR}/boost/stage-mingw-${PROJECT_ARCH}/lib")
|
||||
set (BOSS_LIBS version)
|
||||
ENDIF ()
|
||||
|
||||
set (BOSS_LIBS ${BOSS_LIBS} loadorder yaml-cpp boost_filesystem boost_system boost_regex)
|
||||
ENDIF ()
|
||||
|
||||
# Settings when compiling on Windows.
|
||||
IF (CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
|
||||
set (BOSS_LIBS loadorder yaml-cpp libboost_filesystem-vc110-mt-1_52 libboost_system-vc110-mt-1_52)
|
||||
set (CMAKE_CXX_FLAGS "/EHsc")
|
||||
ENDIF ()
|
||||
|
||||
##############################
|
||||
@@ -58,7 +67,7 @@ ENDIF ()
|
||||
##############################
|
||||
|
||||
# Build API.
|
||||
add_library (boss "${CMAKE_SOURCE_DIR}/src/api.cpp" ${BOSS_SRC})
|
||||
add_library (boss ${PROJECT_LINK} "${CMAKE_SOURCE_DIR}/src/api.cpp" ${BOSS_SRC})
|
||||
target_link_libraries (boss ${BOSS_LIBS})
|
||||
|
||||
# Build tester.
|
||||
|
||||
+15
-15
@@ -69,7 +69,7 @@ h3{
|
||||
-->
|
||||
|
||||
<div id="warning">
|
||||
This documentation is a work in progress, covering an API that is also still a work in progress, and is subject to change. Userlist loading and access has not yet been implemented. The minimal file write doesn't include dirty messages yet.
|
||||
This documentation is a work in progress, covering an API that is also still a work in progress, and is subject to change. Userlist access has not yet been implemented.
|
||||
</div>
|
||||
|
||||
<h1>BOSS API Readme</h1>
|
||||
@@ -101,10 +101,10 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
<h2 id="types">Variable Types</h2>
|
||||
<p>The API uses character strings and unsigned integers for data input/output.
|
||||
<ul>
|
||||
<li>All strings consist of byte characters, are encoded in UTF-8 and are null-terminated.
|
||||
<li>All strings are null-terminated byte character strings encoded in UTF-8.
|
||||
<li>All codes are unsigned integers at least 16 bits in size.
|
||||
<li>All array sizes are unsigned integers at least 16 bits in size.
|
||||
<li>File paths are case-sensitive if the underlying file system is case-sensitive.
|
||||
<li>File paths are case-sensitive if and only if the underlying file system is case-sensitive.
|
||||
</ul>
|
||||
<p>The API also provides two new structures:
|
||||
<code class="box">typedef struct _boss_db_int * boss_db;</code>
|
||||
@@ -158,20 +158,20 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
<h2 id="func">Functions</h2>
|
||||
|
||||
<h3 id="func-error">Error Handling Functions</h3>
|
||||
<div id="boss_get_error_message">
|
||||
<div class="dfn" id="boss_get_error_message">
|
||||
<code class="box">unsigned int boss_get_error_message (char ** message);</code>
|
||||
<p>Outputs a string detailing the last error encountered.
|
||||
<ul>
|
||||
<li><var>message</var> - A pointer to the error string outputted.
|
||||
</ul>
|
||||
</div>
|
||||
<div id="boss_cleanup">
|
||||
<div class="dfn" id="boss_cleanup">
|
||||
<code class="box">void boss_cleanup ();</code>
|
||||
<p>Frees the memory allocated to the error message string, if <a href="#boss_get_error_message">boss_get_error_message</a> has been called.
|
||||
</div>
|
||||
|
||||
<h3 id="func-version">Version Functions</h3>
|
||||
<div id="boss_is_compatible">
|
||||
<div class="dfn" id="boss_is_compatible">
|
||||
<code class="box">bool boss_is_compatible (const unsigned int versionMajor,
|
||||
const unsigned int versionMinor,
|
||||
const unsigned int versionPatch);</code>
|
||||
@@ -182,7 +182,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
<li><var>versionPatch</var> - The patch version number (major.minor.<b>patch</b>) to check.
|
||||
</ul>
|
||||
</div>
|
||||
<div id="boss_get_version">
|
||||
<div class="dfn" id="boss_get_version">
|
||||
<code class="box">unsigned int boss_get_version (unsigned int * versionMajor,
|
||||
unsigned int * versionMinor,
|
||||
unsigned int * versionPatch);</code>
|
||||
@@ -195,7 +195,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
</div>
|
||||
|
||||
<h3 id="func-lifecycle">Lifecycle Management Functions</h3>
|
||||
<div id="boss_create_db">
|
||||
<div class="dfn" id="boss_create_db">
|
||||
<code class="box">unsigned int boss_create_db (boss_db * db,
|
||||
const unsigned int clientGame,
|
||||
const char * gamePath);</code>
|
||||
@@ -206,7 +206,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
<li><var>gamePath</var> - A string giving the path to the game's main folder, ie. the one in which the game's executable lies, or <code>null</code>. If <code>null</code>, then the API will attempt to detect the game folder location itself using the game's registry entries.
|
||||
</ul>
|
||||
</div>
|
||||
<div id="boss_destroy_db">
|
||||
<div class="dfn" id="boss_destroy_db">
|
||||
<code class="box">void boss_destroy_db (boss_db db);</code>
|
||||
<p>Destroys the given database, freeing any memory allocated during its use.
|
||||
<ul>
|
||||
@@ -215,7 +215,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
</div>
|
||||
|
||||
<h3 id="func-load">Database Loading Functions</h3>
|
||||
<div id="boss_load_lists">
|
||||
<div class="dfn" id="boss_load_lists">
|
||||
<code class="box">unsigned int boss_load_lists (boss_db db,
|
||||
const char * masterlistPath,
|
||||
const char * userlistPath);</code>
|
||||
@@ -226,7 +226,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
<li><var>userlistPath</var> - A string containing the relative or absolute path to the userlist file that should be loaded, or <code>null</code>. If <code>null</code>, no userlist will be loaded.
|
||||
</ul>
|
||||
</div>
|
||||
<div id="boss_eval_lists">
|
||||
<div class="dfn" id="boss_eval_lists">
|
||||
<code class="box">unsigned int boss_eval_lists (boss_db db);</code>
|
||||
<p>Refreshes the active plugin list used during evaluation then evaluates all conditional and regular expression metadata entries. Repeated calls re-evaluate the metadata from scratch. This function affects the output of all the database access functions.
|
||||
<ul>
|
||||
@@ -235,7 +235,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
</div>
|
||||
|
||||
<h3 id="func-access">Database Access Functions</h3>
|
||||
<div id="boss_get_tag_map">
|
||||
<div class="dfn" id="boss_get_tag_map">
|
||||
<code class="box">unsigned int boss_get_tag_map (boss_db db,
|
||||
char *** tagMap,
|
||||
size_t * numTags);</code>
|
||||
@@ -246,7 +246,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
<li><var>numTags</var> - A pointer to the size of the <var>tagMap</var> array. <code>0</code> if <var>tagMap</var> is <code>null</code>.
|
||||
</ul>
|
||||
</div>
|
||||
<div id="boss_get_plugin_tags">
|
||||
<div class="dfn" id="boss_get_plugin_tags">
|
||||
<code class="box">unsigned int boss_get_plugin_tags (boss_db db,
|
||||
const char * plugin,
|
||||
unsigned int ** tags_added,
|
||||
@@ -265,7 +265,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
<li><var>userlistModified</var> - <code>true</code> if the Bash Tag suggestions were modified by the data in the userlist, <code>false</code> otherwise.
|
||||
</ul>
|
||||
</div>
|
||||
<div id="boss_get_plugin_messages">
|
||||
<div class="dfn" id="boss_get_plugin_messages">
|
||||
<code class="box">unsigned int boss_get_plugin_messages (boss_db db,
|
||||
const char * plugin,
|
||||
boss_message ** messages,
|
||||
@@ -278,7 +278,7 @@ This documentation is a work in progress, covering an API that is also still a w
|
||||
<li><var>numMessages</var> - A pointer to the size of the <var>messages</var> array. <code>0</code> if <var>messages</var> is <code>null</code>.
|
||||
</ul>
|
||||
</div>
|
||||
<div id="boss_write_minimal_list">
|
||||
<div class="dfn" id="boss_write_minimal_list">
|
||||
<code class="box">unsigned int boss_write_minimal_list (boss_db db,
|
||||
const char * outputFile,
|
||||
const bool overwrite);</code>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# Cross-compiling from Linux to Windows.
|
||||
#
|
||||
# Takes the PROJECT_ARCH variable, with value "32" or "64".
|
||||
set (CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
IF (PROJECT_ARCH MATCHES "32")
|
||||
set (MINGW i586-mingw32msvc)
|
||||
ELSE ()
|
||||
set (MINGW x86_64-w64-mingw32)
|
||||
ENDIF ()
|
||||
|
||||
set (CMAKE_C_COMPILER ${MINGW}-gcc)
|
||||
set (CMAKE_CXX_COMPILER ${MINGW}-g++)
|
||||
set (CMAKE_RC_COMPILER ${MINGW}-windres)
|
||||
set (CMAKE_RANLIB ${MINGW}-ranlib)
|
||||
+15
@@ -35,6 +35,8 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
@@ -549,6 +551,19 @@ BOSS_API unsigned int boss_write_minimal_list (boss_db db, const char * outputFi
|
||||
for (std::list<boss::Plugin>::iterator it=temp.begin(), endIt=temp.end(); it != endIt; ++it) {
|
||||
boss::Plugin p(it->Name());
|
||||
p.Tags(it->Tags());
|
||||
|
||||
std::list<boss::Message> messages = it->Messages(), newMessages;
|
||||
for (std::list<boss::Message>::iterator messageIter = messages.begin(); messageIter != messages.end(); ++messageIter) {
|
||||
if (messageIter->Type() == "warn") {
|
||||
const std::string content = messageIter->Content();
|
||||
if (boost::contains(content, "Do not clean"))
|
||||
newMessages.push_back(*messageIter);
|
||||
else if (boost::contains(content, "Contains dirty edits"))
|
||||
newMessages.push_back(*messageIter);
|
||||
}
|
||||
}
|
||||
it->Messages(newMessages);
|
||||
|
||||
*it = p;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,29 +24,30 @@
|
||||
#ifndef __BOSS_API_H__
|
||||
#define __BOSS_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
//MSVC doesn't support C99, so do the stdbool.h definitions ourselves.
|
||||
//START OF stdbool.h DEFINITIONS.
|
||||
# ifndef __cplusplus
|
||||
# define bool _Bool
|
||||
# define true 1
|
||||
# define false 0
|
||||
# define bool _Bool
|
||||
# define true 1
|
||||
# define false 0
|
||||
# endif
|
||||
# define __bool_true_false_are_defined 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
//END OF stdbool.h DEFINITIONS.
|
||||
#else
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
|
||||
// set up dll import/export decorators
|
||||
// when compiling the dll on windows, ensure BOSS_API_EXPORT is defined. clients
|
||||
// when compiling the dll on windows, ensure BOSS_EXPORT is defined. clients
|
||||
// that use this header do not need to define anything to import the symbols
|
||||
// properly.
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
# ifdef BOSS_API_EXPORT
|
||||
# ifdef BOSS_STATIC
|
||||
# define BOSS_API
|
||||
# elif defined BOSS_EXPORT
|
||||
# define BOSS_API __declspec(dllexport)
|
||||
# else
|
||||
# define BOSS_API __declspec(dllimport)
|
||||
|
||||
+2
-2
@@ -32,8 +32,8 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#if _WIN32 || _WIN64
|
||||
# include <Windows.h>
|
||||
# include <Shlobj.h>
|
||||
# include <windows.h>
|
||||
# include <shlobj.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
+9
-3
@@ -46,8 +46,14 @@
|
||||
#include <sstream>
|
||||
|
||||
#if _WIN32 || _WIN64
|
||||
# include "Windows.h"
|
||||
# include "Shlobj.h"
|
||||
# ifndef UNICODE
|
||||
# define UNICODE
|
||||
# endif
|
||||
# ifndef _UNICODE
|
||||
# define _UNICODE
|
||||
# endif
|
||||
# include "windows.h"
|
||||
# include "shlobj.h"
|
||||
#endif
|
||||
|
||||
namespace boss {
|
||||
@@ -62,7 +68,7 @@ namespace boss {
|
||||
uint32_t chksum = 0;
|
||||
static const size_t buffer_size = 8192;
|
||||
char buffer[buffer_size];
|
||||
ifstream ifile(filename.c_str(), ios::binary);
|
||||
ifstream ifile(filename.string().c_str(), ios::binary);
|
||||
// LOG_TRACE("calculating CRC for: '%s'", filename.string().c_str());
|
||||
boost::crc_32_type result;
|
||||
if (ifile) {
|
||||
|
||||
+2
-1
@@ -35,7 +35,8 @@
|
||||
# - Conditional plugin positions are all made unconditional, so there will be
|
||||
# duplicate entries.
|
||||
|
||||
import re
|
||||
class Plugin:
|
||||
|
||||
|
||||
def escapeYAMLStr(s):
|
||||
special = ['-', '?', ':', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`']
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace boss {
|
||||
if (filename.empty())
|
||||
return false;
|
||||
|
||||
ifstream file(filename.native().c_str(), ios_base::binary | ios_base::in);
|
||||
ifstream file(filename.string().c_str(), ios_base::binary | ios_base::in);
|
||||
|
||||
if (file.bad())
|
||||
//throw boss_error(BOSS_ERROR_FILE_READ_FAIL, filename.string());
|
||||
@@ -163,7 +163,7 @@ namespace boss {
|
||||
char buffer[MAXLENGTH];
|
||||
char* bufptr = buffer;
|
||||
ModHeader modHeader;
|
||||
ifstream file(filename.native().c_str(), ios_base::binary | ios_base::in);
|
||||
ifstream file(filename.string().c_str(), ios_base::binary | ios_base::in);
|
||||
|
||||
modHeader.Name = filename.string();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user