From: Maxim Mamontov Date: Thu, 7 Apr 2011 14:13:28 +0000 (+0300) Subject: Unused modules removed from libstgcommon X-Git-Tag: 2.407-rc3~57 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/45f84c01ffb2bc5cb4379ddda8d14c401c9f8351 Unused modules removed from libstgcommon --- diff --git a/stglibs/common.lib/debug.c b/stglibs/common.lib/debug.c deleted file mode 100644 index 8a2d15c6..00000000 --- a/stglibs/common.lib/debug.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - ***************************************************************************** - * - * File: debug.c - * - * Description: ÷Ù×ÏÄ ÏÔÌÁÄÏÞÎÏÊ ÉÎÆÏÒÍÁÃÉÉ × log ÆÁÊÌ - * - * $Id: debug.c,v 1.2 2005/11/16 16:19:40 nobunaga Exp $ - * - ***************************************************************************** - */ - -#include -#include -#include - -#include "debug.h" - - -/* - ***************************************************************************** - * -= óÏÚÄÁÎÉÅ ÚÁÐÉÓÉ × log-ÆÁÊÌÅ =- - ***************************************************************************** - */ -void PrintfLog(FILE * logFile, char * scriptName, char * fmt, ...) -{ - #ifndef DEMO - va_list vaList; - char buff[MAX_LOG_BUFF_LEN]; - time_t curTime; - char curTimeCh[26]; - - if (logFile) - { - va_start(vaList, fmt); - vsprintf(buff, fmt, vaList); - va_end(vaList); - - curTime = time(NULL); - ctime_r(&curTime, curTimeCh); - curTimeCh[strlen(curTimeCh)-1] = 0; - fprintf(logFile, "%s [%s]: %s\n", scriptName, curTimeCh, buff); - } - #endif - return; -} /* PrintfLog() */ - -/* EOF */ - diff --git a/stglibs/common.lib/debug.h b/stglibs/common.lib/debug.h deleted file mode 100644 index d80de9f7..00000000 --- a/stglibs/common.lib/debug.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - ***************************************************************************** - * - * File: debug.h - * - * Description: ÷Ù×ÏÄ ÏÔÌÁÄÏÞÎÏÊ ÉÎÆÏÒÍÁÃÉÉ × log ÆÁÊÌ - * - * $Id: debug.h,v 1.2 2006/03/07 18:33:56 nobunaga Exp $ - * - ***************************************************************************** - */ - -#ifndef _DEBUG_H_ -#define _DEBUG_H_ - - -#include - - -#define MAX_LOG_BUFF_LEN (2048) - - -void PrintfLog(FILE * logFile, char * scriptName, char * fmt, ...); - -#endif /* _DEBUG_H_ */ - -/* EOF */ - diff --git a/stglibs/common.lib/stg_error.c b/stglibs/common.lib/stg_error.c deleted file mode 100644 index 17aa912d..00000000 --- a/stglibs/common.lib/stg_error.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - ***************************************************************************** - * - * File: stg_error.c - * - * Description: ëÏÄÙ ïÛÉÂÏË ÐÒÏÅËÔÁ StarGazer - * - * $Id: stg_error.c,v 1.1.1.1 2005/09/29 11:33:18 boris Exp $ - * - ***************************************************************************** - */ - -#include "stg_error.h" -//#include "debug.h" - - -/* - ***************************************************************************** - * -= ðÏÉÓË ÓÏÏÂÝÅÎÉÑ Ï ÏÛÉÂËÅ ÐÏ ËÏÄÕ ÏÛÉÂËÉ =- - ***************************************************************************** - */ -char * GetErrorString(RESULT_DATA res) -{ - char * errorString; - - switch (res) - { - case SUCCESS: - { - errorString = "OK: Work finished successfully"; - break; - } - /* astat.cgi */ - case ERROR_CONFIG_READ: - { - errorString = "FAIL: Read config file"; - break; - } - case ERROR_PORT_NUM: - { - errorString = "FAIL: Port value incorrect"; - break; - } - case ERROR_CLEAR_SID_DIR: - { - errorString = "FAIL: ClearSidDir() return fail"; - break; - } - case ERROR_UNKNOWN_HTTP_METHOD: - { - errorString = "FAIL: Umknown HTTP method"; - break; - } - case ERROR_NULL_HTTP_METHOD: - { - errorString = "FAIL: NULL HTTP method"; - break; - } - case ERROR_UNKNOWN_QUERY: - { - errorString = "FAIL: Unknown query"; - break; - } - case ERROR_LOGIN: - { - errorString = "FAIL: Login Error"; - break; - } - case ERROR_PREPARE_USER_SELECTION_PAGE_0: - { - errorString = "FAIL: Prepare user selection page [0]"; - break; - } - case ERROR_ADD_IFACE: - { - errorString = "FAIL: Add iface"; - break; - } - case ERROR_ADD_TARIFF: - { - errorString = "FAIL: Add tariff"; - break; - } - case ERROR_ADD_GROUP: - { - errorString = "FAIL: Add group"; - break; - } - case ERROR_ADD_USER: - { - errorString = "FAIL: Add user"; - break; - } - case ERROR_CREATE_SID: - { - errorString = "FAIL: Create sid"; - break; - } - case ERROR_SET_SID: - { - errorString = "FAIL: Set sid"; - break; - } - case ERROR_UPDATE_SID: - { - errorString = "FAIL: Update sid"; - break; - } - case ERROR_READ_SID_DATA: - { - errorString = "FAIL: Read sid data"; - break; - } - case ERROR_WRITE_SID_DATA: - { - errorString = "FAIL: Write sid data"; - break; - } - case ERROR_REMOVE_EXPIRED_SID: - { - errorString = "FAIL: Remove expired sids"; - break; - } - /* qParam.lib */ - case ERROR_MEMORY_ALLOCATE: - { - errorString = "FAIL: Error memory allocation"; - break; - } - case ERROR_MEMORY_DESPOSE: - { - errorString = "FAIL: Error memory depose"; - break; - } - case ERROR_NULL_QUERY: - { - errorString = "FAIL: Query is NULL"; - break; - } - case ERROR_QUERY: - { - errorString = "FAIL: Error query"; - break; - } - /* diagram.lib */ - case ERROR_ARC_DATA_FULL: - { - errorString = "FAIL: Arc data is full"; - break; - } - case ERROR_ARC_PERCENT: - { - errorString = "FAIL: Arc percent != 100%"; - break; - } - default: - { - errorString = "FAIL: Unknown error"; - } - } /* switch (res) */ - - return (errorString); -}/* GetErrorString() */ - -/* EOF */ - diff --git a/stglibs/common.lib/stg_error.h b/stglibs/common.lib/stg_error.h deleted file mode 100644 index 39ae1457..00000000 --- a/stglibs/common.lib/stg_error.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - ***************************************************************************** - * - * File: stg_error.h - * - * Description: ëÏÄÙ ÏÛÉÂÏË - * - * $Id: stg_error.h,v 1.1.1.1 2005/09/29 11:33:18 boris Exp $ - * - ***************************************************************************** - */ - -#ifndef _STG_ERROR_H_ -#define _STG_ERROR_H_ - - -/* îÁÞÁÌÏ ÏÂÌÁÓÔÉ ÏÛÉÂÏË ÍÏÄÕÌÑ astat.cgi */ -#define ERROR_ASTAT_START (100000) -/* îÁÞÁÌÏ ÏÂÌÁÓÔÉ ÏÛÉÂÏË ÂÉÂÌÉÔÅËÉ qparam.lib */ -#define ERROR_QPARAM_START (102000) -/* îÁÞÁÌÏ ÏÂÌÁÓÔÉ ÏÛÉÂÏË ÂÉÂÌÉÔÅËÉ diagram.lib */ -#define ERROR_DIAGRAM_START (103000) - - -typedef enum -{ - SUCCESS = 0, - - ERROR_CONFIG_READ = ERROR_ASTAT_START, - ERROR_PORT_NUM, - ERROR_CLEAR_SID_DIR, - ERROR_UNKNOWN_HTTP_METHOD, - ERROR_NULL_HTTP_METHOD, - ERROR_UNKNOWN_QUERY, - ERROR_LOGIN, // ÐÏËÁ ÞÔÏ ÏÄÎÁ ÏÛÉÂËÁ ÎÁ ÍÎÏÇÏ ÓÉÔÕÁÃÉÊ: - // * ÎÅ ×ÅÒÎÏÅ ÉÍÑ É ÐÁÒÏÌØ - // * ÎÅÔ Ó×ÑÚÉ Ó ÓÅÒ×ÅÒÏÍ - // * .... - // ÜÔÏ Ó×ÑÚÁÎÏ Ó ËÏÄÁÍÉ ÏÛÉÂÏË ÍÏÄÕÌÑ srvconf.lib - // × ÄÁÌØÎÅÊÛÅÍ ÎÁÄÏ ÐÅÒÅÄÁÌÁÔØ ×ÓÅ ÎÁ ÏÄÉÎ - // enum ÏÛÉÂÏË - ERROR_PREPARE_USER_SELECTION_PAGE_0, - ERROR_ADD_IFACE, - ERROR_ADD_TARIFF, - ERROR_ADD_GROUP, - ERROR_ADD_USER, - ERROR_CREATE_SID, - ERROR_SET_SID, - ERROR_UPDATE_SID, - ERROR_READ_SID_DATA, - ERROR_WRITE_SID_DATA, - ERROR_REMOVE_EXPIRED_SID, - - ERROR_MEMORY_ALLOCATE = ERROR_QPARAM_START, - ERROR_MEMORY_DESPOSE, - ERROR_NULL_QUERY, // ÚÁÐÒÏÓ ÎÅ ÐÏÌÕÞÅÎ - ERROR_QUERY, // ÏÛÉÂËÁ × ÚÁÐÒÏÓÅ - ÎÅÓÏÏÔ×ÅÔÓÔ×ÉÅ ÓÔÁÎÄÁÒÔÕ - - ERROR_ARC_DATA_FULL = ERROR_DIAGRAM_START, - ERROR_ARC_PERCENT, - TODO -} RESULT_DATA; - - -char * GetErrorString(RESULT_DATA res); - -#endif /* _STG_ERROR_H_ */ - -/* EOF */ - diff --git a/stglibs/common.lib/test.cpp b/stglibs/common.lib/test.cpp deleted file mode 100644 index 2d0cff74..00000000 --- a/stglibs/common.lib/test.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Maxim Mamontov - */ - - /* - $Revision: 1.6 $ - $Date: 2009/06/10 10:31:15 $ - $Author: faust $ - */ - -#include -#include -#include - -using namespace std; - -#include "common.h" -#include "test.h" - -time_t stgTime; - -int main(void) -{ -char buf1[256]; -BLOWFISH_CTX ctx; -int functions = 0, ok = 0; - -cout << "Testing common.lib" << endl << "---------------\ ---------------------" << endl; - -if (!TestIntToKMG()) - ok++; -functions++; -if (!Teststrtodouble2()) - ok++; -functions++; -if (!TestIsDigit()) - ok++; -functions++; -if (!TestIsAlpha()) - ok++; -functions++; -if (!TestEncodeDecode()) - ok++; -functions++; -if (!TestParseIPString()) - ok++; -functions++; -if (!TestKOIToWIN()) - ok++; -functions++; -if (!TestDaysInMonth()) - ok++; -functions++; -if (!TestBlowfish()) - ok++; -functions++; -if (!TestMin8()) - ok++; -functions++; -if (!Testinet_ntostr()) - ok++; -functions++; -if (!TestParseTariffTimeStr()) - ok++; -functions++; -if (!TestStr2XX2Str()) - ok++; -functions++; - -cout << "------------------------------------" << endl; -cout << "Functions: \t\t\t" << functions << endl; -cout << "OK's: \t\t\t\t" << ok << endl; -cout << "Fails: \t\t\t\t" << functions - ok << endl; - -return (functions != ok); -} - -int TestIntToKMG() -{ -int res = 1; -cout << "Testing IntToKMG: \t\t"; -res = res && (strcmp(IntToKMG(LONG_LONG_MAX), TEST1_LLMAX) == 0); -//cout << IntToKMG(LONG_LONG_MAX) << " " << TEST1_LLMAX << endl; - -res = res && (strcmp(IntToKMG(1024 * 1024 + 1), TEST1_1) == 0); -//cout << IntToKMG(1024 * 1024 + 1) << " " << TEST1_1 << endl; - -res = res && (strcmp(IntToKMG(0), TEST1_0) == 0); -//cout << IntToKMG(0) << " " << TEST1_0 << endl; - -res = res && (strcmp(IntToKMG(LONG_LONG_MIN), TEST1_LLMIN) == 0); -//cout << IntToKMG(LONG_LONG_MIN) << " " << TEST1_LLMIN << endl; - -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int Teststrtodouble2() -{ -double a; -int res = 1; -cout << "Testing strtodouble2: \t\t"; -res = res && !strtodouble2("0.0", a); -res = res && (a == 0.0); -res = res && !strtodouble2("0.123456", a); -res = res && (a == 0.123456); -res = res && !strtodouble2("123456.0", a); -res = res && (a == 123456.0); -res = res && !strtodouble2("123456.123456", a); -res = res && (a == 123456.123456); -res = res && !strtodouble2("-0.123456", a); -res = res && (a == -0.123456); -res = res && !strtodouble2("-123456.0", a); -res = res && (a == -123456.0); -res = res && !strtodouble2("-123456.123456", a); -res = res && (a == -123456.123456); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestIsDigit() -{ -char a; -int res = 1; -cout << "Testing IsDigit: \t\t"; -for(a = '0'; a < '9'; a++) - res = res && IsDigit(a); -for(a = 'a'; a < 'z'; a++) - res = res && !IsDigit(a); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestIsAlpha() -{ -char a; -int res = 1; -cout << "Testing IsAlpha: \t\t"; -for(a = '0'; a < '9'; a++) - res = res && !IsAlpha(a); -for(a = 'a'; a < 'z'; a++) - res = res && IsAlpha(a); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestEncodeDecode() -{ -char enc[256], dec[512]; -int res = 1; -cout << "Testing EncodeDecode: \t\t"; -Encode12(enc, TEST2_STRING, strlen(TEST2_STRING)); -Decode21(dec, enc); -res = res && !strcmp(dec, TEST2_STRING); -Encode12(enc, TEST2_STRING, 256); // Overflow -Decode21(dec, enc); -res = res && !strcmp(dec, TEST2_STRING); -Encode12(enc, TEST2_STRING, 5); // Underflow -Decode21(dec, enc); -res = res && !strcmp(dec, TEST2_PART); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestParseIPString() -{ -unsigned int ips[4]; -int res = 1; -cout << "Testing ParseIPString: \t\t"; -res = res && (ParseIPString("127.0.0.1, 192.168.58.1, 10.0.0.1", ips, 4) == 0); -res = res && ips[0] == 0x0100007F; -res = res && ips[1] == 0x013AA8C0; -res = res && ips[2] == 0x0100000A; -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestKOIToWIN() -{ -char enc[256], dec[256]; -int res = 1; -cout << "Testing KOIToWin: \t\t"; -KOIToWin(TEST3_STRING, enc, 256); -WinToKOI(enc, dec, 256); -res = res && !strcmp(dec, TEST3_STRING); -KOIToWin(TEST3_STRING, enc, strlen(TEST3_STRING) - 5); -WinToKOI(enc, dec, strlen(TEST3_STRING) - 5); -res = res && !strcmp(dec, TEST3_STRING); -KOIToWin(TEST3_STRING, enc, strlen(TEST3_STRING) + 5); -WinToKOI(enc, dec, strlen(TEST3_STRING) + 5); -res = res && !strcmp(dec, TEST3_STRING); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestDaysInMonth() -{ -int res = 1; -cout << "Testing DaysInMonth: \t\t"; -res = res && (DaysInMonth(2000, 0) == 31); -res = res && (DaysInMonth(2000, 1) == 29); -res = res && (DaysInMonth(2001, 1) == 28); -res = res && (DaysInMonth(2100, 1) == 28); -res = res && (DaysInMonth(2400, 1) == 29); -res = res && (DaysInMonth(2000, 2) == 31); -res = res && (DaysInMonth(2000, 3) == 30); -res = res && (DaysInMonth(2000, 4) == 31); -res = res && (DaysInMonth(2000, 5) == 30); -res = res && (DaysInMonth(2000, 6) == 31); -res = res && (DaysInMonth(2000, 7) == 31); -res = res && (DaysInMonth(2000, 8) == 30); -res = res && (DaysInMonth(2000, 9) == 31); -res = res && (DaysInMonth(2000, 10) == 30); -res = res && (DaysInMonth(2000, 11) == 31); -res = res && (DaysInMonth(2000, 20) == 33); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestBlowfish() -{ -BLOWFISH_CTX ctx; -char enc[256], dec[256]; -int res = 1, i, len = strlen(TEST4_STRING); -cout << "Testing Blowfish: \t\t"; -EnDecodeInit(TEST4_PASSWORD, strlen(TEST4_PASSWORD), &ctx); -strcpy(dec, TEST4_STRING); -for(i = 0; i < len; i += 8) - EncodeString(&enc[i], &dec[i], &ctx); -for(i = 0; i < len; i += 8) - DecodeString(&dec[i], &enc[i], &ctx); -res = res && !strcmp(dec, TEST4_STRING); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestMin8() -{ -int res = 1; -cout << "Testing Min8: \t\t\t"; -res = res && (Min8(INT_MAX) == INT_MAX + 1); -res = res && (Min8(INT_MIN) == INT_MIN); -res = res && (Min8(0) == 0); -res = res && (Min8(7) == 8); -res = res && (Min8(8) == 8); -res = res && (Min8(9) == 16); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res;; -} - -int Testinet_ntostr() -{ -unsigned long ip; -char buf[32]; -int res = 1; -cout << "Testing inet_ntostr: \t\t"; -res = res && (strcmp(inet_ntostr(inet_addr("127.0.0.1")), "127.0.0.1") == 0); -res = res && (strcmp(inet_ntostr(inet_addr("255.255.255.255")), "255.255.255.255") == 0); -res = res && (strcmp(inet_ntostr(inet_addr("0.0.0.0")), "0.0.0.0") == 0); -res = res && (strcmp(inet_ntostr(inet_addr("10.0.0.1")), "10.0.0.1") == 0); -res = res && (strcmp(inet_ntostr(inet_addr("192.168.58.240")), "192.168.58.240") == 0); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} - -int TestParseTariffTimeStr() -{ -int h1, m1, h2, m2; -int res = 1; -cout << "Testing ParseTariffTimeStr: \t"; -res = res && !ParseTariffTimeStr("00:00-00:00", h1, m1, h2, m2); -res = res && (h1 == 0 && m1 == 0 && h2 == 0 && m2 == 0); -res = res && !ParseTariffTimeStr("0:0-0:0", h1, m1, h2, m2); -res = res && (h1 == 0 && m1 == 0 && h2 == 0 && m2 == 0); -res = res && !ParseTariffTimeStr("99:99-99:99", h1, m1, h2, m2); -res = res && (h1 == 99 && m1 == 99 && h2 == 99 && m2 == 99); -res = res && !ParseTariffTimeStr("12:34-56:78", h1, m1, h2, m2); -res = res && (h1 == 12 && m1 == 34 && h2 == 56 && m2 == 78); -if (res) - cout << "OK" << endl; -else - cout << "Fail" << endl; -return !res; -} -//----------------------------------------------------------------------------- -int TestStr2XX2Str() -{ -cout << "Testing Str2XX2Str: \t\t"; - -# define INT8_MIN (-128) -# define INT16_MIN (-32767-1) -# define INT32_MIN (-2147483647-1) -# define INT64_MIN (-__INT64_C(9223372036854775807)-1) -# define INT8_MAX (127) -# define INT16_MAX (32767) -# define INT32_MAX (2147483647) -# define INT64_MAX (__INT64_C(9223372036854775807)) - -int xx; -string s; -for (int i = -5000000; i < 5000000; i+=10) -{ - x2str(i, s); - str2x(s, xx); - if (i != xx) - { - cout << "Fail" << endl; - return 1; - } -} - -x2str(INT32_MIN, s); -str2x(s, xx); -if (xx != INT32_MIN) -{ - cout << INT32_MIN << " " << s << endl; - cout << INT32_MIN << " " << xx << endl; -cout << "Fail" << endl; - return 1; -} - -x2str(INT32_MAX, s); -str2x(s, xx); -if (xx != INT32_MAX) -{ -cout << "Fail" << endl; - return 1; -} -cout << "OK" << endl; -return 0; -} -//----------------------------------------------------------------------------- - diff --git a/stglibs/common.lib/test.h b/stglibs/common.lib/test.h deleted file mode 100644 index 31f0ba08..00000000 --- a/stglibs/common.lib/test.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Maxim Mamontov - */ - - /* - $Revision: 1.4 $ - $Date: 2007/12/02 18:52:05 $ - $Author: nobunaga $ - */ - -#undef STG_TIME - -#define TEST1_LLMAX "8589934592.00 Gb" -#define TEST1_LLMIN "-8589934592.00 Gb" -#define TEST1_0 "0.00 kb" -#define TEST1_1 "1.00 Mb" -#define TEST2_STRING "This is a test string! 0123456789+-*/" -#define TEST2_PART "This i" -#define TEST3_STRING "üÔÏ ÔÅÓÔÏ×ÁÑ ÓÔÒÏËÁ! 0123456789+-*/" -#define TEST3_PART "üÔÏ ÔÅÓÔÏ×ÁÑ ÓÔÒÏËÁ! 012345678" -#define TEST4_STRING "Try to encode this using blowfish" -#define TEST4_PASSWORD "Ha*yN).3zqL!" - -int TestIntToKMG(); -int Teststrtodouble2(); -int TestIsDigit(); -int TestIsAlpha(); -int TestEncodeDecode(); -int TestParseIPString(); -int TestKOIToWIN(); -int TestDaysInMonth(); -int TestBlowfish(); -int TestMin8(); -int Testinet_ntostr(); -int TestParseTariffTimeStr(); -int TestStr2XX2Str(); -