Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Iswenzz committed Mar 27, 2021
2 parents 03787f1 + b4f6440 commit 3b632f3
Show file tree
Hide file tree
Showing 16 changed files with 1,112 additions and 500 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
gsclib.so
gsclib.dll
.ignore
compile.bat
compile.bat
build/
40 changes: 16 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
``gsclib`` acts as a standard library extension for the Call of Duty 4 scripting language. The features this library provides consists of an FTP/FTPS/SFTP client, an HTTP/HTTPS client, Regular Expression (RegEx) support, Language Integrated Query (Linq) support, a MySQL connector for databases, casting/type conversion and other type utilities, and much more. More detailed information on each feature can be found in the documentation section.

## Features & Documentation

* [HTTP/HTTPS client](https://github.com/Iswenzz/gsclib/blob/master/docs/https.md)
* [FTP/FTPS/SFTP client](https://github.com/Iswenzz/gsclib/blob/master/docs/ftp.md)
* [Regular expression](https://github.com/Iswenzz/gsclib/blob/master/docs/regex.md)
Expand All @@ -19,37 +18,27 @@ In order to use this library, just download the archived file down below, and ex

## Building (Linux)
_Pre-Requisites:_

Debian/Ubuntu 32-bit:

sudo apt install nasm paxctl build-essential

Debian/Ubuntu 64-bit:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install nasm:i386 build-essential gcc-multilib g++-multilib

openSUSE 32-bit:

sudo zypper install nasm gcc-32bit gcc-c++-32bit

Arch Linux 32-bit:

yaourt -S nasm paxctl gcc-multilib make
1. Recompile your server with:
```c
#define MAX_SCRIPTFUNCTIONS 256
```
2. [CGSC](https://github.com/Iswenzz/CGSC) and it's pre-requisites.
_Build Command (Linux):_
make
make install
***Note:***
``gsclib`` can be compiled without CGSC features with ``make nocgsc``target.
``gsclib`` can be compiled without CGSC features with ``make nocgsc`` target.
## Building (Windows)
_Pre-Requisites:_
1. [CGSC](https://github.com/Iswenzz/CGSC)
2. Windows [MinGW-W64 GCC-7.3.0](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/7.3.0/threads-win32/dwarf/i686-7.3.0-release-win32-dwarf-rt_v5-rev0.7z)
1. Recompile your server with:
```c
#define MAX_SCRIPTFUNCTIONS 256
```
2. [CGSC](https://github.com/Iswenzz/CGSC) and it's pre-requisites.
3. Windows [Cygwin](https://www.cygwin.com/) or [Git for Windows](https://gitforwindows.org/)

_Build Command (Windows):_
Expand All @@ -58,9 +47,12 @@ _Build Command (Windows):_
mingw32-make install

***Note:***
``gsclib`` can be compiled without CGSC features with ``make nocgsc``target.
``gsclib`` can be compiled without CGSC features with ``mingw32-make nocgsc`` target.

## [Download](https://github.com/Iswenzz/gsclib/releases)

### [Download](https://github.com/Iswenzz/gsclib/releases)
## Troubleshouting
For resolving missing dependencies you can use the [ldd](https://man7.org/linux/man-pages/man1/ldd.1.html) command for Linux, and [Dependency Walker](https://www.dependencywalker.com/) for Windows.

## Contributors:
***Note:*** If you would like to contribute to this repository, feel free to send a pull request, and I will review your code. Also feel free to post about any problems that may arise in the issues section of the repository.
54 changes: 31 additions & 23 deletions deps/mysql/windows/include/binary_log_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,37 @@ extern "C"
*/

typedef enum enum_field_types {
MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
MYSQL_TYPE_BIT,
MYSQL_TYPE_TIMESTAMP2,
MYSQL_TYPE_DATETIME2,
MYSQL_TYPE_TIME2,
MYSQL_TYPE_JSON=245,
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,
MYSQL_TYPE_TINY_BLOB=249,
MYSQL_TYPE_MEDIUM_BLOB=250,
MYSQL_TYPE_LONG_BLOB=251,
MYSQL_TYPE_BLOB=252,
MYSQL_TYPE_VAR_STRING=253,
MYSQL_TYPE_STRING=254,
MYSQL_TYPE_GEOMETRY=255
MYSQL_TYPE_DECIMAL = 0,
MYSQL_TYPE_TINY = 1,
MYSQL_TYPE_SHORT = 2,
MYSQL_TYPE_LONG = 3,
MYSQL_TYPE_FLOAT = 4,
MYSQL_TYPE_DOUBLE = 5,
MYSQL_TYPE_NULL = 6,
MYSQL_TYPE_TIMESTAMP = 7,
MYSQL_TYPE_LONGLONG = 8,
MYSQL_TYPE_INT24 = 9,
MYSQL_TYPE_DATE = 10,
MYSQL_TYPE_TIME = 11,
MYSQL_TYPE_DATETIME = 12,
MYSQL_TYPE_YEAR = 13,
MYSQL_TYPE_NEWDATE = 14,
MYSQL_TYPE_VARCHAR = 15,
MYSQL_TYPE_BIT = 16,
MYSQL_TYPE_TIMESTAMP2 = 17,
MYSQL_TYPE_DATETIME2 = 18,
MYSQL_TYPE_TIME2 = 19,
MYSQL_TYPE_JSON = 245,
MYSQL_TYPE_NEWDECIMAL = 246,
MYSQL_TYPE_ENUM = 247,
MYSQL_TYPE_SET = 248,
MYSQL_TYPE_TINY_BLOB = 249,
MYSQL_TYPE_MEDIUM_BLOB = 250,
MYSQL_TYPE_LONG_BLOB = 251,
MYSQL_TYPE_BLOB = 252,
MYSQL_TYPE_VAR_STRING = 253,
MYSQL_TYPE_STRING = 254,
MYSQL_TYPE_GEOMETRY = 255
} enum_field_types;

#define DATETIME_MAX_DECIMALS 6
Expand Down
2 changes: 2 additions & 0 deletions docs/ftp.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# FTP/FTPS/SFTP

### :warning: **Requests are not thread safe, you'll need your own scripts in GSC !**

#### ``SFTP_Connect(<host>, <user>, <password>, <port>)``
Connect to an SFTP server, the connection can be closed with FTP_Close.

Expand Down
2 changes: 2 additions & 0 deletions docs/https.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# HTTP/HTTPS

### :warning: **Requests are not thread safe, you'll need your own scripts in GSC !**

#### ``HTTPS_GetFile(<filepath>, <url>)``
Save a file from HTTP/HTTPS url.

Expand Down
127 changes: 123 additions & 4 deletions docs/mysql.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# MySQL

### :warning: **Requests are not thread safe, you'll need your own scripts in GSC !**

### MySQL types for prepared statement:
```c
level.MYSQL_TYPE_DECIMAL = 0;
level.MYSQL_TYPE_TINY = 1;
level.MYSQL_TYPE_SHORT = 2;
level.MYSQL_TYPE_LONG = 3;
level.MYSQL_TYPE_FLOAT = 4;
level.MYSQL_TYPE_DOUBLE = 5;
level.MYSQL_TYPE_NULL = 6;
level.MYSQL_TYPE_TIMESTAMP = 7;
level.MYSQL_TYPE_LONGLONG = 8;
level.MYSQL_TYPE_INT24 = 9;
level.MYSQL_TYPE_DATE = 10;
level.MYSQL_TYPE_TIME = 11;
level.MYSQL_TYPE_DATETIME = 12;
level.MYSQL_TYPE_YEAR = 13;
level.MYSQL_TYPE_NEWDATE = 14;
level.MYSQL_TYPE_VARCHAR = 15;
level.MYSQL_TYPE_BIT = 16;
level.MYSQL_TYPE_TIMESTAMP2 = 17;
level.MYSQL_TYPE_DATETIME2 = 18;
level.MYSQL_TYPE_TIME2 = 19;
level.MYSQL_TYPE_JSON = 245;
level.MYSQL_TYPE_NEWDECIMAL = 246;
level.MYSQL_TYPE_ENUM = 247;
level.MYSQL_TYPE_SET = 248;
level.MYSQL_TYPE_TINY_BLOB = 249;
level.MYSQL_TYPE_MEDIUM_BLOB = 250;
level.MYSQL_TYPE_LONG_BLOB = 251;
level.MYSQL_TYPE_BLOB = 252;
level.MYSQL_TYPE_VAR_STRING = 253;
level.MYSQL_TYPE_STRING = 254;
level.MYSQL_TYPE_GEOMETRY = 255;
```

#### ``SQL_Version()``
Print information about the MySQL client.

Expand Down Expand Up @@ -55,16 +92,67 @@ SQL_SelectDB("testdb");
<hr>
#### ``SQL_Query(<query string>)``
Command for performing a statement on the database server.
Command for performing a query on the database server.
Usage Example:
```c
SQL_Query("SELECT * FROM players");
```
<hr>

#### ``SQL_Prepare(<query string>)``
Command for performing a statement on the database server, binds must be set in order.

Usage Example:
```c
printVariable(SQL_Prepare("SELECT name, guid, rank FROM speedrun_ranks WHERE name = ?"));
SQL_BindParam("Iswenzz", level.MYSQL_TYPE_VAR_STRING);
SQL_BindResult(level.MYSQL_TYPE_VAR_STRING, 60);
SQL_BindResult(level.MYSQL_TYPE_VAR_STRING, 60);
SQL_BindResult(level.MYSQL_TYPE_LONG);
SQL_BindResult(level.MYSQL_TYPE_LONG);
SQL_BindResult(level.MYSQL_TYPE_LONG);
```
```c
printVariable(SQL_Prepare("INSERT INTO speedrun_ranks (name, guid, rank) VALUES (?, ?, ?)"));
SQL_BindParam("Iswenzz", level.MYSQL_TYPE_VAR_STRING);
SQL_BindParam("313354b4", level.MYSQL_TYPE_VAR_STRING);
SQL_BindParam("80", level.MYSQL_TYPE_LONG);
SQL_Execute();
```
<hr>

#### ``SQL_BindParam(<value>, <type>)``
Bind a value in the prepared statement.

Usage Example:
```c
SQL_BindParam("Iswenzz", level.MYSQL_TYPE_VAR_STRING);
```
<hr>
#### ``SQL_BindResult(<type>, <?string length>)``
Bind a result in the prepared statement, if you want to retrieve the col when fetching rows.
The <?string length> is optional for all types except strings where you have to specify the string length.
Usage Example:
```c
SQL_BindResult(level.MYSQL_TYPE_VAR_STRING, 60);
SQL_BindResult(level.MYSQL_TYPE_LONG);
```
<hr>

#### ``SQL_Execute()``
Executes the prepared statement.

Usage Example:
```c
SQL_Execute();
```
<hr>

#### ``SQL_NumRows()``
Return the number of rows after a SELECT query.
Return the number of rows after a query or statement.

Usage Example:
```c
Expand All @@ -73,7 +161,7 @@ count = SQL_NumRows();
<hr>

#### ``SQL_NumFields()``
Return the number of fields after a SELECT query.
Return the number of fields after a query or statement.

Usage Example:
```c
Expand All @@ -82,7 +170,7 @@ count = SQL_NumFields();
<hr>

#### ``SQL_AffectedRows()``
Return the number of affected rows after a query.
Return the number of affected rows after a query or statement.

Usage Example:
```c
Expand Down Expand Up @@ -110,6 +198,26 @@ if (isDefined(rows) && isDefined(rows.size))
```
<hr>

#### ``SQL_FetchRowsDict()``
Retrieve rows data in a two dimensional GSC string indexed array after a query.

Usage Example:
```c
rows = SQL_FetchRowsDict();
if (isDefined(rows) && isDefined(rows.size))
{
for (i = 0; i < rows.size; i++)
{
if (isDefined(rows[i]) && isDefined(rows[i].size))
{
for (j = 0; j < rows[i].size; j++)
comPrintF(rows[i][j]);
}
}
}
```
<hr>

#### ``SQL_FetchRow()``
Retrieve a single row data in a GSC array after a query.

Expand All @@ -121,6 +229,17 @@ for (i = 0; i < row.size; i++)
```
<hr>
#### ``SQL_FetchRowDict()``
Retrieve a single row data in a GSC string indexed array after a query.
Usage Example:
```c
row = SQL_FetchRowDict();
for (i = 0; i < row.size; i++)
comPrintF(row[i]);
```
<hr>

#### ``SQL_FetchFields()``
Retrieve all fields in a GSC array after a query.

Expand Down
Loading

0 comments on commit 3b632f3

Please sign in to comment.