Patch level : 12.00

Files correlati     : cg0.exe cg0700a.msk cg0700b.msk cg3.exe cg4.exe

Bug                 :

Commento:
Merge 1.0 libraries
This commit is contained in:
Alessandro Bonazzi 2025-04-05 15:22:18 +02:00
parent 71a9202055
commit 8f8b450425
54 changed files with 31955 additions and 0 deletions

536
src/xvaga01/MD5Checksum.cpp Normal file
View File

@ -0,0 +1,536 @@
/*****************************************************************************************
*** MD5Checksum.cpp: implementation of the MD5Checksum class.
*** Developed by Langfine Ltd.
*** Released to the public domain 12/Nov/2001.
*** Please visit our website www.langfine.com
*** Any modifications must be clearly commented to distinguish them from Langfine's
*** original source code. Please advise Langfine of useful modifications so that we
*** can make them generally available.
*****************************************************************************************/
/****************************************************************************************
This software is derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
Incorporation of this statement is a condition of use; please see the RSA
Data Security Inc copyright notice below:-
Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
rights reserved.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*****************************************************************************************/
/****************************************************************************************
This implementation of the RSA MD5 Algorithm was written by Langfine Ltd
(www.langfine.com).
Langfine Ltd makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
In addition to the above, Langfine make no warrant or assurances regarding the
accuracy of this implementation of the MD5 checksum algorithm nor any assurances regarding
its suitability for any purposes.
This implementation may be used freely provided that Langfine is credited
in a copyright or similar notices (eg, RSA MD5 Algorithm implemented by Langfine
Ltd.) and provided that the RSA Data Security notices are complied with.
*/
#include "wxinc.h"
#include "MD5Checksum.h"
#include "MD5ChecksumDefines.h"
#include <wx/file.h>
#include "wx/filename.h"
/*****************************************************************************************
FUNCTION: wxMD5Checksum::GetMD5
DETAILS: static, public
DESCRIPTION: Gets the MD5 checksum for a specified file
RETURNS: wxString : the hexadecimal MD5 checksum for the specified file
ARGUMENTS: wxString& strFilePath : the full pathname of the specified file
NOTES: Provides an interface to the wxMD5Checksum class. 'strFilePath' name should
hold the full pathname of the file, eg C:\My Documents\Arcticle.txt.
NB. If any problems occur with opening or reading this file, a CFileException
will be thrown; callers of this function should be ready to catch this
exception.
*****************************************************************************************/
wxString wxMD5Checksum::GetMD5(const wxString& strFilePath)
{
if(!wxFileName::FileExists(strFilePath))
return wxEmptyString;
//open the file as a binary file in readonly mode, denying write access
wxFile File(strFilePath, wxFile::read);
//the file has been successfully opened, so now get and return its checksum
return GetMD5(File);
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::GetMD5
DETAILS: static, public
DESCRIPTION: Gets the MD5 checksum for a specified file
RETURNS: wxString : the hexadecimal MD5 checksum for the specified file
ARGUMENTS: wxFile& File : the specified file
NOTES: Provides an interface to the wxMD5Checksum class. 'File' should be open in
binary readonly mode before calling this function.
NB. Callers of this function should be ready to catch any CFileException
thrown by the wxFile functions
*****************************************************************************************/
wxString wxMD5Checksum::GetMD5(wxFile& File)
{
wxMD5Checksum MD5Checksum; //checksum object
int nLength = 0; //number of bytes read from the file
const int nBufferSize = 1024; //checksum the file in blocks of 1024 bytes
unsigned char Buffer[nBufferSize]; //buffer for data read from the file
//checksum the file in blocks of 1024 bytes
while ((nLength = File.Read( Buffer, nBufferSize )) > 0 )
{
MD5Checksum.Update( Buffer, nLength );
}
//finalise the checksum and return it
return MD5Checksum.Final();
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::GetMD5
DETAILS: static, public
DESCRIPTION: Gets the MD5 checksum for data in a unsigned char array
RETURNS: wxString : the hexadecimal MD5 checksum for the specified data
ARGUMENTS: unsigned char* pBuf : pointer to the unsigned char array
unsigned int nLength : number of BYTEs of data to be checksumed
NOTES: Provides an interface to the wxMD5Checksum class. Any data that can
be cast to a unsigned char array of known length can be checksummed by this
function. Typically, wxString and char arrays will be checksumed,
although this function can be used to check the integrity of any unsigned char array.
A buffer of zero length can be checksummed; all buffers of zero length
will return the same checksum.
*****************************************************************************************/
wxString wxMD5Checksum::GetMD5(unsigned char* pBuf, unsigned int nLength)
{
//calculate and return the checksum
wxMD5Checksum MD5Checksum;
MD5Checksum.Update( pBuf, nLength );
return MD5Checksum.Final();
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::RotateLeft
DETAILS: private
DESCRIPTION: Rotates the bits in a 32 bit unsigned long left by a specified amount
RETURNS: The rotated unsigned long
ARGUMENTS: unsigned long x : the value to be rotated
int n : the number of bits to rotate by
*****************************************************************************************/
unsigned long wxMD5Checksum::RotateLeft(unsigned long x, int n)
{
//check that unsigned long is 4 bytes long - true in Visual C++ 6 and 32 bit Windows
wxASSERT( sizeof(x) == 4 );
//rotate and return x
return (x << n) | (x >> (32-n));
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::FF
DETAILS: protected
DESCRIPTION: Implementation of basic MD5 transformation algorithm
RETURNS: none
ARGUMENTS: unsigned long &A, B, C, D : Current (partial) checksum
unsigned long X : Input data
unsigned long S : MD5_SXX Transformation constant
unsigned long T : MD5_TXX Transformation constant
NOTES: None
*****************************************************************************************/
void wxMD5Checksum::FF( unsigned long& A, unsigned long B, unsigned long C, unsigned long D, unsigned long X, unsigned long S, unsigned long T)
{
unsigned long F = (B & C) | (~B & D);
A += F + X + T;
A = RotateLeft(A, S);
A += B;
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::GG
DETAILS: protected
DESCRIPTION: Implementation of basic MD5 transformation algorithm
RETURNS: none
ARGUMENTS: unsigned long &A, B, C, D : Current (partial) checksum
unsigned long X : Input data
unsigned long S : MD5_SXX Transformation constant
unsigned long T : MD5_TXX Transformation constant
NOTES: None
*****************************************************************************************/
void wxMD5Checksum::GG( unsigned long& A, unsigned long B, unsigned long C, unsigned long D, unsigned long X, unsigned long S, unsigned long T)
{
unsigned long G = (B & D) | (C & ~D);
A += G + X + T;
A = RotateLeft(A, S);
A += B;
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::HH
DETAILS: protected
DESCRIPTION: Implementation of basic MD5 transformation algorithm
RETURNS: none
ARGUMENTS: unsigned long &A, B, C, D : Current (partial) checksum
unsigned long X : Input data
unsigned long S : MD5_SXX Transformation constant
unsigned long T : MD5_TXX Transformation constant
NOTES: None
*****************************************************************************************/
void wxMD5Checksum::HH( unsigned long& A, unsigned long B, unsigned long C, unsigned long D, unsigned long X, unsigned long S, unsigned long T)
{
unsigned long H = (B ^ C ^ D);
A += H + X + T;
A = RotateLeft(A, S);
A += B;
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::II
DETAILS: protected
DESCRIPTION: Implementation of basic MD5 transformation algorithm
RETURNS: none
ARGUMENTS: unsigned long &A, B, C, D : Current (partial) checksum
unsigned long X : Input data
unsigned long S : MD5_SXX Transformation constant
unsigned long T : MD5_TXX Transformation constant
NOTES: None
*****************************************************************************************/
void wxMD5Checksum::II( unsigned long& A, unsigned long B, unsigned long C, unsigned long D, unsigned long X, unsigned long S, unsigned long T)
{
unsigned long I = (C ^ (B | ~D));
A += I + X + T;
A = RotateLeft(A, S);
A += B;
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::ByteToDWord
DETAILS: private
DESCRIPTION: Transfers the data in an 8 bit array to a 32 bit array
RETURNS: void
ARGUMENTS: unsigned long* Output : the 32 bit (unsigned long) destination array
unsigned char* Input : the 8 bit (unsigned char) source array
unsigned int nLength : the number of 8 bit data items in the source array
NOTES: Four BYTES from the input array are transferred to each unsigned long entry
of the output array. The first unsigned char is transferred to the bits (0-7)
of the output unsigned long, the second unsigned char to bits 8-15 etc.
The algorithm assumes that the input array is a multiple of 4 bytes long
so that there is a perfect fit into the array of 32 bit words.
*****************************************************************************************/
void wxMD5Checksum::ByteToDWord(unsigned long* Output, unsigned char* Input, unsigned int nLength)
{
//entry invariants
wxASSERT( nLength % 4 == 0 );
//initialisations
unsigned int i=0; //index to Output array
unsigned int j=0; //index to Input array
//transfer the data by shifting and copying
for ( ; j < nLength; i++, j += 4)
{
Output[i] = (unsigned long)Input[j] |
(unsigned long)Input[j+1] << 8 |
(unsigned long)Input[j+2] << 16 |
(unsigned long)Input[j+3] << 24;
}
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::Transform
DETAILS: protected
DESCRIPTION: MD5 basic transformation algorithm; transforms 'm_lMD5'
RETURNS: void
ARGUMENTS: unsigned char Block[64]
NOTES: An MD5 checksum is calculated by four rounds of 'Transformation'.
The MD5 checksum currently held in m_lMD5 is merged by the
transformation process with data passed in 'Block'.
*****************************************************************************************/
void wxMD5Checksum::Transform(unsigned char Block[64])
{
//initialise local data with current checksum
unsigned long a = m_lMD5[0];
unsigned long b = m_lMD5[1];
unsigned long c = m_lMD5[2];
unsigned long d = m_lMD5[3];
//copy BYTES from input 'Block' to an array of ULONGS 'X'
unsigned long X[16];
ByteToDWord( X, Block, 64 );
//Perform Round 1 of the transformation
FF (a, b, c, d, X[ 0], MD5_S11, MD5_T01);
FF (d, a, b, c, X[ 1], MD5_S12, MD5_T02);
FF (c, d, a, b, X[ 2], MD5_S13, MD5_T03);
FF (b, c, d, a, X[ 3], MD5_S14, MD5_T04);
FF (a, b, c, d, X[ 4], MD5_S11, MD5_T05);
FF (d, a, b, c, X[ 5], MD5_S12, MD5_T06);
FF (c, d, a, b, X[ 6], MD5_S13, MD5_T07);
FF (b, c, d, a, X[ 7], MD5_S14, MD5_T08);
FF (a, b, c, d, X[ 8], MD5_S11, MD5_T09);
FF (d, a, b, c, X[ 9], MD5_S12, MD5_T10);
FF (c, d, a, b, X[10], MD5_S13, MD5_T11);
FF (b, c, d, a, X[11], MD5_S14, MD5_T12);
FF (a, b, c, d, X[12], MD5_S11, MD5_T13);
FF (d, a, b, c, X[13], MD5_S12, MD5_T14);
FF (c, d, a, b, X[14], MD5_S13, MD5_T15);
FF (b, c, d, a, X[15], MD5_S14, MD5_T16);
//Perform Round 2 of the transformation
GG (a, b, c, d, X[ 1], MD5_S21, MD5_T17);
GG (d, a, b, c, X[ 6], MD5_S22, MD5_T18);
GG (c, d, a, b, X[11], MD5_S23, MD5_T19);
GG (b, c, d, a, X[ 0], MD5_S24, MD5_T20);
GG (a, b, c, d, X[ 5], MD5_S21, MD5_T21);
GG (d, a, b, c, X[10], MD5_S22, MD5_T22);
GG (c, d, a, b, X[15], MD5_S23, MD5_T23);
GG (b, c, d, a, X[ 4], MD5_S24, MD5_T24);
GG (a, b, c, d, X[ 9], MD5_S21, MD5_T25);
GG (d, a, b, c, X[14], MD5_S22, MD5_T26);
GG (c, d, a, b, X[ 3], MD5_S23, MD5_T27);
GG (b, c, d, a, X[ 8], MD5_S24, MD5_T28);
GG (a, b, c, d, X[13], MD5_S21, MD5_T29);
GG (d, a, b, c, X[ 2], MD5_S22, MD5_T30);
GG (c, d, a, b, X[ 7], MD5_S23, MD5_T31);
GG (b, c, d, a, X[12], MD5_S24, MD5_T32);
//Perform Round 3 of the transformation
HH (a, b, c, d, X[ 5], MD5_S31, MD5_T33);
HH (d, a, b, c, X[ 8], MD5_S32, MD5_T34);
HH (c, d, a, b, X[11], MD5_S33, MD5_T35);
HH (b, c, d, a, X[14], MD5_S34, MD5_T36);
HH (a, b, c, d, X[ 1], MD5_S31, MD5_T37);
HH (d, a, b, c, X[ 4], MD5_S32, MD5_T38);
HH (c, d, a, b, X[ 7], MD5_S33, MD5_T39);
HH (b, c, d, a, X[10], MD5_S34, MD5_T40);
HH (a, b, c, d, X[13], MD5_S31, MD5_T41);
HH (d, a, b, c, X[ 0], MD5_S32, MD5_T42);
HH (c, d, a, b, X[ 3], MD5_S33, MD5_T43);
HH (b, c, d, a, X[ 6], MD5_S34, MD5_T44);
HH (a, b, c, d, X[ 9], MD5_S31, MD5_T45);
HH (d, a, b, c, X[12], MD5_S32, MD5_T46);
HH (c, d, a, b, X[15], MD5_S33, MD5_T47);
HH (b, c, d, a, X[ 2], MD5_S34, MD5_T48);
//Perform Round 4 of the transformation
II (a, b, c, d, X[ 0], MD5_S41, MD5_T49);
II (d, a, b, c, X[ 7], MD5_S42, MD5_T50);
II (c, d, a, b, X[14], MD5_S43, MD5_T51);
II (b, c, d, a, X[ 5], MD5_S44, MD5_T52);
II (a, b, c, d, X[12], MD5_S41, MD5_T53);
II (d, a, b, c, X[ 3], MD5_S42, MD5_T54);
II (c, d, a, b, X[10], MD5_S43, MD5_T55);
II (b, c, d, a, X[ 1], MD5_S44, MD5_T56);
II (a, b, c, d, X[ 8], MD5_S41, MD5_T57);
II (d, a, b, c, X[15], MD5_S42, MD5_T58);
II (c, d, a, b, X[ 6], MD5_S43, MD5_T59);
II (b, c, d, a, X[13], MD5_S44, MD5_T60);
II (a, b, c, d, X[ 4], MD5_S41, MD5_T61);
II (d, a, b, c, X[11], MD5_S42, MD5_T62);
II (c, d, a, b, X[ 2], MD5_S43, MD5_T63);
II (b, c, d, a, X[ 9], MD5_S44, MD5_T64);
//add the transformed values to the current checksum
m_lMD5[0] += a;
m_lMD5[1] += b;
m_lMD5[2] += c;
m_lMD5[3] += d;
}
/*****************************************************************************************
CONSTRUCTOR: wxMD5Checksum
DESCRIPTION: Initialises member data
ARGUMENTS: None
NOTES: None
*****************************************************************************************/
wxMD5Checksum::wxMD5Checksum()
{
// zero members
memset( m_lpszBuffer, 0, 64 );
m_nCount[0] = m_nCount[1] = 0;
// Load magic state initialization constants
m_lMD5[0] = MD5_INIT_STATE_0;
m_lMD5[1] = MD5_INIT_STATE_1;
m_lMD5[2] = MD5_INIT_STATE_2;
m_lMD5[3] = MD5_INIT_STATE_3;
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::DWordToByte
DETAILS: private
DESCRIPTION: Transfers the data in an 32 bit array to a 8 bit array
RETURNS: void
ARGUMENTS: unsigned char* Output : the 8 bit destination array
unsigned long* Input : the 32 bit source array
unsigned int nLength : the number of 8 bit data items in the source array
NOTES: One unsigned long from the input array is transferred into four BYTES
in the output array. The first (0-7) bits of the first unsigned long are
transferred to the first output unsigned char, bits bits 8-15 are transferred from
the second unsigned char etc.
The algorithm assumes that the output array is a multiple of 4 bytes long
so that there is a perfect fit of 8 bit BYTES into the 32 bit DWORDs.
*****************************************************************************************/
void wxMD5Checksum::DWordToByte(unsigned char* Output, unsigned long* Input, unsigned int nLength )
{
//entry invariants
wxASSERT( nLength % 4 == 0 );
//transfer the data by shifting and copying
unsigned int i = 0;
unsigned int j = 0;
for ( ; j < nLength; i++, j += 4)
{
Output[j] = (UCHAR)(Input[i] & 0xff);
Output[j+1] = (UCHAR)((Input[i] >> 8) & 0xff);
Output[j+2] = (UCHAR)((Input[i] >> 16) & 0xff);
Output[j+3] = (UCHAR)((Input[i] >> 24) & 0xff);
}
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::Final
DETAILS: protected
DESCRIPTION: Implementation of main MD5 checksum algorithm; ends the checksum calculation.
RETURNS: wxString : the final hexadecimal MD5 checksum result
ARGUMENTS: None
NOTES: Performs the final MD5 checksum calculation ('Update' does most of the work,
this function just finishes the calculation.)
*****************************************************************************************/
wxString wxMD5Checksum::Final()
{
//Save number of bits
unsigned char Bits[8];
DWordToByte( Bits, m_nCount, 8 );
//Pad out to 56 mod 64.
unsigned int nIndex = (unsigned int)((m_nCount[0] >> 3) & 0x3f);
unsigned int nPadLen = (nIndex < 56) ? (56 - nIndex) : (120 - nIndex);
Update( PADDING, nPadLen );
//Append length (before padding)
Update( Bits, 8 );
//Store final state in 'lpszMD5'
const int nMD5Size = 16;
unsigned char lpszMD5[ nMD5Size ];
DWordToByte( lpszMD5, m_lMD5, nMD5Size );
//Convert the hexadecimal checksum to a wxString
wxString strMD5;
for ( int i=0; i < nMD5Size; i++)
{
wxString Str;
if (lpszMD5[i] == 0) {
Str = wxT("00");
}
else if (lpszMD5[i] <= 15) {
Str.Printf(wxT("0%x"),lpszMD5[i]);
}
else {
Str.Printf(wxT("%x"),lpszMD5[i]);
}
wxASSERT( Str.Length() == 2 );
strMD5 += Str;
}
wxASSERT( strMD5.Length() == 32 );
return strMD5;
}
/*****************************************************************************************
FUNCTION: wxMD5Checksum::Update
DETAILS: protected
DESCRIPTION: Implementation of main MD5 checksum algorithm
RETURNS: void
ARGUMENTS: unsigned char* Input : input block
unsigned int nInputLen : length of input block
NOTES: Computes the partial MD5 checksum for 'nInputLen' bytes of data in 'Input'
*****************************************************************************************/
void wxMD5Checksum::Update( unsigned char* Input, unsigned long nInputLen )
{
//Compute number of bytes mod 64
unsigned int nIndex = (unsigned int)((m_nCount[0] >> 3) & 0x3F);
//Update number of bits
if ( ( m_nCount[0] += nInputLen << 3 ) < ( nInputLen << 3) )
{
m_nCount[1]++;
}
m_nCount[1] += (nInputLen >> 29);
//Transform as many times as possible.
unsigned int i=0;
unsigned int nPartLen = 64 - nIndex;
if (nInputLen >= nPartLen)
{
memcpy( &m_lpszBuffer[nIndex], Input, nPartLen );
Transform( m_lpszBuffer );
for (i = nPartLen; i + 63 < nInputLen; i += 64)
{
Transform( &Input[i] );
}
nIndex = 0;
}
else
{
i = 0;
}
// Buffer remaining input
memcpy( &m_lpszBuffer[nIndex], &Input[i], nInputLen-i);
}

342
src/xvaga01/MD5Checksum.h Normal file
View File

@ -0,0 +1,342 @@
/*****************************************************************************************
*** MD5Checksum.h: interface for the MD5Checksum class.
*** Developed by Langfine Ltd.
*** Released to the public domain 12/Nov/2001.
*** Please visit our website www.langfine.com
*** Any modifications must be clearly commented to distinguish them from Langfine's
*** original source code. Please advise Langfine of useful modifications so that we
*** can make them generally available.
*****************************************************************************************/
#ifndef __MD5CHECKSUM_H__
#define __MD5CHECKSUM_H__
/****************************************************************************************
This software is derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
Incorporation of this statement is a condition of use; please see the RSA
Data Security Inc copyright notice below:-
Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
rights reserved.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*****************************************************************************************/
/****************************************************************************************
This implementation of the RSA MD5 Algorithm was written by Langfine Ltd.
Langfine Ltd makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
In addition to the above, Langfine make no warrant or assurances regarding the
accuracy of this implementation of the MD5 checksum algorithm nor any assurances regarding
its suitability for any purposes.
This implementation may be used freely provided that Langfine is credited
in a copyright or similar notices (eg, RSA MD5 Algorithm implemented by Langfine
Ltd.) and provided that the RSA Data Security notices are complied with.
Langfine may be contacted at mail@langfine.com
*/
/*****************************************************************************************
CLASS: wxMD5Checksum
DESCRIPTION: Implements the "RSA Data Security, Inc. MD5 Message-Digest Algorithm".
NOTES: Calculates the RSA MD5 checksum for a file or congiguous array of data.
Below are extracts from a memo on The MD5 Message-Digest Algorithm by R. Rivest of MIT
Laboratory for Computer Science and RSA Data Security, Inc., April 1992.
1. Executive Summary
This document describes the MD5 message-digest algorithm. The
algorithm takes as input a message of arbitrary length and produces
as output a 128-bit "fingerprint" or "message digest" of the input.
It is conjectured that it is computationally infeasible to produce
two messages having the same message digest, or to produce any
message having a given prespecified target message digest. The MD5
algorithm is intended for digital signature applications, where a
large file must be "compressed" in a secure manner before being
encrypted with a private (secret) key under a public-key cryptosystem
such as RSA.
The MD5 algorithm is designed to be quite fast on 32-bit machines. In
addition, the MD5 algorithm does not require any large substitution
tables; the algorithm can be coded quite compactly.
The MD5 algorithm is an extension of the MD4 message-digest algorithm
1,2]. MD5 is slightly slower than MD4, but is more "conservative" in
design. MD5 was designed because it was felt that MD4 was perhaps
being adopted for use more quickly than justified by the existing
critical review; because MD4 was designed to be exceptionally fast,
it is "at the edge" in terms of risking successful cryptanalytic
attack. MD5 backs off a bit, giving up a little in speed for a much
greater likelihood of ultimate security. It incorporates some
suggestions made by various reviewers, and contains additional
optimizations. The MD5 algorithm is being placed in the public domain
for review and possible adoption as a standard.
2. Terminology and Notation
In this document a "word" is a 32-bit quantity and a "byte" is an
eight-bit quantity. A sequence of bits can be interpreted in a
natural manner as a sequence of bytes, where each consecutive group
of eight bits is interpreted as a byte with the high-order (most
significant) bit of each byte listed first. Similarly, a sequence of
bytes can be interpreted as a sequence of 32-bit words, where each
consecutive group of four bytes is interpreted as a word with the
low-order (least significant) byte given first.
Let x_i denote "x sub i". If the subscript is an expression, we
surround it in braces, as in x_{i+1}. Similarly, we use ^ for
superscripts (exponentiation), so that x^i denotes x to the i-th power.
Let the symbol "+" denote addition of words (i.e., modulo-2^32
addition). Let X <<< s denote the 32-bit value obtained by circularly
shifting (rotating) X left by s bit positions. Let not(X) denote the
bit-wise complement of X, and let X v Y denote the bit-wise OR of X
and Y. Let X xor Y denote the bit-wise XOR of X and Y, and let XY
denote the bit-wise AND of X and Y.
3. MD5 Algorithm Description
We begin by supposing that we have a b-bit message as input, and that
we wish to find its message digest. Here b is an arbitrary
nonnegative integer; b may be zero, it need not be a multiple of
eight, and it may be arbitrarily large. We imagine the bits of the
message written down as follows: m_0 m_1 ... m_{b-1}
The following five steps are performed to compute the message digest
of the message.
3.1 Step 1. Append Padding Bits
The message is "padded" (extended) so that its length (in bits) is
congruent to 448, modulo 512. That is, the message is extended so
that it is just 64 bits shy of being a multiple of 512 bits long.
Padding is always performed, even if the length of the message is
already congruent to 448, modulo 512.
Padding is performed as follows: a single "1" bit is appended to the
message, and then "0" bits are appended so that the length in bits of
the padded message becomes congruent to 448, modulo 512. In all, at
least one bit and at most 512 bits are appended.
3.2 Step 2. Append Length
A 64-bit representation of b (the length of the message before the
padding bits were added) is appended to the result of the previous
step. In the unlikely event that b is greater than 2^64, then only
the low-order 64 bits of b are used. (These bits are appended as two
32-bit words and appended low-order word first in accordance with the
previous conventions.)
At this point the resulting message (after padding with bits and with
b) has a length that is an exact multiple of 512 bits. Equivalently,
this message has a length that is an exact multiple of 16 (32-bit)
words. Let M[0 ... N-1] denote the words of the resulting message,
where N is a multiple of 16.
3.3 Step 3. Initialize MD Buffer
A four-word buffer (A,B,C,D) is used to compute the message digest.
Here each of A, B, C, D is a 32-bit register. These registers are
initialized to the following values in hexadecimal, low-order bytes first):
word A: 01 23 45 67 word B: 89 ab cd ef
word C: fe dc ba 98 word D: 76 54 32 10
3.4 Step 4. Process Message in 16-Word Blocks
We first define four auxiliary functions that each take as input
three 32-bit words and produce as output one 32-bit word.
F(X,Y,Z) = XY v not(X) Z G(X,Y,Z) = XZ v Y not(Z)
H(X,Y,Z) = X xor Y xor Z I(X,Y,Z) = Y xor (X v not(Z))
In each bit position F acts as a conditional: if X then Y else Z.
The function F could have been defined using + instead of v since XY
and not(X)Z will never have 1's in the same bit position.) It is
interesting to note that if the bits of X, Y, and Z are independent
and unbiased, the each bit of F(X,Y,Z) will be independent and unbiased.
The functions G, H, and I are similar to the function F, in that they
act in "bitwise parallel" to produce their output from the bits of X,
Y, and Z, in such a manner that if the corresponding bits of X, Y,
and Z are independent and unbiased, then each bit of G(X,Y,Z),
H(X,Y,Z), and I(X,Y,Z) will be independent and unbiased. Note that
the function H is the bit-wise "xor" or "parity" function of its inputs.
This step uses a 64-element table T[1 ... 64] constructed from the
sine function. Let T[i] denote the i-th element of the table, which
is equal to the integer part of 4294967296 times abs(sin(i)), where i
is in radians. The elements of the table are given in the appendix.
Do the following:
//Process each 16-word block.
For i = 0 to N/16-1 do // Copy block i into X.
For j = 0 to 15 do
Set X[j] to M[i*16+j].
end //of loop on j
// Save A as AA, B as BB, C as CC, and D as DD.
AA = A BB = B
CC = C DD = D
// Round 1.
// Let [abcd k s i] denote the operation
// a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s).
// Do the following 16 operations.
[ABCD 0 7 1] [DABC 1 12 2] [CDAB 2 17 3] [BCDA 3 22 4]
[ABCD 4 7 5] [DABC 5 12 6] [CDAB 6 17 7] [BCDA 7 22 8]
[ABCD 8 7 9] [DABC 9 12 10] [CDAB 10 17 11] [BCDA 11 22 12]
[ABCD 12 7 13] [DABC 13 12 14] [CDAB 14 17 15] [BCDA 15 22 16]
// Round 2.
// Let [abcd k s i] denote the operation
// a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s).
// Do the following 16 operations.
[ABCD 1 5 17] [DABC 6 9 18] [CDAB 11 14 19] [BCDA 0 20 20]
[ABCD 5 5 21] [DABC 10 9 22] [CDAB 15 14 23] [BCDA 4 20 24]
[ABCD 9 5 25] [DABC 14 9 26] [CDAB 3 14 27] [BCDA 8 20 28]
[ABCD 13 5 29] [DABC 2 9 30] [CDAB 7 14 31] [BCDA 12 20 32]
// Round 3.
// Let [abcd k s t] denote the operation
// a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s).
// Do the following 16 operations.
[ABCD 5 4 33] [DABC 8 11 34] [CDAB 11 16 35] [BCDA 14 23 36]
[ABCD 1 4 37] [DABC 4 11 38] [CDAB 7 16 39] [BCDA 10 23 40]
[ABCD 13 4 41] [DABC 0 11 42] [CDAB 3 16 43] [BCDA 6 23 44]
[ABCD 9 4 45] [DABC 12 11 46] [CDAB 15 16 47] [BCDA 2 23 48]
// Round 4.
// Let [abcd k s t] denote the operation
// a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s).
// Do the following 16 operations.
[ABCD 0 6 49] [DABC 7 10 50] [CDAB 14 15 51] [BCDA 5 21 52]
[ABCD 12 6 53] [DABC 3 10 54] [CDAB 10 15 55] [BCDA 1 21 56]
[ABCD 8 6 57] [DABC 15 10 58] [CDAB 6 15 59] [BCDA 13 21 60]
[ABCD 4 6 61] [DABC 11 10 62] [CDAB 2 15 63] [BCDA 9 21 64]
// Then perform the following additions. (That is increment each
// of the four registers by the value it had before this block
// was started.)
A = A + AA B = B + BB C = C + CC D = D + DD
end // of loop on i
3.5 Step 5. Output
The message digest produced as output is A, B, C, D. That is, we
begin with the low-order byte of A, and end with the high-order byte of D.
This completes the description of MD5.
Summary
The MD5 message-digest algorithm is simple to implement, and provides
a "fingerprint" or message digest of a message of arbitrary length.
It is conjectured that the difficulty of coming up with two messages
having the same message digest is on the order of 2^64 operations,
and that the difficulty of coming up with any message having a given
message digest is on the order of 2^128 operations. The MD5 algorithm
has been carefully scrutinized for weaknesses. It is, however, a
relatively new algorithm and further security analysis is of course
justified, as is the case with any new proposal of this sort.
5. Differences Between MD4 and MD5
The following are the differences between MD4 and MD5:
1. A fourth round has been added.
2. Each step now has a unique additive constant.
3. The function g in round 2 was changed from (XY v XZ v YZ) to
(XZ v Y not(Z)) to make g less symmetric.
4. Each step now adds in the result of the previous step. This
promotes a faster "avalanche effect".
5. The order in which input words are accessed in rounds 2 and
3 is changed, to make these patterns less like each other.
6. The shift amounts in each round have been approximately
optimized, to yield a faster "avalanche effect." The shifts in
different rounds are distinct.
References
[1] Rivest, R., "The MD4 Message Digest Algorithm", RFC 1320, MIT and
RSA Data Security, Inc., April 1992.
[2] Rivest, R., "The MD4 message digest algorithm", in A.J. Menezes
and S.A. Vanstone, editors, Advances in Cryptology - CRYPTO '90
Proceedings, pages 303-311, Springer-Verlag, 1991.
[3] CCITT Recommendation X.509 (1988), "The Directory -
Authentication Framework."APPENDIX A - Reference Implementation
The level of security discussed in this memo is considered to be
sufficient for implementing very high security hybrid digital-
signature schemes based on MD5 and a public-key cryptosystem.
Author's Address
Ronald L. Rivest Massachusetts Institute of Technology
Laboratory for Computer Science NE43-324 545 Technology Square
Cambridge, MA 02139-1986 Phone: (617) 253-5880
EMail: rivest@theory.lcs.mit.edu
*****************************************************************************************/
#ifndef _WX_FILEH__
class wxFile;
#endif
class wxMD5Checksum
{
public:
// interface functions for the RSA MD5 calculation
static wxString GetMD5(unsigned char* pBuf, unsigned int nLength);
static wxString GetMD5(wxFile& File);
static wxString GetMD5(const wxString& strFilePath);
protected:
// constructor/destructor
wxMD5Checksum();
virtual ~wxMD5Checksum() {};
// RSA MD5 implementation
void Transform(unsigned char Block[64]);
void Update(unsigned char* Input, unsigned long nInputLen);
wxString Final();
inline unsigned long RotateLeft(unsigned long x, int n);
inline void FF( unsigned long& A, unsigned long B, unsigned long C, unsigned long D, unsigned long X, unsigned long S, unsigned long T);
inline void GG( unsigned long& A, unsigned long B, unsigned long C, unsigned long D, unsigned long X, unsigned long S, unsigned long T);
inline void HH( unsigned long& A, unsigned long B, unsigned long C, unsigned long D, unsigned long X, unsigned long S, unsigned long T);
inline void II( unsigned long& A, unsigned long B, unsigned long C, unsigned long D, unsigned long X, unsigned long S, unsigned long T);
// utility functions
inline void DWordToByte(unsigned char* Output, unsigned long* Input, unsigned int nLength);
inline void ByteToDWord(unsigned long* Output, unsigned char* Input, unsigned int nLength);
private:
unsigned char m_lpszBuffer[64]; // input buffer
unsigned long m_nCount[2]; // number of bits, modulo 2^64 (lsb first)
unsigned long m_lMD5[4]; // MD5 checksum
};
#endif

View File

@ -0,0 +1,119 @@
/*****************************************************************************************
*** MD5ChecksumDefines.h : MD5 Checksum constants
*** Developed by Langfine Ltd.
*** Released to the public domain 12/Nov/2001.
*** Please visit our website www.langfine.com
*** Any modifications must be clearly commented to distinguish them from Langfine's
*** original source code. Please advise Langfine of useful modifications so that we
*** can make them generally available.
*****************************************************************************************/
//Magic initialization constants
#define MD5_INIT_STATE_0 0x67452301
#define MD5_INIT_STATE_1 0xefcdab89
#define MD5_INIT_STATE_2 0x98badcfe
#define MD5_INIT_STATE_3 0x10325476
//Constants for Transform routine.
#define MD5_S11 7
#define MD5_S12 12
#define MD5_S13 17
#define MD5_S14 22
#define MD5_S21 5
#define MD5_S22 9
#define MD5_S23 14
#define MD5_S24 20
#define MD5_S31 4
#define MD5_S32 11
#define MD5_S33 16
#define MD5_S34 23
#define MD5_S41 6
#define MD5_S42 10
#define MD5_S43 15
#define MD5_S44 21
//Transformation Constants - Round 1
#define MD5_T01 0xd76aa478 //Transformation Constant 1
#define MD5_T02 0xe8c7b756 //Transformation Constant 2
#define MD5_T03 0x242070db //Transformation Constant 3
#define MD5_T04 0xc1bdceee //Transformation Constant 4
#define MD5_T05 0xf57c0faf //Transformation Constant 5
#define MD5_T06 0x4787c62a //Transformation Constant 6
#define MD5_T07 0xa8304613 //Transformation Constant 7
#define MD5_T08 0xfd469501 //Transformation Constant 8
#define MD5_T09 0x698098d8 //Transformation Constant 9
#define MD5_T10 0x8b44f7af //Transformation Constant 10
#define MD5_T11 0xffff5bb1 //Transformation Constant 11
#define MD5_T12 0x895cd7be //Transformation Constant 12
#define MD5_T13 0x6b901122 //Transformation Constant 13
#define MD5_T14 0xfd987193 //Transformation Constant 14
#define MD5_T15 0xa679438e //Transformation Constant 15
#define MD5_T16 0x49b40821 //Transformation Constant 16
//Transformation Constants - Round 2
#define MD5_T17 0xf61e2562 //Transformation Constant 17
#define MD5_T18 0xc040b340 //Transformation Constant 18
#define MD5_T19 0x265e5a51 //Transformation Constant 19
#define MD5_T20 0xe9b6c7aa //Transformation Constant 20
#define MD5_T21 0xd62f105d //Transformation Constant 21
#define MD5_T22 0x02441453 //Transformation Constant 22
#define MD5_T23 0xd8a1e681 //Transformation Constant 23
#define MD5_T24 0xe7d3fbc8 //Transformation Constant 24
#define MD5_T25 0x21e1cde6 //Transformation Constant 25
#define MD5_T26 0xc33707d6 //Transformation Constant 26
#define MD5_T27 0xf4d50d87 //Transformation Constant 27
#define MD5_T28 0x455a14ed //Transformation Constant 28
#define MD5_T29 0xa9e3e905 //Transformation Constant 29
#define MD5_T30 0xfcefa3f8 //Transformation Constant 30
#define MD5_T31 0x676f02d9 //Transformation Constant 31
#define MD5_T32 0x8d2a4c8a //Transformation Constant 32
//Transformation Constants - Round 3
#define MD5_T33 0xfffa3942 //Transformation Constant 33
#define MD5_T34 0x8771f681 //Transformation Constant 34
#define MD5_T35 0x6d9d6122 //Transformation Constant 35
#define MD5_T36 0xfde5380c //Transformation Constant 36
#define MD5_T37 0xa4beea44 //Transformation Constant 37
#define MD5_T38 0x4bdecfa9 //Transformation Constant 38
#define MD5_T39 0xf6bb4b60 //Transformation Constant 39
#define MD5_T40 0xbebfbc70 //Transformation Constant 40
#define MD5_T41 0x289b7ec6 //Transformation Constant 41
#define MD5_T42 0xeaa127fa //Transformation Constant 42
#define MD5_T43 0xd4ef3085 //Transformation Constant 43
#define MD5_T44 0x04881d05 //Transformation Constant 44
#define MD5_T45 0xd9d4d039 //Transformation Constant 45
#define MD5_T46 0xe6db99e5 //Transformation Constant 46
#define MD5_T47 0x1fa27cf8 //Transformation Constant 47
#define MD5_T48 0xc4ac5665 //Transformation Constant 48
//Transformation Constants - Round 4
#define MD5_T49 0xf4292244 //Transformation Constant 49
#define MD5_T50 0x432aff97 //Transformation Constant 50
#define MD5_T51 0xab9423a7 //Transformation Constant 51
#define MD5_T52 0xfc93a039 //Transformation Constant 52
#define MD5_T53 0x655b59c3 //Transformation Constant 53
#define MD5_T54 0x8f0ccc92 //Transformation Constant 54
#define MD5_T55 0xffeff47d //Transformation Constant 55
#define MD5_T56 0x85845dd1 //Transformation Constant 56
#define MD5_T57 0x6fa87e4f //Transformation Constant 57
#define MD5_T58 0xfe2ce6e0 //Transformation Constant 58
#define MD5_T59 0xa3014314 //Transformation Constant 59
#define MD5_T60 0x4e0811a1 //Transformation Constant 60
#define MD5_T61 0xf7537e82 //Transformation Constant 61
#define MD5_T62 0xbd3af235 //Transformation Constant 62
#define MD5_T63 0x2ad7d2bb //Transformation Constant 63
#define MD5_T64 0xeb86d391 //Transformation Constant 64
//Null data (except for first unsigned char) used to finalise the checksum calculation
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

676
src/xvaga01/XFont.cpp Normal file
View File

@ -0,0 +1,676 @@
// XFont.cpp Version 1.1
//
// Author: Philip Patrick (GetFontProperties)
//
// Version 1.0 - Initial release of GetFontProperties()
//
// Modified by: Hans Dietrich
// hdietrich2@hotmail.com
//
// Version 1.1: - Removed MFC dependency from GetFontProperties()
// - Converted CFile file I/O to memory mapped file
// - Added Unicode support
// - Combined with my GetFontFile() routine
//
///////////////////////////////////////////////////////////////////////////////
#include "XTrace.h"
#include "XFont.h"
#include <crtdbg.h>
#include <shlobj.h>
///////////////////////////////////////////////////////////////////////////////
//
// If you do not want TRACE output you can
// uncomment the following lines:
//
#undef TRACE
#if _MSC_VER > 1300
#define TRACE __noop
#else
#define TRACE ((void)0)
#endif
//
///////////////////////////////////////////////////////////////////////////////
#pragma warning(disable : 4127) // conditional expression is constant
///////////////////////////////////////////////////////////////////////////////
// private routines
static LONG GetNextNameValue(HKEY key, LPCTSTR subkey, LPTSTR szName, LPTSTR szData);
///////////////////////////////////////////////////////////////////////////////
// defines used by GetWinVer()
#define WUNKNOWNSTR _T("unknown Windows version")
#define W2KSTR _T("Windows 2000")
#define WXPSTR _T("Windows XP")
#define W2003STR _T("Windows Server 2003")
#define WVISTASTR _T("Windows Vista")
#define W2008STR _T("Windows Server 2008")
#define W2008R2STR _T("Windows Server 2008 R2")
#define W7STR _T("Windows 7")
#define W2012STR _T("Windows Server 2012")
#define W8STR _T("Windows 8")
#define W10STR _T("Windows 10")
#define W2016STR _T("Windows Server 2016")
#define WUNKNOWN 0
#define W9XFIRST 1
#define W95 1
#define W95SP1 2
#define W95OSR2 3
#define W98 4
#define W98SP1 5
#define W98SE 6
#define WME 7
#define W9XLAST 99
#define WNTFIRST 101
#define WNT351 101
#define WNT4 102
#define W2K 103
#define WXP 104
#define W2003 105
#define WVISTA 106
#define W2008 107
#define W2008R2 108
#define W7 109
#define W2012 110
#define W8 111
#define W10 112
#define W2016 103
#define WNTLAST 199
#define WCEFIRST 201
#define WCE 201
#define WCELAST 299
///////////////////////////////////////////////////////////////////////////////
//
// structs used by GetFontProperties()
//
typedef struct _tagFONT_PROPERTIES_ANSI
{
char csName[1024];
char csCopyright[1024];
char csTrademark[1024];
char csFamily[1024];
} FONT_PROPERTIES_ANSI;
typedef struct _tagTT_OFFSET_TABLE
{
USHORT uMajorVersion;
USHORT uMinorVersion;
USHORT uNumOfTables;
USHORT uSearchRange;
USHORT uEntrySelector;
USHORT uRangeShift;
} TT_OFFSET_TABLE;
typedef struct _tagTT_TABLE_DIRECTORY
{
char szTag[4]; //table name
ULONG uCheckSum; //Check sum
ULONG uOffset; //Offset from beginning of file
ULONG uLength; //length of the table in bytes
} TT_TABLE_DIRECTORY;
typedef struct _tagTT_NAME_TABLE_HEADER
{
USHORT uFSelector; //format selector. Always 0
USHORT uNRCount; //Name Records count
USHORT uStorageOffset; //Offset for strings storage, from start of the table
} TT_NAME_TABLE_HEADER;
typedef struct _tagTT_NAME_RECORD
{
USHORT uPlatformID;
USHORT uEncodingID;
USHORT uLanguageID;
USHORT uNameID;
USHORT uStringLength;
USHORT uStringOffset; //from start of storage area
} TT_NAME_RECORD;
#define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
#define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
///////////////////////////////////////////////////////////////////////////////
//
// GetFontFile()
//
// Purpose: Find the name of font file from the font name
//
// Parameters: lpszFontName - name of font
// lpszDisplayName - pointer to buffer where font display name
// will be copied
// nDisplayNameSize - size of display name buffer in TCHARs
// lpszFontFile - pointer to buffer where font file name
// will be copied
// nFontFileSize - size of font file buffer in TCHARs
//
// Returns: BOOL - TRUE = success
//
// Notes: This is *not* a foolproof method for finding the name of a
// font file. If a font has been installed in a normal manner,
// and if it is in the Windows "Font" directory, then this method
// will probably work. It will probably work for most screen
// fonts and TrueType fonts. However, this method might not work
// for fonts that are created or installed dynamically, or that
// are specific to a particular device, or that are not installed
// into the font directory.
//
BOOL GetFontFile(LPCTSTR lpszFontName,
LPTSTR lpszDisplayName,
int nDisplayNameSize,
LPTSTR lpszFontFile,
int nFontFileSize)
{
_ASSERTE(lpszFontName && lpszFontName[0] != 0);
if (!lpszFontName || lpszFontName[0] == 0)
return FALSE;
_ASSERTE(lpszDisplayName);
if (!lpszDisplayName)
return FALSE;
_ASSERTE(lpszFontFile);
if (!lpszFontFile)
return FALSE;
lpszDisplayName[0] = _T('\0');
lpszFontFile[0] = _T('\0');
TCHAR szName[2 * MAX_PATH];
TCHAR szData[2 * MAX_PATH];
int nVersion;
TCHAR szVersion[100];
GetWinVer(szVersion, sizeof(szVersion)/sizeof(TCHAR)-1, &nVersion);
LPCTSTR szFontPath = NULL;
if ((nVersion >= WNTFIRST) && (nVersion <= WNTLAST))
szFontPath = _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
else
szFontPath = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Fonts");
BOOL bResult = FALSE;
while (GetNextNameValue(HKEY_LOCAL_MACHINE, szFontPath, szName, szData) == ERROR_SUCCESS)
{
if (_tcsnicmp(lpszFontName, szName, _tcslen(lpszFontName)) == 0)
{
TRACE(_T("found font\n"));
_tcsncpy(lpszDisplayName, szName, nDisplayNameSize-1);
_tcsncpy(lpszFontFile, szData, nFontFileSize-1);
bResult = TRUE;
break;
}
szFontPath = _T(""); // this will get next value, same key
}
GetNextNameValue(HKEY_LOCAL_MACHINE, NULL, NULL, NULL); // close the registry key
return bResult;
}
bool GetFontsFolder(LPTSTR lpszFontPath, int nFontPathSize)
{
_ASSERTE(nFontPathSize >= _MAX_PATH);
*lpszFontPath = '\0';
SHGetFolderPath(NULL, CSIDL_FONTS, NULL, 0, lpszFontPath);
return *lpszFontPath != '\0';
}
///////////////////////////////////////////////////////////////////////////////
//
// GetFontProperties()
//
// Purpose: Get font name from font file
//
// Parameters: lpszFilePath - file path of font file
// lpFontPropsX - pointer to font properties struct
//
// Returns: BOOL - TRUE = success
//
BOOL GetFontProperties(LPCTSTR lpszFilePath, FONT_PROPERTIES * lpFontPropsX)
{
FONT_PROPERTIES_ANSI fp;
FONT_PROPERTIES_ANSI * lpFontProps = &fp;
memset(lpFontProps, 0, sizeof(FONT_PROPERTIES_ANSI));
HANDLE hFile = INVALID_HANDLE_VALUE;
hFile = ::CreateFile(lpszFilePath,
GENERIC_READ,// | GENERIC_WRITE,
0,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
TRACE(_T("ERROR: failed to open '%s'\n"), lpszFilePath);
TRACE(_T("ERROR: %s failed\n"), _T("CreateFile"));
return FALSE;
}
// get the file size
DWORD dwFileSize = ::GetFileSize(hFile, NULL);
if (dwFileSize == INVALID_FILE_SIZE)
{
TRACE(_T("ERROR: %s failed\n"), _T("GetFileSize"));
::CloseHandle(hFile);
return FALSE;
}
TRACE(_T("dwFileSize = %d\n"), dwFileSize);
// Create a file mapping object that is the current size of the file
HANDLE hMappedFile = NULL;
hMappedFile = ::CreateFileMapping(hFile,
NULL,
PAGE_READONLY, //PAGE_READWRITE,
0,
dwFileSize,
NULL);
if (hMappedFile == NULL)
{
TRACE(_T("ERROR: %s failed\n"), _T("CreateFileMapping"));
::CloseHandle(hFile);
return FALSE;
}
LPBYTE lpMapAddress = (LPBYTE) ::MapViewOfFile(hMappedFile, // handle to file-mapping object
FILE_MAP_READ,//FILE_MAP_WRITE, // access mode
0, // high-order DWORD of offset
0, // low-order DWORD of offset
0); // number of bytes to map
if (lpMapAddress == NULL)
{
TRACE(_T("ERROR: %s failed\n"), _T("MapViewOfFile"));
::CloseHandle(hMappedFile);
::CloseHandle(hFile);
return FALSE;
}
BOOL bRetVal = FALSE;
int index = 0;
TT_OFFSET_TABLE ttOffsetTable;
memcpy(&ttOffsetTable, &lpMapAddress[index], sizeof(TT_OFFSET_TABLE));
index += sizeof(TT_OFFSET_TABLE);
ttOffsetTable.uNumOfTables = SWAPWORD(ttOffsetTable.uNumOfTables);
ttOffsetTable.uMajorVersion = SWAPWORD(ttOffsetTable.uMajorVersion);
ttOffsetTable.uMinorVersion = SWAPWORD(ttOffsetTable.uMinorVersion);
//check is this is a true type font and the version is 1.0
if (ttOffsetTable.uMajorVersion != 1 || ttOffsetTable.uMinorVersion != 0)
return bRetVal;
TT_TABLE_DIRECTORY tblDir;
memset(&tblDir, 0, sizeof(TT_TABLE_DIRECTORY));
BOOL bFound = FALSE;
char szTemp[4096];
memset(szTemp, 0, sizeof(szTemp));
for (int i = 0; i< ttOffsetTable.uNumOfTables; i++)
{
//f.Read(&tblDir, sizeof(TT_TABLE_DIRECTORY));
memcpy(&tblDir, &lpMapAddress[index], sizeof(TT_TABLE_DIRECTORY));
index += sizeof(TT_TABLE_DIRECTORY);
strncpy(szTemp, tblDir.szTag, 4);
if (_stricmp(szTemp, "name") == 0)
{
bFound = TRUE;
tblDir.uLength = SWAPLONG(tblDir.uLength);
tblDir.uOffset = SWAPLONG(tblDir.uOffset);
break;
}
else if (szTemp[0] == 0)
{
break;
}
}
if (bFound)
{
index = tblDir.uOffset;
TT_NAME_TABLE_HEADER ttNTHeader;
memcpy(&ttNTHeader, &lpMapAddress[index], sizeof(TT_NAME_TABLE_HEADER));
index += sizeof(TT_NAME_TABLE_HEADER);
ttNTHeader.uNRCount = SWAPWORD(ttNTHeader.uNRCount);
ttNTHeader.uStorageOffset = SWAPWORD(ttNTHeader.uStorageOffset);
TT_NAME_RECORD ttRecord;
bFound = FALSE;
for (int i = 0;
i < ttNTHeader.uNRCount &&
(lpFontProps->csCopyright[0] == 0 ||
lpFontProps->csName[0] == 0 ||
lpFontProps->csTrademark[0] == 0 ||
lpFontProps->csFamily[0] == 0);
i++)
{
memcpy(&ttRecord, &lpMapAddress[index], sizeof(TT_NAME_RECORD));
index += sizeof(TT_NAME_RECORD);
ttRecord.uNameID = SWAPWORD(ttRecord.uNameID);
ttRecord.uStringLength = SWAPWORD(ttRecord.uStringLength);
ttRecord.uStringOffset = SWAPWORD(ttRecord.uStringOffset);
if (ttRecord.uNameID == 1 || ttRecord.uNameID == 0 || ttRecord.uNameID == 7)
{
int nPos = index; //f.GetPosition();
index = tblDir.uOffset + ttRecord.uStringOffset + ttNTHeader.uStorageOffset;
memset(szTemp, 0, sizeof(szTemp));
memcpy(szTemp, &lpMapAddress[index], ttRecord.uStringLength);
index += ttRecord.uStringLength;
if (szTemp[0] != 0)
{
_ASSERTE(strlen(szTemp) < sizeof(lpFontProps->csName));
switch (ttRecord.uNameID)
{
case 0:
if (lpFontProps->csCopyright[0] == 0)
strncpy(lpFontProps->csCopyright, szTemp,
sizeof(lpFontProps->csCopyright)-1);
break;
case 1:
if (lpFontProps->csFamily[0] == 0)
strncpy(lpFontProps->csFamily, szTemp,
sizeof(lpFontProps->csFamily)-1);
bRetVal = TRUE;
break;
case 4:
if (lpFontProps->csName[0] == 0)
strncpy(lpFontProps->csName, szTemp,
sizeof(lpFontProps->csName)-1);
break;
case 7:
if (lpFontProps->csTrademark[0] == 0)
strncpy(lpFontProps->csTrademark, szTemp,
sizeof(lpFontProps->csTrademark)-1);
break;
default:
break;
}
}
index = nPos;
}
}
}
::UnmapViewOfFile(lpMapAddress);
::CloseHandle(hMappedFile);
::CloseHandle(hFile);
if (lpFontProps->csName[0] == 0)
strcpy(lpFontProps->csName, lpFontProps->csFamily);
memset(lpFontPropsX, 0, sizeof(FONT_PROPERTIES));
#ifdef _UNICODE
::MultiByteToWideChar(CP_ACP, 0, lpFontProps->csName, -1, lpFontPropsX->csName,
sizeof(lpFontPropsX->csName)/sizeof(TCHAR)-1);
::MultiByteToWideChar(CP_ACP, 0, lpFontProps->csCopyright, -1, lpFontPropsX->csCopyright,
sizeof(lpFontPropsX->csCopyright)/sizeof(TCHAR)-1);
::MultiByteToWideChar(CP_ACP, 0, lpFontProps->csTrademark, -1, lpFontPropsX->csTrademark,
sizeof(lpFontPropsX->csTrademark)/sizeof(TCHAR)-1);
::MultiByteToWideChar(CP_ACP, 0, lpFontProps->csFamily, -1, lpFontPropsX->csFamily,
sizeof(lpFontPropsX->csFamily)/sizeof(TCHAR)-1);
#else
strcpy(lpFontPropsX->csName, lpFontProps->csName);
strcpy(lpFontPropsX->csCopyright, lpFontProps->csCopyright);
strcpy(lpFontPropsX->csTrademark, lpFontProps->csTrademark);
strcpy(lpFontPropsX->csFamily, lpFontProps->csFamily);
#endif
return bRetVal;
}
///////////////////////////////////////////////////////////////////////////////
//
// GetNextNameValue()
//
// Purpose: Get first/next name/value pair from registry
//
// Parameters: key - handle to open key, or predefined key
// pszSubkey - subkey name
// pszName - pointer to buffer that receives the value string
// pszData - pointer to buffer that receives the data string
//
// Returns: LONG - return code from registry function; ERROR_SUCCESS = success
//
// Notes: If pszSubkey, pszName, and pszData are all NULL, then the open
// handle will be closed.
//
// The first time GetNextNameValue is called, pszSubkey should be
// specified. On subsequent calls, pszSubkey should be NULL or
// an empty string.
//
static LONG GetNextNameValue(HKEY key, LPCTSTR pszSubkey, LPTSTR pszName, LPTSTR pszData)
{
static HKEY hkey = NULL; // registry handle, kept open between calls
static DWORD dwIndex = 0; // count of values returned
LONG retval = ERROR_SUCCESS;
// if all parameters are NULL then close key
if (pszSubkey == NULL && pszName == NULL && pszData == NULL)
{
TRACE(_T("closing key\n"));
if (hkey)
::RegCloseKey(hkey);
hkey = NULL;
return ERROR_SUCCESS;
}
// if subkey is specified then open key (first time)
if (pszSubkey && *pszSubkey)
{
// retval = ::RegOpenKeyEx(key, pszSubkey, 0, KEY_ALL_ACCESS, &hkey); // Incapace...
retval = ::RegOpenKeyEx(key, pszSubkey, 0, KEY_READ, &hkey); // ... devi solo leggere!
if (retval != ERROR_SUCCESS)
{
TRACE(_T("ERROR: RegOpenKeyEx failed\n"));
return retval;
}
else
{
TRACE(_T("RegOpenKeyEx ok\n"));
}
dwIndex = 0;
}
else
{
dwIndex++;
}
_ASSERTE(pszName != NULL && pszData != NULL);
*pszName = 0;
*pszData = 0;
TCHAR szValueName[MAX_PATH];
DWORD dwValueNameSize = sizeof(szValueName)-1;
BYTE szValueData[MAX_PATH];
DWORD dwValueDataSize = sizeof(szValueData)-1;
DWORD dwType = 0;
retval = ::RegEnumValue(hkey, dwIndex, szValueName, &dwValueNameSize, NULL,
&dwType, szValueData, &dwValueDataSize);
if (retval == ERROR_SUCCESS)
{
TRACE(_T("szValueName=<%s> szValueData=<%s>\n"), szValueName, szValueData);
lstrcpy(pszName, (LPTSTR)szValueName);
lstrcpy(pszData, (LPTSTR)szValueData);
}
else
{
TRACE(_T("RegEnumKey failed\n"));
}
return retval;
}
// from winbase.h
#ifndef VER_PLATFORM_WIN32s
#define VER_PLATFORM_WIN32s 0
#endif
#ifndef VER_PLATFORM_WIN32_WINDOWS
#define VER_PLATFORM_WIN32_WINDOWS 1
#endif
#ifndef VER_PLATFORM_WIN32_NT
#define VER_PLATFORM_WIN32_NT 2
#endif
#ifndef VER_PLATFORM_WIN32_CE
#define VER_PLATFORM_WIN32_CE 3
#endif
/*
This table has been assembled from Usenet postings, personal
observations, and reading other people's code. Please feel
free to add to it or correct it.
dwPlatFormID dwMajorVersion dwMinorVersion dwBuildNumber
95 1 4 0 950
95 SP1 1 4 0 >950 && <=1080
95 OSR2 1 4 <10 >1080
98 1 4 10 1998
98 SP1 1 4 10 >1998 && <2183
98 SE 1 4 10 >=2183
ME 1 4 90 3000
NT 3.51 2 3 51
NT 4 2 4 0 1381
2000 2 5 0 2195
XP 2 5 1 2600
2003 2 5 2
Vista 2 6 0
2008 2 6 0
2008 R2 2 6 1
Win7 2 6 1 3600
Win8 2 6 2
Win8.1 2 6 3
Win10 2 6 4
Win10 2 10 0
CE 3
*/
///////////////////////////////////////////////////////////////////////////////
//
// GetWinVer()
//
// Purpose: Get Windows version info
//
// Parameters: lpszVersion - pointer to buffer that receives the version
// string
// nVersionSize - size of the version buffer in TCHARs
// pnVersion - pointer to int that receives the version code
//
// Returns: BOOL - TRUE = success
//
///////////////////////////////////////////////////////////////////////////////
// GetWinVer
bool GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
{
int nVersion = WUNKNOWN;
LPCTSTR cp = WUNKNOWNSTR;
OSVERSIONINFOEX osinfo; memset(&osinfo, 0, sizeof(osinfo));
osinfo.dwOSVersionInfoSize = sizeof(osinfo);
if (::GetVersionEx((OSVERSIONINFO*)&osinfo))
{
DWORD dwPlatformId = osinfo.dwPlatformId;
DWORD dwMinorVersion = osinfo.dwMinorVersion;
DWORD dwMajorVersion = osinfo.dwMajorVersion;
DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this
const bool bServer = osinfo.wProductType != VER_NT_WORKSTATION;
if (dwPlatformId == VER_PLATFORM_WIN32_NT)
{
if (dwMajorVersion <= 5)
{
switch (dwMinorVersion)
{
case 0: cp = W2KSTR; nVersion = W2K; break;
case 1: cp = WXPSTR; nVersion = WXP; break;
case 2:
default: cp = W2003STR; nVersion = W2003; break;
}
} else
if (dwMajorVersion == 6)
{
switch (dwMinorVersion)
{
case 0:
if (bServer)
{ cp = W2008STR; nVersion = W2008; }
else
{ cp = WVISTASTR; nVersion = WVISTA; }
break;
case 1:
if (bServer)
{ cp = W2008R2STR; nVersion = W2008R2; }
else
{ cp = W7STR; nVersion = W7; }
break;
case 2:
case 3:
if (bServer)
{ cp = W2012STR; nVersion = W2012; }
else
{ cp = W8STR; nVersion = W8; }
break;
default:
if (bServer)
{ cp = W2016STR; nVersion = W2016; }
else
{ cp = W10STR; nVersion = W10; }
break;
}
} else
if (dwMajorVersion >= 10)
{
if (bServer)
{ cp = W2016STR; nVersion = W2016; }
else
{ cp = W10STR; nVersion = W10; }
}
}
}
if (lpszVersion != NULL && nVersionSize > 0)
_tcsncpy(lpszVersion, cp, nVersionSize-1);
if (pnVersion != NULL)
*pnVersion = nVersion;
return nVersion == WUNKNOWN;
}

39
src/xvaga01/XFont.h Normal file
View File

@ -0,0 +1,39 @@
// XFont.h Version 1.1
//
// Copyright (C) 2003 Hans Dietrich
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef XFONT_H
#define XFONT_H
typedef struct _tagFONT_PROPERTIES
{
TCHAR csName[1024];
TCHAR csCopyright[1024];
TCHAR csTrademark[1024];
TCHAR csFamily[1024];
} FONT_PROPERTIES, *LPFONT_PROPERTIES;
BOOL GetFontFile(LPCTSTR lpszFontName,
LPTSTR lpszDisplayName,
int nDisplayNameSize,
LPTSTR lpszFontFile,
int nFontFileSize);
BOOL GetFontProperties(LPCTSTR lpszFilePath,
LPFONT_PROPERTIES lpFontProps);
bool GetFontsFolder(LPTSTR lpszFontPath, int nFontPathSize);
bool GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *nVersion);
#endif //XFONT_H

122
src/xvaga01/XTrace.h Normal file
View File

@ -0,0 +1,122 @@
// XTrace.h Version 1.1
//
// Author: Paul Mclachlan
//
// Modified by: Hans Dietrich
// hdietrich2@hotmail.com
//
// Version 1.1: added Unicode support
// added optional thread id to output string
// added option to enable/disable full path
// added TRACERECT macro
// changed name to avoid conflicts with Paul's class.
//
// This code was taken from article by Paul Mclachlan, "Getting around
// the need for a vararg #define just to automatically use __FILE__ and
// __LINE__ in a TRACE macro". For original article, see
// http://www.codeproject.com/useritems/location_trace.asp
//
// XTrace.h is a drop-in replacement for MFC's TRACE facility. It has no
// dependency on MFC. It is thread-safe and uses no globals or statics.
//
// It optionally adds source module/line number and thread id to each line
// of TRACE output. To control these features, use the following defines:
//
// XTRACE_SHOW_FULLPATH
// XTRACE_SHOW_THREAD_ID
//
// XTrace.h also provides the TRACERECT macro, which outputs the contents
// of a RECT struct. In Release builds, no output will be produced.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef XTRACE_H
#define XTRACE_H
#ifdef WIN32
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#include <tchar.h>
#pragma warning(push)
#pragma warning(disable : 4127) // conditional expression is constant
#define XTRACE_SHOW_FULLPATH FALSE // FALSE = only show base name of file
#define XTRACE_SHOW_THREAD_ID TRUE // TRUE = include thread id in output
class xtracing_output_debug_string
{
public:
xtracing_output_debug_string(LPCTSTR lpszFile, int line) :
m_file(lpszFile),
m_line(line)
{
}
void operator() (LPCTSTR lpszFormat, ...)
{
va_list va;
va_start(va, lpszFormat);
TCHAR buf1[BUFFER_SIZE];
TCHAR buf2[BUFFER_SIZE];
// add the __FILE__ and __LINE__ to the front
LPCTSTR cp = (LPCTSTR) m_file;
if (!XTRACE_SHOW_FULLPATH)
{
cp = _tcsrchr(m_file, _T('\\'));
if (cp)
cp++;
}
if (XTRACE_SHOW_THREAD_ID)
{
if (_sntprintf(buf1, BUFFER_SIZE-1, _T("%s(%d) : [%X] %s"),
cp, m_line, GetCurrentThreadId(), lpszFormat) < 0)
buf1[BUFFER_SIZE-1] = _T('\0');
}
else
{
if (_sntprintf(buf1, BUFFER_SIZE-1, _T("%s(%d) : %s"),
cp, m_line, lpszFormat) < 0)
buf1[BUFFER_SIZE-1] = _T('\0');
}
// format the message as requested
if (_vsntprintf(buf2, BUFFER_SIZE-1, buf1, va) < 0)
buf2[BUFFER_SIZE-1] = _T('\0');
va_end(va);
// write it out
OutputDebugString(buf2);
}
private:
LPCTSTR m_file;
int m_line;
enum { BUFFER_SIZE = 4096 };
};
#undef TRACE
#ifdef _DEBUG
#define TRACE (xtracing_output_debug_string(_T(__FILE__), __LINE__ ))
#define TRACEERROR (xtracing_output_debug_string(_T(__FILE__), __LINE__ ))
#else
#define TRACE ((void)0)
#define TRACEERROR ((void)0)
#endif
#define TRACERECT(r) TRACE(_T(#r) _T(": left = %d top = %d right = %d bottom = %d\n"), \
(r).left, (r).top, (r).right, (r).bottom)
#pragma warning(pop)
#endif //XTRACE_H

799
src/xvaga01/agasys.cpp Normal file
View File

@ -0,0 +1,799 @@
#include "wxinc.h"
#include "incstr.h"
#include "agasys.h"
#include "xvt.h"
#include "guid.hpp"
///////////////////////////////////////////////////////////
// Unzip support
///////////////////////////////////////////////////////////
#include <wx/dir.h>
#include <wx/stdpaths.h>
#include <wx/wfstream.h>
#include <wx/zipstrm.h>
static unsigned int aga_getziplist(const char* zipfile, wxArrayString& aFiles)
{
wxFFileInputStream fin(zipfile);
wxZipInputStream zip(fin);
for (wxZipEntry* z = zip.GetNextEntry(); z; z = zip.GetNextEntry())
{
const wxString str = z->GetInternalName();
aFiles.Add(str);
}
return aFiles.GetCount();
}
bool aga_unzip(const char* zipfile, const char* destdir)
{
wxArrayString aFiles;
const unsigned int files = aga_getziplist(zipfile, aFiles);
WINDOW pi = xvt_dm_progress_create(NULL_WIN, "Unzip", files, TRUE);
for (unsigned int f = 0; f < files; f++)
{
const wxString& strFileName = aFiles[f];
xvt_dm_progress_set_text(pi, strFileName);
if (wxEndsWithPathSeparator(strFileName) || strFileName.Find('.') < 0) // Is dir name
{
wxString strOutDir = destdir;
if (!wxEndsWithPathSeparator(strOutDir))
strOutDir += wxFILE_SEP_PATH;
strOutDir += strFileName;
xvt_fsys_mkdir(strOutDir);
}
else
{
wxFFileInputStream file(zipfile);
wxZipInputStream fin(file);
wxZipEntry* entry = nullptr;
do entry = fin.GetNextEntry();
while (entry && entry->GetInternalName() != strFileName);
if (entry == nullptr || !fin.OpenEntry(*entry))
continue;
wxString strOutFile = destdir;
if (!wxEndsWithPathSeparator(strOutFile) && !wxIsPathSeparator(strFileName[0]))
strOutFile += wxFILE_SEP_PATH;
strOutFile += strFileName;
wxString strPath;
::wxSplitPath(strOutFile, &strPath, nullptr, nullptr);
xvt_fsys_mkdir(strPath);
wxFileOutputStream fout(strOutFile);
fout.Write(fin);
}
if (!xvt_dm_progress_set_status(pi, f+1, files))
break;
}
xvt_dm_progress_destroy(pi);
return files > 0;
}
///////////////////////////////////////////////////////////
// Zip support
///////////////////////////////////////////////////////////
static void AddFileToZip(const wxString& strPrefix, const wxString& strFile,
wxZipOutputStream& zip)
{
if (!wxFileExists(strFile))
return;
wxString strPath, strName, strExt;
wxSplitPath(strFile, &strPath, &strName, &strExt);
wxString strRelName;
strRelName = strPath.Mid(strPrefix.Length());
if (!strRelName.IsEmpty())
strRelName += '/';
strRelName += strName;
strRelName += '.';
strRelName += strExt;
zip.PutNextEntry(strRelName);
wxFileInputStream fin(strFile);
zip.Write(fin); // Scrivo file compresso
}
static bool AddFilesToZip(const wxString& strBase, wxArrayString& aFiles, const char* zipfile)
{
wxFFileOutputStream out(zipfile);
wxZipOutputStream zip(out);
const size_t nFiles = aFiles.GetCount();
WINDOW pi = xvt_dm_progress_create(NULL_WIN, "Zip", nFiles, TRUE);
for (size_t i = 0; i < nFiles; i++)
{
const wxString& str = aFiles[i];
xvt_dm_progress_set_text(pi, str);
AddFileToZip(strBase, str, zip);
if (!xvt_dm_progress_set_status(pi, i+1, nFiles))
break;
}
xvt_dm_progress_destroy(pi);
return true;
}
bool aga_zip(const char* srcfiles, const char* zipfile)
{
wxString strBase, strMask, strExt;
wxSplitPath(srcfiles, &strBase, &strMask, &strExt);
strMask += '.';
strMask += strExt;
wxArrayString aFiles;
wxDir::GetAllFiles(strBase, &aFiles, strMask);
return AddFilesToZip(strBase, aFiles, zipfile);
}
bool aga_zip_filelist(const char* filelist, const char* zipfile)
{
wxArrayString aFiles;
ifstream fin(filelist);
while (!fin.eof())
{
char name[_MAX_PATH] = { 0 };
fin.getline(name, sizeof(name));
if (*name)
aFiles.Add(name);
else
break;
}
return AddFilesToZip("", aFiles, zipfile);
}
///////////////////////////////////////////////////////////
// DDE
///////////////////////////////////////////////////////////
#include <wx/dde.h>
#define wxAgaClient wxDDEClient
static wxAgaClient* _net_client = nullptr;
static unsigned long _net_conns = 0;
class wxAgaConnection : public wxDDEConnection
{
public:
bool ExecuteAsync(const wxChar *data, int size, wxIPCFormat format = wxIPC_TEXT);
};
bool wxAgaConnection::ExecuteAsync(const wxChar *data, int size, wxIPCFormat WXUNUSED(format))
{
DWORD result;
if (size < 0)
size = (wxStrlen(data) + 1) * sizeof(wxChar); // includes final NUL
bool ok = DdeClientTransaction((LPBYTE)data, size, (HCONV)m_hConv, nullptr,
0, XTYP_EXECUTE, TIMEOUT_ASYNC, &result) != 0;
return ok;
}
unsigned long aga_dde_connect(const char* host, const char* service, const char* topic)
{
if (_net_client == nullptr)
{
_net_client = new wxAgaClient;
_net_conns = 0;
}
wxConnectionBase* conn = _net_client->MakeConnection(host, service, topic);
if (conn != nullptr)
_net_conns++;
return (unsigned long)conn;
}
bool aga_dde_poke(unsigned long connection, const char* item, const char* data)
{
return false;
}
int aga_dde_request(unsigned long connection, const char* item, char* data, int max_size)
{
int len = 0;
if (connection != 0)
{
wxAgaConnection* conn = (wxAgaConnection*)connection;
wxChar* buff = conn->Request(item, &len);
if (max_size > 0)
memcpy(data, buff, min(max_size, len));
}
return len;
}
bool aga_dde_execute(unsigned long connection, const char* msg)
{
bool ok = false;
if (connection != 0)
{
wxAgaConnection* conn = (wxAgaConnection*)connection;
const bool bLogEnabled = wxLog::EnableLogging(false);
ok = conn->Execute(msg, -1);
wxLog::EnableLogging(bLogEnabled);
}
return ok;
}
bool aga_dde_execute_async(unsigned long connection, const char* msg)
{
bool ok = false;
if (connection != 0)
{
wxAgaConnection* conn = (wxAgaConnection*)connection;
ok = conn->ExecuteAsync(msg, -1);
}
return ok;
}
bool aga_dde_terminate(unsigned long connection)
{
bool ok = false;
if (connection != 0 && _net_client != nullptr)
{
wxAgaConnection* conn = (wxAgaConnection*)connection;
ok = conn->Disconnect();
if (ok && _net_conns > 0)
{
_net_conns--;
if (_net_conns == 0)
{
delete _net_client;
_net_client = nullptr;
}
}
}
return ok;
}
///////////////////////////////////////////////////////////
// Multi file operations
///////////////////////////////////////////////////////////
//Solo da Vista in poi...
#include <Shobjidl.h>
#include <ShlGUID.h>
static IFileOperation* CreatePFO()
{
HRESULT hr = ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (!SUCCEEDED(hr))
return nullptr;
IFileOperation *pfo = nullptr;
hr = ::CoCreateInstance(CLSID_FileOperation, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pfo));
if (!SUCCEEDED(hr))
return nullptr;
pfo->SetOperationFlags(FOF_NOCONFIRMATION);
return pfo;
}
static void DeleteIUnknown(IUnknown* iu)
{
if (iu)
{
iu->Release();
iu = nullptr;
}
}
int xvt_fsys_files_remove(const char* src, SLIST names)
{
int nDone = 0;
IFileOperation *pfo = CreatePFO();
if (!pfo)
return -1;
HRESULT hr = 0;
if (xvt_slist_count(names) == 0)
{
wxString n = src;
wxWritableWCharBuffer wcb = n.wchar_str();
IShellItem * psiFolder = nullptr;
hr = ::SHCreateItemFromParsingName(wcb, nullptr, IID_PPV_ARGS(&psiFolder));
if (SUCCEEDED(hr))
{
IEnumShellItems * pEnum = nullptr;
hr = psiFolder->BindToHandler(nullptr, BHID_EnumItems, IID_IEnumShellItems, (void**)&pEnum);
if (SUCCEEDED(hr))
{
hr = pfo->DeleteItems(pEnum);
if (SUCCEEDED(hr))
nDone++;
DeleteIUnknown(pEnum);
}
DeleteIUnknown(psiFolder);
}
}
else
{
wxString srcpath(src);
for (SLIST_ELT e = xvt_slist_get_first(names); e; e = xvt_slist_get_next(names, e))
{
wxFileName n = xvt_slist_get(names, e, nullptr);
wxString name = n.GetFullPath();
if (!n.IsAbsolute() && name.Find(srcpath) == wxNOT_FOUND)
n.PrependDir(src);
wxWritableWCharBuffer wcb = n.GetFullPath().wchar_str();
IShellItem* psiItem = nullptr;
hr = ::SHCreateItemFromParsingName(wcb, nullptr, IID_PPV_ARGS(&psiItem));
if (SUCCEEDED(hr))
{
hr = pfo->DeleteItem(psiItem, nullptr);
if (SUCCEEDED(hr))
nDone++;
DeleteIUnknown(psiItem);
}
}
}
hr = pfo->PerformOperations();
DeleteIUnknown(pfo);
return SUCCEEDED(hr) ? nDone : -1;
}
int xvt_fsys_files_copy(const char* src, SLIST names, const char* dst)
{
int nDone = 0;
IFileOperation *pfo = CreatePFO();
if (!pfo)
return -1;
wxString d = dst;
wxWritableWCharBuffer wcbd = d.wchar_str();
HRESULT hrd = 0;
IShellItem * pdiFolder = nullptr;
hrd = ::SHCreateItemFromParsingName(wcbd, nullptr, IID_PPV_ARGS(&pdiFolder));
if (!SUCCEEDED(hrd))
return -1;
HRESULT hr = 0;
if (xvt_slist_count(names) == 0)
{
wxString n = src;
wxWritableWCharBuffer wcb = n.wchar_str();
IShellItem * psiFolder = nullptr;
hr = ::SHCreateItemFromParsingName(wcb, nullptr, IID_PPV_ARGS(&psiFolder));
if (SUCCEEDED(hr))
{
IEnumShellItems * pEnum = nullptr;
hr = psiFolder->BindToHandler(nullptr, BHID_EnumItems, IID_IEnumShellItems, (void**)&pEnum);
if (SUCCEEDED(hr))
{
hr = pfo->CopyItems(pEnum, pdiFolder);
if (SUCCEEDED(hr))
nDone++;
DeleteIUnknown(pEnum);
}
DeleteIUnknown(psiFolder);
}
}
else
{
for (SLIST_ELT e = xvt_slist_get_first(names); e; e = xvt_slist_get_next(names, e))
{
wxFileName n = xvt_slist_get(names, e, nullptr);
if (!n.IsAbsolute())
n.PrependDir(src);
wxWritableWCharBuffer wcb = n.GetFullPath().wchar_str();
IShellItem* psiItem = nullptr;
hr = ::SHCreateItemFromParsingName(wcb, nullptr, IID_PPV_ARGS(&psiItem));
if (SUCCEEDED(hr))
{
hr = pfo->CopyItem(psiItem, pdiFolder, nullptr, nullptr);
if (SUCCEEDED(hr))
nDone++;
DeleteIUnknown(psiItem);
}
}
}
hr = pfo->PerformOperations();
DeleteIUnknown(pdiFolder);
DeleteIUnknown(pfo);
return SUCCEEDED(hr) ? nDone : -1;
}
int xvt_fsys_files_move(const char* src, SLIST names, const char* dst)
{
int nDone = 0;
IFileOperation *pfo = CreatePFO();
if (!pfo)
return -1;
wxString d = dst;
wxWritableWCharBuffer wcbd = d.wchar_str();
HRESULT hrd = 0;
IShellItem * pdiFolder = nullptr;
hrd = ::SHCreateItemFromParsingName(wcbd, nullptr, IID_PPV_ARGS(&pdiFolder));
if (!SUCCEEDED(hrd))
return -1;
HRESULT hr = 0;
if (xvt_slist_count(names) == 0)
{
wxString n = src;
wxWritableWCharBuffer wcb = n.wchar_str();
IShellItem * psiFolder = nullptr;
hr = ::SHCreateItemFromParsingName(wcb, nullptr, IID_PPV_ARGS(&psiFolder));
if (SUCCEEDED(hr))
{
IEnumShellItems * pEnum = nullptr;
hr = psiFolder->BindToHandler(nullptr, BHID_EnumItems, IID_IEnumShellItems, (void**)&pEnum);
if (SUCCEEDED(hr))
{
hr = pfo->MoveItems(pEnum, pdiFolder);
if (SUCCEEDED(hr))
nDone++;
DeleteIUnknown(pEnum);
}
DeleteIUnknown(psiFolder);
}
}
else
{
for (SLIST_ELT e = xvt_slist_get_first(names); e; e = xvt_slist_get_next(names, e))
{
wxFileName n = xvt_slist_get(names, e, nullptr);
if (!n.IsAbsolute())
n.PrependDir(src);
wxWritableWCharBuffer wcb = n.GetFullPath().wchar_str();
IShellItem* psiItem = nullptr;
hr = ::SHCreateItemFromParsingName(wcb, nullptr, IID_PPV_ARGS(&psiItem));
if (SUCCEEDED(hr))
{
hr = pfo->MoveItem(psiItem, pdiFolder, nullptr, nullptr);
if (SUCCEEDED(hr))
nDone++;
DeleteIUnknown(psiItem);
}
}
}
hr = pfo->PerformOperations();
DeleteIUnknown(pfo);
DeleteIUnknown(pdiFolder);
return SUCCEEDED(hr) ? nDone : -1;
}
void xvt_fsys_get_sys_dir(int what_dir, char * dir)
{
wxFileName d;
wxString out;
switch (what_dir)
{
case XVT_DESKTOP_DIR:
{
d = wxStandardPaths::Get().GetDocumentsDir();
d.SetName(wxString("Desktop"));
out = d.GetFullPath();
}
break;
case XVT_DOCUMENTS_DIR:
d = wxStandardPaths::Get().GetDocumentsDir();
out = d.GetFullPath();
break;
case XVT_EXEC_DIR:
d = wxFileName::DirName(wxStandardPaths::Get().GetExecutablePath());
out = d.GetFullPath();
break;
case XVT_INSTALL_DIR:
d = wxStandardPaths::Get().GetDocumentsDir();
out = d.GetVolume(); out << wxFileName::GetVolumeSeparator().c_str() << "\\";
break;
case XVT_TEMP_DIR:
d = wxStandardPaths::Get().GetTempDir();
out = d.GetFullPath();
break;
default:
break;
}
wxStrncpy(dir, out, MAX_PATH);
}
///////////////////////////////////////////////////////////
// TProgressIndicator
///////////////////////////////////////////////////////////
class TProgressIndicator : public wxDialog
{
enum { MAX_GAUGES = 16 };
wxGauge* m_pGauge[MAX_GAUGES];
wxStaticText* m_pPassed;
wxStaticText* m_pResidual;
wxStaticText* m_pEstimated;
wxStopWatch m_chrono;
long m_nNextUpdate;
protected:
DECLARE_EVENT_TABLE();
void Init(wxString msg, int nGauges, bool bCancellable);
wxString msec2str(long ms) const;
long Elapsed() const { return m_chrono.Time(); }
public:
void SetRange(int nRange, int nGauge = 0);
bool SetProgress(int nPos, int nGauge = 0);
void SetMessage(wxString msg);
TProgressIndicator(wxString msg, bool bCancellable, int nGauges);
TProgressIndicator(size_t nRange, wxString msg, bool bCancellable);
virtual ~TProgressIndicator();
};
BEGIN_EVENT_TABLE(TProgressIndicator, wxDialog)
// EVT_MENU(wxID_CANCEL, TProgressIndicator::OnCancel)
END_EVENT_TABLE()
wxString TProgressIndicator::msec2str(long ms) const
{
int s = ms/1000;
const int h = s / 3600;
s -= h*3600;
const int m = s / 60;
s -= m*60;
return wxString::Format(wxT("%02d:%02d:%02d"), h, m, s);
}
void TProgressIndicator::SetRange(int nRange, int nGauge)
{
wxASSERT(nRange >= 0 && nGauge >= 0 && nGauge < MAX_GAUGES);
m_pGauge[nGauge]->SetRange(nRange);
}
bool TProgressIndicator::SetProgress(int nPos, int nGauge)
{
if (!IsShown())
return false;
wxASSERT(nPos >= 0 && nGauge >= 0 && nGauge < MAX_GAUGES);
m_pGauge[nGauge]->SetValue(nPos);
const long elap = Elapsed();
if (elap > m_nNextUpdate)
{
m_nNextUpdate = elap+CLOCKS_PER_SEC;
m_pPassed->SetLabel(msec2str(elap));
wxLongLong_t nTotValue = 0, nTotRange = 0;
for (int i = 0; i < MAX_GAUGES && m_pGauge[i]; i++)
{
const int nValue = m_pGauge[i]->GetValue();
const int nRange = m_pGauge[i]->GetRange();
if (nValue < nRange) // Escludi dal calcolo i processi già terminati
{
nTotValue += nValue;
nTotRange += nRange;
}
}
if (nTotValue > 0)
{
const long est = long(elap * nTotRange / nTotValue);
m_pEstimated->SetLabel(msec2str(est));
m_pResidual->SetLabel(msec2str(est-elap));
}
wxYield();
}
return true;
}
void TProgressIndicator::SetMessage(wxString msg)
{ SetLabel(msg); }
void TProgressIndicator::Init(wxString msg, int nGauges, bool bCancellable)
{
const int nGap = 4;
wxBoxSizer* pTopSizer = new wxBoxSizer(wxVERTICAL);
SetSizer(pTopSizer);
memset(m_pGauge, 0, sizeof(m_pGauge));
for (int i = 0; i < nGauges; i++)
{
m_pGauge[i] = new wxGauge(this, 1001+i, 100, wxDefaultPosition, wxSize(400, -1));
pTopSizer->Add(m_pGauge[i], 0, wxALL, nGap);
}
wxGridSizer* pTimersSizer = new wxGridSizer(1, 3, nGap, nGap);
pTopSizer->Add(pTimersSizer, 0, wxEXPAND);
wxStaticBoxSizer* pPassed = new wxStaticBoxSizer(wxVERTICAL, this, _("Elapsed Time"));
pTimersSizer->Add(pPassed, 0, wxEXPAND);
m_pPassed = new wxStaticText(this, 1101, wxT("00:00:00"));
pPassed->Add(m_pPassed, 0, wxALL|wxALIGN_CENTER, 0);
wxStaticBoxSizer* pResidual = new wxStaticBoxSizer(wxVERTICAL, this, _("Residual Time"));
pTimersSizer->Add(pResidual, 0, wxEXPAND);
m_pResidual = new wxStaticText(this, 1102, wxT("00:00:00"));
pResidual->Add(m_pResidual, 0, wxALL|wxALIGN_CENTER, 0);
wxStaticBoxSizer* pEstimated = new wxStaticBoxSizer(wxVERTICAL, this, _("Estimated Time"));
pTimersSizer->Add(pEstimated, 0, wxEXPAND);
m_pEstimated = new wxStaticText(this, 1103, wxT("00:00:00"));
pEstimated->Add(m_pEstimated, 0, wxALL|wxALIGN_CENTER, 0);
wxButton* pCancel = nullptr;
if (bCancellable)
{
pCancel = new wxButton(this, wxID_CANCEL, _("Cancel"));
pTopSizer->Add(pCancel, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, nGap);
}
pTopSizer->SetSizeHints(this);
SetMessage(msg);
Show();
Enable();
Update();
m_nNextUpdate = 0;
m_chrono.Start();
}
TProgressIndicator::TProgressIndicator(size_t nRange, wxString msg, bool bCancellable)
: wxDialog(nullptr, wxID_ANY, msg)
{
Init(msg, 1, bCancellable);
SetRange(nRange, 0);
}
TProgressIndicator::TProgressIndicator(wxString msg, bool bCancellable, int nGauges)
: wxDialog(nullptr, wxID_ANY, msg)
{
Init(msg, nGauges, bCancellable);
}
TProgressIndicator::~TProgressIndicator()
{ }
///////////////////////////////////////////////////////////
// Multiprocess
///////////////////////////////////////////////////////////
class TWorker : public wxThread
{
XVT_MULTITHREAD_CALLBACK m_pFunc;
void* m_pCaller;
void* m_pData;
int m_nFirst, m_nLast, m_nTotal;
TProgressIndicator* m_pi;
int m_nGauge;
protected:
virtual ExitCode Entry();
public:
TWorker(XVT_MULTITHREAD_CALLBACK func, void* pCaller, void* pData,
int nFirst, int nLast, int nTotal, TProgressIndicator* pi, int nGauge);
};
wxThread::ExitCode TWorker::Entry()
{
ExitCode ec = 0;
if (m_pi != nullptr)
{
m_pi->SetRange(m_nLast-m_nFirst, m_nGauge);
for (int i = m_nFirst; i < m_nLast && ec == 0; i++)
{
ec = (ExitCode)m_pFunc(m_pCaller, m_pData, i, m_nTotal);
if (!m_pi->SetProgress(i-m_nFirst+1, m_nGauge))
ec = ExitCode(-1);
}
}
else
{
for (int i = m_nFirst; i < m_nLast && ec == 0; i++)
ec = (ExitCode)m_pFunc(m_pCaller, m_pData, i, m_nTotal);
}
return ec;
}
TWorker::TWorker(XVT_MULTITHREAD_CALLBACK func, void* pCaller, void* pData,
int nFirst, int nLast, int nTotal, TProgressIndicator* pi, int nGauge)
: wxThread(wxTHREAD_JOINABLE), m_pFunc(func), m_pCaller(pCaller), m_pData(pData),
m_nFirst(nFirst), m_nLast(nLast), m_nTotal(nTotal), m_pi(pi), m_nGauge(nGauge)
{
// SetPriority(WXTHREAD_MIN_PRIORITY);
Create();
}
BOOLEAN xvt_sys_multithread(XVT_MULTITHREAD_CALLBACK pFunc, void* pCaller, void* pData,
int tot, const char* msg)
{
const int MAX_WORKERS = 16;
// Bilanciamento automatico
int nWorkers = wxThread::GetCPUCount();
if (nWorkers <= 0)
nWorkers = 1;
if (nWorkers > tot)
nWorkers = tot;
if (nWorkers > MAX_WORKERS)
nWorkers = MAX_WORKERS;
int ret = 0;
if (nWorkers > 1)
{
TProgressIndicator* pi = nullptr;
if (msg && *msg)
pi = new TProgressIndicator(msg, tot > nWorkers, nWorkers);
TWorker* worker[MAX_WORKERS]; memset(worker, 0, sizeof(worker));
int nFirst, nLast = 0, w;
for (w = 0; w < nWorkers; w++)
{
nFirst = nLast;
nLast = tot*(w+1)/nWorkers;
worker[w] = new TWorker(pFunc, pCaller, pData, nFirst, nLast, tot, pi, w);
}
for (w = 0; w < nWorkers; w++)
worker[w]->Run();
if (pi != nullptr)
pi->Refresh();
for (w = 0; w < nWorkers; w++)
{
const wxThread::ExitCode r = worker[w]->Wait();
if (ret == 0 && r != 0)
ret = int(r);
delete worker[w];
worker[w] = nullptr;
}
if (pi != nullptr)
delete pi;
}
else
{
if (msg && *msg)
{
TProgressIndicator pi(size_t(tot), msg, tot > nWorkers);
for (int i = 0; i < tot && ret == 0; i++)
{
ret = pFunc(pCaller, pData, i, tot);
if (!pi.SetProgress(i+1))
ret = -1;
}
}
else
{
for (int i = 0; i < tot && ret == 0; i++)
ret = pFunc(pCaller, pData, i, tot);
}
}
return ret;
}
XVTDLL char * xvt_GUID()
{
strstream strguid;
strguid << xg::newGuid() << '\0';
return strguid.str();
}

25
src/xvaga01/agasys.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef __AGASYS_H__
#define __AGASYS_H__
#ifdef WIN32
#if XVAGADLL == 1
#define XVTDLL __declspec(dllexport)
#else
#define XVTDLL __declspec(dllimport)
#endif
#else
#define XVTDLL
#endif
XVTDLL bool aga_unzip(const char* zipfile, const char* destdir);
XVTDLL bool aga_zip(const char* zipmask, const char* zipfile);
XVTDLL bool aga_zip_filelist(const char* filelist, const char* zipfile);
XVTDLL unsigned long aga_dde_connect(const char* host, const char* service, const char* topic);
XVTDLL bool aga_dde_execute(unsigned long connection, const char* command);
XVTDLL bool aga_dde_execute_async(unsigned long connection, const char* command);
XVTDLL bool aga_dde_poke(unsigned long connection, const char* item, const char* data);
XVTDLL int aga_dde_request(unsigned long connection, const char* item, char* data, int max_size);
XVTDLL bool aga_dde_terminate(unsigned long connection);
#endif

4
src/xvaga01/checksum.md5 Normal file
View File

@ -0,0 +1,4 @@
; MD5 checksums created by TeraCopy
; teracopy.com
DD6B72874B85200006D9EDCA2FC2DB23 *xvt_sw.cpp

697
src/xvaga01/fastapi.h Normal file
View File

@ -0,0 +1,697 @@
/****************************************************************************/
/** **/
/** Hardlock **/
/** API-Structures and definitions **/
/** **/
/** This file contains some helpful defines to access a Hardlock using **/
/** the application programming interface (API) for Hardlock. **/
/** **/
/** Aladdin Germany **/
/** **/
/** Revision history **/
/** ----------------
*** $Log: not supported by cvs2svn $
*** Revision 1.52 2003/04/30 12:21:14 chris
*** fix structure packing for Borland
***
*** Revision 1.51 2003/02/24 08:00:28 werner
*** Added RUS-Flag: DISABLE_TS_CHECK for Terminal Server detection
***
*** Revision 1.50 2003/01/30 09:48:13 axel
*** added functions API_GETHLSADDR 108, API_GETHLSTEXT 109
*** added error NO_LOCAL_FUNCTION 61
***
*** Revision 1.49 2002/08/23 10:47:10 axel
*** added API_READ_HLS, API_CALC_HLS and NO_REMOTE_FUNCTION
*** (used for detecting HL-Server Hardlock licenses)
***
*** Revision 1.48 2002/08/22 16:15:27 alex
*** added define _AKS_QT_APPLICATION_ if you want to compile with Qt,
*** because slots from lic structure is a Qt keyword
***
*** Revision 1.47 2002/03/18 13:24:34 chris
*** Win64 changes
***
*** Revision 1.46 2000/12/19 16:37:41 chris
*** detect MacOS X
***
*** Revision 1.45 2000/07/30 22:22:17 chris
*** ia64 detection
***
*** Revision 1.44 2000/07/10 09:45:09 chris
*** Module2 field
***
*** Revision 1.43 2000/05/25 14:11:43 chris
*** added some HASP stuff
***
*** Revision 1.42 2000/03/21 14:18:28 chris
*** HL_SIS and HL_LIS structure definitions
***
*** Revision 1.41 2000/02/18 14:04:44 chris
*** fixed pascal define for CygWin & MingW32
***
*** Revision 1.40 1999/12/06 13:06:11 chris
*** fixed structure packing for MSC compiler
***
*** Revision 1.39 1999/11/28 01:39:46 chris
*** added 64bit support (only tested with AlphaLinux currently)
***
*** Revision 1.38 1999/10/07 11:28:45 chris
*** Duplicate revision
***
*** Revision 1.37 1999/10/07 11:28:45 Henri
*** Removed uneeded TLV defines.
***
*** Revision 1.36 1999/10/07 10:47:04 Henri
*** Removed unused flags.
***
*** Revision 1.35 1999/09/30 09:27:46 Henri
*** Added PORT_BUSY.
***
*** Revision 1.34 1999/09/24 07:49:43 Werner
*** Added RUS_RTB_EXPIRED and RUS_SERIAL_MISMATCH
*** error codes.
***
*** Revision 1.33 1999/09/21 12:06:57 Henri
*** Arranged error codes.
***
*** Revision 1.32 1999/09/20 12:56:28 Werner
*** Added FORCE_ALF_CREATE constant.
***
*** Revision 1.31 1999/09/15 17:04:18 Henri
*** Changed WriteLicense.
***
*** Revision 1.30 1999/09/01 15:06:44 Adi
*** Added special handling of global expiration date.
***
*** Revision 1.29 1999/08/16 13:03:58 chris
*** restore previous structure packing after HL_API definition
*** (for MSVC)
***
*** Revision 1.28 1999/08/08 23:10:55 chris
*** added 2 bytes to reserved field: API structure was 2 bytes too short
***
*** Revision 1.27 1999/08/04 13:04:41 chris
*** API_FFS_GETRUSINFO define
***
*** Revision 1.26 1999/08/04 11:03:33 chris
*** API_FFS_WRITE_LIC definition and some more status codes
***
*** Revision 1.25 1999/08/03 20:36:15 chris
*** renamed FIB structure to RUS_FIB to avoid clash
*** with api_defs.h
***
*** Revision 1.24 1999/07/26 10:58:28 Henri
*** Added FIB structure.
***
*** Revision 1.23 1999/07/19 10:29:35 Henri
*** Renamed define for BUFFER_TOO_SMALL
***
*** Revision 1.22 1999/07/19 10:11:30 Henri
*** Added RUS functionality.
***
*** Revision 1.21 1998/10/21 15:56:53 Henri
*** Changed defines for Borland Builder.
***
*** Revision 1.20 1998/08/14 11:33:54 Henri
*** Changed driver comment.
***
*** Revision 1.19 1998/07/10 12:34:05 Henri
*** Added define for Borland Builder.
***
*** Revision 1.18 1998/06/29 09:01:36 Henri
*** Extended API struc.
***
*** Revision 1.17 1998/06/08 16:36:31 chris
*** fixed structure packing on gcc version 2.7 and above
***
*** Revision 1.16 1998/05/08 14:11:33 Henri
*** Added defines for HL_READID.
***
*** Revision 1.15 1998/04/07 13:14:59 chris
*** added API_READ_ID function code
***
*** Revision 1.14 1998/02/17 21:56:19 Henri
*** Added pragma pack(1) for Watcom 11/DOS
***
*** Revision 1.13 1997/07/01 13:56:54 henri
*** Fixed defines for LabView.
***
*** Revision 1.12 1997/04/28 15:30:53 chris
*** define UNIX32 ifdef __QNX__
***
*** Revision 1.11 1997/02/03 18:08:36 henri
*** Renamed error 17
***
*** Revision 1.10 1997/01/30 17:16:55 henri
*** Added LM return codes.
***
*** Revision 1.9 1997/01/28 08:23:30 henri
*** Missed a semicolon ;-)
***
*** Revision 1.8 1997/01/27 17:57:11 henri
*** Added slot number in API structure.
***
*** Revision 1.7 1997/01/16 18:18:11 henri
*** Added API_LMINIT function code.
***
*** Revision 1.6 1996/11/13 16:55:49 chris
*** added SOLARIS & UNIX32 define
***
*** Revision 1.5 1996/08/12 16:23:43 henri
*** Added VCS log.
***
**/
/****************************************************************************/
#if !defined(_FASTAPI_H_)
#define _FASTAPI_H_
#if defined(LINUX) || defined(SOLARIS) || defined(SCO) || defined(__QNX__) || defined(DARWIN) || defined(MACOSX)
#define UNIX32
#if defined(__alpha__) || defined(__ia64__)
#ifndef __64BIT__
#define __64BIT__
#endif
#define NO_UNALIGN
#endif
#endif
#ifdef __OS2__
#ifdef INTERNAL_16BITDLL
#define LOAD_DS
#else
#ifdef __WATCOMC__
#ifdef __386__ /* not the 16bit compiler */
#include <os2.h>
#endif
#else
#include <os2.h>
#endif
#endif
#ifdef OS_16
#define RET_ Word
#define FAR_ far pascal
#define DATAFAR_ far
#else
#define RET_ APIRET
#define FAR_
#define CALL_ APIENTRY
#define DATAFAR_
#endif
#pragma pack(2)
#endif
#ifdef UNIX32
#define __386__
#define pascal
#pragma pack(1)
#endif
#ifdef __GNUC__
#define __386__
#if !defined(__CYGWIN__) && !defined(__MINGW32__)
#define pascal
#endif
#if ((__GNUC__==2) && (__GNUC_MINOR__>=7)) || (__GNUC__>2)
#define ALIGN_GCC __attribute__ ((__packed__))
#ifdef NO_UNALIGN
#define AS_ALIGN __attribute__ ((__aligned__(8)))
#endif
#else
#pragma pack(1)
#endif
#endif
#ifdef _MSC_VER
#if _MSC_VER >= 900
#pragma pack(push,_fastapi_h_,1)
#else
#pragma pack(1)
#endif
#endif
#ifdef __BORLANDC__
#pragma pack(1)
#endif
#if defined(WINNT) || defined(__WIN32__) || defined(_WIN32)
#if !defined(_WIN64) && !defined(WIN64)
#ifndef __386__ /* Watcom doesnt like it */
#define __386__
#endif
#endif
#ifdef DLL
#define CALL_ __stdcall
#else
#define CALL_
#endif
#endif
#if defined(_WIN64) || defined(WIN64)
#ifndef __64BIT__
#define __64BIT__
#endif
#define DATAFAR_
#define FAR_
#define pascal __stdcall
#endif
#ifdef DOS386 /* Symantec C */
#define __386__
#pragma pack(2)
#endif
#ifdef __HIGHC__ /* Metaware High C */
#define __386__
#define _PACKED _Packed
#endif
#ifdef __ZTC__ /* Zortech C */
#define __386__
#endif
#ifdef SALFORD /* Salford C */
#define ALIGN_ 8
#endif
#ifdef __WATCOMC__
#pragma pack(1)
#ifndef __386__
#ifndef OS_16
#define CALL_ cdecl
#endif
#endif
#endif
#ifdef _CVI_ /* LabWindows/CVI */
#define RET_ Word
#ifndef _NI_mswin32_
#define CALL_ pascal
#else /* No pascal in WIN32-Version of LabWindows/CVI 4.0.1 */
#define CALL_ _stdcall
#endif
#ifndef __386__ /* __386__ defined by LabWindows/CVI */
#define FAR_ far
#define DATAFAR_ far
#endif
#endif
#ifdef __386__
#define DATAFAR_
#define FAR_
#endif
#ifdef HLHIGH_DLL
#define CALL_ pascal _export
#endif
#ifdef LOAD_DS
#define CALL_ _loadds
#endif
#ifndef CALL_
#define CALL_
#endif
#ifndef _PACKED
#define _PACKED
#endif
#ifndef ALIGN_GCC
# define ALIGN_GCC
#endif
#ifndef DATAFAR_
#define DATAFAR_ far
#endif
#ifndef FAR_
#define FAR_ far
#endif
#ifndef RET_
#define RET_ Word
#endif
#ifndef ALIGN_
#define ALIGN_
#endif
#ifndef AS_ALIGN
#define AS_ALIGN
#endif
/* -------------------------------- */
/* Definitions and API structures : */
/* -------------------------------- */
#ifdef __64BIT__
typedef unsigned int Long;
#if !defined(_WIN64) && !defined(WIN64)
typedef unsigned long Int64;
#else
typedef unsigned __int64 Int64; /* stupid Windows convention */
#endif
#else
typedef unsigned long Long;
#endif
#ifndef __BCPLUSPLUS__
typedef unsigned char Byte;
typedef unsigned short Word;
#else
#ifndef VCL_H
typedef unsigned char Byte;
typedef unsigned short Word;
#endif
#endif
#ifndef __64BIT__
#define set_data_ptr(api,buf) (api)->Data=(Byte DATAFAR_ *)(buf)
#define get_data_ptr(api) ((void *)((api)->Data))
#else /* above macros for <=32 bit, below macros for >32 bit */
#define set_data_ptr(api,buf) do { (api)->Data=(((Long)(buf)) & 0xffffffffu); \
(api)->DataHigh=(((Long)(((Int64)(buf))>>32)) \
& 0xffffffffu);} while (0)
#define get_data_ptr(api) ((void *)((Int64)((api)->Data) | \
(((Int64)((api)->DataHigh))<<32)))
#endif
typedef struct
{
Word Use_Key;
Byte Key[8];
} ALIGN_GCC DES_MODE;
typedef struct
{
Word ModAd; /* Hardlock module address */
Word Reg; /* Memory register adress */
Word Value; /* Memory value */
Byte Reserved[4];
} ALIGN_GCC EYE_MODE;
typedef struct
{
Long PW1; /* HASP passwords */
Long PW2;
Word P1;
} ALIGN_GCC HASP_MODE;
typedef struct
{
Word LT_Reserved;
Word Reg; /* Memory register adress */
Word Value; /* Memory value */
Word Password[2]; /* Access passwords */
} ALIGN_GCC LT_MODE;
typedef union
{
DES_MODE Des;
EYE_MODE Eye;
LT_MODE Lt;
HASP_MODE Hasp;
} HARDWARE;
typedef struct
{
Word P2;
Word P3;
} ALIGN_GCC HASP_MODE2;
typedef union
{
HASP_MODE2 Hasp2;
} HARDWARE2;
typedef struct rus_fib
{
Byte MARKER[2];
Long SERIAL_ID;
Byte VERSION[2];
Word FIXED;
Word VAR;
Word CRC;
} ALIGN_GCC RUS_FIB;
typedef _PACKED struct ALIGN_ hl_api
{
Byte API_Version_ID[2]; /* Version */
Word API_Options[2]; /* API Optionflags */
Word ModID; /* Modul-ID (EYE = 0...) */
HARDWARE Module; /* Hardware type */
#ifdef __OS2__ /* Pointer to cipher data */
#ifdef OS_16
void far *Data;
#else
#ifdef __BORLANDC__
void FAR16PTR Data;
#else
void * _Seg16 Data;
#endif
#endif
#else
#ifndef __64BIT__
void DATAFAR_ *Data;
#else
Long Data; /* low part only */
#endif
#endif
Word Bcnt; /* Number of blocks */
Word Function; /* Function number */
Word Status; /* Actual status */
Word Remote; /* Remote or local?? */
Word Port; /* Port address if local */
Word Speed; /* Speed of port if local */
Word NetUsers; /* Current Logins (HL-Server) */
Byte ID_Ref[8]; /* Referencestring */
Byte ID_Verify[8]; /* Encrypted ID_Ref */
Long Task_ID; /* Multitasking program ID */
Word MaxUsers; /* Maximum Logins (HL-Server) */
Long Timeout; /* Login Timeout in minutes */
Word ShortLife; /* (multiple use) */
Word Application; /* Application number */
Word Protocol; /* Protocol flags */
Word PM_Host; /* DOS Extender type */
Long OSspecific; /* ptr to OS specific data */
Word PortMask; /* Default local search (in) */
Word PortFlags; /* Default local search (out) */
Word EnvMask; /* Use env string search (in) */
Word EnvFlags; /* Use env string search (out) */
Byte EEFlags; /* EE type flags */
Word Prot4Info; /* (internal use) */
Byte FuncOptions; /* Enable add. functionality */
Word Slot_ID; /* Licence slot number */
Word Slot_ID_HIGH; /* Licence slot High value */
Word RUS_ExpDate; /* RUS Expiration date */
Long DataHigh; /* Pointer to data high value */
#ifndef __64BIT__
void DATAFAR_ *VendorKey; /* Pointer to RUS vendor key */
#else
Long VendorKey; /* dto. */
#endif
Long VendorKeyHigh; /* Vendor key high value */
Long OSspecificHigh; /* ptr to OS specific data */
Long RUS_MaxInfo; /* RUS max user/counter */
Long RUS_CurInfo; /* RUS current user/counter */
RUS_FIB RUS_Fib; /* RUS FIB structure */
HARDWARE2 Module2; /* 2nd hw dependend fields */
Byte Reserved2[122]; /* Reserved area */
} ALIGN_GCC AS_ALIGN HL_API, LT_API, HS_API;
typedef _PACKED struct ALIGN_ { /* HL_LIS slot information */
Long max_user;
Long cur_user;
Word exp_date;
Byte flag; /* singularity flag */
Byte res; /* filler to make structure size multiple of 4 bytes */
} ALIGN_GCC HL_SIS;
/* License Information Structure (HL_LIS) */
typedef _PACKED struct ALIGN_ {
Word current_date;
Word res;
Long num_slots;
Word glob_exp_date;
Word res2; /* filler to make size multiple of 4 bytes */
#ifdef __AKS_QT_APPLICATION__
HL_SIS slot[1]; /* slots is a keyword in Qt application, renamed array */
#else
HL_SIS slots[1];
#endif
} ALIGN_GCC HL_LIS;
#ifdef UNIX32
#pragma pack()
#endif
#ifdef __OS2__
#pragma pack()
#endif
#ifdef __BORLANDC__
#pragma pack(1)
#endif
#ifdef _MSC_VER
#if _MSC_VER >= 900
#pragma pack(pop,_fastapi_h_)
#else
#pragma pack()
#endif
#endif
/* ------------- */
/* Module-ID's : */
/* ------------- */
#define EYE_DONGLE 0 /* Hardlock E-Y-E */
#define DES_DONGLE 1 /* FAST DES */
#define LT_DONGLE 3 /* Hardlock LT */
#define HASP_DONGLE 4 /* HASP */
/* --------------------- */
/* API function calls : */
/* --------------------- */
#define API_INIT 0 /* Init API structure */
#define API_DOWN 1 /* Free API structure */
#define API_FORCE_DOWN 31 /* Force deinintialization */
#define API_MULTI_SHELL_ON 2 /* MTS is enabled */
#define API_MULTI_SHELL_OFF 3 /* MTS is disabled */
#define API_MULTI_ON 4 /* Enable MTS */
#define API_MULTI_OFF 5 /* Disable MTS */
#define API_AVAIL 6 /* Dongle available? */
#define API_LOGIN 7 /* Login dongle server */
#define API_LOGOUT 8 /* Logout dongle server */
#define API_INFO 9 /* Get API informations */
#define API_GET_TASKID 32 /* Get TaskID from API */
#define API_LOGIN_INFO 34 /* Get API Login informations */
/* --------------------------- */
/* Data and memory functions : */
/* --------------------------- */
#define API_KEYE 11 /* Use KEYE for encryption */
#define API_READ 20 /* Read one word of dongle EEPROM */
#define API_WRITE 21 /* Write one word of dongle EEPROM */
#define API_READ_BLOCK 23 /* Read EEPROM in one block */
#define API_WRITE_BLOCK 24 /* Write EEPROM in one block */
#define API_READ_ID 29 /* Read USB ID memory */
#define API_ABORT 51 /* Critical Error Abort */
/* -------------- */
/* LM functions : */
/* -------------- */
#define API_LMINIT 40 /* LM compatible API_INIT replacement */
#define API_LMPING 41 /* checks if LM dongle and slot is available */
#define API_LMINFO 42 /* info about currently used LIMA */
#define API_READ_HLS 78 /* get number of licences for USB server HL */
#define API_CALC_HLS 79 /* calculate num of licenses for parallel server HL */
#define API_GETHLSADDR 108 /* get addr struc of currently used HLS */
#define API_GETHLSTEXT 109 /* get text addr of currently used HLS */
/* --------------- */
/* RUS functions : */
/* --------------- */
#define API_FFS_INIT 256 /* RUS init function, downed with API_DOWN */
#define API_FFS_ISRUSHL 257 /* Is RUS HL ? */
#define API_FFS_LOGIN 258 /* RUS Login to Hardlock server */
#define API_FFS_CHECK_LIC 259 /* RUS Create LIS */
#define API_FFS_READ_LICBLOCK 260 /* RUS Read LIC Block */
#define API_FFS_QUERY_SLOT 261 /* RUS query slot function */
#define API_FFS_FREE_SLOT 262 /* RUS free slot */
#define API_FFS_OCCUPY_SLOT 263 /* RUS occupies a slot */
#define API_FFS_INC_CNTR 264 /* RUS counter increment */
#define API_FFS_PARSERTB 265 /* RUS Parse RTB */
#define API_FFS_GET_HWDEP_INFO 266 /* RUS get hardware dependent information */
#define API_FFS_WRITE_LIC 267 /* RUS write updated license information */
#define API_FFS_GETRUSINFO 269 /* get RUS info */
/* -------------------- */
/* Dongle access mode : */
/* -------------------- */
#define LOCAL_DEVICE 1 /* Query local HL only */
#define NET_DEVICE 2 /* Query remote HL only */
#define DONT_CARE 3 /* Query local or remote HL */
/* -------------------- */
/* EnvMask/Port Flags : */
/* -------------------- */
#define USB_DEVICE 256 /* Port flag for USB use */
#define IGNORE_ENVIRONMENT 0x8000 /* Ignore HL_SEARCH */
#define EEF_NOAUTOUSB 8 /* No automatic USB search */
/* ---------- */
/* RUS flags: */
/* ---------- */
#define FORCE_RUS 1 /* Enable RUS init without VK */
#define DISABLE_TS_CHECK 2 /* Disable Terminal Server Detection */
#define FORCE_ALF_CREATE 1 /* Force creation of ALF file in HLM_WRITELICENSE */
/* ------------------ */
/* API PM_Host ID's : */
/* ------------------ */
#define API_XTD_DETECT 0
#define API_XTD_DPMI 1 /* QDPMI, Borland, Windows ... */
#define API_XTD_PHAR386 2
#define API_XTD_PHAR286 3
#define API_XTD_CODEBLDR 4 /* Intel Code Builder */
#define API_XTD_COBOLXM 5
/* ------------------ */
/* API Status Codes : */
/* ------------------ */
#define STATUS_OK 0 /* API call was succesfull */
#define NOT_INIT 1 /* DONGLE not initialized */
#define ALREADY_INIT 2 /* Already initialized */
#define UNKNOWN_DONGLE 3 /* Device not supported */
#define UNKNOWN_FUNCTION 4 /* Function not supported */
#define HLS_FULL 6 /* HL-Server login table full */
#define NO_DONGLE 7 /* No device available */
#define NETWORK_ERROR 8 /* A network error occured */
#define NO_ACCESS 9 /* No device available */
#define INVALID_PARAM 10 /* A wrong parameter occured */
#define VERSION_MISMATCH 11 /* HL-Server not API version */
#define DOS_ALLOC_ERROR 12 /* Error on memory allocation */
#define CANNOT_OPEN_DRIVER 14 /* Can not open Hardlock driver */
#define INVALID_ENV 15 /* Invalid environment string */
#define DYNALINK_FAILED 16 /* Unable to get a function entry */
#define INVALID_LIC 17 /* No valid licence info (LM) */
#define NO_LICENSE 18 /* Slot/licence not enabled (LM) */
#define PORT_BUSY 19 /* Cannot acquire port */
#define RUS_NO_DEVICE 20 /* Key is no Hardlock RUS key */
#define RUS_INVALID_LIC 21 /* Invalid RUS license */
#define RUS_SYNC_ERR 22 /* FIB in key and api struc mismatch */
#define NOT_IMPLEMENTED 23 /* not (yet) implemented */
#define BUFFER_TOO_SMALL 24 /* Buffer for function too small */
#define UNKNOWN_HW_TYPE 25 /* unknown hardware descriptor */
#define RUS_INV_FBPOS 26 /* unknown fixed block position */
#define RUS_INVALID_SLOT 27 /* Non-existing slot number given */
#define RUS_DATE_FAKE 28 /* RUS Date fake detected */
#define RUS_COUNT_DOWN 29 /* RUS dead counter limit reached */
#define RUS_INVALID_VK 30 /* RUS Vendor key is invalid */
#define RUS_NO_LIC_FILE 31 /* RUS License file not found */
#define RUS_INV_VBLOCK 32 /* RUS invalid variable block */
#define RUS_LIC_FILE_WRITE_ERR 33 /* error writing (updated) license file */
#define RUS_NO_INFO_AVAILABLE 34 /* GET_HWDEP_INFO: no info there */
#define RUS_INFO_PACK_ERR 35 /* " " " " : cannot TLV encode data */
#define RUS_LIC_WRITE_ERR 36 /* write license failed */
#define RUS_DATE_EXPIRED 37 /* RUS Expiration Date reached. */
#define TS_DETECTED 38 /* Term. Server / Citrix Winframe detected*/
#define RUS_INVALID_RTB 39 /* Invalid updated data (RTB) */
#define RUS_RTB_EXPIRED 40 /* Update data (RTB) has expired. */
#define RUS_SERIAL_MISMATCH 41 /* Update data serial does not match */
#define NO_REMOTE_FUNCTION 60 /* function is available locally only */
#define NO_LOCAL_FUNCTION 61 /* function is available remotely only */
#define TOO_MANY_USERS 256 /* Login table full (remote) */
#define SELECT_DOWN 257 /* Printer not On-line */
#define NO_SERIALID 258 /* Serial ID not readable or n/a */
#endif /*_FASTAPI_H_*/
/* eof */

607
src/xvaga01/fstrcmp.c Normal file
View File

@ -0,0 +1,607 @@
/* Functions to make fuzzy comparisons between strings
Copyright (C) 1988-1989, 1992-1993, 1995, 2001 Free Software Foundation, Inc.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
Derived from GNU diff 2.7, analyze.c et al.
The basic algorithm is described in:
"An O(ND) Difference Algorithm and its Variations", Eugene Myers,
Algorithmica Vol. 1 No. 2, 1986, pp. 251-266;
see especially section 4.2, which describes the variation used below.
The basic algorithm was independently discovered as described in:
"Algorithms for Approximate String Matching", E. Ukkonen,
Information and Control Vol. 64, 1985, pp. 100-118.
Modified to work on strings rather than files
by Peter Miller <pmiller@agso.gov.au>, October 1995 */
/* Specification. */
#include "fstrcmp.h"
#include <string.h>
#include <stdio.h>
#include <limits.h>
#ifdef WIN32
#include <malloc.h>
#else
#include <stdlib.h>
#endif
/*
* Data on one input string being compared.
*/
struct string_data
{
/* The string to be compared. */
const char *data;
/* The length of the string to be compared. */
int data_length;
/* The number of characters inserted or deleted. */
int edit_count;
};
static struct string_data string[2];
#ifdef MINUS_H_FLAG
/* This corresponds to the diff -H flag. With this heuristic, for
strings with a constant small density of changes, the algorithm is
linear in the strings size. This is unlikely in typical uses of
fstrcmp, and so is usually compiled out. Besides, there is no
interface to set it true. */
static int heuristic;
#endif
/* Vector, indexed by diagonal, containing 1 + the X coordinate of the
point furthest along the given diagonal in the forward search of the
edit matrix. */
static int *fdiag;
/* Vector, indexed by diagonal, containing the X coordinate of the point
furthest along the given diagonal in the backward search of the edit
matrix. */
static int *bdiag;
/* Edit scripts longer than this are too expensive to compute. */
static int too_expensive;
/* Snakes bigger than this are considered `big'. */
#define SNAKE_LIMIT 20
struct partition
{
/* Midpoints of this partition. */
int xmid, ymid;
/* Nonzero if low half will be analyzed minimally. */
int lo_minimal;
/* Likewise for high half. */
int hi_minimal;
};
/* NAME
diag - find diagonal path
SYNOPSIS
int diag(int xoff, int xlim, int yoff, int ylim, int minimal,
struct partition *part);
DESCRIPTION
Find the midpoint of the shortest edit script for a specified
portion of the two strings.
Scan from the beginnings of the strings, and simultaneously from
the ends, doing a breadth-first search through the space of
edit-sequence. When the two searches meet, we have found the
midpoint of the shortest edit sequence.
If MINIMAL is nonzero, find the minimal edit script regardless
of expense. Otherwise, if the search is too expensive, use
heuristics to stop the search and report a suboptimal answer.
RETURNS
Set PART->(XMID,YMID) to the midpoint (XMID,YMID). The diagonal
number XMID - YMID equals the number of inserted characters
minus the number of deleted characters (counting only characters
before the midpoint). Return the approximate edit cost; this is
the total number of characters inserted or deleted (counting
only characters before the midpoint), unless a heuristic is used
to terminate the search prematurely.
Set PART->LEFT_MINIMAL to nonzero iff the minimal edit script
for the left half of the partition is known; similarly for
PART->RIGHT_MINIMAL.
CAVEAT
This function assumes that the first characters of the specified
portions of the two strings do not match, and likewise that the
last characters do not match. The caller must trim matching
characters from the beginning and end of the portions it is
going to specify.
If we return the "wrong" partitions, the worst this can do is
cause suboptimal diff output. It cannot cause incorrect diff
output. */
static int diag (int xoff, int xlim, int yoff, int ylim, int minimal, struct partition * part)
{
int *const fd = fdiag; /* Give the compiler a chance. */
int *const bd = bdiag; /* Additional help for the compiler. */
const char *const xv = string[0].data; /* Still more help for the compiler. */
const char *const yv = string[1].data; /* And more and more . . . */
const int dmin = xoff - ylim; /* Minimum valid diagonal. */
const int dmax = xlim - yoff; /* Maximum valid diagonal. */
const int fmid = xoff - yoff; /* Center diagonal of top-down search. */
const int bmid = xlim - ylim; /* Center diagonal of bottom-up search. */
int fmin = fmid;
int fmax = fmid; /* Limits of top-down search. */
int bmin = bmid;
int bmax = bmid; /* Limits of bottom-up search. */
int c; /* Cost. */
int odd = (fmid - bmid) & 1;
/*
* True if southeast corner is on an odd diagonal with respect
* to the northwest.
*/
fd[fmid] = xoff;
bd[bmid] = xlim;
for (c = 1;; ++c)
{
int d; /* Active diagonal. */
int big_snake;
big_snake = 0;
/* Extend the top-down search by an edit step in each diagonal. */
if (fmin > dmin)
fd[--fmin - 1] = -1;
else
++fmin;
if (fmax < dmax)
fd[++fmax + 1] = -1;
else
--fmax;
for (d = fmax; d >= fmin; d -= 2)
{
int x;
int y;
int oldx;
int tlo;
int thi;
tlo = fd[d - 1],
thi = fd[d + 1];
if (tlo >= thi)
x = tlo + 1;
else
x = thi;
oldx = x;
y = x - d;
while (x < xlim && y < ylim && xv[x] == yv[y])
{
++x;
++y;
}
if (x - oldx > SNAKE_LIMIT)
big_snake = 1;
fd[d] = x;
if (odd && bmin <= d && d <= bmax && bd[d] <= x)
{
part->xmid = x;
part->ymid = y;
part->lo_minimal = part->hi_minimal = 1;
return 2 * c - 1;
}
}
/* Similarly extend the bottom-up search. */
if (bmin > dmin)
bd[--bmin - 1] = INT_MAX;
else
++bmin;
if (bmax < dmax)
bd[++bmax + 1] = INT_MAX;
else
--bmax;
for (d = bmax; d >= bmin; d -= 2)
{
int x;
int y;
int oldx;
int tlo;
int thi;
tlo = bd[d - 1],
thi = bd[d + 1];
if (tlo < thi)
x = tlo;
else
x = thi - 1;
oldx = x;
y = x - d;
while (x > xoff && y > yoff && xv[x - 1] == yv[y - 1])
{
--x;
--y;
}
if (oldx - x > SNAKE_LIMIT)
big_snake = 1;
bd[d] = x;
if (!odd && fmin <= d && d <= fmax && x <= fd[d])
{
part->xmid = x;
part->ymid = y;
part->lo_minimal = part->hi_minimal = 1;
return 2 * c;
}
}
if (minimal)
continue;
#ifdef MINUS_H_FLAG
/* Heuristic: check occasionally for a diagonal that has made lots
of progress compared with the edit distance. If we have any
such, find the one that has made the most progress and return
it as if it had succeeded.
With this heuristic, for strings with a constant small density
of changes, the algorithm is linear in the strings size. */
if (c > 200 && big_snake && heuristic)
{
int best;
best = 0;
for (d = fmax; d >= fmin; d -= 2)
{
int dd;
int x;
int y;
int v;
dd = d - fmid;
x = fd[d];
y = x - d;
v = (x - xoff) * 2 - dd;
if (v > 12 * (c + (dd < 0 ? -dd : dd)))
{
if
(
v > best
&&
xoff + SNAKE_LIMIT <= x
&&
x < xlim
&&
yoff + SNAKE_LIMIT <= y
&&
y < ylim
)
{
/* We have a good enough best diagonal; now insist
that it end with a significant snake. */
int k;
for (k = 1; xv[x - k] == yv[y - k]; k++)
{
if (k == SNAKE_LIMIT)
{
best = v;
part->xmid = x;
part->ymid = y;
break;
}
}
}
}
}
if (best > 0)
{
part->lo_minimal = 1;
part->hi_minimal = 0;
return 2 * c - 1;
}
best = 0;
for (d = bmax; d >= bmin; d -= 2)
{
int dd;
int x;
int y;
int v;
dd = d - bmid;
x = bd[d];
y = x - d;
v = (xlim - x) * 2 + dd;
if (v > 12 * (c + (dd < 0 ? -dd : dd)))
{
if (v > best && xoff < x && x <= xlim - SNAKE_LIMIT &&
yoff < y && y <= ylim - SNAKE_LIMIT)
{
/* We have a good enough best diagonal; now insist
that it end with a significant snake. */
int k;
for (k = 0; xv[x + k] == yv[y + k]; k++)
{
if (k == SNAKE_LIMIT - 1)
{
best = v;
part->xmid = x;
part->ymid = y;
break;
}
}
}
}
}
if (best > 0)
{
part->lo_minimal = 0;
part->hi_minimal = 1;
return 2 * c - 1;
}
}
#endif /* MINUS_H_FLAG */
/* Heuristic: if we've gone well beyond the call of duty, give up
and report halfway between our best results so far. */
if (c >= too_expensive)
{
int fxybest;
int fxbest;
int bxybest;
int bxbest;
/* Pacify `gcc -Wall'. */
fxbest = 0;
bxbest = 0;
/* Find forward diagonal that maximizes X + Y. */
fxybest = -1;
for (d = fmax; d >= fmin; d -= 2)
{
int x;
int y;
x = fd[d] < xlim ? fd[d] : xlim;
y = x - d;
if (ylim < y)
{
x = ylim + d;
y = ylim;
}
if (fxybest < x + y)
{
fxybest = x + y;
fxbest = x;
}
}
/* Find backward diagonal that minimizes X + Y. */
bxybest = INT_MAX;
for (d = bmax; d >= bmin; d -= 2)
{
int x;
int y;
x = xoff > bd[d] ? xoff : bd[d];
y = x - d;
if (y < yoff)
{
x = yoff + d;
y = yoff;
}
if (x + y < bxybest)
{
bxybest = x + y;
bxbest = x;
}
}
/* Use the better of the two diagonals. */
if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff))
{
part->xmid = fxbest;
part->ymid = fxybest - fxbest;
part->lo_minimal = 1;
part->hi_minimal = 0;
}
else
{
part->xmid = bxbest;
part->ymid = bxybest - bxbest;
part->lo_minimal = 0;
part->hi_minimal = 1;
}
return 2 * c - 1;
}
}
}
/* NAME
compareseq - find edit sequence
SYNOPSIS
void compareseq(int xoff, int xlim, int yoff, int ylim, int minimal);
DESCRIPTION
Compare in detail contiguous subsequences of the two strings
which are known, as a whole, to match each other.
The subsequence of string 0 is [XOFF, XLIM) and likewise for
string 1.
Note that XLIM, YLIM are exclusive bounds. All character
numbers are origin-0.
If MINIMAL is nonzero, find a minimal difference no matter how
expensive it is. */
static void compareseq (int xoff, int xlim, int yoff, int ylim, int minimal)
{
const char *const xv = string[0].data; /* Help the compiler. */
const char *const yv = string[1].data;
/* Slide down the bottom initial diagonal. */
while (xoff < xlim && yoff < ylim && xv[xoff] == yv[yoff])
{
++xoff;
++yoff;
}
/* Slide up the top initial diagonal. */
while (xlim > xoff && ylim > yoff && xv[xlim - 1] == yv[ylim - 1])
{
--xlim;
--ylim;
}
/* Handle simple cases. */
if (xoff == xlim)
{
while (yoff < ylim)
{
++string[1].edit_count;
++yoff;
}
}
else if (yoff == ylim)
{
while (xoff < xlim)
{
++string[0].edit_count;
++xoff;
}
}
else
{
int c;
struct partition part;
/* Find a point of correspondence in the middle of the strings. */
c = diag (xoff, xlim, yoff, ylim, minimal, &part);
if (c == 1)
{
#if 0
/* This should be impossible, because it implies that one of
the two subsequences is empty, and that case was handled
above without calling `diag'. Let's verify that this is
true. */
abort ();
#else
/* The two subsequences differ by a single insert or delete;
record it and we are done. */
if (part.xmid - part.ymid < xoff - yoff)
++string[1].edit_count;
else
++string[0].edit_count;
#endif
}
else
{
/* Use the partitions to split this problem into subproblems. */
compareseq (xoff, part.xmid, yoff, part.ymid, part.lo_minimal);
compareseq (part.xmid, xlim, part.ymid, ylim, part.hi_minimal);
}
}
}
/* NAME
fstrcmp - fuzzy string compare
SYNOPSIS
double fstrcmp(const char *, const char *);
DESCRIPTION
The fstrcmp function may be used to compare two string for
similarity. It is very useful in reducing "cascade" or
"secondary" errors in compilers or other situations where
symbol tables occur.
RETURNS
double; 0 if the strings are entirely dissimilar, 1 if the
strings are identical, and a number in between if they are
similar. */
double fstrcmp (const char * string1, const char *string2)
{
int i;
size_t fdiag_len;
static int *fdiag_buf;
static size_t fdiag_max;
/* set the info for each string. */
string[0].data = string1;
string[0].data_length = strlen (string1);
string[1].data = string2;
string[1].data_length = strlen (string2);
/* short-circuit obvious comparisons */
if (string[0].data_length == 0 && string[1].data_length == 0)
return 1.0;
if (string[0].data_length == 0 || string[1].data_length == 0)
return 0.0;
/* Set TOO_EXPENSIVE to be approximate square root of input size,
bounded below by 256. */
too_expensive = 1;
for (i = string[0].data_length + string[1].data_length; i != 0; i >>= 2)
too_expensive <<= 1;
if (too_expensive < 256)
too_expensive = 256;
/* Because fstrcmp is typically called multiple times, while scanning
symbol tables, etc, attempt to minimize the number of memory
allocations performed. Thus, we use a static buffer for the
diagonal vectors, and never free them. */
fdiag_len = string[0].data_length + string[1].data_length + 3;
if (fdiag_len > fdiag_max)
{
fdiag_max = fdiag_len;
fdiag_buf = realloc (fdiag_buf, fdiag_max * (2 * sizeof (int))); // era xrealloc
}
fdiag = fdiag_buf + string[1].data_length + 1;
bdiag = fdiag + fdiag_len;
/* Now do the main comparison algorithm */
string[0].edit_count = 0;
string[1].edit_count = 0;
compareseq (0, string[0].data_length, 0, string[1].data_length, 0);
/* The result is
((number of chars in common) / (average length of the strings)).
This is admittedly biased towards finding that the strings are
similar, however it does produce meaningful results. */
return ((double) (string[0].data_length + string[1].data_length
- string[1].edit_count - string[0].edit_count)
/ (string[0].data_length + string[1].data_length));
}

33
src/xvaga01/fstrcmp.h Normal file
View File

@ -0,0 +1,33 @@
/* GNU gettext - internationalization aids
Copyright (C) 1995, 2000 Free Software Foundation, Inc.
This file was written by Peter Miller <pmiller@agso.gov.au>
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, 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. */
#ifndef _FSTRCMP_H
#define _FSTRCMP_H
#ifdef __cplusplus
extern "C" { // No mangling!
#endif
double fstrcmp(const char * string1, const char *string2);
#ifdef __cplusplus
}
#endif
#endif

407
src/xvaga01/guid.cpp Normal file
View File

@ -0,0 +1,407 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Graeme Hill (http://graemehill.ca)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <cstring>
#include "guid.hpp"
#ifdef GUID_LIBUUID
#include <uuid/uuid.h>
#endif
#ifdef GUID_CFUUID
#include <CoreFoundation/CFUUID.h>
#endif
#ifdef GUID_WINDOWS
#include <objbase.h>
#endif
#ifdef GUID_ANDROID
#include <jni.h>
#include <cassert>
#endif
BEGIN_XG_NAMESPACE
#ifdef GUID_ANDROID
AndroidGuidInfo androidInfo;
AndroidGuidInfo AndroidGuidInfo::fromJniEnv(JNIEnv *env)
{
AndroidGuidInfo info;
info.env = env;
auto localUuidClass = env->FindClass("java/util/UUID");
info.uuidClass = (jclass)env->NewGlobalRef(localUuidClass);
env->DeleteLocalRef(localUuidClass);
info.newGuidMethod = env->GetStaticMethodID(
info.uuidClass, "randomUUID", "()Ljava/util/UUID;");
info.mostSignificantBitsMethod = env->GetMethodID(
info.uuidClass, "getMostSignificantBits", "()J");
info.leastSignificantBitsMethod = env->GetMethodID(
info.uuidClass, "getLeastSignificantBits", "()J");
info.initThreadId = std::this_thread::get_id();
return info;
}
void initJni(JNIEnv *env)
{
androidInfo = AndroidGuidInfo::fromJniEnv(env);
}
#endif
// overload << so that it's easy to convert to a string
std::ostream &operator<<(std::ostream &s, const Guid &guid)
{
std::ios_base::fmtflags f(s.flags()); // politely don't leave the ostream in hex mode
s << std::hex << std::setfill('0')
<< std::setw(2) << (int)guid._bytes[0]
<< std::setw(2) << (int)guid._bytes[1]
<< std::setw(2) << (int)guid._bytes[2]
<< std::setw(2) << (int)guid._bytes[3]
<< "-"
<< std::setw(2) << (int)guid._bytes[4]
<< std::setw(2) << (int)guid._bytes[5]
<< "-"
<< std::setw(2) << (int)guid._bytes[6]
<< std::setw(2) << (int)guid._bytes[7]
<< "-"
<< std::setw(2) << (int)guid._bytes[8]
<< std::setw(2) << (int)guid._bytes[9]
<< "-"
<< std::setw(2) << (int)guid._bytes[10]
<< std::setw(2) << (int)guid._bytes[11]
<< std::setw(2) << (int)guid._bytes[12]
<< std::setw(2) << (int)guid._bytes[13]
<< std::setw(2) << (int)guid._bytes[14]
<< std::setw(2) << (int)guid._bytes[15];
s.flags(f);
return s;
}
bool operator<(const xg::Guid &lhs, const xg::Guid &rhs)
{
return lhs.bytes() < rhs.bytes();
}
bool Guid::isValid() const
{
xg::Guid empty;
return *this != empty;
}
// convert to string using std::snprintf() and std::string
std::string Guid::str() const
{
char one[10], two[6], three[6], four[6], five[14];
snprintf(one, 10, "%02x%02x%02x%02x",
_bytes[0], _bytes[1], _bytes[2], _bytes[3]);
snprintf(two, 6, "%02x%02x",
_bytes[4], _bytes[5]);
snprintf(three, 6, "%02x%02x",
_bytes[6], _bytes[7]);
snprintf(four, 6, "%02x%02x",
_bytes[8], _bytes[9]);
snprintf(five, 14, "%02x%02x%02x%02x%02x%02x",
_bytes[10], _bytes[11], _bytes[12], _bytes[13], _bytes[14], _bytes[15]);
const std::string sep("-");
std::string out(one);
out += sep + two;
out += sep + three;
out += sep + four;
out += sep + five;
return out;
}
// conversion operator for std::string
Guid::operator std::string() const
{
return str();
}
// Access underlying bytes
const std::array<unsigned char, 16>& Guid::bytes() const
{
return _bytes;
}
// create a guid from vector of bytes
Guid::Guid(const std::array<unsigned char, 16> &bytes) : _bytes(bytes)
{ }
// create a guid from vector of bytes
Guid::Guid(std::array<unsigned char, 16> &&bytes) : _bytes(std::move(bytes))
{ }
// converts a single hex char to a number (0 - 15)
unsigned char hexDigitToChar(char ch)
{
// 0-9
if (ch > 47 && ch < 58)
return ch - 48;
// a-f
if (ch > 96 && ch < 103)
return ch - 87;
// A-F
if (ch > 64 && ch < 71)
return ch - 55;
return 0;
}
bool isValidHexChar(char ch)
{
// 0-9
if (ch > 47 && ch < 58)
return true;
// a-f
if (ch > 96 && ch < 103)
return true;
// A-F
if (ch > 64 && ch < 71)
return true;
return false;
}
// converts the two hexadecimal characters to an unsigned char (a byte)
unsigned char hexPairToChar(char a, char b)
{
return hexDigitToChar(a) * 16 + hexDigitToChar(b);
}
// create a guid from string
/*
Guid::Guid(std::string_view fromString)
{
char charOne = '\0';
char charTwo = '\0';
bool lookingForFirstChar = true;
unsigned nextByte = 0;
for (const char &ch : fromString)
{
if (ch == '-')
continue;
if (nextByte >= 16 || !isValidHexChar(ch))
{
// Invalid string so bail
zeroify();
return;
}
if (lookingForFirstChar)
{
charOne = ch;
lookingForFirstChar = false;
}
else
{
charTwo = ch;
auto byte = hexPairToChar(charOne, charTwo);
_bytes[nextByte++] = byte;
lookingForFirstChar = true;
}
}
// if there were fewer than 16 bytes in the string then guid is bad
if (nextByte < 16)
{
zeroify();
return;
}
}
*/
// create empty guid
Guid::Guid() : _bytes{ {0} }
{ }
// set all bytes to zero
void Guid::zeroify()
{
std::fill(_bytes.begin(), _bytes.end(), static_cast<unsigned char>(0));
}
// overload equality operator
bool Guid::operator==(const Guid &other) const
{
return _bytes == other._bytes;
}
// overload inequality operator
bool Guid::operator!=(const Guid &other) const
{
return !((*this) == other);
}
// member swap function
void Guid::swap(Guid &other)
{
_bytes.swap(other._bytes);
}
// This is the linux friendly implementation, but it could work on other
// systems that have libuuid available
#ifdef GUID_LIBUUID
Guid newGuid()
{
std::array<unsigned char, 16> data;
static_assert(std::is_same<unsigned char[16], uuid_t>::value, "Wrong type!");
uuid_generate(data.data());
return Guid{std::move(data)};
}
#endif
// this is the mac and ios version
#ifdef GUID_CFUUID
Guid newGuid()
{
auto newId = CFUUIDCreate(NULL);
auto bytes = CFUUIDGetUUIDBytes(newId);
CFRelease(newId);
std::array<unsigned char, 16> byteArray =
{{
bytes.byte0,
bytes.byte1,
bytes.byte2,
bytes.byte3,
bytes.byte4,
bytes.byte5,
bytes.byte6,
bytes.byte7,
bytes.byte8,
bytes.byte9,
bytes.byte10,
bytes.byte11,
bytes.byte12,
bytes.byte13,
bytes.byte14,
bytes.byte15
}};
return Guid{std::move(byteArray)};
}
#endif
// obviously this is the windows version
#ifdef GUID_WINDOWS
Guid newGuid()
{
GUID newId;
CoCreateGuid(&newId);
std::array<unsigned char, 16> bytes =
{
(unsigned char)((newId.Data1 >> 24) & 0xFF),
(unsigned char)((newId.Data1 >> 16) & 0xFF),
(unsigned char)((newId.Data1 >> 8) & 0xFF),
(unsigned char)((newId.Data1) & 0xff),
(unsigned char)((newId.Data2 >> 8) & 0xFF),
(unsigned char)((newId.Data2) & 0xff),
(unsigned char)((newId.Data3 >> 8) & 0xFF),
(unsigned char)((newId.Data3) & 0xFF),
(unsigned char)newId.Data4[0],
(unsigned char)newId.Data4[1],
(unsigned char)newId.Data4[2],
(unsigned char)newId.Data4[3],
(unsigned char)newId.Data4[4],
(unsigned char)newId.Data4[5],
(unsigned char)newId.Data4[6],
(unsigned char)newId.Data4[7]
};
return Guid{std::move(bytes)};
}
#endif
// android version that uses a call to a java api
#ifdef GUID_ANDROID
Guid newGuid(JNIEnv *env)
{
assert(env != androidInfo.env || std::this_thread::get_id() == androidInfo.initThreadId);
jobject javaUuid = env->CallStaticObjectMethod(
androidInfo.uuidClass, androidInfo.newGuidMethod);
jlong mostSignificant = env->CallLongMethod(javaUuid,
androidInfo.mostSignificantBitsMethod);
jlong leastSignificant = env->CallLongMethod(javaUuid,
androidInfo.leastSignificantBitsMethod);
std::array<unsigned char, 16> bytes =
{
(unsigned char)((mostSignificant >> 56) & 0xFF),
(unsigned char)((mostSignificant >> 48) & 0xFF),
(unsigned char)((mostSignificant >> 40) & 0xFF),
(unsigned char)((mostSignificant >> 32) & 0xFF),
(unsigned char)((mostSignificant >> 24) & 0xFF),
(unsigned char)((mostSignificant >> 16) & 0xFF),
(unsigned char)((mostSignificant >> 8) & 0xFF),
(unsigned char)((mostSignificant) & 0xFF),
(unsigned char)((leastSignificant >> 56) & 0xFF),
(unsigned char)((leastSignificant >> 48) & 0xFF),
(unsigned char)((leastSignificant >> 40) & 0xFF),
(unsigned char)((leastSignificant >> 32) & 0xFF),
(unsigned char)((leastSignificant >> 24) & 0xFF),
(unsigned char)((leastSignificant >> 16) & 0xFF),
(unsigned char)((leastSignificant >> 8) & 0xFF),
(unsigned char)((leastSignificant) & 0xFF)
};
env->DeleteLocalRef(javaUuid);
return Guid{std::move(bytes)};
}
Guid newGuid()
{
return newGuid(androidInfo.env);
}
#endif
END_XG_NAMESPACE
// Specialization for std::swap<Guid>() --
// call member swap function of lhs, passing rhs
namespace std
{
template <>
void swap(xg::Guid &lhs, xg::Guid &rhs) noexcept
{
lhs.swap(rhs);
}
}

150
src/xvaga01/guid.hpp Normal file
View File

@ -0,0 +1,150 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Graeme Hill (http://graemehill.ca)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once
#define GUID_WINDOWS
#ifdef GUID_ANDROID
#include <thread>
#include <jni.h>
#endif
#include <functional>
#include <iostream>
#include <array>
#include <sstream>
//#include <string_view>
#include <utility>
#include <iomanip>
#define BEGIN_XG_NAMESPACE namespace xg {
#define END_XG_NAMESPACE }
BEGIN_XG_NAMESPACE
// Class to represent a GUID/UUID. Each instance acts as a wrapper around a
// 16 byte value that can be passed around by value. It also supports
// conversion to string (via the stream operator <<) and conversion from a
// string via constructor.
class Guid
{
public:
explicit Guid(const std::array<unsigned char, 16> &bytes);
explicit Guid(std::array<unsigned char, 16> &&bytes);
// explicit Guid(std::string_view fromString);
Guid();
Guid(const Guid &other) = default;
Guid &operator=(const Guid &other) = default;
Guid(Guid &&other) = default;
Guid &operator=(Guid &&other) = default;
bool operator==(const Guid &other) const;
bool operator!=(const Guid &other) const;
std::string str() const;
operator std::string() const;
const std::array<unsigned char, 16>& bytes() const;
void swap(Guid &other);
bool isValid() const;
private:
void zeroify();
// actual data
std::array<unsigned char, 16> _bytes;
// make the << operator a friend so it can access _bytes
friend std::ostream &operator<<(std::ostream &s, const Guid &guid);
friend bool operator<(const Guid &lhs, const Guid &rhs);
};
Guid newGuid();
#ifdef GUID_ANDROID
struct AndroidGuidInfo
{
static AndroidGuidInfo fromJniEnv(JNIEnv *env);
JNIEnv *env;
jclass uuidClass;
jmethodID newGuidMethod;
jmethodID mostSignificantBitsMethod;
jmethodID leastSignificantBitsMethod;
std::thread::id initThreadId;
};
extern AndroidGuidInfo androidInfo;
void initJni(JNIEnv *env);
// overloading for multi-threaded calls
Guid newGuid(JNIEnv *env);
#endif
namespace details
{
template <typename...> struct hash;
template<typename T>
struct hash<T> : public std::hash<T>
{
using std::hash<T>::hash;
};
template <typename T, typename... Rest>
struct hash<T, Rest...>
{
inline std::size_t operator()(const T& v, const Rest&... rest) {
std::size_t seed = hash<Rest...>{}(rest...);
seed ^= hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed;
}
};
}
END_XG_NAMESPACE
namespace std
{
// Template specialization for std::swap<Guid>() --
// See guid.cpp for the function definition
template <>
void swap(xg::Guid &guid0, xg::Guid &guid1) noexcept;
// Specialization for std::hash<Guid> -- this implementation
// uses std::hash<std::string> on the stringification of the guid
// to calculate the hash
template <>
struct hash<xg::Guid>
{
std::size_t operator()(xg::Guid const &guid) const
{
const uint64_t* p = reinterpret_cast<const uint64_t*>(guid.bytes().data());
return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
}
};
}

75
src/xvaga01/hlapi_c.h Normal file
View File

@ -0,0 +1,75 @@
/* $Id: hlapi_c.h,v 1.2 2010-02-09 10:14:58 guy Exp $ */
#include "fastapi.h"
/* --------------------- */
/* Function prototypes : */
/* --------------------- */
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------ */
/* Basic Hardlock API */
/* ------------------ */
RET_ FAR_ CALL_ HL_LOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey);
RET_ FAR_ CALL_ HL_LOGOUT (void);
RET_ FAR_ CALL_ HL_AVAIL (void);
RET_ FAR_ CALL_ HL_PORTINF (void);
RET_ FAR_ CALL_ HL_ACCINF (void);
RET_ FAR_ CALL_ HL_USERINF (void);
RET_ FAR_ CALL_ HL_MAXUSER (void);
RET_ FAR_ CALL_ HL_MEMINF (void);
RET_ FAR_ CALL_ HL_CODE (void DATAFAR_ *Data, Word Count);
RET_ FAR_ CALL_ HL_WRITE (Word Reg, Word Value);
RET_ FAR_ CALL_ HL_READ (Word Reg, Word DATAFAR_ *Value);
RET_ FAR_ CALL_ HL_READBL (Byte DATAFAR_ *Eeprom);
RET_ FAR_ CALL_ HL_WRITEBL (Byte DATAFAR_ *Eeprom);
RET_ FAR_ CALL_ HL_ABORT (void);
RET_ FAR_ CALL_ HL_VERSION (void);
RET_ FAR_ CALL_ HL_HLSVERS (void);
RET_ FAR_ CALL_ HL_SELECT (HL_API DATAFAR_ *hl_ptr);
RET_ FAR_ CALL_ HL_READID (Word DATAFAR_ *IDLow, Word DATAFAR_ *IDHigh);
RET_ FAR_ CALL_ HL_SERVERLICENSES (Word DATAFAR_ *Value);
RET_ FAR_ CALL_ HL_SERVERADDR (char *text, Long *textsize);
/* ---------------- */
/* Hardlock RUS API */
/* ---------------- */
RET_ FAR_ CALL_ HLM_LOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey, Byte DATAFAR_ * VKey, Long RUSOptions, Byte DATAFAR_ * SearchStr);
RET_ FAR_ CALL_ HLM_OCCUPYSLOT (Long Slot);
RET_ FAR_ CALL_ HLM_FREESLOT (Long Slot);
RET_ FAR_ CALL_ HLM_CHECKSLOT (Long Slot, Long * MaxUser, Long * CurrentUser);
RET_ FAR_ CALL_ HLM_CHECKCOUNTER (Word IncVal, Long * MaxCounter, Long * CurrentCounter);
RET_ FAR_ CALL_ HLM_CHECKEXPDATE (Long Slot, Word * Year, Word * Month, Word * Day);
RET_ FAR_ CALL_ HLM_GETRUSINFO (Long * BufLen, Byte DATAFAR_ * RTBBuffer, Word Base64);
RET_ FAR_ CALL_ HLM_WRITELICENSE (Long BufLen, Byte DATAFAR_ * RTBBuffer, Word Access, Byte DATAFAR_ * SearchStr,Word Options);
RET_ FAR_ CALL_ HLM_ISRUSHL (Long * ID);
RET_ FAR_ CALL_ HLM_CHECKALLSLOTS (Long *BufLen, HL_LIS *Buffer);
RET_ FAR_ CALL_ HLM_LOGOUT (void);
/* ---------------------- */
/* Hardlock Error Routine */
/* ---------------------- */
const char * FAR_ CALL_ HL_ERRMSG (Word num, Long options, Byte ** errdefine, Byte ** errextmsg);
/* ------------------------------------------- */
/* Obsolete functions, for compatiblity only!! */
/* ------------------------------------------- */
#ifndef __OS2__
void FAR_ CALL_ HL_ON (Word Port, Word ModAd);
void FAR_ CALL_ HL_OFF (Word Port);
Word FAR_ CALL_ K_EYE (Word Port, char DATAFAR_ *Inp, Word BlkCnt);
void FAR_ CALL_ HL_WR (Word Port, Word Reg, Word Val);
Word FAR_ CALL_ HL_RD (Word Port, Word Reg);
void FAR_ CALL_ INT_ON (void);
void FAR_ CALL_ INT_OFF (void);
#endif
RET_ FAR_ CALL_ HL_CALC (Word i1, Word i2, Word i3, Word i4);
RET_ FAR_ CALL_ HL_LMLOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey, Word SlotID, Byte DATAFAR_ *SearchStr);
#ifdef __cplusplus
};
#endif
/* eof */

15
src/xvaga01/incstr.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <incstr.h>
istream & eatwhite(istream & i)
{
char c;
while (i.get(c))
{
if (!isspace(c))
{
i.putback(c);
break;
}
}
return i;
}

9
src/xvaga01/incstr.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef __INCSTR_H
#define __INCRSTR_H
#include <fstream>
#include <iostream>
#include <strstream>
using namespace std;
#endif

197
src/xvaga01/matche.cpp Normal file
View File

@ -0,0 +1,197 @@
#include <stdlib.h>
#include "matche.h"
// codici di ritorno della matche()
#define regexp_MATCH_PATTERN (6) // pattern non valido
#define regexp_MATCH_LITERAL (5) // il pattern non coincide su un carattere comune
#define regexp_MATCH_RANGE (4) // il pattern non coincide in un costrutto [..]
#define regexp_MATCH_ABORT (3) // il stringa da confrontare è terminata anticipatamente
#define regexp_MATCH_END (2) // il pattern è terminato anticipatamente
#define regexp_MATCH_VALID (1) // pattern e stringa coincidono
// codici di ritorno della is_valid_pattern()
#define regexp_PATTERN_VALID (0) // il pattern è valido
#define regexp_PATTERN_ESC (-1) // è presente un escape aperto a fine pattern
#define regexp_PATTERN_RANGE (-2) // c'è un range non chiuso all'interno di un costrutto [..]
#define regexp_PATTERN_CLOSE (-3) // manca la parentesi di chiusura in un costrutto [..]
#define regexp_PATTERN_EMPTY (-4) // c'è un costrutto vuoto
// prototipi delle funzioni interne
static int matche(const char *pat, const char *str); // ritorna un codice della classe regexp_MATCH che indica se e in che modo pattern e stringa coincidono
static int matche_after_star(const char *pat, const char *str); // chiama ricorsivamente la matche() con i segmenti puri del pattern e della stringa
static bool is_pattern(const char *pat); // ritorna true se la stringa è un pattern
static bool is_valid_pattern(const char *pat, int *err= NULL); // ritorna true se la stringa è un pattern valido, indica un codice di ritorno della classe regexp_PATTERN nel secondo parametro
static bool is_pattern(const char *p) {
while (*p) {
switch (*p++) {
case '?':
case '*':
case '[':
case '\\':
return true;
}
}
return false;
}
static bool is_valid_pattern(const char *p, int *error_type) {
if (error_type != NULL) *error_type= regexp_PATTERN_VALID; // inizializzazione del tipo d'errore
while (*p) { // ciclo all'interno del pattern fino a fine stringa
switch(*p) { // determinazione del tipo di wild card nel pattern
case '\\': // controllo dell'escape, non può essere a fine pattern
if (!*++p) {
if (error_type != NULL) *error_type= regexp_PATTERN_ESC;
return false;
}
p++;
break;
case '[': // controllo della costruzione del costrutto [..]
p++;
if (*p == ']') { // se il prossimo carattere è ']' il costrutto è vuoto
if (error_type != NULL) *error_type= regexp_PATTERN_EMPTY;
return false;
}
if (!*p) { // se si è a fine stringa il costrutto non è chiuso
if (error_type != NULL) *error_type= regexp_PATTERN_CLOSE;
return false;
}
while (*p != ']') { // ciclo fino a fine costrutto [..]
if (*p == '\\') { // controllo per gli escape
p++;
if (!*p++) { // controllo che l'escape non sia a fine pattern
if (error_type != NULL) *error_type= regexp_PATTERN_ESC;
return false;
}
} else p++;
if (!*p) { // se si è a fine stringa il costrutto non è chiuso
if (error_type != NULL) *error_type= regexp_PATTERN_CLOSE;
return false;
}
if (*p == '-') { // controllo di un eventuale range
if (!*++p || *p == ']') { // deve esistere una fine del range
if (error_type != NULL) *error_type= regexp_PATTERN_RANGE;
return false;
} else {
if (*p == '\\') p++; // controllo degli escape
if (!*p++) { // controllo che l'escape non sia a fine pattern
if (error_type != NULL) *error_type= regexp_PATTERN_ESC;
return false;
}
}
}
}
break;
case '*': // tutti gli altri caratteri sono elementi validi del pattern
case '?':
default:
p++; // caratteri normali
break;
}
}
return true;
}
static int matche_after_star(const char *p, const char *t) {
int match= 0;
while (*p == '?' || *p == '*') { // salto degli eventuali '*' e '?'
if (*p == '?') // salto di un carattere per ciascun '?'
if (!*t++) return regexp_MATCH_ABORT; // se la stringa termina qui non c'è coincidenza
p++; // posizionamento sul prossimo carattere del pattern
}
if (!*p) return regexp_MATCH_VALID; //se il pattern è concluso c'è coincidenza
int nextp= *p; // prelevamento del prossimo carattere, normale o '['
if (nextp == '\\') {
nextp= p[1];
if (!nextp) return regexp_MATCH_PATTERN; // se il pattern termina qui non è valido
}
do { // ciclo fino a conclusione di stringa o pattern
if (nextp == *t || nextp == '[') match= matche(p, t); // è necessario che il carattere corrente del testo coincida con il carattere corrente del pattern, oppure che il pattern abbia un inizio di costrutto [..]
if (!*t++) match= regexp_MATCH_ABORT; // se la stringa termina qui non c'è coincidenza
} while (match != regexp_MATCH_VALID && match != regexp_MATCH_ABORT && match != regexp_MATCH_PATTERN);
return match; // ritorno del risultato
}
static int matche(const char *p, const char *t) {
for (; *p; p++, t++) {
if (!*t) // se si è alla fine della stringa, il confronto è concluso
return (*p == '*' && *++p == '\0') ? regexp_MATCH_VALID : regexp_MATCH_ABORT;
switch (*p) { // determina il tipo di wild card del pattern
case '?': // carattere singolo, qualunque carattere coincide
break;
case '*': // sottostringa, coincide qualunque sequenza di caratteri
return matche_after_star (p, t);
case '[': { // costrutto [..], controllo di coincidenza per inclusione o esclusione su un solo carattere
p++; // posizionamento all'inizio del range
bool invert= false; // controllo di inclusione o esclusione del costrutto
if (*p == '!' || *p == '^') {
invert= true;
p++;
}
if (*p == ']') // se si è su una chiusura di costrutto il pattern non è valido
return regexp_MATCH_PATTERN;
bool member_match= false;
bool loop= true;
while (loop) {
char range_start, range_end; // inizio e fine del range corrente
if (*p == ']') { // se si è alla fine del costrutto il ciclo si conclude
loop= false;
continue;
}
if (*p == '\\') // controllo di coincidenza su un metacarattere, dopo un escape
range_start= range_end= *++p;
else
range_start= range_end= *p;
if (!*p) return regexp_MATCH_PATTERN; // se il pattern termina non è valido
if (*++p == '-') { // controllo del segno di sottoinsieme
range_end= *++p; // impostazione della fine del range
if (range_end == '\0' || range_end == ']') return regexp_MATCH_PATTERN; // se il costrutto [..] o il pattern terminano qui allora il pattern non è valido
if (range_end == '\\') { // la fine del range è un metacarattere
range_end= *++p;
if (!range_end) return regexp_MATCH_PATTERN; // se il pattern termina non è valido
}
p++; // posizionamento oltre il range
}
if (range_start < range_end) { // confronto del carattere corrente con il costrutto, controllo della sequenzialità degli estremi del range
if (*t >= range_start && *t <= range_end) {
member_match= true;
loop= false;
}
} else {
if (*t >= range_end && *t <= range_start) {
member_match= true;
loop= false;
}
}
}
if ((invert && member_match) || !(invert || member_match)) // controllo del risultato dell'ultimo confronto nel costrutto [..]
return regexp_MATCH_RANGE;
if (member_match) { // salto del resto del costrutto se non è esclusivo
while (*p != ']') {
if (!*p) return regexp_MATCH_PATTERN; // se si è a fine pattern il costrutto non è valido
if (*p == '\\') { // salto di un confronto con un metacarattere
p++;
if (!*p) return regexp_MATCH_PATTERN; // se il pattern termina qui non è valido
}
p++; // posizionamento sul prossimo carattere del pattern
}
}
break;
}
case '\\': // confronto con un metacarattere
p++; // posizionamento sul carattere da confrontare
if (!*p) return regexp_MATCH_PATTERN; // se il pattern termina qui non è valido
default: // confronto con un carattere normale
if (*p != *t) return regexp_MATCH_LITERAL;
}
}
if (*t) return regexp_MATCH_END; // se la stringa non è conclusa non c'è coincidenza
else return regexp_MATCH_VALID;
}
bool match(const char *pat, const char *str)
{
const int err = matche(pat, str);
return (err == regexp_MATCH_VALID); // ritorna true se il pattern e la stringa coincidono
}

1
src/xvaga01/matche.h Normal file
View File

@ -0,0 +1 @@
bool match(const char *pat, const char *str);

386
src/xvaga01/oslinux.cpp Normal file
View File

@ -0,0 +1,386 @@
#include "wxinc.h"
#include "wx/print.h"
#include "wx/printdlg.h"
#include "xvt.h"
#include "oslinux.h"
#include "xvt_menu.h"
#include "xvt_help.h"
#include "xvintern.h"
#include <wx/fontenum.h>
#include <wx/string.h>
#include <wx/snglinst.h>
#include <wx/utils.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <mntent.h>
#include <sys/vfs.h>
#include <unistd.h>
wxString OsLinux_File2App(const char* filename)
{
wxString app;
SORRY_BOX();
return app;
}
int OsLinux_EnumerateFamilies(char** families, int max_count)
{
wxFontEnumerator ef;
ef.EnumerateFacenames();
wxArrayString * fonts = ef.GetFacenames();
size_t items = fonts->GetCount();
size_t i;
for (i = 0; i < items; i++)
families[i] = xvt_str_duplicate((*fonts)[i].c_str());
return items;
}
int OsLinux_EnumerateSizes(const char* name, long* sizes, short* scalable, int max_count)
{
int i = 0;
*scalable = 1;
for (int size = 4; size < 80; size++)
sizes[i++] = size;
return i;
}
void OsLinux_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent)
{
SORRY_BOX();
}
void OsLinux_UpdateWindow(unsigned int handle)
{
// non deve fare nulla in Linux, sembra di si verificare SORRY_BOX();
}
void OsLinux_Set_FileTime(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime)
{
}
///////////////////////////////////////////////////////////
// Hardlock Support
///////////////////////////////////////////////////////////
#include "hlapi_c.h"
bool OsLinux_HL_Login(unsigned short address, const unsigned char* label, const unsigned char* password)
{
int err = HL_LOGIN(address, LOCAL_DEVICE, (unsigned char*)label, (unsigned char*)password);
return err == STATUS_OK;
}
bool OsLinux_HL_Logout()
{
HL_LOGOUT();
return TRUE;
}
bool OsLinux_HL_Read(unsigned short reg, unsigned short* data)
{
int err = HL_READ(reg, data);
return err == STATUS_OK;
}
bool OsLinux_HL_ReadBlock(unsigned char* data)
{
int err = HL_READBL(data);
return err == STATUS_OK;
}
bool OsLinux_HL_Write(unsigned short reg, unsigned short data)
{
int err = HL_WRITE(reg, data);
return err == STATUS_OK;
}
bool OsLinux_HL_Crypt(unsigned short* data) // Array di 4 words (8 bytes)
{
int err = HL_CODE(data, 1);
return err == STATUS_OK;
}
///////////////////////////////////////////////////////////
// Eutron Smartlink Support
///////////////////////////////////////////////////////////
#include "skeylinux.h"
static SKEY_DATA skey;
bool OsLinux_SL_Crypt(unsigned short* data)
{
skey.command = SCRAMBLING_MODE;
memset(skey.data, 0, sizeof(skey.data));
memcpy(skey.data, data, 8);
clink(&skey);
const bool ok = (skey.status == ST_OK);
if (ok)
memcpy(data, skey.data, 8);
return ok;
}
bool OsLinux_SL_Login(const unsigned char* label, const unsigned char* password)
{
memset(&skey, 0, sizeof(SKEY_DATA));
skey.command = LOCATING_MODE;
skey.status = ST_HW_FAILURE; // Don't leave ST_OK = 0 here!
memcpy(skey.label, label, strlen((const char*)label));
memcpy(skey.password, password, strlen((const char*)password));
clink(&skey);
return skey.status == ST_OK;
}
bool OsLinux_SL_Logout()
{
skey.command = 0;
clink(&skey);
return true;
}
bool OsLinux_SL_ReadBlock(unsigned short reg, unsigned short size, unsigned short* data)
{
skey.command = BLOCK_READING_MODE;
unsigned short* pointer = (unsigned short*)(&skey.data[0]);
unsigned short* number = (unsigned short*)(&skey.data[2]);
*pointer = reg;
*number = size;
clink(&skey);
const bool ok = skey.status == ST_OK;
if (ok)
memcpy(data, &skey.data[4], size*sizeof(unsigned short));
return ok;
}
bool OsLinux_SL_WriteBlock(unsigned short reg, unsigned short size, const unsigned short* data)
{
skey.command = BLOCK_WRITING_MODE;
unsigned short* pointer = (unsigned short*)(&skey.data[0]);
unsigned short* number = (unsigned short*)(&skey.data[2]);
*pointer = reg;
*number = size;
memcpy(&skey.data[4], data, size*sizeof(unsigned short));
clink(&skey);
return skey.status == ST_OK;
}
void OsLinux_GetFileSys(const char* path, char * dev, char * dir, char * type)
{
struct mntent *m;
FILE *f = setmntent("/etc/mnttab", "r");
while ((m = getmntent(f)) && strncmp(path, m->mnt_dir, strlen(m->mnt_dir)) != 0);
if (m)
{
if (dev) strcpy(dev, m->mnt_fsname);
if (dir) strcpy(dir, m->mnt_dir);
if (type) strcpy(type, m->mnt_type);
}
else
{
if (dev) *dev = '\0';
if (dir) *dir = '\0';
if (type) *type = '\0';
}
endmntent(f);
}
bool OsLinux_IsNetworkDrive(const char * path)
{
struct statfs buf;
if (statfs(path, &buf) == -1)
return FALSE;
return (buf.f_type == 0x6969 /*NFS_SUPER_MAGIC */) ||
(buf.f_type == 0x517B /*SMB_SUPER_MAGIC)*/);
}
int64_t OsLinux_GetDiskFreeSpace(const char * path)
{
struct statfs buf;
int64_t nBytes = 0L;
if (statfs(path, &buf) != -1)
{
nBytes = buf.f_bsize;
nBytes *= buf.f_bavail;
nBytes *= 1024;
}
return nBytes;
}
#include "wx/settings.h"
#include "X11/Xutil.h"
#ifndef MWM_DECOR_BORDER
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3)
#define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
#define MWM_DECOR_RESIZEH (1L << 2)
#define MWM_DECOR_TITLE (1L << 3)
#define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6)
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MOVE (1L << 2)
#define MWM_FUNC_MINIMIZE (1L << 3)
#define MWM_FUNC_MAXIMIZE (1L << 4)
#define MWM_FUNC_CLOSE (1L << 5)
#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
#define MWM_TEAROFF_WINDOW (1L<<0)
#endif
struct MwmHints {
long flags;
long functions;
long decorations;
long input_mode;
};
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
// Set the window manager decorations according to the
// given wxWindows style
bool wxSetWMDecorations(Window w, long style)
{
Atom mwm_wm_hints = XInternAtom((Display * )wxGetDisplay(),"_MOTIF_WM_HINTS", False);
if (mwm_wm_hints == 0)
return FALSE;
MwmHints hints;
hints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
hints.decorations = 0;
hints.functions = 0;
// if ((style & wxSIMPLE_BORDER) || (style & wxNO_BORDER))
if (style & wxNO_BORDER)
{
// leave zeros
}
else
{
hints.decorations = MWM_DECOR_BORDER;
hints.functions = MWM_FUNC_MOVE | MWM_FUNC_CLOSE;
if ((style & wxCAPTION) != 0)
hints.decorations |= MWM_DECOR_TITLE;
if ((style & wxSYSTEM_MENU) != 0)
{
hints.decorations |= MWM_DECOR_MENU;
}
if ((style & wxMINIMIZE_BOX) != 0)
{
hints.functions |= MWM_FUNC_MINIMIZE;
hints.decorations |= MWM_DECOR_MINIMIZE;
}
if ((style & wxMAXIMIZE_BOX) != 0)
{
hints.functions |= MWM_FUNC_MAXIMIZE;
hints.decorations |= MWM_DECOR_MAXIMIZE;
}
if ((style & wxRESIZE_BORDER) != 0)
{
hints.functions |= MWM_FUNC_RESIZE;
hints.decorations |= MWM_DECOR_RESIZEH;
}
}
XChangeProperty((Display *) wxGetDisplay(), w, mwm_wm_hints, mwm_wm_hints, 32, PropModeReplace,
(unsigned char *) &hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
return TRUE;
}
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
void OsLinux_SetCaptionStyle(wxWindow * w, long style)
{
wxSetWMDecorations(GDK_WINDOW_XID(w->m_widget->window), style);
}
int OsLinux_GetSessionId()
{
char s[256];
wxStrncpy(s, wxGetEnv("DISPLAY"), sizeof(s));
char* p = strchr(s, ':');
if (p == NULL)
p = s;
else
p++;
char * e = strchr(p, '.');
if (e != NULL)
*e = '\0';
return atoi(p);
}
bool OsLinux_IsdTaskbarVisible()
{
return true;
}
unsigned long OsLinux_GetDriveSerialNumber(char * path)
{
unsigned long SerialNumber = 0L;
char buf[256];
char dev[256];
char dir[256];
char type[256];
OsLinux_GetFileSys(path, dev, dir, type);
if (*dev)
{
len = readlink(dev, buf, 256);
buf[len] = 0;
sprintf(buf2, "%s/%s", "/sys/block/", buf);
for (i = 0; i < 6; i++) {
p = strrchr(buf2, '/');
*p = 0;
}
strcat(buf2, "/serial");
int f = open(buf2, 0);
len = read(f, buf, 256);
if (len <= 0) {
perror("read()");
}
buf[len] = 0;
len = 0;
for (const char * s = buf; *s, ; s++)
{
if (isdigit(s))
dev[i++] = *s;
}
dev[i] = '\0';
SerialNumber = atol(dev);
}
return (long)SerialNumber;
}

30
src/xvaga01/oslinux.h Normal file
View File

@ -0,0 +1,30 @@
wxString OsLinux_File2App(const char* filename);
int OsLinux_EnumerateFamilies(char** families, int max_count);
int OsLinux_EnumerateSizes(const char* name, long* sizes, short* scalable, int max_count);
void OsLinux_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent);
void OsLinux_UpdateWindow(unsigned int handle);
void OsLinux_Set_FileTime(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime);
bool OsLinux_HL_Crypt(unsigned short* data);
bool OsLinux_HL_Login(unsigned short address, const unsigned char* label, const unsigned char* password);
bool OsLinux_HL_Logout() ;
bool OsLinux_HL_Read(unsigned short reg, unsigned short* data);
bool OsLinux_HL_ReadBlock(unsigned char* data);
bool OsLinux_HL_Write(unsigned short reg, unsigned short data);
bool OsLinux_SL_Crypt(unsigned short* data);
bool OsLinux_SL_Login(const unsigned char* label, const unsigned char* password);
bool OsLinux_SL_Logout() ;
bool OsLinux_SL_ReadBlock(unsigned short reg, unsigned short size, unsigned short* data);
bool OsLinux_SL_WriteBlock(unsigned short reg, unsigned short size, const unsigned short* data);
void OsLinux_GetFileSys(const char* path, char * dev, char * dir, char * type);
bool OsLinux_IsNetworkDrive(const char * path);
int64_t OsLinux_GetDiskFreeSpace(const char * path);
void OsLinux_SetCaptionStyle(wxWindow * w, long style);
int OsLinux_GetSessionId();
bool OsLinux_IsdTaskbarVisible();
unsigned long OsLinux_GetDriveSerialNumber(char * path);

1474
src/xvaga01/oswin32.cpp Normal file

File diff suppressed because it is too large Load Diff

55
src/xvaga01/oswin32.h Normal file
View File

@ -0,0 +1,55 @@
void OsWin32_Beep(int severity);
const char * OsWin32_CommandLine();
bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size);
void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal, unsigned int& nSize);
void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nSize);
HBITMAP OsWin32_CreateBitmap(const wxImage& img, wxDC& dc);
bool OsWin32_DrawBitmap(HBITMAP hBMP, wxDC& dc, const wxRect& dst, const wxRect& src);
void OsWin32_DrawDottedRect(WXHDC hDC, int left, int top, int right, int bottom);
wxString OsWin32_File2App(const char* filename);
bool OsWin32_GotoUrl(const char* url, const char* action);
wxIcon OsWin32_LoadIcon(const char* file);
void OsWin32_Set_FileTime(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime);
int OsWin32_EnumerateFamilies(WXHDC hDC, char** families, int max_count);
int OsWin32_EnumerateSizes(WXHDC hDC, const char* name, long* sizes, short* scalable, int max_count);
void OsWin32_SetCaptionStyle(WXHWND handle, long style);
void* OsWin32_GetPrinterInfo(int& size, const char* printer);
WXHINSTANCE OsWin32_ProcessModule(const char* name);
void OsWin32_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent);
unsigned int OsWin32_FindMenuContainer();
long OsWin32_GetChildrenCount(unsigned int parent);
long OsWin32_CloseChildren(unsigned int parent);
void OsWin32_CloseSiblings(unsigned int parent);
void OsWin32_UpdateWindow(unsigned int handle);
void OsWin32_NumberFormat(char* str, int size);
int OsWin32_Help(WXHWND handle, const char* hlp, unsigned int cmd, const char* topic);
int OsWin32_GetSessionId();
bool OsWin32_IsWindowsServer();
WXHWND OsWin32_ProgressCreate(WXHWND hwndOwner, const char* strTtle, long nTotal, bool bCanCancel);
void OsWin32_ProgressDestroy(WXHWND hProgDlg);
bool OsWin32_ProgressSetStatus(WXHWND hProgDlg, long nCurrent, long nTotal);
void OsWin32_ProgressSetText(WXHWND hProgDlg, const char* msg);
bool OsWin32_IsdTaskbarVisible();
long OsWin32_get_MAC_adresses(char * addresses);
wxString OsWin32_get_disk_root(const char* path);
unsigned long OsWin32_GetDriveSerialNumber(char * path);
int OsWin32_TaskList(const char ** list);
//#define SPEECH_API 1
#ifdef SPEECH_API
bool OsWin32_InitializeSpeech();
bool OsWin32_Speak(const char* text, bool async);
void OsWin32_DeinitializeSpeech();
#endif

523
src/xvaga01/smapi.cpp Normal file
View File

@ -0,0 +1,523 @@
/////////////////////////////////////////////////////////////////////////////
// Name: smapi.cpp
// Purpose: Simple MAPI classes
// Author: PJ Naughter <pjna@naughter.com>
// Modified by: Julian Smart
// Created: 2001-08-21
// RCS-ID: $Id: smapi.cpp,v 1.5 2010-04-22 15:26:15 guy Exp $
// Copyright: (c) PJ Naughter
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wxinc.h"
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifdef __WXMSW__
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/string.h"
#include "wx/msw/private.h"
// mapi.h in Cygwin's include directory isn't a full implementation and is
// not sufficient for this lib. However recent versions of Cygwin also
// have another mapi.h in include/w32api which can be used.
//
#ifdef __CYGWIN__
#include <w32api/mapi.h>
#else
#include <mapi.h>
#endif
#include "smapi.h"
class wxMapiData
{
public:
wxMapiData()
{
m_hSession = 0;
m_nLastError = 0;
m_hMapi = NULL;
m_lpfnMAPILogon = NULL;
m_lpfnMAPILogoff = NULL;
m_lpfnMAPISendMail = NULL;
m_lpfnMAPIResolveName = NULL;
m_lpfnMAPIFreeBuffer = NULL;
}
//Data
LHANDLE m_hSession; //Mapi Session handle
long m_nLastError; //Last Mapi error value
HINSTANCE m_hMapi; //Instance handle of the MAPI dll
LPMAPILOGON m_lpfnMAPILogon; //MAPILogon function pointer
LPMAPILOGOFF m_lpfnMAPILogoff; //MAPILogoff function pointer
LPMAPISENDMAIL m_lpfnMAPISendMail; //MAPISendMail function pointer
LPMAPIRESOLVENAME m_lpfnMAPIResolveName; //MAPIResolveName function pointer
LPMAPIFREEBUFFER m_lpfnMAPIFreeBuffer; //MAPIFreeBuffer function pointer
};
////////////////////////////////// Implementation /////////////////////////////
wxMapiSession::wxMapiSession()
{
m_data = new wxMapiData;
Initialise();
}
wxMapiSession::~wxMapiSession()
{
//Logoff if logged on
Logoff();
//Unload the MAPI dll
Deinitialise();
delete m_data;
}
void wxMapiSession::Initialise()
{
//First make sure the "WIN.INI" entry for MAPI is present aswell
//as the MAPI32 dll being present on the system
bool bMapiInstalled = (::GetProfileInt(_T("MAIL"), _T("MAPI"), 0) != 0) &&
(SearchPath(NULL, _T("MAPI32.DLL"), NULL, 0, NULL, NULL) != 0);
if (bMapiInstalled)
{
//Load up the MAPI dll and get the function pointers we are interested in
m_data->m_hMapi = ::LoadLibrary(_T("MAPI32.DLL"));
if (m_data->m_hMapi)
{
m_data->m_lpfnMAPILogon = (LPMAPILOGON) GetProcAddress(m_data->m_hMapi, "MAPILogon");
m_data->m_lpfnMAPILogoff = (LPMAPILOGOFF) GetProcAddress(m_data->m_hMapi, "MAPILogoff");
m_data->m_lpfnMAPISendMail = (LPMAPISENDMAIL) GetProcAddress(m_data->m_hMapi, "MAPISendMail");
m_data->m_lpfnMAPIResolveName = (LPMAPIRESOLVENAME) GetProcAddress(m_data->m_hMapi, "MAPIResolveName");
m_data->m_lpfnMAPIFreeBuffer = (LPMAPIFREEBUFFER) GetProcAddress(m_data->m_hMapi, "MAPIFreeBuffer");
//If any of the functions are not installed then fail the load
if (m_data->m_lpfnMAPILogon == NULL ||
m_data->m_lpfnMAPILogoff == NULL ||
m_data->m_lpfnMAPISendMail == NULL ||
m_data->m_lpfnMAPIResolveName == NULL ||
m_data->m_lpfnMAPIFreeBuffer == NULL)
{
wxLogDebug(_T("Failed to get one of the functions pointer in MAPI32.DLL\n"));
Deinitialise();
}
}
}
else
{
wxMessageBox("Mapi is not installed on this computer", "MAPIInitialise", wxOK|wxCENTRE|wxICON_ERROR);
}
}
void wxMapiSession::Deinitialise()
{
if (m_data->m_hMapi)
{
//Unload the MAPI dll and reset the function pointers to NULL
FreeLibrary(m_data->m_hMapi);
m_data->m_hMapi = NULL;
m_data->m_lpfnMAPILogon = NULL;
m_data->m_lpfnMAPILogoff = NULL;
m_data->m_lpfnMAPISendMail = NULL;
m_data->m_lpfnMAPIResolveName = NULL;
m_data->m_lpfnMAPIFreeBuffer = NULL;
}
}
bool wxMapiSession::Logon(const wxString& sProfileName, const wxString& sPassword, wxWindow* pParentWnd)
{
wxASSERT(MapiInstalled()); //MAPI must be installed
wxASSERT(m_data->m_lpfnMAPILogon); //Function pointer must be valid
//Initialise the function return value
bool bSuccess = FALSE;
//Just in case we are already logged in
Logoff();
//Setup the ascii versions of the profile name and password
int nProfileLength = sProfileName.Length();
LPSTR pszProfileName = NULL;
LPSTR pszPassword = NULL;
wxCharBuffer cbProfile(1),cbPassword(1);
if (nProfileLength)
{
#ifndef UNICODE
pszProfileName = (LPSTR) sProfileName.c_str();
pszPassword = (LPSTR) sPassword.c_str();
#else
cbProfile = sProfileName.mb_str();
cbPassword = sPassword.mb_str();
pszProfileName = cbProfile.data();
pszPassword = cbPassword.data();
#endif
}
//Setup the flags & UIParam parameters used in the MapiLogon call
FLAGS flags = 0;
ULONG nUIParam = 0;
if (nProfileLength == 0)
{
//No profile name given, then we must interactively request a profile name
if (pParentWnd)
{
nUIParam = (ULONG) (HWND) pParentWnd->GetHWND();
flags |= MAPI_LOGON_UI;
}
else
{
//No window given, just use the main window of the app as the parent window
if (wxTheApp->GetTopWindow())
{
nUIParam = (ULONG) (HWND) wxTheApp->GetTopWindow()->GetHWND();
flags |= MAPI_LOGON_UI;
}
}
}
//First try to acquire a new MAPI session using the supplied settings using the MAPILogon functio
ULONG nError = m_data->m_lpfnMAPILogon(nUIParam, pszProfileName, pszPassword, flags | MAPI_NEW_SESSION, 0, &m_data->m_hSession);
if (nError != SUCCESS_SUCCESS && nError != MAPI_E_USER_ABORT)
{
//Failed to create a create mapi session, try to acquire a shared mapi session
wxLogDebug(_T("Failed to logon to MAPI using a new session, trying to acquire a shared one\n"));
nError = m_data->m_lpfnMAPILogon(nUIParam, NULL, NULL, 0, 0, &m_data->m_hSession);
if (nError == SUCCESS_SUCCESS)
{
m_data->m_nLastError = SUCCESS_SUCCESS;
bSuccess = TRUE;
}
else
{
wxLogDebug(_T("Failed to logon to MAPI using a shared session, Error:%ld\n"), nError);
m_data->m_nLastError = nError;
}
}
else if (nError == SUCCESS_SUCCESS)
{
m_data->m_nLastError = SUCCESS_SUCCESS;
bSuccess = TRUE;
}
return bSuccess;
}
bool wxMapiSession::LoggedOn() const
{
return (m_data->m_hSession != 0);
}
bool wxMapiSession::MapiInstalled() const
{
return (m_data->m_hMapi != NULL);
}
bool wxMapiSession::Logoff()
{
wxASSERT(MapiInstalled()); //MAPI must be installed
wxASSERT(m_data->m_lpfnMAPILogoff); //Function pointer must be valid
//Initialise the function return value
bool bSuccess = FALSE;
if (m_data->m_hSession)
{
//Call the MAPILogoff function
ULONG nError = m_data->m_lpfnMAPILogoff(m_data->m_hSession, 0, 0, 0);
if (nError != SUCCESS_SUCCESS)
{
wxLogDebug(_T("Failed in call to MapiLogoff, Error:%ld"), nError);
m_data->m_nLastError = nError;
bSuccess = TRUE;
}
else
{
m_data->m_nLastError = SUCCESS_SUCCESS;
bSuccess = TRUE;
}
m_data->m_hSession = 0;
}
return bSuccess;
}
bool wxMapiSession::Resolve(const wxString& sName, void* lppRecip1)
{
lpMapiRecipDesc* lppRecip = (lpMapiRecipDesc*) lppRecip1;
wxASSERT(MapiInstalled()); //MAPI must be installed
wxASSERT(m_data->m_lpfnMAPIResolveName); //Function pointer must be valid
wxASSERT(LoggedOn()); //Must be logged on to MAPI
wxASSERT(m_data->m_hSession); //MAPI session handle must be valid
//Call the MAPIResolveName function
#ifndef UNICODE
LPSTR lpszAsciiName = (LPSTR) sName.c_str();
#else
wxCharBuffer cbName(1);
cbName = sName.mb_str();
LPSTR lpszAsciiName = cbName.data();
#endif
ULONG nError = m_data->m_lpfnMAPIResolveName(m_data->m_hSession, 0, lpszAsciiName, 0, 0, lppRecip);
if (nError != SUCCESS_SUCCESS)
{
wxLogDebug(_T("Failed to resolve the name: %s, Error:%ld\n"),
sName.c_str(), nError);
m_data->m_nLastError = nError;
}
return (nError == SUCCESS_SUCCESS);
}
bool wxMapiSession::Send(wxMailMessage& message, bool show_ui)
{
wxASSERT(MapiInstalled()); //MAPI must be installed
wxASSERT(m_data->m_lpfnMAPISendMail); //Function pointer must be valid
wxASSERT(m_data->m_lpfnMAPIFreeBuffer); //Function pointer must be valid
wxASSERT(LoggedOn()); //Must be logged on to MAPI
wxASSERT(m_data->m_hSession); //MAPI session handle must be valid
//Initialise the function return value
bool bSuccess = FALSE;
//Create the MapiMessage structure to match the message parameter send into us
MapiMessage mapiMessage;
ZeroMemory(&mapiMessage, sizeof(mapiMessage));
#ifndef UNICODE
mapiMessage.lpszSubject = (LPSTR) message.m_subject.c_str();
mapiMessage.lpszNoteText = (LPSTR) message.m_body.c_str();
#else
wxCharBuffer cbSubject(1),cbBody(1),cbOriginator(1);
cbSubject = message.m_subject.mb_str();
cbBody = message.m_body.mb_str();
mapiMessage.lpszSubject = cbSubject.data();
mapiMessage.lpszNoteText = cbBody.data();
#endif
mapiMessage.nRecipCount = message.m_to.GetCount() + message.m_cc.GetCount() + message.m_bcc.GetCount();
wxASSERT(mapiMessage.nRecipCount); //Must have at least 1 recipient!
//Allocate the recipients array
mapiMessage.lpRecips = new MapiRecipDesc[mapiMessage.nRecipCount];
// If we have a 'From' field, use it
if (!message.m_from.IsEmpty())
{
mapiMessage.lpOriginator = new MapiRecipDesc;
ZeroMemory(mapiMessage.lpOriginator, sizeof(MapiRecipDesc));
mapiMessage.lpOriginator->ulRecipClass = MAPI_ORIG;
// TODO Do we have to call Resolve?
#ifndef UNICODE
mapiMessage.lpOriginator->lpszName = (LPSTR) message.m_from.c_str();
#else
cbOriginator = message.m_from.mb_str();
mapiMessage.lpOriginator->lpszName = cbOriginator.data();
#endif
}
//Setup the "To" recipients
int nRecipIndex = 0;
int nToSize = message.m_to.GetCount();
int i;
for (i=0; i<nToSize; i++)
{
MapiRecipDesc& recip = mapiMessage.lpRecips[nRecipIndex];
ZeroMemory(&recip, sizeof(MapiRecipDesc));
recip.ulRecipClass = MAPI_TO;
wxString& sName = message.m_to[i];
//Try to resolve the name
lpMapiRecipDesc lpTempRecip;
if (Resolve(sName, (void*) &lpTempRecip))
{
//Resolve worked, put the resolved name back into the sName
sName = wxString(lpTempRecip->lpszName,*wxConvCurrent);
//Don't forget to free up the memory MAPI allocated for us
m_data->m_lpfnMAPIFreeBuffer(lpTempRecip);
}
#ifndef UNICODE
recip.lpszName = (LPSTR) sName.c_str();
#else
recip.lpszName = sName.mb_str().release();
#endif
++nRecipIndex;
}
//Setup the "CC" recipients
int nCCSize = message.m_cc.GetCount();
for (i=0; i<nCCSize; i++)
{
MapiRecipDesc& recip = mapiMessage.lpRecips[nRecipIndex];
ZeroMemory(&recip, sizeof(MapiRecipDesc));
recip.ulRecipClass = MAPI_CC;
wxString& sName = message.m_cc[i];
//Try to resolve the name
lpMapiRecipDesc lpTempRecip;
if (Resolve(sName, (void*) &lpTempRecip))
{
//Resolve worked, put the resolved name back into the sName
sName = wxString(lpTempRecip->lpszName,*wxConvCurrent);
//Don't forget to free up the memory MAPI allocated for us
m_data->m_lpfnMAPIFreeBuffer(lpTempRecip);
}
#ifndef UNICODE
recip.lpszName = (LPSTR) sName.c_str();
#else
recip.lpszName = sName.mb_str().release();
#endif
++nRecipIndex;
}
//Setup the "BCC" recipients
int nBCCSize = message.m_bcc.GetCount();
for (i=0; i<nBCCSize; i++)
{
MapiRecipDesc& recip = mapiMessage.lpRecips[nRecipIndex];
ZeroMemory(&recip, sizeof(MapiRecipDesc));
recip.ulRecipClass = MAPI_BCC;
wxString& sName = message.m_bcc[i];
//Try to resolve the name
lpMapiRecipDesc lpTempRecip;
if (Resolve(sName, (void*) &lpTempRecip))
{
//Resolve worked, put the resolved name back into the sName
sName = wxString(lpTempRecip->lpszName,wxConvCurrent);
//Don't forget to free up the memory MAPI allocated for us
m_data->m_lpfnMAPIFreeBuffer(lpTempRecip);
}
#ifndef UNICODE
recip.lpszName = (LPSTR) sName.c_str();
#else
recip.lpszName = sName.mb_str().release();
#endif
++nRecipIndex;
}
//Setup the attachments
int nAttachmentSize = message.m_attachments.GetCount();
int nTitleSize = message.m_attachmentTitles.GetCount();
if (nTitleSize)
{
wxASSERT(nTitleSize == nAttachmentSize); //If you are going to set the attachment titles then you must set
//the attachment title for each attachment
}
if (nAttachmentSize)
{
mapiMessage.nFileCount = nAttachmentSize;
mapiMessage.lpFiles = new MapiFileDesc[nAttachmentSize];
for (i=0; i<nAttachmentSize; i++)
{
MapiFileDesc& file = mapiMessage.lpFiles[i];
ZeroMemory(&file, sizeof(MapiFileDesc));
file.nPosition = 0xFFFFFFFF;
wxString& sFilename = message.m_attachments[i];
#ifndef UNICODE
file.lpszPathName = (LPSTR) sFilename.c_str();
#else
file.lpszPathName = sFilename.mb_str().release();
#endif
//file.lpszFileName = file.lpszPathName;
file.lpszFileName = NULL;
if (nTitleSize && !message.m_attachmentTitles[i].IsEmpty())
{
wxString& sTitle = message.m_attachmentTitles[i];
#ifndef UNICODE
file.lpszFileName = (LPSTR) sTitle.c_str();
#else
file.lpszFileName = sTitle.mb_str().release();
#endif
}
}
}
if (nRecipIndex > 0 && message.m_query_receipt)
mapiMessage.flFlags |= MAPI_RECEIPT_REQUESTED;
//Do the actual send using MAPISendMail
const UINT nFlags = show_ui ? MAPI_DIALOG : 0;
ULONG nError = m_data->m_lpfnMAPISendMail(m_data->m_hSession, 0, &mapiMessage, nFlags, 0);
if (nError == SUCCESS_SUCCESS)
{
bSuccess = TRUE;
m_data->m_nLastError = SUCCESS_SUCCESS;
}
else
{
wxString msg = "Impossibile inviare il messaggio: Errore ";
msg << nError;
wxMessageBox(msg, "MAPISendMail", wxOK|wxCENTRE|wxICON_ERROR);
m_data->m_nLastError = nError;
}
//Tidy up the Attachements
if (nAttachmentSize)
{
#ifdef UNICODE
for (i = 0;i < nAttachmentSize;i++)
{
free(mapiMessage.lpFiles[i].lpszPathName);
free(mapiMessage.lpFiles[i].lpszFileName);
}
#endif
delete [] mapiMessage.lpFiles;
}
//Free up the Recipients and Originator memory
#ifdef UNICODE
for (i = 0;i < nRecipIndex;i++)
free(mapiMessage.lpRecips[i].lpszName);
#endif
delete [] mapiMessage.lpRecips;
delete mapiMessage.lpOriginator;
return bSuccess;
}
long wxMapiSession::GetLastError() const
{
return m_data->m_nLastError;
}
bool wxMailMessage::Send(const wxString& profileName, bool bUI, const wxString& WXUNUSED(sendMail))
{
wxASSERT(m_to.GetCount() > 0) ;
wxString profile(profileName);
wxMapiSession session;
if (!session.MapiInstalled())
return FALSE;
if (!session.Logon(profile))
return FALSE;
return session.Send(*this, bUI);
}
#endif // __WXMSW__

99
src/xvaga01/smapi.h Normal file
View File

@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////
// Name: smapi.h
// Purpose: Simple MAPI classes
// Author: PJ Naughter <pjna@naughter.com>
// Modified by: Julian Smart
// Created: 2001-08-21
// RCS-ID: $Id: smapi.h,v 1.4 2010-04-22 15:26:15 guy Exp $
// Copyright: (c) PJ Naughter
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SMAPI_H_
#define _WX_SMAPI_H_
class wxMailMessage
{
public:
// A common usage
wxMailMessage(const wxString& subject, const wxString& to,
const wxString& body, const wxString& from = wxEmptyString,
const wxString& attachment = wxEmptyString,
const wxString& attachmentTitle = wxEmptyString) : m_query_receipt(false)
{
m_to.Add(to);
m_subject = subject;
m_body = body;
m_from = from;
if (!attachment.IsEmpty())
{
m_attachments.Add(attachment);
m_attachmentTitles.Add(attachmentTitle);
}
}
wxMailMessage() : m_query_receipt(false) {}
//// Accessors
void AddTo(const wxString& to) { m_to.Add(to); }
void AddCc(const wxString& cc) { m_cc.Add(cc); }
void AddBcc(const wxString& bcc) { m_bcc.Add(bcc); }
void AddAttachment(const wxString& attach, const wxString& title = wxEmptyString)
{ m_attachments.Add(attach); m_attachmentTitles.Add(title); }
void SetSubject(const wxString& subject) { m_subject = subject; }
void SetBody(const wxString& body) { m_body = body; }
void SetFrom(const wxString& from) { m_from = from; }
bool Send(const wxString& profileName = wxEmptyString,
bool bShowUI = false, const wxString& sendMail = wxT("/usr/sbin/sendmail -t"));
public:
wxArrayString m_to; //The To: Recipients
wxString m_from; //The From: email address (optional)
wxArrayString m_cc; //The CC: Recipients
wxArrayString m_bcc; //The BCC Recipients
wxString m_subject; //The Subject of the message
wxString m_body; //The Body of the message
wxArrayString m_attachments; //Files to attach to the email
wxArrayString m_attachmentTitles; //Titles to use for the email file attachments
bool m_query_receipt; //Query receipt message
};
class wxMapiData;
//The class which encapsulates the MAPI connection
class wxMapiSession
{
public:
//Constructors / Destructors
wxMapiSession();
~wxMapiSession();
//Logon / Logoff Methods
bool Logon(const wxString& sProfileName, const wxString& sPassword = wxEmptyString, wxWindow* pParentWnd = NULL);
bool LoggedOn() const;
bool Logoff();
//Send a message
bool Send(wxMailMessage& message, bool show_ui);
//General MAPI support
bool MapiInstalled() const;
//Error Handling
long GetLastError() const;
protected:
//Methods
void Initialise();
void Deinitialise();
bool Resolve(const wxString& sName, void* lppRecip1);
wxMapiData* m_data;
};
#endif //_WX_SMAPI_H_

59
src/xvaga01/statbar.h Normal file
View File

@ -0,0 +1,59 @@
/* STATBAR.H for dynamic custom control for XVT/Design 2.01
$Revision: 1.5 $ $Author: guy $ $Date: 2008-05-20 14:06:05 $
This code was written by Christopher Williamson,
May be distributed in object form only when embedded in a
registered XVT user's application.
Copyright 1993-1994, XVT Software Inc., All Rights Reserved.
*/
#ifndef STATBAR_H
#define STATBAR_H
#if defined(_cplusplus) || defined(__cplusplus)
extern "C" {
#endif
/* internal constants for sizing arrays, defaults, etc... */
//#define STATBAR_MAX_LEN 256 /* maximum length of status bar string */
//#define STATBAR_MAX_NUM 128 /* maximum number of status bars in an app */
//#define STATBAR_FONT_SIZE 10 /* default font size on Windows/PM/NT/CH */
/* the following CIS functions are external and may be called by the app */
XVTDLL const char* statbar_set_title(WINDOW win, const char *text);
XVTDLL const char* statbar_set_default_title(WINDOW win, const char *text);
/* the following CIS functions are external and are usable in all font modes */
XVTDLL XVT_FNTID statbar_set_fontid(WINDOW win, XVT_FNTID fontid);
XVTDLL XVT_FNTID statbar_get_fontid(WINDOW win, XVT_FNTID fontid);
/* the event handler and create function for statbar */
XVTDLL WINDOW statbar_create
(int cid, int left, int top, int right, int bottom,
int prop_count, char **prop_list, WINDOW parent_win,
int parent_rid, long parent_flags, char *parent_class);
XVTDLL BOOLEAN statbar_destroy(WINDOW win);
/* toolbar supports different types of controls */
enum TOOL_TYPE { TOOL_SEPARATOR = -1, TOOL_BUTTON, TOOL_TOGLBUTN, TOOL_RADIOBUTN };
/* the following CIS functions are external and may be called by the app */
XVTDLL BOOLEAN xvt_toolbar_add_control(WINDOW win, int cid, TOOL_TYPE type, const char *title,
int ico, int cust_width, int idx);
XVTDLL WINDOW xvt_toolbar_create(int cid, int left, int top, int right, int bottom,
long style, WINDOW parent_win);
XVTDLL void xvt_toolbar_enable_control(WINDOW win, int cid, BOOLEAN on);
XVTDLL void xvt_toolbar_realize(WINDOW win);
XVTDLL BOOLEAN xvt_toolbar_remove_control(WINDOW win, int cid);
XVTDLL BOOLEAN xvt_toolbar_set_last_tool(WINDOW win, int cid);
XVTDLL void xvt_toolbar_show_control(WINDOW win, int cid, BOOLEAN on);
XVTDLL BOOLEAN xvt_toolbar_toggle_control(WINDOW win, int cid, BOOLEAN on);
XVTDLL BOOLEAN xvt_toolbar_set_image(WINDOW win, int cid, int ico);
#if defined(_cplusplus) || defined(__cplusplus)
} /* extern "C" */
#endif
#endif /* STATBAR_H */

5077
src/xvaga01/treelistctrl.cpp Normal file

File diff suppressed because it is too large Load Diff

552
src/xvaga01/treelistctrl.h Normal file
View File

@ -0,0 +1,552 @@
/////////////////////////////////////////////////////////////////////////////
// Name: treelistctrl.h
// Purpose: wxTreeListCtrl class
// Author: Robert Roebling
// Maintainer: Otto Wyss
// Created: 01/02/97
// RCS-ID: $Id: treelistctrl.h,v 1.1.2.1 2011-04-06 14:09:31 guy Exp $
// Copyright: (c) 2004 Robert Roebling, Julian Smart, Alberto Griggio,
// Vadim Zeitlin, Otto Wyss
// Licence: wxWindows
/////////////////////////////////////////////////////////////////////////////
#ifndef TREELISTCTRL_H
#define TREELISTCTRL_H
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "treelistctrl.h"
#endif
#include <wx/treectrl.h>
#include <wx/listctrl.h> // for wxListEvent
class WXDLLEXPORT wxTreeListItem;
class WXDLLEXPORT wxTreeListHeaderWindow;
class WXDLLEXPORT wxTreeListMainWindow;
#define wxTR_COLUMN_LINES 0x1000 // put border around items
#define wxTR_VIRTUAL 0x4000 // The application provides items text on demand.
// Using this typedef removes an ambiguity when calling Remove()
#ifdef __WXMSW__
#if !wxCHECK_VERSION(2, 5, 0)
typedef long wxTreeItemIdValue;
#else
typedef void *wxTreeItemIdValue;
#endif
#endif
//-----------------------------------------------------------------------------
// wxTreeListColumnAttrs
//-----------------------------------------------------------------------------
enum {
DEFAULT_COL_WIDTH = 100
};
class /*WXDLLEXPORT*/ wxTreeListColumnInfo: public wxObject {
public:
wxTreeListColumnInfo (const wxString &text = wxEmptyString,
int width = DEFAULT_COL_WIDTH,
int flag = wxALIGN_LEFT,
int image = -1,
bool shown = true,
bool edit = false) {
m_text = text;
m_width = width;
m_flag = flag;
m_image = image;
m_selected_image = -1;
m_shown = shown;
m_edit = edit;
}
wxTreeListColumnInfo (const wxTreeListColumnInfo& other) {
m_text = other.m_text;
m_width = other.m_width;
m_flag = other.m_flag;
m_image = other.m_image;
m_selected_image = other.m_selected_image;
m_shown = other.m_shown;
m_edit = other.m_edit;
}
~wxTreeListColumnInfo() {}
// get/set
wxString GetText() const { return m_text; }
wxTreeListColumnInfo& SetText (const wxString& text) { m_text = text; return *this; }
int GetWidth() const { return m_width; }
wxTreeListColumnInfo& SetWidth (int width) { m_width = width; return *this; }
int GetAlignment() const { return m_flag; }
wxTreeListColumnInfo& SetAlignment (int flag) { m_flag = flag; return *this; }
int GetImage() const { return m_image; }
wxTreeListColumnInfo& SetImage (int image) { m_image = image; return *this; }
int GetSelectedImage() const { return m_selected_image; }
wxTreeListColumnInfo& SetSelectedImage (int image) { m_selected_image = image; return *this; }
bool IsEditable() const { return m_edit; }
wxTreeListColumnInfo& SetEditable (bool edit)
{ m_edit = edit; return *this; }
bool IsShown() const { return m_shown; }
wxTreeListColumnInfo& SetShown(bool shown) { m_shown = shown; return *this; }
private:
wxString m_text;
int m_width;
int m_flag;
int m_image;
int m_selected_image;
bool m_shown;
bool m_edit;
};
//----------------------------------------------------------------------------
// wxTreeListCtrl - the multicolumn tree control
//----------------------------------------------------------------------------
// modes for navigation
const int wxTL_MODE_NAV_FULLTREE = 0x0000; // default
const int wxTL_MODE_NAV_EXPANDED = 0x0001;
const int wxTL_MODE_NAV_VISIBLE = 0x0002;
const int wxTL_MODE_NAV_LEVEL = 0x0004;
// modes for FindItem
const int wxTL_MODE_FIND_EXACT = 0x0000; // default
const int wxTL_MODE_FIND_PARTIAL = 0x0010;
const int wxTL_MODE_FIND_NOCASE = 0x0020;
// additional flag for HitTest
const int wxTREE_HITTEST_ONITEMCOLUMN = 0x2000;
extern /*WXDLLEXPORT*/ const wxChar* wxTreeListCtrlNameStr;
class /*WXDLLEXPORT*/ wxTreeListCtrl : public wxControl
{
friend class wxTreeListHeaderWindow;
friend class wxTreeListMainWindow;
friend class wxTreeListItem;
public:
// creation
// --------
wxTreeListCtrl()
: m_header_win(0), m_main_win(0), m_headerHeight(0)
{}
wxTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTR_DEFAULT_STYLE,
const wxValidator &validator = wxDefaultValidator,
const wxString& name = wxTreeListCtrlNameStr )
: m_header_win(0), m_main_win(0), m_headerHeight(0)
{
Create(parent, id, pos, size, style, validator, name);
}
virtual ~wxTreeListCtrl() {}
bool Create(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTR_DEFAULT_STYLE,
const wxValidator &validator = wxDefaultValidator,
const wxString& name = wxTreeListCtrlNameStr );
void Refresh(bool erase=TRUE, const wxRect* rect=NULL);
void SetFocus();
// accessors
// ---------
// get the total number of items in the control
size_t GetCount() const;
// indent is the number of pixels the children are indented relative to
// the parents position. SetIndent() also redraws the control
// immediately.
unsigned int GetIndent() const;
void SetIndent(unsigned int indent);
// line spacing is the space above and below the text on each line
unsigned int GetLineSpacing() const;
void SetLineSpacing(unsigned int spacing);
// image list: these functions allow to associate an image list with
// the control and retrieve it. Note that when assigned with
// SetImageList, the control does _not_ delete
// the associated image list when it's deleted in order to allow image
// lists to be shared between different controls. If you use
// AssignImageList, the control _does_ delete the image list.
//
// The normal image list is for the icons which correspond to the
// normal tree item state (whether it is selected or not).
// Additionally, the application might choose to show a state icon
// which corresponds to an app-defined item state (for example,
// checked/unchecked) which are taken from the state image list.
wxImageList *GetImageList() const;
wxImageList *GetStateImageList() const;
wxImageList *GetButtonsImageList() const;
void SetImageList(wxImageList *imageList);
void SetStateImageList(wxImageList *imageList);
void SetButtonsImageList(wxImageList *imageList);
void AssignImageList(wxImageList *imageList);
void AssignStateImageList(wxImageList *imageList);
void AssignButtonsImageList(wxImageList *imageList);
void SetToolTip(const wxString& tip);
void SetToolTip (wxToolTip *tip);
void SetItemToolTip(const wxTreeItemId& item, const wxString &tip);
// Functions to work with columns
// adds a column
void AddColumn (const wxString& text,
int width = DEFAULT_COL_WIDTH,
int flag = wxALIGN_LEFT,
int image = -1,
bool shown = true,
bool edit = false) {
AddColumn (wxTreeListColumnInfo (text, width, flag, image, shown, edit));
}
void AddColumn (const wxTreeListColumnInfo& colInfo);
// inserts a column before the given one
void InsertColumn (int before,
const wxString& text,
int width = DEFAULT_COL_WIDTH,
int flag = wxALIGN_LEFT,
int image = -1,
bool shown = true,
bool edit = false) {
InsertColumn (before,
wxTreeListColumnInfo (text, width, flag, image, shown, edit));
}
void InsertColumn (int before, const wxTreeListColumnInfo& colInfo);
// deletes the given column - does not delete the corresponding column
void RemoveColumn (int column);
// returns the number of columns in the ctrl
int GetColumnCount() const;
// tells which column is the "main" one, i.e. the "threaded" one
void SetMainColumn (int column);
int GetMainColumn() const;
void SetColumn (int column, const wxTreeListColumnInfo& colInfo);
wxTreeListColumnInfo& GetColumn (int column);
const wxTreeListColumnInfo& GetColumn (int column) const;
void SetColumnText (int column, const wxString& text);
wxString GetColumnText (int column) const;
void SetColumnWidth (int column, int width);
int GetColumnWidth (int column) const;
void SetColumnAlignment (int column, int flag);
int GetColumnAlignment (int column) const;
void SetColumnImage (int column, int image);
int GetColumnImage (int column) const;
void SetColumnShown (int column, bool shown = true);
bool IsColumnShown (int column) const;
void SetColumnEditable (int column, bool edit = true);
bool IsColumnEditable (int column) const;
// Functions to work with items.
// accessors
// ---------
// retrieve item's label (of the main column)
wxString GetItemText (const wxTreeItemId& item) const
{ return GetItemText (item, GetMainColumn()); }
// retrieves item's label of the given column
wxString GetItemText (const wxTreeItemId& item, int column) const;
// get one of the images associated with the item (normal by default)
int GetItemImage (const wxTreeItemId& item,
wxTreeItemIcon which = wxTreeItemIcon_Normal) const
{ return GetItemImage (item, GetMainColumn(), which); }
int GetItemImage (const wxTreeItemId& item, int column,
wxTreeItemIcon which = wxTreeItemIcon_Normal) const;
// get the data associated with the item
wxTreeItemData *GetItemData (const wxTreeItemId& item) const;
bool GetItemBold (const wxTreeItemId& item) const;
wxColour GetItemTextColour (const wxTreeItemId& item) const;
wxColour GetItemBackgroundColour (const wxTreeItemId& item) const;
wxFont GetItemFont (const wxTreeItemId& item) const;
// modifiers
// set item's label
void SetItemText (const wxTreeItemId& item, const wxString& text)
{ SetItemText (item, GetMainColumn(), text); }
void SetItemText (const wxTreeItemId& item, int column, const wxString& text);
// get one of the images associated with the item (normal by default)
void SetItemImage (const wxTreeItemId& item, int image,
wxTreeItemIcon which = wxTreeItemIcon_Normal)
{ SetItemImage (item, GetMainColumn(), image, which); }
// the which parameter is ignored for all columns but the main one
void SetItemImage (const wxTreeItemId& item, int column, int image,
wxTreeItemIcon which = wxTreeItemIcon_Normal);
// associate some data with the item
void SetItemData (const wxTreeItemId& item, wxTreeItemData *data);
// force appearance of [+] button near the item. This is useful to
// allow the user to expand the items which don't have any children now
// - but instead add them only when needed, thus minimizing memory
// usage and loading time.
void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
// the item will be shown in bold
void SetItemBold (const wxTreeItemId& item, bool bold = true);
// set the item's text colour
void SetItemTextColour (const wxTreeItemId& item, const wxColour& colour);
// set the item's background colour
void SetItemBackgroundColour (const wxTreeItemId& item, const wxColour& colour);
// set the item's font (should be of the same height for all items)
void SetItemFont (const wxTreeItemId& item, const wxFont& font);
// set the window font
virtual bool SetFont ( const wxFont &font );
// set the styles.
void SetWindowStyle (const long styles);
long GetWindowStyle() const;
long GetWindowStyleFlag () const { return GetWindowStyle(); }
// item status inquiries
// ---------------------
// is the item visible (it might be outside the view or not expanded)?
bool IsVisible (const wxTreeItemId& item, bool fullRow = false, bool within = true) const;
// does the item has any children?
bool HasChildren (const wxTreeItemId& item) const;
// is the item expanded (only makes sense if HasChildren())?
bool IsExpanded (const wxTreeItemId& item) const;
// is this item currently selected (the same as has focus)?
bool IsSelected (const wxTreeItemId& item) const;
// is item text in bold font?
bool IsBold (const wxTreeItemId& item) const;
// does the layout include space for a button?
// number of children
// ------------------
// if 'recursively' is FALSE, only immediate children count, otherwise
// the returned number is the number of all items in this branch
size_t GetChildrenCount (const wxTreeItemId& item, bool recursively = true);
// navigation
// ----------
// wxTreeItemId.IsOk() will return FALSE if there is no such item
// get the root tree item
wxTreeItemId GetRootItem() const;
// get the item currently selected (may return NULL if no selection)
wxTreeItemId GetSelection() const;
// get the items currently selected, return the number of such item
size_t GetSelections (wxArrayTreeItemIds&) const;
// get the parent of this item (may return NULL if root)
wxTreeItemId GetItemParent (const wxTreeItemId& item) const;
// for this enumeration function you must pass in a "cookie" parameter
// which is opaque for the application but is necessary for the library
// to make these functions reentrant (i.e. allow more than one
// enumeration on one and the same object simultaneously). Of course,
// the "cookie" passed to GetFirstChild() and GetNextChild() should be
// the same!
// get child of this item
#if !wxCHECK_VERSION(2, 5, 0)
wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& cookie) const;
wxTreeItemId GetNextChild(const wxTreeItemId& item, long& cookie) const;
wxTreeItemId GetPrevChild(const wxTreeItemId& item, long& cookie) const;
wxTreeItemId GetLastChild(const wxTreeItemId& item, long& cookie) const;
#else
wxTreeItemId GetFirstChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const;
wxTreeItemId GetNextChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const;
wxTreeItemId GetPrevChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const;
wxTreeItemId GetLastChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const;
#endif
// get sibling of this item
wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
// get item in the full tree (currently only for internal use)
wxTreeItemId GetNext(const wxTreeItemId& item) const;
wxTreeItemId GetPrev(const wxTreeItemId& item) const;
// get expanded item, see IsExpanded()
wxTreeItemId GetFirstExpandedItem() const;
wxTreeItemId GetNextExpanded(const wxTreeItemId& item) const;
wxTreeItemId GetPrevExpanded(const wxTreeItemId& item) const;
// get visible item, see IsVisible()
wxTreeItemId GetFirstVisibleItem( bool fullRow = false) const;
wxTreeItemId GetFirstVisible( bool fullRow = false, bool within = true) const;
wxTreeItemId GetNextVisible (const wxTreeItemId& item, bool fullRow = false, bool within = true) const;
wxTreeItemId GetPrevVisible (const wxTreeItemId& item, bool fullRow = false, bool within = true) const;
wxTreeItemId GetLastVisible ( bool fullRow = false, bool within = true) const;
// operations
// ----------
// add the root node to the tree
wxTreeItemId AddRoot (const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = NULL);
// insert a new item in as the first child of the parent
wxTreeItemId PrependItem (const wxTreeItemId& parent,
const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = NULL);
// insert a new item after a given one
wxTreeItemId InsertItem (const wxTreeItemId& parent,
const wxTreeItemId& idPrevious,
const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = NULL);
// insert a new item before the one with the given index
wxTreeItemId InsertItem (const wxTreeItemId& parent,
size_t index,
const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = NULL);
// insert a new item in as the last child of the parent
wxTreeItemId AppendItem (const wxTreeItemId& parent,
const wxString& text,
int image = -1, int selectedImage = -1,
wxTreeItemData *data = NULL);
// delete this item (except root) + children and associated data if any
void Delete (const wxTreeItemId& item);
// delete all children (but don't delete the item itself)
void DeleteChildren (const wxTreeItemId& item);
// delete the root and all its children from the tree
void DeleteRoot();
// expand this item
void Expand (const wxTreeItemId& item);
// expand this item and all subitems recursively
void ExpandAll (const wxTreeItemId& item);
// collapse the item without removing its children
void Collapse (const wxTreeItemId& item);
// collapse the item and remove all children
void CollapseAndReset(const wxTreeItemId& item); //? TODO ???
// toggles the current state
void Toggle (const wxTreeItemId& item);
// remove the selection from currently selected item (if any)
void Unselect();
void UnselectAll();
// select this item - return true if selection was allowed (no veto)
bool SelectItem (const wxTreeItemId& item,
const wxTreeItemId& last = (wxTreeItemId*)NULL,
bool unselect_others = true);
// select all items in the expanded tree
void SelectAll();
// make sure this item is visible (expanding the parent item and/or
// scrolling to this item if necessary)
void EnsureVisible (const wxTreeItemId& item);
// scroll to this item (but don't expand its parent)
void ScrollTo (const wxTreeItemId& item);
// The first function is more portable (because easier to implement
// on other platforms), but the second one returns some extra info.
wxTreeItemId HitTest (const wxPoint& point)
{ int flags; int column; return HitTest (point, flags, column); }
wxTreeItemId HitTest (const wxPoint& point, int& flags)
{ int column; return HitTest (point, flags, column); }
wxTreeItemId HitTest (const wxPoint& point, int& flags, int& column);
// get the bounding rectangle of the item (or of its label only)
bool GetBoundingRect (const wxTreeItemId& item, wxRect& rect,
bool textOnly = false) const;
// Start editing the item label: this (temporarily) replaces the item
// with a one line edit control. The item will be selected if it hadn't
// been before.
void EditLabel (const wxTreeItemId& item)
{ EditLabel (item, GetMainColumn()); }
// edit item's label of the given column
void EditLabel (const wxTreeItemId& item, int column);
// virtual mode
virtual wxString OnGetItemText( wxTreeItemData* item, long column ) const;
// sorting
// this function is called to compare 2 items and should return -1, 0
// or +1 if the first item is less than, equal to or greater than the
// second one. The base class version performs alphabetic comparaison
// of item labels (GetText)
virtual int OnCompareItems (const wxTreeItemId& item1, const wxTreeItemId& item2);
// sort the children of this item using OnCompareItems
// NB: this function is not reentrant and not MT-safe (FIXME)!
void SortChildren(const wxTreeItemId& item);
// searching
wxTreeItemId FindItem (const wxTreeItemId& item, const wxString& str, int mode = 0);
// overridden base class virtuals
virtual bool SetBackgroundColour (const wxColour& colour);
virtual bool SetForegroundColour (const wxColour& colour);
// drop over item
void SetDragItem (const wxTreeItemId& item = (wxTreeItemId*)NULL);
virtual wxSize DoGetBestSize() const;
protected:
// header window, responsible for column visualization and manipulation
wxTreeListHeaderWindow* GetHeaderWindow() const
{ return m_header_win; }
wxTreeListHeaderWindow* m_header_win; // future cleanup: make private or remove GetHeaderWindow()
// main window, the "true" tree ctrl
wxTreeListMainWindow* GetMainWindow() const
{ return m_main_win; }
wxTreeListMainWindow* m_main_win; // future cleanup: make private or remove GetMainWindow()
int GetHeaderHeight() const { return m_headerHeight; }
void CalculateAndSetHeaderHeight();
void DoHeaderLayout();
void OnSize(wxSizeEvent& event);
private:
int m_headerHeight;
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxTreeListCtrl)
};
#endif // TREELISTCTRL_H

23
src/xvaga01/wxinc.h Normal file
View File

@ -0,0 +1,23 @@
// Evito di mettere nei settaggi di tutti i progetti questa sequela di #define
#ifndef __WXINC_H__
#define __WXINC_H__
#ifdef WIN32
#define __WINDOWS__
#define __WXMSW__
#define __WIN95__
#define __WIN32__
#define WINVER 0x0500
#define STRICT
#define WXUSINGDLL 1
#include <wx/wxprec.h>
#else
#define _FILE_OFFSET_BITS 64
#define _LARGE_FILES
#define __WXGTK__
#define GTK_NO_CHECK_CASTS
#define _IODBC
#include <wx/wx.h>
#endif
#endif

5041
src/xvaga01/xvaga.cpp Normal file

File diff suppressed because it is too large Load Diff

284
src/xvaga01/xvapp.cpp Normal file
View File

@ -0,0 +1,284 @@
#include "../xvaga/wxinc.h"
#include "xvt.h"
#include <wx/filename.h>
#include <wx/snglinst.h>
#ifdef false
#ifdef __WXMSW__
#include <windows.h>
#include <stdio.h>
#include <imagehlp.h>
static FILE * f = nullptr;
void print_stack_element(STACKFRAME frame)
{
//------------------------------------------------------------------
// Declare an image help symbol structure to hold symbol info and
// name up to 256 chars This struct is of variable lenght though so
// it must be declared as a raw byte buffer.
//------------------------------------------------------------------
static char symbolBuffer[sizeof(IMAGEHLP_SYMBOL) + 255];
memset(symbolBuffer, 0, sizeof(IMAGEHLP_SYMBOL) + 255);
// Cast it to a symbol struct:
IMAGEHLP_SYMBOL * symbol = (IMAGEHLP_SYMBOL*)symbolBuffer;
// Need to set the first two fields of this symbol before obtaining name info:
symbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL) + 255;
symbol->MaxNameLength = 254;
// The displacement from the beginning of the symbol is stored here: pretty useless
unsigned displacement = 0;
// Get the symbol information from the address of the instruction pointer register:
if (SymGetSymFromAddr(GetCurrentProcess(), // Process to get symbol information for
frame.AddrPC.Offset, // Address to get symbol for: instruction pointer register
(DWORD*)& displacement, // Displacement from the beginning of the symbol: whats this for ?
symbol)) // Where to save the symbol
{
// Add the name of the function to the function list:
fprintf(f, "0x%08x %s\n", frame.AddrPC.Offset, symbol->Name);
}
else
{
// Print an unknown location:
// functionNames.push_back("unknown location");
fprintf(f, "0x%08x\n", frame.AddrPC.Offset);
}
}
void windows_print_stacktrace(CONTEXT* context)
{
SymInitialize(GetCurrentProcess(), 0, true);
STACKFRAME frame = { 0 };
/* setup initial stack frame */
frame.AddrPC.Offset = context->Eip;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrStack.Offset = context->Esp;
frame.AddrStack.Mode = AddrModeFlat;
frame.AddrFrame.Offset = context->Ebp;
frame.AddrFrame.Mode = AddrModeFlat;
while (StackWalk(IMAGE_FILE_MACHINE_I386, GetCurrentProcess(), GetCurrentThread(), &frame,
context, 0, SymFunctionTableAccess, SymGetModuleBase, 0))
print_stack_element(frame);
SymCleanup(GetCurrentProcess());
}
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS * ExceptionInfo)
{
fopen_s(&f, "stack.log", xvt_fsys_file_exists("stack.log") != 0 ? "a+tc" : "wtc");
if (f != nullptr)
{
switch (ExceptionInfo->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
fprintf(f, "Error: EXCEPTION_ACCESS_VIOLATION");
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
fprintf(f, "Error: EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
break;
case EXCEPTION_BREAKPOINT:
fprintf(f, "Error: EXCEPTION_BREAKPOINT");
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
fprintf(f, "Error: EXCEPTION_DATATYPE_MISALIGNMENT");
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
fprintf(f, "Error: EXCEPTION_FLT_DENORMAL_OPERAND");
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
fprintf(f, "Error: EXCEPTION_FLT_DIVIDE_BY_ZERO");
break;
case EXCEPTION_FLT_INEXACT_RESULT:
fprintf(f, "Error: EXCEPTION_FLT_INEXACT_RESULT");
break;
case EXCEPTION_FLT_INVALID_OPERATION:
fprintf(f, "Error: EXCEPTION_FLT_INVALID_OPERATION");
break;
case EXCEPTION_FLT_OVERFLOW:
fprintf(f, "Error: EXCEPTION_FLT_OVERFLOW");
break;
case EXCEPTION_FLT_STACK_CHECK:
fprintf(f, "Error: EXCEPTION_FLT_STACK_CHECK");
break;
case EXCEPTION_FLT_UNDERFLOW:
fprintf(f, "Error: EXCEPTION_FLT_UNDERFLOW");
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
fprintf(f, "Error: EXCEPTION_ILLEGAL_INSTRUCTION");
break;
case EXCEPTION_IN_PAGE_ERROR:
fprintf(f, "Error: EXCEPTION_IN_PAGE_ERROR");
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
fprintf(f, "Error: EXCEPTION_INT_DIVIDE_BY_ZERO");
break;
case EXCEPTION_INT_OVERFLOW:
fprintf(f, "Error: EXCEPTION_INT_OVERFLOW");
break;
case EXCEPTION_INVALID_DISPOSITION:
fprintf(f, "Error: EXCEPTION_INVALID_DISPOSITION");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
fprintf(f, "Error: EXCEPTION_NONCONTINUABLE_EXCEPTION");
break;
case EXCEPTION_PRIV_INSTRUCTION:
fprintf(f, "Error: EXCEPTION_PRIV_INSTRUCTION");
break;
case EXCEPTION_SINGLE_STEP:
fprintf(f, "Error: EXCEPTION_SINGLE_STEP");
break;
case EXCEPTION_STACK_OVERFLOW:
fprintf(f, "Error: EXCEPTION_STACK_OVERFLOW");
break;
default:
return EXCEPTION_EXECUTE_HANDLER; // per ora non mi interessa;
break;
}
/* If this is a stack overflow then we can't walk the stack, so just show
where the error happened */
if (EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
windows_print_stacktrace(ExceptionInfo->ContextRecord);
else
{
STACKFRAME frame = { 0 };
frame.AddrPC.Offset = ExceptionInfo->ContextRecord->Eip;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrStack.Offset = ExceptionInfo->ContextRecord->Esp;
frame.AddrStack.Mode = AddrModeFlat;
frame.AddrFrame.Offset = ExceptionInfo->ContextRecord->Ebp;
frame.AddrFrame.Mode = AddrModeFlat;
print_stack_element(frame);
}
fflush(f);
}
return EXCEPTION_EXECUTE_HANDLER;
}
static BOOL PreventSetUnhandledExceptionFilter()
{
HMODULE hKernelbase = LoadLibrary(_T("KernelBase.dll"));
HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
if (hKernel32 == nullptr) return false;
void *pOrgEntry = GetProcAddress(hKernel32, "SetUnhandledExceptionFilter");
if (pOrgEntry == nullptr) return false;
#ifdef _M_IX86
// Code for x86:
// 33 C0 xor eax,eax
// C2 04 00 ret 4
unsigned char szExecute[] = { 0x33, 0xC0, 0xC2, 0x04, 0x00 };
#elif _M_X64
// 33 C0 xor eax,eax
// C3 ret
unsigned char szExecute[] = { 0x33, 0xC0, 0xC3 };
#else
#error "The following code only works for x86 and x64!"
#endif
SIZE_T bytesWritten = 0;
BOOL bRet = WriteProcessMemory(GetCurrentProcess(),
pOrgEntry, szExecute, sizeof(szExecute), &bytesWritten);
return bRet;
}
void OSWin32_set_signal_handler()
{
AddVectoredExceptionHandler(1L, windows_exception_handler);
// SetUnhandledExceptionFilter(windows_exception_handler);
PreventSetUnhandledExceptionFilter();
}
#else
void OSLinux_set_signal_handler()
{
}
#endif
#endif
extern int xvt_main(int argc, char** argv);
class TMainApp : public wxApp
{
wxSingleInstanceChecker* m_sic;
protected:
virtual bool OnInit();
virtual int OnExit();
void OnTimer(wxTimerEvent& evt);
// void OnUnhandledException();
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(TMainApp);
};
IMPLEMENT_DYNAMIC_CLASS(TMainApp, wxApp)
IMPLEMENT_APP(TMainApp)
#define TIMER_ID 883
BEGIN_EVENT_TABLE(TMainApp, wxApp)
EVT_TIMER(TIMER_ID, TMainApp::OnTimer)
END_EVENT_TABLE()
void TMainApp::OnTimer(wxTimerEvent& evt)
{
xvt_app_pre_create();
xvt_main(argc, argv);
}
bool TMainApp::OnInit()
{
#ifdef false
#ifdef __WXMSW__
OSWin32_set_signal_handler();
#else
OSLinux_set_signal_handler();
#endif
#endif
wxFileName strWrk = argv[0];
//const wxString strApp = strWrk.GetName().Lower();
strWrk.MakeAbsolute();
wxString strApp = strWrk.GetFullPath().Lower();
strApp.Replace("\\", "_"); strApp.Replace("/", "_"); strApp.Replace(":", "_");
m_sic = new wxSingleInstanceChecker(strApp);
xvt_vobj_set_attr(NULL_WIN, ATTR_APPL_ALREADY_RUNNING, m_sic->IsAnotherRunning());
// Non eseguo direttamente xvt_main per dar modo al main event loop di partire
wxTimerEvent evt(TIMER_ID);
AddPendingEvent(evt);
return true;
}
/*void TMainApp::OnUnhandledException()
{
windows_exception_handler(nullptr);
}
*/
int TMainApp::OnExit()
{
delete m_sic;
m_sic = NULL;
return wxApp::OnExit();
}

634
src/xvaga01/xvt.h Normal file
View File

@ -0,0 +1,634 @@
#ifndef XVT_INCL_XVT
#define XVT_INCL_XVT
#if defined(WIN32)&&(_MSC_VER > 1300)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#ifdef XVT_INCL_NATIVE
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#define STRICT
#include <windows.h>
#endif
#endif
#ifdef WIN32
#ifdef XVAGADLL
#define XVTDLL __declspec(dllexport)
#else
#define XVTDLL __declspec(dllimport)
#endif
#else
#define XVTDLL
#endif
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "xvt_env.h"
#include "xvt_defs.h"
#include "xvt_help.h"
#include "xvt_menu.h"
#include "xvt_type.h"
#include "xvt_vers.h"
#ifdef __cplusplus
extern "C" {
#endif
#define XVT_DESKTOP_DIR 0
#define XVT_DOCUMENTS_DIR 1
#define XVT_EXEC_DIR 2
#define XVT_INSTALL_DIR 3
#define XVT_TEMP_DIR 4
#define MAX_TASKS 1024
XVTDLL void xvt_app_allow_quit(void);
XVTDLL void xvt_app_pre_create(void);
XVTDLL void xvt_app_create(int argc, char **argv, unsigned long flags, EVENT_HANDLER eh, XVT_CONFIG *config);
XVTDLL void xvt_app_destroy(void);
XVTDLL BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD*, long* ph, long* pw, long* pvr, long* phr);
XVTDLL DRAW_CTOOLS* xvt_app_get_default_ctools(DRAW_CTOOLS* ct);
XVTDLL void xvt_app_process_pending_events(void);
XVTDLL char* xvt_cb_alloc_data(long size);
XVTDLL BOOLEAN xvt_cb_close(void);
XVTDLL void xvt_cb_free_data(void);
XVTDLL char* xvt_cb_get_data(CB_FORMAT cbfmt, char *name, long *sizep);
XVTDLL BOOLEAN xvt_cb_has_format(CB_FORMAT fmt, char *name);
XVTDLL BOOLEAN xvt_cb_open(BOOLEAN writing);
XVTDLL BOOLEAN xvt_cb_put_data(CB_FORMAT cbfmt, char *name, long size, PICTURE pic);
XVTDLL void xvt_ctl_check_radio_button(WINDOW Win, WINDOW* Wins, int NbrWindows);
XVTDLL WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data);
XVTDLL void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check);
XVTDLL void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR_ACTION action);
XVTDLL void xvt_ctl_set_texture(WINDOW win, XVT_IMAGE img);
XVTDLL void xvt_debug_printf(const char* fmt, ...);
XVTDLL void xvt_dm_popup_message(const char *fmt);
XVTDLL void xvt_dm_popup_warning(const char *fmt);
XVTDLL void xvt_dm_popup_error(const char *fmt);
XVTDLL WINDOW xvt_dm_progress_create(WINDOW parent, const char* msg, long total, BOOLEAN cancellable);
XVTDLL BOOLEAN xvt_dm_progress_set_status(WINDOW prog, long current, long total);
XVTDLL void xvt_dm_progress_set_text(WINDOW prog, const char* msg);
XVTDLL void xvt_dm_progress_destroy(WINDOW prog);
XVTDLL void xvt_dm_post_about_box(void);
XVTDLL ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char*Btn2, const char* Btn3, const char* xin_buffer);
XVTDLL unsigned int xvt_dm_post_date_sel(WINDOW win, const RCT* ownrct, unsigned int ansidate); // Added by guy
XVTDLL BOOLEAN xvt_dm_post_color_sel(COLOR* color, unsigned long reserved);
XVTDLL void xvt_dm_post_error(const char *fmt);
XVTDLL void xvt_dm_post_fatal_exit(const char *fmt);
XVTDLL FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, const char *msg);
XVTDLL FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg);
XVTDLL FL_STATUS xvt_dm_post_dir_sel(DIRECTORY *dir); // Added by Luca
XVTDLL BOOLEAN xvt_dm_post_font_sel(WINDOW win, XVT_FNTID font_id, PRINT_RCD *precp, unsigned long reserved);
XVTDLL void xvt_dm_post_message(const char *fmt);
XVTDLL void xvt_dm_post_note(const char *fmt);
XVTDLL BOOLEAN xvt_dm_post_page_setup(PRINT_RCD *precp);
XVTDLL char* xvt_dm_post_string_prompt(const char* message, char* response, int response_len);
XVTDLL void xvt_dm_post_warning(const char *fmt);
XVTDLL BOOLEAN xvt_dm_post_speech(const char* text, int priority, BOOLEAN async); // 0 = Error, 1 = Warning, 2 Message, ...
XVTDLL void xvt_dm_speech_enable(int mode);
XVTDLL int xvt_dm_speech_enabled(void);
// Dongle support by Sirio
/*
XVTDLL int xvt_dongle_sa_crypt(unsigned short* data);
XVTDLL int xvt_dongle_sa_login(const char* module);
XVTDLL int xvt_dongle_sa_logout(const char* module);
XVTDLL int xvt_dongle_sa_test(const char* module);
*/
// Dongle support
XVTDLL int xvt_dongle_crypt(unsigned short* data);
// Dongle software support
XVTDLL BOOLEAN xvt_dongle_sw_encode_decode(unsigned char* data, unsigned long serial, int len);
XVTDLL int xvt_dongle_sw_crypt(unsigned short* data);
XVTDLL BOOLEAN xvt_get_secret(const char* addresses);
XVTDLL void xvt_dwin_clear(WINDOW win, COLOR col);
XVTDLL void xvt_dwin_draw_arc(WINDOW win, const RCT* r, int sx, int sy, int ex, int ey);
XVTDLL void xvt_dwin_draw_checkmark(WINDOW win, const RCT* rctp);
XVTDLL void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid);
XVTDLL void xvt_dwin_draw_icon_rect(WINDOW win, RCT* rct, int rid);
XVTDLL void xvt_dwin_draw_gradient_circular(WINDOW win, const RCT* r, COLOR col1, COLOR col2, const PNT* center); // Added by AGA
XVTDLL void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR col2, int angle); // Added by AGA
XVTDLL void xvt_dwin_draw_image_on_pdf(WINDOW win, const char* name, const RCT* dest); // Added by AGA
XVTDLL void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, const RCT* dest, const RCT* source);
XVTDLL void xvt_dwin_draw_line(WINDOW win, PNT pnt);
XVTDLL void xvt_dwin_draw_oval(WINDOW Win, const RCT* r);
XVTDLL void xvt_dwin_draw_pie(WINDOW win, const RCT *rctp, int start_x, int start_y, int stop_x, int stop_y);
XVTDLL void xvt_dwin_draw_polygon(WINDOW win, const PNT *lpnts, int npnts);
XVTDLL void xvt_dwin_draw_polyline(WINDOW win, const PNT *lpnts, int npnts);
XVTDLL void xvt_dwin_draw_rect(WINDOW win, const RCT *rctp);
XVTDLL void xvt_dwin_draw_roundrect(WINDOW win, const RCT *rctp, int oval_width, int oval_height);
XVTDLL void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp); // Added by Guy
XVTDLL void xvt_dwin_draw_tool(WINDOW win, int x, int y, int rid, int size); // Added by Guy
XVTDLL void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt);
XVTDLL void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len);
XVTDLL RCT* xvt_dwin_get_clip(WINDOW win, RCT* rct);
XVTDLL DRAW_CTOOLS* xvt_dwin_get_draw_ctools(WINDOW win, DRAW_CTOOLS *ctoolsp);
XVTDLL XVT_FNTID xvt_dwin_get_font(WINDOW win);
XVTDLL void xvt_dwin_get_font_metrics(WINDOW win, int *leadingp, int *ascentp, int *descentp);
XVTDLL long xvt_dwin_get_font_size_mapped(WINDOW win);
XVTDLL int xvt_dwin_get_text_width(WINDOW win, const char *s, int len);
XVTDLL void xvt_dwin_invalidate_rect(WINDOW win, const RCT *rctp);
XVTDLL BOOLEAN xvt_dwin_is_update_needed(WINDOW Win, const RCT* rctp);
XVTDLL void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv);
XVTDLL void xvt_dwin_set_back_color(WINDOW win, COLOR color);
XVTDLL void xvt_dwin_set_cbrush(WINDOW win, CBRUSH* cbrush);
XVTDLL void xvt_dwin_set_clip(WINDOW win, const RCT* rct);
XVTDLL void xvt_dwin_set_cpen(WINDOW win, CPEN* cpen);
XVTDLL void xvt_dwin_set_draw_ctools(WINDOW win, DRAW_CTOOLS* xct);
XVTDLL void xvt_dwin_set_draw_mode(WINDOW win, DRAW_MODE mode);
XVTDLL void xvt_dwin_set_font(WINDOW win, XVT_FNTID font_id);
XVTDLL void xvt_dwin_set_fore_color(WINDOW win, COLOR color);
XVTDLL void xvt_dwin_set_std_cbrush(WINDOW win, long flag);
XVTDLL void xvt_dwin_set_std_cpen(WINDOW win, long flag);
XVTDLL void xvt_dwin_update(WINDOW win);
XVTDLL XVT_ERRSEV xvt_errmsg_get_sev_id(XVT_ERRMSG err);
XVTDLL long xvt_fmap_get_family_sizes(PRINT_RCD *precp, char *family, long *size_array, BOOLEAN *scalable, long max_sizes);
XVTDLL long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_families);
XVTDLL void xvt_font_copy(XVT_FNTID dest_font_id, XVT_FNTID src_font_id, XVT_FONT_ATTR_MASK mask);
XVTDLL XVT_FNTID xvt_font_create(void);
XVTDLL void xvt_font_deserialize(XVT_FNTID font_id, const char *buf);
XVTDLL void xvt_font_destroy(XVT_FNTID font_id);
XVTDLL BOOLEAN xvt_font_get_family(XVT_FNTID font_id, char* buf, long max_buf);
XVTDLL BOOLEAN xvt_font_get_family_mapped(XVT_FNTID font_id, char* buf, long max_buf);
XVTDLL void xvt_font_get_metrics(XVT_FNTID font_id, int *leadingp, int *ascentp, int *descentp);
XVTDLL BOOLEAN xvt_font_get_native_desc(XVT_FNTID font_id, char *buf, long max_buf);
XVTDLL long xvt_font_get_size(XVT_FNTID font_id);
XVTDLL XVT_FONT_STYLE_MASK xvt_font_get_style(XVT_FNTID font_id);
XVTDLL WINDOW xvt_font_get_win(XVT_FNTID font_id);
XVTDLL BOOLEAN xvt_font_is_mapped(XVT_FNTID font_id);
XVTDLL void xvt_font_map(XVT_FNTID font_id, WINDOW font_win );
XVTDLL void xvt_font_map_using_default(XVT_FNTID font_id);
XVTDLL void xvt_font_set_family(XVT_FNTID font_id, const char* family);
XVTDLL void xvt_font_set_size(XVT_FNTID font_id, long size);
XVTDLL void xvt_font_set_style(XVT_FNTID font_id, XVT_FONT_STYLE_MASK mask);
XVTDLL long xvt_font_serialize(XVT_FNTID font_id, char *buf, long max_buf);
XVTDLL void xvt_font_unmap(XVT_FNTID font_id);
XVTDLL BOOLEAN xvt_fsys_build_pathname(char *mbs, const char *volname, const char *dirname, const char *leafroot, const char *leafext, const char *leafvers);
XVTDLL BOOLEAN xvt_fsys_convert_dir_to_str(DIRECTORY *dirp, char *path, int sz_path);
XVTDLL BOOLEAN xvt_fsys_convert_str_to_dir(const char *path, DIRECTORY *dirp);
XVTDLL BOOLEAN xvt_fsys_convert_fspec_to_str(const FILE_SPEC *fs, char *path, int sz_path);
XVTDLL BOOLEAN xvt_fsys_convert_str_to_fspec(const char *mbs, FILE_SPEC *fs);
XVTDLL BOOLEAN xvt_fsys_get_dir(DIRECTORY* dirp); // da eliminare nella 13
XVTDLL BOOLEAN xvt_fsys_get_curr_dir(DIRECTORY* dirp);
XVTDLL void xvt_fsys_get_default_dir(DIRECTORY* dirp);
XVTDLL void xvt_fsys_get_temp_dir(DIRECTORY* dirp);
XVTDLL SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs);
XVTDLL BOOLEAN xvt_fsys_parse_pathname (const char *mbs, char *volname, char *dirname, char *leafroot, char *leafext, char *leafvers);
XVTDLL void xvt_fsys_restore_dir();
XVTDLL void xvt_fsys_save_dir();
XVTDLL BOOLEAN xvt_fsys_set_dir(const DIRECTORY* dirp);
XVTDLL long xvt_fsys_get_file_attr(const FILE_SPEC *fs, long attr);
XVTDLL void xvt_fsys_set_file_time(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime);
XVTDLL BOOLEAN xvt_fsys_fcopy(const char* orig, const char* dest);
// Added by Guy
XVTDLL unsigned long xvt_fsys_get_disk_size(const char* path, char unit);
XVTDLL unsigned long xvt_fsys_get_disk_free_space(const char* path, char unit);
XVTDLL BOOLEAN xvt_fsys_is_floppy_drive(const char* path);
XVTDLL BOOLEAN xvt_fsys_is_removable_drive(const char* path);
XVTDLL BOOLEAN xvt_fsys_is_network_drive(const char* path);
XVTDLL BOOLEAN xvt_fsys_is_fixed_drive(const char* path);
XVTDLL BOOLEAN xvt_fsys_test_disk_free_space(const char* path, unsigned long filesize);
XVTDLL BOOLEAN xvt_fsys_mkdir(const char *pathname);
XVTDLL BOOLEAN xvt_fsys_rmdir(const char *pathname);
XVTDLL BOOLEAN xvt_fsys_remove_file(const char *pathname);
XVTDLL BOOLEAN xvt_fsys_rename_file(const char *src_pathname, const char *dst_pathname);
XVTDLL int xvt_fsys_access(const char *pathname, int mode);
XVTDLL BOOLEAN xvt_fsys_dir_exists(const char *pathname);
XVTDLL BOOLEAN xvt_fsys_file_exists(const char *pathname);
XVTDLL int xvt_fsys_get_campo_stp_value(const char* name, char* value, int valsize);
XVTDLL const char* xvt_fsys_get_home_dir();
XVTDLL const char* xvt_fsys_get_campo_ini();
XVTDLL long xvt_fsys_file_attr(const char* pathname, long attr);
XVTDLL BOOLEAN xvt_fsys_file_md5(const char* path, char* outstr32);
XVTDLL int xvt_fsys_files_copy (const char* src, SLIST names, const char* dst);
XVTDLL int xvt_fsys_files_move (const char* src, SLIST names, const char* dst);
XVTDLL int xvt_fsys_files_remove(const char* src, SLIST names);
XVTDLL void xvt_fsys_get_sys_dir(int what_dir, char * dir);
XVTDLL void xvt_help_close_helpfile(XVT_HELP_INFO hi);
XVTDLL XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags);
XVTDLL BOOLEAN xvt_help_process_event(XVT_HELP_INFO hi, WINDOW win, EVENT *ev);
XVTDLL BOOLEAN xvt_html_set_url(WINDOW win, const char* url);
XVTDLL void xvt_image_blur(XVT_IMAGE image, short radius);
XVTDLL XVT_IMAGE xvt_image_capture(WINDOW win, const RCT* rct);
XVTDLL XVT_IMAGE xvt_image_create(XVT_IMAGE_FORMAT format, short width, short height, COLOR color);
XVTDLL void xvt_image_destroy(XVT_IMAGE image);
XVTDLL int xvt_image_find_clut_index(XVT_IMAGE image, COLOR color);
XVTDLL COLOR xvt_image_get_clut(XVT_IMAGE image, short index);
XVTDLL void xvt_image_get_dimensions(XVT_IMAGE image, short *width, short *height);
XVTDLL XVT_IMAGE_FORMAT xvt_image_get_format(XVT_IMAGE image);
XVTDLL short xvt_image_get_ncolors(XVT_IMAGE image);
XVTDLL COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y);
XVTDLL XVT_IMAGE xvt_image_read(const char *filenamep);
XVTDLL XVT_IMAGE xvt_image_read_bmp(const char *filenamep);
XVTDLL void xvt_image_replace_color(XVT_IMAGE image, COLOR old_color, COLOR new_color);
XVTDLL void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color);
XVTDLL void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors);
XVTDLL void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color);
XVTDLL void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp);
typedef XVT_CALLCONV_TYPEDEF(void, IMAGE_FILTER, (short x, short y, unsigned char* rgba, void* jolly));
XVTDLL BOOLEAN xvt_image_filter(XVT_IMAGE image, IMAGE_FILTER filter, void* param);
XVTDLL int xvt_list_add_item(WINDOW win, short icon, const char* text, int flags);
XVTDLL BOOLEAN xvt_list_add(WINDOW win, int index, const char* text);
XVTDLL BOOLEAN xvt_list_clear(WINDOW win);
XVTDLL int xvt_list_get_sel_index(WINDOW win);
XVTDLL BOOLEAN xvt_list_set_sel(WINDOW win, int index, BOOLEAN select);
XVTDLL int xvt_list_count(WINDOW win);
XVTDLL MENU_TAG xvt_list_popup(WINDOW parent, const RCT* ownrct, const MENU_ITEM* menu, const XVT_COLOR_COMPONENT* colors, MENU_TAG first);
XVTDLL DATA_PTR xvt_mem_alloc(size_t size);
XVTDLL void xvt_mem_free(DATA_PTR p);
XVTDLL DATA_PTR xvt_mem_realloc(DATA_PTR p, size_t size);
XVTDLL DATA_PTR xvt_mem_rep(DATA_PTR dst, DATA_PTR src, unsigned int srclen, long reps);
XVTDLL DATA_PTR xvt_mem_zalloc(size_t size);
XVTDLL MENU_ITEM* xvt_menu_get_tree(WINDOW win);
XVTDLL BOOLEAN xvt_menu_popup(const MENU_ITEM *menu_p, WINDOW win, PNT pos, XVT_POPUP_ALIGNMENT alignment, MENU_TAG item);
XVTDLL void xvt_menu_set_font_sel(WINDOW win, XVT_FNTID font_id);
XVTDLL void xvt_menu_set_item_checked(WINDOW win, MENU_TAG tag, BOOLEAN check);
XVTDLL void xvt_menu_set_item_enabled(WINDOW win, MENU_TAG tag, BOOLEAN enable);
XVTDLL void xvt_menu_set_item_title(WINDOW win, MENU_TAG tag, const char* text);
XVTDLL void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree);
XVTDLL void xvt_menu_update(WINDOW win);
XVTDLL MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m);
XVTDLL short xvt_notebk_add_page(WINDOW notebk, WINDOW page, const char* title, XVT_IMAGE img, short page_no);
XVTDLL short xvt_notebk_get_front_page(WINDOW notebk);
XVTDLL short xvt_notebk_get_num_tabs(WINDOW notebk);
XVTDLL WINDOW xvt_notebk_get_page(WINDOW notebk, short page_no);
XVTDLL char* xvt_notebk_get_tab_title(WINDOW notebk, short page_no, char* title, int sz_title);
XVTDLL void xvt_notebk_set_front_page(WINDOW notebk, short page_no);
XVTDLL void xvt_notebk_set_tab_icon(WINDOW notebk, short page_no, int rid);
XVTDLL void xvt_notebk_set_tab_image(WINDOW notebk, short page_no, XVT_IMAGE img);
XVTDLL void xvt_notebk_set_tab_title(WINDOW notebk, short page_no, const char* title);
XVTDLL void xvt_notebk_set_page_title(WINDOW notebk, short page_no, const char* title);
XVTDLL void xvt_notebk_rem_page(WINDOW notebk, short page_no);
XVTDLL void xvt_notebk_rem_tab(WINDOW notebk, short tab_no);
XVTDLL char * xvt_GUID();
// Added by Guy
typedef const char* TRANSLATE_CALLBACK(const char* ita);
XVTDLL void xvt_menu_translate_tree(WINDOW win, TRANSLATE_CALLBACK tc);
XVTDLL short xvt_palet_add_colors(XVT_PALETTE palet, COLOR *colorsp, short numcolors);
XVTDLL short xvt_palet_add_colors_from_image(XVT_PALETTE palet, XVT_IMAGE image);
XVTDLL XVT_PALETTE xvt_palet_create(XVT_PALETTE_TYPE type, XVT_PALETTE_ATTR reserved);
XVTDLL void xvt_palet_destroy(XVT_PALETTE palet);
XVTDLL short xvt_palet_get_colors(XVT_PALETTE palet, COLOR *colorsp, short maxcolors);
XVTDLL short xvt_palet_get_ncolors(XVT_PALETTE palet);
XVTDLL int xvt_palet_get_tolerance(XVT_PALETTE p);
XVTDLL void xvt_palet_set_tolerance(XVT_PALETTE p, int t);
XVTDLL void xvt_print_close(void);
XVTDLL BOOLEAN xvt_print_close_page(PRINT_RCD *precp);
XVTDLL PRINT_RCD* xvt_print_create(int *sizep);
XVTDLL PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name); // Added by Aga
XVTDLL int xvt_print_get_name(const PRINT_RCD *precp, char* name, int sz_s); // Added by Aga
XVTDLL int xvt_print_set_name(PRINT_RCD* precp, const char* name); // Added by Aga
XVTDLL WINDOW xvt_print_create_win(PRINT_RCD *precp, const char* title);
XVTDLL void xvt_print_destroy(PRINT_RCD *precp);
XVTDLL RCT* xvt_print_get_next_band(void);
XVTDLL BOOLEAN xvt_print_is_valid(const PRINT_RCD *precp);
XVTDLL BOOLEAN xvt_print_open(void);
XVTDLL BOOLEAN xvt_print_start_thread (BOOLEAN (* print_fcn)(long), long data);
XVTDLL BOOLEAN xvt_print_open_page(PRINT_RCD *precp);
// Added XVAGA
XVTDLL SLIST xvt_print_list_devices();
XVTDLL BOOLEAN xvt_print_set_default_device(const char* name);
XVTDLL BOOLEAN xvt_print_get_default_device(char* name, int namesize);
XVTDLL BOOLEAN xvt_print_suspend_thread();
XVTDLL BOOLEAN xvt_print_restart_thread();
XVTDLL BOOLEAN xvt_print_is_pdf(const PRINT_RCD* precp);
XVTDLL BOOLEAN xvt_print_pdf_version(char* version, int size);
XVTDLL void xvt_rect_deflate(RCT *rctp, short ix, short iy);
XVTDLL int xvt_rect_get_height(const RCT *rctp);
XVTDLL int xvt_rect_get_width(const RCT *rctp);
XVTDLL BOOLEAN xvt_rect_has_point(const RCT *rctp, PNT pnt);
XVTDLL void xvt_rect_inflate(RCT *rctp, short ix, short iy);
XVTDLL BOOLEAN xvt_rect_intersect(RCT *drctp, const RCT *rctp1, const RCT *rctp2);
XVTDLL BOOLEAN xvt_rect_is_empty(const RCT *rctp);
XVTDLL void xvt_rect_offset(RCT *rctp, short dh, short dv);
XVTDLL void xvt_rect_set(RCT *rctp, short left, short top, short right, short bottom);
XVTDLL void xvt_rect_set_empty(RCT *rctp);
XVTDLL void xvt_rect_set_null(RCT* rctp);
XVTDLL BOOLEAN xvt_rect_set_pos(RCT *rctp, PNT pos);
XVTDLL void xvt_res_free_menu_tree(MENU_ITEM* tree);
XVTDLL XVT_FNTID xvt_res_get_font(int rid);
XVTDLL XVT_IMAGE xvt_res_get_icon(int rid);
XVTDLL XVT_IMAGE xvt_res_get_image(int rid);
XVTDLL MENU_ITEM* xvt_res_get_menu(int rid);
XVTDLL char* xvt_res_get_str(int rid, char *s, int sz_s);
XVTDLL int xvt_sbar_get_pos(WINDOW win, SCROLL_TYPE t);
XVTDLL int xvt_sbar_get_proportion(WINDOW win, SCROLL_TYPE t);
XVTDLL void xvt_sbar_get_range(WINDOW win, SCROLL_TYPE t, int *minp, int *maxp);
XVTDLL void xvt_sbar_set_pos(WINDOW win, SCROLL_TYPE t, int pos);
XVTDLL void xvt_sbar_set_proportion(WINDOW win, SCROLL_TYPE t, int proportion);
XVTDLL void xvt_sbar_set_range(WINDOW win, SCROLL_TYPE t, int min, int max);
XVTDLL void xvt_scr_beep(void);
XVTDLL WINDOW xvt_scr_get_focus_topwin(void);
XVTDLL WINDOW xvt_scr_get_focus_vobj(void);
XVTDLL SLIST xvt_scr_list_wins();
XVTDLL void xvt_scr_reset_busy_cursor();
XVTDLL void xvt_scr_set_busy_cursor();
XVTDLL void xvt_scr_set_focus_vobj(WINDOW win);
XVTDLL BOOLEAN xvt_slist_add_at_elt(SLIST x, SLIST_ELT e, const char *sx, long data);
XVTDLL int xvt_slist_count(SLIST x);
XVTDLL SLIST xvt_slist_create();
XVTDLL void xvt_slist_destroy(SLIST list);
XVTDLL char* xvt_slist_get(SLIST x, SLIST_ELT e, long *datap);
XVTDLL long* xvt_slist_get_data(SLIST_ELT elt);
XVTDLL SLIST_ELT xvt_slist_get_first(SLIST list);
XVTDLL SLIST_ELT xvt_slist_get_next(SLIST list, SLIST_ELT item);
XVTDLL SLIST_ELT xvt_slist_find_str(SLIST list, const char* str); // Cerca una stringa all'interno di una SLIST
XVTDLL BOOLEAN xvt_fsys_fupdate(const char* src, const char* dst); // Aggiorna il file dst se più vecchio di src
XVTDLL int xvt_str_compare_ignoring_case (const char* s1, const char* s2);
XVTDLL int xvt_str_encode(const char* text, char* cypher, int mode);
XVTDLL int xvt_str_decode(const char* cypher, char* text, int mode);
XVTDLL int xvt_str_base64_encode(const char *name, char *cypher);
XVTDLL int xvt_str_base64_decode(const char *cypher, long len, unsigned char *text);
XVTDLL size_t xvt_str_base64_len(size_t len);
XVTDLL char* xvt_str_duplicate(const char* str);
XVTDLL BOOLEAN xvt_str_match(const char* str, const char* pat, BOOLEAN case_sensitive);
XVTDLL double xvt_str_fuzzy_compare (const char* s1, const char* s2);
XVTDLL double xvt_str_fuzzy_compare_ignoring_case(const char* s1, const char* s2);
XVTDLL void xvt_str_make_upper(char* str);
XVTDLL void xvt_str_make_lower(char* str);
XVTDLL BOOLEAN xvt_str_md5(const char* instr, char* outstr32);
XVTDLL char* xvt_str_number_format(char* str, int size);
XVTDLL BOOLEAN xvt_str_same(const char* s1, const char* s2);
XVTDLL char * xvt_str_exec_dir();
XVTDLL XVT_TREEVIEW_NODE xvt_treeview_add_child_node(WINDOW win,
XVT_TREEVIEW_NODE parent, XVT_TREEVIEW_NODE_TYPE type,
XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image,
const char* string, XVT_TREEVIEW_CALLBACK callback, const char* data);
XVTDLL WINDOW xvt_treeview_create(WINDOW parent_win,
RCT * rct_p, char * title, long ctl_flags, long app_data, int ctl_id,
XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image,
long attrs, int line_height);
XVTDLL void xvt_treeview_destroy_node(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL BOOLEAN xvt_treeview_enable_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN on);
XVTDLL BOOLEAN xvt_treeview_expand_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN recurse);
XVTDLL XVT_TREEVIEW_NODE xvt_treeview_find_node_string(WINDOW win, const char* text);
XVTDLL XVT_TREEVIEW_NODE xvt_treeview_get_child_node(WINDOW win, XVT_TREEVIEW_NODE parent_node, int position);
XVTDLL const char* xvt_treeview_get_node_data(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL XVT_TREEVIEW_NODE xvt_treeview_get_root_node(WINDOW win);
XVTDLL XVT_TREEVIEW_NODE xvt_treeview_get_selected_node(WINDOW win);
XVTDLL SLIST xvt_treeview_get_selected_list(WINDOW win);
XVTDLL BOOLEAN xvt_treeview_remove_child_node(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL BOOLEAN xvt_treeview_remove_node_children(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL void xvt_treeview_resume(WINDOW win);
XVTDLL void xvt_treeview_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel);
XVTDLL void xvt_treeview_set_node_bold(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN bold);
XVTDLL void xvt_treeview_set_node_images(WINDOW win, XVT_TREEVIEW_NODE node,
XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image);
XVTDLL void xvt_treeview_set_node_string(WINDOW win, XVT_TREEVIEW_NODE node, const char* text);
XVTDLL void xvt_treeview_suspend(WINDOW win);
XVTDLL BOOLEAN xvt_chr_is_digit(int c);
XVTDLL BOOLEAN xvt_chr_is_alpha(int c);
XVTDLL BOOLEAN xvt_chr_is_alnum(int c);
// System calls by XVAGA
XVTDLL void xvt_sys_beep(int severity);
XVTDLL long xvt_sys_close_children(WINDOW win);
XVTDLL long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask);
XVTDLL long xvt_sys_execute_in_window(const char* cmdline, WINDOW win);
XVTDLL BOOLEAN xvt_sys_kill(long pid);
XVTDLL const char * xvt_sys_command();
typedef XVT_CALLCONV_TYPEDEF(int, XVT_MULTITHREAD_CALLBACK, (void* pCaller, void* pData, int i, int tot) );
XVTDLL BOOLEAN xvt_sys_multithread(XVT_MULTITHREAD_CALLBACK callback, void* pCaller, void* pData, int tot, const char* msg);
XVTDLL BOOLEAN xvt_sys_get_host_name(char* name, int maxlen);
XVTDLL BOOLEAN xvt_sys_get_user_name(char* name, int maxlen);
XVTDLL BOOLEAN xvt_sys_goto_url(const char* url, const char* action);
XVTDLL int xvt_sys_dongle_server_running();
XVTDLL BOOLEAN xvt_sys_find_editor(const char* file, char* editor);
XVTDLL BOOLEAN xvt_sys_get_env(const char* varname, char* value, int max_size);
XVTDLL void xvt_sys_set_oem(int oem);
XVTDLL long xvt_sys_get_oem_int(const char* name, long defval);
XVTDLL int xvt_sys_get_oem_string(const char* name, const char* defval, char* value, int maxsize);
XVTDLL long xvt_sys_get_profile_int(const char* file, const char* paragraph, const char* name, long defval);
XVTDLL int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
const char* defval, char* value, int maxsize);
XVTDLL BOOLEAN xvt_sys_set_profile_int(const char* file, const char* paragraph, const char* name, long value);
XVTDLL BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name, const char* value);
XVTDLL BOOLEAN xvt_sys_remove_profile_string(const char* file, const char* paragraph, const char* name);
XVTDLL int xvt_sys_get_session_id();
XVTDLL unsigned long xvt_sys_get_free_memory();
XVTDLL unsigned long xvt_sys_get_free_memory_kb();
XVTDLL int xvt_sys_get_os_version();
XVTDLL BOOLEAN xvt_sys_is_pda();
XVTDLL int xvt_sys_get_version(char* os_version, char* ptk_version, int maxsize);
XVTDLL unsigned int xvt_sys_load_icon(const char* file);
XVTDLL void xvt_sys_sleep(unsigned long msec);
XVTDLL void xvt_sys_search_env(const char* filename, const char* varname, char* pathname);
XVTDLL BOOLEAN xvt_sys_set_env(const char* varname, const char* value);
XVTDLL void xvt_sys_sorry_box(const char* func, const char* file, int line);
XVTDLL void xvt_sys_deprecated_box(const char* oldfunc, const char* file, const char* newfunc);
XVTDLL struct tm* xvt_time_now();
XVTDLL long xvt_timer_create(WINDOW win, long interval);
XVTDLL void xvt_timer_destroy(long id);
XVTDLL WINDOW xvt_trayicon_create(WINDOW owner, short icon, const char* tooltip);
XVTDLL void xvt_trayicon_destroy(WINDOW tray);
XVTDLL void xvt_vobj_destroy(WINDOW win);
XVTDLL long xvt_vobj_get_attr(WINDOW win, long data);
XVTDLL RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp);
XVTDLL long xvt_vobj_get_data(WINDOW win);
XVTDLL RCT* xvt_vobj_get_outer_rect(WINDOW win, RCT *rctp);
XVTDLL XVT_PALETTE xvt_vobj_get_palet(WINDOW win);
XVTDLL WINDOW xvt_vobj_get_parent(WINDOW win);
XVTDLL char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title);
XVTDLL WIN_TYPE xvt_vobj_get_type(WINDOW win);
XVTDLL BOOLEAN xvt_vobj_is_focusable(WINDOW win);
XVTDLL BOOLEAN xvt_vobj_is_valid(WINDOW win);
XVTDLL void xvt_vobj_maximize(WINDOW win); // Added by XVAGA
XVTDLL void xvt_vobj_minimize(WINDOW win); // Added by XVAGA
XVTDLL BOOLEAN xvt_vobj_maximized(WINDOW win); // Added by XVAGA
XVTDLL void xvt_vobj_hide(WINDOW win); // Added by XVAGA
XVTDLL void xvt_vobj_show(WINDOW win); // Added by XVAGA
XVTDLL BOOLEAN xvt_vobj_shown(WINDOW win); // Added by XVAGA
XVTDLL void xvt_vobj_move(WINDOW win, const RCT* rctp);
XVTDLL void xvt_vobj_raise(WINDOW win);
XVTDLL void xvt_vobj_set_attr(WINDOW win, long data, long value);
XVTDLL void xvt_vobj_set_data(WINDOW win, long AppData);
XVTDLL void xvt_vobj_set_enabled(WINDOW win, BOOLEAN enabled);
XVTDLL void xvt_vobj_set_palet(WINDOW win, XVT_PALETTE palet);
XVTDLL void xvt_vobj_set_title(WINDOW win, const char* title);
XVTDLL void xvt_vobj_set_visible(WINDOW win, BOOLEAN show);
XVTDLL void xvt_vobj_translate_points(WINDOW from_win, WINDOW to_win, PNT *pntp, int npnts);
XVTDLL WINDOW xvt_win_create(WIN_TYPE wtype, const RCT* rct_p, const char* title, int menu_rid, WINDOW parent_win, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data);
XVTDLL long xvt_win_dispatch_event(WINDOW win, EVENT* event_p);
XVTDLL BOOLEAN xvt_win_enum_wins(WINDOW parent_win, XVT_ENUM_CHILDREN func, long data, unsigned long reserved);
XVTDLL long xvt_win_get_children_count(WINDOW parent_win);
XVTDLL void xvt_win_post_event(WINDOW win, EVENT* event_p); // Added by XVAGA
XVTDLL void xvt_win_release_pointer(void);
XVTDLL void xvt_win_set_caret_size(WINDOW win, int width, int height);
XVTDLL void xvt_win_set_caret_pos(WINDOW win, PNT p);
XVTDLL void xvt_win_set_caret_visible(WINDOW win, BOOLEAN on);
XVTDLL void xvt_win_set_cursor(WINDOW win, CURSOR Cursor);
XVTDLL void xvt_win_set_handler(WINDOW win, EVENT_HANDLER eh);
XVTDLL void xvt_win_trap_pointer(WINDOW win);
XVTDLL BOOLEAN xvt_win_is_taskbar_visible();
// Added by XVAGA
#ifndef UNDEF_TASK
XVTDLL const char ** xvt_task_get_list(int & ntasks);
XVTDLL int xvt_task_get_instances(const char * task);
#endif
XVTDLL BOOLEAN xvt_pane_add(WINDOW parent, WINDOW pane, const char* name, int dock, int flags);
XVTDLL BOOLEAN xvt_pane_change_flags(WINDOW pane, int set, int reset);
XVTDLL BOOLEAN xvt_pane_detach(WINDOW pane);
XVTDLL BOOLEAN xvt_pane_manager_load_perspective(WINDOW win, const char* str);
XVTDLL int xvt_pane_manager_save_perspective(WINDOW win, char* str, int max_size);
XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW pane, int min_size, int best_size, int max_size);
XVTDLL BOOLEAN xvt_pane_set_title(WINDOW pane, const char* title);
XVTDLL BOOLEAN xvt_sign_file(const char* input_file, char* output_file);
XVTDLL BOOLEAN xvt_sign_start();
XVTDLL BOOLEAN xvt_sign_stop();
XVTDLL BOOLEAN xvt_sign_test(const char* input_file);
typedef int ODBC_CALLBACK(void*, int, char**, char**);
XVTDLL XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir);
XVTDLL BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle);
XVTDLL ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly);
XVTDLL BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size);
XVTDLL BOOLEAN xvt_odbc_log_file(XVT_ODBC handle, const char* str);
XVTDLL BOOLEAN xvt_sql_begin(XVT_SQLDB handle);
XVTDLL BOOLEAN xvt_sql_close(XVT_SQLDB handle);
XVTDLL BOOLEAN xvt_sql_commit(XVT_SQLDB handle);
XVTDLL BOOLEAN xvt_sql_driver(XVT_SQLDB handle, char* str, int max_size);
XVTDLL ULONG xvt_sql_execute(XVT_SQLDB handle, const char* sql, ODBC_CALLBACK cb, void* jolly);
XVTDLL SLIST xvt_sql_list_fields(XVT_SQLDB handle, const char* table);
XVTDLL SLIST xvt_sql_list_tables(XVT_SQLDB handle);
XVTDLL const char * xvt_sql_field_type(XVT_SQLDB handle, const char* table, const char* field);
XVTDLL XVT_SQLDB xvt_sql_open(const char* dsn, const char* usr, const char* pwd, const char* dir);
XVTDLL BOOLEAN xvt_sql_rollback(XVT_SQLDB handle);
XVTDLL BOOLEAN xvt_sql_table_exists(XVT_SQLDB handle, const char* name);
typedef BOOLEAN PROP_CALLBACK(WINDOW win, XVT_TREEVIEW_NODE node, void* app_data);
XVTDLL XVT_TREEVIEW_NODE xvt_prop_add(WINDOW win, const char* type, const char* name, const char* value, const char* label);
XVTDLL XVT_TREEVIEW_NODE xvt_prop_current(WINDOW win);
XVTDLL XVT_TREEVIEW_NODE xvt_prop_find(WINDOW win, const char* name);
XVTDLL void xvt_prop_fit_columns(WINDOW win);
XVTDLL BOOLEAN xvt_prop_for_each(WINDOW win, PROP_CALLBACK pcb, void* jolly);
XVTDLL int xvt_prop_get_data(WINDOW win, XVT_TREEVIEW_NODE node, char* value, int maxlen);
XVTDLL int xvt_prop_get_string(WINDOW win, XVT_TREEVIEW_NODE node, char* label, int maxlen);
XVTDLL int xvt_prop_get_type(WINDOW win, XVT_TREEVIEW_NODE node, char* type, int maxlen);
XVTDLL BOOLEAN xvt_prop_remove(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL BOOLEAN xvt_prop_restart(WINDOW win);
XVTDLL BOOLEAN xvt_prop_set_data(WINDOW win, XVT_TREEVIEW_NODE node, const char* value);
XVTDLL BOOLEAN xvt_prop_set_read_only(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN ro);
XVTDLL BOOLEAN xvt_prop_suspend(WINDOW win);
XVTDLL XVT_TREEVIEW_NODE xvt_treelist_add_child_node(WINDOW win,
XVT_TREEVIEW_NODE parent, XVT_TREEVIEW_NODE_TYPE type,
XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image,
const char* string, XVT_TREEVIEW_CALLBACK callback, const char* data);
XVTDLL WINDOW xvt_treelist_create(WINDOW parent_win,
RCT * rct_p, char * title, long ctl_flags, long app_data, int ctl_id,
XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image,
long attrs, int line_height);
XVTDLL void xvt_treelist_destroy_node(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL BOOLEAN xvt_treelist_enable_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN on);
XVTDLL BOOLEAN xvt_treelist_expand_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN recurse);
XVTDLL XVT_TREEVIEW_NODE xvt_treelist_find_node_string(WINDOW win, const char* text);
XVTDLL XVT_TREEVIEW_NODE xvt_treelist_get_child_node(WINDOW win, XVT_TREEVIEW_NODE parent_node, int position);
XVTDLL const char* xvt_treelist_get_node_data(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL XVT_TREEVIEW_NODE xvt_treelist_get_root_node(WINDOW win);
XVTDLL XVT_TREEVIEW_NODE xvt_treelist_get_selected_node(WINDOW win);
XVTDLL SLIST xvt_treelist_get_selected_list(WINDOW win);
XVTDLL BOOLEAN xvt_treelist_remove_child_node(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL BOOLEAN xvt_treelist_remove_node_children(WINDOW win, XVT_TREEVIEW_NODE node);
XVTDLL void xvt_treelist_resume(WINDOW win);
XVTDLL void xvt_treelist_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel);
XVTDLL void xvt_treelist_set_node_bold(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN bold);
XVTDLL void xvt_treelist_set_node_images(WINDOW win, XVT_TREEVIEW_NODE node,
XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image);
XVTDLL void xvt_treelist_set_node_string(WINDOW win, XVT_TREEVIEW_NODE node, const char* text);
XVTDLL void xvt_treelist_suspend(WINDOW win);
XVTDLL BOOLEAN xvt_url_valid(const char * url);
XVTDLL BOOLEAN xvt_url_get(const char * url, const char * path, const char * outfile);
XVTDLL void xvt_set_mail_params(const char * smtp, const char * port, const char * user, const char * pass, const char * from);
// Send email using normal methods
// flags 0x1=UI; 0x2=Receipt
XVTDLL BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn, const char* subject,
const char* msg, const char* attach, short flags);
// Send email using Microsoft Powershell
XVTDLL BOOLEAN xvt_powermail_send(const char* to, const char* cc, const char* ccn,
const char* subject, const char* msg, const char* attach, short flags, const char* usr); // 0x1=UI; 0x2=Receipt
XVTDLL BOOLEAN xvt_wx_mail_send(const char* to, const char* cc, const char* ccn, const char* subject,
const char* msg, const char* attach, short flags);
XVTDLL short xvt_mail_installed();
XVTDLL void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down);
XVTDLL int xvt_net_get_status();
XVTDLL int xvt_xslt_transform(const char * infile, const char * stylefile, const char * outfile); // Added by AGA
#ifdef __cplusplus
}
#endif
#define SORRY_BOX() xvt_sys_sorry_box(__FUNCTION__, __FILE__, __LINE__)
#ifdef NDEBUG
#define DEPRECATED_BOX(newfunc)
#else
#define DEPRECATED_BOX(newfunc) xvt_sys_deprecated_box(__FUNCTION__, __FILE__, newfunc)
#endif
#endif

538
src/xvaga01/xvt_defs.h Normal file
View File

@ -0,0 +1,538 @@
/****************************************************************************
*
* Copyright 1987-1996 XVT Software. All rights reserved.
* May be used only in accordance with a valid Source Code License
* Agreement with XVT Software.
*
* $RCSfile: xvt_defs.h,v $
* $Revision: 1.11.2.2 $
*
* Purpose: Global XVT macro definitions.
*
****************************************************************************/
#ifndef XVT_INCL_DEFS
#define XVT_INCL_DEFS
/*---------------------------------------------------------------------------
Resource ID constants
---------------------------------------------------------------------------*/
/* DECLINING usage: Do not rely on MENU_BAR_RID, as support for it may
* be discontinued in a future release */
#define MENU_BAR_RID 9001 /* ID for default menubar resource */
#define ICON_RSRC 9012
#define DB_ABOUT 9050
#define DB_ASK 9051
#define DB_ERROR 9052
#define DB_NOTE 9053
#define DB_OPEN 9054
#define DB_ABORT 9055
#define DB_SAVE 9056
#define DB_HELPTOPICS 9057
#define DB_HELPTEXT 9058
#define DB_RESPONSE 9059
#define DB_WARNING 9060
#define DB_FONTSEL 9061
/* Number 9062 reserved for XVT/Mac FontSize dialog */
#define STR_HELPTYPE 40000 /* string resource for help file-type */
/* Define the beginning of the common code and K layer string resources */
/* The maximum reserved string res ID is 32767 */
#define XVT_STRING_RES_BASE 30000
#define XVTV_STRING_RES_BASE XVT_STRING_RES_BASE + 1300
/*---------------------------------------------------------------------------
Standard dialog pushbutton control IDs
---------------------------------------------------------------------------*/
#define DLG_OK 1 /* default button was clicked */
#define DLG_YES DLG_OK /* synonym */
#define DLG_CANCEL 2 /* cancel button was clicked */
#define DLG_OUTLINE 3 /* ID of userItem on Mac (internal use) */
#define DLG_NO 4 /* other button was clicked */
/*---------------------------------------------------------------------------
Colors
---------------------------------------------------------------------------*/
#ifndef COLOR_RED
#define COLOR_RED 0x01FF0000L
#endif
#ifndef COLOR_GREEN
#define COLOR_GREEN 0x0200FF00L
#endif
#ifndef COLOR_BLUE
#define COLOR_BLUE 0x030000FFL
#endif
#ifndef COLOR_CYAN
#define COLOR_CYAN 0x0400FFFFL
#endif
#ifndef COLOR_MAGENTA
#define COLOR_MAGENTA 0x05FF00FFL
#endif
#ifndef COLOR_YELLOW
#define COLOR_YELLOW 0x06FFFF00L
#endif
#ifndef COLOR_BLACK
#define COLOR_BLACK 0x07000000L
#endif
#ifndef COLOR_DKGRAY
#define COLOR_DKGRAY 0x08404040L
#endif
#ifndef COLOR_GRAY
#define COLOR_GRAY 0x09808080L
#endif
#ifndef COLOR_LTGRAY
#define COLOR_LTGRAY 0x0AC0C0C0L
#endif
#ifndef COLOR_WHITE
#define COLOR_WHITE 0x0BFFFFFFL
#endif
#define COLOR_INVALID ((COLOR)~0)
/*---------------------------------------------------------------------------
String and Character Constants
---------------------------------------------------------------------------*/
#define XVT_MAX_MB_SIZE XVTK_MAX_MB_SIZE
/*---------------------------------------------------------------------------
Key codes
---------------------------------------------------------------------------*/
#define K_DEL 127 /* delete (same as ASCII) */
#define K_UP 301 /* up arrow */
#define K_DOWN 302 /* down arrow */
#define K_RIGHT 303 /* right arrow */
#define K_LEFT 304 /* left arrow */
#define K_PREV 305 /* previous screen */
#define K_NEXT 306 /* next screen */
#define K_LHOME 307 /* line home */
#define K_LEND 308 /* line end */
#define K_HOME 309 /* home */
#define K_END 310 /* end */
#define K_INS 312 /* insert */
#define K_WLEFT 313 /* word left */
#define K_WRIGHT 314 /* word right */
#define K_BTAB 315 /* back tab */
#define K_HELP 316 /* help */
#define K_CLEAR 317 /* clear */
#define K_KP0 318 /* keypad '0' */
#define K_KP1 319
#define K_KP2 320
#define K_KP3 321
#define K_KP4 322
#define K_KP5 323
#define K_KP6 324
#define K_KP7 325
#define K_KP8 326
#define K_KP9 327 /* keypad '9' */
#define K_COPY 328 /* copy */
#define K_CUT 329 /* cut */
#define K_PASTE 330 /* paste */
#define K_F1 331 /* function key 1 */
#define K_F2 332
#define K_F3 333
#define K_F4 334
#define K_F5 335
#define K_F6 336
#define K_F7 337
#define K_F8 338
#define K_F9 339
#define K_F10 340
#define K_F11 341
#define K_F12 342
#define K_F13 343
#define K_F14 344
#define K_F15 345 /* function key 15 */
#define K_F16 346
#define K_F17 347
#define K_F18 348
#define K_F19 349
#define K_F20 350
#define K_F21 351
#define K_F22 352
#define K_F23 353
#define K_F24 354
#define K_KPMULT 372 /* keypad '*' */
#define K_KPSUB 373 /* keypad '-' */
#define K_KPADD 374 /* keypad '+' */
#define K_KPDIV 375 /* keypad '/' */
#define K_KPDOT 376 /* keypad '.' */
#define K_KPEQ 377 /* keypad '=' */
/*---------------------------------------------------------------------------
Text edit module
---------------------------------------------------------------------------*/
#define TX_READONLY 0x0001 /* text is not editable */
#define TX_WRAP 0x0002 /* wrap text to margin */
#define TX_AUTOVSCROLL 0x0004 /* autoscroll vertically */
#define TX_AUTOHSCROLL 0x0008 /* autoscroll horizontally */
#define TX_BORDER 0x0010 /* rectangular border */
#define TX_VSCROLLBAR 0x0020 /* vertical scroll bar */
#define TX_HSCROLLBAR 0x0040 /* horizontal scroll bar */
#define TX_ONEPAR 0x0080 /* one paragraph only (no \r) */
#define TX_NOCOPY 0x0100 /* no copy allowed */
#define TX_NOCUT 0x0200 /* no cut allowed */
#define TX_NOPASTE 0x0400 /* no paste allowed */
#define TX_NOMENU 0x0800 /* no edit menu changes */
#define TX_ENABLECLEAR 0x1000 /* leave CLEAR enabled always */
#define TX_OVERTYPE 0x2000 /* overtype mode */
#define TX_DISABLED 0x4000
#define TX_INVISIBLE 0x8000
/*---------------------------------------------------------------------------
Cursors
---------------------------------------------------------------------------*/
#define CURSOR_ARROW 0 /* arrow */
#define CURSOR_IBEAM 1 /* I-beam */
#define CURSOR_CROCE 2 /* cross hair (was CURSOR_CROSS)*/
#define CURSOR_PLUS 3 /* plus sign (fatter than cross hair) */
#define CURSOR_WAIT 4 /* waiting symbol (e.g., hourglass) */
#define CURSOR_HELP 5 /* help system */
#define CURSOR_USER 11 /* user defined shape (>= 11) */
/*---------------------------------------------------------------------------
Event masks
---------------------------------------------------------------------------*/
#define EM_NONE ((EVENT_MASK)0L)
#define EM_ALL ((EVENT_MASK)~0L)
#define EM_CREATE ((EVENT_MASK)(1L << E_CREATE))
#define EM_DESTROY ((EVENT_MASK)(1L << E_DESTROY))
#define EM_FOCUS ((EVENT_MASK)(1L << E_FOCUS))
#define EM_SIZE ((EVENT_MASK)(1L << E_SIZE))
#define EM_UPDATE ((EVENT_MASK)(1L << E_UPDATE))
#define EM_CLOSE ((EVENT_MASK)(1L << E_CLOSE))
#define EM_MOUSE_DOWN ((EVENT_MASK)(1L << E_MOUSE_DOWN))
#define EM_MOUSE_UP ((EVENT_MASK)(1L << E_MOUSE_UP))
#define EM_MOUSE_MOVE ((EVENT_MASK)(1L << E_MOUSE_MOVE))
#define EM_MOUSE_DBL ((EVENT_MASK)(1L << E_MOUSE_DBL))
#define EM_CHAR ((EVENT_MASK)(1L << E_CHAR))
#define EM_VSCROLL ((EVENT_MASK)(1L << E_VSCROLL))
#define EM_HSCROLL ((EVENT_MASK)(1L << E_HSCROLL))
#define EM_COMMAND ((EVENT_MASK)(1L << E_COMMAND))
#define EM_FONT ((EVENT_MASK)(1L << E_FONT))
#define EM_CONTROL ((EVENT_MASK)(1L << E_CONTROL))
#define EM_TIMER ((EVENT_MASK)(1L << E_TIMER))
#define EM_QUIT ((EVENT_MASK)(1L << E_QUIT))
#define EM_HELP ((EVENT_MASK)(1L << E_HELP))
#define EM_USER ((EVENT_MASK)(1L << E_USER))
#define EM_CXO ((EVENT_MASK)(1L << E_CXO))
/*---------------------------------------------------------------------------
XVT escape code value ranges
---------------------------------------------------------------------------*/
#define XVT_ESC_COMMON_BASE 8000
#define XVT_ESC_INTERNAL_BASE 30000
/*---------------------------------------------------------------------------
Control, window, and dialog creation flags
---------------------------------------------------------------------------*/
#define CTL_FLAG_DISABLED 0x00000001L
#define CTL_FLAG_CHECKED 0x00000004L
#define CTL_FLAG_DEFAULT 0x00000008L
#define CTL_FLAG_INVISIBLE 0x00000010L
#define CTL_FLAG_GROUP 0x00000020L
#define CTL_FLAG_MAC_MULTILINE 0x00000080L /* opt3 */
#define CTL_FLAG_MAC_WORDWRAP 0x00000100L /* opt4 */
#define CTL_FLAG_READONLY 0x00000200L
#define CTL_FLAG_MULTIPLE 0x00000400L
#define CTL_FLAG_MAC_GENEVA9 0x00000800L /* was opt1 */
#define CTL_FLAG_PM_SYSICON 0x00000800L
#define CTL_FLAG_MAC_MONACO9 0x00001000L /* was opt2 */
#define CTL_FLAG_NATIVE_JUST 0x0L /* default */
#define CTL_FLAG_LEFT_JUST 0x00002000L /* left text */
#define CTL_FLAG_CENTER_JUST 0x00004000L /* centered text */
#define CTL_FLAG_RIGHT_JUST 0x00008000L /* right justified text */
#define CTL_FLAG_PASSWORD 0x00010000L
/* Notebk specific flags */
#define CTL_FLAG_TAB_SQUARE 0x00000000L /* default */
#define CTL_FLAG_TAB_ROUND 0x00020000L
#define CTL_FLAG_TAB_DEFAULT 0x00000000L /* default */
#define CTL_FLAG_TAB_BOTTOM 0x00100000L
#define CTL_FLAG_TAB_LEFT 0x00200000L
#define CTL_FLAG_TAB_RIGHT 0x00400000L
#define CTL_FLAG_TAB_TOP 0x00800000L
#define WSF_NONE 0x00000000L
#define WSF_SIZE 0x00000001L /* is user sizeable */
#define WSF_CLOSE 0x00000002L /* is user closeable */
#define WSF_HSCROLL 0x00000004L /* has horz. scrolbar outside client area */
#define WSF_VSCROLL 0x00000008L /* has vert. scrolbar outside client area */
#define WSF_DECORATED 0x0000000FL /* all of above four flags */
#define WSF_INVISIBLE 0x00000010L /* is initially invisible */
#define WSF_DISABLED 0x00000020L /* is initially disabled */
#define WSF_FLOATING 0x00000040L /* is floating */
#define WSF_ICONIZABLE 0x00000080L
#define WSF_ICONIZED 0x00000100L /* is initially iconized */
#define WSF_SIZEONLY 0x00000200L /* lacks border rectangles (Mac only) */
#define WSF_NO_MENUBAR 0x00000800L /* has no menu bar of its own */
#define WSF_MAXIMIZED 0x00001000L /* initially maximized */
#define WSF_PLACE_EXACT 0x00002000L /* do not auto-place */
#define WSF_DEFER_MODAL 0x00008000L /* defer modal state for W_MODAL windows */
#define WSF_TRANSPARENT 0x00010000L /* trasparent */
#define WSF_NO_TASKBAR 0x00020000L /* No task bar icon */
#define DLG_FLAG_DISABLED 0x00000001L
#define DLG_FLAG_INVISIBLE 0x00000002L
/*---------------------------------------------------------------------------
Standard tool constants
---------------------------------------------------------------------------*/
#define TL_PEN_BLACK 1L
#define TL_PEN_HOLLOW 2L
#define TL_PEN_RUBBER 3L
#define TL_PEN_WHITE 4L
#define TL_PEN_DKGRAY 5L
#define TL_PEN_GRAY 6L
#define TL_PEN_LTGRAY 7L
#define TL_BRUSH_BLACK 0L
#define TL_BRUSH_WHITE 1L
/*---------------------------------------------------------------------------
Font support
---------------------------------------------------------------------------*/
/* Font style */
#define XVT_FS_NONE 0L
#define XVT_FS_BOLD (1L<<0)
#define XVT_FS_ITALIC (1L<<1)
#define XVT_FS_UNDERLINE (1L<<4)
#define XVT_FS_OUTLINE (1L<<5)
#define XVT_FS_SHADOW (1L<<6)
#define XVT_FS_INVERSE (1L<<7)
#define XVT_FS_BLINK (1L<<8)
#define XVT_FS_STRIKEOUT (1L<<9)
#define XVT_FS_USER1 (1L<<15)
#define XVT_FS_USER2 (1L<<16)
#define XVT_FS_USER3 (1L<<17)
#define XVT_FS_USER4 (1L<<18)
#define XVT_FS_USER5 (1L<<19)
#define XVT_FS_WILDCARD (1L<<25)
/* Font attribute type */
#define XVT_FA_FAMILY (XVT_FONT_ATTR_MASK)(1L<<0)
#define XVT_FA_SIZE (XVT_FONT_ATTR_MASK)(1L<<1)
#define XVT_FA_STYLE (XVT_FONT_ATTR_MASK)(1L<<2)
#define XVT_FA_NATIVE (XVT_FONT_ATTR_MASK)(1L<<3)
#define XVT_FA_APP_DATA (XVT_FONT_ATTR_MASK)(1L<<4)
#define XVT_FA_WIN (XVT_FONT_ATTR_MASK)(1L<<5)
#define XVT_FA_ALL (XVT_FONT_ATTR_MASK)~(0L)
/* Guaranteed support for these font families */
#ifdef WIN32
#define XVT_FFN_TIMES "Times New Roman"
#define XVT_FFN_HELVETICA "Arial"
#define XVT_FFN_COURIER "Courier New"
#define XVT_FFN_FIXED "Courier New"
#define XVT_FFN_SYSTEM "system"
#else
#define XVT_FFN_TIMES "times"
#define XVT_FFN_HELVETICA "helvetica"
#define XVT_FFN_COURIER "courier"
#define XVT_FFN_FIXED "fixed"
#define XVT_FFN_SYSTEM "system"
#endif
/* Convenience macro for identifying a NULL font id */
#define NULL_FNTID ((XVT_FNTID)NULL)
/*---------------------------------------------------------------------------
COLOR macros
---------------------------------------------------------------------------*/
/* allocated nbr of entries in image->v.cl8.clut */
#define XVT_CLUT_SIZE 256
#define XVT_PALETTE_SIZE 256
/* macros for COLOR values */
#define XVT_MAKE_COLOR(r,g,b) ((COLOR)((((ULONG)(r)&0xFF) << 16) | \
(((ULONG)(g)&0xFF) << 8) | \
(((ULONG)(b)&0xFF))))
#define XVT_COLOR_GET_RED(color) ((unsigned char)(((color) >> 16) & 0xFF))
#define XVT_COLOR_GET_GREEN(color) ((unsigned char)(((color) >> 8) & 0xFF))
#define XVT_COLOR_GET_BLUE(color) ((unsigned char)((color) & 0xFF))
/*---------------------------------------------------------------------------
File attributes
---------------------------------------------------------------------------*/
/* definitions for attributes used in the xvt_fsys_*_file_attr calls */
#define XVT_FILE_ATTR_MINIMUM 1L
#define XVT_FILE_ATTR_EXIST 1L
#define XVT_FILE_ATTR_READ 2L
#define XVT_FILE_ATTR_WRITE 3L
#define XVT_FILE_ATTR_EXECUTE 4L
#define XVT_FILE_ATTR_DIRECTORY 5L
#define XVT_FILE_ATTR_NUMLINKS 6L
#define XVT_FILE_ATTR_SIZE 7L
#define XVT_FILE_ATTR_ATIME 8L
#define XVT_FILE_ATTR_MTIME 9L
#define XVT_FILE_ATTR_CTIME 10L
#define XVT_FILE_ATTR_CREATORSTR 11L
#define XVT_FILE_ATTR_DIRSTR 12L
#define XVT_FILE_ATTR_FILESTR 13L
#define XVT_FILE_ATTR_TYPESTR 14L
#define XVT_FILE_ATTR_MAXIMUM 14L
/*---------------------------------------------------------------------------
Miscellaneous
---------------------------------------------------------------------------*/
#define XVT_TIMER_ERROR (-1L)
#define XVT_MAX_WINDOW_RECT ((RCT *)NULL)
#define DIR_TYPE "/\1\2\3" /* used with list_files */
#ifndef NULL
#define NULL 0L
#endif
#define NULL_WIN ((WINDOW)NULL)
#define NULL_PICTURE ((PICTURE)NULL)
#define NULL_PIXMAP ((XVT_PIXMAP)NULL)
#define NULL_PALETTE ((XVT_PALETTE)NULL)
#define NULL_IMAGE ((XVT_IMAGE)NULL)
#define NULL_TID ((XVT_HELP_TID)NULL)
#define NULL_TXEDIT NULL_WIN
#define BAD_TXEDIT NULL_TXEDIT
#define TASK_WIN ((WINDOW)xvt_vobj_get_attr(NULL_WIN, ATTR_TASK_WINDOW))
#define SCREEN_WIN ((WINDOW)xvt_vobj_get_attr(NULL_WIN, ATTR_SCREEN_WINDOW))
//#define PRINTER_WIN ((WINDOW)xvt_vobj_get_attr(NULL_WIN, ATTR_PRINTER_WINDOW)) // Guy optimization
#define PRINTER_WIN 883L
#define PTR_LONG(p) ((long)(char *)(p))
#ifndef max
#define max(x, y) ((x) > (y) ? (x) : (y))
#endif
#ifndef min
#define min(x, y) ((x) < (y) ? (x) : (y))
#endif
#define XVT_MAKE_VERSION(major, minor, patch) ((major)*10000L + (minor)*100L + (patch))
/*---------------------------------------------------------------------------
Attribute definitions for get/set_value()
Note that non-portable constants are defined by the platform header.
---------------------------------------------------------------------------*/
#define ATTR_BASE 0
/* system config attributes */
#define ATTR_BACK_COLOR (ATTR_BASE + 100)
#define ATTR_HAVE_COLOR (ATTR_BASE + 101)
#define ATTR_HAVE_MOUSE (ATTR_BASE + 102)
#define ATTR_NUM_TIMERS (ATTR_BASE + 103)
#define ATTR_XVT_CONFIG (ATTR_BASE + 104)
#define ATTR_DISPLAY_TYPE (ATTR_BASE + 105)
/* Object size attributes */
#define ATTR_CTL_BUTTON_HEIGHT (ATTR_BASE + 200)
#define ATTR_CTL_CHECKBOX_HEIGHT (ATTR_BASE + 201)
#define ATTR_CTL_EDIT_TEXT_HEIGHT (ATTR_BASE + 202)
#define ATTR_CTL_HORZ_SBAR_HEIGHT (ATTR_BASE + 203)
#define ATTR_CTL_VERT_SBAR_WIDTH (ATTR_BASE + 204)
#define ATTR_CTL_RADIOBUTTON_HEIGHT (ATTR_BASE + 205)
#define ATTR_CTL_STATIC_TEXT_HEIGHT (ATTR_BASE + 206)
#define ATTR_ICON_WIDTH (ATTR_BASE + 207)
#define ATTR_ICON_HEIGHT (ATTR_BASE + 208)
/* Predefined windows */
#define ATTR_SCREEN_WINDOW (ATTR_BASE + 300)
#define ATTR_TASK_WINDOW (ATTR_BASE + 301)
#define ATTR_PRINTER_WINDOW (ATTR_BASE + 302)
/* System metric attributes */
#define ATTR_SCREEN_HEIGHT (ATTR_BASE + 400)
#define ATTR_SCREEN_WIDTH (ATTR_BASE + 401)
#define ATTR_SCREEN_HRES (ATTR_BASE + 402)
#define ATTR_SCREEN_VRES (ATTR_BASE + 403)
#define ATTR_PRINTER_HEIGHT (ATTR_BASE + 404)
#define ATTR_PRINTER_WIDTH (ATTR_BASE + 405)
#define ATTR_PRINTER_HRES (ATTR_BASE + 406)
#define ATTR_PRINTER_VRES (ATTR_BASE + 407)
#define ATTR_DOC_STAGGER_HORZ (ATTR_BASE + 408)
#define ATTR_DOC_STAGGER_VERT (ATTR_BASE + 409)
/* Window metric attributes */
#define ATTR_DOCFRAME_WIDTH (ATTR_BASE + 500)
#define ATTR_DOCFRAME_HEIGHT (ATTR_BASE + 501)
#define ATTR_FRAME_WIDTH (ATTR_BASE + 502)
#define ATTR_FRAME_HEIGHT (ATTR_BASE + 503)
#define ATTR_DBLFRAME_WIDTH (ATTR_BASE + 504)
#define ATTR_DBLFRAME_HEIGHT (ATTR_BASE + 505)
#define ATTR_MENU_HEIGHT (ATTR_BASE + 506)
#define ATTR_TITLE_HEIGHT (ATTR_BASE + 507)
/* Window attributes */
#define ATTR_NATIVE_GRAPHIC_CONTEXT (ATTR_BASE + 601)
#define ATTR_NATIVE_WINDOW (ATTR_BASE + 602)
#define ATTR_PROPAGATE_NAV_CHARS (ATTR_BASE + 603)
/* Misc attributes */
#define ATTR_DEBUG_FILENAME (ATTR_BASE + 700)
#define ATTR_MALLOC_ERR_HANDLER (ATTR_BASE + 701) /* DECLINING */
#define ATTR_KEY_HOOK (ATTR_BASE + 702)
#define ATTR_EVENT_HOOK (ATTR_BASE + 703)
#define ATTR_SUPPRESS_UPDATE_CHECK (ATTR_BASE + 704)
#define ATTR_FATAL_ERR_HANDLER (ATTR_BASE + 705) /* DECLINING */
#define ATTR_ERRMSG_HANDLER (ATTR_BASE + 706)
#define ATTR_MEMORY_MANAGER (ATTR_BASE + 707)
#define ATTR_DEFAULT_PALETTE_TYPE (ATTR_BASE + 708)
#define ATTR_ERRMSG_FILENAME (ATTR_BASE + 709)
#define ATTR_HELP_HOOK (ATTR_BASE + 710)
#define ATTR_HELP_CONTEXT (ATTR_BASE + 711)
#define ATTR_COLLATE_HOOK (ATTR_BASE + 712)
#define ATTR_MULTIBYTE_AWARE (ATTR_BASE + 713)
#define ATTR_RESOURCE_FILENAME (ATTR_BASE + 714)
#define ATTR_APP_CTL_COLORS (ATTR_BASE + 715)
#define ATTR_APPL_NAME_RID (ATTR_BASE + 716)
#define ATTR_TASKWIN_TITLE_RID (ATTR_BASE + 717)
#define ATTR_R40_TXEDIT_BEHAVIOR (ATTR_BASE + 718)
#define ATTR_APP_CTL_FONT_RID (ATTR_BASE + 719)
#define ATTR_SPEECH_MODE (ATTR_BASE + 720) /* Added by Guy */
#define ATTR_APPL_VERSION_STRING (ATTR_BASE + 721) /* Added by Guy */
#define ATTR_APPL_ALREADY_RUNNING (ATTR_BASE + 722) /* Added by Guy */
#define ATTR_APPL_VERSION_YEAR (ATTR_BASE + 723) /* Added by Guy */
/* Font attributes */
#define ATTR_FONT_MAPPER (ATTR_BASE + 800)
#define ATTR_FONT_DIALOG (ATTR_BASE + 801)
#define ATTR_FONT_CACHE_SIZE (ATTR_BASE + 802)
/*---------------------------------------------------------------------------
Values for the "modifier" field of the E_CHAR event.
---------------------------------------------------------------------------*/
#define XVT_MOD_KEY_NONE 0L
#define XVT_MOD_KEY_SHIFT (1L<<1)
#define XVT_MOD_KEY_CTL (1L<<2)
#define XVT_MOD_KEY_ALT (1L<<3)
#define XVT_MOD_KEY_LSHIFT (1L<<4)
#define XVT_MOD_KEY_RSHIFT (1L<<5)
#define XVT_MOD_KEY_CMD (1L<<6)
#define XVT_MOD_KEY_OPTION (1L<<7)
#define XVT_MOD_KEY_COMPOSE (1L<<8)
#define XVT_MOD_KEY_LALT (1L<<9)
#define XVT_MOD_KEY_RALT (1L<<10)
#define XVT_MOD_KEY_ALTGRAF (1L<<11)
/*---------------------------------------------------------------------------
Values for the type XVT_COLOR_TYPE.
---------------------------------------------------------------------------*/
#define XVT_COLOR_NULL (XVT_COLOR_TYPE)(0L)
#define XVT_COLOR_FOREGROUND (XVT_COLOR_TYPE)(1L<<1)
#define XVT_COLOR_BACKGROUND (XVT_COLOR_TYPE)(1L<<2)
#define XVT_COLOR_BLEND (XVT_COLOR_TYPE)(1L<<3)
#define XVT_COLOR_HIGHLIGHT (XVT_COLOR_TYPE)(1L<<4)
#define XVT_COLOR_BORDER (XVT_COLOR_TYPE)(1L<<5)
#define XVT_COLOR_TROUGH (XVT_COLOR_TYPE)(1L<<6)
#define XVT_COLOR_SELECT (XVT_COLOR_TYPE)(1L<<7)
// Added by XVAGA
#define XVT_COLOR_CAPTIONLT (XVT_COLOR_TYPE)(1L<<8)
#define XVT_COLOR_CAPTIONDK (XVT_COLOR_TYPE)(1L<<9)
#define XVT_COLOR_CAPTIONTEXT (XVT_COLOR_TYPE)(1L<<10)
#define XVT_PDF_PRINTER_NAME "***AGAPDF***"
#endif /* XVT_INCL_DEFS */

77
src/xvaga01/xvt_env.h Normal file
View File

@ -0,0 +1,77 @@
#define XVT_CC_ENUM_END 127
#define XVT_OS_WIN32 400
#define XVT_OS_LINUX 595
#ifdef WIN32
#define XVT_OS XVT_OS_WIN32
#else
#define XVT_OS XVT_OS_LINUX
#endif
#define XVT_WS_LINUX 107
#define XVT_WS_WIN_95 301
#define XVT_WS_WIN_98 302
#define XVT_WS_WIN_ME 303
#define XVT_WS_WIN_NT 304
#define XVT_WS_WIN_2000 305
#define XVT_WS_WIN_XP 306
#define XVT_WS_WIN_2003 307
#define XVT_WS_WIN_VISTA 308
#define XVT_WS_WIN_2008 309
#define XVT_WS_WIN_2008R2 310
#define XVT_WS_WIN_7 311
#define XVT_WS_WIN_2012 312
#define XVT_WS_WIN_8 313
#define XVT_WS_WIN_10 314
#define XVT_WS_UNKNOWN 0
#define MACWS 100 /* Apple Macintosh */
#define PMWS 200 /* IBM OS/2 PM */
#define WIN32WS 300 /* MS Windows 3.1 for NT */
#define WIN16WS 400 /* MS Windows 3.x for Win16 */
#define WMWS 450 /* Character */
#define MTFWS 500 /* Motif */
#define XOLWS 501 /* Open Look */
#define WXGTKWS 107
#define NTWS WIN32WS /* for compatibility with docs */
#define WINWS WIN16WS /* for compatibility with docs */
#if defined(WIN32)
#define XVTWS WIN32WS
#elif defined(LINUX)
#define XVTWS WXGTKWS
#else
#define XVTWS XVT_WS_UNKNOWN
#endif
#define ATTR_WIN_BASE 10000
#define ATTR_WIN_CMD_LINE (ATTR_WIN_BASE + 0)
#define ATTR_WIN_INSTANCE (ATTR_WIN_BASE + 1)
#define ATTR_WIN_PREV_INSTANCE (ATTR_WIN_BASE + 2)
#define ATTR_WIN_MDI (ATTR_WIN_BASE + 3)
#define ATTR_WIN_FCN_PRINT_INIT (ATTR_WIN_BASE + 4)
#define ATTR_WIN_PM_CLASS_ICON (ATTR_WIN_BASE + 5)
#define ATTR_WIN_PM_DRAWABLE_TWIN (ATTR_WIN_BASE + 6)
#define ATTR_WIN_PM_SPECIAL_1ST_DOC (ATTR_WIN_BASE + 7)
#define ATTR_WIN_PM_NO_TWIN (ATTR_WIN_BASE + 8)
#define ATTR_WIN_PM_TWIN_STARTUP_DATA (ATTR_WIN_BASE + 9)
#define ATTR_WIN_PM_TWIN_STARTUP_MASK (ATTR_WIN_BASE + 10)
#define ATTR_WIN_PM_TWIN_STARTUP_RCT (ATTR_WIN_BASE + 11)
#define ATTR_WIN_PM_TWIN_STARTUP_STYLE (ATTR_WIN_BASE + 12)
#define ATTR_WIN_OPENFILENAME_HOOK (ATTR_WIN_BASE + 13)
#define ATTR_WIN_POPUP_DETACHED (ATTR_WIN_BASE + 14)
#define main xvt_main
/****************************************************************************
* Define Prototyping Information
****************************************************************************/
#define XVT_CC_ARGL(al__) (
#define XVT_CC_ARG(t__,a__) t__ a__,
#define XVT_CC_LARG(t__,a__) t__ a__)
#define XVT_CC_ARGS(al__) al__
#define XVT_CC_NOARGS() (void)
/* Default to no linkage conventions in callback typedef */
#define XVT_CALLCONV_TYPEDEF(ret, func, args) ret (*func)XVT_CC_ARGS(args)

280
src/xvaga01/xvt_help.h Normal file
View File

@ -0,0 +1,280 @@
/****************************************************************************
*
* Copyright 1987-1996 XVT Software. All rights reserved.
* May be used only in accordance with a valid Source Code License
* Agreement with XVT Software.
*
* $RCSfile: xvt_help.h,v $
* $Revision: 1.1 $
*
* Purpose: XVT help subsystem macros and types.
*
****************************************************************************/
#ifndef XVT_INCL_HELP
#define XVT_INCL_HELP
/*
* Help Versions
*/
#define XVT_HELP_VERSION_MAJOR 4
#define XVT_HELP_VERSION_MINOR 57
#define XVT_HELP_VERSION_PATCH 0
#define XVT_HELP_VERSION XVT_MAKE_VERSION(XVT_HELP_VERSION_MAJOR,XVT_HELP_VERSION_MINOR,XVT_HELP_VERSION_PATCH)
/*
* Types
*/
typedef struct s_xvt_help_info {long* fake;} *XVT_HELP_INFO;
#define NULL_HELP_INFO (XVT_HELP_INFO)0
typedef enum e_xvt_help_flavor
{
XVT_HELP_FLAVOR_NONE,
XVT_HELP_FLAVOR_NTVSRV,
XVT_HELP_FLAVOR_NTVBND,
XVT_HELP_FLAVOR_PORTSRV,
XVT_HELP_FLAVOR_PORTBND
} XVT_HELP_FLAVOR;
/*
* Help System Flags.
*/
/* for xvt_help_open_helpfile */
#define HSF_INDEX_ON_DISK 0x001L /* Default value is in-memory */
#define HSF_NO_TOPIC_WARNING 0x002L /* No warning for missing topics */
#define HSF_NO_HELPMENU_ASSOC 0x004L /* Don't associate topics to helpmenu */
#define HSF_APPNAME_TITLE 0x008L /* show APPNAME in title */
#define HSF_NO_BEEP_MODAL 0x010L /* don't beep for help on modal dialog*/
/* internal use, only */
#define HSF_EXIT_ON_CLOSE 0x020L /* exit when topic window closes */
/* for customization */
#define HSF_USER 0x040L
/*
* Reserved help topic IDs
*/
#define XVT_TPC_BASE 32000
#define XVT_TPC_HELPONHELP (XVT_TPC_BASE + 0)
#define XVT_TPC_INDEX (XVT_TPC_BASE + 1)
#define XVT_TPC_TUTORIAL (XVT_TPC_BASE + 2)
#define XVT_TPC_BASICSKILLS (XVT_TPC_BASE + 3)
#define XVT_TPC_PROCEDURES (XVT_TPC_BASE + 4)
#define XVT_TPC_KEYBOARD (XVT_TPC_BASE + 5)
#define XVT_TPC_CONTENTS (XVT_TPC_BASE + 6)
#define XVT_TPC_ABOUT (XVT_TPC_BASE + 7)
#define XVT_TPC_COMMANDS (XVT_TPC_BASE + 8)
#define XVT_TPC_GLOSSARY (XVT_TPC_BASE + 9)
#define XVT_TPC_ABOUTHELP (XVT_TPC_BASE + 10)
/* Motif specific */
#define XVT_TPC_ONHELP XVT_TPC_HELPONHELP
#define XVT_TPC_ONKEYS XVT_TPC_KEYBOARD
#define XVT_TPC_ONVERSION XVT_TPC_ABOUT
/* Other help menu item topics */
#define XVT_TPC_ONCONTEXT (XVT_TPC_BASE + 20)
#define XVT_TPC_SEARCH (XVT_TPC_BASE + 21)
#define XVT_TPC_ONWINDOW (XVT_TPC_BASE + 22)
#define XVT_TPC_OBJCLICK (XVT_TPC_BASE + 23)
/* predefined dialog topics */
#define XVT_TPC_FILE_OPEN (XVT_TPC_BASE + 30)
#define XVT_TPC_FILE_SAVE (XVT_TPC_BASE + 40)
#define XVT_TPC_ASK (XVT_TPC_BASE + 50)
#define XVT_TPC_NOTE (XVT_TPC_BASE + 60)
#define XVT_TPC_ERROR (XVT_TPC_BASE + 70)
#define XVT_TPC_WARNING (XVT_TPC_BASE + 80)
#define XVT_TPC_STRING_PROMPT (XVT_TPC_BASE + 90)
#define XVT_TPC_FONT_SEL (XVT_TPC_BASE + 100)
#define XVT_TPC_PAGE_SETUP (XVT_TPC_BASE + 110)
#define XVT_TPC_MESSAGE (XVT_TPC_BASE + 120)
#define XVT_TPC_FATAL (XVT_TPC_BASE + 130)
/* maximum predefined topic */
#define XVT_TPC_MAX (XVT_TPC_BASE + 130)
/*
* Resource-related macros.
*/
/*
* Help Menu Tags
*/
#define TagBASE M_HELP
#define M_HELP_HELPMENU (TagBASE + 0)
#define M_HELP_ONCONTEXT (TagBASE + 1)
#define M_HELP_HELPONHELP (TagBASE + 2)
#define M_HELP_ONWINDOW (TagBASE + 3)
#define M_HELP_KEYBOARD (TagBASE + 4)
#define M_HELP_INDEX (TagBASE + 5)
#define M_HELP_TUTORIAL (TagBASE + 6)
#define M_HELP_SEARCH (TagBASE + 7)
#define M_HELP_OBJCLICK (TagBASE + 8)
#define M_HELP_VERSION (TagBASE + 9)
#define M_HELP_GOTO (TagBASE + 10)
#define M_HELP_GLOSSARY (TagBASE + 11)
#define M_HELP_CONTENTS (TagBASE + 12)
/* internal use -- highest help tag */
#define M_HELP_LAST (TagBASE + 12)
#ifndef NO_HELP_RESOURCES
/*
* Help menu text strings.
*
* (Because of the Mac, these are numbered using even values.)
*/
#define HELP_STR_BASE XVTV_STRING_RES_BASE
#define TextHELPMENU (HELP_STR_BASE + 0)
#define TextONWINDOW (HELP_STR_BASE + 2)
#define TextHELPONHELP (HELP_STR_BASE + 4)
#define TextKEYBOARD (HELP_STR_BASE + 6)
#define TextINDEX (HELP_STR_BASE + 8)
#define TextCONTENTS (HELP_STR_BASE + 10)
#define TextTUTORIAL (HELP_STR_BASE + 12)
#define TextVERSION (HELP_STR_BASE + 14)
#define TextSEARCH (HELP_STR_BASE + 16)
#define TextONCONTEXT (HELP_STR_BASE + 18)
#define TextOBJCLICK (HELP_STR_BASE + 20)
/* Topic menubar navigate strings */
#define TextNAV_SEARCH (HELP_STR_BASE + 22)
#define TextNAV_GOTO (HELP_STR_BASE + 24)
#define TextNAV_MARK (HELP_STR_BASE + 26)
#define TextNAV_BACKLINK (HELP_STR_BASE + 28)
#define TextNAV_FORWLINK (HELP_STR_BASE + 30)
#define TextNAV_PREVPAGE (HELP_STR_BASE + 32)
#define TextNAV_NEXTPAGE (HELP_STR_BASE + 34)
/* General strings */
#define TextCLIP_ERR (HELP_STR_BASE + 36)
#define TextMEM_ERR (HELP_STR_BASE + 38)
#define TextCLIP_PUT_ERR (HELP_STR_BASE + 40)
#define TextPRINT_ERR (HELP_STR_BASE + 42)
#define TextPRINT_OK (HELP_STR_BASE + 44)
#define TextCLIP_OK (HELP_STR_BASE + 46)
#define TextTHREAD_INFO (HELP_STR_BASE + 48)
#define TextMARKED_INFO (HELP_STR_BASE + 50)
/* Copy selection window */
#define TextCOPYPART_NONE (HELP_STR_BASE + 52)
/* Some labels */
#define TextMARK (HELP_STR_BASE + 54)
#define TextUNMARK (HELP_STR_BASE + 56)
/* hyper link & hot link attribute strings */
#define TextHYPERLINK (HELP_STR_BASE + 60)
#define TextHOTLINK (HELP_STR_BASE + 62)
/*
* Define the local resource file constants
*/
/* Window, dialog identifiers */
#define HELP_RES_BASE 29500
#define TOPIC_WIN_RID (HELP_RES_BASE + 0)
#define GOTO_DLG_RID (HELP_RES_BASE + 3)
#define SEARCH_DLG_RID (HELP_RES_BASE + 4)
#define TOPIC_SELCOPY_RID (HELP_RES_BASE + 5)
#define HELPVIEW_ABOUT_RID (HELP_RES_BASE + 6)
/* Topic window menubar */
#define TOPICWIN_MENUBAR (HELP_RES_BASE + 10)
#define MHELP_FILE (HELP_RES_BASE + 11)
#define MHELP_FILE_PRINT_SETUP (HELP_RES_BASE + 12)
#define MHELP_FILE_PRINT (HELP_RES_BASE + 13)
#define MHELP_FILE_EXIT (HELP_RES_BASE + 14)
#define MHELP_EDIT (HELP_RES_BASE + 15)
#define MHELP_EDIT_COPY M_EDIT_COPY /* (HELP_RES_BASE + 16) */
#define MHELP_EDIT_AS_WRAPPED (HELP_RES_BASE + 17)
#define MHELP_NAV (HELP_RES_BASE + 18)
#define MHELP_NAV_SEARCH (HELP_RES_BASE + 19)
#define MHELP_NAV_GOTO (HELP_RES_BASE + 20)
#define MHELP_NAV_MARK (HELP_RES_BASE + 21)
#define MHELP_NAV_BACKLINK (HELP_RES_BASE + 22)
#define MHELP_NAV_FORWLINK (HELP_RES_BASE + 23)
#define MHELP_NAV_PREVPAGE (HELP_RES_BASE + 24)
#define MHELP_NAV_NEXTPAGE (HELP_RES_BASE + 25)
#define MHELP_HELP (HELP_RES_BASE + 26)
#define MHELP_HELP_ONHELP M_HELP_HELPONHELP
#define MHELP_HELP_ABOUT (HELP_RES_BASE + 27)
#define MHELP_EDIT_COPYPART (HELP_RES_BASE + 28)
/* Topic specific control identifiers */
#define TOPIC_SEARCH (HELP_RES_BASE + 30)
#define TOPIC_BOOKMARK (HELP_RES_BASE + 31)
#define TOPIC_GOTO (HELP_RES_BASE + 32)
#define TOPIC_BACKLINK (HELP_RES_BASE + 33)
#define TOPIC_FORWLINK (HELP_RES_BASE + 34)
#define TOPIC_VSCROLL (HELP_RES_BASE + 35)
#define TOPIC_INFOGROUP (HELP_RES_BASE + 36)
#define TOPIC_INFOLBL (HELP_RES_BASE + 37)
#define TOPIC_CLIENTW (HELP_RES_BASE + 38)
#define TOPIC_PREVPAGE (HELP_RES_BASE + 39)
#define TOPIC_NEXTPAGE (HELP_RES_BASE + 40)
/* Shared identifiers */
#define CLIENT_AREA (HELP_RES_BASE + 50)
/* Search dialog ids */
#define SEARCH_BY_TOPICNAME (HELP_RES_BASE + 60)
#define SEARCH_BY_KEYWORD (HELP_RES_BASE + 61)
#define SEARCH_SELECT_LIST (HELP_RES_BASE + 62)
#define SEARCH_MATCH_LIST (HELP_RES_BASE + 63)
#define SEARCH_GOTO_MATCH (HELP_RES_BASE + 64)
#define SEARCH_CANCEL DLG_CANCEL
#define SEARCH_RADIO_LBL (HELP_RES_BASE + 66)
#define SEARCH_ITEMS_LBL (HELP_RES_BASE + 67)
#define SEARCH_MATCH_LBL (HELP_RES_BASE + 68)
/* Goto dialog ids */
#define GOTO_CONTENTS M_HELP_CONTENTS
#define GOTO_INDEX M_HELP_INDEX
#define GOTO_CONTENTS M_HELP_CONTENTS
#define GOTO_GLOSSARY M_HELP_GLOSSARY
#define GOTO_KEYBOARD M_HELP_KEYBOARD
#define GOTO_BOOKMARK_LIST (HELP_RES_BASE + 70)
#define GOTO_BOOKMARK_BTN (HELP_RES_BASE + 71)
#define GOTO_CANCEL DLG_CANCEL
#define GOTO_GROUP (HELP_RES_BASE + 73)
#define GOTO_BOOK_LBL (HELP_RES_BASE + 74)
/* Popup window sample definition */
#define POPUP_WIN_RID (HELP_RES_BASE + 80)
/* Topic selection copy menubar */
#define EDITSEL_MENUBAR (HELP_RES_BASE + 90)
#define MHELP_TSE_EDIT (HELP_RES_BASE + 91)
#define MHELP_TSE_EDIT_COPY /* (HELP_RES_BASE + 92) */ M_EDIT_COPY
#define MHELP_TSE_HELP (HELP_RES_BASE + 93)
#define MHELP_TSE_HELP_ONHELP M_HELP_HELPONHELP
#define MHELP_TSE_HELP_ABOUT (HELP_RES_BASE + 94)
/* Other RID for selection copy window */
#define TOPIC_SELCOPY_WIN_TX (HELP_RES_BASE + 100)
#define TOPIC_SELCOPY_WIN_LBL (HELP_RES_BASE + 101)
/* RID's for viewer about box */
#define XHV_STATIC_1 (HELP_RES_BASE + 110)
#define XHV_STATIC_2 (HELP_RES_BASE + 111)
#endif /* NO_HELP_RESOURCES */
#endif /* XVT_INCL_HELP */

48
src/xvaga01/xvt_menu.h Normal file
View File

@ -0,0 +1,48 @@
/****************************************************************************
*
* Copyright 1987-1996 XVT Software. All rights reserved.
* May be used only in accordance with a valid Source Code License
* Agreement with XVT Software.
*
* $RCSfile: xvt_menu.h,v $
* $Revision: 1.2.6.1 $
*
* Purpose: XVT menu subsystem definitions.
*
****************************************************************************/
#ifndef XVT_INCL_XVT_MENU
#define XVT_INCL_XVT_MENU
#define MAX_MENU_TAG 31999 /* max allowable application menu tag */
#define M_FILE 32000
#define M_FILE_NEW (M_FILE+1)
#define M_FILE_OPEN (M_FILE+2)
#define M_FILE_CLOSE (M_FILE+3)
#define M_FILE_SAVE (M_FILE+4)
#define M_FILE_SAVE_AS (M_FILE+5)
#define M_FILE_REVERT (M_FILE+6)
#define M_FILE_PG_SETUP (M_FILE+7)
#define M_FILE_PRINT (M_FILE+8)
#define M_FILE_QUIT (M_FILE+9)
#define M_FILE_ABOUT (M_FILE+10)
#define M_FILE_PREVIEW (M_FILE+11)
#define M_EDIT 32025
#define M_EDIT_UNDO (M_EDIT+1)
#define M_EDIT_CUT (M_EDIT+2)
#define M_EDIT_COPY (M_EDIT+3)
#define M_EDIT_PASTE (M_EDIT+4)
#define M_EDIT_CLEAR (M_EDIT+5)
#define M_EDIT_SEL_ALL (M_EDIT+6)
#define M_EDIT_CLIPBOARD (M_EDIT+7)
#define M_FONT 32050 /* needs range of 300 for Mac */
#define M_STYLE 32350
#define M_HELP 32450 /* reserve about 50 for Help */
#define M_DEFAULT_SEPARATOR 32765 /* indicates no tag value set */
#define FONT_MENU_TAG 32766 /* magic cookie */
/* XVT/Mac reserves 32767 */
#endif /* XVT_INCL_XVT_MENU */

417
src/xvaga01/xvt_sql.cpp Normal file
View File

@ -0,0 +1,417 @@
#include "wxinc.h"
#include "xvt.h"
#include "../wxSqlite3/wxSqlite3.h"
class XVT_SQLDataBase
{
public:
virtual bool Open(const char* dsn, const char* usr, const char* pwd, const char* dir) = 0;
virtual bool Close() = 0 { return false; }
virtual bool IsOk() const = 0 { return false; }
virtual ULONG Execute(const char* sql, ODBC_CALLBACK cb, void* jolly) = 0;
virtual SLIST ListFields(const char* table) const = 0;
virtual SLIST ListTables() const = 0;
virtual wxString FindField(const char* strTable, const char* strField) const = 0;
virtual bool TableExists(const char* name) const;
virtual bool Begin() const { return false; }
virtual bool Commit() const { return false; }
virtual bool Rollback() const { return false; }
virtual ~XVT_SQLDataBase() { Close(); }
};
bool XVT_SQLDataBase::TableExists(const char* name) const
{
bool yes = false;
SLIST list = ListTables();
for (SLIST_ELT e = xvt_slist_get_first(list); e != NULL && !yes; e = xvt_slist_get_next(list, e))
{
const char* table = xvt_slist_get(list, e, NULL);
yes = xvt_str_same(name, table) != 0;
}
xvt_slist_destroy(list);
return yes;
}
class XVT_SQLDB_SQLite3 : public XVT_SQLDataBase
{
wxSQLite3Database* m_pDB;
protected:
virtual bool Open(const char* dsn, const char* usr, const char* pwd, const char* dir);
virtual bool Close();
virtual bool IsOk() const { return m_pDB != NULL && m_pDB->IsOpen(); }
virtual ULONG Execute(const char* sql, ODBC_CALLBACK cb, void* jolly);
virtual SLIST ListFields(const char* table) const;
virtual SLIST ListTables() const;
virtual wxString FindField(const char* strTable, const char* strField) const;
virtual bool TableExists(const char* name) const;
public:
virtual bool Begin() const;
virtual bool Commit() const;
virtual bool Rollback() const;
XVT_SQLDB_SQLite3() : m_pDB(NULL) {}
};
bool XVT_SQLDB_SQLite3::Open(const char* dsn, const char*, const char*, const char*)
{
Close();
m_pDB = new wxSQLite3Database;
if (dsn == NULL || *dsn <= ' ')
dsn = ":memory:";
try
{
m_pDB->Open(dsn);
}
catch(wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage());
return false;
}
return true;
}
bool XVT_SQLDB_SQLite3::Close()
{
if (IsOk())
{
delete m_pDB;
m_pDB = NULL;
}
return true;
}
bool XVT_SQLDB_SQLite3::Begin() const
{
bool bDone = IsOk();
if (bDone)
{
try { m_pDB->Begin(); }
catch(wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage());
bDone = false;
}
}
return bDone;
}
bool XVT_SQLDB_SQLite3::Commit() const
{
bool bDone = IsOk();
if (bDone)
{
try { m_pDB->Commit(); }
catch(wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage());
bDone = false;
}
}
return bDone;
}
bool XVT_SQLDB_SQLite3::Rollback() const
{
bool bDone = IsOk();
if (bDone)
{
try { m_pDB->Rollback(); }
catch(wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage());
bDone = false;
}
}
return bDone;
}
ULONG XVT_SQLDB_SQLite3::Execute(const char* sql, ODBC_CALLBACK cb, void* jolly)
{
ULONG nRows = 0;
if (!IsOk())
return nRows;
if (cb != NULL) // Ho una vera callback?
{
try
{
wxSQLite3ResultSet rs = m_pDB->ExecuteQuery(sql);
short numcols = rs.GetColumnCount();
if (numcols > 0)
{
wxArrayString aNames, aValues;
const short nMaxCols = 256;
char* values[nMaxCols]; // Lista dei valori del record corrente
memset(values, 0, sizeof(values));
char* names[2*nMaxCols]; // Lista dei nomi dei campi e dei tipi
memset(names, 0, sizeof(names));
if (numcols > nMaxCols)
numcols = nMaxCols;
short c;
for (c = 0; c < numcols; c++)
{
aNames.Add(rs.GetColumnName(c));
names[c] = (char*)(const char*)aNames[c];
switch (rs.GetColumnType(c))
{
case WXSQLITE_INTEGER:
case WXSQLITE_FLOAT:
names[c+numcols] = "NUMERIC"; break;
default:
names[c+numcols] = "VARCHAR"; break;
}
}
while (rs.NextRow())
{
aValues.Empty();
for (c = 0; c < numcols; c++)
{
aValues.Add(rs.GetAsString(c));
values[c] = (char*)(const char*)aValues[c];
}
if (cb(jolly, numcols, values, names) != 0)
break;
nRows++;
}
}
}
catch(wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage() + "\n" + sql);
}
}
else
nRows = m_pDB->ExecuteUpdate(sql);
return nRows;
}
SLIST XVT_SQLDB_SQLite3::ListTables() const
{
wxASSERT(m_pDB != NULL);
SLIST list = xvt_slist_create();
const wxString strQuery = wxT("SELECT name FROM sqlite_master WHERE type = 'table'");
try
{
wxSQLite3ResultSet rs = m_pDB->ExecuteQuery(strQuery);
while (rs.NextRow())
xvt_slist_add_at_elt(list, NULL, rs.GetAsString(0), 0L);
}
catch(wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage() + "\n" + strQuery);
}
return list;
}
SLIST XVT_SQLDB_SQLite3::ListFields(const char* strTable) const
{
SLIST list = NULL;
if (TableExists(strTable))
{
list = xvt_slist_create();
wxString strQuery; strQuery << "PRAGMA table_info(" << (const char*)strTable << ");";
try
{
wxSQLite3ResultSet rs = m_pDB->ExecuteQuery(strQuery);
while (rs.NextRow())
{
const wxString strField = rs.GetAsString(1);
const wxString strType = rs.GetAsString(2);
if (strType == "INTEGER")
xvt_slist_add_at_elt(list, NULL, strField, 2L); // intfld
if (strType == "NUMERIC")
xvt_slist_add_at_elt(list, NULL, strField, 5L); // realfld
else
xvt_slist_add_at_elt(list, NULL, strField, 1L); // alfafld
}
}
catch(wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage() + "\n" + strQuery);
}
}
return list;
}
wxString XVT_SQLDB_SQLite3::FindField(const char* strTable, const char* strField) const
{
wxString strType;
if (TableExists(strTable))
{
wxString strQuery; strQuery << "PRAGMA table_info(" << (const char*)strTable << ");";
try
{
wxSQLite3ResultSet rs = m_pDB->ExecuteQuery(strQuery);
while (rs.NextRow())
{
const wxString strFieldFound = rs.GetAsString(1);
if (strFieldFound == strField)
strType = rs.GetAsString(2);
}
}
catch (wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage() + "\n" + strQuery);
}
}
return strType;
}
bool XVT_SQLDB_SQLite3::TableExists(const char* name) const
{
return m_pDB != NULL && name && *name && m_pDB->TableExists(name);
}
///////////////////////////////////////////////////////////
// xvt_sql_...
///////////////////////////////////////////////////////////
XVT_SQLDB xvt_sql_open(const char* dsn, const char* usr, const char* pwd, const char* dir)
{
XVT_SQLDataBase* db = new XVT_SQLDB_SQLite3;
db->Open(dsn, usr, pwd, dir);
return (XVT_SQLDB)db;
}
BOOLEAN xvt_sql_close(XVT_SQLDB handle)
{
BOOLEAN ok = handle != NULL;
if (ok)
{
XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
if (db != NULL)
delete db;
}
return ok;
}
BOOLEAN xvt_sql_begin(XVT_SQLDB handle)
{
BOOLEAN ok = handle != NULL;
if (ok)
{
XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
if (db != NULL)
ok = db->Begin();
}
return ok;
}
BOOLEAN xvt_sql_commit(XVT_SQLDB handle)
{
BOOLEAN ok = handle != NULL;
if (ok)
{
XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
if (db != NULL)
ok = db->Commit();
}
return ok;
}
BOOLEAN xvt_sql_rollback(XVT_SQLDB handle)
{
BOOLEAN ok = handle != NULL;
if (ok)
{
XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
if (db != NULL)
ok = db->Rollback();
}
return ok;
}
ULONG xvt_sql_execute(XVT_SQLDB handle, const char* sql, ODBC_CALLBACK cb, void* jolly)
{
ULONG n = 0;
if (handle && sql && *sql)
{
XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
if (db->IsOk())
{
try
{
n = db->Execute(sql, cb, jolly);
}
catch(wxSQLite3Exception& e)
{
xvt_dm_post_error(e.GetMessage() + "\n" + sql);
n = ~0;
}
}
}
return n;
}
SLIST xvt_sql_list_fields(XVT_SQLDB handle, const char* table)
{
SLIST list = NULL;
XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
if (table && *table && db != NULL && db->IsOk())
list = db->ListFields(table);
return list;
}
SLIST xvt_sql_list_tables(XVT_SQLDB handle)
{
SLIST list = NULL;
XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
if (db != NULL && db->IsOk())
list = db->ListTables();
return list;
}
XVTDLL const char * xvt_sql_field_type(XVT_SQLDB handle, const char* table, const char* field)
{
XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
static wxString strType;
strType = "";
if (db != NULL && db->IsOk())
strType = db->FindField(table, field);
return strType;
}
BOOLEAN xvt_sql_table_exists(XVT_SQLDB handle, const char* name)
{
BOOLEAN yes = FALSE;
if (handle && name && *name)
{
const XVT_SQLDataBase* db = (XVT_SQLDataBase*)handle;
if (db->IsOk())
yes = db->TableExists(name);
}
return yes;
}
BOOLEAN xvt_sql_driver(XVT_SQLDB handle, char* str, int max_size)
{
if (str != NULL && max_size > 8)
{
if (handle != NULL)
wxStrncpy(str, "SQLite 3", max_size);
else
wxStrncpy(str, "ODBC 2.0", max_size);
}
return handle != NULL;
}

226
src/xvaga01/xvt_ssa.cpp Normal file
View File

@ -0,0 +1,226 @@
#include "wxinc.h"
#include "xvt.h"
#include "wx/filename.h"
#include "../ssa/h/ssadll.h"
#include "../ssa/h/ssaerr.h"
#include <errno.h>
///////////////////////////////////////////////////////////
// TSSA_Pinger
///////////////////////////////////////////////////////////
class TSSA_Pinger : public wxTimer
{
int m_nSerNo;
bool m_bRemote;
wxString m_strModule;
wxString _id, _ini;
protected:
virtual void Notify();
bool IsRemote() const { return m_bRemote; }
bool IsMenu() const;
bool IsFreeModule(const wxString& mod) const;
int AddRef(const wxString& m, int nDelta = +1);
int DecRef(const wxString& m) { return AddRef(m, -1); }
wxString NormalizedModule(const char* m) const;
bool LoginProduct();
bool LogoutProduct();
public:
int Login(const char* module);
int Serial() const { return m_nSerNo; }
int Logout(const char* module);
TSSA_Pinger();
};
static TSSA_Pinger* _ssa_timer = NULL;
static const char* const _ssa_product = "CAMPO";
bool TSSA_Pinger::IsMenu() const
{
const wxFileName argv0 = __argv[0];
return argv0.GetName().IsSameAs("ba0", false);
}
void TSSA_Pinger::Notify()
{ SSA_Ping(_id); }
bool TSSA_Pinger::LoginProduct()
{
bool bLoggedIn = IsRemote() && !IsMenu();
if (!bLoggedIn)
{
const int err = SSA_Login(_id, _ssa_product);
bLoggedIn = err == 0;
}
if (bLoggedIn && m_nSerNo < 0)
m_nSerNo = SSA_NumeroSerie(_ssa_product);
if (bLoggedIn && IsRemote() && IsMenu())
::WritePrivateProfileSection(_ssa_product, "\0\0", _ini); // Azzera tutti i conteggi dei moduli
return bLoggedIn;
}
bool TSSA_Pinger::LogoutProduct()
{
m_nSerNo = SSA_UTENTE_NON_LOGGATO;
if (IsRemote() && !IsMenu())
return true;
int err = SSA_Logout(_id, _ssa_product);
return err == 0;
}
wxString TSSA_Pinger::NormalizedModule(const char* m) const
{
wxString module;
if (m && *m)
{
module = m;
module.Trim();
module.MakeLower();
module.Truncate(2);
}
return module;
}
int TSSA_Pinger::AddRef(const wxString& module, int nDelta)
{
int nCount = xvt_sys_get_profile_int(_ini, _ssa_product, module, 0);
nCount += nDelta;
if (nCount < 0) nCount = 0;
xvt_sys_set_profile_int(_ini, _ssa_product, module, nCount);
return nCount;
}
bool TSSA_Pinger::IsFreeModule(const wxString& mod) const
{ return mod.IsEmpty() || mod=="ba" || mod=="pd" || mod=="ps"; }
int TSSA_Pinger::Login(const char* mod)
{
if (mod == NULL || *mod <= ' ')
return LoginProduct() ? Serial() : SSA_UTENTE_NON_LOGGATO;
const wxString module = NormalizedModule(mod);
if (IsFreeModule(module)) // Base o personalizzazione
return 0;
if (IsRemote() && AddRef(module) > 1)
return 0;
int err = SSA_ApriModulo(_id, module);
if (err == SSA_UTENTE_NON_LOGGATO) // ritenta!
{
LoginProduct();
err = SSA_ApriModulo(_id, module);
}
if (err != 0 && *module >= 'a')
err = SSA_ApriModulo(_id, module.Upper());
if (IsRemote() && err != 0)
DecRef(module);
if (err == 0)
m_strModule = module;
return err;
}
int TSSA_Pinger::Logout(const char* mod)
{
const wxString module = mod == NULL ? m_strModule : NormalizedModule(mod);
int err= 0;
bool cm = !IsFreeModule(module);
if (cm)
{
if (IsRemote())
cm = DecRef(module) <= 0;
if (cm)
err = SSA_ChiudiModulo(_id, module);
}
if (err == 0)
LogoutProduct();
return err;
}
TSSA_Pinger::TSSA_Pinger()
{
wxFileName ini = xvt_fsys_get_campo_ini();
ini.SetName("ssacount"); ini.MakeAbsolute();
_ini = ini.GetFullPath();
const int sess = xvt_sys_get_session_id();
char user[64], host[64];
xvt_sys_get_user_name(user, sizeof(user));
xvt_sys_get_host_name(host, sizeof(host));
_id.Printf("%s@%s:%d", user, host, sess);
char ssaagent[128] = { 0 };
const int len = xvt_sys_get_profile_string("ssa.ini", "", "SSA-PORT", "", ssaagent, sizeof(ssaagent));
m_bRemote = len > 8;
m_nSerNo = -1;
}
///////////////////////////////////////////////////////////
// xvt_dongle_sa_...
///////////////////////////////////////////////////////////
int xvt_dongle_sa_login(const char* module)
{
if (_ssa_timer == nullptr)
_ssa_timer = new TSSA_Pinger;
return _ssa_timer->Login(module);
}
int xvt_dongle_sa_crypt(unsigned short* data)
{
if (_ssa_timer == nullptr)
return SSA_UTENTE_NON_LOGGATO;
if (data == nullptr)
return -EACCES;
data[0] ^= 0xDEAD;
data[1] ^= 0xBEEF;
data[2] ^= 0xDEAD;
data[3] ^= 0xBEEF;
return 0;
}
int xvt_dongle_sa_logout(const char* module)
{
int err = SSA_UTENTE_NON_LOGGATO;
if (_ssa_timer != NULL)
err = _ssa_timer->Logout(module); // logout
return err;
}
int xvt_dongle_sa_test(const char* module)
{
int err = SSA_PROD_NOTFOUND;
if (module && *module && *module != '?')
{
wxString p = _ssa_product;
wxString m = module;
const int dot = m.Find('.');
if (dot > 0)
{
p = m.Left(dot);
m = m.Mid(dot+1);
}
err = SSA_VerificaModulo(p, m);
if (err <= SSA_MOD_NOTFOUND && m[0] >= 'a')
{
m.MakeUpper();
err = SSA_VerificaModulo(p, m);
}
}
return err;
}

68
src/xvaga01/xvt_sw.cpp Normal file
View File

@ -0,0 +1,68 @@
#include "wxinc.h"
#include "xvt.h"
#include <errno.h>
#ifdef __WXMSW__
#include "oswin32.h"
#else
#include <unistd.h>
#include "oslinux.h"
#endif
XVTDLL int xvt_dongle_sw_crypt(unsigned short* data)
{
if (data == NULL)
return -EACCES;
char chiaro[80], cifrato[80];
sprintf(chiaro, "%04x%04x%04x%04x", data[0], data[1], data[2], data[3]);
xvt_str_md5(chiaro, cifrato);
_strupr(cifrato);
data[0] = cifrato[0] * 0xFF + cifrato[1];
data[1] = cifrato[2] * 0xFF + cifrato[3];
data[2] = cifrato[4] * 0xFF + cifrato[5];
data[3] = cifrato[6] * 0xFF + cifrato[7];
data[0] ^= data[2];
data[1] ^= data[2];
data[2] ^= data[1];
data[3] ^= data[2];
return 0;
}
XVTDLL BOOLEAN xvt_dongle_sw_encode_decode(unsigned char* data, unsigned long serial, int len)
{
const int size = sizeof(serial);
unsigned char s[size];
for (int i = 0; i < len;)
{
s[1] = (unsigned char)((serial + i) / 0xFFFFFF);
s[2] = (unsigned char)(((serial + i) - s[1] * 0xFFFFFF) / 0xFFFF);
s[0] = (unsigned char)(((serial + i) - s[2] * 0xFFFF) / 0xFF);
s[3] = (unsigned char)((serial + i) - s[0] * 0xFF);
((unsigned char *) data)[i++] ^= s[0];
((unsigned char *) data)[i++] ^= s[1];
((unsigned char *) data)[i++] ^= s[2];
((unsigned char *) data)[i++] ^= s[3];
}
return true;
}
XVTDLL BOOLEAN xvt_get_secret(const char* addresses)
{
int retval = 0;
#ifdef __WXMSW__
retval = OsWin32_get_MAC_adresses((char *)addresses);
#else
retval = OsLinux_get_MAC_adresses((char *)addresses);
#endif
if (retval != 0)
{
wxString strMessage;
strMessage.Printf("Error callng GetAdaptersInfo %d" , retval);
xvt_dm_post_error(strMessage);
}
return retval == NOERROR;
}

484
src/xvaga01/xvt_type.h Normal file
View File

@ -0,0 +1,484 @@
#ifndef BOOLEAN
#define BOOLEAN short
#endif
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
#ifdef LINUX
#define _MAX_PATH 512
#define _MAX_EXT 6
#define _MAX_DRIVE 6
#define _MAX_DIR 512
#define _MAX_FNAME 512
#endif
typedef unsigned long WINDOW;
typedef unsigned int UNIT_TYPE;
typedef unsigned long ULONG;
typedef unsigned long XVT_ERRMSG;
typedef unsigned long XVT_ODBC;
typedef unsigned long XVT_SQLDB;
typedef unsigned long XVT_SQLSTMT;
typedef wchar_t XVT_WCHAR;
typedef short MENU_TAG;
typedef short CURSOR;
typedef char* DATA_PTR;
#define EOL_SEQ "\015\012"
typedef struct
{
short top, left, bottom, right;
} RCT;
typedef long XVT_HELP_TID;
typedef unsigned long COLOR;
typedef unsigned long XVT_COLOR_TYPE;
typedef unsigned long XVT_FONT_ATTR_MASK;
typedef unsigned long XVT_FONT_STYLE_MASK;
typedef long PICTURE;
typedef void* XVT_IMAGE;
typedef enum {
XVT_IMAGE_NONE,
XVT_IMAGE_CL8,
XVT_IMAGE_RGB,
XVT_IMAGE_MONO,
} XVT_IMAGE_FORMAT;
#define XVT_FNTID void*
typedef void* XVT_PALETTE;
typedef unsigned long XVT_PALETTE_ATTR;
#define XVT_ESC_GET_PRINTER_INFO 883
#define XVT_ESC_SET_PRINTER_INFO 884
typedef enum e_display_type {
XVT_DISPLAY_MONO, /* monochromatic display */
XVT_DISPLAY_GRAY_16, /* 16-entry grayscale */
XVT_DISPLAY_GRAY_256, /* 256-entry grayscale */
XVT_DISPLAY_COLOR_16, /* 16-entry color */
XVT_DISPLAY_COLOR_256, /* 256-entry color */
XVT_DISPLAY_DIRECT_COLOR, /* full color capabilities */
} XVT_DISPLAY_TYPE;
typedef enum {
XVT_PALETTE_NONE,
XVT_PALETTE_STOCK,
XVT_PALETTE_CURRENT,
XVT_PALETTE_CUBE16,
XVT_PALETTE_CUBE256,
XVT_PALETTE_USER
} XVT_PALETTE_TYPE;
typedef enum { /* response from ask fcn */
RESP_DEFAULT, /* default button */
RESP_2, /* second button */
RESP_3, /* third button */
} ASK_RESPONSE;
typedef enum { /* result from file open & save dialogs */
FL_BAD, /* error occurred */
FL_CANCEL, /* cancel button clicked */
FL_OK, /* OK button clicked */
} FL_STATUS;
typedef struct
{
char path[_MAX_DIR];
} DIRECTORY;
typedef struct s_mitem {
MENU_TAG tag; /* menu tag */
char *text; /* text to appear in menu */
short mkey; /* mnemonic */
unsigned enabled: 1; /* enabled? */
unsigned checked: 1; /* checked? */
unsigned checkable: 1; /* checkable? */
unsigned separator: 1; /* separator? */
struct s_mitem *child; /* pointer to submenu */
} MENU_ITEM;
typedef enum e_popup_alignment {
XVT_POPUP_CENTER,
XVT_POPUP_LEFT_ALIGN,
XVT_POPUP_RIGHT_ALIGN,
XVT_POPUP_OVER_ITEM
} XVT_POPUP_ALIGNMENT;
#define SZ_FNAME _MAX_FNAME
#define SZ_EXT 6
typedef struct { /* file specification */
DIRECTORY dir; /* directory */
char type[SZ_EXT]; /* file type/extension */
char name[SZ_FNAME]; /* filename */
char creator[6]; /* file creator */
} FILE_SPEC;
typedef struct
{
void* pr;
} PRINT_RCD;
typedef struct
{
short v, h;
} PNT;
typedef struct { char* str; long data; void* next; } SLIST_ITEM;
typedef SLIST_ITEM* SLIST_ELT;
typedef struct { SLIST_ELT head; long count; } xvtList;
typedef xvtList* SLIST;
typedef enum { /* drawing (transfer) mode */
M_COPY,
M_OR,
M_XOR,
M_CLEAR,
M_NOT_COPY,
M_NOT_OR,
M_NOT_XOR,
M_NOT_CLEAR
} DRAW_MODE;
typedef enum e_pen_style { /* pen style */
P_SOLID, /* solid */
P_DOT, /* dotted line */
P_DASH /* dashed line */
} PEN_STYLE;
typedef enum {
PAT_NONE, /* no pattern */
PAT_HOLLOW, /* hollow */
PAT_SOLID, /* solid fill */
PAT_HORZ, /* horizontal lines */
PAT_VERT, /* vertical lines */
PAT_FDIAG, /* diagonal lines -- top-left to bottom-right */
PAT_BDIAG, /* diagonal lines -- top-right to bottom-left */
PAT_CROSS, /* horizontal and vertical crossing lines */
PAT_DIAGCROSS, /* diagonal crossing lines */
PAT_RUBBER, /* rubber banding */
PAT_SPECIAL
} PAT_STYLE;
typedef struct { /* color pen tool */
short width; /* width */
PAT_STYLE pat; /* pattern */
PEN_STYLE style; /* style */
COLOR color; /* color */
} CPEN;
typedef struct
{
PAT_STYLE pat;
COLOR color;
} CBRUSH;
typedef struct { /* color drawing tools */
CPEN pen; /* color pen */
CBRUSH brush; /* color brush */
DRAW_MODE mode; /* drawing mode */
COLOR fore_color; /* foreground color */
COLOR back_color; /* background color */
BOOLEAN opaque_text; /* is text opaque*/
} DRAW_CTOOLS;
typedef enum { /* scrollbar activity */
SC_NONE, /* nowhere (ignore) */
SC_LINE_UP, /* one line up */
SC_LINE_DOWN, /* one line down */
SC_PAGE_UP, /* previous page */
SC_PAGE_DOWN, /* next page */
SC_THUMB, /* thumb repositioning */
SC_THUMBTRACK /* thumb tracking */
} SCROLL_CONTROL;
typedef enum { /* type of window */
W_NONE, /* marker for end of WIN_DEF array */
W_DOC, /* document window */
W_PLAIN, /* window with plain border */
W_DBL, /* window with double border */
W_PRINT, /* XVT internal use only */
W_TASK, /* task window */
W_SCREEN, /* screen window */
W_NO_BORDER, /* no border */
W_PIXMAP, /* pixmap */
W_MODAL, /* modal window */
WD_MODAL, /* modal dialog */
WD_MODELESS, /* modeless dialog */
WC_PUSHBUTTON, /* button control */
WC_RADIOBUTTON, /* radio button control */
WC_CHECKBOX, /* check box control */
WC_HSCROLL, /* horizontal scrollbar control */
WC_VSCROLL, /* vertical scrollbar control */
//WC_EDIT, /* edit control */ commentato perche' rompe le scatole
WC_TEXT, /* static text control */
WC_LBOX, /* list box control */
WC_LISTBUTTON, /* button with list */
WC_CHECKBUTTON, /* check button control */
WC_LISTEDIT, /* edit with field list */
WC_GROUPBOX, /* group box */
WC_TEXTEDIT, /* text edit object */
WC_ICON, /* icon control */
WO_TE, /* text edit */
WC_HGAUGE, /* horizontal progress bar */
WC_VGAUGE, /* vertical progress bar */
WC_NOTEBK, /* notebook control */
WC_HTML, /* HTML control */
WC_TREE, /* tree view */
WC_OUTLOOKBAR, /* Barra di Outlook */
WC_HSLIDER, /* horizontal slider control */
WC_VSLIDER, /* vertical slider control */
WC_POPUP, /* list of listedit control or popup menu */
WC_PROPGRID, /* property grid */
WC_MVC, /* model view controller */
WC_TREELIST, /* tree list */
WC_METROBAR, /* Barra di Metro */
} WIN_TYPE;
typedef enum {
SEV_NONE,
SEV_WARNING,
SEV_ERROR,
SEV_FATAL,
} XVT_ERRSEV;
typedef enum { /* type of scrollbar */
HSCROLL, /* horizontal */
VSCROLL, /* vertical */
HVSCROLL, /* either */
HVGAUGE, /* progress bar */
HVSLIDER, /* slider */
} SCROLL_TYPE;
/* Treeview - Types */
typedef void * XVT_TREEVIEW_NODE;
typedef enum e_treeview_node_type {
XVT_TREEVIEW_NODE_TERMINAL, /* leaf - no children */
XVT_TREEVIEW_NODE_NONTERMINAL, /* branch - may have children */
XVT_ENUM_DUMMY26 = XVT_CC_ENUM_END
} XVT_TREEVIEW_NODE_TYPE;
typedef XVT_CALLCONV_TYPEDEF( BOOLEAN, XVT_TREEVIEW_CALLBACK,
(WINDOW ctl_win, XVT_TREEVIEW_NODE node) );
typedef struct s_ctlinfo {
WIN_TYPE type;
WINDOW win;
union {
struct s_scroll {
SCROLL_CONTROL what;
short pos;
} scroll;
struct s_edit {
BOOLEAN focus_change;
BOOLEAN active;
} edit;
struct s_lbox {
BOOLEAN dbl_click;
} lbox;
struct s_listedit {
BOOLEAN focus_change;
BOOLEAN active;
} listedit;
struct s_notebk {
WINDOW page;
short page_new;
short page_old;
} notebk;
struct s_html {
int reserved; /* Reserved...no usage yet.*/
} html;
struct s_treeview {
XVT_TREEVIEW_NODE node; /* Node */
BOOLEAN sgl_click; /* Single click */
BOOLEAN dbl_click; /* Double click */
BOOLEAN expanded; /* Node was expanded */
BOOLEAN collapsed; /* Node was collapsed */
} treeview;
} v;
} CONTROL_INFO;
typedef struct s_xvt_color_component {
XVT_COLOR_TYPE type; /* color component being defined */
COLOR color; /* RGB color value */
} XVT_COLOR_COMPONENT;
typedef enum s_xvt_color_action {
XVT_COLOR_ACTION_SET,/* set the colors */
XVT_COLOR_ACTION_UNSET/* unset the colors */
} XVT_COLOR_ACTION;
typedef struct s_win_def {
WIN_TYPE wtype; /* WC_* or WO_* type */
RCT rct;
char *text;
UNIT_TYPE units;
XVT_COLOR_COMPONENT * ctlcolors;
union {
struct s_win_def_win { /* WINDOW's */
short int menu_rid; /* menu resource id */
MENU_ITEM *menu_p; /* pointer to menu tree */
long flags; /* WSF_* flags */
XVT_FNTID ctl_font_id; /* control font id */
} win;
struct s_win_def_dlg { /* DIALOG's */
long flags; /* WSF_* flags */
XVT_FNTID ctl_font_id; /* control font id */
} dlg;
struct s_win_def_ctl { /* CONTROL's */
short int ctrl_id;
short int icon_id; /* for icons only */
long flags; /* CTL_* flags */
XVT_FNTID font_id; /* logical font */
} ctl;
struct s_win_def_tx { /* text edit objects */
unsigned short attrib; /* TX_* flags */
XVT_FNTID font_id; /* logical font */
short margin; /* right margin */
short limit; /* max chars */
short int tx_id; /* text ID */
} tx;
} v;
} WIN_DEF;
typedef enum {
E_CREATE, /* creation */
E_DESTROY, /* destruction */
E_FOCUS, /* window focus gain/loss */
E_SIZE, /* resize */
E_UPDATE, /* update */
E_CLOSE, /* close window request */
E_MOUSE_DOWN, /* mouse down */
E_MOUSE_UP, /* mouse up */
E_MOUSE_MOVE, /* mouse move */
E_MOUSE_DBL, /* mouse double click */
E_CHAR, /* character typed */
E_VSCROLL, /* vert. window scrollbar activity */
E_HSCROLL, /* horz. window scrollbar activity */
E_COMMAND, /* menu command */
E_FONT, /* font menu selection */
E_CONTROL, /* control activity */
E_TIMER, /* timer */
E_QUIT, /* application shutdown request */
E_HELP, /* help invoked */
E_USER, /* user defined */
E_CXO, /* cxo event */
E_PROCESS, /* child process terminated */
} EVENT_TYPE;
typedef struct s_event {
EVENT_TYPE type;
union _v {
struct s_mouse { /* E_MOUSE_DOWN, E_MOUSE_UP, E_MOUSE_MOVE, E_MOUSE_DBL */
PNT where; /* location of event (window relative) */
BOOLEAN shift; /* shift key down? */
BOOLEAN control; /* control or option key down? */
short button; /* button number */
} mouse;
struct s_char { /* E_CHAR */
XVT_WCHAR ch; /* wide character */
BOOLEAN shift; /* shift key down? */
BOOLEAN control; /* control or option key down? */
BOOLEAN virtual_key; /* ch contains virtual key or not? */
unsigned long modifiers; /* bit field of key modifiers */
} chr;
BOOLEAN active; /* E_FOCUS: activation? (vs. deactivation) */
BOOLEAN query; /* E_QUIT: query only? (app calls quit_OK) */
struct s_scroll_info { /* E_VSCROLL, E_HSCROLL */
SCROLL_CONTROL what; /* site of activity */
short pos; /* thumb position, if SC_THUMB */
} scroll;
struct s_cmd { /* E_COMMAND */
MENU_TAG tag; /* menu item tag */
BOOLEAN shift; /* shift key? */
BOOLEAN control; /* control or option key? */
} cmd;
struct s_size { /* E_SIZE */
short height; /* new height */
short width; /* new width */
} size;
struct s_efont { /* E_FONT */
XVT_FNTID font_id; /* R4 font id of selected font */
} font;
struct s_ctl { /* E_CONTROL */
short id; /* control's ID */
CONTROL_INFO ci; /* control info */
} ctl;
struct s_update { /* E_UPDATE */
RCT rct; /* update rectangle */
} update;
struct s_timer { /* E_TIMER */
long id; /* timer ID */
} timer;
struct s_user { /* E_USER */
long id; /* application ID */
void *ptr; /* application pointer */
} user;
struct s_help { /* E_HELP */
WINDOW obj; /* help for control, window, dialog */
MENU_TAG tag; /* help for menu item */
XVT_HELP_TID tid; /* predefined help topic */
} help;
struct s_cxo { /* E_CXO */
long msg_id; /* CXO message id - Unique to each CXO */
void * ptr; /* message data pointer */
} cxo;
struct s_process { /* E_PROCESS */
long pid; /* PID of started/terminated process */
int msg_id; /* 0=started; 1=stopped */
int exit_code;
} process;
} v;
} EVENT, *EVENT_PTR;
typedef unsigned long EVENT_MASK;
typedef long (* EVENT_HANDLER) (WINDOW win, EVENT *ep);
typedef BOOLEAN (* XVT_ERRMSG_HANDLER) (XVT_ERRMSG err, DATA_PTR context);
typedef BOOLEAN (* XVT_ENUM_CHILDREN)(WINDOW child, long data);
typedef enum { /* std. clipboard format */
CB_TEXT, /* ASCII text */
CB_PICT, /* encapsulated picture */
CB_APPL /* app's own (must have name) */
} CB_FORMAT;
typedef struct s_xvt_config
{
short menu_bar_ID; /* task menubar ResID */
short about_box_ID; /* default aboutbox ResID */
const char* base_appl_name; /* application's "filename" */
const char* appl_name; /* application's name */
const char* taskwin_title; /* title for task window */
} XVT_CONFIG;

25
src/xvaga01/xvt_vers.h Normal file
View File

@ -0,0 +1,25 @@
/****************************************************************************
*
* Copyright (c) 1989 - 2002 Providence Software Solutions, Inc. All rights reserved.
* May be used only in accordance with a valid Source Code License
* Agreement with Providence Software Solutions, Inc.
*
* $RCSfile: xvt_vers.h,v $
* $Revision: 1.1 $
*
* Purpose: XVT PTK version definitions.
*
****************************************************************************/
#ifndef XVT_INCL_VERS
#define XVT_INCL_VERS
#define XVT_PTK_VERSION_MAJOR 5
#define XVT_PTK_VERSION_MINOR 6
#define XVT_PTK_VERSION_PATCH 1
#define XVT_PTK_VERSION (XVT_MAKE_VERSION(XVT_PTK_VERSION_MAJOR,XVT_PTK_VERSION_MINOR,XVT_PTK_VERSION_PATCH))
#define XVT_CHECK_VERSION(vma,vmi,vpa) XVT_PTK_VERSION>=XVT_MAKE_VERSION(vma,vmi,vpa)
#endif /* XVT_INCL_VERS */

496
src/xvaga01/xvtart.cpp Normal file
View File

@ -0,0 +1,496 @@
#include "wxinc.h"
#include "xvt.h"
#include "xvtart.h"
#ifdef __WXMSW__
#include "oswin32.h"
#else
#include "oslinux.h"
#endif
#include <wx/artprov.h>
#include <wx/aui/aui.h>
#include <wx/filename.h>
wxString xvtart_GetResourceIni()
{
DIRECTORY dir; xvt_fsys_get_default_dir(&dir);
wxString str = dir.path;
str += "/res/resource.ini";
return str;
}
wxString xvtart_GetResourceName(const char* type, int rid)
{
wxString strName(type); strName << "s";
wxString strKey; strKey.Printf("%d", rid);
DIRECTORY dir; xvt_fsys_get_default_dir(&dir);
wxString startup_dir = dir.path;
if ((rid == ICON_RSRC || rid == 0) && strName == "Icons")
{
int i = 1;
switch (xvt_sys_get_os_version())
{
case XVT_WS_WIN_2000:
case XVT_WS_WIN_2003: i = 0; break; // Cerco prima l'icona a 256 colori
default : i = 1; break; // Cerco solo l'icona in RGBA
}
for (; i < 2; i++)
{
const char* const oem_var = i == 0 ? "Icon256" : "Icon";
char name[MAX_PATH];
if (xvt_sys_get_oem_string(oem_var, "", name, sizeof(name)))
{
wxFileName fname(startup_dir + "/setup/" + name);
if (fname.FileExists())
{
fname.Normalize();
strName = fname.GetFullPath().Lower();
return strName;
}
}
}
}
wxString val;
char* buff = val.GetWriteBuf(MAX_PATH);
xvt_sys_get_profile_string(xvtart_GetResourceIni(), strName, strKey, "", buff, MAX_PATH);
val.UngetWriteBuf();
if (!val.IsEmpty())
{
strName = startup_dir;
strName += "/custom/";
strName += val;
if (!wxFileExists(strName))
{
const int oem = xvt_sys_get_oem_int("OEM", 0);
if (oem > 0)
{
char oemstr[MAX_PATH];
strName = startup_dir;
strName += "/res/OEM_";
sprintf(oemstr, "%02d", oem);
strName += oemstr;
strName += "/";
strName += val;
}
if (!wxFileExists(strName))
{
strName = startup_dir;
strName += "/res/";
strName += val;
}
}
wxFileName fname(strName);
fname.Normalize();
strName = fname.GetFullPath().Lower();
}
else
strName.Empty();
return strName;
}
///////////////////////////////////////////////////////////
// TArtProvider
///////////////////////////////////////////////////////////
class TArtProvider : public wxArtProvider
{
#if !wxCHECK_VERSION(2,9,0)
WX_DECLARE_STRING_HASH_MAP(wxIconBundle, TIconBundleHashTable);
TIconBundleHashTable m_hmBundles;
WX_DECLARE_STRING_HASH_MAP(unsigned, TIconIdHashTable);
TIconIdHashTable m_hmIds;
#endif
protected:
virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size);
virtual wxIconBundle CreateIconBundle(const wxArtID& id, const wxArtClient& client);
public:
#if !wxCHECK_VERSION(2,9,0)
wxIconBundle GetIconBundle(const wxArtID& id, const wxArtClient& client);
wxIcon GetIcon(const wxArtID& id, const wxArtClient& client = wxART_OTHER, const wxSize& size = wxDefaultSize);
wxSize GetNativeSizeHint(const wxArtClient& client);
#endif
unsigned int GetIconBundleNumber(const wxArtID& id);
};
TArtProvider* _TheArtProvider = NULL;
void xvtart_Init()
{
if (_TheArtProvider == NULL)
_TheArtProvider = new TArtProvider;
wxArtProvider::Push(_TheArtProvider);
}
wxBitmap TArtProvider::CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size)
{
wxString strName;
long tool = -1;
if (id.StartsWith(wxT("wxART")))
{
if (id == wxART_ERROR) tool = 201; else
if (id == wxART_HELP) tool = 163; else
if (id == wxART_INFORMATION) tool = 162; else
if (id == wxART_MISSING_IMAGE) tool = 100; else
if (id == wxART_NEW) tool = 105; else
if (id == wxART_QUESTION) tool = 202; else
if (id == wxART_QUIT) tool = 114; else
if (id == wxART_WARNING) tool = 203; else
;
}
else
id.ToLong(&tool);
if (tool > 0)
{
strName = xvtart_GetResourceName("Tool", tool);
if (strName.IsEmpty() || !::wxFileExists(strName))
strName = xvtart_GetResourceName("Tool", 100); // Default empty icon
}
else
strName = id;
if (!strName.IsEmpty() && ::wxFileExists(strName))
{
if (strName.EndsWith(".ico"))
{
const wxIcon ico = GetIcon(strName, client, size);
return wxBitmap(ico);
}
else
{
int sx = size.x, sy = size.y;
if (sx <= 0 || sy <= 0)
{
const wxSize sz = GetNativeSizeHint(client);
if (sx <= 0) sx = sz.x;
if (sy <= 0) sy = sz.y;
}
wxImage img(strName, wxBITMAP_TYPE_ANY);
img.Rescale(sx, sy, wxIMAGE_QUALITY_HIGH);
return wxBitmap(img);
}
}
return wxNullBitmap;
}
wxIconBundle TArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& WXUNUSED(client))
{
wxString strName = id;
long nIco = -1;
if (id.StartsWith(wxT("wxART")))
{
if (id == wxART_EXECUTABLE_FILE) nIco = ICON_RSRC; else
;
}
else
id.ToLong(&nIco);
if (nIco > 0)
strName = xvtart_GetResourceName("Icon", nIco);
wxIconBundle ib;
bool bFound = false;
if (::wxFileExists(strName))
{
const bool bLog = wxLog::EnableLogging(false); // Evita segnalazione di errore di formato icona
if (strName.EndsWith(wxT(".ico")))
{
ib.AddIcon(strName, wxBITMAP_TYPE_ICO);
bFound = true;
}
else
{
ib.AddIcon(OsWin32_LoadIcon(strName));
bFound = true;
}
wxLog::EnableLogging(bLog);
for (wxCoord s = 16; s <= 48; s += 16)
{
const wxIcon smico = ib.GetIcon(s);
if (smico.GetWidth() != s)
{
wxBitmap bmpbig(ib.GetIcon());
wxImage img = bmpbig.ConvertToImage();
img.Rescale(s, s, wxIMAGE_QUALITY_HIGH);
wxBitmap bmpsmall(img);
wxIcon icosmall; icosmall.CopyFromBitmap(bmpsmall);
ib.AddIcon(icosmall);
}
}
}
else
{
if (!strName.IsEmpty()) // Getione caso strName=".ext"
{
ib.AddIcon(OsWin32_LoadIcon(strName));
bFound = true;
}
}
if (!bFound && nIco == ICON_RSRC)
{
strName.Printf("%d", ICON_RSRC); // id puo' essere wxART_EXECUTABLE_FILE
ib.AddIcon(wxIcon(strName, wxBITMAP_TYPE_ICO_RESOURCE));
}
return ib;
}
#if !wxCHECK_VERSION(2,9,0)
wxSize TArtProvider::GetNativeSizeHint(const wxArtClient& client)
{
int ix = 32, iy = 32;
if (client == wxART_FRAME_ICON)
{
const int x = wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
const int y = wxSystemSettings::GetMetric(wxSYS_SMALLICON_Y);
if (x > 0 && y > 0)
{ ix = x; iy = y; }
else
{ ix /= 2; iy /= 2; }
}
else
{
const int x = wxSystemSettings::GetMetric(wxSYS_ICON_X);
const int y = wxSystemSettings::GetMetric(wxSYS_ICON_Y);
if (x > 0 && y > 0)
{ ix = x; iy = y; }
if (client == wxART_MESSAGE_BOX)
{ ix *= 2; iy *= 2; }
}
return wxSize(ix,iy);
}
wxIconBundle TArtProvider::GetIconBundle(const wxArtID& id, const wxArtClient& client)
{
TIconBundleHashTable::iterator it = m_hmBundles.find(id);
if (it == m_hmBundles.end())
{
const wxIconBundle b = CreateIconBundle(id, client);
m_hmBundles[id] = b;
unsigned long uid = 0;
if (!id.ToULong(&uid))
{
wxString numid; numid.Printf(wxT("%lu"), GetIconBundleNumber(id));
m_hmBundles[numid] = b;
}
return b;
}
return it->second;
}
wxIcon TArtProvider::GetIcon(const wxArtID& id, const wxArtClient& client, const wxSize& size)
{
wxIconBundle bundle = GetIconBundle(id, client);
const wxSize sz = size == wxDefaultSize ? GetNativeSizeHint(client) : size;
wxIcon ico = bundle.GetIcon(sz);
if (ico.IsOk() && sz.x != ico.GetWidth()) // Should never happen :-)
{
wxBitmap bmpbig(bundle.GetIcon());
wxImage img = bmpbig.ConvertToImage();
img.Rescale(sz.x, sz.y, wxIMAGE_QUALITY_HIGH);
wxBitmap bmpsmall(img);
wxIcon icosmall; icosmall.CopyFromBitmap(bmpsmall);
ico = icosmall;
bundle.AddIcon(ico);
}
return ico;
}
// Metodo fichissimo per assegnare un identificatore univoco alle icone chiamate per nome del file.*
unsigned int TArtProvider::GetIconBundleNumber(const wxArtID& id)
{
unsigned int num = m_hmIds[id];
if (num == 0)
{
num = 60000+m_hmIds.size();
m_hmIds[id] = num;
}
return num;
}
#endif
///////////////////////////////////////////////////////////
// xvt_sys_load_icon
///////////////////////////////////////////////////////////
const wxBitmap xvtart_GetToolResource(int nIcon, int nDesiredSize)
{
if (nDesiredSize < 16) nDesiredSize = 16; else
if (nDesiredSize > 128) nDesiredSize = 128;
wxArtID id; id.Printf("%d", nIcon);
return wxArtProvider::GetBitmap(id, wxART_TOOLBAR, wxSize(nDesiredSize, nDesiredSize));
}
const wxIcon xvtart_GetIconResource(int nIcon, const char* client, const int size)
{
wxASSERT(_TheArtProvider != NULL);
if (nIcon <= 0)
nIcon = ICON_RSRC;
wxArtID id; id.Printf("%d", nIcon);
wxArtClient cl = client && * client ? client : wxART_OTHER;
wxSize sz(size, size);
return _TheArtProvider->GetIcon(id, cl, sz);
}
unsigned int xvt_sys_load_icon(const char* file)
{
wxASSERT(_TheArtProvider != NULL);
const wxArtID id = file;
const wxIcon ico = _TheArtProvider->GetIcon(id);
return ico.IsOk() ? _TheArtProvider->GetIconBundleNumber(id) : ICON_RSRC;
}
WX_DECLARE_HASH_MAP(int, wxCursor, wxIntegerHash, wxIntegerEqual, TCursorHashTable);
const wxCursor xvtart_GetCursorResource(int rid)
{
static TCursorHashTable _nice_cursors;
wxCursor cursor = _nice_cursors[rid];
if (!cursor.IsOk())
{
switch (rid)
{
case CURSOR_CROCE: cursor = wxCURSOR_CROSS; break;
case CURSOR_IBEAM: cursor = wxCURSOR_IBEAM; break;
default:
{
const wxString strName = xvtart_GetResourceName("Cursor", rid);
if (::wxFileExists(strName))
{
if (strName.Find(".ico") > 0)
cursor = wxCursor(strName, wxBITMAP_TYPE_ICO);
else
cursor = wxCursor(strName, wxBITMAP_TYPE_CUR);
}
}
break;
}
if (!cursor.IsOk())
{
wxFAIL_MSG(_("Invalid cursor"));
cursor = *wxSTANDARD_CURSOR;
}
_nice_cursors[rid] = cursor;
}
return cursor;
}
///////////////////////////////////////////////////////////
// TAuiManager
///////////////////////////////////////////////////////////
/*
class TAuiManager : public wxAuiManager
{
public:
static bool DrawBackground(wxDC& dc, wxWindow* window, int orientation, const wxRect &rect);
static bool BaseColours(wxColour& base, wxColour& light, wxColour& dark, wxColour& text);
TAuiManager();
};
bool TAuiManager::BaseColours(wxColour& base, wxColour& light, wxColour& dark, wxColour& text)
{
const wxSize sz(256,256);
wxBitmap bmp = wxArtProvider::GetBitmap(wxArtID(wxT("Skin")), wxART_OTHER, sz);
if (bmp.IsOk())
{
wxColourBase::ChannelType ldark = 255, llight = 0;
dark = *wxWHITE;
light = *wxBLACK;
wxNativePixelData data(bmp);
const int dim = data.GetHeight();
wxNativePixelData::Iterator p(data);
double r = 0, g = 0, b = 0;
for (int i = 0; i < dim; i++)
{
p.MoveTo(data, i, i);
r += p.Red();
g += p.Green();
b += p.Blue();
const wxColour col(p.Red(), p.Green(), p.Blue());
const wxColourBase::ChannelType lcol = Luma(col);
if (lcol < ldark)
{
dark = col;
ldark = lcol;
}
if (lcol > llight)
{
light = col;
llight = lcol;
}
}
r /= dim; g /= dim; b /= dim;
base = wxColour(r, g, b);
const wxColourBase::ChannelType lbase = Luma(base);
if (lbase - ldark < 40)
dark = ModulatedColor(dark, -(40 - lbase + ldark));
if (llight - lbase < 40)
light = ModulatedColor(light, +(40 - llight + lbase));
text = ContrastingColor(base);
}
return bmp.IsOk();
}
bool TAuiManager::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(window),
int WXUNUSED(orientation), const wxRect &rect)
{
const wxBitmap bmp = wxArtProvider::GetBitmap(wxArtID(wxT("Skin")), wxART_OTHER, wxSize(256,256));
if (bmp.IsOk())
{
const wxSize szBm = bmp.GetSize();
for (wxCoord y = rect.y; y < rect.GetBottom(); y += szBm.y)
{
for (wxCoord x = rect.x; x < rect.GetRight(); x += szBm.x)
dc.DrawBitmap(bmp, x, y);
}
}
return bmp.IsOk();
}
TAuiManager::TAuiManager()
{
SetArtProvider(new TDockArt);
}
*/
wxAuiManager* xvtart_CreateManager(wxWindow* win)
{
return new wxAuiManager(win); // will be TAUIManager
}

17
src/xvaga01/xvtart.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef __XVTART_H__
#define __XVTART_H__
#ifndef _WX_FRAMEMANAGER_H_
class wxAuiManager;
#endif
const wxCursor xvtart_GetCursorResource(int rid);
const wxIcon xvtart_GetIconResource(int rid, const char* client = NULL, int size = -1);
wxString xvtart_GetResourceIni();
wxString xvtart_GetResourceName(const char* type, int rid);
const wxBitmap xvtart_GetToolResource(int rid, int size);
void xvtart_Init();
wxAuiManager* xvtart_CreateManager(wxWindow* win);
#endif

3873
src/xvaga01/xvtctl.cpp Normal file

File diff suppressed because it is too large Load Diff

866
src/xvaga01/xvtdm.cpp Normal file
View File

@ -0,0 +1,866 @@
#include "wxinc.h"
#include "xvt.h"
#include "xvtwin.h"
#include <wx/artprov.h>
#include <wx/calctrl.h>
#include <wx/clipbrd.h>
#include <wx/colordlg.h>
#include <wx/fontdlg.h>
#include <wx/wxhtml.h>
#include <wx/statline.h>
#include <wx/tokenzr.h>
#ifdef __WXMSW__
#include "oswin32.h"
#endif
///////////////////////////////////////////////////////////
// TwxHtmlWindow
///////////////////////////////////////////////////////////
class TwxHtmlWindow : public wxHtmlWindow
{
protected:
virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
};
void TwxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
{
const wxString href = link.GetHref();
if (href.StartsWith("mailto:"))
xvt_mail_send(href.AfterFirst(':'), NULL, NULL, _GetAppTitle(), ToText(), NULL, 1);
else
wxHtmlWindow::OnLinkClicked(link);
}
///////////////////////////////////////////////////////////
// TMessageBox
///////////////////////////////////////////////////////////
class TMessageBox : public wxDialog
{
wxTimer m_timer;
protected:
void OnButton(wxCommandEvent& evt);
void OnTimeout(wxTimerEvent& evt);
void AddButton(wxSizer* sz, wxWindowID id);
DECLARE_EVENT_TABLE()
wxString GetMessage() const;
public:
TMessageBox(wxWindow* pParent, const wxString& msg, int nStyle, int nTimeout = 0);
};
BEGIN_EVENT_TABLE(TMessageBox, wxDialog)
EVT_BUTTON(wxID_ANY, TMessageBox::OnButton)
EVT_TIMER(wxID_ANY, TMessageBox::OnTimeout)
END_EVENT_TABLE()
wxString TMessageBox::GetMessage() const
{
wxString str;
const wxWindow* txt = FindWindowById(wxID_EDIT, this);
if (txt != NULL)
{
wxHtmlWindow* html = wxDynamicCast(txt, wxHtmlWindow);
if (html != NULL)
str = html->ToText();
else
str = txt->GetLabel();
}
return str;
}
void TMessageBox::OnButton(wxCommandEvent& evt)
{
int ec = wxCANCEL;
switch (evt.GetId())
{
case wxID_YES: ec = wxYES; break;
case wxID_OK : ec = wxOK; break;
case wxID_NO : ec = wxNO; break;
case wxID_COPY:
wxTheClipboard->Open();
wxTheClipboard->SetData(new wxTextDataObject(GetMessage()));
wxTheClipboard->Close();
return; // DO NOT EXIT
case wxID_SAVEAS:
xvt_mail_send("hotline@sirio-is.it", NULL, NULL, _GetAppTitle(), GetMessage(), NULL, 1);
return; // DO NOT EXIT
default: ec = GetEscapeId(); break;
}
EndModal(ec);
}
void TMessageBox::OnTimeout(wxTimerEvent& WXUNUSED(evt))
{
wxWindowID id = GetEscapeId();
if (id <= 0)
id = GetAffirmativeId();
if (id > 0)
{
wxCommandEvent cmd(wxEVT_COMMAND_BUTTON_CLICKED, id);
AddPendingEvent(cmd);
}
else
EndModal(wxCANCEL);
}
void TMessageBox::AddButton(wxSizer* sz, wxWindowID id)
{
wxString strPrompt;
switch (id)
{
case 0x20: strPrompt = _("Si Tutti"); break;
case 0x40: strPrompt = _("No Tutti"); break;
default : break;
}
wxButton* btn = new wxButton(this, id, strPrompt, wxDefaultPosition, wxSize(64,-1));
sz->Add(btn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2);
}
TMessageBox::TMessageBox(wxWindow* pParent, const wxString& msg, int nStyle, int nTimeout)
: wxDialog(pParent, wxID_ANY, _GetAppTitle(), wxDefaultPosition, wxDefaultSize,
wxCAPTION | wxRAISED_BORDER | wxSTAY_ON_TOP), m_timer(this)
{
TTaskWin* tw = wxDynamicCast(pParent ? pParent : _task_win, TTaskWin);
if (tw != NULL)
{
const COLOR col = tw->GetCtlColor(XVT_COLOR_BACKGROUND);
if (col != COLOR_INVALID)
{
CAST_COLOR(col, rgb);
SetOwnBackgroundColour(rgb);
}
}
wxBoxSizer* pMainSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* pTopSizer = new wxBoxSizer(wxHORIZONTAL);
pMainSizer->Add(pTopSizer);
wxArtID nIco = wxART_INFORMATION;
if (nStyle & wxICON_HAND) nIco = wxART_ERROR; else
if (nStyle & wxICON_INFORMATION) nIco = wxART_INFORMATION; else
if (nStyle & wxICON_EXCLAMATION) nIco = wxART_WARNING; else
if (nStyle & wxICON_QUESTION) nIco = wxART_QUESTION; else
if (nStyle & 0x1000) nIco = "220";
const BOOLEAN bTerminalino = xvt_sys_is_pda();
const int nBorder = bTerminalino ? 2 : 4;
const int nIcon = bTerminalino ? 32 : 64;
const int nWrap = bTerminalino ?160 :400;
const wxBitmap img = wxArtProvider::GetBitmap(nIco, wxART_MESSAGE_BOX, wxSize(nIcon,nIcon));
pTopSizer->Add(new wxStaticBitmap(this, wxID_ANY, img), 0, wxALL|wxALIGN_CENTER, nBorder);
if (msg.StartsWith("<html>") && msg.EndsWith("</html>"))
{
TwxHtmlWindow* html = new TwxHtmlWindow;
html->Create(this, wxID_EDIT, wxDefaultPosition, wxSize(nWrap,nWrap/1.6180339887));
html->SetPage(msg);
pTopSizer->Add(html, 0, wxALL|wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL, nBorder);
}
else
{
wxStaticText* ss = NULL;
if (bTerminalino)
{
int nLines = 0;
wxStringTokenizer tok(msg, wxT("\n"));
for (nLines = 0; tok.HasMoreTokens(); nLines++)
nLines += tok.GetNextToken().Len()/32;
ss = new wxStaticText(this, wxID_EDIT, wxEmptyString, wxDefaultPosition,
wxSize(nWrap, 16*nLines), wxST_NO_AUTORESIZE);
}
else
ss = new wxStaticText(this, wxID_EDIT, wxEmptyString);
ss->Wrap(nWrap);
ss->SetLabel(msg);
pTopSizer->Add(ss, 0, wxALL|wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL, nBorder);
}
pMainSizer->Add(new wxStaticLine(this), wxID_STATIC, wxALL|wxEXPAND, nBorder);
wxFlexGridSizer* pBottomSizer = new wxFlexGridSizer(0, 2, 0, 0);
pBottomSizer->AddGrowableCol(1);
pMainSizer->Add(pBottomSizer, 0, wxGROW|wxALL, nBorder);
wxBoxSizer* pSmallSizer = new wxBoxSizer(wxHORIZONTAL);
pBottomSizer->Add(pSmallSizer, 0, wxALIGN_TOP|wxALL, 0);
wxBoxSizer* pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
pBottomSizer->Add(pButtonSizer, 0, wxALIGN_RIGHT|wxALL, 0);
if (nStyle & wxYES_NO)
{
if (nStyle & 0x60) // Yes,No,*All
{
if (nStyle & 0x20) // No, Yes, Yes All
{
SetAffirmativeId(wxID_YES);
SetEscapeId(wxID_NO);
AddButton(pButtonSizer, wxID_NO);
AddButton(pButtonSizer, wxID_YES);
AddButton(pButtonSizer, 0x20);
}
else // Yes, No, No All
{
SetAffirmativeId(wxID_NO);
SetEscapeId(wxID_YES);
AddButton(pButtonSizer, wxID_YES);
AddButton(pButtonSizer, wxID_NO);
AddButton(pButtonSizer, 0x40);
}
}
else
{
if (nStyle & wxNO_DEFAULT)
{
SetAffirmativeId(wxID_NO);
SetEscapeId(wxID_YES);
AddButton(pButtonSizer, wxID_NO);
AddButton(pButtonSizer, wxID_YES);
}
else
{
SetAffirmativeId(wxID_YES);
SetEscapeId(wxID_NO);
AddButton(pButtonSizer, wxID_YES);
AddButton(pButtonSizer, wxID_NO);
}
}
}
if (nStyle & wxOK)
{
SetAffirmativeId(wxID_OK);
AddButton(pButtonSizer, wxID_OK);
}
if (nStyle & wxCANCEL)
{
SetEscapeId(wxID_CANCEL);
AddButton(pButtonSizer, wxID_CANCEL);
}
if (!bTerminalino)
{
const int nAssYear = xvt_vobj_get_attr(NULL_WIN, ATTR_APPL_VERSION_YEAR);
if (nAssYear >= 2121)
{
const wxBitmap bmpCopy = wxArtProvider::GetBitmap(wxART_COPY, wxART_BUTTON);
wxBitmapButton* btnCopy = new wxBitmapButton(this, wxID_COPY, bmpCopy);
pSmallSizer->Add(btnCopy, 0, wxALIGN_TOP);
/*
if (xvt_mail_installed())
{
const wxBitmap bmpMail = wxArtProvider::GetBitmap("139", wxART_BUTTON, wxSize(bmpCopy.GetWidth(), bmpCopy.GetHeight()));
wxBitmapButton* btnMail = new wxBitmapButton(this, wxID_SAVEAS, bmpMail);
pSmallSizer->Add(btnMail, 0, wxALIGN_TOP);
}
*/
}
}
SetSizerAndFit(pMainSizer);
CentreOnParent();
if (nTimeout > 0)
m_timer.Start(1000*nTimeout, true);
}
///////////////////////////////////////////////////////////
// _*Box
///////////////////////////////////////////////////////////
int _MessageBox(const wxString& msg, int nStyle, int nTimeout = 0)
{
xvt_dm_post_speech(msg, 1, TRUE);
xvt_sys_beep((nStyle & wxICON_ERROR) ? 2 : (nStyle & wxICON_WARNING) ? 1 : 0);
TMessageBox dlg(NULL, msg, nStyle, nTimeout);
const int ret = dlg.ShowModal();
switch(ret)
{
case wxOK : xvt_dm_post_speech(_("ok"), 7, TRUE); break;
case wxYES: xvt_dm_post_speech(_("si"), 7, TRUE); break;
case wxNO : xvt_dm_post_speech(_("no"), 7, TRUE); break;
default : xvt_dm_post_speech(_("annulla"), 7, TRUE); break;
}
return ret;
}
///////////////////////////////////////////////////////////
// _PopUpBox
///////////////////////////////////////////////////////////
class TPopUpBox : public wxDialog
{
DECLARE_EVENT_TABLE();
wxTimer m_Timer;
int m_nStep, m_nTimeout;
protected:
void OnTimer(wxTimerEvent& evt);
void OnChar(wxKeyEvent& evt);
void OnClick(wxMouseEvent& evt);
public:
TPopUpBox(wxWindow* pParent, const wxString& msg, int nStyle, int nTimeout);
};
BEGIN_EVENT_TABLE(TPopUpBox, wxDialog)
EVT_TIMER(wxID_ANY, TPopUpBox::OnTimer)
EVT_CHAR(TPopUpBox::OnChar)
EVT_LEFT_DOWN(TPopUpBox::OnClick)
END_EVENT_TABLE()
void TPopUpBox::OnChar(wxKeyEvent& WXUNUSED(evt))
{
if (IsShown())
{
m_Timer.Stop();
EndModal(wxID_CANCEL);
}
}
void TPopUpBox::OnClick(wxMouseEvent& WXUNUSED(evt))
{
if (IsShown())
{
m_Timer.Stop();
EndModal(wxID_CANCEL);
}
}
void TPopUpBox::OnTimer(wxTimerEvent& WXUNUSED(evt))
{
if (IsShown())
{
const wxRect rctMain = GetParent()->GetRect();
const wxRect rctMine = GetRect();
const int msec = (m_nStep++)*m_Timer.GetInterval();
if (msec <= m_nTimeout/4)
{
const double perc = double(msec)/(m_nTimeout/4);
Move(rctMain.x, rctMain.GetBottom() - rctMine.height * perc);
}
if (msec >= 3*m_nTimeout/4 && msec <= m_nTimeout)
{
const double perc = double(m_nTimeout-msec)/(m_nTimeout/4);
Move(rctMain.x, rctMain.GetBottom() - rctMine.height * perc);
}
if (msec > m_nTimeout)
{
m_Timer.Stop();
EndModal(wxID_CANCEL);
}
}
}
TPopUpBox::TPopUpBox(wxWindow* pParent, const wxString& msg, int nStyle, int nTimeout)
: wxDialog(pParent, wxID_ANY, wxEmptyString, wxPoint(0,2024), wxDefaultSize, wxBORDER_SIMPLE),
m_nTimeout(nTimeout*1000), m_Timer(this), m_nStep(0)
{
TTaskWin* tw = wxDynamicCast(pParent ? pParent : _task_win, TTaskWin);
if (tw != NULL)
{
const COLOR col = tw->GetCtlColor(XVT_COLOR_BACKGROUND);
if (col != COLOR_INVALID)
{
CAST_COLOR(col, rgb);
SetOwnBackgroundColour(rgb);
}
}
wxBoxSizer* sz = new wxBoxSizer(wxHORIZONTAL);
wxArtID nIco = wxART_ERROR;
if (nStyle & wxICON_HAND) nIco = wxART_ERROR; else
if (nStyle & wxICON_INFORMATION) nIco = wxART_INFORMATION; else
if (nStyle & wxICON_EXCLAMATION) nIco = wxART_WARNING; else
if (nStyle & 0x1000) nIco = "220";
const wxBitmap img = wxArtProvider::GetBitmap(nIco, wxART_MESSAGE_BOX);
wxStaticBitmap* bmp = new wxStaticBitmap(this, wxID_ANY, img);
sz->Add(bmp, 0, wxALL, 8);
wxStaticText* ss = new wxStaticText(this, wxID_ANY, wxEmptyString);
ss->Wrap(160);
ss->SetLabel(msg);
sz->Add(ss, 0, wxALL | wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL, 8);
SetSizerAndFit(sz);
m_Timer.Start(25);
}
static void _PopUpBox(const wxString& msg, int nStyle, int nTimeout = 4)
{
wxWindow* pFrame = wxTheApp->GetTopWindow();
bool bCanPopUp = pFrame != NULL && xvt_sys_get_oem_int("OEM", -1) == 0;
#ifdef __WXMSW__
if (bCanPopUp)
bCanPopUp = !OsWin32_IsWindowsServer(); // Animazioni non consigliabili in TS
#endif
if (bCanPopUp)
{
xvt_sys_beep(nStyle & wxICON_ERROR ? 2 : 1);
TPopUpBox dlg(pFrame, msg, nStyle, nTimeout <= 0 ? 4 : nTimeout);
dlg.ShowModal();
}
else
_MessageBox(msg, nStyle|wxOK, nTimeout);
}
WX_DECLARE_STRING_HASH_MAP(int, TMessagesMap);
void xvt_sys_sorry_box(const char* func, const char* file, int line)
{
#ifndef NDEBUG
static TMessagesMap sorry;
if (sorry[func]++ == 0)
{
wxString strMessage;
strMessage.Printf("Function %s in file %s at line %d\nis not implemented yet: be patient...",
func, file, line);
_PopUpBox(strMessage, 0x1000); // Smiley Icon
}
#endif
}
void xvt_sys_deprecated_box(const char* oldfunc, const char* file, const char* newfunc)
{
#ifndef NDEBUG
static TMessagesMap deprecated;
if (deprecated[oldfunc]++ == 0)
{
wxString strMessage;
strMessage.Printf("Function %s in file %s is deprecated:\n%s is much more trendy now!\nYou can blame Guy for this, if you're bold enough!",
oldfunc, file, newfunc);
_PopUpBox(strMessage, 0x1000);
}
#endif
}
///////////////////////////////////////////////////////////
// Speech support
///////////////////////////////////////////////////////////
// 0 Errors
// 1 Warnings
// 2 Messages
// 3 Requests
// 7 Buttons
static int m_nSpeechMode = 0;
void xvt_dm_speech_enable(int mode)
{
#ifdef SPEECH_API
m_nSpeechMode = mode;
if (m_nSpeechMode != 0)
{
if (!OsWin32_InitializeSpeech())
m_nSpeechMode = 0;
}
else
{
OsWin32_DeinitializeSpeech();
}
#endif
}
int xvt_dm_speech_enabled(void)
{ return m_nSpeechMode; }
///////////////////////////////////////////////////////////
// Common dialogs
///////////////////////////////////////////////////////////
void xvt_dm_post_about_box()
{
const char* ver = (const char*)xvt_vobj_get_attr(NULL_WIN, ATTR_APPL_VERSION_STRING);
if (ver == NULL || !*ver) ver = "2015 12.0/100";
wxString msg; msg << "Versione " << ver;
xvt_dm_post_message(msg);
}
BOOLEAN xvt_dm_post_color_sel(COLOR* color, unsigned long reserved)
{
CAST_COLOR(*color, wc);
wxColourData cd;
cd.SetChooseFull(true);
cd.SetColour(wc);
for (int i = 0; i < 16; i++)
{
const unsigned char val = (i & 0x8) ? 255 : 127;
const unsigned char red = (i & 0x1) ? val : 0;
const unsigned char green = (i & 0x2) ? val : 0;
const unsigned char blue = (i & 0x4) ? val : 0;
wxColour col(red, green, blue);
cd.SetCustomColour(i, col);
}
wxWindow* win = wxDynamicCast ((void*)reserved, wxWindow);
wxColourDialog dialog(win, &cd);
if (dialog.ShowModal() == wxID_OK)
{
*color = MAKE_XVT_COLOR(dialog.GetColourData().GetColour());
if (*color == 0) *color = COLOR_BLACK; // 0x000000 confonde XI, mentre con 0x07000000 e' a suo agio
return TRUE;
}
return FALSE;
}
class TwxCalendarDlg : public wxDialog
{
enum { ID_CAL = 1883 };
wxDateTime& m_date;
wxCalendarCtrl* m_cal;
protected:
virtual bool TransferDataFromWindow();
void OnCalendar(wxCalendarEvent& e);
public:
TwxCalendarDlg(wxWindow* parent, wxDateTime& date);
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(TwxCalendarDlg, wxDialog)
EVT_CALENDAR(wxID_ANY, TwxCalendarDlg::OnCalendar)
END_EVENT_TABLE()
void TwxCalendarDlg::OnCalendar(wxCalendarEvent& WXUNUSED(e))
{
wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
AddPendingEvent(evt);
}
bool TwxCalendarDlg::TransferDataFromWindow()
{
bool ok = wxDialog::TransferDataFromWindow();
if (ok)
m_date = m_cal->GetDate();
return ok;
}
TwxCalendarDlg::TwxCalendarDlg(wxWindow* parent, wxDateTime& date)
: wxDialog(parent, wxID_ANY, "Data", wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER), m_date(date)
{
m_cal = new wxCalendarCtrl(this, ID_CAL, m_date, wxDefaultPosition, wxDefaultSize,
wxCAL_MONDAY_FIRST | wxCAL_SHOW_HOLIDAYS | wxCAL_SHOW_SURROUNDING_WEEKS);
wxButton* button = new wxButton(this, wxID_OK, "OK");
wxGridSizer* sizer = new wxFlexGridSizer(2, 1, 8, 8);
sizer->Add(m_cal, 0, wxALIGN_CENTER);
sizer->Add(button, 0, wxALIGN_CENTER);
SetSizer(sizer);
sizer->SetSizeHints(this);
}
unsigned int xvt_dm_post_date_sel(WINDOW win, const RCT* rct, unsigned int ansidate)
{
int d = ansidate%100;
int m = (ansidate/100)%100;
int y = ansidate / 10000;
wxDateTime date;
if (d >= 1 && d <= 31 && m >= 1 && m <= 12 && y > 1900)
date.Set(d, wxDateTime::Month(m-1), y);
else
date = wxDateTime::Today();
CAST_WIN(win, w);
wxDialog* dlg = new TwxCalendarDlg(&w, date);
if (rct != NULL)
{
const wxRect client = w.GetClientRect();
const wxRect rect = dlg->GetRect();
wxPoint pos(rct->right - rect.width, rct->bottom);
if (pos.x < 0)
pos.x = rct->left;
if (rct->bottom + rect.height > client.GetBottom())
pos.y = rct->top - rect.height;
dlg->Move(w.ClientToScreen(pos));
}
if (dlg->ShowModal() == wxID_OK)
{
d = date.GetDay();
m = date.GetMonth()+1;
y = date.GetYear();
ansidate = y*10000 + m*100 + d;
}
dlg->Destroy();
return ansidate;
}
BOOLEAN xvt_dm_post_speech(const char* text, int priority, BOOLEAN async)
{
BOOLEAN ok = FALSE;
#ifdef SPEECH_API
if ((m_nSpeechMode & (1 << priority)) != 0)
ok = OsWin32_Speak(text, async != 0);
#endif
return ok;
}
ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char* WXUNUSED(Btn2), const char* Btn3, const char* fmt)
{
int nFlags = wxICON_QUESTION | wxYES_NO;
if (wxStricmp(Btn1, "no") == 0)
nFlags |= wxNO_DEFAULT;
if (Btn3 != NULL) //il Btn3 è presente sulla maschera (es. noyesall_box, yesnocancel_box)
{
if (wxStricmp(Btn3, "Si Tutti") == 0)
nFlags |= 0x20; else
if (wxStricmp(Btn3, "No Tutti") == 0)
nFlags |= 0x40;
else
nFlags |= wxCANCEL;
}
const int answer = _MessageBox(fmt, nFlags);
return answer == wxYES ? RESP_DEFAULT : (answer == wxNO ? RESP_2 : RESP_3);
}
void xvt_dm_post_error(const char *fmt)
{
_MessageBox(fmt, wxOK | wxICON_HAND);
}
void xvt_dm_post_fatal_exit(const char *fmt)
{
_MessageBox(fmt, wxOK | wxICON_HAND, 10);
abort();
}
static wxString MakeFileName(const wxChar* name, const wxChar* ext)
{
wxString f = name;
if (ext && *ext)
{
if (*ext != '.')
f += '.';
f += ext;
}
return f;
}
static FL_STATUS xvt_dm_post_file_ask(FILE_SPEC *fsp, const char *msg, int flags)
{
DIRECTORY savedir; xvt_fsys_get_curr_dir(&savedir); // Salvo cartella corrente
wxString path = fsp->dir.path;
wxString name = MakeFileName(fsp->name, fsp->type);
wxString extension = fsp->type;
wxString wild;
if (!extension.IsEmpty() && extension != "*")
wild << _("File ") << extension << " (*." << extension << ")|*." << extension << "|";
if (flags & wxFD_OPEN)
wild << _("Tutti i file (*.*)|*.*|");
wild << '|';
wxString selectedname = wxFileSelector(msg, path, name, extension , wild, flags);
if (selectedname.IsEmpty())
return FL_CANCEL;
xvt_fsys_convert_str_to_fspec(selectedname, fsp);
xvt_fsys_set_dir(&savedir); // Ripristino cartella corrente
return FL_OK;
}
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, const char *msg)
{
const int flags = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
return xvt_dm_post_file_ask(fsp, msg, flags);
}
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg)
{
const int flags = wxFD_SAVE | wxFD_OVERWRITE_PROMPT;
return xvt_dm_post_file_ask(fsp, msg, flags);
}
FL_STATUS xvt_dm_post_dir_sel(DIRECTORY *dir)
{
wxDirDialog dlg(_task_win);
dlg.SetPath(dir->path);
if (dlg.ShowModal() == wxID_OK)
{
xvt_fsys_convert_str_to_dir(dlg.GetPath(), dir);
return FL_OK;
}
return FL_CANCEL;
}
BOOLEAN xvt_dm_post_font_sel(WINDOW win, XVT_FNTID font_id, PRINT_RCD* WXUNUSED(precp), unsigned long reserved)
{
CAST_FONT(font_id, font);
wxFontData data;
data.SetInitialFont(font.Font(NULL, win));
data.EnableEffects(reserved != 0);
wxFontDialog dlg(_task_win, data);
BOOLEAN ok = dlg.ShowModal() == wxID_OK;
if (ok)
{
font.Copy(dlg.GetFontData().GetChosenFont());
if (win == (WINDOW)_task_win)
{
EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_FONT;
e.v.font.font_id = font_id;
_task_win_handler(win, &e);
}
}
return ok;
}
void xvt_dm_post_message(const char *fmt)
{
_MessageBox(fmt, wxOK | wxICON_INFORMATION);
}
void xvt_dm_post_note(const char *fmt)
{
_PopUpBox(fmt, wxICON_INFORMATION);
}
char* xvt_dm_post_string_prompt(const char* message, char* response, int response_len)
{
if (message && response && response_len > 0)
{
wxTextEntryDialog dlg(NULL, message, _GetAppTitle(), response);
if (dlg.ShowModal() == wxID_OK)
{
wxStrncpy(response, dlg.GetValue(), response_len);
response[response_len-1] = '\0';
}
else
*response = '\0';
}
return response;
}
void xvt_dm_post_warning(const char *fmt)
{
_MessageBox(fmt, wxOK|wxICON_EXCLAMATION);
}
void xvt_dm_popup_error(const char *fmt)
{
_PopUpBox(fmt, wxICON_HAND);
}
void xvt_dm_popup_message(const char *fmt)
{
_PopUpBox(fmt, wxICON_INFORMATION);
}
void xvt_dm_popup_warning(const char *fmt)
{
_PopUpBox(fmt, wxICON_EXCLAMATION);
}
///////////////////////////////////////////////////////////
// Help system
///////////////////////////////////////////////////////////
#ifdef __WXMSW__
#include "OsWin32.h"
#endif
struct XVAGA_HELP_INFO
{
wxString m_strFilename;
bool m_hlp;
} help_info;
XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC* WXUNUSED(fs), unsigned long WXUNUSED(flags))
{
return (XVT_HELP_INFO)&help_info;
}
void xvt_help_close_helpfile(XVT_HELP_INFO hi)
{
if (hi == NULL_HELP_INFO)
hi = (XVT_HELP_INFO)&help_info;
}
BOOLEAN xvt_help_process_event(XVT_HELP_INFO WXUNUSED(hi), WINDOW win, EVENT *ev)
{
BOOLEAN bProcessed = FALSE;
#ifdef __WXMSW__
WXHWND hwnd = (WXHWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
switch (ev->type)
{
case E_COMMAND:
bProcessed = OsWin32_Help(hwnd, "", ev->v.cmd.tag, NULL);
break;
case E_HELP:
bProcessed = OsWin32_Help(hwnd, "", M_HELP_ONCONTEXT, (const char*)ev->v.help.tid);
break;
default:
break;
}
#endif // WIN32
return bProcessed;
}
///////////////////////////////////////////////////////////
// Progress dialog
///////////////////////////////////////////////////////////
WINDOW xvt_dm_progress_create(WINDOW owner, const char* title, long nTotal, BOOLEAN cancellable)
{
#ifdef __WXMSW__
WXHWND hwnd = (WXHWND)xvt_vobj_get_attr(owner, ATTR_NATIVE_WINDOW);
return (WINDOW)OsWin32_ProgressCreate(hwnd, title, nTotal, cancellable != 0);
#endif
return NULL_WIN;
}
void xvt_dm_progress_destroy(WINDOW prog)
{
#ifdef __WXMSW__
if (prog)
OsWin32_ProgressDestroy((WXHWND)prog);
#endif
}
BOOLEAN xvt_dm_progress_set_status(WINDOW prog, long nCurrent, long nTotal)
{
#ifdef __WXMSW__
return OsWin32_ProgressSetStatus((WXHWND)prog, nCurrent, nTotal);
#endif
return FALSE;
}
void xvt_dm_progress_set_text(WINDOW prog, const char* msg)
{
#ifdef __WXMSW__
OsWin32_ProgressSetText((WXHWND)prog, msg);
#endif
if (msg && *msg)
xvt_app_process_pending_events();
}

1524
src/xvaga01/xvtextra.cpp Normal file

File diff suppressed because it is too large Load Diff

660
src/xvaga01/xvtmail.cpp Normal file
View File

@ -0,0 +1,660 @@
#include "wxinc.h"
#include "xvt.h"
#include "smapi.h"
#include <wx/tokenzr.h>
#include <wx/file.h>
#include <wx/filename.h>
#include <wx/mimetype.h>
#include <wx/textfile.h>
#include <email.h>
#include <smtp.h>
#include <fstream>
static wxString GetMailParam(const char* key, const char* def = "")
{
static wxString ini; // C:\campo\dati\config\user.ini
if (ini.IsEmpty())
{
wxString cu = "ADMIN";
for (int i = __argc-1; i > 1; i--)
{
wxString u = __argv[i]; u.MakeUpper();
if (u.StartsWith("/U") || u.StartsWith("-U"))
{
cu = u.Mid(2);
break;
}
}
char study[_MAX_PATH]; xvt_sys_get_profile_string(NULL, "Main", "Study", "", study, sizeof(study));
ini = study;
if (!wxEndsWithPathSeparator(ini))
ini += wxFILE_SEP_PATH;
ini += "config\\"; ini += cu; ini += ".ini";
}
wxString val; const size_t sz = _MAX_PATH;
xvt_sys_get_profile_string(ini, "Mail", key, def, val.GetWriteBuf(sz), sz);
val.UngetWriteBuf();
return val;
}
static wxString __smtp = "notset";
static wxString __port = "notset";
static wxString __user = "notset";
static wxString __pass = "notset";
static wxString __from = "notset";
void xvt_set_mail_params(const char * smtp, const char * port, const char * user, const char * pass, const char * from)
{
if (__smtp == "notset")
{
__smtp = GetMailParam("Server", "MAPI");
__port = GetMailParam("Port");
__user = GetMailParam("User");
__pass = GetMailParam("Password");
wxString f = (user && *user) ? user: __user;
if (f.find('@') < 0)
{
f += "@";
f += __smtp.AfterFirst('.');
}
__from = GetMailParam("From", f);
}
if (smtp && *smtp)
__smtp = _strdup(smtp);
if (port && *port)
__port = _strdup(port);
if (user && *user)
__user = _strdup(user);
if (pass && *pass)
__pass = _strdup(pass);
}
static bool GetMailParams(wxString& smtp, wxString& port, wxString& user, wxString& pass, wxString& from)
{
if (__smtp == "notset")
{
__smtp = GetMailParam("Server", "MAPI");
__port = GetMailParam("Port");
__user = GetMailParam("User");
__pass = GetMailParam("Password");
}
smtp = __smtp;
port = __port;
user = __user;
pass = __pass;
if (__from == "notset")
{
wxString f = user;
if (f.find('@') < 0)
{
f += "@";
f += __smtp.AfterFirst('.');
}
__from = GetMailParam("From", f);
}
from = __from;
return !smtp.IsEmpty() && !pass.IsEmpty();
}
static bool has_power_mail()
{
return GetMailParam("Powershell") == "X";
}
static bool has_ccnsend()
{
return GetMailParam("CcnSend") == "X";
}
short xvt_mail_installed()
{
short bInstalled = 0;
if (::GetProfileInt(_T("MAIL"), _T("MAPI"), 0) != 0 &&
SearchPath(NULL, _T("MAPI32.DLL"), NULL, 0, NULL, NULL) != 0)
bInstalled |= 0x1;
if (xvt_fsys_file_exists("servers/mailsend.exe") || has_power_mail())
{
wxString smtp, port, user, pass, from;
GetMailParams(smtp, port, user, pass, from);
if (!pass.IsEmpty() && smtp != "MAPI")
bInstalled |= 0x2;
}
return bInstalled;
}
static void AppendQuotedString(wxString& cmd, const char* key, const wxString& value)
{
if (!value.IsEmpty())
cmd << " -" << key << " \"" << value << "\"";
}
static void AppendAttachment(wxString& cmd, const wxString& fname, bool att = true)
{
if (wxFileName::FileExists(fname))
{
char ext[_MAX_EXT] = { 0 };
xvt_fsys_parse_pathname (fname, NULL, NULL, NULL, ext, NULL);
wxString mime = ext;
wxFileType* ft = wxTheMimeTypesManager->GetFileTypeFromExtension(mime);
if (ft != NULL)
{
wxArrayString aMime;
if (ft->GetMimeTypes(aMime))
mime = aMime[0];
}
if (att)
{
wxString a; a << fname << "," << mime << ",a";
AppendQuotedString(cmd, "attach", a);
}
else
{
wxString a; a << fname << "," << mime << ",i";
AppendQuotedString(cmd, "attach", a);
}
}
}
///////////////////////////////////////////////////////////
// wxEmailDlg
///////////////////////////////////////////////////////////
class wxEmailDlg : public wxDialog
{
protected:
wxTextCtrl* AddString(wxSizer* ctlSizer, int id, const char* label, wxString* str);
public:
wxString _strEmail;
wxEmailDlg();
};
wxTextCtrl* wxEmailDlg::AddString(wxSizer* ctlSizer, int id, const char* label, wxString* str)
{
wxStaticText* lbl = new wxStaticText(this, wxID_ANY, label);
const int k = 20, b = k / 10;
wxTextCtrl* txt = new wxTextCtrl(this, id, wxEmptyString, wxDefaultPosition, wxSize(20 * k, k),
0, wxTextValidator(wxFILTER_ASCII, str));
ctlSizer->Add(lbl, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, b);
ctlSizer->Add(txt, 1, wxALIGN_LEFT | wxALL, b);
return txt;
}
wxEmailDlg::wxEmailDlg() : wxDialog(NULL, wxID_ANY, "Email",
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE)
{
wxSizer* ctlTextSizer = new wxFlexGridSizer(4, 2, 8, 8);
AddString(ctlTextSizer, 1001, "Destinatario", &_strEmail);
wxSizer* ctlButtonSizer = CreateButtonSizer(wxOK | wxCANCEL);
wxBoxSizer* ctlTopSizer = new wxBoxSizer(wxVERTICAL);
ctlTopSizer->Add(ctlTextSizer, 0, wxALIGN_CENTER);
ctlTopSizer->Add(ctlButtonSizer, 0, wxALIGN_CENTER);
SetSizer(ctlTopSizer);
ctlTopSizer->SetSizeHints(this);
}
BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn,
const char* subject, const char* msg,
const char* attach, short flags)
{
const short mail_inst = xvt_mail_installed();
wxString server, port, user, password, from;
bool mailsend = (mail_inst & 0x2) && GetMailParams(server, port, user, password, from);
bool ui = mailsend && ((flags & 0x1) != 0);
wxString str_to(to);
if (ui)
{
wxEmailDlg dlg;
dlg._strEmail = str_to;
if (dlg.ShowModal() == wxID_OK)
str_to = dlg._strEmail;
}
wxStringTokenizer tokTo(str_to, _T(";"));
wxMailMessage Msg(subject, tokTo.GetNextToken(), msg);
Msg.m_query_receipt = flags & 0x2;
while (tokTo.HasMoreTokens())
Msg.AddTo(tokTo.GetNextToken());
if (Msg.m_to[0].IsEmpty())
{
Msg.m_to[0] = " "; // Il destinatario "" fa piantare MAPI con errore 25
ui = true; // Forza user interface in assenza di recipient
}
if (attach && *attach)
{
wxStringTokenizer tokAttach(attach, _T(";"));
while (tokAttach.HasMoreTokens())
Msg.AddAttachment(tokAttach.GetNextToken());
}
if (cc && *cc)
{
wxStringTokenizer Tok(cc, _T(";"));
while (Tok.HasMoreTokens())
Msg.AddCc(Tok.GetNextToken());
}
if (ccn && *ccn)
{
wxString strCCn(ccn);
if (has_ccnsend())
strCCn << ";" << from;
wxStringTokenizer Tok(strCCn, _T(";"));
while (Tok.HasMoreTokens())
Msg.AddBcc(Tok.GetNextToken());
}
BOOLEAN ok = false;
if (mailsend)
{
wxString cmd = "servers/mailsend.exe";
AppendQuotedString(cmd, "smtp", server);
if (!port.IsEmpty())
{
cmd += " -port ";
cmd += port;
}
AppendQuotedString(cmd, "from", from);
if ((flags & 0x2) && from.Find("@") > 0)
{
//AppendQuotedString(cmd, "rt", from);
AppendQuotedString(cmd, "rrr", from);
}
// Lista dei destinatari
for (size_t i = 0; i < Msg.m_to.size(); i++)
AppendQuotedString(cmd, "to", Msg.m_to[i]);
// Lista dei destinatari in copia
for (size_t i = 0; i < Msg.m_cc.size(); i++)
AppendQuotedString(cmd, "cc", Msg.m_cc[i]);
if (cmd.Find("-cc") < 0)
cmd += " +cc"; // In assenza di destinatari in copia aggiungo +cc
// Lista dei destinatari in copia nascosta
for (size_t i = 0; i < Msg.m_bcc.size(); i++)
AppendQuotedString(cmd, "bc", Msg.m_bcc[i]);
if ((flags & 0x4) && from.Find("@") > 0)
{
wxString strMyself; strMyself << "c " << from;
if (cmd.Find(strMyself) < 0)
AppendQuotedString(cmd, "bc", from); // Aggiungo me stesso ai destinatari nascosti
}
if (cmd.Find("-bc") < 0)
cmd += " +bc"; // In assenza di destinatari nascosti aggiungo +bc
AppendQuotedString(cmd, "sub", Msg.m_subject);
AppendQuotedString(cmd, "user", user);
AppendQuotedString(cmd, "pass", password);
AppendQuotedString(cmd, "enc-type", "base64");
if (!Msg.m_attachments.IsEmpty())
{
for (size_t a = 0; a < Msg.m_attachments.size(); a++)
{
const wxString& fn = Msg.m_attachments[a];
if (wxFileName::FileExists(fn))
AppendAttachment(cmd, fn);
}
}
wxString ftmp;
if (Msg.m_body.IsEmpty())
{
if (cmd.Find("-M ") < 0)
{
wxString m; m << "Cordiali saluti\n" << from;
m.Trim();
AppendQuotedString(cmd, "M", m);
}
}
else
{
wxStringTokenizer tok(Msg.m_body, "\n");
Msg.m_body.Trim();
if (Msg.m_body.Find("\n") < 0)
AppendQuotedString(cmd, "M", Msg.m_body);
else
{
DIRECTORY tmp; xvt_fsys_get_temp_dir(&tmp);
xvt_fsys_build_pathname(ftmp.GetWriteBuf(_MAX_PATH), NULL, tmp.path, "msgbody", "html", NULL);
ftmp.UngetWriteBuf();
wxFile file(ftmp, wxFile::write);
file.Write("<html><body>\n");
Msg.m_body.Replace("\n", "<br>");
file.Write(Msg.m_body);
file.Write("\n</body><html>\n");
file.Close();
AppendAttachment(cmd, ftmp, false);
}
}
const wxString strLog = "mailsend.log";
xvt_fsys_remove_file(strLog);
AppendQuotedString(cmd, "log", strLog);
int nRetry = wxAtoi(GetMailParam("Retry", "2"));
if (nRetry <= 0) nRetry = 2;
ok = FALSE;
for (int r = 0; r < nRetry && !ok; r++)
{
if (r > 0)
{
const int nSeconds = 5*r;
WINDOW w = xvt_dm_progress_create(TASK_WIN, "MailSend retrying...", nSeconds, TRUE);
for (int s = 1; s <= nSeconds; s++)
{
xvt_sys_sleep(1000);
xvt_dm_progress_set_status(w, s, nSeconds);
}
xvt_dm_progress_destroy(w);
}
wxExecute(cmd, wxEXEC_SYNC);
wxFile fLog(strLog, wxFile::read);
const wxFileOffset flen = fLog.Length();
if (flen > 0)
{
char* buff = (char*)calloc(flen+8, 1); // zero filled buffer
fLog.Read(buff, flen);
if (wxStrstr(buff, "Mail sent successfully"))
ok = TRUE;
delete [] buff;
}
}
}
else
if (mail_inst & 1)
{
xvt_fsys_save_dir();
ok = Msg.Send(wxEmptyString, ui);
xvt_fsys_restore_dir();
}
return ok;
}
void buildPSArray(wxString& str)
{
if (str.Find(";") >= 0)
{
wxStringTokenizer str_tok(str, ";");
str = "";
while (str_tok.HasMoreTokens())
{
if (str_tok.GetPosition() > 0)
str << ",";
str << '\'' << str_tok.GetNextToken() << '\'';
}
}
else
{
wxString wrkstr(str);
str = "\'";
str << wrkstr << "\'";
}
}
BOOLEAN xvt_powermail_send(const char* to, const char* cc, const char* ccn,
const char* subject, const char* msg,
const char* attach, short flags, const char* usr)
{
wxString server, port, user, password, from;
// Controllo che Windows sia almeno 8 e che riesca a ricevere i parametri E-mail
if(xvt_sys_get_os_version() < XVT_WS_WIN_7 || !GetMailParams(server, port, user, password, from))
xvt_mail_send(to, cc, ccn, subject, msg, attach, flags);
wxString str_to(to);
if ((flags & 0x1) != 0)
{
wxEmailDlg dlg;
dlg._strEmail = str_to;
if (dlg.ShowModal() == wxID_OK)
str_to = dlg._strEmail;
}
DIRECTORY tmp; xvt_fsys_get_temp_dir(&tmp);
// Per togliere il rischio di sovrapposizioni vado nella cartella dell'utente
wxString userTemp; userTemp << tmp.path << "\\" << usr;
wxString powerFile;
static int powerNumber = 0;
wxString powerName = "powermail_"; powerName << ++powerNumber;
xvt_fsys_build_pathname(powerFile.GetWriteBuf(_MAX_PATH), NULL, userTemp, powerName, "ps1", NULL);
powerFile.UngetWriteBuf();
// Creo il file
wxFile file(powerFile, wxFile::write);
// Parsing port tokens
/* Token dictionary (all case insensitive):
* 465/587/... port
* -SSL Enable ssl/tls
* -nbcc No Blind Carbon Copy
*/
wxStringTokenizer portTok(port, " ");
wxString port_number;
bool ssl = false, hasccn = ccn && *ccn, hascc = cc && *cc;
while(portTok.HasMoreTokens())
{
wxString tok = portTok.GetNextToken();
if (tok[0] >= '0' && tok[0] <= '9')
port_number = tok;
if (tok.Upper() == "-SSL")
ssl = true;
if (tok.Upper() == "-NBCC")
hasccn = false;
}
// Hard code and no play makes Tolla a dull programmer
file.Write("$Server = \""); file.Write(server); file.Write("\"\n");
file.Write("$Port = \""); file.Write(port_number); file.Write("\"\n");
file.Write("$SSL = ");
if(ssl)
file.Write("$true");
else
file.Write("$false");
file.Write("\n");
file.Write("$Username = \""); file.Write(user); file.Write("\"\n");
file.Write("$Password = \""); file.Write(password); file.Write("\"\n");
file.Write("$From = \""); file.Write(from); file.Write("\"\n");
buildPSArray(str_to);
file.Write("$To = "); file.Write(str_to); file.Write("\n");
file.Write("$Subject = \""); file.Write(subject); file.Write("\"\n");
file.Write("$Body = \""); file.Write(msg); file.Write("\"\n");
if (hascc)
{
wxString str_cc(cc);
buildPSArray(str_cc);
file.Write("$CC = "); file.Write(str_cc); file.Write("\n");
}
if (hasccn || has_ccnsend())
{
wxString str_ccn(from);
if (ccn && *ccn)
str_ccn << ";" << ccn;
buildPSArray(str_ccn);
file.Write("$Bcc = "); file.Write(str_ccn); file.Write("\n");
}
file.Write(
"$message = new-object Net.Mail.MailMessage\n"
"$message.From = $From\n"
"$message.To.Add($To)\n");
//TODO same per from e to
//mettere un flag nella mask per decidere se mettere in CC o in CCn
if (hascc)
{
file.Write("foreach($i in $CC)\n"
"{ $message.CC.Add($i) }\n");
}
if (hasccn || has_ccnsend())
{
file.Write("foreach($i in $Bcc)\n"
"{ $message.Bcc.Add($i)}\n");
}
file.Write(
"$message.Subject = $Subject\n"
"$message.Body = $Body\n"
);
if (flags & 0x2)
file.Write("$message.DeliveryNotificationOptions = 1\n");
// Aggiungo a schiena gli allegati
if (attach && *attach)
{
wxStringTokenizer tokAttach(attach, _T(";"));
int i = 0;
while (tokAttach.HasMoreTokens())
{
wxString attachmentLine;
attachmentLine << "$attach" << ++i << "= New-Object Net.Mail.Attachment(\""
<< tokAttach.GetNextToken() << "\");\n" << "$message.Attachments.Add("
<< "$attach" << i << ")\n";
file.Write(attachmentLine);
}
}
file.Write(
"$smtp = new-object Net.Mail.SmtpClient($Server, $Port);\n"
"$smtp.EnableSSL = $SSL;\n"
"$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);\n"
"try\n"
"{\n"
" $smtp.send($message);\n"
" write-host \"E-Mail sent\" \n"
" $exitCode = 0 \n"
" exit $exitCode \n"
"}\n"
"catch\n"
"{\n"
" write-host \"E-Mail not sent\" ; \n"
" write-host $_.Exception.Message ;\n"
" $exitCode = 1 \n"
" exit $exitCode \n"
"}\n"
);
file.Close();
wxString command("powershell.exe ");
//una volta scritto lo scritp ps1 cos'è che lo runna? Dove vinene aperta la PowerShell?
// al momento lo script generato da campo funziona se runnato direttamente da powershell
command << powerFile;
FILE *f;
fopen_s(&f, "maillog.log", "w");
fprintf(f, "Comando %s\n", (const char*)command);
int exit = xvt_sys_execute(command, true, true);
fprintf(f, "exitcode = %d\n", exit);
fclose(f);
return exit == 0;
}
BOOLEAN xvt_wx_mail_send(const char* to, const char* cc, const char* ccn,
const char* subject, const char* msg,
const char* attach, short flags)
{
wxString server, port, user, password, from;
GetMailParams(server, port, user, password, from);
bool ui = (flags & 0x1) != 0;
wxSMTP * Smtp = new wxSMTP(nullptr);
wxString str_to(to);
bool ok = true;
if (ui)
{
wxEmailDlg dlg;
dlg._strEmail = str_to;
if (dlg.ShowModal() == wxID_OK)
str_to = dlg._strEmail;
}
wxStringTokenizer tokTo(str_to, _T(";"));
wxEmailMessage * Msg = new wxEmailMessage(subject, msg, from);
// da trovare Msg->m_query_receipt = flags & 0x2;
while (tokTo.HasMoreTokens())
Msg->AddTo(tokTo.GetNextToken());
if (attach && *attach)
{
wxStringTokenizer tokAttach(attach, _T(";"));
while (tokAttach.HasMoreTokens())
Msg->AddFile(tokAttach.GetNextToken());
}
if (cc && *cc)
{
wxStringTokenizer Tok(cc, _T(";"));
while (Tok.HasMoreTokens())
Msg->AddCc(Tok.GetNextToken());
}
if (ccn && *ccn)
{
wxString strCCn(ccn);
if (has_ccnsend())
strCCn << ";" << from;
wxStringTokenizer Tok(strCCn, _T(";"));
while (Tok.HasMoreTokens())
Msg->AddBcc(Tok.GetNextToken());
}
int service = atoi(port);
if (service == 0)
service = 25;
Smtp->SetHost(server, service, from, password);
Smtp->Send(Msg);
Smtp->SendData();
delete Msg;
delete Smtp;
return ok;
}

298
src/xvaga01/xvtodbc.cpp Normal file
View File

@ -0,0 +1,298 @@
#include "wxinc.h"
#include "xvt.h"
#include <wx/db.h>
///////////////////////////////////////////////////////////
// TwxConnectionDlg
///////////////////////////////////////////////////////////
class TwxConnectionDlg : public wxDialog
{
protected:
wxTextCtrl* AddString(wxSizer* ctlSizer, int id, const char* label, wxString* str);
public:
wxString _strDsn, _strUsr, _strPwd, _strDir;
TwxConnectionDlg();
};
wxTextCtrl* TwxConnectionDlg::AddString(wxSizer* ctlSizer, int id, const char* label, wxString* str)
{
wxStaticText* lbl = new wxStaticText(this, wxID_ANY, label);
const int k = 20, b = k/10;
wxTextCtrl* txt = new wxTextCtrl(this, id, wxEmptyString, wxDefaultPosition, wxSize(20*k, k),
0, wxTextValidator(wxFILTER_ASCII, str));
ctlSizer->Add(lbl, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, b);
ctlSizer->Add(txt, 1, wxALIGN_LEFT | wxALL, b);
return txt;
}
TwxConnectionDlg::TwxConnectionDlg() : wxDialog(NULL, wxID_ANY, "ODBC",
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE)
{
wxSizer* ctlTextSizer = new wxFlexGridSizer(4, 2, 8, 8);
AddString(ctlTextSizer, 1001, "Dsn", &_strDsn);
AddString(ctlTextSizer, 1002, "User", &_strUsr);
AddString(ctlTextSizer, 1003, "Password", &_strPwd);
AddString(ctlTextSizer, 1004, "Directory", &_strDir);
wxSizer* ctlButtonSizer = CreateButtonSizer(wxOK | wxCANCEL);
wxBoxSizer* ctlTopSizer = new wxBoxSizer(wxVERTICAL);
ctlTopSizer->Add(ctlTextSizer, 0, wxALIGN_CENTER);
ctlTopSizer->Add(ctlButtonSizer, 0, wxALIGN_CENTER);
SetSizer(ctlTopSizer);
ctlTopSizer->SetSizeHints(this);
}
///////////////////////////////////////////////////////////
// xvt_odbc_...
///////////////////////////////////////////////////////////
static wxDbConnectInf* ci = nullptr;
static wxString strDsn, strUsr, strPwd, strDir;
XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir)
{
if (strDsn != dsn && ci != nullptr)
{
delete ci;
ci = nullptr;
}
strDsn = dsn;
strUsr = usr;
strPwd = pwd;
strDir = dir;
if (strDsn.IsEmpty())
{
TwxConnectionDlg* dlg = new TwxConnectionDlg;
if (dlg->ShowModal() == wxID_OK)
{
strDsn = dlg->_strDsn;
strUsr = dlg->_strUsr;
strPwd = dlg->_strPwd;
strDir = dlg->_strDir;
}
dlg->Destroy();
if (strDsn.IsEmpty())
return (XVT_ODBC)nullptr;
}
if (ci == nullptr)
{
ci = new wxDbConnectInf(NULL, strDsn, strUsr, strPwd, strDir);
// Set the ODBC version environment
SQLSetEnvAttr(ci->GetHenv(), SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
}
bool bSuccess = false;
wxDb* db = new wxDb(ci->GetHenv(), true);
if (strDsn.Find(';') > 0)
bSuccess = db->Open(strDsn); // Use connection string
else
bSuccess = db->Open(ci); // Use DSN, user and password
if (!bSuccess)
{
int err = db->DB_STATUS;
db->DispNextError();
if (ci != nullptr)
{
delete ci;
ci = nullptr;
}
strDsn = "";
delete db;
db = nullptr;
}
return (XVT_ODBC)db;
}
BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle)
{
BOOLEAN ok = handle != NULL;
if (ok)
{
wxDb* db = (wxDb*)handle;
db->CommitTrans();
db->Close();
if (ci != nullptr)
{
delete ci;
ci = nullptr;
}
strDsn = "";
delete db;
}
return ok;
}
BOOLEAN xvt_odbc_log_file(XVT_ODBC handle, const char* str)
{
BOOLEAN ok = handle != NULL;
if (ok)
{
wxDb* db = (wxDb*)handle;
if (str && *str)
ok = db->SetSqlLogging(sqlLogON, wxString(str));
else
db->SetSqlLogging(sqlLogOFF, wxEmptyString);
}
return ok;
}
ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly)
{
ULONG nCount = 0;
if (handle && sql && *sql)
{
wxDb* db = (wxDb*)handle;
if (cb != NULL) // Ho una vera callback?
{
wxDbColInf* columns = NULL;
short numcols = 0;
if (db->ExecSql(sql, &columns, numcols) && numcols > 0)
{
const size_t BUF_SIZE = 1024*64;
char* buffer = new char[BUF_SIZE]; // Valore di un singolo campo
char** values = new char*[numcols]; // Lista dei valori del record corrente
memset(values, 0, numcols*sizeof(char*));
char** names = new char*[numcols*2]; // Lista dei nomi dei campi e dei tipi
memset(names, 0, numcols*2*sizeof(char*));
short c;
for (c = 0; c < numcols; c++)
{
const wxDbColInf& info = columns[c];
names[c] = (char*)info.colName;
switch (info.dbDataType)
{
case DB_DATA_TYPE_INTEGER:
case DB_DATA_TYPE_FLOAT:
names[c+numcols] = "NUMERIC"; break;
case DB_DATA_TYPE_DATE:
names[c+numcols] = "DATE"; break;
default:
names[c+numcols] = "VARCHAR"; break;
}
}
wxArrayString data;
for (nCount = 0; db->GetNext(); nCount++)
{
data.Empty(); // Svuota l'array
for (c = 0; c < numcols; c++)
{
const wxDbColInf& info = columns[c];
try
{
SDWORD cbReturned = SQL_NULL_DATA;
switch (info.dbDataType)
{
case DB_DATA_TYPE_DATE:
{
db->GetData(c+1, SQL_C_CHAR, buffer, BUF_SIZE, &cbReturned);
int d = 0, m = 0, y = 0;
int n = sscanf(buffer, "%04d-%02d-%02d", &y, &m, &d);
if (n == 3 && d > 0)
sprintf(buffer, "%04d%02d%02d", y, m, d);
else
buffer[0] = '\0';
}
break;
default:
db->GetData(c+1, SQL_C_CHAR, buffer, BUF_SIZE, &cbReturned);
break;
}
if (cbReturned == SQL_NULL_DATA)
buffer[0] = '\0';
data.Add(buffer);
}
catch (...)
{
break;
}
}
for (c = 0; c < (short)data.GetCount(); c++)
values[c] = (char*)data[c].c_str();
const int err = cb(jolly, numcols, values, names);
if (err != 0)
break;
}
delete values; // butta la lista dei valori
delete names; // butta la lista dei nomi
delete buffer; // butta il buffer temporaneo
}
}
else
{
wxString cmd(sql); cmd.MakeUpper();
if (cmd.StartsWith("BEGIN"))
/* DO NOTHING! */; else
if (cmd.StartsWith("COMMIT"))
db->CommitTrans(); else
if (cmd.StartsWith("SELECT"))
{
// Senza callback mi limito a contare i records
if (db->ExecSql(sql))
for (nCount = 0; db->GetNext(); nCount++);
else
nCount = -db->nativeError;
}
else
if (cmd.StartsWith("SHOW"))
{
if (db->ExecSql(sql))
for (nCount = 0; db->GetNext(); nCount++);
else
nCount = -db->nativeError;
}
else
{
db->SetDebugErrorMessages(true);
if (db->ExecSql(sql))
nCount = 1;
else
nCount = -db->nativeError;
db->SetDebugErrorMessages(false);
}
}
}
return nCount;
}
BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size)
{
if (str != NULL && max_size > 8)
{
if (handle != NULL)
{
const wxDb* db = (const wxDb*)handle;
wxStrncpy(str, db->dbInf.driverName, max_size);
}
else
wxStrncpy(str, "ODBC 2.0", max_size);
}
return handle != NULL;
}

1233
src/xvaga01/xvtpdf.cpp Normal file

File diff suppressed because it is too large Load Diff

133
src/xvaga01/xvtpdf.h Normal file
View File

@ -0,0 +1,133 @@
#ifndef __XVTPDF_H
#define __XVTPDF_H
#ifndef PDFLIB_H
struct PDF_c {};
#include "../pdf/pdflib/pdflibdl.h"
#endif
///////////////////////////////////////////////////////////
// TwxPDFDC
///////////////////////////////////////////////////////////
class TwxPDFDC : public wxDC
{
enum { PDF_IMG_CACHE_SIZE = 32 };
protected:
TwxPDFDC(); // Dummy constructor for dynamic construction
bool IsValidFontFile(const char* strFontFile) const;
bool GetFontFamily(const wxFont& font, wxString& file, wxString& family) const;
public:
// Recommended constructor
TwxPDFDC(const wxPrintData& data, const char* strFilename);
~TwxPDFDC();
virtual bool Ok() const;
bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE );
bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
void DoCrossHair(wxCoord x, wxCoord y) ;
void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
void DoDrawPoint(wxCoord x, wxCoord y);
void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20);
void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
void DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection);
void DoDrawSpline(wxList *points);
bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = FALSE,
wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
bool CanDrawBitmap() const { return true; }
void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y );
void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask=FALSE );
void DoDrawImage( const wxString& name, const wxRect& dst );
void DrawImage( const wxString& name, const wxRect& dst )
{ DoDrawImage(name, dst); }
void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
void Clear();
void SetFont( const wxFont& font );
void SetPen( const wxPen& pen );
void SetBrush( const wxBrush& brush );
void SetLogicalFunction( int function );
void SetBackground( const wxBrush& brush );
void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
void DestroyClippingRegion();
void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
bool StartDoc(const wxString& message);
void EndDoc();
void StartPage();
void EndPage();
wxCoord GetCharHeight() const;
wxCoord GetCharWidth() const;
bool CanGetTextExtent() const { return true; }
void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent = (wxCoord *) NULL,
wxCoord *externalLeading = (wxCoord *) NULL,
wxFont *theFont = (wxFont *) NULL ) const;
void DoGetSize(int* width, int* height) const;
void DoGetSizeMM(int *width, int *height) const;
// Resolution in pixels per logical inch
wxSize GetPPI() const;
void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
void SetDeviceOrigin( wxCoord x, wxCoord y );
void SetBackgroundMode(int WXUNUSED(mode)) { }
void SetPalette(const wxPalette& WXUNUSED(palette)) { }
const wxPrintData& GetPrintData() const { return m_printData; }
void SetPrintData(const wxPrintData& data) { m_printData = data; }
virtual int GetDepth() const { return 24; }
const wxString& OutputFile() const { return m_fileName; }
protected:
void SetFontColor(const wxColor& color) const;
int GetBitmapHandle(const wxBitmap& bitmap) const;
int GetImageHandle(const wxString& name);
PDF *m_p;
PDFlib_api *m_PDFlib;
wxPrintData m_printData;
wxString m_fileName;
wxColor m_color;
int m_pageNumber;
int m_fontnr;
bool m_clipping;
bool m_topDown;
bool m_pageopen;
double m_fontsize; // m_ascent + m_descent
double m_ascent, m_descent, m_leading;
wxString m_filenames[PDF_IMG_CACHE_SIZE];
int m_handles[PDF_IMG_CACHE_SIZE];
int m_cacheidx;
DECLARE_DYNAMIC_CLASS(TwxPDFDC)
};
#endif

28
src/xvaga01/xvtslt.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef XVT_XSLT
#define XVT_XSLT
#ifdef WIN32
#ifdef XVAGADLL
#define XSLTDLL __declspec(dllexport)
#else
#define XSLTDLL __declspec(dllimport)
#endif
#else
#define XSLTDLL
#endif
#ifdef __cplusplus
extern "C" {
#endif
XSLTDLL int xvt_xslt_transform(const char * infile, const char * stylefile, const char * outfile); // Added by AGA
#ifdef __cplusplus
}
#endif
#endif

1247
src/xvaga01/xvtwin.cpp Normal file

File diff suppressed because it is too large Load Diff

258
src/xvaga01/xvtwin.h Normal file
View File

@ -0,0 +1,258 @@
#ifndef __XVTWIN_H
#define __XVTWIN_H
#ifndef _WX_PROCESSH__
#include <wx/process.h>
#endif
class TFontId : public wxObject
{
wxString m_strFace;
int m_nSize;
XVT_FONT_STYLE_MASK m_wMask;
WINDOW m_win;
DECLARE_DYNAMIC_CLASS(TFontId);
protected:
void Copy(const TFontId& pFont);
bool IsEqual(const TFontId& pFont) const;
public:
void SetWin(WINDOW w) { m_win = w; }
WINDOW Win() const { return m_win; }
void SetPointSize(int s) { m_nSize = s; }
int PointSize() const { return m_nSize; }
void SetMask(XVT_FONT_STYLE_MASK mask) { m_wMask = mask; }
XVT_FONT_STYLE_MASK Mask() const { return m_wMask; }
int Style() const;
bool Underline() const;
int Weight() const;
void SetFaceName(const char* f) { m_strFace = f; }
const char* FaceName() const;
int Family() const;
void Copy(const wxFont& rFont);
const wxFont& Font(wxDC* dc, WINDOW w) const;
TFontId& operator=(const TFontId& f) { Copy(f); return *this; }
bool operator==(const TFontId& f) const { return IsEqual(f); }
bool operator!=(const TFontId& f) const { return !IsEqual(f); }
TFontId() : m_nSize(0), m_wMask(0), m_win(NULL_WIN) { }
TFontId(const TFontId& f) : m_win(NULL_WIN) { Copy(f); }
};
class TDC : public wxObject
{
wxWindow* _owner;
protected:
wxDC* _dc;
RCT _clip;
int _dirty; // false = 0, true = 1, very_dirty = -1;
int _deltaf;
DRAW_CTOOLS _real_dct;
TFontId _real_font;
RCT _real_clip;
bool PenChanged() const;
bool BrushChanged() const;
bool FontChanged() const;
bool ClipChanged() const;
public:
DRAW_CTOOLS _dct;
TFontId _font;
wxPoint _pnt;
void SetClippingBox(const RCT* pRct);
bool GetClippingBox(RCT* pRct) const;
void SetDirty(int d = 1);
int GetFontDelta() const { return _deltaf; }
virtual wxDC& GetDC(bool bPaint = false);
virtual void KillDC();
TDC(wxWindow* owner);
virtual ~TDC();
};
class TPrintDC : public TDC
{
static bool _page_start;
public:
static void SetPageStart();
virtual wxDC& GetDC(bool);
virtual void KillDC();
TPrintDC(wxWindow* owner);
virtual ~TPrintDC();
};
WX_DECLARE_HASH_MAP(WINDOW, TDC*, wxIntegerHash, wxIntegerEqual, wxTDCHashMap);
class TDCMapper : public wxTDCHashMap
{
WINDOW _pLastOwner;
TDC* _pLastTDC;
public:
TDC& GetTDC(WINDOW owner);
wxDC& GetDC(WINDOW owner, bool bPaint = false) { return GetTDC(owner).GetDC(bPaint); }
void DestroyDC(WINDOW owner);
void DestroyTDC(WINDOW owner);
bool HasValidDC(WINDOW owner) const;
TDCMapper() : _pLastOwner(NULL_WIN), _pLastTDC(NULL) { }
virtual ~TDCMapper() { DestroyTDC(NULL_WIN); }
};
TDCMapper& GetTDCMapper();
class TwxWindowBase : public wxWindow
{
#ifdef LINUX
private:
wxString m_strTitle;
virtual void SetTitle(const wxString& title) { wxWindow::SetTitle(m_strTitle = title); }
virtual wxString GetTitle() const { return m_strTitle; }
#endif
#ifdef WIN32
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif
public:
bool CreateBase(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, long style);
TwxWindowBase() { }
TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint & pos, const wxSize & size, long style);
DECLARE_DYNAMIC_CLASS(TwxWindowBase)
};
class wxAuiManager;
class TwxWindow : public TwxWindowBase
{
private:
MENU_ITEM* m_menu;
wxAuiManager* m_pManager;
bool m_bInDestroy;
protected:
virtual void OnChar(wxKeyEvent& e);
virtual void OnClose(wxCloseEvent& e);
virtual void OnKeyDown(wxKeyEvent& e);
virtual void OnKillFocus(wxFocusEvent& e);
virtual void OnMenu(wxCommandEvent& e);
virtual void OnMouseCaptureLost(wxMouseCaptureLostEvent& e);
virtual void OnMouseDouble(wxMouseEvent& e);
virtual void OnMouseDown(wxMouseEvent& e);
virtual void OnMouseMove(wxMouseEvent& e);
virtual void OnMouseUp(wxMouseEvent& e);
virtual void OnMouseWheel(wxMouseEvent& e);
virtual void OnScroll(wxScrollEvent& e);
virtual void OnScrollWin(wxScrollWinEvent& e);
virtual void OnSetFocus(wxFocusEvent& e);
virtual void OnSize(wxSizeEvent& e);
virtual void OnTimer(wxTimerEvent& e);
virtual void OnButton(wxCommandEvent& e);
virtual void OnCheckBox(wxCommandEvent& e);
virtual void OnRadioButton(wxCommandEvent& e);
public:
long DoXvtEvent(EVENT& e);
virtual void OnPaint(wxPaintEvent& e);
virtual bool InDestroy() const { return m_bInDestroy; }
public:
WIN_TYPE _type;
EVENT_HANDLER _eh;
long _app_data;
wxTimer* _timer;
void SetMenuTree(const MENU_ITEM* menu);
MENU_ITEM* GetMenuTree() const { return m_menu; }
BOOLEAN AddPane(wxWindow* wnd, const char* name, int nDock = 0, int nFlags = 0);
TwxWindow();
TwxWindow(wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0);
virtual ~TwxWindow();
DECLARE_DYNAMIC_CLASS(TwxWindow);
DECLARE_EVENT_TABLE();
};
class TTaskWin : public wxFrame
{
MENU_ITEM* m_menu;
wxMenuBar* m_pOldBar;
wxWindow* m_MenuOwner;
XVT_COLOR_COMPONENT* m_xcc;
protected:
virtual void OnClose(wxCloseEvent& e);
virtual void OnMenu(wxCommandEvent& e);
virtual void OnSize(wxSizeEvent& e);
void OnEndProcess(wxProcessEvent& evt);
public:
virtual void OnPaint(wxPaintEvent& e);
DECLARE_DYNAMIC_CLASS(TTaskWin);
DECLARE_EVENT_TABLE();
TTaskWin() : wxFrame(), m_menu(NULL), m_pOldBar(NULL), m_MenuOwner(NULL), m_xcc(NULL) { } // Needed by DECLARE_DYNAMIC_CLASS
public:
void SetMenuTree(const MENU_ITEM* tree);
const MENU_ITEM* GetMenuTree() const { return m_menu; }
void PushMenuTree(const MENU_ITEM* tree, wxWindow* owner);
void PopMenuTree();
COLOR GetCtlColor(XVT_COLOR_TYPE c) const;
const XVT_COLOR_COMPONENT* GetCtlColors() const;
void SetCtlColors(const XVT_COLOR_COMPONENT* colors);
TTaskWin(wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
virtual ~TTaskWin();
};
struct XVT_EVENT : public EVENT
{
XVT_EVENT(EVENT_TYPE t) { memset(this, 0, sizeof(EVENT)); type = t; }
};
#define TIMER_ID 1
const wxString& _GetAppTitle();
#define CAST_WIN(win,w) wxWindow& w = *wxStaticCast((wxObject*)win, wxWindow);
#define CAST_TWIN(win,w) TwxWindow& w = *wxStaticCast((wxObject*)win, TwxWindow);
#define CAST_TDC(win,dc) TDC& dc = GetTDCMapper().GetTDC(win);
#define CAST_DC(win,dc) wxDC& dc = GetTDCMapper().GetDC(win);
#define CAST_FONT(font_id, font) TFontId& font = *wxStaticCast(font_id, TFontId);
#define CAST_COLOR(xc, wc) wxColour wc((xc>>16)&0xFF, (xc>>8)&0xFF, xc&0xFF)
#define MAKE_XVT_COLOR(wc) XVT_MAKE_COLOR(wc.Red(), wc.Green(), wc.Blue())
wxRect RCT2Rect(const RCT* prct);
void Rect2RCT(const wxRect& rect, RCT* rct);
#ifdef XVTWIN_CPP
#define extern
#endif
extern wxHashTable _nice_windows;
extern wxFrame* _task_win;
extern EVENT_HANDLER _task_win_handler;
#endif

69
src/xvaga01/xvtxslt.cpp Normal file
View File

@ -0,0 +1,69 @@
#include "xvtslt.h"
#include "libxslt/libxslt.h"
#include "libxslt/xsltconfig.h"
#include "libexslt/exslt.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/debugXML.h>
#include <libxml/HTMLtree.h>
#include <libxml/xmlIO.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/uri.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
#include <libxslt/extensions.h>
#include <libxslt/security.h>
#include <libexslt/exsltconfig.h>
XSLTDLL int xvt_xslt_transform(const char * infile, const char * stylefile, const char * outfile) // Added by AGA
{
int error = 0;
xsltStylesheetPtr cur = nullptr;
xmlDocPtr doc = nullptr;
const xmlChar * style = xmlCharStrdup(stylefile);
xmlSubstituteEntitiesDefault(1);
xmlLoadExtDtdDefaultValue = 1;
cur = xsltParseStylesheetFile(style);
if (cur == nullptr)
error = 2; // stile assente
if ((error == 0) && (cur != nullptr) && (cur->errors == 0))
{
doc = xmlParseFile(infile);
if (doc == nullptr)
error = 1; // input assente o errato
if (error == 0)
{
xmlDocPtr res = xsltApplyStylesheet(cur, doc, nullptr);
if (res != nullptr)
{
xsltSaveResultToFilename(outfile, res, cur, 0);
// xmlFreeDoc(res);
}
else
error = 3;
}
}
if (style != nullptr)
free((void *) style);
if (cur != nullptr)
xsltFreeStylesheet(cur);
if (doc != nullptr)
xmlFreeDoc(doc);
xsltCleanupGlobals();
xmlCleanupParser();
return error;
}