From: Maxim Mamontov Date: Sun, 18 Feb 2018 17:17:04 +0000 (+0200) Subject: Variable scope reduction. X-Git-Tag: 2.409~22 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/862223ebc00e6153adb8f02f9c3b117547d16314 Variable scope reduction. --- diff --git a/projects/sgconf_xml/main.cpp b/projects/sgconf_xml/main.cpp index 8c2ce593..d43efea4 100644 --- a/projects/sgconf_xml/main.cpp +++ b/projects/sgconf_xml/main.cpp @@ -24,6 +24,10 @@ $Author: nobunaga $ $Date: 2008/01/05 12:11:34 $ */ +#include "stg/common.h" +#include "stg/netunit.h" +#include "request.h" + #include #include #include @@ -33,10 +37,6 @@ $Date: 2008/01/05 12:11:34 $ #include #include -#include "stg/common.h" -#include "stg/netunit.h" -#include "request.h" - #define FN_LEN (512) #define REQ_STR_LEN (300) char fileName[FN_LEN]; diff --git a/projects/sgconf_xml/parser.cpp b/projects/sgconf_xml/parser.cpp index f2d5993b..23ec776a 100644 --- a/projects/sgconf_xml/parser.cpp +++ b/projects/sgconf_xml/parser.cpp @@ -1,12 +1,12 @@ +#include "stg/common.h" +#include "stg/netunit.h" +#include "request.h" + #include #include #include #include -#include "stg/common.h" -#include "stg/netunit.h" -#include "request.h" - int parse_depth = 0; XML_Parser parser; //--------------------------------------------------------------------------- @@ -92,16 +92,14 @@ if (strncasecmp(el, "dir_name_", 9) == 0 || strcasecmp(el, "address") == 0 || st if (strcasecmp(el, "traff") == 0) { -// printf ("\n"); int j = 0; - uint64_t t; while (attr[j]) { + uint64_t t; str2x(attr[j+1], t); printf ("<%s>%lld\n", attr[j], t, attr[j]); j+=2; } -// printf ("\n"); return; } else @@ -109,7 +107,6 @@ else printf ("<%s>%s\n", el, attr[1], el); return; } -// } parse_depth++; if (parse_depth == 1) { @@ -130,17 +127,17 @@ if (parse_depth == 1) void EndElement(void *, const char *el) { parse_depth--; -if (strcasecmp(el, "ServerInfo") == 0 || strcasecmp(el, "Tariffs") == 0 || strcasecmp(el, "Admins") == 0 || strcasecmp(el, "Users") == 0 || strcasecmp(el, "tariff") == 0 || strcasecmp(el, "user") == 0) - { +if (strcasecmp(el, "ServerInfo") == 0 || + strcasecmp(el, "Tariffs") == 0 || + strcasecmp(el, "Admins") == 0 || + strcasecmp(el, "Users") == 0 || + strcasecmp(el, "tariff") == 0 || + strcasecmp(el, "user") == 0) printf ("\n", el); - } } //--------------------------------------------------------------------------- int ParseReply(void *, list * ans) -//int ParseReply(void * data, SLIST * ans) { -//char answ[ENC_MSG_LEN + 1]; -int len; int done = 0; parse_depth = 0; @@ -158,7 +155,7 @@ XML_SetElementHandler(parser, StartElement, EndElement); list::iterator n = ans->begin(); while (n != ans->end()) { - len = strlen(n->c_str()); + int len = strlen(n->c_str()); if (++n == ans->end()) done = 1;