mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
Initial import of Sqlite
This commit is contained in:
parent
26e8b0dbb6
commit
c79909eb80
404
dlls/sqlite/CString.h
Executable file
404
dlls/sqlite/CString.h
Executable file
@ -0,0 +1,404 @@
|
||||
/* AMX Mod X
|
||||
*
|
||||
* by the AMX Mod X Development Team
|
||||
* originally developed by OLO
|
||||
*
|
||||
*
|
||||
* 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 2 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, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_CSTRING_H
|
||||
#define _INCLUDE_CSTRING_H
|
||||
|
||||
//by David "BAILOPAN" Anderson
|
||||
class String
|
||||
{
|
||||
public:
|
||||
String()
|
||||
{
|
||||
v = NULL;
|
||||
mSize = 0;
|
||||
cSize = 0;
|
||||
Grow(2);
|
||||
assign("");
|
||||
}
|
||||
|
||||
~String()
|
||||
{
|
||||
if (v)
|
||||
delete [] v;
|
||||
}
|
||||
|
||||
String(const char *src)
|
||||
{
|
||||
v = NULL;
|
||||
mSize = 0;
|
||||
cSize = 0; assign(src);
|
||||
}
|
||||
|
||||
String(String &src)
|
||||
{
|
||||
v = NULL;
|
||||
mSize = 0;
|
||||
cSize = 0;
|
||||
assign(src.c_str());
|
||||
}
|
||||
|
||||
const char *c_str() { return v?v:""; }
|
||||
const char *c_str() const { return v?v:""; }
|
||||
|
||||
void append(const char *t)
|
||||
{
|
||||
Grow(cSize + strlen(t) + 1);
|
||||
strcat(v, t);
|
||||
cSize = strlen(v);
|
||||
}
|
||||
|
||||
void append(const char c)
|
||||
{
|
||||
Grow(cSize + 2);
|
||||
v[cSize] = c;
|
||||
v[++cSize] = 0;
|
||||
}
|
||||
|
||||
void append(String &d)
|
||||
{
|
||||
const char *t = d.c_str();
|
||||
Grow(cSize + strlen(t));
|
||||
strcat(v, t);
|
||||
cSize = strlen(v);
|
||||
}
|
||||
|
||||
void assign(const String &src)
|
||||
{
|
||||
assign(src.c_str());
|
||||
}
|
||||
|
||||
void assign(const char *d)
|
||||
{
|
||||
if (!d)
|
||||
{
|
||||
Grow(1);
|
||||
cSize = 0;
|
||||
strcpy(v, "");
|
||||
return;
|
||||
}
|
||||
Grow(strlen(d));
|
||||
if (v)
|
||||
{
|
||||
strcpy(v, d);
|
||||
cSize = strlen(v);
|
||||
} else {
|
||||
cSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
if (v)
|
||||
{
|
||||
v[0] = 0;
|
||||
cSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int compare (const char *d)
|
||||
{
|
||||
if (v) {
|
||||
if (d) {
|
||||
return strcmp(v, d);
|
||||
} else {
|
||||
return strlen(v);
|
||||
}
|
||||
} else {
|
||||
if (d) {
|
||||
return strlen(d);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Added this for amxx inclusion
|
||||
bool empty()
|
||||
{
|
||||
if (!v || !cSize)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int size()
|
||||
{
|
||||
if (!v)
|
||||
return 0;
|
||||
return cSize;
|
||||
}
|
||||
|
||||
const char * _fread(FILE *fp)
|
||||
{
|
||||
Grow(512);
|
||||
char * ret = fgets(v, 511, fp);
|
||||
cSize = strlen(v);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int find(const char c, int index = 0)
|
||||
{
|
||||
if (!v)
|
||||
return npos;
|
||||
if (index >= (int)cSize || index < 0)
|
||||
return npos;
|
||||
unsigned int i = 0;
|
||||
for (i=index; i<cSize; i++)
|
||||
{
|
||||
if (v[i] == c)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return npos;
|
||||
}
|
||||
|
||||
bool is_space(int c)
|
||||
{
|
||||
if (c == '\f' || c == '\n' ||
|
||||
c == '\t' || c == '\r' ||
|
||||
c == '\v' || c == ' ')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void trim()
|
||||
{
|
||||
if (!v)
|
||||
return;
|
||||
unsigned int i = 0;
|
||||
unsigned int j = 0;
|
||||
|
||||
if (cSize == 1)
|
||||
{
|
||||
if (is_space(v[i]))
|
||||
{
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char c0 = v[0];
|
||||
|
||||
if (is_space(c0))
|
||||
{
|
||||
for (i=0; i<cSize; i++)
|
||||
{
|
||||
if (!is_space(v[i]) || (is_space(v[i]) && ((unsigned char)i==cSize-1)))
|
||||
{
|
||||
erase(0, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cSize = strlen(v);
|
||||
|
||||
if (cSize < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_space(v[cSize-1]))
|
||||
{
|
||||
for (i=cSize-1; i>=0; i--)
|
||||
{
|
||||
if (!is_space(v[i])
|
||||
|| (is_space(v[i]) && i==0))
|
||||
{
|
||||
erase(i+1, j);
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
if (cSize == 1)
|
||||
{
|
||||
if (is_space(v[0]))
|
||||
{
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String & erase(unsigned int start, int num = npos)
|
||||
{
|
||||
if (!v)
|
||||
return (*this);
|
||||
unsigned int i = 0;
|
||||
//check for bounds
|
||||
if (num == npos || start+num > cSize-num+1)
|
||||
num = cSize - start;
|
||||
//do the erasing
|
||||
bool copyflag = false;
|
||||
for (i=0; i<cSize; i++)
|
||||
{
|
||||
if (i>=start && i<start+num)
|
||||
{
|
||||
if (i+num < cSize)
|
||||
{
|
||||
v[i] = v[i+num];
|
||||
} else {
|
||||
v[i] = 0;
|
||||
}
|
||||
copyflag = true;
|
||||
} else if (copyflag) {
|
||||
if (i+num < cSize)
|
||||
{
|
||||
v[i] = v[i+num];
|
||||
} else {
|
||||
v[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
cSize -= num;
|
||||
v[cSize] = 0;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
String substr(unsigned int index, int num = npos)
|
||||
{
|
||||
String ns;
|
||||
|
||||
if (index >= cSize || !v)
|
||||
return ns;
|
||||
|
||||
if (num == npos)
|
||||
{
|
||||
num = cSize - index;
|
||||
} else if (index+num >= cSize) {
|
||||
num = cSize - index;
|
||||
}
|
||||
|
||||
unsigned int i = 0, j=0;
|
||||
char *s = new char[cSize+1];
|
||||
|
||||
for (i=index; i<index+num; i++)
|
||||
{
|
||||
s[j++] = v[i];
|
||||
}
|
||||
s[j] = 0;
|
||||
|
||||
ns.assign(s);
|
||||
|
||||
delete [] s;
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
||||
void toLower()
|
||||
{
|
||||
if (!v)
|
||||
return;
|
||||
unsigned int i = 0;
|
||||
for (i=0; i<cSize; i++)
|
||||
{
|
||||
if (v[i] >= 65 && v[i] <= 90)
|
||||
v[i] |= 32;
|
||||
}
|
||||
}
|
||||
|
||||
String & operator = (const String &src)
|
||||
{
|
||||
assign(src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
String & operator = (const char *src)
|
||||
{
|
||||
assign(src);
|
||||
return *this;
|
||||
|
||||
}
|
||||
|
||||
char operator [] (unsigned int index)
|
||||
{
|
||||
if (index > cSize)
|
||||
{
|
||||
return -1;
|
||||
} else {
|
||||
return v[index];
|
||||
}
|
||||
}
|
||||
|
||||
int at(int a)
|
||||
{
|
||||
if (a < 0 || a >= (int)cSize)
|
||||
return -1;
|
||||
|
||||
return v[a];
|
||||
}
|
||||
|
||||
bool at(int at, char c)
|
||||
{
|
||||
if (at < 0 || at >= (int)cSize)
|
||||
return false;
|
||||
|
||||
v[at] = c;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
void Grow(unsigned int d)
|
||||
{
|
||||
if (d<1)
|
||||
return;
|
||||
if (d > mSize)
|
||||
{
|
||||
mSize = d + 16; // allocate a buffer
|
||||
char *t = new char[d+1];
|
||||
if (v) {
|
||||
strcpy(t, v);
|
||||
t[cSize] = 0;
|
||||
delete [] v;
|
||||
}
|
||||
v = t;
|
||||
mSize = d;
|
||||
}
|
||||
}
|
||||
|
||||
char *v;
|
||||
unsigned int mSize;
|
||||
unsigned int cSize;
|
||||
public:
|
||||
static const int npos = -1;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_CSTRING_H
|
444
dlls/sqlite/CVector.h
Executable file
444
dlls/sqlite/CVector.h
Executable file
@ -0,0 +1,444 @@
|
||||
/* AMX Mod X
|
||||
*
|
||||
* by the AMX Mod X Development Team
|
||||
* originally developed by OLO
|
||||
*
|
||||
*
|
||||
* 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 2 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, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*/
|
||||
|
||||
#ifndef __CVECTOR_H__
|
||||
#define __CVECTOR_H__
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
// Vector
|
||||
template <class T> class CVector
|
||||
{
|
||||
bool Grow()
|
||||
{
|
||||
// automatic grow
|
||||
size_t newSize = m_Size * 2;
|
||||
if (newSize == 0)
|
||||
newSize = 8; // a good init value
|
||||
T *newData = new T[newSize];
|
||||
if (!newData)
|
||||
return false;
|
||||
if (m_Data)
|
||||
{
|
||||
memcpy(newData, m_Data, m_Size * sizeof(T));
|
||||
delete [] m_Data;
|
||||
}
|
||||
m_Data = newData;
|
||||
m_Size = newSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GrowIfNeeded()
|
||||
{
|
||||
if (m_CurrentUsedSize >= m_Size)
|
||||
return Grow();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChangeSize(size_t size)
|
||||
{
|
||||
// change size
|
||||
if (size == m_Size)
|
||||
return true;
|
||||
T *newData = new T[size];
|
||||
if (!newData)
|
||||
return false;
|
||||
if (m_Data)
|
||||
{
|
||||
memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T)));
|
||||
delete [] m_Data;
|
||||
}
|
||||
if (m_Size < size)
|
||||
m_CurrentSize = size;
|
||||
m_Data = newData;
|
||||
m_Size = size;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FreeMemIfPossible()
|
||||
{
|
||||
|
||||
}
|
||||
protected:
|
||||
T *m_Data;
|
||||
size_t m_Size;
|
||||
size_t m_CurrentUsedSize;
|
||||
size_t m_CurrentSize;
|
||||
public:
|
||||
class iterator
|
||||
{
|
||||
protected:
|
||||
T *m_Ptr;
|
||||
public:
|
||||
// constructors / destructors
|
||||
iterator()
|
||||
{
|
||||
m_Ptr = NULL;
|
||||
}
|
||||
|
||||
iterator(T * ptr)
|
||||
{
|
||||
m_Ptr = ptr;
|
||||
}
|
||||
|
||||
// member functions
|
||||
T * base()
|
||||
{
|
||||
return m_Ptr;
|
||||
}
|
||||
|
||||
const T * base() const
|
||||
{
|
||||
return m_Ptr;
|
||||
}
|
||||
|
||||
// operators
|
||||
T & operator*()
|
||||
{
|
||||
return *m_Ptr;
|
||||
}
|
||||
|
||||
T * operator->()
|
||||
{
|
||||
return m_Ptr;
|
||||
}
|
||||
|
||||
iterator & operator++() // preincrement
|
||||
{
|
||||
++m_Ptr;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
iterator operator++(int) // postincrement
|
||||
{
|
||||
iterator tmp = *this;
|
||||
++m_Ptr;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
iterator & operator--() // predecrement
|
||||
{
|
||||
--m_Ptr;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
iterator operator--(int) // postdecrememnt
|
||||
{
|
||||
iterator tmp = *this;
|
||||
--m_Ptr;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
bool operator==(T * right) const
|
||||
{
|
||||
return (m_Ptr == right);
|
||||
}
|
||||
|
||||
bool operator==(const iterator & right) const
|
||||
{
|
||||
return (m_Ptr == right.m_Ptr);
|
||||
}
|
||||
|
||||
bool operator!=(T * right) const
|
||||
{
|
||||
return (m_Ptr != right);
|
||||
}
|
||||
|
||||
bool operator!=(const iterator & right) const
|
||||
{
|
||||
return (m_Ptr != right.m_Ptr);
|
||||
}
|
||||
|
||||
iterator & operator+=(size_t offset)
|
||||
{
|
||||
m_Ptr += offset;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
iterator & operator-=(size_t offset)
|
||||
{
|
||||
m_Ptr += offset;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
iterator operator+(size_t offset) const
|
||||
{
|
||||
iterator tmp(*this);
|
||||
tmp.m_Ptr += offset;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
iterator operator-(size_t offset) const
|
||||
{
|
||||
iterator tmp(*this);
|
||||
tmp.m_Ptr += offset;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
T & operator[](size_t offset)
|
||||
{
|
||||
return (*(*this + offset));
|
||||
}
|
||||
|
||||
const T & operator[](size_t offset) const
|
||||
{
|
||||
return (*(*this + offset));
|
||||
}
|
||||
|
||||
bool operator<(const iterator & right) const
|
||||
{
|
||||
return m_Ptr < right.m_Ptr;
|
||||
}
|
||||
|
||||
bool operator>(const iterator & right) const
|
||||
{
|
||||
return m_Ptr > right.m_Ptr;
|
||||
}
|
||||
|
||||
bool operator<=(const iterator & right) const
|
||||
{
|
||||
return m_Ptr <= right.m_Ptr;
|
||||
}
|
||||
|
||||
bool operator>=(const iterator & right) const
|
||||
{
|
||||
return m_Ptr >= right.m_Ptr;
|
||||
}
|
||||
|
||||
size_t operator-(const iterator & right) const
|
||||
{
|
||||
return m_Ptr - right.m_Ptr;
|
||||
}
|
||||
};
|
||||
|
||||
// constructors / destructors
|
||||
CVector<T>()
|
||||
{
|
||||
m_Size = 0;
|
||||
m_CurrentUsedSize = 0;
|
||||
m_Data = NULL;
|
||||
}
|
||||
|
||||
CVector<T>(const CVector<T> & other)
|
||||
{
|
||||
// copy data
|
||||
m_Data = new T [other.m_Size];
|
||||
m_Size = other.m_Size;
|
||||
m_CurrentUsedSize = other.m_CurrentUsedSize;
|
||||
memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T));
|
||||
}
|
||||
|
||||
~CVector<T>()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
// interface
|
||||
size_t size() const
|
||||
{
|
||||
return m_CurrentUsedSize;
|
||||
}
|
||||
|
||||
size_t capacity() const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
return iterator(m_Data);
|
||||
}
|
||||
|
||||
iterator end()
|
||||
{
|
||||
return iterator(m_Data + m_CurrentUsedSize);
|
||||
}
|
||||
|
||||
iterator iterAt(size_t pos)
|
||||
{
|
||||
if (pos > m_CurrentUsedSize)
|
||||
assert(0);
|
||||
return iterator(m_Data + pos);
|
||||
}
|
||||
|
||||
bool reserve(size_t newSize)
|
||||
{
|
||||
return ChangeSize(newSize);
|
||||
}
|
||||
|
||||
bool push_back(const T & elem)
|
||||
{
|
||||
++m_CurrentUsedSize;
|
||||
if (!GrowIfNeeded())
|
||||
{
|
||||
--m_CurrentUsedSize;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Data[m_CurrentUsedSize - 1] = elem;
|
||||
return true;
|
||||
}
|
||||
|
||||
void pop_back()
|
||||
{
|
||||
--m_CurrentUsedSize;
|
||||
if (m_CurrentUsedSize < 0)
|
||||
m_CurrentUsedSize = 0;
|
||||
// :TODO: free memory sometimes
|
||||
}
|
||||
|
||||
bool resize(size_t newSize)
|
||||
{
|
||||
if (!ChangeSize(newSize))
|
||||
return false;
|
||||
FreeMemIfPossible();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return (m_CurrentUsedSize == 0);
|
||||
}
|
||||
|
||||
T & at(size_t pos)
|
||||
{
|
||||
if (pos > m_CurrentUsedSize)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
return m_Data[pos];
|
||||
}
|
||||
|
||||
const T & at(size_t pos) const
|
||||
{
|
||||
if (pos > m_CurrentUsedSize)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
return m_Data[pos];
|
||||
}
|
||||
|
||||
T & operator[](size_t pos)
|
||||
{
|
||||
return at(pos);
|
||||
}
|
||||
|
||||
const T & operator[](size_t pos) const
|
||||
{
|
||||
return at(pos);
|
||||
}
|
||||
|
||||
T & front()
|
||||
{
|
||||
if (m_CurrentUsedSize < 1)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
return m_Data[0];
|
||||
}
|
||||
|
||||
const T & front() const
|
||||
{
|
||||
if (m_CurrentUsedSize < 1)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
return m_Data[0];
|
||||
}
|
||||
|
||||
T & back()
|
||||
{
|
||||
if (m_CurrentUsedSize < 1)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
return m_Data[m_CurrentUsedSize - 1];
|
||||
}
|
||||
|
||||
const T & back() const
|
||||
{
|
||||
if (m_CurrentUsedSize < 1)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
return m_Data[m_CurrentUsedSize - 1];
|
||||
}
|
||||
|
||||
bool insert(iterator where, const T & value)
|
||||
{
|
||||
// we have to insert before
|
||||
// if it is begin, don't decrement
|
||||
if (where != m_Data)
|
||||
--where;
|
||||
// validate iter
|
||||
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
||||
return false;
|
||||
|
||||
++m_CurrentUsedSize;
|
||||
if (!GrowIfNeeded())
|
||||
{
|
||||
--m_CurrentUsedSize;
|
||||
return false;
|
||||
}
|
||||
|
||||
memmove(where.base() + 1, where.base(), m_CurrentUsedSize - (where - m_Data));
|
||||
memcpy(where.base(), &value, sizeof(T));
|
||||
return true;
|
||||
}
|
||||
|
||||
void erase(iterator where)
|
||||
{
|
||||
// validate iter
|
||||
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
||||
return false;
|
||||
|
||||
if (m_CurrentUsedSize > 1)
|
||||
{
|
||||
// move
|
||||
memmove(where.base(), where.base() + 1, m_CurrentUsedSize - 1);
|
||||
}
|
||||
|
||||
--m_CurrentUsedSize;
|
||||
// :TODO: free memory sometimes
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
m_Size = 0;
|
||||
m_CurrentUsedSize = 0;
|
||||
delete [] m_Data;
|
||||
m_Data = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __CVECTOR_H__
|
||||
|
101
dlls/sqlite/Makefile
Executable file
101
dlls/sqlite/Makefile
Executable file
@ -0,0 +1,101 @@
|
||||
MODNAME = mysql_amxx
|
||||
SRCFILES = mysql.cpp amxxmodule.cpp mysql_amx.cpp
|
||||
|
||||
EXTRA_LIBS_LINUX = -lmysqlclient -lz
|
||||
EXTRA_LIBS_WIN32 = extra/lib_win32/libmysqlclient.a extra/lib_win32/libz.a -lws2_32 -lwsock32
|
||||
EXTRA_LIBDIRS_LINUX = -Lextra/lib_linux
|
||||
EXTRA_LIBDIRS_WIN32 = -Lextra/lib_win32
|
||||
|
||||
EXTRA_INCLUDEDIRS = -Iextra/include -I../amxmodx
|
||||
|
||||
EXTRA_FLAGS = -Dstrcmpi=strcasecmp
|
||||
|
||||
SDKTOP=../hlsdk
|
||||
METADIR=../metamod/metamod
|
||||
|
||||
|
||||
SDKSRC=$(SDKTOP)/SourceCode
|
||||
OBJDIR_LINUX=obj.linux
|
||||
OBJDIR_WIN32=obj.win32
|
||||
SRCDIR=.
|
||||
|
||||
ifdef windir
|
||||
OS=WIN32
|
||||
else
|
||||
OS=LINUX
|
||||
endif
|
||||
|
||||
CC_LINUX=gcc
|
||||
ifeq "$(OS)" "WIN32"
|
||||
CC_WIN32=gcc
|
||||
LD_WINDLL=dllwrap
|
||||
DEFAULT=win32
|
||||
CLEAN=clean_win32
|
||||
else
|
||||
CC_WIN32=/usr/local/cross-tools/i386-mingw32msvc/bin/gcc
|
||||
LD_WINDLL=/usr/local/cross-tools/bin/i386-mingw32msvc-dllwrap
|
||||
DEFAULT=linux win32
|
||||
CLEAN=clean_both
|
||||
endif
|
||||
|
||||
|
||||
|
||||
LIBFILE_LINUX = $(MODNAME)_i386.so
|
||||
LIBFILE_WIN32 = $(MODNAME).dll
|
||||
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX)
|
||||
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
|
||||
|
||||
FILES_ALL = *.cpp *.h [A-Z]* *.rc
|
||||
ifeq "$(OS)" "LINUX"
|
||||
ASRCFILES := $(shell ls -t $(SRCFILES))
|
||||
else
|
||||
ASRCFILES := $(shell dir /b)
|
||||
endif
|
||||
OBJ_LINUX := $(SRCFILES:%.cpp=$(OBJDIR_LINUX)/%.o)
|
||||
OBJ_WIN32 := $(SRCFILES:%.cpp=$(OBJDIR_WIN32)/%.o)
|
||||
|
||||
CCOPT = -march=i386 -O2 -s -DNDEBUG
|
||||
|
||||
INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/pm_shared -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS)
|
||||
CFLAGS=-Wall -Wno-unknown-pragmas
|
||||
ODEF = -DOPT_TYPE=\"optimized\"
|
||||
CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS)
|
||||
|
||||
DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $<
|
||||
DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
|
||||
LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) -o $@
|
||||
LINK_WIN32=$(LD_WINDLL) -mwindows --def $(MODNAME).def --add-stdcall-alias $(OBJ_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@
|
||||
|
||||
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.cpp
|
||||
$(DO_CC_LINUX)
|
||||
|
||||
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.cpp
|
||||
$(DO_CC_WIN32)
|
||||
|
||||
default: $(DEFAULT)
|
||||
|
||||
$(TARGET_LINUX): $(OBJDIR_LINUX) $(OBJ_LINUX)
|
||||
$(LINK_LINUX)
|
||||
|
||||
$(TARGET_WIN32): $(OBJDIR_WIN32) $(OBJ_WIN32)
|
||||
$(LINK_WIN32)
|
||||
|
||||
$(OBJDIR_LINUX):
|
||||
mkdir $@
|
||||
|
||||
$(OBJDIR_WIN32):
|
||||
mkdir $@
|
||||
|
||||
win32: $(TARGET_WIN32)
|
||||
|
||||
linux: $(TARGET_LINUX)
|
||||
|
||||
clean: $(CLEAN)
|
||||
|
||||
clean_both:
|
||||
-rm -f $(OBJDIR_LINUX)/*
|
||||
-rm -f $(OBJDIR_WIN32)/*
|
||||
|
||||
clean_win32:
|
||||
del /q $(OBJDIR_WIN32)
|
||||
|
181
dlls/sqlite/Makefile.pl
Executable file
181
dlls/sqlite/Makefile.pl
Executable file
@ -0,0 +1,181 @@
|
||||
#!/usr/bin/perl
|
||||
#(C)2004 AMX Mod X Development Team
|
||||
# by David "BAILOPAN" Anderson
|
||||
|
||||
# output will occur in bin.x.proc
|
||||
# where x is debug or opt and proc is ix86 or amd64
|
||||
# You must use this script from the project src dir
|
||||
|
||||
#options =
|
||||
# debug - enable gdb debugging
|
||||
# amd64 - compile for AMD64
|
||||
# proc=ix86 - assumed not amd64
|
||||
# clean - clean the specifications above
|
||||
|
||||
$PROJECT = "mysql_amxx";
|
||||
$sdk = "../hlsdk/SourceCode";
|
||||
$mm = "../metamod/metamod";
|
||||
$gccf = "gcc";
|
||||
$mysql_link = "extra/lib_linux";
|
||||
|
||||
@CPP_SOURCE_FILES = ("mysql.cpp", "mysql_amx.cpp", "amxxmodule.cpp");
|
||||
|
||||
@C_SOURCE_FILES = ();
|
||||
my %OPTIONS, %OPT;
|
||||
|
||||
$OPT{"debug"} = "-g -ggdb";
|
||||
$OPT{"opt"} = "-O2 -ffast-math -funroll-loops -fomit-frame-pointer -s -DNDEBUG -Wall -Wno-unknown-pragmas -DOPT_TYPE=\"optimized\" -fno-exceptions -fno-rtti";
|
||||
|
||||
$OPTIONS{"include"} = "-I$sdk -I. -I$mm -I$sdk/engine -I$sdk/common -I$sdk/pm_shared -I$sdk/dlls -Iextra/include";
|
||||
|
||||
while ($cmd = shift)
|
||||
{
|
||||
if ($cmd =~ /amd64/) {
|
||||
$OPTIONS{"amd64"} = 1;
|
||||
} elsif ($cmd =~ /debug/) {
|
||||
$OPTIONS{"debug"} = 1;
|
||||
} elsif ($cmd =~ /proc=i(\d)86/) {
|
||||
$proc = $1;
|
||||
if ($OPTIONS{"amd64"})
|
||||
{
|
||||
die "You cannot compile for i".$proc."86 and AMD64.\n";
|
||||
} else {
|
||||
$OPTIONS{"proc"} = "i".$proc."86";
|
||||
}
|
||||
} elsif ($cmd =~ /clean/) {
|
||||
$OPTIONS{"clean"} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$gcc = `$gccf --version`;
|
||||
if ($gcc =~ /2\.9/)
|
||||
{
|
||||
$OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
|
||||
} else {
|
||||
$OPT{"opt"} .= " -falign-loops=2 -falign-jumps=2 -falign-functions=2";
|
||||
}
|
||||
|
||||
if ($OPTIONS{"debug"})
|
||||
{
|
||||
$cflags = $OPT{"debug"};
|
||||
} else {
|
||||
if (!$OPTIONS{"amd64"})
|
||||
{
|
||||
$proc = $OPTIONS{"proc"};
|
||||
if (!$proc)
|
||||
{
|
||||
$proc = 3;
|
||||
}
|
||||
$cflags = "-march=i".$proc."86 ".$OPT{"opt"};
|
||||
} else {
|
||||
$cflags = $OPT{"opt"};
|
||||
}
|
||||
}
|
||||
|
||||
if ($OPTIONS{"amd64"})
|
||||
{
|
||||
$cflags = " -m64 -DHAVE_I64 -DSMALL_CELL_SIZE=64 $cflags";
|
||||
}
|
||||
|
||||
if ($OPTIONS{"debug"})
|
||||
{
|
||||
$outdir = "bin.debug";
|
||||
} else {
|
||||
$outdir = "bin.opt";
|
||||
}
|
||||
|
||||
if ($OPTIONS{"amd64"})
|
||||
{
|
||||
$outdir .= ".amd64";
|
||||
$bin = $PROJECT."_amd64.so";
|
||||
$OPTIONS{"include"} .= " -L".$mysql_link."64";
|
||||
} else {
|
||||
$proc = $OPTIONS{"proc"};
|
||||
if ($proc)
|
||||
{
|
||||
$outdir .= ".i".$proc."86";
|
||||
$bin = $PROJECT."_i".$proc."86.so";
|
||||
} else {
|
||||
$outdir .= ".i386";
|
||||
$bin = $PROJECT."_i386.so";
|
||||
}
|
||||
$OPTIONS{"include"} .= " -L".$mysql_link;
|
||||
}
|
||||
|
||||
unlink("$outdir/$bin");
|
||||
if ($OPTIONS{"clean"})
|
||||
{
|
||||
`rm $outdir/*.o`;
|
||||
die("Project cleaned.\n");
|
||||
}
|
||||
|
||||
#create the dirs
|
||||
#build link list
|
||||
my @LINK;
|
||||
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
|
||||
{
|
||||
$file = $CPP_SOURCE_FILES[$i];
|
||||
$file =~ s/\.cpp/\.o/;
|
||||
push(@LINK, $outdir."/".$file);
|
||||
}
|
||||
for ($i=0; $i<=$#C_SOURCE_FILES; $i++)
|
||||
{
|
||||
$file = $C_SOURCE_FILES[$i];
|
||||
$file =~ s/\.c/\.o/;
|
||||
push(@LINK, $outdir."/".$file);
|
||||
}
|
||||
|
||||
if (!(-d $outdir))
|
||||
{
|
||||
mkdir($outdir);
|
||||
}
|
||||
|
||||
$inc = $OPTIONS{"include"};
|
||||
|
||||
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
|
||||
{
|
||||
$file = $CPP_SOURCE_FILES[$i];
|
||||
$ofile = $file;
|
||||
$ofile =~ s/\.cpp/\.o/;
|
||||
$ofile = "$outdir/$ofile";
|
||||
$gcc = "$gccf $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
|
||||
if (-e $ofile)
|
||||
{
|
||||
$file_time = (stat($file))[9];
|
||||
$ofile_time = (stat($ofile))[9];
|
||||
if ($file_time > $ofile_time)
|
||||
{
|
||||
print "$gcc\n";
|
||||
`$gcc`;
|
||||
}
|
||||
} else {
|
||||
print "$gcc\n";
|
||||
`$gcc`;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
|
||||
{
|
||||
$file = $C_SOURCE_FILES[$i];
|
||||
$ofile = $file;
|
||||
$ofile =~ s/\.c/\.o/;
|
||||
$ofile = "$outdir/$ofile";
|
||||
$gcc = "cc $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
|
||||
if (-e $ofile)
|
||||
{
|
||||
$file_time = (stat($file))[9];
|
||||
$ofile_time = (stat($ofile))[9];
|
||||
if ($file_time > $ofile_time)
|
||||
{
|
||||
print "$gcc\n";
|
||||
`$gcc`;
|
||||
}
|
||||
} else {
|
||||
print "$gcc\n";
|
||||
`$gcc`;
|
||||
}
|
||||
}
|
||||
|
||||
$gcc = "$gccf $cflags $inc -shared -ldl -lm @LINK -lmysqlclient -lz -o $outdir/$bin";
|
||||
print "$gcc\n";
|
||||
`$gcc`;
|
3042
dlls/sqlite/amxxmodule.cpp
Executable file
3042
dlls/sqlite/amxxmodule.cpp
Executable file
File diff suppressed because it is too large
Load Diff
2197
dlls/sqlite/amxxmodule.h
Executable file
2197
dlls/sqlite/amxxmodule.h
Executable file
File diff suppressed because it is too large
Load Diff
468
dlls/sqlite/moduleconfig.h
Executable file
468
dlls/sqlite/moduleconfig.h
Executable file
@ -0,0 +1,468 @@
|
||||
// Configuration
|
||||
|
||||
#ifndef __MODULECONFIG_H__
|
||||
#define __MODULECONFIG_H__
|
||||
|
||||
// Module info
|
||||
<<<<<<< moduleconfig.h
|
||||
#define MODULE_NAME "Sqlite"
|
||||
#define MODULE_VERSION "1.00"
|
||||
=======
|
||||
#define MODULE_NAME "MySQL"
|
||||
#define MODULE_VERSION "1.01"
|
||||
>>>>>>> 1.7
|
||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||
#define MODULE_URL "http://www.amxmodx.org/"
|
||||
#define MODULE_LOGTAG "SQLITE"
|
||||
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
|
||||
#define MODULE_RELOAD_ON_MAPCHANGE
|
||||
|
||||
#ifdef __DATE__
|
||||
#define MODULE_DATE __DATE__
|
||||
#else // __DATE__
|
||||
#define MODULE_DATE "Unknown"
|
||||
#endif // __DATE__
|
||||
|
||||
// metamod plugin?
|
||||
#define USE_METAMOD
|
||||
|
||||
// - AMXX Init functions
|
||||
// Also consider using FN_META_*
|
||||
// AMXX query
|
||||
//#define FN_AMXX_QUERY OnAmxxQuery
|
||||
// AMXX attach
|
||||
// Do native functions init here (MF_AddNatives)
|
||||
#define FN_AMXX_ATTACH OnAmxxAttach
|
||||
// AMXX dettach
|
||||
//#define FN_AMXX_DETTACH OnAmxxDettach
|
||||
// All plugins loaded
|
||||
// Do forward functions init here (MF_RegisterForward)
|
||||
// #define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||
|
||||
/**** METAMOD ****/
|
||||
// If your module doesn't use metamod, you may close the file now :)
|
||||
#ifdef USE_METAMOD
|
||||
// ----
|
||||
// Hook Functions
|
||||
// Uncomment these to be called
|
||||
// You can also change the function name
|
||||
|
||||
// - Metamod init functions
|
||||
// Also consider using FN_AMXX_*
|
||||
// Meta query
|
||||
//#define FN_META_QUERY OnMetaQuery
|
||||
// Meta attach
|
||||
//#define FN_META_ATTACH OnMetaAttach
|
||||
// Meta dettach
|
||||
//#define FN_META_DETTACH OnMetaDettach
|
||||
|
||||
// (wd) are Will Day's notes
|
||||
// - GetEntityAPI2 functions
|
||||
// #define FN_GameDLLInit GameDLLInit /* pfnGameInit() */
|
||||
// #define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
|
||||
// #define FN_DispatchThink DispatchThink /* pfnThink() */
|
||||
// #define FN_DispatchUse DispatchUse /* pfnUse() */
|
||||
// #define FN_DispatchTouch DispatchTouch /* pfnTouch() */
|
||||
// #define FN_DispatchBlocked DispatchBlocked /* pfnBlocked() */
|
||||
// #define FN_DispatchKeyValue DispatchKeyValue /* pfnKeyValue() */
|
||||
// #define FN_DispatchSave DispatchSave /* pfnSave() */
|
||||
// #define FN_DispatchRestore DispatchRestore /* pfnRestore() */
|
||||
// #define FN_DispatchObjectCollsionBox DispatchObjectCollsionBox /* pfnSetAbsBox() */
|
||||
// #define FN_SaveWriteFields SaveWriteFields /* pfnSaveWriteFields() */
|
||||
// #define FN_SaveReadFields SaveReadFields /* pfnSaveReadFields() */
|
||||
// #define FN_SaveGlobalState SaveGlobalState /* pfnSaveGlobalState() */
|
||||
// #define FN_RestoreGlobalState RestoreGlobalState /* pfnRestoreGlobalState() */
|
||||
// #define FN_ResetGlobalState ResetGlobalState /* pfnResetGlobalState() */
|
||||
// #define FN_ClientConnect ClientConnect /* pfnClientConnect() (wd) Client has connected */
|
||||
// #define FN_ClientDisconnect ClientDisconnect /* pfnClientDisconnect() (wd) Player has left the game */
|
||||
// #define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */
|
||||
// #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */
|
||||
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
|
||||
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
|
||||
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
|
||||
#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
||||
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
|
||||
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
|
||||
// #define FN_StartFrame StartFrame /* pfnStartFrame() */
|
||||
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */
|
||||
// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */
|
||||
// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */
|
||||
// #define FN_PlayerCustomization PlayerCustomization /* pfnPlayerCustomization() Notifies .dll of new customization for player. */
|
||||
// #define FN_SpectatorConnect SpectatorConnect /* pfnSpectatorConnect() Called when spectator joins server */
|
||||
// #define FN_SpectatorDisconnect SpectatorDisconnect /* pfnSpectatorDisconnect() Called when spectator leaves the server */
|
||||
// #define FN_SpectatorThink SpectatorThink /* pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t) */
|
||||
// #define FN_Sys_Error Sys_Error /* pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2 */
|
||||
// #define FN_PM_Move PM_Move /* pfnPM_Move() (wd) SDK2 */
|
||||
// #define FN_PM_Init PM_Init /* pfnPM_Init() Server version of player movement initialization; (wd) SDK2 */
|
||||
// #define FN_PM_FindTextureType PM_FindTextureType /* pfnPM_FindTextureType() (wd) SDK2 */
|
||||
// #define FN_SetupVisibility SetupVisibility /* pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 */
|
||||
// #define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */
|
||||
// #define FN_AddToFullPack AddToFullPack /* pfnAddToFullPack() (wd) SDK2 */
|
||||
// #define FN_CreateBaseline CreateBaseline /* pfnCreateBaseline() Tweak entity baseline for network encoding allows setup of player baselines too.; (wd) SDK2 */
|
||||
// #define FN_RegisterEncoders RegisterEncoders /* pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 */
|
||||
// #define FN_GetWeaponData GetWeaponData /* pfnGetWeaponData() (wd) SDK2 */
|
||||
// #define FN_CmdStart CmdStart /* pfnCmdStart() (wd) SDK2 */
|
||||
// #define FN_CmdEnd CmdEnd /* pfnCmdEnd() (wd) SDK2 */
|
||||
// #define FN_ConnectionlessPacket ConnectionlessPacket /* pfnConnectionlessPacket() (wd) SDK2 */
|
||||
// #define FN_GetHullBounds GetHullBounds /* pfnGetHullBounds() (wd) SDK2 */
|
||||
// #define FN_CreateInstancedBaselines CreateInstancedBaselines /* pfnCreateInstancedBaselines() (wd) SDK2 */
|
||||
// #define FN_InconsistentFile InconsistentFile /* pfnInconsistentFile() (wd) SDK2 */
|
||||
// #define FN_AllowLagCompensation AllowLagCompensation /* pfnAllowLagCompensation() (wd) SDK2 */
|
||||
|
||||
// - GetEntityAPI2_Post functions
|
||||
// #define FN_GameDLLInit_Post GameDLLInit_Post
|
||||
// #define FN_DispatchSpawn_Post DispatchSpawn_Post
|
||||
// #define FN_DispatchThink_Post DispatchThink_Post
|
||||
// #define FN_DispatchUse_Post DispatchUse_Post
|
||||
// #define FN_DispatchTouch_Post DispatchTouch_Post
|
||||
// #define FN_DispatchBlocked_Post DispatchBlocked_Post
|
||||
// #define FN_DispatchKeyValue_Post DispatchKeyValue_Post
|
||||
// #define FN_DispatchSave_Post DispatchSave_Post
|
||||
// #define FN_DispatchRestore_Post DispatchRestore_Post
|
||||
// #define FN_DispatchObjectCollsionBox_Post DispatchObjectCollsionBox_Post
|
||||
// #define FN_SaveWriteFields_Post SaveWriteFields_Post
|
||||
// #define FN_SaveReadFields_Post SaveReadFields_Post
|
||||
// #define FN_SaveGlobalState_Post SaveGlobalState_Post
|
||||
// #define FN_RestoreGlobalState_Post RestoreGlobalState_Post
|
||||
// #define FN_ResetGlobalState_Post ResetGlobalState_Post
|
||||
// #define FN_ClientConnect_Post ClientConnect_Post
|
||||
// #define FN_ClientDisconnect_Post ClientDisconnect_Post
|
||||
// #define FN_ClientKill_Post ClientKill_Post
|
||||
// #define FN_ClientPutInServer_Post ClientPutInServer_Post
|
||||
// #define FN_ClientCommand_Post ClientCommand_Post
|
||||
// #define FN_ClientUserInfoChanged_Post ClientUserInfoChanged_Post
|
||||
// #define FN_ServerActivate_Post ServerActivate_Post
|
||||
// #define FN_ServerDeactivate_Post ServerDeactivate_Post
|
||||
// #define FN_PlayerPreThink_Post PlayerPreThink_Post
|
||||
// #define FN_PlayerPostThink_Post PlayerPostThink_Post
|
||||
// #define FN_StartFrame_Post StartFrame_Post
|
||||
// #define FN_ParmsNewLevel_Post ParmsNewLevel_Post
|
||||
// #define FN_ParmsChangeLevel_Post ParmsChangeLevel_Post
|
||||
// #define FN_GetGameDescription_Post GetGameDescription_Post
|
||||
// #define FN_PlayerCustomization_Post PlayerCustomization_Post
|
||||
// #define FN_SpectatorConnect_Post SpectatorConnect_Post
|
||||
// #define FN_SpectatorDisconnect_Post SpectatorDisconnect_Post
|
||||
// #define FN_SpectatorThink_Post SpectatorThink_Post
|
||||
// #define FN_Sys_Error_Post Sys_Error_Post
|
||||
// #define FN_PM_Move_Post PM_Move_Post
|
||||
// #define FN_PM_Init_Post PM_Init_Post
|
||||
// #define FN_PM_FindTextureType_Post PM_FindTextureType_Post
|
||||
// #define FN_SetupVisibility_Post SetupVisibility_Post
|
||||
// #define FN_UpdateClientData_Post UpdateClientData_Post
|
||||
// #define FN_AddToFullPack_Post AddToFullPack_Post
|
||||
// #define FN_CreateBaseline_Post CreateBaseline_Post
|
||||
// #define FN_RegisterEncoders_Post RegisterEncoders_Post
|
||||
// #define FN_GetWeaponData_Post GetWeaponData_Post
|
||||
// #define FN_CmdStart_Post CmdStart_Post
|
||||
// #define FN_CmdEnd_Post CmdEnd_Post
|
||||
// #define FN_ConnectionlessPacket_Post ConnectionlessPacket_Post
|
||||
// #define FN_GetHullBounds_Post GetHullBounds_Post
|
||||
// #define FN_CreateInstancedBaselines_Post CreateInstancedBaselines_Post
|
||||
// #define FN_InconsistentFile_Post InconsistentFile_Post
|
||||
// #define FN_AllowLagCompensation_Post AllowLagCompensation_Post
|
||||
|
||||
// - GetEngineAPI functions
|
||||
// #define FN_PrecacheModel PrecacheModel
|
||||
// #define FN_PrecacheSound PrecacheSound
|
||||
// #define FN_SetModel SetModel
|
||||
// #define FN_ModelIndex ModelIndex
|
||||
// #define FN_ModelFrames ModelFrames
|
||||
// #define FN_SetSize SetSize
|
||||
// #define FN_ChangeLevel ChangeLevel
|
||||
// #define FN_GetSpawnParms GetSpawnParms
|
||||
// #define FN_SaveSpawnParms SaveSpawnParms
|
||||
// #define FN_VecToYaw VecToYaw
|
||||
// #define FN_VecToAngles VecToAngles
|
||||
// #define FN_MoveToOrigin MoveToOrigin
|
||||
// #define FN_ChangeYaw ChangeYaw
|
||||
// #define FN_ChangePitch ChangePitch
|
||||
// #define FN_FindEntityByString FindEntityByString
|
||||
// #define FN_GetEntityIllum GetEntityIllum
|
||||
// #define FN_FindEntityInSphere FindEntityInSphere
|
||||
// #define FN_FindClientInPVS FindClientInPVS
|
||||
// #define FN_EntitiesInPVS EntitiesInPVS
|
||||
// #define FN_MakeVectors MakeVectors
|
||||
// #define FN_AngleVectors AngleVectors
|
||||
// #define FN_CreateEntity CreateEntity
|
||||
// #define FN_RemoveEntity RemoveEntity
|
||||
// #define FN_CreateNamedEntity CreateNamedEntity
|
||||
// #define FN_MakeStatic MakeStatic
|
||||
// #define FN_EntIsOnFloor EntIsOnFloor
|
||||
// #define FN_DropToFloor DropToFloor
|
||||
// #define FN_WalkMove WalkMove
|
||||
// #define FN_SetOrigin SetOrigin
|
||||
// #define FN_EmitSound EmitSound
|
||||
// #define FN_EmitAmbientSound EmitAmbientSound
|
||||
// #define FN_TraceLine TraceLine
|
||||
// #define FN_TraceToss TraceToss
|
||||
// #define FN_TraceMonsterHull TraceMonsterHull
|
||||
// #define FN_TraceHull TraceHull
|
||||
// #define FN_TraceModel TraceModel
|
||||
// #define FN_TraceTexture TraceTexture
|
||||
// #define FN_TraceSphere TraceSphere
|
||||
// #define FN_GetAimVector GetAimVector
|
||||
// #define FN_ServerCommand ServerCommand
|
||||
// #define FN_ServerExecute ServerExecute
|
||||
// #define FN_engClientCommand engClientCommand
|
||||
// #define FN_ParticleEffect ParticleEffect
|
||||
// #define FN_LightStyle LightStyle
|
||||
// #define FN_DecalIndex DecalIndex
|
||||
// #define FN_PointContents PointContents
|
||||
// #define FN_MessageBegin MessageBegin
|
||||
// #define FN_MessageEnd MessageEnd
|
||||
// #define FN_WriteByte WriteByte
|
||||
// #define FN_WriteChar WriteChar
|
||||
// #define FN_WriteShort WriteShort
|
||||
// #define FN_WriteLong WriteLong
|
||||
// #define FN_WriteAngle WriteAngle
|
||||
// #define FN_WriteCoord WriteCoord
|
||||
// #define FN_WriteString WriteString
|
||||
// #define FN_WriteEntity WriteEntity
|
||||
// #define FN_CVarRegister CVarRegister
|
||||
// #define FN_CVarGetFloat CVarGetFloat
|
||||
// #define FN_CVarGetString CVarGetString
|
||||
// #define FN_CVarSetFloat CVarSetFloat
|
||||
// #define FN_CVarSetString CVarSetString
|
||||
// #define FN_AlertMessage AlertMessage
|
||||
// #define FN_EngineFprintf EngineFprintf
|
||||
// #define FN_PvAllocEntPrivateData PvAllocEntPrivateData
|
||||
// #define FN_PvEntPrivateData PvEntPrivateData
|
||||
// #define FN_FreeEntPrivateData FreeEntPrivateData
|
||||
// #define FN_SzFromIndex SzFromIndex
|
||||
// #define FN_AllocString AllocString
|
||||
// #define FN_GetVarsOfEnt GetVarsOfEnt
|
||||
// #define FN_PEntityOfEntOffset PEntityOfEntOffset
|
||||
// #define FN_EntOffsetOfPEntity EntOffsetOfPEntity
|
||||
// #define FN_IndexOfEdict IndexOfEdict
|
||||
// #define FN_PEntityOfEntIndex PEntityOfEntIndex
|
||||
// #define FN_FindEntityByVars FindEntityByVars
|
||||
// #define FN_GetModelPtr GetModelPtr
|
||||
// #define FN_RegUserMsg RegUserMsg
|
||||
// #define FN_AnimationAutomove AnimationAutomove
|
||||
// #define FN_GetBonePosition GetBonePosition
|
||||
// #define FN_FunctionFromName FunctionFromName
|
||||
// #define FN_NameForFunction NameForFunction
|
||||
// #define FN_ClientPrintf ClientPrintf
|
||||
// #define FN_ServerPrint ServerPrint
|
||||
// #define FN_Cmd_Args Cmd_Args
|
||||
// #define FN_Cmd_Argv Cmd_Argv
|
||||
// #define FN_Cmd_Argc Cmd_Argc
|
||||
// #define FN_GetAttachment GetAttachment
|
||||
// #define FN_CRC32_Init CRC32_Init
|
||||
// #define FN_CRC32_ProcessBuffer CRC32_ProcessBuffer
|
||||
// #define FN_CRC32_ProcessByte CRC32_ProcessByte
|
||||
// #define FN_CRC32_Final CRC32_Final
|
||||
// #define FN_RandomLong RandomLong
|
||||
// #define FN_RandomFloat RandomFloat
|
||||
// #define FN_SetView SetView
|
||||
// #define FN_Time Time
|
||||
// #define FN_CrosshairAngle CrosshairAngle
|
||||
// #define FN_LoadFileForMe LoadFileForMe
|
||||
// #define FN_FreeFile FreeFile
|
||||
// #define FN_EndSection EndSection
|
||||
// #define FN_CompareFileTime CompareFileTime
|
||||
// #define FN_GetGameDir GetGameDir
|
||||
// #define FN_Cvar_RegisterVariable Cvar_RegisterVariable
|
||||
// #define FN_FadeClientVolume FadeClientVolume
|
||||
// #define FN_SetClientMaxspeed SetClientMaxspeed
|
||||
// #define FN_CreateFakeClient CreateFakeClient
|
||||
// #define FN_RunPlayerMove RunPlayerMove
|
||||
// #define FN_NumberOfEntities NumberOfEntities
|
||||
// #define FN_GetInfoKeyBuffer GetInfoKeyBuffer
|
||||
// #define FN_InfoKeyValue InfoKeyValue
|
||||
// #define FN_SetKeyValue SetKeyValue
|
||||
// #define FN_SetClientKeyValue SetClientKeyValue
|
||||
// #define FN_IsMapValid IsMapValid
|
||||
// #define FN_StaticDecal StaticDecal
|
||||
// #define FN_PrecacheGeneric PrecacheGeneric
|
||||
// #define FN_GetPlayerUserId GetPlayerUserId
|
||||
// #define FN_BuildSoundMsg BuildSoundMsg
|
||||
// #define FN_IsDedicatedServer IsDedicatedServer
|
||||
// #define FN_CVarGetPointer CVarGetPointer
|
||||
// #define FN_GetPlayerWONId GetPlayerWONId
|
||||
// #define FN_Info_RemoveKey Info_RemoveKey
|
||||
// #define FN_GetPhysicsKeyValue GetPhysicsKeyValue
|
||||
// #define FN_SetPhysicsKeyValue SetPhysicsKeyValue
|
||||
// #define FN_GetPhysicsInfoString GetPhysicsInfoString
|
||||
// #define FN_PrecacheEvent PrecacheEvent
|
||||
// #define FN_PlaybackEvent PlaybackEvent
|
||||
// #define FN_SetFatPVS SetFatPVS
|
||||
// #define FN_SetFatPAS SetFatPAS
|
||||
// #define FN_CheckVisibility CheckVisibility
|
||||
// #define FN_DeltaSetField DeltaSetField
|
||||
// #define FN_DeltaUnsetField DeltaUnsetField
|
||||
// #define FN_DeltaAddEncoder DeltaAddEncoder
|
||||
// #define FN_GetCurrentPlayer GetCurrentPlayer
|
||||
// #define FN_CanSkipPlayer CanSkipPlayer
|
||||
// #define FN_DeltaFindField DeltaFindField
|
||||
// #define FN_DeltaSetFieldByIndex DeltaSetFieldByIndex
|
||||
// #define FN_DeltaUnsetFieldByIndex DeltaUnsetFieldByIndex
|
||||
// #define FN_SetGroupMask SetGroupMask
|
||||
// #define FN_engCreateInstancedBaseline engCreateInstancedBaseline
|
||||
// #define FN_Cvar_DirectSet Cvar_DirectSet
|
||||
// #define FN_ForceUnmodified ForceUnmodified
|
||||
// #define FN_GetPlayerStats GetPlayerStats
|
||||
// #define FN_AddServerCommand AddServerCommand
|
||||
// #define FN_Voice_GetClientListening Voice_GetClientListening
|
||||
// #define FN_Voice_SetClientListening Voice_SetClientListening
|
||||
// #define FN_GetPlayerAuthId GetPlayerAuthId
|
||||
|
||||
// - GetEngineAPI_Post functions
|
||||
// #define FN_PrecacheModel_Post PrecacheModel_Post
|
||||
// #define FN_PrecacheSound_Post PrecacheSound_Post
|
||||
// #define FN_SetModel_Post SetModel_Post
|
||||
// #define FN_ModelIndex_Post ModelIndex_Post
|
||||
// #define FN_ModelFrames_Post ModelFrames_Post
|
||||
// #define FN_SetSize_Post SetSize_Post
|
||||
// #define FN_ChangeLevel_Post ChangeLevel_Post
|
||||
// #define FN_GetSpawnParms_Post GetSpawnParms_Post
|
||||
// #define FN_SaveSpawnParms_Post SaveSpawnParms_Post
|
||||
// #define FN_VecToYaw_Post VecToYaw_Post
|
||||
// #define FN_VecToAngles_Post VecToAngles_Post
|
||||
// #define FN_MoveToOrigin_Post MoveToOrigin_Post
|
||||
// #define FN_ChangeYaw_Post ChangeYaw_Post
|
||||
// #define FN_ChangePitch_Post ChangePitch_Post
|
||||
// #define FN_FindEntityByString_Post FindEntityByString_Post
|
||||
// #define FN_GetEntityIllum_Post GetEntityIllum_Post
|
||||
// #define FN_FindEntityInSphere_Post FindEntityInSphere_Post
|
||||
// #define FN_FindClientInPVS_Post FindClientInPVS_Post
|
||||
// #define FN_EntitiesInPVS_Post EntitiesInPVS_Post
|
||||
// #define FN_MakeVectors_Post MakeVectors_Post
|
||||
// #define FN_AngleVectors_Post AngleVectors_Post
|
||||
// #define FN_CreateEntity_Post CreateEntity_Post
|
||||
// #define FN_RemoveEntity_Post RemoveEntity_Post
|
||||
// #define FN_CreateNamedEntity_Post CreateNamedEntity_Post
|
||||
// #define FN_MakeStatic_Post MakeStatic_Post
|
||||
// #define FN_EntIsOnFloor_Post EntIsOnFloor_Post
|
||||
// #define FN_DropToFloor_Post DropToFloor_Post
|
||||
// #define FN_WalkMove_Post WalkMove_Post
|
||||
// #define FN_SetOrigin_Post SetOrigin_Post
|
||||
// #define FN_EmitSound_Post EmitSound_Post
|
||||
// #define FN_EmitAmbientSound_Post EmitAmbientSound_Post
|
||||
// #define FN_TraceLine_Post TraceLine_Post
|
||||
// #define FN_TraceToss_Post TraceToss_Post
|
||||
// #define FN_TraceMonsterHull_Post TraceMonsterHull_Post
|
||||
// #define FN_TraceHull_Post TraceHull_Post
|
||||
// #define FN_TraceModel_Post TraceModel_Post
|
||||
// #define FN_TraceTexture_Post TraceTexture_Post
|
||||
// #define FN_TraceSphere_Post TraceSphere_Post
|
||||
// #define FN_GetAimVector_Post GetAimVector_Post
|
||||
// #define FN_ServerCommand_Post ServerCommand_Post
|
||||
// #define FN_ServerExecute_Post ServerExecute_Post
|
||||
// #define FN_engClientCommand_Post engClientCommand_Post
|
||||
// #define FN_ParticleEffect_Post ParticleEffect_Post
|
||||
// #define FN_LightStyle_Post LightStyle_Post
|
||||
// #define FN_DecalIndex_Post DecalIndex_Post
|
||||
// #define FN_PointContents_Post PointContents_Post
|
||||
// #define FN_MessageBegin_Post MessageBegin_Post
|
||||
// #define FN_MessageEnd_Post MessageEnd_Post
|
||||
// #define FN_WriteByte_Post WriteByte_Post
|
||||
// #define FN_WriteChar_Post WriteChar_Post
|
||||
// #define FN_WriteShort_Post WriteShort_Post
|
||||
// #define FN_WriteLong_Post WriteLong_Post
|
||||
// #define FN_WriteAngle_Post WriteAngle_Post
|
||||
// #define FN_WriteCoord_Post WriteCoord_Post
|
||||
// #define FN_WriteString_Post WriteString_Post
|
||||
// #define FN_WriteEntity_Post WriteEntity_Post
|
||||
// #define FN_CVarRegister_Post CVarRegister_Post
|
||||
// #define FN_CVarGetFloat_Post CVarGetFloat_Post
|
||||
// #define FN_CVarGetString_Post CVarGetString_Post
|
||||
// #define FN_CVarSetFloat_Post CVarSetFloat_Post
|
||||
// #define FN_CVarSetString_Post CVarSetString_Post
|
||||
// #define FN_AlertMessage_Post AlertMessage_Post
|
||||
// #define FN_EngineFprintf_Post EngineFprintf_Post
|
||||
// #define FN_PvAllocEntPrivateData_Post PvAllocEntPrivateData_Post
|
||||
// #define FN_PvEntPrivateData_Post PvEntPrivateData_Post
|
||||
// #define FN_FreeEntPrivateData_Post FreeEntPrivateData_Post
|
||||
// #define FN_SzFromIndex_Post SzFromIndex_Post
|
||||
// #define FN_AllocString_Post AllocString_Post
|
||||
// #define FN_GetVarsOfEnt_Post GetVarsOfEnt_Post
|
||||
// #define FN_PEntityOfEntOffset_Post PEntityOfEntOffset_Post
|
||||
// #define FN_EntOffsetOfPEntity_Post EntOffsetOfPEntity_Post
|
||||
// #define FN_IndexOfEdict_Post IndexOfEdict_Post
|
||||
// #define FN_PEntityOfEntIndex_Post PEntityOfEntIndex_Post
|
||||
// #define FN_FindEntityByVars_Post FindEntityByVars_Post
|
||||
// #define FN_GetModelPtr_Post GetModelPtr_Post
|
||||
// #define FN_RegUserMsg_Post RegUserMsg_Post
|
||||
// #define FN_AnimationAutomove_Post AnimationAutomove_Post
|
||||
// #define FN_GetBonePosition_Post GetBonePosition_Post
|
||||
// #define FN_FunctionFromName_Post FunctionFromName_Post
|
||||
// #define FN_NameForFunction_Post NameForFunction_Post
|
||||
// #define FN_ClientPrintf_Post ClientPrintf_Post
|
||||
// #define FN_ServerPrint_Post ServerPrint_Post
|
||||
// #define FN_Cmd_Args_Post Cmd_Args_Post
|
||||
// #define FN_Cmd_Argv_Post Cmd_Argv_Post
|
||||
// #define FN_Cmd_Argc_Post Cmd_Argc_Post
|
||||
// #define FN_GetAttachment_Post GetAttachment_Post
|
||||
// #define FN_CRC32_Init_Post CRC32_Init_Post
|
||||
// #define FN_CRC32_ProcessBuffer_Post CRC32_ProcessBuffer_Post
|
||||
// #define FN_CRC32_ProcessByte_Post CRC32_ProcessByte_Post
|
||||
// #define FN_CRC32_Final_Post CRC32_Final_Post
|
||||
// #define FN_RandomLong_Post RandomLong_Post
|
||||
// #define FN_RandomFloat_Post RandomFloat_Post
|
||||
// #define FN_SetView_Post SetView_Post
|
||||
// #define FN_Time_Post Time_Post
|
||||
// #define FN_CrosshairAngle_Post CrosshairAngle_Post
|
||||
// #define FN_LoadFileForMe_Post LoadFileForMe_Post
|
||||
// #define FN_FreeFile_Post FreeFile_Post
|
||||
// #define FN_EndSection_Post EndSection_Post
|
||||
// #define FN_CompareFileTime_Post CompareFileTime_Post
|
||||
// #define FN_GetGameDir_Post GetGameDir_Post
|
||||
// #define FN_Cvar_RegisterVariable_Post Cvar_RegisterVariable_Post
|
||||
// #define FN_FadeClientVolume_Post FadeClientVolume_Post
|
||||
// #define FN_SetClientMaxspeed_Post SetClientMaxspeed_Post
|
||||
// #define FN_CreateFakeClient_Post CreateFakeClient_Post
|
||||
// #define FN_RunPlayerMove_Post RunPlayerMove_Post
|
||||
// #define FN_NumberOfEntities_Post NumberOfEntities_Post
|
||||
// #define FN_GetInfoKeyBuffer_Post GetInfoKeyBuffer_Post
|
||||
// #define FN_InfoKeyValue_Post InfoKeyValue_Post
|
||||
// #define FN_SetKeyValue_Post SetKeyValue_Post
|
||||
// #define FN_SetClientKeyValue_Post SetClientKeyValue_Post
|
||||
// #define FN_IsMapValid_Post IsMapValid_Post
|
||||
// #define FN_StaticDecal_Post StaticDecal_Post
|
||||
// #define FN_PrecacheGeneric_Post PrecacheGeneric_Post
|
||||
// #define FN_GetPlayerUserId_Post GetPlayerUserId_Post
|
||||
// #define FN_BuildSoundMsg_Post BuildSoundMsg_Post
|
||||
// #define FN_IsDedicatedServer_Post IsDedicatedServer_Post
|
||||
// #define FN_CVarGetPointer_Post CVarGetPointer_Post
|
||||
// #define FN_GetPlayerWONId_Post GetPlayerWONId_Post
|
||||
// #define FN_Info_RemoveKey_Post Info_RemoveKey_Post
|
||||
// #define FN_GetPhysicsKeyValue_Post GetPhysicsKeyValue_Post
|
||||
// #define FN_SetPhysicsKeyValue_Post SetPhysicsKeyValue_Post
|
||||
// #define FN_GetPhysicsInfoString_Post GetPhysicsInfoString_Post
|
||||
// #define FN_PrecacheEvent_Post PrecacheEvent_Post
|
||||
// #define FN_PlaybackEvent_Post PlaybackEvent_Post
|
||||
// #define FN_SetFatPVS_Post SetFatPVS_Post
|
||||
// #define FN_SetFatPAS_Post SetFatPAS_Post
|
||||
// #define FN_CheckVisibility_Post CheckVisibility_Post
|
||||
// #define FN_DeltaSetField_Post DeltaSetField_Post
|
||||
// #define FN_DeltaUnsetField_Post DeltaUnsetField_Post
|
||||
// #define FN_DeltaAddEncoder_Post DeltaAddEncoder_Post
|
||||
// #define FN_GetCurrentPlayer_Post GetCurrentPlayer_Post
|
||||
// #define FN_CanSkipPlayer_Post CanSkipPlayer_Post
|
||||
// #define FN_DeltaFindField_Post DeltaFindField_Post
|
||||
// #define FN_DeltaSetFieldByIndex_Post DeltaSetFieldByIndex_Post
|
||||
// #define FN_DeltaUnsetFieldByIndex_Post DeltaUnsetFieldByIndex_Post
|
||||
// #define FN_SetGroupMask_Post SetGroupMask_Post
|
||||
// #define FN_engCreateInstancedBaseline_Post engCreateInstancedBaseline_Post
|
||||
// #define FN_Cvar_DirectSet_Post Cvar_DirectSet_Post
|
||||
// #define FN_ForceUnmodified_Post ForceUnmodified_Post
|
||||
// #define FN_GetPlayerStats_Post GetPlayerStats_Post
|
||||
// #define FN_AddServerCommand_Post AddServerCommand_Post
|
||||
// #define FN_Voice_GetClientListening_Post Voice_GetClientListening_Post
|
||||
// #define FN_Voice_SetClientListening_Post Voice_SetClientListening_Post
|
||||
// #define FN_GetPlayerAuthId_Post GetPlayerAuthId_Post
|
||||
|
||||
// #define FN_OnFreeEntPrivateData OnFreeEntPrivateData
|
||||
// #define FN_GameShutdown GameShutdown
|
||||
// #define FN_ShouldCollide ShouldCollide
|
||||
|
||||
// #define FN_OnFreeEntPrivateData_Post OnFreeEntPrivateData_Post
|
||||
// #define FN_GameShutdown_Post GameShutdown_Post
|
||||
// #define FN_ShouldCollide_Post ShouldCollide_Post
|
||||
|
||||
|
||||
#endif // USE_METAMOD
|
||||
|
||||
#endif // __MODULECONFIG_H__
|
||||
|
460
dlls/sqlite/sqlite.cpp
Executable file
460
dlls/sqlite/sqlite.cpp
Executable file
@ -0,0 +1,460 @@
|
||||
/* AMX Mod X
|
||||
* MySQL Module
|
||||
*
|
||||
* by the AMX Mod X Development Team
|
||||
*
|
||||
* This file is part of AMX Mod X.
|
||||
*
|
||||
*
|
||||
* 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 2 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, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "sqlite_amx.h"
|
||||
|
||||
unsigned int lastDb;
|
||||
|
||||
CVector<SQLResult*> Results;
|
||||
CVector<SQL*> DBList;
|
||||
|
||||
// ///////////////////////////////
|
||||
// Sqlite natives for AMX scripting
|
||||
// ///////////////////////////////
|
||||
|
||||
// sql = mysql_connect(host[],user[],pass[],dbname[],error[],maxlength) :
|
||||
// - open connection
|
||||
// not used: host, user, pass
|
||||
static cell AMX_NATIVE_CALL sql_connect(AMX *amx, cell *params) // 6 param
|
||||
{
|
||||
int i = 0;
|
||||
int id = -1;
|
||||
//char *host = MF_GetAmxString(amx,params[1], 0, &i);
|
||||
//char *user = MF_GetAmxString(amx,params[2], 1, &i);
|
||||
//char *pass = MF_GetAmxString(amx,params[3], 2, &i);
|
||||
char *dbname = MF_GetAmxString(amx,params[4], 3, &i);
|
||||
i = 0;
|
||||
|
||||
if (!strlen(dbname)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Recieved invalid parameter.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SQL *c=NULL;
|
||||
|
||||
for (i=0; (unsigned int)i<DBList.size(); i++) {
|
||||
if (DBList[i]->isFree) {
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (id>=0) {
|
||||
c = DBList[id];
|
||||
} else {
|
||||
c = new SQL;
|
||||
DBList.push_back(c);
|
||||
id = (unsigned int)(DBList.size() - 1);
|
||||
}
|
||||
|
||||
if (!c->Connect(dbname))
|
||||
{
|
||||
if (c->ErrorStr.size() < 1)
|
||||
{
|
||||
c->Error();
|
||||
}
|
||||
MF_SetAmxString(amx, params[5], c->ErrorStr.c_str(), params[6]);
|
||||
return CONNECT_FAILED;
|
||||
}
|
||||
|
||||
MF_SetAmxString(amx,params[5],"",params[6]);
|
||||
|
||||
lastDb = id;
|
||||
|
||||
return id+1;
|
||||
}
|
||||
|
||||
// mysql_error(sql,dest[],maxlength)
|
||||
// - store maxlength characters from mysql error in current row to dest
|
||||
static cell AMX_NATIVE_CALL sql_error(AMX *amx, cell *params) // 3 params
|
||||
{
|
||||
unsigned int id = params[1]-1;
|
||||
if (id >= DBList.size() || DBList[id]->isFree)
|
||||
id = lastDb;
|
||||
|
||||
SQL *sql = DBList[id];
|
||||
|
||||
if (sql->ErrorStr.size() > 1)
|
||||
{
|
||||
MF_SetAmxString(amx, params[2], sql->ErrorStr.c_str(), params[3]);
|
||||
sql->ErrorStr.assign("");
|
||||
return 1;
|
||||
} else {
|
||||
sql->Error();
|
||||
if (sql->ErrorStr.size() > 1)
|
||||
{
|
||||
MF_SetAmxString(amx, params[2], sql->ErrorStr.c_str(), params[3]);
|
||||
sql->ErrorStr.assign("");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
MF_SetAmxString(amx, params[2], "", params[3]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// mysql_query(sql,query[]) - returns 0 on success, <0 on failure, >0 on result set
|
||||
static cell AMX_NATIVE_CALL sql_query(AMX *amx, cell *params) // 2 params
|
||||
{
|
||||
unsigned int id = params[1]-1;
|
||||
|
||||
if (id >= DBList.size() || DBList[id]->isFree) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid database handle %d", id);
|
||||
return QUERY_FAILED;
|
||||
}
|
||||
|
||||
lastDb = id;
|
||||
|
||||
int len = 0;
|
||||
const char *query = MF_FormatAmxString(amx, params, 2, &len);
|
||||
|
||||
SQL *sql = DBList[id];
|
||||
|
||||
return sql->Query(query); //Return the result set handle, if any
|
||||
}
|
||||
|
||||
// the OLD mysql_query
|
||||
static cell AMX_NATIVE_CALL mysql_query(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1]-1;
|
||||
|
||||
if (id >= DBList.size() || DBList[id]->isFree) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid database handle %d", id);
|
||||
return QUERY_FAILED;
|
||||
}
|
||||
|
||||
lastDb = id;
|
||||
|
||||
int len = 0;
|
||||
const char *query = MF_FormatAmxString(amx, params, 2, &len);
|
||||
|
||||
SQL *sql = DBList[id];
|
||||
|
||||
return sql->Query(query, 1); //Return the result set handle, if any
|
||||
}
|
||||
|
||||
// mysql_nextrow(sql) :
|
||||
// - read next row
|
||||
// - return :
|
||||
// . number of line
|
||||
// . 0 at end
|
||||
static cell AMX_NATIVE_CALL sql_nextrow(AMX *amx, cell *params) // 1 param
|
||||
{
|
||||
unsigned int id = params[1]-1;
|
||||
|
||||
if (id == -1)
|
||||
{
|
||||
//the user should have checked, but we'll return 0 anyway
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (id >= Results.size() || Results[id]->isFree)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQLResult *Result = Results[id];
|
||||
|
||||
return Result->Nextrow();
|
||||
}
|
||||
|
||||
// old version
|
||||
static cell AMX_NATIVE_CALL mysql_nextrow(AMX *amx, cell *params) // 1 param
|
||||
{
|
||||
if (Results.size() < 1)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQLResult *Result = Results[0];
|
||||
|
||||
return Result->Nextrow();
|
||||
}
|
||||
|
||||
// mysql_close(sql) :
|
||||
// - free result
|
||||
// - close connection
|
||||
static cell AMX_NATIVE_CALL sql_close(AMX *amx, cell *params) // 1 param
|
||||
{
|
||||
cell *addr = MF_GetAmxAddr(amx, params[1]);
|
||||
unsigned int id = (*addr) - 1;
|
||||
if (id >= DBList.size() || DBList[id]->isFree) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid database handle %d", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lastDb = id;
|
||||
|
||||
SQL *sql = DBList[id];
|
||||
|
||||
sql->Disconnect();
|
||||
|
||||
*addr = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Returns a field from a query result handle.
|
||||
// 2 param - returns integer
|
||||
// 3 param - stores float in cell byref
|
||||
// 4 param - stores string
|
||||
static cell AMX_NATIVE_CALL sql_getfield(AMX *amx, cell *params) // 2-4 params
|
||||
{
|
||||
unsigned int id = params[1]-1;
|
||||
|
||||
if (id >= Results.size() || Results[id]->isFree)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d.", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQLResult *Result = Results[id];
|
||||
if (Result->m_rowCount == 0)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Record set is empty.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int numParams = (*params)/sizeof(cell);
|
||||
cell *fAddr = NULL;
|
||||
const char *field = Result->GetField(params[2]-1);
|
||||
if (field == NULL)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Field error.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (numParams)
|
||||
{
|
||||
case 2:
|
||||
return atoi(field);
|
||||
break;
|
||||
case 3:
|
||||
fAddr = MF_GetAmxAddr(amx, params[3]);
|
||||
*fAddr = amx_ftoc((REAL)atof(field));
|
||||
return 1;
|
||||
break;
|
||||
case 4:
|
||||
return MF_SetAmxString(amx, params[3], field?field:"", *(MF_GetAmxAddr(amx, params[4])));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Mysql version
|
||||
static cell AMX_NATIVE_CALL mysql_getfield(AMX *amx, cell *params) // 2-4 params
|
||||
{
|
||||
unsigned int id = params[2];
|
||||
|
||||
if (Results.size() < 1)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQLResult *Result = Results[0];
|
||||
cell *fAddr = NULL;
|
||||
const char *field = Result->GetField(id);
|
||||
if (field == NULL)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown error");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return MF_SetAmxString(amx, params[3], field?field:"", *(MF_GetAmxAddr(amx, params[4])));
|
||||
}
|
||||
|
||||
//Returns a field from a query result handle.
|
||||
// 2 param - returns integer
|
||||
// 3 param - stores float in cell byref
|
||||
// 4 param - stores string
|
||||
static cell AMX_NATIVE_CALL sql_getresult(AMX *amx, cell *params) // 4 params
|
||||
{
|
||||
unsigned int id = params[1]-1;
|
||||
|
||||
if (id >= Results.size())
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQLResult *Result = Results[id];
|
||||
int numParams = (*params)/sizeof(cell);
|
||||
cell *fAddr = NULL;
|
||||
int len = 0;
|
||||
const char *column = MF_GetAmxString(amx, params[2], 0, &len);
|
||||
const char *field = Result->GetField(column);
|
||||
if (field == NULL)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown error");
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (numParams)
|
||||
{
|
||||
case 2:
|
||||
return atoi(field);
|
||||
break;
|
||||
case 3:
|
||||
fAddr = MF_GetAmxAddr(amx, params[3]);
|
||||
*fAddr = amx_ftoc((REAL)atof(field));
|
||||
return 1;
|
||||
break;
|
||||
case 4:
|
||||
len = *(MF_GetAmxAddr(amx, params[4]));
|
||||
return MF_SetAmxString(amx, params[3], field?field:"", params[4]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL sql_free_result(AMX *amx, cell *params)
|
||||
{
|
||||
cell *addr = (MF_GetAmxAddr(amx, params[1]));
|
||||
unsigned int id = (*addr) - 1;
|
||||
|
||||
if (id == -1)
|
||||
{
|
||||
//the user should have checked, but we'll return 0 anyway
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (id >= Results.size())
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQLResult *Result = Results[id];
|
||||
|
||||
*addr = 0;
|
||||
|
||||
if (Result->isFree) {
|
||||
MF_PrintSrvConsole("***ERROR: Tried to free result %d, but the result was already free!\n", id + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result->FreeResult();
|
||||
|
||||
#if defined _DEBUG
|
||||
if (id + 1 == SQLResult::latestStoredResultId)
|
||||
MF_PrintSrvConsole("***FREED: %d\n", id + 1);
|
||||
else
|
||||
MF_PrintSrvConsole("***FREED: %d WARNING LAST STORED: %d!\n", id + 1, SQLResult::latestStoredResultId);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL sql_num_rows(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1]-1;
|
||||
|
||||
if (id == -1)
|
||||
{
|
||||
//the user should have checked, but we'll return 0 anyway
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (id >= Results.size() || Results[id]->isFree)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQLResult *Result = Results[id];
|
||||
|
||||
return (cell)Result->NumRows();
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL sql_type(AMX *amx, cell *params)
|
||||
{
|
||||
return MF_SetAmxString(amx, params[1], "sqlite", params[2]);
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO mysql_Natives[] = {
|
||||
{ "dbi_connect", sql_connect },
|
||||
{ "dbi_query", sql_query },
|
||||
{ "dbi_field", sql_getfield },
|
||||
{ "dbi_nextrow", sql_nextrow },
|
||||
{ "dbi_close", sql_close },
|
||||
{ "dbi_error", sql_error },
|
||||
{ "dbi_type", sql_type },
|
||||
{ "dbi_free_result", sql_free_result },
|
||||
{ "dbi_num_rows", sql_num_rows },
|
||||
{ "dbi_result", sql_getresult },
|
||||
{ "mysql_connect", sql_connect },
|
||||
{ "mysql_query", mysql_query },
|
||||
{ "mysql_getfield", mysql_getfield },
|
||||
{ "mysql_nextrow", mysql_nextrow },
|
||||
{ "mysql_close", sql_close },
|
||||
{ "mysql_error", sql_error },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
void OnAmxxAttach()
|
||||
{
|
||||
SQLResult *Dump = new SQLResult;
|
||||
Dump->isFree = false;
|
||||
Results.push_back(Dump);
|
||||
MF_AddNatives(mysql_Natives);
|
||||
}
|
||||
|
||||
void ServerDeactivate()
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (i=0; i<Results.size(); i++)
|
||||
{
|
||||
if (!Results[i]->isFree)
|
||||
Results[i]->FreeResult();
|
||||
delete Results[i];
|
||||
}
|
||||
for (i=0; i<DBList.size(); i++)
|
||||
{
|
||||
DBList[i]->Disconnect();
|
||||
delete DBList[i];
|
||||
}
|
||||
Results.clear();
|
||||
DBList.clear();
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
278
dlls/sqlite/sqlite_amx.cpp
Executable file
278
dlls/sqlite/sqlite_amx.cpp
Executable file
@ -0,0 +1,278 @@
|
||||
#include "sqlite_amx.h"
|
||||
|
||||
SQL::SQL()
|
||||
{
|
||||
isFree = true;
|
||||
sqlite = NULL;
|
||||
}
|
||||
|
||||
SQL::~SQL()
|
||||
{
|
||||
if (!isFree)
|
||||
Disconnect();
|
||||
}
|
||||
int SQL::Error()
|
||||
{
|
||||
if (sqlite == NULL)
|
||||
return 0;
|
||||
|
||||
ErrorCode = sqlite3_errcode(sqlite);
|
||||
ErrorStr.assign(sqlite3_errmsg(sqlite));
|
||||
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
int SQL::Connect(const char *base)
|
||||
{
|
||||
Database.assign(base);
|
||||
|
||||
isFree = false;
|
||||
int err = 0;
|
||||
|
||||
this->ErrorCode = sqlite3_open(Database.c_str(), &sqlite);
|
||||
if (ErrorCode != SQLITE_OK) {
|
||||
err = Error();
|
||||
if (err)
|
||||
{
|
||||
MF_Log("DB Connection failed(%d): %s", err, sqlite3_errmsg(sqlite));
|
||||
sqlite3_close(sqlite);
|
||||
isFree = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
isFree = false;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SQL::Disconnect()
|
||||
{
|
||||
Database.clear();
|
||||
|
||||
if (sqlite != NULL)
|
||||
sqlite3_close(sqlite);
|
||||
|
||||
sqlite = NULL;
|
||||
|
||||
isFree = true;
|
||||
}
|
||||
|
||||
int SQL::Query(const char *query, int OLD)
|
||||
{
|
||||
if (sqlite == NULL || isFree)
|
||||
{
|
||||
ErrorCode = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (OLD)
|
||||
{
|
||||
if (Results.size() < 1)
|
||||
{
|
||||
SQLResult *t = new SQLResult;
|
||||
Results.push_back(t);
|
||||
} else {
|
||||
if (!Results[0]->isFree)
|
||||
Results[0]->FreeResult();
|
||||
}
|
||||
return (Results[0]->Query(this, query)==0);
|
||||
}
|
||||
|
||||
unsigned int i = 0;
|
||||
int id = -1;
|
||||
for (i=0; i < Results.size(); i++)
|
||||
{
|
||||
if (Results[i]->isFree) {
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (id < 0) {
|
||||
|
||||
SQLResult *p = new SQLResult;
|
||||
|
||||
int ret = p->Query(this, query);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
delete p;
|
||||
|
||||
if (ret == -1)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
} else {
|
||||
Results.push_back(p);
|
||||
#if defined _DEBUG
|
||||
MF_PrintSrvConsole("***STORE: %d (push_back)\n", Results.size());
|
||||
SQLResult::latestStoredResultId = Results.size();
|
||||
#endif
|
||||
|
||||
return Results.size();
|
||||
}
|
||||
} else {
|
||||
SQLResult *r = Results[id];
|
||||
int ret = Results[id]->Query(this, query);
|
||||
if (ret != 0)
|
||||
{
|
||||
if (ret == -1)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
} else {
|
||||
#if defined _DEBUG
|
||||
MF_PrintSrvConsole("***STORE: %d\n", id + 1);
|
||||
SQLResult::latestStoredResultId = id + 1;
|
||||
#endif
|
||||
return (id + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SQLResult::SQLResult()
|
||||
{
|
||||
isFree = true;
|
||||
m_fieldNames = 0;
|
||||
m_hasData = false;
|
||||
m_currentRow = -1;
|
||||
m_data = NULL;
|
||||
m_errorMsg = NULL;
|
||||
m_rowCount = 0;
|
||||
m_columnCount = 0;
|
||||
}
|
||||
|
||||
SQLResult::~SQLResult()
|
||||
{
|
||||
if (!isFree)
|
||||
FreeResult();
|
||||
}
|
||||
|
||||
int SQLResult::Query(SQL *cn, const char *query)
|
||||
{
|
||||
/*
|
||||
int sqlite3_get_table(
|
||||
sqlite3*, // An open database
|
||||
const char *sql, // SQL to be executed
|
||||
char ***resultp, // Result written to a char *[] that this points to
|
||||
int *nrow, // Number of result rows written here
|
||||
int *ncolumn, // Number of result columns written here
|
||||
char **errmsg // Error msg written here
|
||||
);
|
||||
*/
|
||||
int rowCount, columnCount;
|
||||
int result = sqlite3_get_table(cn->sqlite, query, &m_data, &rowCount, &columnCount, &m_errorMsg);
|
||||
m_rowCount = rowCount;
|
||||
m_columnCount = columnCount;
|
||||
if (result != SQLITE_OK)
|
||||
{
|
||||
MF_Log("Query error: %s", m_errorMsg);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
m_hasData = true;
|
||||
this->m_fieldNames = new String[m_columnCount];
|
||||
for (unsigned int i = 0; i < m_columnCount; i++)
|
||||
m_fieldNames[i].assign(m_data[i]);
|
||||
|
||||
#if defined _DEBUG
|
||||
MF_PrintSrvConsole("SQLite: Select query returned %d rows in %d columns.\n", m_rowCount, m_columnCount);
|
||||
for (unsigned int i = 0; i < m_columnCount; i++) {
|
||||
MF_PrintSrvConsole("%15s", m_fieldNames[i].c_str());
|
||||
}
|
||||
MF_PrintSrvConsole("\n");
|
||||
for (unsigned int i = 0; i < m_rowCount; i++) {
|
||||
for (unsigned int j = 0; j < m_columnCount; j++) {
|
||||
MF_PrintSrvConsole("%15s", m_data[(1 + i) * m_columnCount + j]);
|
||||
}
|
||||
MF_PrintSrvConsole("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
isFree = false;
|
||||
return 0; // Return 0 here? and 1 on error... 0's get stored and 1's get deleted
|
||||
}
|
||||
|
||||
bool SQLResult::Nextrow()
|
||||
{
|
||||
if (isFree)
|
||||
return false;
|
||||
|
||||
if (++m_currentRow >= (int)this->m_rowCount) {
|
||||
//m_currentRow = -1; <-- this is probably bad and inconsistent...
|
||||
//FreeResult(); <-- this is probably bad and inconsistent... freeing should be the responsibility of the scripter
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SQLResult::FreeResult()
|
||||
{
|
||||
if (isFree)
|
||||
return;
|
||||
/*
|
||||
#if defined _DEBUG
|
||||
MF_PrintSrvConsole("FREEING a result!\n");
|
||||
#endif
|
||||
*/
|
||||
isFree = true;
|
||||
|
||||
if (m_hasData) {
|
||||
sqlite3_free_table(m_data);
|
||||
|
||||
delete [] this->m_fieldNames;
|
||||
|
||||
m_hasData = false;
|
||||
}
|
||||
|
||||
m_currentRow = -1;
|
||||
m_columnCount = 0;
|
||||
m_rowCount = 0;
|
||||
}
|
||||
|
||||
const char *SQLResult::GetField(unsigned int field)
|
||||
{
|
||||
if (isFree || field >= m_columnCount || m_currentRow < 0 || m_currentRow >= (int)m_rowCount)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_data[(m_currentRow + 1) * m_columnCount + field];
|
||||
}
|
||||
|
||||
const char *SQLResult::GetField(const char *field)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
int id = -1;
|
||||
if (field == NULL)
|
||||
return NULL;
|
||||
for (i=0; i < m_columnCount; i++)
|
||||
{
|
||||
if (strcmp(m_fieldNames[i].c_str(), field) == 0)
|
||||
{
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (id<0 || id>=(int)m_columnCount)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return GetField(id);
|
||||
}
|
||||
|
||||
unsigned int SQLResult::NumRows()
|
||||
{
|
||||
if (isFree)
|
||||
return 0;
|
||||
|
||||
return m_rowCount;
|
||||
}
|
||||
#if defined _DEBUG
|
||||
unsigned int SQLResult::latestStoredResultId = 0;
|
||||
#endif
|
68
dlls/sqlite/sqlite_amx.h
Executable file
68
dlls/sqlite/sqlite_amx.h
Executable file
@ -0,0 +1,68 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifndef __linux__
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
#include "CVector.h"
|
||||
#include "CString.h"
|
||||
#include "sqlite3.h"
|
||||
|
||||
#define MEM_ALLOC_FAILED -20
|
||||
#define CONNECT_FAILED -10
|
||||
#define QUERY_FAILED -5
|
||||
|
||||
#include "amxxmodule.h"
|
||||
|
||||
class SQL
|
||||
{
|
||||
public:
|
||||
SQL();
|
||||
~SQL();
|
||||
int Connect(/*const char *host, const char *user, const char *pass,*/ const char *base);
|
||||
int Query(const char *query, int OLD=0);
|
||||
void Disconnect();
|
||||
int Error();
|
||||
|
||||
sqlite3 *sqlite;
|
||||
|
||||
String ErrorStr;
|
||||
int ErrorCode;
|
||||
|
||||
String Database;
|
||||
|
||||
bool isFree;
|
||||
};
|
||||
|
||||
class SQLResult
|
||||
{
|
||||
public:
|
||||
SQLResult();
|
||||
~SQLResult();
|
||||
int Query(SQL *cn, const char *query);
|
||||
bool Nextrow();
|
||||
void FreeResult();
|
||||
const char *GetField(unsigned int field);
|
||||
const char *GetField(const char *field);
|
||||
unsigned int NumRows();
|
||||
|
||||
String *m_fieldNames;
|
||||
bool isFree;
|
||||
int m_currentRow;
|
||||
bool m_hasData;
|
||||
|
||||
char **m_data;
|
||||
char *m_errorMsg;
|
||||
unsigned int m_rowCount, m_columnCount;
|
||||
#if defined _DEBUG
|
||||
static unsigned int latestStoredResultId;
|
||||
#endif
|
||||
};
|
||||
|
||||
char *amx_string(AMX *amx, cell ¶m, int &len);
|
||||
|
||||
extern CVector<SQLResult*> Results;
|
||||
extern CVector<SQL*> DBList;
|
||||
|
Loading…
Reference in New Issue
Block a user