diff --git a/external/queryparser.c b/external/queryparser.c index 3a8e97d..ec45ac6 100644 --- a/external/queryparser.c +++ b/external/queryparser.c @@ -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; } @@ -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++; @@ -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++; } @@ -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++; } diff --git a/external/queryparser.h b/external/queryparser.h index 64211f3..06ffd08 100644 --- a/external/queryparser.h +++ b/external/queryparser.h @@ -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