Darryl Pogue
13 years ago
11 changed files with 0 additions and 1464 deletions
@ -1,21 +0,0 @@ |
|||||||
include_directories("../../CoreLib") |
|
||||||
include_directories("../../NucleusLib") |
|
||||||
|
|
||||||
set(pnIni_HEADERS |
|
||||||
Intern.h |
|
||||||
Pch.h |
|
||||||
pnIni.h |
|
||||||
) |
|
||||||
|
|
||||||
set(pnIni_PRIVATE |
|
||||||
Private/pnIniAllIncludes.h |
|
||||||
Private/pnIniChange.h |
|
||||||
Private/pnIniCore.h |
|
||||||
Private/pnIniCore.cpp |
|
||||||
Private/pnIniSrv.h |
|
||||||
) |
|
||||||
|
|
||||||
add_library(pnIni STATIC ${pnIni_HEADERS} ${pnIni_PRIVATE}) |
|
||||||
|
|
||||||
source_group("Header Files" FILES ${pnIni_HEADERS}) |
|
||||||
source_group("Private" FILES ${pnIni_PRIVATE}) |
|
@ -1,101 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Intern.h |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_INTERN_H |
|
||||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Intern.h included more than once" |
|
||||||
#endif |
|
||||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_INTERN_H |
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* Ini |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
struct IniValue { |
|
||||||
ARRAY(wchar_t *) fArgs; |
|
||||||
IniKey * fKey; |
|
||||||
unsigned fIndex; |
|
||||||
unsigned fLineNum; |
|
||||||
|
|
||||||
IniValue (IniKey * key, unsigned lineNum); |
|
||||||
~IniValue (); |
|
||||||
}; |
|
||||||
|
|
||||||
struct IniKey { |
|
||||||
HASHLINK(IniKey) fLink; |
|
||||||
ARRAY(IniValue *) fValues; |
|
||||||
IniSection * fSection; |
|
||||||
wchar_t fName[1]; // variable length
|
|
||||||
// no more fields
|
|
||||||
|
|
||||||
IniKey (IniSection * section, const wchar_t name[]); |
|
||||||
~IniKey (); |
|
||||||
|
|
||||||
unsigned GetHash () const; |
|
||||||
bool operator== (const CHashKeyStrPtrI & rhs) const; |
|
||||||
}; |
|
||||||
|
|
||||||
struct IniSection { |
|
||||||
HASHTABLEDECL(IniKey, CHashKeyStrPtrI, fLink) fKeys; |
|
||||||
HASHLINK(IniSection) fLink; |
|
||||||
wchar_t fName[1]; // variable length
|
|
||||||
// no more fields
|
|
||||||
|
|
||||||
IniSection (const wchar_t name[]); |
|
||||||
~IniSection (); |
|
||||||
|
|
||||||
unsigned GetHash () const; |
|
||||||
bool operator== (const CHashKeyStrPtrI & rhs) const; |
|
||||||
}; |
|
||||||
|
|
||||||
struct Ini { |
|
||||||
HASHTABLEDECL(IniSection, CHashKeyStrPtrI, fLink) fSections; |
|
||||||
|
|
||||||
~Ini (); |
|
||||||
}; |
|
@ -1,63 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Pch.h |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PCH_H |
|
||||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Pch.h included more than once" |
|
||||||
#endif |
|
||||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PCH_H |
|
||||||
|
|
||||||
|
|
||||||
#include "pnUtils/pnUtils.h" |
|
||||||
#include "pnProduct/pnProduct.h" |
|
||||||
#include "pnNetBase/pnNetBase.h" |
|
||||||
#include "pnAsyncCore/pnAsyncCore.h" |
|
||||||
|
|
||||||
#include "Private/pnIniAllIncludes.h" |
|
||||||
#include "Intern.h" |
|
||||||
|
|
||||||
|
|
||||||
#include <malloc.h> |
|
@ -1,56 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniAllIncludes.h |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINIALLINCLUDES_H |
|
||||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniAllIncludes.h included more than once" |
|
||||||
#endif |
|
||||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINIALLINCLUDES_H |
|
||||||
|
|
||||||
|
|
||||||
#include "pnIniCore.h" |
|
||||||
#include "pnIniChange.h" |
|
||||||
#include "pnIniSrv.h" |
|
@ -1,81 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniChange.h |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINICHANGE_H |
|
||||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniChange.h included more than once" |
|
||||||
#endif |
|
||||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINICHANGE_H |
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* Change notifications for files in the "./Config" directory |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
struct IniChangeReg; |
|
||||||
|
|
||||||
typedef void (* FIniFileChangeCallback)(const wchar_t fullPath[]); |
|
||||||
|
|
||||||
void IniChangeInitialize ( |
|
||||||
const wchar_t dir[] = L"Config" |
|
||||||
); |
|
||||||
void IniChangeDestroy (); |
|
||||||
|
|
||||||
void IniChangeAdd ( |
|
||||||
const wchar_t filename[], // just filename, no path or extension
|
|
||||||
FIniFileChangeCallback callback, |
|
||||||
IniChangeReg ** reg |
|
||||||
); |
|
||||||
void IniChangeRemove ( |
|
||||||
IniChangeReg * reg, |
|
||||||
bool wait |
|
||||||
); |
|
||||||
void IniChangeSignal ( |
|
||||||
IniChangeReg * reg, |
|
||||||
bool wait |
|
||||||
); |
|
@ -1,785 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.cpp |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#include "../Pch.h" |
|
||||||
#pragma hdrstop |
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* Internal functions |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
static wchar_t * TrimWhitespace (wchar_t * name) { |
|
||||||
while (isspace((char) *name)) |
|
||||||
++name; |
|
||||||
|
|
||||||
for (wchar_t * term = name; *term; ++term) { |
|
||||||
if (isspace((char) *term)) { |
|
||||||
*term = 0; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* |
|
||||||
* IniValue |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
IniValue::IniValue (IniKey * key, unsigned lineNum) |
|
||||||
: fKey(key) |
|
||||||
, fLineNum(lineNum) |
|
||||||
{ |
|
||||||
fIndex = key->fValues.Add(this); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
IniValue::~IniValue () { |
|
||||||
wchar_t ** cur = fArgs.Ptr(); |
|
||||||
wchar_t ** end = fArgs.Term(); |
|
||||||
for (; cur < end; ++cur) |
|
||||||
free(*cur); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
static void AddValueString ( |
|
||||||
IniValue * value, |
|
||||||
const wchar_t src[] |
|
||||||
) { |
|
||||||
unsigned chars = StrLen(src) + 1; |
|
||||||
wchar_t * dst = (wchar_t*)malloc(sizeof(wchar_t) * chars); |
|
||||||
StrTokenize(&src, dst, chars, L" \t\r\n\""); |
|
||||||
value->fArgs.Add(StrDup(dst)); |
|
||||||
|
|
||||||
free(dst); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* |
|
||||||
* IniKey |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
IniKey::IniKey (IniSection * section, const wchar_t name[]) |
|
||||||
: fSection(section) |
|
||||||
{ |
|
||||||
StrCopy(fName, name, (unsigned) -1); |
|
||||||
fSection->fKeys.Add(this); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
IniKey::~IniKey () { |
|
||||||
IniValue ** cur = fValues.Ptr(); |
|
||||||
IniValue ** end = fValues.Term(); |
|
||||||
for (; cur < end; ++cur) |
|
||||||
delete *cur; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
inline unsigned IniKey::GetHash () const { |
|
||||||
return StrHashI(fName); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
inline bool IniKey::operator== (const CHashKeyStrPtrI & rhs) const { |
|
||||||
return !StrCmpI(fName, rhs.GetString()); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
static IniValue * AddKeyValue ( |
|
||||||
IniSection * section, |
|
||||||
wchar_t * string, |
|
||||||
unsigned lineNum |
|
||||||
) { |
|
||||||
string = TrimWhitespace(string); |
|
||||||
|
|
||||||
// Find or create the key
|
|
||||||
IniKey * key = section->fKeys.Find(string); |
|
||||||
if (!key) { |
|
||||||
key = new(malloc( |
|
||||||
sizeof(*key) - sizeof(key->fName) + StrBytes(string) |
|
||||||
)) IniKey(section, string); |
|
||||||
} |
|
||||||
|
|
||||||
// Add a new value holder for the key
|
|
||||||
return new IniValue(key, lineNum); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* |
|
||||||
* IniSection |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
IniSection::IniSection (const wchar_t name[]) { |
|
||||||
StrCopy(fName, name, (unsigned) -1); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
IniSection::~IniSection () { |
|
||||||
fKeys.Clear(); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
inline unsigned IniSection::GetHash () const { |
|
||||||
return StrHashI(fName); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
inline bool IniSection::operator== (const CHashKeyStrPtrI & rhs) const { |
|
||||||
return !StrCmpI(fName, rhs.GetString()); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
static IniSection * AddSection ( |
|
||||||
Ini * ini, |
|
||||||
wchar_t * string |
|
||||||
) { |
|
||||||
// Find or create the section
|
|
||||||
IniSection * section = ini->fSections.Find(string); |
|
||||||
if (!section) { |
|
||||||
section = new(malloc( |
|
||||||
sizeof(*section) - sizeof(section->fName) + StrBytes(string) |
|
||||||
)) IniSection(string); |
|
||||||
ini->fSections.Add(section); |
|
||||||
} |
|
||||||
return section; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* |
|
||||||
* Ini |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
Ini::~Ini () { |
|
||||||
fSections.Clear(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* |
|
||||||
* ParseBuffer |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
static void ParseBuffer ( |
|
||||||
Ini * ini, |
|
||||||
const wchar_t buffer[] |
|
||||||
) { |
|
||||||
|
|
||||||
const wchar_t SECTION_OPEN_CHAR = '['; |
|
||||||
const wchar_t SECTION_CLOSE_CHAR = ']'; |
|
||||||
const wchar_t EQUIVALENCE_CHAR = '='; |
|
||||||
const wchar_t VALUE_SEPARATOR = ','; |
|
||||||
const wchar_t COMMENT_CHAR = ';'; |
|
||||||
const wchar_t QUOTE_CHAR = '\"'; |
|
||||||
const wchar_t NEWLINE = '\n'; |
|
||||||
|
|
||||||
enum { |
|
||||||
STATE_BEGIN, |
|
||||||
STATE_NEWLINE, |
|
||||||
STATE_SECTION, |
|
||||||
STATE_STRIP_TRAILING, |
|
||||||
STATE_KEY, |
|
||||||
STATE_VALUE, |
|
||||||
} state = STATE_BEGIN; |
|
||||||
|
|
||||||
IniSection * section = nil; |
|
||||||
IniValue * value = nil; |
|
||||||
const wchar_t * start = nil; |
|
||||||
bool valInQuotes = false; |
|
||||||
wchar_t dst[512]; |
|
||||||
dst[0] = 0; |
|
||||||
|
|
||||||
for (unsigned lineNum = 1;; ++buffer) { |
|
||||||
|
|
||||||
// Get next character
|
|
||||||
unsigned chr = *buffer; |
|
||||||
if (!chr) |
|
||||||
break; |
|
||||||
if (chr == '\r') |
|
||||||
continue; |
|
||||||
if (chr == '\n') |
|
||||||
++lineNum; |
|
||||||
if (chr == '\t') |
|
||||||
chr = ' '; |
|
||||||
|
|
||||||
switch (state) { |
|
||||||
case STATE_BEGIN: |
|
||||||
ASSERT(chr == UNICODE_BOM); |
|
||||||
state = STATE_NEWLINE; |
|
||||||
break; |
|
||||||
|
|
||||||
case STATE_NEWLINE: |
|
||||||
if (chr == NEWLINE) |
|
||||||
break; |
|
||||||
if (chr == ' ') |
|
||||||
break; |
|
||||||
if (chr == SECTION_OPEN_CHAR) { |
|
||||||
start = buffer + 1; |
|
||||||
state = STATE_SECTION; |
|
||||||
} |
|
||||||
else if (chr == COMMENT_CHAR) { |
|
||||||
state = STATE_STRIP_TRAILING; |
|
||||||
} |
|
||||||
else { |
|
||||||
start = buffer; |
|
||||||
state = STATE_KEY; |
|
||||||
} |
|
||||||
break; |
|
||||||
|
|
||||||
case STATE_SECTION: |
|
||||||
if (chr == NEWLINE) { |
|
||||||
state = STATE_NEWLINE; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
if (chr == SECTION_CLOSE_CHAR) { |
|
||||||
StrCopy(dst, start, min((unsigned long)(buffer - start + 1), arrsize(dst))); |
|
||||||
section = AddSection(ini, dst); |
|
||||||
state = STATE_STRIP_TRAILING; |
|
||||||
} |
|
||||||
break; |
|
||||||
|
|
||||||
case STATE_STRIP_TRAILING: |
|
||||||
if (chr == NEWLINE) |
|
||||||
state = STATE_NEWLINE; |
|
||||||
break; |
|
||||||
|
|
||||||
case STATE_KEY: |
|
||||||
if (chr == NEWLINE) { |
|
||||||
state = STATE_NEWLINE; |
|
||||||
break; |
|
||||||
} |
|
||||||
if (chr != EQUIVALENCE_CHAR) |
|
||||||
break; |
|
||||||
|
|
||||||
if (!section) { |
|
||||||
state = STATE_STRIP_TRAILING; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
StrCopy(dst, start, min((unsigned long)(buffer - start + 1), arrsize(dst))); |
|
||||||
value = AddKeyValue(section, dst, lineNum); |
|
||||||
start = buffer + 1; |
|
||||||
state = STATE_VALUE; |
|
||||||
valInQuotes = false; |
|
||||||
break; |
|
||||||
|
|
||||||
case STATE_VALUE: |
|
||||||
if (chr == QUOTE_CHAR) |
|
||||||
valInQuotes = !valInQuotes; |
|
||||||
if ((valInQuotes || chr != VALUE_SEPARATOR) && (chr != NEWLINE)) |
|
||||||
break; |
|
||||||
if (!value) { |
|
||||||
state = chr == NEWLINE ? STATE_NEWLINE : STATE_STRIP_TRAILING; |
|
||||||
break; |
|
||||||
} |
|
||||||
if (valInQuotes) { |
|
||||||
state = chr == NEWLINE ? STATE_NEWLINE : STATE_STRIP_TRAILING; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
StrCopy(dst, start, min((unsigned long)(buffer - start + 1), arrsize(dst))); |
|
||||||
AddValueString(value, dst); |
|
||||||
if (chr == VALUE_SEPARATOR) |
|
||||||
start = buffer + 1; |
|
||||||
else |
|
||||||
state = STATE_NEWLINE; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// cleanup current value
|
|
||||||
if (state == STATE_VALUE) { |
|
||||||
StrCopy(dst, start, min((unsigned long)(buffer - start + 1), arrsize(dst))); |
|
||||||
AddValueString(value, dst); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* |
|
||||||
* ParseFile |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
static void IniFileNotifyProc ( |
|
||||||
AsyncFile , |
|
||||||
EAsyncNotifyFile , |
|
||||||
AsyncNotifyFile * , |
|
||||||
void ** |
|
||||||
) { |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
static bool ParseFile ( |
|
||||||
Ini * ini, |
|
||||||
const wchar_t fileName[] |
|
||||||
) { |
|
||||||
// Open file
|
|
||||||
uint64_t fileSize; |
|
||||||
uint64_t fileLastWriteTime; |
|
||||||
EFileError error; |
|
||||||
AsyncFile file = AsyncFileOpen( |
|
||||||
fileName, |
|
||||||
IniFileNotifyProc, |
|
||||||
&error, |
|
||||||
kAsyncFileReadAccess, |
|
||||||
kAsyncFileModeOpenExisting, |
|
||||||
kAsyncFileShareRead, |
|
||||||
nil, |
|
||||||
&fileSize, |
|
||||||
&fileLastWriteTime |
|
||||||
); |
|
||||||
if (!file) |
|
||||||
return false; |
|
||||||
|
|
||||||
bool result; |
|
||||||
if (fileSize > 256 * 1024) { |
|
||||||
result = false; |
|
||||||
} |
|
||||||
else if (!fileSize) { |
|
||||||
result = true; |
|
||||||
} |
|
||||||
else { |
|
||||||
// Read entire file into memory and NULL terminate wchar_t
|
|
||||||
uint8_t * buffer = (uint8_t *) malloc((unsigned) fileSize + sizeof(wchar_t)); |
|
||||||
AsyncFileRead(file, 0, buffer, (unsigned) fileSize, kAsyncFileRwSync, nil); |
|
||||||
* (wchar_t *) &buffer[fileSize] = 0; |
|
||||||
|
|
||||||
// Convert to unicode if necessary
|
|
||||||
if (* (wchar_t *) buffer != UNICODE_BOM) { |
|
||||||
uint8_t * src = buffer; |
|
||||||
// Allocate two extra spaces for UNICODE_BOM and terminator
|
|
||||||
unsigned newBufferSize = ((unsigned) fileSize + 2) * sizeof(wchar_t); |
|
||||||
|
|
||||||
// Allocate new buffer
|
|
||||||
wchar_t * dst = (wchar_t *) malloc(newBufferSize); |
|
||||||
|
|
||||||
// If it's UTF-8 file,convert to Unicode
|
|
||||||
if (StrCmpI((char *)buffer, UTF8_BOM, StrLen(UTF8_BOM)) == 0) { |
|
||||||
// StrUtf8ToUnicode will convert UTF8_BOM to UNICODE_BOM
|
|
||||||
StrUtf8ToUnicode(dst, (char *)src, newBufferSize); |
|
||||||
} |
|
||||||
else { |
|
||||||
// do simple conversion to Unicode
|
|
||||||
dst[0] = UNICODE_BOM; |
|
||||||
for (unsigned index = 0;; ++index) { |
|
||||||
if (0 == (dst[index + 1] = src[index])) |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
free(src); |
|
||||||
buffer = (uint8_t *) dst; |
|
||||||
} |
|
||||||
|
|
||||||
ParseBuffer(ini, (const wchar_t *) buffer); |
|
||||||
free(buffer); |
|
||||||
result = true; |
|
||||||
} |
|
||||||
|
|
||||||
AsyncFileClose(file, kAsyncFileDontTruncate); |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* Exports |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
Ini * IniOpen ( |
|
||||||
const wchar_t fileName[] |
|
||||||
) { |
|
||||||
Ini * ini = new Ini; |
|
||||||
if (!ParseFile(ini, fileName)) { |
|
||||||
IniClose(ini); |
|
||||||
return nil; |
|
||||||
} |
|
||||||
return ini; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
void IniClose (Ini * ini) { |
|
||||||
delete ini; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniSection * IniGetFirstSection ( |
|
||||||
const Ini * ini, |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
) { |
|
||||||
if (chars) |
|
||||||
*name = 0; |
|
||||||
if (!ini) |
|
||||||
return nil; |
|
||||||
|
|
||||||
const IniSection * section = ini->fSections.Head(); |
|
||||||
if (section) |
|
||||||
StrCopy(name, section->fName, chars); |
|
||||||
return section; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniSection * IniGetNextSection ( |
|
||||||
const IniSection * section, |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
) { |
|
||||||
if (chars) |
|
||||||
*name = 0; |
|
||||||
if (!section) |
|
||||||
return nil; |
|
||||||
|
|
||||||
section = section->fLink.Next(); |
|
||||||
if (section) |
|
||||||
StrCopy(name, section->fName, chars); |
|
||||||
return section; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniSection * IniGetSection ( |
|
||||||
const Ini * ini, |
|
||||||
const wchar_t name[] |
|
||||||
) { |
|
||||||
if (!ini) |
|
||||||
return nil; |
|
||||||
|
|
||||||
return ini->fSections.Find( |
|
||||||
CHashKeyStrPtrI(name) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniKey * IniGetFirstKey ( |
|
||||||
const IniSection * section, |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
) { |
|
||||||
if (chars) |
|
||||||
*name = 0; |
|
||||||
if (!section) |
|
||||||
return nil; |
|
||||||
|
|
||||||
const IniKey * key = section->fKeys.Head(); |
|
||||||
if (key) |
|
||||||
StrCopy(name, key->fName, chars); |
|
||||||
return key; |
|
||||||
} |
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
const IniKey * IniGetFirstKey ( |
|
||||||
const Ini * ini, |
|
||||||
const wchar_t sectionName[], |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
) { |
|
||||||
if (const IniSection * section = IniGetSection(ini, sectionName)) |
|
||||||
return IniGetFirstKey(section, name, chars); |
|
||||||
|
|
||||||
return nil; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniKey * IniGetNextKey ( |
|
||||||
const IniKey * key, |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
) { |
|
||||||
if (chars) |
|
||||||
*name = 0; |
|
||||||
if (!key) |
|
||||||
return nil; |
|
||||||
|
|
||||||
key = key->fLink.Next(); |
|
||||||
if (key) |
|
||||||
StrCopy(name, key->fName, chars); |
|
||||||
return key; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniKey * IniGetKey ( |
|
||||||
const IniSection * section, |
|
||||||
const wchar_t name[] |
|
||||||
) { |
|
||||||
if (!section) |
|
||||||
return nil; |
|
||||||
|
|
||||||
return section->fKeys.Find( |
|
||||||
CHashKeyStrPtrI(name) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniValue * IniGetFirstValue ( |
|
||||||
const IniKey * key, |
|
||||||
unsigned * lineNum |
|
||||||
) { |
|
||||||
if (lineNum) |
|
||||||
*lineNum = 0; |
|
||||||
|
|
||||||
const IniValue * value = nil; |
|
||||||
for (;;) { |
|
||||||
if (!key) |
|
||||||
break; |
|
||||||
|
|
||||||
value = key->fValues[0]; |
|
||||||
if (lineNum) |
|
||||||
*lineNum = value->fLineNum; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
return value; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniValue * IniGetFirstValue ( |
|
||||||
const IniSection * section, |
|
||||||
const wchar_t keyName[], |
|
||||||
unsigned * lineNum |
|
||||||
) { |
|
||||||
const IniValue * value = nil; |
|
||||||
if (lineNum) |
|
||||||
*lineNum = 0; |
|
||||||
|
|
||||||
for (;;) { |
|
||||||
if (!section) |
|
||||||
break; |
|
||||||
|
|
||||||
const IniKey * key = section->fKeys.Find( |
|
||||||
CHashKeyStrPtrI(keyName) |
|
||||||
); |
|
||||||
value = IniGetFirstValue(key, lineNum); |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
return value; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniValue * IniGetFirstValue ( |
|
||||||
const Ini * ini, |
|
||||||
const wchar_t sectionName[], |
|
||||||
const wchar_t keyName[], |
|
||||||
unsigned * lineNum |
|
||||||
) { |
|
||||||
const IniValue * value = nil; |
|
||||||
if (lineNum) |
|
||||||
*lineNum = 0; |
|
||||||
|
|
||||||
for (;;) { |
|
||||||
if (!ini) |
|
||||||
break; |
|
||||||
|
|
||||||
const IniSection * section = ini->fSections.Find( |
|
||||||
CHashKeyStrPtrI(sectionName) |
|
||||||
); |
|
||||||
|
|
||||||
value = IniGetFirstValue(section, keyName, lineNum); |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
return value; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
const IniValue * IniGetNextValue ( |
|
||||||
const IniValue * value, |
|
||||||
unsigned * lineNum |
|
||||||
) { |
|
||||||
if (lineNum) |
|
||||||
*lineNum = 0; |
|
||||||
|
|
||||||
const IniKey * key = value->fKey; |
|
||||||
if (value->fIndex + 1 < key->fValues.Count()) { |
|
||||||
value = key->fValues[value->fIndex + 1]; |
|
||||||
if (lineNum) |
|
||||||
*lineNum = value->fLineNum; |
|
||||||
} |
|
||||||
else { |
|
||||||
value = nil; |
|
||||||
} |
|
||||||
|
|
||||||
return value; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
bool IniGetUnsigned ( |
|
||||||
const IniValue * value, |
|
||||||
unsigned * result, |
|
||||||
unsigned index, |
|
||||||
unsigned defaultValue |
|
||||||
) { |
|
||||||
ASSERT(result); |
|
||||||
|
|
||||||
for (;;) { |
|
||||||
if (!value) |
|
||||||
break; |
|
||||||
|
|
||||||
wchar_t str[32]; |
|
||||||
if (!IniGetString(value, str, arrsize(str), index, nil)) |
|
||||||
break; |
|
||||||
|
|
||||||
if (!str[0]) |
|
||||||
break; |
|
||||||
|
|
||||||
*result = StrToUnsigned(str, nil, 0); |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
*result = defaultValue; |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
bool IniGetString ( |
|
||||||
const IniValue * value, |
|
||||||
wchar_t * result, |
|
||||||
unsigned resultChars, |
|
||||||
unsigned index, |
|
||||||
const wchar_t defaultValue[] |
|
||||||
) { |
|
||||||
ASSERT(result); |
|
||||||
|
|
||||||
bool found = value && index < value->fArgs.Count(); |
|
||||||
|
|
||||||
if (found) |
|
||||||
StrCopy(result, value->fArgs[index], resultChars); |
|
||||||
else if (defaultValue) |
|
||||||
StrCopy(result, defaultValue, resultChars); |
|
||||||
|
|
||||||
return found; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
bool IniGetUuid ( |
|
||||||
const IniValue * value, |
|
||||||
Uuid * uuid, |
|
||||||
unsigned index, |
|
||||||
const Uuid & defaultValue |
|
||||||
) { |
|
||||||
wchar_t str[128]; |
|
||||||
if (IniGetString(value, str, arrsize(str), index, nil)) |
|
||||||
return GuidFromString(str, uuid); |
|
||||||
else |
|
||||||
*uuid = defaultValue; |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
unsigned IniGetBoundedValue ( |
|
||||||
const IniValue * value, |
|
||||||
const wchar_t section[], |
|
||||||
const wchar_t key[], |
|
||||||
unsigned index, |
|
||||||
unsigned minVal, |
|
||||||
unsigned maxVal, |
|
||||||
unsigned defVal |
|
||||||
) { |
|
||||||
if (!value) |
|
||||||
return defVal; |
|
||||||
|
|
||||||
unsigned result; |
|
||||||
IniGetUnsigned(value, &result, index, defVal); |
|
||||||
if ((result < minVal) || (result > maxVal)) { |
|
||||||
result = defVal; |
|
||||||
} |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
unsigned IniGetBoundedValue ( |
|
||||||
const Ini * ini, |
|
||||||
const wchar_t section[], |
|
||||||
const wchar_t key[], |
|
||||||
unsigned index, |
|
||||||
unsigned minVal, |
|
||||||
unsigned maxVal, |
|
||||||
unsigned defVal |
|
||||||
) { |
|
||||||
unsigned lineNum; |
|
||||||
const IniValue * value = IniGetFirstValue( |
|
||||||
ini, |
|
||||||
section, |
|
||||||
key, |
|
||||||
&lineNum |
|
||||||
); |
|
||||||
|
|
||||||
return IniGetBoundedValue( |
|
||||||
value, |
|
||||||
section, |
|
||||||
key, |
|
||||||
index, |
|
||||||
minVal, |
|
||||||
maxVal, |
|
||||||
defVal |
|
||||||
); |
|
||||||
} |
|
@ -1,170 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.h |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINICORE_H |
|
||||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.h included more than once" |
|
||||||
#endif |
|
||||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINICORE_H |
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* Ini file parsing functions |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
struct Ini; |
|
||||||
struct IniKey; |
|
||||||
struct IniValue; |
|
||||||
struct IniSection; |
|
||||||
|
|
||||||
|
|
||||||
// File
|
|
||||||
Ini * IniOpen ( |
|
||||||
const wchar_t filename[] |
|
||||||
); |
|
||||||
void IniClose ( |
|
||||||
Ini * ini |
|
||||||
); |
|
||||||
|
|
||||||
// Section
|
|
||||||
const IniSection * IniGetFirstSection ( |
|
||||||
const Ini * ini, |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
); |
|
||||||
const IniSection * IniGetNextSection ( |
|
||||||
const IniSection * section, |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
); |
|
||||||
const IniSection * IniGetSection ( |
|
||||||
const Ini * ini, |
|
||||||
const wchar_t name[] |
|
||||||
); |
|
||||||
|
|
||||||
// Key
|
|
||||||
const IniKey * IniGetFirstKey ( |
|
||||||
const IniSection * section, |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
); |
|
||||||
const IniKey * IniGetFirstKey ( |
|
||||||
const Ini * ini, |
|
||||||
const wchar_t sectionName[], |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
); |
|
||||||
const IniKey * IniGetNextKey ( |
|
||||||
const IniKey * key, |
|
||||||
wchar_t * name, |
|
||||||
unsigned chars |
|
||||||
); |
|
||||||
const IniKey * IniGetKey ( |
|
||||||
const IniSection * ini, |
|
||||||
const wchar_t name[] |
|
||||||
); |
|
||||||
|
|
||||||
// Value
|
|
||||||
const IniValue * IniGetFirstValue ( |
|
||||||
const IniKey * key, |
|
||||||
unsigned * iter |
|
||||||
); |
|
||||||
const IniValue * IniGetFirstValue ( |
|
||||||
const IniSection * section, |
|
||||||
const wchar_t keyName[], |
|
||||||
unsigned * iter |
|
||||||
); |
|
||||||
const IniValue * IniGetFirstValue ( |
|
||||||
const Ini * ini, |
|
||||||
const wchar_t sectionName[], |
|
||||||
const wchar_t keyName[], |
|
||||||
unsigned * iter |
|
||||||
); |
|
||||||
const IniValue * IniGetNextValue ( |
|
||||||
const IniValue * value, |
|
||||||
unsigned * iter |
|
||||||
); |
|
||||||
|
|
||||||
// Data
|
|
||||||
bool IniGetUnsigned ( |
|
||||||
const IniValue * value, |
|
||||||
unsigned * result, |
|
||||||
unsigned index = 0, |
|
||||||
unsigned defaultValue = 0 |
|
||||||
); |
|
||||||
bool IniGetString ( |
|
||||||
const IniValue * value, |
|
||||||
wchar_t * result, |
|
||||||
unsigned resultChars, |
|
||||||
unsigned index = 0, |
|
||||||
const wchar_t defaultValue[] = nil |
|
||||||
); |
|
||||||
bool IniGetUuid ( |
|
||||||
const IniValue * value, |
|
||||||
Uuid * result, |
|
||||||
unsigned index = 0, |
|
||||||
const Uuid & defaultValue = kNilGuid |
|
||||||
); |
|
||||||
|
|
||||||
// Bounded values
|
|
||||||
unsigned IniGetBoundedValue ( |
|
||||||
const Ini * ini, |
|
||||||
const wchar_t sectionName[], |
|
||||||
const wchar_t keyName[], |
|
||||||
unsigned index, |
|
||||||
unsigned minVal, |
|
||||||
unsigned maxVal, |
|
||||||
unsigned defVal |
|
||||||
); |
|
||||||
unsigned IniGetBoundedValue ( |
|
||||||
const IniValue * value, |
|
||||||
unsigned index, |
|
||||||
unsigned minVal, |
|
||||||
unsigned maxVal, |
|
||||||
unsigned defVal |
|
||||||
); |
|
@ -1,56 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniSrv.cpp |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#include "../Pch.h" |
|
||||||
#pragma hdrstop |
|
||||||
|
|
||||||
|
|
||||||
#ifdef SERVER |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif |
|
@ -1,77 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniSrv.h |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINISRV_H |
|
||||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniSrv.h included more than once" |
|
||||||
#endif |
|
||||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINISRV_H |
|
||||||
|
|
||||||
|
|
||||||
#ifdef SERVER |
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* ServerRights API |
|
||||||
* |
|
||||||
***/ |
|
||||||
|
|
||||||
// These values may never change because server modules
|
|
||||||
// must use the same values as plServer.exe
|
|
||||||
enum EServerRights { |
|
||||||
kSrvRightsNone = 0, |
|
||||||
kSrvRightsBasic = 1, |
|
||||||
kSrvRightsServer = 2, |
|
||||||
kNumSrvRights |
|
||||||
}; |
|
||||||
|
|
||||||
EServerRights SrvIniGetServerRightsByNode (NetAddressNode addrNode); |
|
||||||
EServerRights SrvIniGetServerRights (const NetAddress & addr); |
|
||||||
void SrvIniParseServerRights (Ini * ini); |
|
||||||
|
|
||||||
|
|
||||||
#endif |
|
@ -1,53 +0,0 @@ |
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
|
||||||
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
|
||||||
(or a modified version of those libraries), |
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
|
||||||
licensors of this Program grant you additional |
|
||||||
permission to convey the resulting work. Corresponding Source for a |
|
||||||
non-source form of such a combination shall include the source code for |
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
|
||||||
work. |
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
||||||
or by snail mail at: |
|
||||||
Cyan Worlds, Inc. |
|
||||||
14617 N Newport Hwy |
|
||||||
Mead, WA 99021 |
|
||||||
|
|
||||||
*==LICENSE==*/ |
|
||||||
/*****************************************************************************
|
|
||||||
* |
|
||||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/pnIni.h |
|
||||||
*
|
|
||||||
***/ |
|
||||||
|
|
||||||
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PNINI_H |
|
||||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PNINI_H |
|
||||||
|
|
||||||
#include "Private/pnIniAllIncludes.h" |
|
||||||
|
|
||||||
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PNINI_H
|
|
Loading…
Reference in new issue