X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/bd3f1dd24a1af10b7c0e403397019610f727325c..1631088d558bc27b4f94869ddedec4580e7f30fa:/projects/sgconf/common_sg.cpp diff --git a/projects/sgconf/common_sg.cpp b/projects/sgconf/common_sg.cpp index bf2ac622..a15f7588 100644 --- a/projects/sgconf/common_sg.cpp +++ b/projects/sgconf/common_sg.cpp @@ -52,12 +52,6 @@ struct GetUserCbData void * data; bool * result; }; -//----------------------------------------------------------------------------- -struct AuthByCbData -{ - void * data; - bool * result; -}; //--------------------------------------------------------------------------- struct HelpParams { @@ -90,7 +84,7 @@ HelpParams hp[] = {"set credit expire", "get credit expire", "-E", ""}, {"set password", "get password", "-o", ""}, {"set prepaid traffic", "get prepaid traffic", "-e", ""}, - {"set IP-addresses", "get IP-addresses", "-I", "<*|ip_addr[,ip_addr...]>"}, + {"set IP-addresses", "get IP-addresses", "-I", "<*|ip_addr[,ip_addr...]>"}, {"set name", "get name", "-A", ""}, {"set note", "get note", "-N", ""}, {"set street address", "get street address", "-D", "
"}, @@ -404,7 +398,7 @@ StringReqParams strReqParams[] = {"group", req->group, &ud->group}, {"tariff", req->tariff, &ud->tariff}, {"password", req->usrPasswd, &ud->password}, - {"ip", req->ips, &ud->ips} // IP-address of user + {"ip", req->ips, &ud->ips} // IP-address of user }; for (unsigned i = 0; i < sizeof(strReqParams) / sizeof(StringReqParams); i++) { @@ -418,20 +412,11 @@ for (unsigned i = 0; i < sizeof(strReqParams) / sizeof(StringReqParams); i++) *result = true; } //----------------------------------------------------------------------------- -void RecvAuthByData(const std::vector & list, void * d) +void RecvAuthByData(const PARSER_AUTH_BY::INFO & list, void *) { -AuthByCbData * abcbd; -abcbd = (AuthByCbData *)d; - -bool * result = abcbd->result; - -REQUEST * req = (REQUEST *)abcbd->data; - for (std::vector::const_iterator it = list.begin(); it != list.end(); ++it) cout << *it << "\n"; cout << endl; - -*result = true; } //----------------------------------------------------------------------------- int ProcessSetUser(const std::string &server, @@ -531,33 +516,21 @@ int ProcessAuthBy(const std::string &server, { SERVCONF sc; -bool result = false; - -sc.SetServer(server.c_str()); // õÓÔÁÎÁ×ÌÉ×ÁÅÍ ÉÍÑ ÓÅÒ×ÅÒÁ Ó ËÏÔÏÒÇÏ ÚÁÂÉÒÁÔØ ÉÎÆÕ -sc.SetPort(port); // ÁÄÍÉÎÓËÉÊ ÐÏÒÔ ÓÅÒ×ÅÒÁÐÏÒÔ -sc.SetAdmLogin(admLogin.c_str()); // ÷ÙÓÔÁ×ÌÑÅÍ ÌÏÇÉÎ É ÐÁÒÏÌØ ÁÄÍÉÎÁ +sc.SetServer(server.c_str()); +sc.SetPort(port); +sc.SetAdmLogin(admLogin.c_str()); sc.SetAdmPassword(admPasswd.c_str()); -// TODO Good variable name :) -AuthByCbData abcbd; - -abcbd.data = data; -abcbd.result = &result; - -sc.SetGetUserAuthByRecvCb(RecvAuthByData, &abcbd); -sc.GetUserAuthBy(login.c_str()); +sc.SetAuthByCallback(RecvAuthByData, NULL); +sc.AuthBy(login.c_str()); -if (result) - { - printf("Ok\n"); - return 0; - } -else +if (sc.GetError()) { printf("Error\n"); return -1; } +printf("Ok\n"); return 0; } //-----------------------------------------------------------------------------