Skip to content

Commit

Permalink
fix: query parser library variable name
Browse files Browse the repository at this point in the history
This commit fixes the variable name for "query parser" library to match the standard.
  • Loading branch information
ThePedroo committed Sep 23, 2024
1 parent e2860cd commit 9476c78
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
46 changes: 23 additions & 23 deletions external/queryparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
#define QUERY_ON_VALUE 2
#define QUERY_ON_VALUE_KEY_END 3

void qparser_init(struct qparser_info *parseInfo, struct qparser_query *buffer, int length) {
parseInfo->length = length;
parseInfo->queriesLength = 0;
parseInfo->queries = buffer;
memset(parseInfo->queries, 0, (size_t)length * sizeof(struct qparser_query));
void qparser_init(struct qparser_info *parse_info, struct qparser_query *buffer, int length) {
parse_info->length = length;
parse_info->queriesLength = 0;
parse_info->queries = buffer;
memset(parse_info->queries, 0, (size_t)length * sizeof(struct qparser_query));
}

void qparser_parse(struct qparser_info *parseInfo, char *url) {
void qparser_parse(struct qparser_info *parse_info, char *url) {
int keyIndex = 0;
int valueIndex = 0;

int state = -1;

for (int i = 0; url[i] != '\0'; i++) {
if (parseInfo->queriesLength >= parseInfo->length) {
printf("[queryparser]: qparser_query length exceeded.\n - Limit: %d\n", parseInfo->length);
if (parse_info->queriesLength >= parse_info->length) {
printf("[queryparser]: qparser_query length exceeded.\n - Limit: %d\n", parse_info->length);

return;
}
Expand Down Expand Up @@ -58,18 +58,18 @@ void qparser_parse(struct qparser_info *parseInfo, char *url) {
if (state == 1) {
if (keyIndex >= 64) goto keyLimitReached;

parseInfo->queries[parseInfo->queriesLength].value[valueIndex] = '\0';
parse_info->queries[parse_info->queriesLength].value[valueIndex] = '\0';

state = 0;
valueIndex = 0;
parseInfo->queriesLength++;
parse_info->queriesLength++;

if (parseInfo->queriesLength >= parseInfo->length) goto queriesLimitReached;
if (parse_info->queriesLength >= parse_info->length) goto queriesLimitReached;
}

if (keyIndex >= 64) goto keyLimitReached;

parseInfo->queries[parseInfo->queriesLength].key[keyIndex] = url[i];
parse_info->queries[parse_info->queriesLength].key[keyIndex] = url[i];

keyIndex++;

Expand All @@ -80,13 +80,13 @@ void qparser_parse(struct qparser_info *parseInfo, char *url) {
if (valueIndex >= 1024) goto valueLimitReached;

if (state == 3) {
parseInfo->queries[parseInfo->queriesLength].key[keyIndex] = '\0';
parse_info->queries[parse_info->queriesLength].key[keyIndex] = '\0';

state = 2;
keyIndex = 0;
}

parseInfo->queries[parseInfo->queriesLength].value[valueIndex] = url[i];
parse_info->queries[parse_info->queriesLength].value[valueIndex] = url[i];

valueIndex++;
}
Expand All @@ -95,39 +95,39 @@ void qparser_parse(struct qparser_info *parseInfo, char *url) {
}
}

if (parseInfo->queries[parseInfo->queriesLength].key[0] != '\0') {
if (parse_info->queries[parse_info->queriesLength].key[0] != '\0') {
if (keyIndex >= 64) goto keyLimitReached;

parseInfo->queries[parseInfo->queriesLength].value[valueIndex] = '\0';
parse_info->queries[parse_info->queriesLength].value[valueIndex] = '\0';

parseInfo->queriesLength++;
parse_info->queriesLength++;
}

return;

keyLimitReached: {
printf("[queryparser]: Key length exceeded.\n - Limit: %d\n", parseInfo->length);
printf("[queryparser]: Key length exceeded.\n - Limit: %d\n", parse_info->length);

return;
}

valueLimitReached: {
printf("[queryparser]: Value length exceeded.\n - Limit: %d\n", parseInfo->length);
printf("[queryparser]: Value length exceeded.\n - Limit: %d\n", parse_info->length);

return;
}

queriesLimitReached: {
printf("[queryparser]: Queries length exceeded.\n - Limit: %d\n", parseInfo->length);
printf("[queryparser]: Queries length exceeded.\n - Limit: %d\n", parse_info->length);

return;
}
}

struct qparser_query *qparser_get_query(struct qparser_info *parseInfo, char *key) {
struct qparser_query *qparser_get_query(struct qparser_info *parse_info, char *key) {
int i = 0;
while (i < parseInfo->queriesLength) {
if (parseInfo->queries[i].key[0] != '\0' && strcmp(parseInfo->queries[i].key, key) == 0) return &parseInfo->queries[i];
while (i < parse_info->queriesLength) {
if (parse_info->queries[i].key[0] != '\0' && strcmp(parse_info->queries[i].key, key) == 0) return &parse_info->queries[i];

i++;
}
Expand Down
6 changes: 3 additions & 3 deletions external/queryparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ struct qparser_info {
struct qparser_query *queries;
};

void qparser_init(struct qparser_info *parseInfo, struct qparser_query *buffer, int length);
void qparser_init(struct qparser_info *parse_info, struct qparser_query *buffer, int length);

void qparser_parse(struct qparser_info *parseInfo, char *url);
void qparser_parse(struct qparser_info *parse_info, char *url);

struct qparser_query *qparser_get_query(struct qparser_info *parseInfo, char *key);
struct qparser_query *qparser_get_query(struct qparser_info *parse_info, char *key);

#endif

0 comments on commit 9476c78

Please sign in to comment.