mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
## ⚠️ATTENTION! ⚠️ Upgrading procedure: **Database:** After this PR will be merged you need to backup your DB first (you can use the db-assembler or any mysql client to generate the dump) and restore it after. The reason is that we use now docker named volumes instead of binded ones to improve performance. **Conf & client data**: if you use the default configuration, both the etc and the data folder are now available inside the **/env/docker**. Finally, you can cleanup the /docker folder previously used by our system. ## Changes Proposed: This PR will implement the [devcontainer ](https://code.visualstudio.com/docs/remote/containers) feature for VSCode. Allowing us to develop and debug directly within the container in the same way on all OSes. * Implemented support for vscode dev-container feature by remote-extension suite * Docker performance optimizations for MacOS and non-linux hosts * Bash system improvements * Implemented first command using Deno runtime environment (typescript) and [commander.js] * Implemented wait mechanism for db_assembler * Implemented db migration command * possibility to run the authserver and worldserver with GDB using the integrated simple-restarter * Implemented docker multi-stage mechanism to use one single Dockerfile for all the services * client-data downloader now creates a placeholder to avoid downloading the same version of data files multiple times * deployment of pre-compiled docker images on [docker hub](https://hub.docker.com/u/acore), you can test them [here](https://github.com/azerothcore/acore-docker)
130 lines
3.6 KiB
C
130 lines
3.6 KiB
C
/* gcc -O2 -Wall -pedantic dump-parser.c -o dump-parser
|
||
Usage: cat dump.sql | dump-parser
|
||
Or : dump-parser dump.sql
|
||
bugs :
|
||
* the parser will fail if the 10001st character of a line is an escaped quote, it will see it as an unescaped quote.
|
||
*/
|
||
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <stdbool.h>
|
||
#include <string.h>
|
||
|
||
#define BUFFER 100000
|
||
|
||
bool is_escaped(char* string, int offset) {
|
||
if (offset == 0) {
|
||
return false;
|
||
} else if (string[offset - 1] == '\\') {
|
||
return !is_escaped(string, offset - 1);
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
bool is_commented(char* string) {
|
||
char buffer[4];
|
||
|
||
sprintf(buffer, "%.3s", string);
|
||
|
||
return strcmp(buffer, "-- ") == 0;
|
||
}
|
||
|
||
int main(int argc, char *argv[])
|
||
{
|
||
FILE* file = argc > 1 ? fopen(argv[1], "r") : stdin;
|
||
|
||
char buffer[BUFFER];
|
||
char* line;
|
||
int pos;
|
||
int parenthesis = 0;
|
||
bool quote = false;
|
||
bool escape = false;
|
||
bool comment = false;
|
||
|
||
while (fgets(buffer, BUFFER, file) != NULL) {
|
||
line = buffer;
|
||
|
||
/* skip commented */
|
||
if (comment || is_commented(line)) {
|
||
comment = line[strlen(line) - 1] != '\n';
|
||
fputs(line, stdout);
|
||
} else {
|
||
pos = 0;
|
||
|
||
nullchar:
|
||
while (line[pos] != '\0') {
|
||
/* if we are still in escape state, we need to check first char. */
|
||
if (!escape) {
|
||
/* find any character in ()' */
|
||
pos = strcspn(line, "()'\\");
|
||
}
|
||
|
||
if (pos > 0) {
|
||
/* print before match */
|
||
printf("%.*s", pos, line);
|
||
}
|
||
|
||
switch (line[pos]) {
|
||
case '(':
|
||
if (!quote) {
|
||
if (parenthesis == 0) {
|
||
putchar('\n');
|
||
}
|
||
parenthesis++;
|
||
}
|
||
if (escape) {
|
||
escape = false;
|
||
}
|
||
break;
|
||
|
||
case ')':
|
||
if (!quote) {
|
||
if (parenthesis > 0) {
|
||
parenthesis--;
|
||
} else {
|
||
/* whoops */
|
||
puts("\n");
|
||
fputs(line, stdout);
|
||
fputs("Found closing parenthesis without opening one.\n", stderr);
|
||
exit(1);
|
||
}
|
||
}
|
||
if (escape) {
|
||
escape = false;
|
||
}
|
||
break;
|
||
|
||
case '\\':
|
||
escape = !escape;
|
||
break;
|
||
|
||
case '\'':
|
||
if (escape) {
|
||
escape = false;
|
||
} else {
|
||
quote = !quote;
|
||
}
|
||
break;
|
||
|
||
case '\0':
|
||
goto nullchar;
|
||
|
||
default:
|
||
if (escape) {
|
||
escape = false;
|
||
}
|
||
break;
|
||
}
|
||
|
||
/* print char then skip it (to make sure we don’t double match) */
|
||
putchar(line[pos]);
|
||
line = line + pos + 1;
|
||
pos = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|