X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/c4456f2cae7261f7263e3708ff995bade7da722f..4a6814d2f7eb9e4a46264f3d5a285ca4a29b0d06:/projects/sgconf/common_sg.cpp diff --git a/projects/sgconf/common_sg.cpp b/projects/sgconf/common_sg.cpp index bb4f5967..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", "
"}, @@ -129,7 +123,7 @@ printf("To get userdata<0...9> use:\n"); printf("sgconf get -s -p -a -w -u --ud0 [--ud1 ...]\n\n"); printf("To get user's authorizers list use:\n"); -printf("sgconf get -s -p -a -w -u --authorized-by\n"); +printf("sgconf get -s -p -a -w -u --authorized-by\n\n"); printf("To send message use:\n"); printf("sgconf set -s -p -a -w -u -m \n\n"); @@ -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; } //-----------------------------------------------------------------------------