Reindent canonizer.c
- Untabify - Remove trailing whitespace. - Allman braces.
This commit is contained in:
@ -7,73 +7,78 @@
|
|||||||
#include <buffer.h>
|
#include <buffer.h>
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
static char* server_options[] = {
|
static char* server_options[] =
|
||||||
"MariaDB Corporation MaxScale",
|
{
|
||||||
"--datadir=./",
|
"MariaDB Corporation MaxScale",
|
||||||
"--language=./",
|
"--datadir=./",
|
||||||
"--skip-innodb",
|
"--language=./",
|
||||||
"--default-storage-engine=myisam",
|
"--skip-innodb",
|
||||||
NULL
|
"--default-storage-engine=myisam",
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
|
const int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
|
||||||
|
|
||||||
static char* server_groups[] = {
|
static char* server_groups[] =
|
||||||
"embedded",
|
{
|
||||||
"server",
|
"embedded",
|
||||||
"server",
|
"server",
|
||||||
NULL
|
"server",
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
unsigned int psize;
|
||||||
|
GWBUF* qbuff;
|
||||||
|
char *tok;
|
||||||
|
char readbuff[4092];
|
||||||
|
FILE* infile;
|
||||||
|
FILE* outfile;
|
||||||
|
|
||||||
unsigned int psize;
|
if (argc != 3)
|
||||||
GWBUF* qbuff;
|
{
|
||||||
char *tok;
|
printf("Usage: canonizer <input file> <output file>\n");
|
||||||
char readbuff[4092];
|
return 1;
|
||||||
FILE* infile;
|
}
|
||||||
FILE* outfile;
|
|
||||||
|
|
||||||
if(argc != 3){
|
|
||||||
printf("Usage: canonizer <input file> <output file>\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mysql_library_init(num_elements, server_options, server_groups)){
|
if (mysql_library_init(num_elements, server_options, server_groups))
|
||||||
printf("Embedded server init failed.\n");
|
{
|
||||||
return 1;
|
printf("Embedded server init failed.\n");
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
infile = fopen(argv[1],"rb");
|
|
||||||
outfile = fopen(argv[2],"wb");
|
|
||||||
|
|
||||||
if(infile == NULL || outfile == NULL){
|
|
||||||
printf("Opening files failed.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!feof(infile))
|
infile = fopen(argv[1],"rb");
|
||||||
{
|
outfile = fopen(argv[2],"wb");
|
||||||
fgets(readbuff,4092,infile);
|
|
||||||
psize = strlen(readbuff);
|
if (infile == NULL || outfile == NULL)
|
||||||
if(psize < 4092){
|
{
|
||||||
qbuff = gwbuf_alloc(psize + 7);
|
printf("Opening files failed.\n");
|
||||||
*(qbuff->sbuf->data + 0) = (unsigned char)psize;
|
return 1;
|
||||||
*(qbuff->sbuf->data + 1) = (unsigned char)(psize>>8);
|
}
|
||||||
*(qbuff->sbuf->data + 2) = (unsigned char)(psize>>16);
|
|
||||||
*(qbuff->sbuf->data + 4) = 0x03;
|
while (!feof(infile))
|
||||||
memcpy(qbuff->start + 5,readbuff,psize + 1);
|
{
|
||||||
parse_query(qbuff);
|
fgets(readbuff,4092,infile);
|
||||||
tok = qc_get_canonical(qbuff);
|
psize = strlen(readbuff);
|
||||||
fprintf(outfile,"%s\n",tok);
|
if (psize < 4092)
|
||||||
free(tok);
|
{
|
||||||
gwbuf_free(qbuff);
|
qbuff = gwbuf_alloc(psize + 7);
|
||||||
}
|
*(qbuff->sbuf->data + 0) = (unsigned char)psize;
|
||||||
}
|
*(qbuff->sbuf->data + 1) = (unsigned char)(psize>>8);
|
||||||
fclose(infile);
|
*(qbuff->sbuf->data + 2) = (unsigned char)(psize>>16);
|
||||||
fclose(outfile);
|
*(qbuff->sbuf->data + 4) = 0x03;
|
||||||
mysql_library_end();
|
memcpy(qbuff->start + 5,readbuff,psize + 1);
|
||||||
|
parse_query(qbuff);
|
||||||
return 0;
|
tok = qc_get_canonical(qbuff);
|
||||||
|
fprintf(outfile,"%s\n",tok);
|
||||||
|
free(tok);
|
||||||
|
gwbuf_free(qbuff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(infile);
|
||||||
|
fclose(outfile);
|
||||||
|
mysql_library_end();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user