2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
24 $Date: 2010/03/25 14:37:43 $
28 #include "common_sg.h"
29 #include "sg_error_codes.h"
31 #include "stg/user_conf.h"
32 #include "stg/user_stat.h"
33 #include "stg/common.h"
54 typedef typename T::value_type type;
58 struct ARRAY_TYPE<T[]>
63 template <typename T, size_t N>
64 struct ARRAY_TYPE<T[N]>
70 bool SetArrayItem(T & array, const char * index, const typename ARRAY_TYPE<T>::type & value)
73 if (str2x(index, pos))
80 void UsageConnection();
85 void UsageCorporations();
87 } // namespace anonymous
91 struct option long_options_get[] = {
92 {"server", 1, 0, 's'}, //Server
93 {"port", 1, 0, 'p'}, //Port
94 {"admin", 1, 0, 'a'}, //Admin
95 {"admin_pass", 1, 0, 'w'}, //passWord
96 {"user", 1, 0, 'u'}, //User
97 {"addcash", 0, 0, 'c'}, //Add Cash
98 //{"setcash", 0, 0, 'v'}, //Set Cash
99 {"credit", 0, 0, 'r'}, //cRedit
100 {"tariff", 0, 0, 't'}, //Tariff
101 {"message", 0, 0, 'm'}, //message
102 {"password", 0, 0, 'o'}, //password
103 {"down", 0, 0, 'd'}, //down
104 {"passive", 0, 0, 'i'}, //passive
105 {"disable-stat",0, 0, 'S'}, //disable detail stat
106 {"always-online",0, 0, 'O'}, //always online
107 {"session-upload", 1, 0, 500}, //SU0
108 {"session-download", 1, 0, 501}, //SD0
109 {"month-upload", 1, 0, 502}, //MU0
110 {"month-download", 1, 0, 503}, //MD0
112 {"user-data", 1, 0, 700}, //UserData0
114 {"prepaid", 0, 0, 'e'}, //prepaid traff
115 {"create", 0, 0, 'n'}, //create
116 {"delete", 0, 0, 'l'}, //delete
118 {"note", 0, 0, 'N'}, //Note
119 {"name", 0, 0, 'A'}, //nAme
120 {"address", 0, 0, 'D'}, //aDdress
121 {"email", 0, 0, 'L'}, //emaiL
122 {"phone", 0, 0, 'P'}, //phone
123 {"group", 0, 0, 'G'}, //Group
124 {"ip", 0, 0, 'I'}, //IP-address of user
125 {"authorized-by",0, 0, 800}, //always online
129 struct option long_options_set[] = {
130 {"server", 1, 0, 's'}, //Server
131 {"port", 1, 0, 'p'}, //Port
132 {"admin", 1, 0, 'a'}, //Admin
133 {"admin_pass", 1, 0, 'w'}, //passWord
134 {"user", 1, 0, 'u'}, //User
135 {"addcash", 1, 0, 'c'}, //Add Cash
136 {"setcash", 1, 0, 'v'}, //Set Cash
137 {"credit", 1, 0, 'r'}, //cRedit
138 {"tariff", 1, 0, 't'}, //Tariff
139 {"message", 1, 0, 'm'}, //message
140 {"password", 1, 0, 'o'}, //password
141 {"down", 1, 0, 'd'}, //down
142 {"passive", 1, 0, 'i'}, //passive
143 {"disable-stat",1, 0, 'S'}, //disable detail stat
144 {"always-online",1, 0, 'O'}, //always online
145 {"session-upload", 1, 0, 500}, //U0
146 {"session-download", 1, 0, 501}, //U1
147 {"month-upload", 1, 0, 502}, //U2
148 {"month-download", 1, 0, 503}, //U3
150 {"user-data", 1, 0, 700}, //UserData
152 {"prepaid", 1, 0, 'e'}, //prepaid traff
153 {"create", 1, 0, 'n'}, //create
154 {"delete", 1, 0, 'l'}, //delete
156 {"note", 1, 0, 'N'}, //Note
157 {"name", 1, 0, 'A'}, //nAme
158 {"address", 1, 0, 'D'}, //aDdress
159 {"email", 1, 0, 'L'}, //emaiL
160 {"phone", 1, 0, 'P'}, //phone
161 {"group", 1, 0, 'G'}, //Group
162 {"ip", 0, 0, 'I'}, //IP-address of user
166 //-----------------------------------------------------------------------------
167 CASH_INFO ParseCash(const char * str)
169 //-c 123.45:log message
170 std::string cashString;
172 const char * pos = strchr(str, ':');
175 cashString.append(str, pos);
176 message.append(pos + 1);
182 if (strtodouble2(cashString, cash) != 0)
184 printf("Incorrect cash value %s\n", str);
185 exit(PARAMETER_PARSING_ERR_CODE);
188 return CASH_INFO(cash, message);
190 //-----------------------------------------------------------------------------
191 double ParseCredit(const char * c)
194 if (strtodouble2(c, credit) != 0)
196 printf("Incorrect credit value %s\n", c);
197 exit(PARAMETER_PARSING_ERR_CODE);
202 //-----------------------------------------------------------------------------
203 double ParsePrepaidTraffic(const char * c)
206 if (strtodouble2(c, credit) != 0)
208 printf("Incorrect prepaid traffic value %s\n", c);
209 exit(PARAMETER_PARSING_ERR_CODE);
214 //-----------------------------------------------------------------------------
215 int64_t ParseTraff(const char * c)
218 if (str2x(c, traff) != 0)
220 printf("Incorrect credit value %s\n", c);
221 exit(PARAMETER_PARSING_ERR_CODE);
226 //-----------------------------------------------------------------------------
227 bool ParseDownPassive(const char * dp)
229 if (!(dp[1] == 0 && (dp[0] == '1' || dp[0] == '0')))
231 printf("Incorrect value %s\n", dp);
232 exit(PARAMETER_PARSING_ERR_CODE);
237 //-----------------------------------------------------------------------------
238 void ParseTariff(const char * str, RESETABLE<std::string> & tariffName, RESETABLE<std::string> & nextTariff)
240 const char * pos = strchr(str, ':');
243 std::string tariff(str, pos);
244 if (strcmp(pos + 1, "now") == 0)
246 else if (strcmp(pos + 1, "delayed") == 0)
250 printf("Incorrect tariff value '%s'. Should be '<tariff>', '<tariff>:now' or '<tariff>:delayed'.\n", str);
251 exit(PARAMETER_PARSING_ERR_CODE);
257 //-----------------------------------------------------------------------------
258 time_t ParseCreditExpire(const char * str)
260 struct tm brokenTime;
262 brokenTime.tm_wday = 0;
263 brokenTime.tm_yday = 0;
264 brokenTime.tm_isdst = 0;
265 brokenTime.tm_hour = 0;
266 brokenTime.tm_min = 0;
267 brokenTime.tm_sec = 0;
269 stg_strptime(str, "%Y-%m-%d", &brokenTime);
271 return stg_timegm(&brokenTime);
273 //-----------------------------------------------------------------------------
274 void ParseAnyString(const char * c, string * msg, const char * enc)
277 char * ob = new char[strlen(c) + 1];
278 char * ib = new char[strlen(c) + 1];
285 setlocale(LC_ALL, "");
288 strncpy(charsetF, nl_langinfo(CODESET), 255);
290 const char * charsetT = enc;
294 size_t insize = strlen(ib);
295 size_t outsize = strlen(ib);
299 cd = iconv_open(charsetT, charsetF);
300 if (cd == (iconv_t) -1)
304 printf("Warning: iconv from %s to %s failed\n", charsetF, charsetT);
309 printf("error iconv_open\n");
311 exit(ICONV_ERR_CODE);
314 #if defined(FREE_BSD) || defined(FREE_BSD5)
315 nconv = iconv (cd, (const char**)&inbuf, &insize, &outbuf, &outsize);
317 nconv = iconv (cd, &inbuf, &insize, &outbuf, &outsize);
319 //printf("nconv=%d outsize=%d\n", nconv, outsize);
320 if (nconv == (size_t) -1)
324 printf("iconv error\n");
325 exit(ICONV_ERR_CODE);
337 //-----------------------------------------------------------------------------
338 void CreateRequestSet(REQUEST * req, char * r)
340 const int strLen = 10024;
342 memset(str, 0, strLen);
346 if (!req->usrMsg.empty())
349 Encode12str(msg, req->usrMsg.data());
350 sprintf(str, "<Message login=\"%s\" msgver=\"1\" msgtype=\"1\" repeat=\"0\" repeatperiod=\"0\" showtime=\"0\" text=\"%s\"/>", req->login.const_data().c_str(), msg.c_str());
351 //sprintf(str, "<message login=\"%s\" priority=\"0\" text=\"%s\"/>\n", req->login, msg);
358 sprintf(str, "<DelUser login=\"%s\"/>", req->login.const_data().c_str());
366 sprintf(str, "<AddUser> <login value=\"%s\"/> </AddUser>", req->login.const_data().c_str());
372 strcat(r, "<SetUser>\n");
373 sprintf(str, "<login value=\"%s\"/>\n", req->login.const_data().c_str());
375 if (!req->credit.empty())
377 sprintf(str, "<credit value=\"%f\"/>\n", req->credit.const_data());
381 if (!req->creditExpire.empty())
383 sprintf(str, "<creditExpire value=\"%ld\"/>\n", req->creditExpire.const_data());
387 if (!req->prepaidTraff.empty())
389 sprintf(str, "<FreeMb value=\"%f\"/>\n", req->prepaidTraff.const_data());
393 if (!req->cash.empty())
396 Encode12str(msg, req->message);
397 sprintf(str, "<cash add=\"%f\" msg=\"%s\"/>\n", req->cash.const_data(), msg.c_str());
401 if (!req->setCash.empty())
404 Encode12str(msg, req->message);
405 sprintf(str, "<cash set=\"%f\" msg=\"%s\"/>\n", req->setCash.const_data(), msg.c_str());
409 if (!req->usrPasswd.empty())
411 sprintf(str, "<password value=\"%s\" />\n", req->usrPasswd.const_data().c_str());
415 if (!req->down.empty())
417 sprintf(str, "<down value=\"%d\" />\n", req->down.const_data());
421 if (!req->passive.empty())
423 sprintf(str, "<passive value=\"%d\" />\n", req->passive.const_data());
427 if (!req->disableDetailStat.empty())
429 sprintf(str, "<disableDetailStat value=\"%d\" />\n", req->disableDetailStat.const_data());
433 if (!req->alwaysOnline.empty())
435 sprintf(str, "<aonline value=\"%d\" />\n", req->alwaysOnline.const_data());
439 // IP-address of user
440 if (!req->ips.empty())
442 sprintf(str, "<ip value=\"%s\" />\n", req->ips.const_data().c_str());
446 int uPresent = false;
447 int dPresent = false;
448 for (int i = 0; i < DIR_NUM; i++)
450 if (!req->monthUpload[i].empty())
452 if (!uPresent && !dPresent)
454 sprintf(str, "<traff ");
460 ss << req->monthUpload[i].const_data();
461 //sprintf(str, "MU%d=\"%lld\" ", i, req->u[i].const_data());
462 sprintf(str, "MU%d=\"%s\" ", i, ss.str().c_str());
465 if (!req->monthDownload[i].empty())
467 if (!uPresent && !dPresent)
469 sprintf(str, "<traff ");
475 ss << req->monthDownload[i].const_data();
476 sprintf(str, "MD%d=\"%s\" ", i, ss.str().c_str());
479 if (!req->sessionUpload[i].empty())
481 if (!uPresent && !dPresent)
483 sprintf(str, "<traff ");
489 ss << req->sessionUpload[i].const_data();
490 //sprintf(str, "MU%d=\"%lld\" ", i, req->u[i].const_data());
491 sprintf(str, "MU%d=\"%s\" ", i, ss.str().c_str());
494 if (!req->sessionDownload[i].empty())
496 if (!uPresent && !dPresent)
498 sprintf(str, "<traff ");
504 ss << req->sessionDownload[i].const_data();
505 sprintf(str, "MD%d=\"%s\" ", i, ss.str().c_str());
509 if (uPresent || dPresent)
516 if (!req->tariff.empty())
518 switch (req->chgTariff)
521 sprintf(str, "<tariff now=\"%s\"/>\n", req->tariff.const_data().c_str());
525 sprintf(str, "<tariff recalc=\"%s\"/>\n", req->tariff.const_data().c_str());
529 sprintf(str, "<tariff delayed=\"%s\"/>\n", req->tariff.const_data().c_str());
536 if (!req->note.empty())
539 Encode12str(note, req->note.data());
540 sprintf(str, "<note value=\"%s\"/>", note.c_str());
544 if (!req->name.empty())
547 Encode12str(name, req->name.data());
548 sprintf(str, "<name value=\"%s\"/>", name.c_str());
552 if (!req->address.empty())
555 Encode12str(address, req->address.data());
556 sprintf(str, "<address value=\"%s\"/>", address.c_str());
560 if (!req->email.empty())
563 Encode12str(email, req->email.data());
564 sprintf(str, "<email value=\"%s\"/>", email.c_str());
568 if (!req->phone.empty())
571 Encode12str(phone, req->phone.data());
572 sprintf(str, "<phone value=\"%s\"/>", phone.c_str());
576 if (!req->group.empty())
579 Encode12str(group, req->group.data());
580 sprintf(str, "<group value=\"%s\"/>", group.c_str());
584 for (int i = 0; i < USERDATA_NUM; i++)
586 if (!req->userData[i].empty())
589 Encode12str(ud, req->userData[i].data());
590 sprintf(str, "<userdata%d value=\"%s\"/>", i, ud.c_str());
595 strcat(r, "</SetUser>\n");
597 //-----------------------------------------------------------------------------
598 int CheckParameters(REQUEST * req)
605 bool a = !req->admLogin.empty()
606 && !req->admPasswd.empty()
607 && !req->server.empty()
608 && !req->port.empty()
609 && !req->login.empty();
611 bool b = !req->cash.empty()
612 || !req->setCash.empty()
613 || !req->credit.empty()
614 || !req->prepaidTraff.empty()
615 || !req->tariff.empty()
616 || !req->usrMsg.empty()
617 || !req->usrPasswd.empty()
619 || !req->note.empty()
620 || !req->name.empty()
621 || !req->address.empty()
622 || !req->email.empty()
623 || !req->phone.empty()
624 || !req->group.empty()
625 || !req->ips.empty() // IP-address of user
631 for (int i = 0; i < DIR_NUM; i++)
633 if (req->sessionUpload[i].empty())
640 for (int i = 0; i < DIR_NUM; i++)
642 if (req->sessionDownload[i].empty())
649 for (int i = 0; i < DIR_NUM; i++)
651 if (req->monthUpload[i].empty())
658 for (int i = 0; i < DIR_NUM; i++)
660 if (req->monthDownload[i].empty())
667 for (int i = 0; i < DIR_NUM; i++)
669 if (req->userData[i].empty())
677 //printf("a=%d, b=%d, u=%d, d=%d ud=%d\n", a, b, u, d, ud);
678 return a && (b || su || sd || mu || md || ud);
680 //-----------------------------------------------------------------------------
681 int CheckParametersGet(REQUEST * req)
683 return CheckParameters(req);
685 //-----------------------------------------------------------------------------
686 int CheckParametersSet(REQUEST * req)
688 return CheckParameters(req);
690 //-----------------------------------------------------------------------------
691 bool mainGet(int argc, char **argv)
695 RESETABLE<string> t1;
696 int missedOptionArg = false;
698 const char * short_options_get = "s:p:a:w:u:crtmodieNADLPGISOE";
699 int option_index = -1;
704 c = getopt_long(argc, argv, short_options_get, long_options_get, &option_index);
715 req.port = ParseServerPort(optarg);
720 req.admLogin = ParseAdminLogin(optarg);
723 case 'w': //admin password
724 req.admPasswd = ParsePassword(optarg);
727 case 'o': //change user password
732 req.login = ParseUser(optarg);
743 case 'E': //credit expire
744 req.creditExpire = 1;
759 case 'e': //Prepaid Traffic
760 req.prepaidTraff = 1;
787 case 'I': //IP-address of user
791 case 'S': //Detail stat status
792 req.disableDetailStat = " ";
795 case 'O': //Always online status
796 req.alwaysOnline = " ";
800 SetArrayItem(req.sessionUpload, optarg, 1);
801 //req.sessionUpload[optarg] = 1;
804 SetArrayItem(req.sessionDownload, optarg, 1);
805 //req.sessionDownload[optarg] = 1;
808 SetArrayItem(req.monthUpload, optarg, 1);
809 //req.monthUpload[optarg] = 1;
812 SetArrayItem(req.monthDownload, optarg, 1);
813 //req.monthDownload[optarg] = 1;
817 SetArrayItem(req.userData, optarg, std::string(" "));
818 //req.userData[optarg] = " ";
827 missedOptionArg = true;
831 printf ("?? getopt returned character code 0%o ??\n", c);
837 printf ("non-option ARGV-elements: ");
838 while (optind < argc)
839 printf ("%s ", argv[optind++]);
841 exit(PARAMETER_PARSING_ERR_CODE);
844 if (missedOptionArg || !CheckParametersGet(&req))
846 //printf("Parameter needed\n");
848 exit(PARAMETER_PARSING_ERR_CODE);
852 return ProcessAuthBy(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), req.login.data());
854 return ProcessGetUser(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), req.login.data(), req);
856 //-----------------------------------------------------------------------------
857 bool mainSet(int argc, char **argv)
862 bool isMessage = false;
865 RESETABLE<string> t1;
867 const char * short_options_set = "s:p:a:w:u:c:r:t:m:o:d:i:e:v:nlN:A:D:L:P:G:I:S:O:E:";
869 int missedOptionArg = false;
875 int option_index = -1;
877 c = getopt_long(argc, argv, short_options_set, long_options_set, &option_index);
889 req.port = ParseServerPort(optarg);
894 req.admLogin = ParseAdminLogin(optarg);
897 case 'w': //admin password
898 req.admPasswd = ParsePassword(optarg);
901 case 'o': //change user password
902 conf.password = ParsePassword(optarg);
906 req.login = ParseUser(optarg);
910 stat.cashAdd = ParseCash(optarg);
914 stat.cashSet = ParseCash(optarg);
918 conf.credit = ParseCredit(optarg);
921 case 'E': //credit expire
922 conf.creditExpire = ParseCreditExpire(optarg);
926 conf.disabled = ParseDownPassive(optarg);
930 conf.passive = ParseDownPassive(optarg);
934 ParseTariff(optarg, conf.tariffName, conf.nextTariff);
938 ParseAnyString(optarg, &str);
943 case 'e': //Prepaid Traffic
944 stat.freeMb = ParsePrepaidTraffic(optarg);
947 case 'n': //Create User
948 req.createUser = true;
951 case 'l': //Delete User
952 req.deleteUser = true;
956 ParseAnyString(optarg, &str, "koi8-ru");
961 ParseAnyString(optarg, &str, "koi8-ru");
966 ParseAnyString(optarg, &str, "koi8-ru");
971 ParseAnyString(optarg, &str, "koi8-ru");
976 ParseAnyString(optarg, &str);
981 ParseAnyString(optarg, &str, "koi8-ru");
985 case 'I': //IP-address of user
986 ParseAnyString(optarg, &str);
987 conf.ips = StrToIPS(str);
991 conf.disabledDetailStat = ParseDownPassive(optarg);
995 conf.alwaysOnline = ParseDownPassive(optarg);
999 SetArrayItem(stat.sessionUp, optarg, ParseTraff(argv[optind++]));
1002 SetArrayItem(stat.sessionDown, optarg, ParseTraff(argv[optind++]));
1005 SetArrayItem(stat.monthUp, optarg, ParseTraff(argv[optind++]));
1008 SetArrayItem(stat.monthDown, optarg, ParseTraff(argv[optind++]));
1011 case 700: //UserData
1012 ParseAnyString(argv[optind++], &str);
1013 SetArrayItem(conf.userdata, optarg, str);
1017 missedOptionArg = true;
1021 missedOptionArg = true;
1025 printf("?? getopt returned character code 0%o ??\n", c);
1031 printf ("non-option ARGV-elements: ");
1032 while (optind < argc)
1033 printf ("%s ", argv[optind++]);
1035 exit(PARAMETER_PARSING_ERR_CODE);
1038 if (missedOptionArg || !CheckParametersSet(&req))
1040 //printf("Parameter needed\n");
1042 exit(PARAMETER_PARSING_ERR_CODE);
1045 const int rLen = 20000;
1047 memset(rstr, 0, rLen);
1050 return ProcessSendMessage(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), req.login.data(), req.usrMsg.data());
1052 return ProcessSetUser(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), req.login.data(), conf, stat);
1054 //-----------------------------------------------------------------------------
1055 int main(int argc, char **argv)
1062 exit(PARAMETER_PARSING_ERR_CODE);
1065 if (strcmp(argv[1], "get") == 0)
1068 return mainGet(argc - 1, argv + 1);
1070 else if (strcmp(argv[1], "set") == 0)
1073 if (mainSet(argc - 1, argv + 1) )
1080 exit(PARAMETER_PARSING_ERR_CODE);
1082 return UNKNOWN_ERR_CODE;
1084 //-----------------------------------------------------------------------------
1091 std::cout << "sgconf is the Stargazer management utility.\n\n"
1093 << "\tsgconf [options]\n\n"
1094 << "General options:\n"
1095 << "\t-c, --config <config file>\t\toverride default config file (default: \"~/.config/stg/sgconf.conf\")\n"
1096 << "\t-h, --help\t\t\t\tshow this help and exit\n"
1097 << "\t-v, --version\t\t\t\tshow version information and exit\n\n";
1103 UsageCorporations();
1105 //-----------------------------------------------------------------------------
1106 void UsageConnection()
1108 std::cout << "Connection options:\n"
1109 << "\t-s, --server <address>\t\t\thost to connect (ip or domain name, default: \"localhost\")\n"
1110 << "\t-p, --port <port>\t\t\tport to connect (default: \"5555\")\n"
1111 << "\t-u, --username <username>\t\tadministrative login (default: \"admin\")\n"
1112 << "\t-w, --userpass <password>\t\tpassword for administrative login\n"
1113 << "\t-a, --address <connection string>\tconnection params as a single string in format: <login>:<password>@<host>:<port>\n\n";
1115 //-----------------------------------------------------------------------------
1118 std::cout << "Admins management options:\n"
1119 << "\t--get-admins\t\t\t\tget a list of admins (subsequent options will define what to show)\n"
1120 << "\t\t--login\t\t\t\tshow admin's login\n"
1121 << "\t\t--priv\t\t\t\tshow admin's priviledges\n\n"
1122 << "\t--get-admin\t\t\t\tget the information about admin\n"
1123 << "\t\t--login <login>\t\t\tlogin of the admin to show\n"
1124 << "\t\t--priv\t\t\t\tshow admin's priviledges\n\n"
1125 << "\t--add-admin\t\t\t\tadd a new admin\n"
1126 << "\t\t--login <login>\t\t\tlogin of the admin to add\n"
1127 << "\t\t--password <password>\t\tpassword of the admin to add\n"
1128 << "\t\t--priv <priv number>\t\tpriviledges of the admin to add\n\n"
1129 << "\t--del-admin\t\t\t\tdelete an existing admin\n"
1130 << "\t\t--login <login>\t\t\tlogin of the admin to delete\n\n"
1131 << "\t--chg-admin\t\t\t\tchange an existing admin\n"
1132 << "\t\t--login <login>\t\t\tlogin of the admin to change\n"
1133 << "\t\t--priv <priv number>\t\tnew priviledges\n\n";
1135 //-----------------------------------------------------------------------------
1138 std::cout << "Tariffs management options:\n"
1139 << "\t--get-tariffs\t\t\t\tget a list of tariffs (subsequent options will define what to show)\n"
1140 << "\t\t--name\t\t\t\tshow tariff's name\n"
1141 << "\t\t--fee\t\t\t\tshow tariff's fee\n"
1142 << "\t\t--free\t\t\t\tshow tariff's prepaid traffic in terms of cost\n"
1143 << "\t\t--passive-cost\t\t\tshow tariff's cost of \"freeze\"\n"
1144 << "\t\t--traff-type\t\t\tshow what type of traffix will be accounted by the tariff\n"
1145 << "\t\t--dirs\t\t\t\tshow tarification rules for directions\n\n"
1146 << "\t--get-tariff\t\t\t\tget the information about tariff\n"
1147 << "\t\t--name <name>\t\t\tname of the tariff to show\n"
1148 << "\t\t--fee\t\t\t\tshow tariff's fee\n"
1149 << "\t\t--free\t\t\t\tshow tariff's prepaid traffic in terms of cost\n"
1150 << "\t\t--passive-cost\t\t\tshow tariff's cost of \"freeze\"\n"
1151 << "\t\t--traff-type\t\t\tshow what type of traffix will be accounted by the tariff\n"
1152 << "\t\t--dirs\t\t\t\tshow tarification rules for directions\n\n"
1153 << "\t--add-tariff\t\t\t\tadd a new tariff\n"
1154 << "\t\t--name <name>\t\t\tname of the tariff to add\n"
1155 << "\t\t--fee <fee>\t\t\tstariff's fee\n"
1156 << "\t\t--free <free>\t\t\ttariff's prepaid traffic in terms of cost\n"
1157 << "\t\t--passive-cost <cost>\t\ttariff's cost of \"freeze\"\n"
1158 << "\t\t--traff-type <type>\t\twhat type of traffi will be accounted by the tariff\n"
1159 << "\t\t--times <times>\t\t\tslash-separated list of \"day\" time-spans (in form \"hh:mm-hh:mm\") for each direction\n"
1160 << "\t\t--prices-day-a <prices>\t\tslash-separated list of prices for \"day\" traffic before threshold for each direction\n"
1161 << "\t\t--prices-night-a <prices>\tslash-separated list of prices for \"night\" traffic before threshold for each direction\n"
1162 << "\t\t--prices-day-b <prices>\t\tslash-separated list of prices for \"day\" traffic after threshold for each direction\n"
1163 << "\t\t--prices-night-b <prices>\tslash-separated list of prices for \"night\" traffic after threshold for each direction\n"
1164 << "\t\t--single-prices <yes|no>\tslash-separated list of \"single price\" flags for each direction\n"
1165 << "\t\t--no-discounts <yes|no>\t\tslash-separated list of \"no discount\" flags for each direction\n"
1166 << "\t\t--thresholds <thresholds>\tslash-separated list of thresholds (in Mb) for each direction\n\n"
1167 << "\t--del-tariff\t\t\t\tdelete an existing tariff\n"
1168 << "\t\t--name <name>\t\t\tname of the tariff to delete\n\n"
1169 << "\t--chg-tariff\t\t\t\tchange an existing tariff\n"
1170 << "\t\t--name <name>\t\t\tname of the tariff to change\n"
1171 << "\t\t--fee <fee>\t\t\tstariff's fee\n"
1172 << "\t\t--free <free>\t\t\ttariff's prepaid traffic in terms of cost\n"
1173 << "\t\t--passive-cost <cost>\t\ttariff's cost of \"freeze\"\n"
1174 << "\t\t--traff-type <type>\t\twhat type of traffix will be accounted by the tariff\n"
1175 << "\t\t--dir <N>\t\t\tnumber of direction data to change\n"
1176 << "\t\t\t--time <time>\t\t\"day\" time-span (in form \"hh:mm-hh:mm\")\n"
1177 << "\t\t\t--price-day-a <price>\tprice for \"day\" traffic before threshold\n"
1178 << "\t\t\t--price-night-a <price>\tprice for \"night\" traffic before threshold\n"
1179 << "\t\t\t--price-day-b <price>\tprice for \"day\" traffic after threshold\n"
1180 << "\t\t\t--price-night-b <price>\tprice for \"night\" traffic after threshold\n"
1181 << "\t\t\t--single-price <yes|no>\t\"single price\" flag\n"
1182 << "\t\t\t--no-discount <yes|no>\t\"no discount\" flag\n"
1183 << "\t\t\t--threshold <threshold>\tthreshold (in Mb)\n\n";
1185 //-----------------------------------------------------------------------------
1188 std::cout << "Users management options:\n"
1189 << "\t--get-users\t\t\t\tget a list of users (subsequent options will define what to show)\n"
1190 << "\t--get-user\t\t\t\tget the information about user\n"
1191 << "\t--add-user\t\t\t\tadd a new user\n"
1192 << "\t--del-user\t\t\t\tdelete an existing user\n"
1193 << "\t--chg-user\t\t\t\tchange an existing user\n"
1194 << "\t--check-user\t\t\t\tcheck credentials is valid\n"
1195 << "\t--send-message\t\t\t\tsend a message to a user\n"
1198 //-----------------------------------------------------------------------------
1199 void UsageServices()
1201 std::cout << "Services management options:\n"
1202 << "\t--get-services\t\t\t\tget a list of services (subsequent options will define what to show)\n"
1203 << "\t\t--name\t\t\t\tshow service's name\n"
1204 << "\t\t--comment\t\t\tshow a comment to the service\n"
1205 << "\t\t--cost\t\t\t\tshow service's cost\n"
1206 << "\t\t--pay-day\t\t\tshow service's pay day\n\n"
1207 << "\t--get-service\t\t\t\tget the information about service\n"
1208 << "\t\t--name <name>\t\t\tname of the service to show\n"
1209 << "\t\t--comment\t\t\tshow a comment to the service\n"
1210 << "\t\t--cost\t\t\t\tshow service's cost\n"
1211 << "\t\t--pay-day\t\t\tshow service's pay day\n\n"
1212 << "\t--add-service\t\t\t\tadd a new service\n"
1213 << "\t\t--name <name>\t\t\tname of the service to add\n"
1214 << "\t\t--comment <comment>\t\ta comment to the service\n"
1215 << "\t\t--cost <cost>\t\t\tservice's cost\n"
1216 << "\t\t--pay-day <day>\t\t\tservice's pay day\n\n"
1217 << "\t--del-service\t\t\t\tdelete an existing service\n"
1218 << "\t\t--name <name>\t\t\tname of the service to delete\n\n"
1219 << "\t--chg-service\t\t\t\tchange an existing service\n"
1220 << "\t\t--name <name>\t\t\tname of the service to change\n"
1221 << "\t\t--comment <comment>\t\ta comment to the service\n"
1222 << "\t\t--cost <cost>\t\t\tservice's cost\n"
1223 << "\t\t--pay-day <day>\t\t\tservice's pay day\n\n";
1225 //-----------------------------------------------------------------------------
1226 void UsageCorporations()
1228 std::cout << "Corporations management options:\n"
1229 << "\t--get-corporations\t\t\tget a list of corporations (subsequent options will define what to show)\n"
1230 << "\t\t--name\t\t\t\tshow corporation's name\n"
1231 << "\t\t--cash\t\t\t\tshow corporation's cash\n\n"
1232 << "\t--get-corp\t\t\t\tget the information about corporation\n"
1233 << "\t\t--name <name>\t\t\tname of the corporation to show\n"
1234 << "\t\t--cash\t\t\t\tshow corporation's cash\n\n"
1235 << "\t--add-corp\t\t\t\tadd a new corporation\n"
1236 << "\t\t--name <name>\t\t\tname of the corporation to add\n"
1237 << "\t\t--cash <cash>\t\t\tinitial corporation's cash (default: \"0\")\n\n"
1238 << "\t--del-corp\t\t\t\tdelete an existing corporation\n"
1239 << "\t\t--name <name>\t\t\tname of the corporation to delete\n\n"
1240 << "\t--chg-corp\t\t\t\tchange an existing corporation\n"
1241 << "\t\t--name <name>\t\t\tname of the corporation to change\n"
1242 << "\t\t--add-cash <amount>[:<message>]\tadd cash to the corporation's account and optional comment message\n"
1243 << "\t\t--set-cash <cash>[:<message>]\tnew corporation's cash and optional comment message\n\n";
1246 } // namespace anonymous