Modifiche dalla versione Linux sulla 2.1
git-svn-id: svn://10.65.10.50/trunk@11908 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
50af5d8a5a
commit
0a81e1371c
@ -1,6 +1,6 @@
|
||||
#include "BaseServ.h"
|
||||
#include "baseserv.h"
|
||||
|
||||
#include "Dongle.h"
|
||||
#include "dongle.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@ -53,7 +53,7 @@ TUserInfo* TUserTable::AddConnection(wxSocketBase& sock, const wxChar* user)
|
||||
wxIPV4address peer; sock.GetPeer(peer);
|
||||
const wxString host = peer.Hostname();
|
||||
ui = new TUserInfo(user, host);
|
||||
m_Hash.Put(wxString::Format("%s@%s", user, host), ui);
|
||||
m_Hash.Put(wxString::Format("%s@%s", (const char *) user, host.c_str()), ui);
|
||||
}
|
||||
ui->m_nPrograms++;
|
||||
|
||||
@ -66,7 +66,7 @@ TUserInfo* TUserTable::Find(wxSocketBase& sock, const wxChar* user)
|
||||
const wxString host = peer.Hostname();
|
||||
|
||||
if (user && *user)
|
||||
return (TUserInfo*)m_Hash.Get(wxString::Format("%s@%s", user, host));
|
||||
return (TUserInfo*)m_Hash.Get(wxString::Format("%s@%s", (const char *) user, host.c_str()));
|
||||
|
||||
BeginFind();
|
||||
for (TUserInfo* ui = Next(); ui; ui = Next())
|
||||
@ -85,7 +85,7 @@ void TUserTable::RemoveConnection(wxSocketBase& sock, const wxChar* user)
|
||||
{
|
||||
ui->m_nPrograms--;
|
||||
if (ui->m_nPrograms <= 0)
|
||||
m_Hash.Delete(wxString::Format("%s@%s", ui->m_strName, ui->m_strHost));
|
||||
m_Hash.Delete(wxString::Format("%s@%s", ui->m_strName.c_str(), ui->m_strHost.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ void TUserTable::Kill(const wxChar* strUser)
|
||||
{
|
||||
if (ui->m_strName == strUser)
|
||||
{
|
||||
m_Hash.Delete(wxString::Format("%s@%s", ui->m_strName, ui->m_strHost));
|
||||
m_Hash.Delete(wxString::Format("%s@%s", ui->m_strName.c_str(), ui->m_strHost.c_str()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -183,8 +183,8 @@ wxString TAuthorizationServer::Garble(unsigned short n, const wxDateTime& date)
|
||||
unsigned short data[4];
|
||||
data[0] = m_Dongle.Number();
|
||||
data[1] = n;
|
||||
data[2] = unsigned short(val >> 16);
|
||||
data[3] = unsigned short(val & 0xFFFF);
|
||||
data[2] = (unsigned short)(val >> 16);
|
||||
data[3] = (unsigned short)(val & 0xFFFF);
|
||||
m_Dongle.garble(data);
|
||||
return wxString::Format("%04X%04X", data[0], data[1]);
|
||||
}
|
||||
@ -395,7 +395,7 @@ void TAuthorizationServer::GenerateUsers(wxString& strFilename)
|
||||
tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%H:%M:%S");
|
||||
tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%d-%m-%Y");
|
||||
|
||||
wxString href = wxString::Format("kill.cgi?%s", ui->m_strName);
|
||||
wxString href = wxString::Format("kill.cgi?%s", ui->m_strName.c_str());
|
||||
AddLinkButton(tr.AddChild("td"), "Kill", href).SetAttr("width", "100%");
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ void TAuthorizationServer::GenerateFile(wxString& strFilename)
|
||||
} else
|
||||
if (strName == "year")
|
||||
{
|
||||
const int nModule = atoi(strArgs);
|
||||
// const int nModule = atoi(strArgs);
|
||||
TXmlItem html;
|
||||
TXmlItem& body = CreatePageBody(html);
|
||||
TXmlItem& form = body.AddChild("form");
|
||||
@ -552,7 +552,7 @@ void TAuthorizationServer::GenerateFile(wxString& strFilename)
|
||||
} else
|
||||
if (strName == "maxusers")
|
||||
{
|
||||
const int nModule = atoi(strArgs);
|
||||
// const int nModule = atoi(strArgs);
|
||||
TXmlItem html;
|
||||
TXmlItem& body = CreatePageBody(html);
|
||||
TXmlItem& form = body.AddChild("form");
|
||||
@ -757,7 +757,7 @@ void TAuthorizationServer::ProcessUserLogin(wxString cmd, wxSocketBase& sock)
|
||||
if (m_Dongle.Connected())
|
||||
{
|
||||
// Preliminary GUEST login
|
||||
if (stricmp(strUser,"******")==0 && stricmp(strProgram, "ba0100")==0)
|
||||
if (wxStricmp(strUser,"******")==0 && wxStricmp(strProgram, "ba0100")==0)
|
||||
{
|
||||
num = 1;
|
||||
}
|
||||
|
@ -16,13 +16,15 @@
|
||||
// headers
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "BaseServ.h"
|
||||
#include "baseserv.h"
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/sckstrm.h>
|
||||
#include <wx/msw/iniconf.h>
|
||||
#ifdef LINUX
|
||||
#include <wx/filename.h>
|
||||
#endif
|
||||
|
||||
#include <wx/app.h>
|
||||
|
||||
@ -469,7 +471,7 @@ const wxChar* TBaseServerApp::GetConfigName() const
|
||||
|
||||
void TBaseServerApp::SetConfigString(const wxChar* key, const wxChar* val, const wxChar* app) const
|
||||
{
|
||||
wxIniConfig ini("", "", GetConfigName());
|
||||
wxFileConfig ini("", "", GetConfigName(), "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
|
||||
wxString str;
|
||||
if (app == NULL || *app == '\0')
|
||||
app = GetAppName();
|
||||
@ -486,7 +488,7 @@ void TBaseServerApp::SetConfigInt(const wxChar* key, int val, const wxChar* app)
|
||||
|
||||
wxString TBaseServerApp::GetConfigString(const wxChar* key, const wxChar* def, const wxChar* app) const
|
||||
{
|
||||
wxIniConfig ini("", "", GetConfigName());
|
||||
wxFileConfig ini("", "", GetConfigName(), "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
|
||||
wxString str;
|
||||
if (app == NULL || *app == '\0')
|
||||
app = GetAppName();
|
||||
@ -510,7 +512,7 @@ bool TBaseServerApp::GetConfigBool(const wxChar* key, bool def, const wxChar* ap
|
||||
wxString str = GetConfigString(key, "*", app);
|
||||
bool val = def;
|
||||
if (str != "*")
|
||||
val = (str[0] == '1') || (str[0] == 'X') || (str[0] == 'Y');
|
||||
val = (str[0u] == '1') || (str[0u] == 'X') || (str[0u] == 'Y');
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -542,6 +544,15 @@ bool TBaseServerApp::OnInit()
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef LINUX
|
||||
wxString path;
|
||||
|
||||
wxFileName::SplitPath(argv[0], &path, NULL, NULL);
|
||||
|
||||
if (!path.IsEmpty())
|
||||
wxSetWorkingDirectory(path);
|
||||
#endif
|
||||
|
||||
// Create the address - defaults to localhost:0 initially
|
||||
wxIPV4address addr;
|
||||
addr.Service(GetDefaultPort());
|
||||
|
@ -3,6 +3,9 @@
|
||||
#include <wx/snglinst.h>
|
||||
#include <wx/socket.h>
|
||||
#include <wx/wfstream.h>
|
||||
#ifdef LINUX
|
||||
#include <wx/app.h>
|
||||
#endif
|
||||
|
||||
#include "xml.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "BaseServ.h"
|
||||
#include "baseserv.h"
|
||||
|
||||
class TCoffeeServer : public TBaseServerApp
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "BaseServ.h"
|
||||
#include "baseserv.h"
|
||||
|
||||
#include <wx/dbtable.h>
|
||||
#include <wx/dynarray.h>
|
||||
@ -380,10 +380,10 @@ TTable::TTable(wxDb* db, const wxString& strName)
|
||||
if (m_table->Open(false, false))
|
||||
{
|
||||
if (!FillRecordSet())
|
||||
GetServerApp().WriteLog(wxString::Format("Can't query table %s", strName));
|
||||
GetServerApp().WriteLog(wxString::Format("Can't query table %s", strName.c_str()));
|
||||
}
|
||||
else
|
||||
GetServerApp().WriteLog(wxString::Format("Can't open table %s", strName));
|
||||
GetServerApp().WriteLog(wxString::Format("Can't open table %s", strName.c_str()));
|
||||
|
||||
m_nCurrent = 0; // Before the first
|
||||
}
|
||||
@ -509,9 +509,9 @@ TDataBase& TStudy::DB(long firm)
|
||||
wxString strDsn, strPath;
|
||||
|
||||
if (firm > 0)
|
||||
strDsn.sprintf("%s_%05lda", m_strName, firm);
|
||||
strDsn.sprintf("%s_%05lda", m_strName.c_str(), firm);
|
||||
else
|
||||
strDsn.sprintf("%s_COM", m_strName);
|
||||
strDsn.sprintf("%s_COM", m_strName.c_str());
|
||||
|
||||
db = new TDataBase;
|
||||
|
||||
@ -522,7 +522,7 @@ TDataBase& TStudy::DB(long firm)
|
||||
}
|
||||
|
||||
TStudy::TStudy(const char* strName, const char* strUser, const char* strPass)
|
||||
: wxHashTable(wxKEY_INTEGER), m_strName(strName), m_strUser(strUser), m_strPass(strPass)
|
||||
: wxHashTable(wxKEY_INTEGER), m_strUser(strUser), m_strPass(strPass), m_strName(strName)
|
||||
{
|
||||
DeleteContents(true);
|
||||
}
|
||||
@ -905,7 +905,7 @@ void TDataBaseServer::WriteTable(wxString strDsn, wxString strUser,
|
||||
tTotalTime = clock() - tTotalStart;
|
||||
|
||||
WriteLog(wxString::Format("--- %u Records. Query:%u Retrieve:%u Total:%u",
|
||||
nRecords, tQueryTime, tRetrieveTime, tTotalTime));
|
||||
nRecords, (unsigned int) tQueryTime, (unsigned int) tRetrieveTime, (unsigned int) tTotalTime));
|
||||
}
|
||||
|
||||
void TDataBaseServer::ProcessFormQuery(const wxString& strFileName, THashTable& hashArgs)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "BaseServ.h"
|
||||
#include "baseserv.h"
|
||||
#include <wx/hashmap.h>
|
||||
#include <wx/mstream.h>
|
||||
|
||||
@ -360,7 +360,7 @@ void TDictionaryServer::GenerateIndex(TXmlItem& body)
|
||||
wxChar cLast = '\0';
|
||||
for (size_t i = 0; i < m_DevotoOli.size(); i++)
|
||||
{
|
||||
const wxChar cCurr = toupper(m_DevotoOli.OriginalEntry(i)[0]);
|
||||
const wxChar cCurr = toupper(m_DevotoOli.OriginalEntry(i)[0u]);
|
||||
if (cCurr > cLast)
|
||||
{
|
||||
TXmlItem& td = tr.AddChild("td").SetAttr("align", "center");
|
||||
@ -413,7 +413,7 @@ void TDictionaryServer::GenerateFile(wxString& strFilename)
|
||||
}
|
||||
if (strName == "dictionary")
|
||||
{
|
||||
const wxChar cFilter = strArgs.IsEmpty() ? 'A' : toupper(strArgs[0]);
|
||||
const wxChar cFilter = strArgs.IsEmpty() ? 'A' : toupper(strArgs[ 0u]);
|
||||
GenerateIndex(body);
|
||||
|
||||
TXmlItem& table = body.AddChild("table");
|
||||
@ -446,9 +446,11 @@ size_t TDictionaryServer::FindIndex(const wxString& strKey)
|
||||
const wxChar cFirst = toupper(strKey[0]);
|
||||
const size_t nPos = atoi(strKey.Mid(2));
|
||||
size_t nFound = 0;
|
||||
for (size_t i = 0; i < m_DevotoOli.size(); i++)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < m_DevotoOli.size(); i++)
|
||||
{
|
||||
const wxChar c = toupper(m_DevotoOli.OriginalEntry(i)[0]);
|
||||
const wxChar c = toupper(m_DevotoOli.OriginalEntry(i)[ 0u]);
|
||||
if (c == cFirst)
|
||||
{
|
||||
if (nFound == nPos)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "BaseServ.h"
|
||||
#include "Dongle.h"
|
||||
#include "baseserv.h"
|
||||
#include "dongle.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBit_array
|
||||
@ -100,8 +100,8 @@ void TBit_array::reset(size_t n)
|
||||
_bit[i] &= ~mask(n);
|
||||
}
|
||||
|
||||
void TBit_array::not(size_t n)
|
||||
{
|
||||
void TBit_array::neg(size_t n)
|
||||
{
|
||||
const size_t i = index(n);
|
||||
if (i >= _size) resize(i);
|
||||
_bit[i] ^= mask(n);
|
||||
@ -212,7 +212,9 @@ wxString encode(const wxChar* data)
|
||||
{
|
||||
wxString tmp;
|
||||
wxChar* buf = tmp.GetWriteBuf(80);
|
||||
for (int i = 0; data[i]; i++)
|
||||
int i;
|
||||
|
||||
for (i = 0; data[i]; i++)
|
||||
buf[i] = data[i] + (i < 8 ? encryption_key[i] : data[i - 8]);
|
||||
buf[i] = '\0';
|
||||
tmp.UngetWriteBuf();
|
||||
@ -223,7 +225,9 @@ wxString decode(const char* data)
|
||||
{
|
||||
wxString tmp;
|
||||
wxChar* buf = tmp.GetWriteBuf(80);
|
||||
for (int i = 0; data[i]; i++)
|
||||
int i;
|
||||
|
||||
for (i = 0; data[i]; i++)
|
||||
buf[i] = data[i] - (i < 8 ? encryption_key[i] : buf[i - 8]);
|
||||
buf[i] = '\0';
|
||||
tmp.UngetWriteBuf();
|
||||
@ -247,9 +251,18 @@ wxString decode(const char* data)
|
||||
///////////////////////////////////////////////////////////
|
||||
// Smartkey stuff
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef WIN32
|
||||
#include "skeylink.h"
|
||||
static KEY_NET* _eutron_key = NULL;
|
||||
#else
|
||||
#include "skeylinux.h"
|
||||
#define smartlink clink
|
||||
#define KEY_NET SKEY_DATA
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
#endif
|
||||
|
||||
static KEY_NET * _eutron_key = NULL;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
@ -299,7 +312,7 @@ unsigned long TEutronFooter::checksum(bool set)
|
||||
|
||||
const unsigned short offset = sizeof(_size) + sizeof(_checksum);
|
||||
unsigned char* ptr = (unsigned char*)(&_size) + offset;
|
||||
const unsigned short len = unsigned short(_size - offset);
|
||||
const unsigned short len = (unsigned short)(_size - offset);
|
||||
|
||||
unsigned long cs = 0;
|
||||
for (unsigned short i = 0; i < len; i++, ptr++)
|
||||
@ -344,7 +357,7 @@ inline void reset_bit(unsigned short& w, unsigned char b)
|
||||
|
||||
TDongle::TDongle()
|
||||
: _hardware(_dongle_unknown), _type(_no_dongle), _serno(0xFFFF),
|
||||
_dirty(false), _max_users(1), _year_assist(2002)
|
||||
_max_users(1), _year_assist(2002), _dirty(false)
|
||||
{
|
||||
memset(_eprom, 0, sizeof(_eprom));
|
||||
}
|
||||
@ -368,7 +381,9 @@ void TDongle::garble(unsigned short* data) const
|
||||
case _dongle_eutron:
|
||||
if (_eutron_key)
|
||||
{
|
||||
#ifdef WIN32
|
||||
_eutron_key->net_command = NET_KEY_ACCESS;
|
||||
#endif
|
||||
_eutron_key->command = SCRAMBLING_MODE;
|
||||
memcpy(_eutron_key->data, data, 8);
|
||||
smartlink(_eutron_key);
|
||||
@ -406,7 +421,7 @@ bool TDongle::already_programmed() const
|
||||
return false; // Really virgin.
|
||||
|
||||
unsigned long cs = 0;
|
||||
for (byte* ptr = (byte*)_eprom; ptr < (byte*)&eh->_checksum; ptr++)
|
||||
for (byte * ptr = (byte*)_eprom; ptr < (byte*)&eh->_checksum; ptr++)
|
||||
cs += *ptr | ~(short(*ptr << 8));
|
||||
if (eh->_checksum != cs)
|
||||
return false; // Malicious programming!
|
||||
@ -545,8 +560,13 @@ bool TDongle::eutron_login(bool test_all_keys)
|
||||
if (_eutron_key == NULL)
|
||||
_eutron_key = new KEY_NET;
|
||||
memset(_eutron_key, 0, sizeof(KEY_NET));
|
||||
|
||||
#ifdef WIN32
|
||||
_eutron_key->net_command = NET_KEY_OPEN;
|
||||
// _eutron_key->command = LOCATING_MODE;
|
||||
#else
|
||||
_eutron_key->command = LOCATING_MODE;
|
||||
#endif
|
||||
|
||||
_eutron_key->status = ST_HW_FAILURE; // Don't leave ST_OK = 0 here!
|
||||
|
||||
const char* labels[5] = { "AGA.INFORMATICA", "AGA.PRASSI", "AGA.PROCOM",
|
||||
@ -678,7 +698,9 @@ bool TDongle::Logout()
|
||||
case _dongle_eutron:
|
||||
if (_eutron_key)
|
||||
{
|
||||
#ifdef WIN32
|
||||
_eutron_key->net_command = NET_KEY_CLOSE;
|
||||
#endif
|
||||
_eutron_key->command = 0;
|
||||
smartlink(_eutron_key);
|
||||
}
|
||||
@ -725,7 +747,9 @@ bool TDongle::read_words(unsigned short reg, unsigned short len, unsigned short*
|
||||
case _dongle_eutron:
|
||||
if (_eutron_key)
|
||||
{
|
||||
#ifdef WIN32
|
||||
_eutron_key->net_command = NET_KEY_ACCESS;
|
||||
#endif
|
||||
_eutron_key->command = BLOCK_READING_MODE;
|
||||
unsigned short* pointer = (unsigned short*)(&_eutron_key->data[0]);
|
||||
unsigned short* number = (unsigned short*)(&_eutron_key->data[2]);
|
||||
@ -782,7 +806,9 @@ bool TDongle::write_words(unsigned short reg, unsigned short len, unsigned short
|
||||
case _dongle_eutron:
|
||||
if (_eutron_key)
|
||||
{
|
||||
#ifdef WIN32
|
||||
_eutron_key->net_command = NET_KEY_ACCESS;
|
||||
#endif
|
||||
_eutron_key->command = BLOCK_WRITING_MODE;
|
||||
unsigned short* pointer = (unsigned short*)(&_eutron_key->data[0]);
|
||||
unsigned short* number = (unsigned short*)(&_eutron_key->data[2]);
|
||||
|
@ -11,8 +11,8 @@ enum { MAX_DONGLE_ASSIST = 8 };
|
||||
|
||||
class TBit_array : public wxObject
|
||||
{
|
||||
size_t _size;
|
||||
unsigned char* _bit;
|
||||
size_t _size;
|
||||
|
||||
protected:
|
||||
virtual bool ok() const;
|
||||
@ -22,7 +22,7 @@ protected:
|
||||
size_t index(size_t n) const
|
||||
{ return size_t(n / 8); }
|
||||
unsigned long mask(size_t n) const
|
||||
{ return unsigned long(1 << (n & 0x7)); }
|
||||
{ return (unsigned long)(1 << (n & 0x7)); }
|
||||
|
||||
public:
|
||||
TBit_array(size_t size = 0);
|
||||
@ -40,7 +40,7 @@ public:
|
||||
|
||||
void set(size_t n);
|
||||
void reset(size_t n);
|
||||
void not(size_t n);
|
||||
void neg(size_t n);
|
||||
|
||||
void set(size_t n, bool on) { on ? set(n) : reset(n); }
|
||||
void set();
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "BaseServ.h"
|
||||
#include "baseserv.h"
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/msw/iniconf.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@ -88,11 +87,13 @@ void TLerchServer::GenerateFile(wxString& strFilename)
|
||||
TXmlItem& table = body.AddChild("table");
|
||||
table.SetAttr("border", "1"); table.SetAttr("width", "100%");
|
||||
strFilename = GetTempFilename();
|
||||
const wxString LerchName = GetAppName();
|
||||
|
||||
wxArrayString arr; CreateServersList(arr);
|
||||
for (size_t i = 0; i < arr.GetCount(); i++)
|
||||
{
|
||||
wxIniConfig ini("", "", GetConfigName());
|
||||
const bool lerch = arr[i] == LerchName;
|
||||
wxFileConfig ini("", "", GetConfigName(), "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
|
||||
wxString str;
|
||||
str << '/' << arr[i];
|
||||
ini.SetPath(str);
|
||||
@ -113,16 +114,24 @@ void TLerchServer::GenerateFile(wxString& strFilename)
|
||||
TXmlItem& td0 = tr.AddChild("td");
|
||||
td0.SetAttr("width", "15%"); td0.SetAttr("align", "center");
|
||||
TXmlItem& a = td0.AddChild("a");
|
||||
a.SetAttr("href", wxString::Format("http://%s:%d/index.htm", strHost, nPort));
|
||||
TXmlItem& img = a.AddChild("img");
|
||||
if (!lerch && bRunning)
|
||||
{
|
||||
a.SetAttr("href", wxString::Format("http://%s:%d/index.htm", strHost.c_str(), nPort));
|
||||
a.SetAttr("target", "_blank");
|
||||
}
|
||||
TXmlItem& img = a.AddChild("img");
|
||||
img.SetAttr("src", strIcon); img.SetAttr("border", 0L); img.SetAttr("alt", arr[i]);
|
||||
|
||||
AddMiniForm(tr, bRunning ? "kill.cgi" : "start.cgi", arr[i], bRunning ? "Stop" : "Start");
|
||||
AddMiniForm(tr, (bRunning || lerch) ? "kill.cgi" : "start.cgi", arr[i], (bRunning || lerch) ? "Stop" : "Start");
|
||||
AddMiniForm(tr, "config.cgi", arr[i], "Configure");
|
||||
|
||||
TXmlItem& a3 = tr.AddChild("td").AddChild("a");
|
||||
a3.SetAttr("href", wxString::Format("http://%s:%d/index.htm", strHost, nPort));
|
||||
a3 << arr[i] << " Server";
|
||||
if (!lerch && bRunning)
|
||||
{
|
||||
a3.SetAttr("href", wxString::Format("http://%s:%d/index.htm", strHost.c_str(), nPort));
|
||||
a3.SetAttr("target", "_blank");
|
||||
}
|
||||
a3 << arr[i] << " Server";
|
||||
}
|
||||
|
||||
html.Save(strFilename);
|
||||
@ -172,20 +181,26 @@ void TLerchServer::ProcessFormStart(const THashTable& args, wxSocketBase& sock)
|
||||
|
||||
if (ok)
|
||||
{
|
||||
const wxString strRun = GetConfigString("Run", "", strApp);
|
||||
wxString strRun = GetConfigString("Run", "", strApp);
|
||||
if (wxFileExists(strRun))
|
||||
{
|
||||
#ifdef LINUX
|
||||
if (strRun[ 0u] != '/' && strRun[ 0u] != '.')
|
||||
strRun = "./" + strRun;
|
||||
#endif
|
||||
const long nProc = wxExecute(strRun);
|
||||
if (nProc == 0 || nProc == -1)
|
||||
MessageBox("ERROR", wxString::Format("Can't run %s executable (%s)", strApp, strRun), sock);
|
||||
MessageBox("ERROR", wxString::Format("Can't run %s executable (%s)", strApp.c_str(),
|
||||
strRun.c_str()), sock);
|
||||
else
|
||||
MessageBox("Server Started", strApp, sock);
|
||||
}
|
||||
else
|
||||
MessageBox("ERROR", wxString::Format("Can't find %s executable (%s)", strApp, strRun), sock);
|
||||
MessageBox("ERROR", wxString::Format("Can't find %s executable (%s)", strApp.c_str(),
|
||||
strRun.c_str()), sock);
|
||||
}
|
||||
else
|
||||
MessageBox("ERROR", wxString::Format("%s il already running", strApp), sock);
|
||||
MessageBox("ERROR", wxString::Format("%s il already running", strApp.c_str()), sock);
|
||||
}
|
||||
|
||||
void TLerchServer::KillProcess(const wxString& strApp)
|
||||
@ -219,7 +234,7 @@ void TLerchServer::ProcessFormKill(const THashTable& args, wxSocketBase& sock)
|
||||
if (strApp == GetAppName()) // Stop myself!
|
||||
{
|
||||
wxArrayString app; CreateServersList(app);
|
||||
for (size_t i = 0; i < app.GetCount(); i++)
|
||||
for (size_t i = 0; i < app.GetCount(); i++)
|
||||
{
|
||||
if (app[i] != GetAppName()) // Stop Children only!
|
||||
{
|
||||
@ -236,7 +251,7 @@ void TLerchServer::ProcessFormKill(const THashTable& args, wxSocketBase& sock)
|
||||
void TLerchServer::EnumerateVariables(const wxString& strApp, wxArrayString& arr) const
|
||||
{
|
||||
wxFileInputStream inf(GetConfigName());
|
||||
wxString strParagraph = wxString::Format("[%s]", strApp);
|
||||
wxString strParagraph = wxString::Format("[%s]", strApp.c_str());
|
||||
wxString str;
|
||||
|
||||
bool bFound = false;
|
||||
@ -255,7 +270,7 @@ void TLerchServer::EnumerateVariables(const wxString& strApp, wxArrayString& arr
|
||||
while (inf.Ok())
|
||||
{
|
||||
inf >> str;
|
||||
if (str.IsEmpty() || str[0] == '[')
|
||||
if (str.IsEmpty() || str[0u] == '[')
|
||||
break;
|
||||
const int nEqual = str.Find('=');
|
||||
if (nEqual > 0)
|
||||
@ -325,7 +340,7 @@ void TLerchServer::ProcessFormUpdate(THashTable& args, wxSocketBase& sock)
|
||||
SetConfigString(strKey, strVal, strApp);
|
||||
}
|
||||
}
|
||||
const wxString msg = wxString::Format("%s parameters updated", strApp);
|
||||
const wxString msg = wxString::Format("%s parameters updated", strApp.c_str());
|
||||
MessageBox("Success!", msg, sock);
|
||||
}
|
||||
|
||||
@ -416,7 +431,13 @@ bool TLerchServer::Initialization()
|
||||
{
|
||||
wxString strRun = GetConfigString("Run", "", strApp);
|
||||
if (wxFileExists(strRun))
|
||||
{
|
||||
#ifdef LINUX
|
||||
if (strRun[ 0u] != '/' && strRun[ 0u] != '.')
|
||||
strRun = "./" + strRun;
|
||||
#endif
|
||||
wxExecute(strRun);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
84
server/skeylinux.h
Executable file
84
server/skeylinux.h
Executable file
@ -0,0 +1,84 @@
|
||||
#ifndef __SKEYLINK_H
|
||||
#define __SKEYLINK_H
|
||||
|
||||
#ifndef __SKEYDRV_H
|
||||
#define __SKEYDRV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
/* Smartkey mode codes */
|
||||
|
||||
#define SCRAMBLING_MODE 's'
|
||||
#define READING_MODE 'r'
|
||||
#define WRITING_MODE 'w'
|
||||
#define FIXING_MODE 'f'
|
||||
#define LOCATING_MODE 'l'
|
||||
#define COMPARING_MODE 'c'
|
||||
#define PROGRAMMING_MODE 'p'
|
||||
#define MODEL_READING_MODE 'm'
|
||||
#define ENCRYPTING_MODE 'e'
|
||||
#define SERIAL_NUMBER_READING_MODE 'n'
|
||||
#define FIX_READING_MODE 'x'
|
||||
#define EXT_MODEL_READING_MODE 'h'
|
||||
#define FAIL_COUNTER_READING_MODE 'a'
|
||||
#define BLOCK_READING_MODE ('b' | ((unsigned)'r' << 8))
|
||||
#define BLOCK_WRITING_MODE ('b' | ((unsigned)'w' << 8))
|
||||
|
||||
/***************************************************************************/
|
||||
/* Smartkey models */
|
||||
|
||||
#define SKEY_NONE '0' /* No Smartkey */
|
||||
#define SKEY_FX '1' /* Smartkey mod. FX */
|
||||
#define SKEY_PR '2' /* Smartkey mod. PR */
|
||||
#define SKEY_EP '3' /* Smartkey mod. EP */
|
||||
#define SKEY_SP '9' /* Smartkey mod. SP */
|
||||
#define SKEY_NET 'A' /* Smartkey mod. NET */
|
||||
|
||||
/***************************************************************************/
|
||||
/* Return codes */
|
||||
|
||||
#define ST_OK 0 /* No errors */
|
||||
#define ST_NONE_KEY -1 /* No Smartkey present */
|
||||
#define ST_SYNT_ERR -2 /* Syntax error */
|
||||
#define ST_LABEL_FAILED -3 /* Uncorrect label */
|
||||
#define ST_PW_DATA_FAILED -4 /* Uncorrect password or data */
|
||||
#define ST_HW_FAILURE -20 /* Smartkey damaged */
|
||||
|
||||
/***************************************************************************/
|
||||
/* Field length */
|
||||
|
||||
#define LABEL_LENGTH 16
|
||||
#define PASSWORD_LENGTH 16
|
||||
#define DATA_LENGTH 64
|
||||
#define EXTENDED_DATA_LENGTH 352
|
||||
#define SCRAMBLE_LENGTH 8
|
||||
|
||||
/***************************************************************************/
|
||||
/* Communication structure definition */
|
||||
|
||||
typedef struct smartkey {
|
||||
short lpt;
|
||||
short command;
|
||||
unsigned char label[LABEL_LENGTH];
|
||||
unsigned char password[PASSWORD_LENGTH];
|
||||
unsigned char data[DATA_LENGTH];
|
||||
short fail_counter;
|
||||
short status;
|
||||
unsigned char ext_data[EXTENDED_DATA_LENGTH];
|
||||
} SKEY_DATA;
|
||||
|
||||
/***************************************************************************/
|
||||
/* Interface function prototype */
|
||||
|
||||
int clink(SKEY_DATA*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -31,15 +31,15 @@ wxInputStream& operator>>(wxInputStream& inf, wxString& str)
|
||||
const int nEol = str.Find('\n');
|
||||
if (nEol >= 0)
|
||||
{
|
||||
if (str[nEol+1] > '\0')
|
||||
inf.SeekI(nStart+nEol+1);
|
||||
if (str[(size_t)(nEol+1)] > '\0')
|
||||
inf.SeekI(nStart+nEol+1, (wxSeekMode) 0);
|
||||
str.Truncate(nEol);
|
||||
str.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!str.IsEmpty())
|
||||
inf.SeekI(nStart+str.Length());
|
||||
inf.SeekI(nStart+str.Length(), (wxSeekMode) 0);
|
||||
}
|
||||
|
||||
return inf;
|
||||
@ -253,7 +253,7 @@ int TXmlItem::ReadTag(wxInputStream& inf)
|
||||
if (str.IsEmpty())
|
||||
return -1;
|
||||
|
||||
if (str[0] != '<') // No tag = sequence of words
|
||||
if (str[ 0u] != '<') // No tag = sequence of words
|
||||
{
|
||||
bool bFirstChar = true;
|
||||
while (!inf.Eof())
|
||||
@ -291,10 +291,10 @@ int TXmlItem::ReadTag(wxInputStream& inf)
|
||||
wxString name = GetWord(inf);
|
||||
while (!name.IsEmpty())
|
||||
{
|
||||
if (name[0] == '>')
|
||||
if (name[ 0u] == '>')
|
||||
return bChildrenFollow ? +1 : 0;
|
||||
|
||||
if (name[0] == '/')
|
||||
if (name[0u] == '/')
|
||||
{
|
||||
bChildrenFollow = false;
|
||||
continue;
|
||||
@ -302,7 +302,7 @@ int TXmlItem::ReadTag(wxInputStream& inf)
|
||||
|
||||
// Ho letto un nome di attributo
|
||||
wxString str = GetWord(inf);
|
||||
if (str.IsEmpty() || str[0] != '=')
|
||||
if (str.IsEmpty() || str[0u] != '=')
|
||||
break;
|
||||
// Leggo il valore dell'attributo
|
||||
str = GetWord(inf);
|
||||
@ -372,7 +372,7 @@ bool TXmlItem::Read(wxInputStream& inf)
|
||||
TXmlItem& item = AddChild("/"); // Add dummy child
|
||||
if (item.Read(inf))
|
||||
{
|
||||
if (item.m_strTag[0] == '/')
|
||||
if (item.m_strTag[0u] == '/')
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -455,7 +455,9 @@ void TXmlItem::Write(wxOutputStream& outf, int tab) const
|
||||
if (GetChildren() > 0)
|
||||
{
|
||||
outf << ">";
|
||||
for (int n = 0; ; n++)
|
||||
int n;
|
||||
|
||||
for (n = 0; ; n++)
|
||||
{
|
||||
TXmlItem* c = GetChild(n);
|
||||
if (c == NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user