* SEE32FUN.PRG
* Contains all calls to SEE32.DLL
* NOTES:
* This file, calls seeAttach() and loads the library SEE32.DLL
*
* The library remains open throughout the execution of program.
* seeRelease() is called and closes the library and frees it.
* W A R N I N G
* ( Do NOT confuse seeRelease() with seeClose() )
#include "FIVEWIN.CH"
#INCLUDE "DLL.CH"
#INCLUDE "KEYCODE.CH" // includes #define SEE_KEY_CODE (Registration Number)
#INCLUDE "SEE32.CH" // includes all #defines for SEE32.DLL - Also works for 32 bits
// (SEE32.CH has some differences and we can't use it as it is)
// _INT must be converted into LONG (or DWORD if needed), when calling DLL32 !!!!!!!!!
Function XAttach( nBrChans, nKeyCode )
*-------------------------------------
local uResult
local cFarProc
hDLL := If( ValType( "SEE32.DLL" ) == "N", "SEE32.DLL", ;
LoadLibrary( "SEE32.DLL" ) )
if Abs( hDLL ) > 32
cFarProc = GetProcAddress( hDLL, If( .T., "seeAttach", ),.T., _INT, LONG, LONG )
uResult = CallDLL( cFarProc, nBrChans, nKeyCode )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endIF
Return uResult
Function XRelease( )
*------------------- (No parameters needed or used here)
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc = GetProcAddress( hDLL, If( .T., "seeRelease", ),.T., _INT )
uResult = CallDLL( cFarProc )
If( ValType( "SEE32.DLL" ) == "N",, FreeLibrary( hDLL ) )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XClose( nChan )
*-----------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc = GetProcAddress( hDLL, If( .T., "seeClose", ),.T., _INT, LONG )
uResult = CallDLL( cFarProc, nChan )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endIF
return uResult
Function XStringParam( nChan, nIndex, cValue )
*---------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeStringParam", ),.T., _INT, LONG, LONG, LPSTR )
uResult := CallDLL( cFarProc, nChan, nIndex, @cValue )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XIntegerParam( nChan, nIndex, nValue )
*----------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeIntegerParam", ),.T., _INT, LONG, LONG, LONG )
uResult := CallDLL( cFarProc, nChan, nIndex, nValue )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XSmtpConnect( nChan, cServer, cFrom, cReply )
*-----------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeSmtpConnect", ),.T., _INT,LONG,LPSTR,LPSTR,LPSTR )
uResult := CallDLL( cFarProc, nChan, @cServer, @cFrom, @cReply )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XPop3Connect( nChan, cServer, cUser, cPassword )
*--------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seePop3Connect", ),.T., _INT,LONG,LPSTR,LPSTR,LPSTR )
uResult := CallDLL( cFarProc, nChan, @cServer, @cUser, @cPassword )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XErrorText( nChan, nCode, cBuffer, nBufLen )
*----------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeErrorText", ),.T., _INT,LONG,LONG,LPSTR,LONG )
uResult := CallDLL( cFarProc, nChan, nCode, @cBuffer, nBufLen )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XSendEmail(nChan, cRcpt, cCC, cBCC, cSubj, cMsg, cAttach )
*------------------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc = GetProcAddress( hDLL, If( .T., "seeSendEmail", ),.T., _INT,LONG,LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,LPSTR )
uResult = CallDLL( cFarProc,nChan,@cRcpt,@cCC,@cBCC,@cSubj,@cMsg,@cAttach )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XStatistics( nChan, nIndex )
*------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc = GetProcAddress( hDLL, If( .T., "seeStatistics", ),.T., LONG,LONG,LONG )
uResult = CallDLL( cFarProc,nChan,nIndex )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
end
return uResult
Function XDebug( nChan, nIndex, cBuffer, nBufLen )
*-------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc = GetProcAddress( hDLL, If( .T., "seeDebug", ),.T., _INT,LONG,LONG,LPSTR,LONG)
uResult = CallDLL( cFarProc, nChan, nIndex, @cBuffer, nBufLen )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
end
return uResult
Function XDriver( nChan )
*------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeDriver", ),.T., _INT, LONG )
uResult := CallDLL( cFarProc, nChan )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XAbort( nChan )
*-----------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeAbort", ),.T., _INT,LONG )
uResult := CallDLL( cFarProc, nChan )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XCommand( nChan, cCommand )
*-----------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeCommand", ),.T., _INT, LONG, LPSTR)
uResult := CallDLL( cFarProc, nChan, @cCommand )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XDecodeBuffer( cCodedBuf, cClearBuf, nBufLen )
*------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeDecodeBuffer", ),.T., _INT,LPSTR,LPSTR,LONG)
uResult := CallDLL( cFarProc, @cCodedBuf, @cClearBuf, nBufLen )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XEncodeBuffer( cCodedBuf, cClearBuf, nBufLen )
*------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeEncodeBuffer", ),.T., _INT,LPSTR,LPSTR,LONG)
uResult := CallDLL( cFarProc, @cCodedBuf, @cClearBuf, nBufLen )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XDeleteEMail( nChan, nMsgNbr )
*-------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeDeleteEmail", ),.T., _INT,LONG,LONG)
uResult := CallDLL( cFarProc, nChan, nMsgNbr )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XExtractLine( cSource, nLineNbr, cBuffer, nBufLen )
*-----------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeExtractLine", ),.T., _INT,LPSTR,LONG,LPSTR,LONG)
uResult := CallDLL( cFarProc, @cSource, nLineNbr, @cBuffer, nBufLen )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XExtractText( cBuffer, cSearch, cText, nBufLen )
*--------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeExtractText", ),.T., _INT,LPSTR,LPSTR,LPSTR,LONG)
uResult := CallDLL( cFarProc, @cBuffer, @cSearch, @cText, nBufLen )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XGetEMailCount( nChan )
*-------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeGetEmailCount", ),.T., _INT,LONG)
uResult := CallDLL( cFarProc, nChan )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XGetEMailFile( nChan, nMsgNbr, cFileName, cEmailDir, cAttachDir )
*-------------------------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeGetEmailFile", ),.T., _INT,LONG,LONG,LPSTR,LPSTR,LPSTR)
uResult := CallDLL( cFarProc, nChan, nMsgNbr, @cFileName, @cEmailDir, @cAttachDir)
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XGetEMailLines( nChan, nMsgNbr, nLines, cBuffer, nBufLen )
*------------------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeGetEmailLines", ),.T., _INT,LONG,LONG,LONG,LPSTR,LONG)
uResult := CallDLL( cFarProc, nChan, nMsgNbr, nLines, @cBuffer, nBufLen )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XGetEMailSize( nChan, nMsgNbr )
*---------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeGetEmailSize", ),.T., _INT,LONG,LONG)
uResult := CallDLL( cFarProc, nChan, nMsgNbr )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XGetEMailUID( nChan, nMsgNbr, cBuffer, nBufLen )
*--------------------------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeGetEmailUID", ),.T., _INT,LONG,LONG,LPSTR,LONG)
uResult := CallDLL( cFarProc, nChan, nMsgNbr, @cBuffer, nBufLen )
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XVerifyFormat( cEmailAddr )
*-----------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeVerifyFormat", ),.T., _INT,LPSTR) // 32 Bits
uResult := CallDLL( cFarProc, @cEmailAddr ) // 06/may/2004 V.
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function XVerifyUser( nChan, cEmailAddr )
*----------------------------------------
local uResult
local cFarProc
if Abs( hDLL ) > 32
cFarProc := GetProcAddress( hDLL, If( .T., "seeVerifyUser", ),.T., _INT,LONG,LPSTR) // 32 Bits
uResult := CallDLL( cFarProc, nChan, @cEmailAddr ) // 06/may/2004 V.
else
MsgAlert( "Error code: " + LTrim( Str( hDLL ) ) + " loading SEE32.DLL" )
endif
return uResult
Function SEE32_ERROR(x)
*----------------------
Local aErrs := {} // array to hold the errors
Local n := 0 // numeric pointer for ascan()
aErrs := { ;
{ -1, "Socket has been closed"} ,;
{ -4, "WINSOCK is currently blocking"} ,;
{ -5, "Bad status flag passed to seeStatus"} ,;
{ -7, "Invalid socket"} ,;
{ -8, "Socket timed out"} ,;
{ -9, "No available sockaddr structures"} ,;
{ -12, "No host name"} ,;
{ -14, "Internal checksum fails!"} ,;
{ -18, "Cannot create socket"} ,;
{ -31, "Response buffer has overflowed"} ,;
{ -32, "Bad character in email address"} ,;
{ -34, "Cannot access WINSOCK"} ,;
{ -35, "Cannot open file"} ,;
{ -36, "Error attempting to connect"} ,;
{ -37, "EMPTY email address"} ,;
{ -38, "FromPtr is NULL"} ,;
{ -39, "Missing '@' character in email address"} ,;
{ -40, "Missing FROM email address"} ,;
{ -41, "Missing '<' delimiter in email address"} ,;
{ -43, "Missing '>' terminating email address"} ,;
{ -44, "Not connected to server: " + CRLF + SmtpServer} ,;
{ -45, "Must have at least one receipient"} ,;
{ -46, "Cannot find SMTP/POP3 server: " + CRLF + SmtpServer} ,;
{ -47, "Unexpected NULL pointer"} ,;
{ -48, "ToPtr is NULL"} ,;
{ -49, "SMTP returned error"} ,;
{ -50, "SMTP/POP3 server not specified"} ,;
{ -51, "Socket read error"} ,;
{ -52, "Socket write error"} ,;
{ -53, "Too many '@' symbols in email address"} ,;
{ -54, "Found unexpected '>' character in email address"} ,;
{ -55, "Cannot allocate memory"} ,;
{ -56, "Illegal chars in server name"} ,;
{ -58, "SMTP function ONLY"} ,;
{ -59, "POP3 function ONLY"} ,;
{ -61, "USER name not specified"} ,;
{ -62, "PASSWORD not specified"} ,;
{ -63, "POP3 returned error"} ,;
{ -64, "No such message number"} ,;
{ -65, "Missing filename"} ,;
{ -66, "Missing email path"} ,;
{ -67, "Cannot create file"} ,;
{ -68, "Buffer is NULL"} ,;
{ -69, "Buffer size < 128"} ,;
{ -70, "Missing path for attachments"} ,;
{ -71, "seeAttach not called"} ,;
{ -72, "seeAttach already called"} ,;
{ -73, "Channel number of out range"} ,;
{ -74, "Bad key code (2nd argument to seeAttach)"} ,;
{-10004, "Interrupted system call"} ,;
{-10009, "Bad file number"} ,;
{-10013, "Access denied"} ,;
{-10014, "Bad address"} ,;
{-10022, "Invalid argument"} ,;
{-10024, "Too many open files"} ,;
{-10035, "Would block socket in non-blocking mode"} ,;
{-10036, "Blocking call already in progress"} ,;
{-10037, "Operation already completed"} ,;
{-10038, "Not a valid socket"} ,;
{-10039, "Destination address required"} ,;
{-10040, "Message too big for buffer"} ,;
{-10041, "Prot mismatch"} ,;
{-10042, "Prot option invalid"} ,;
{-10043, "Prot not supported"} ,;
{-10044, "Socket type not supported"} ,;
{-10045, "Socket operation not supported"} ,;
{-10047, "Socket address family not supported"} ,;
{-10048, "Socket address already in use"} ,;
{-10049, "Socket address not available"} ,;
{-10050, "Network error"} ,;
{-10051, "Cannot reach network"} ,;
{-10052, "Connection dropped"} ,;
{-10053, "Connection timed-out or aborted"} ,;
{-10054, "Connection reset by remote host"} ,;
{-10055, "Out of buffer space"} ,;
{-10056, "Socket already connected"} ,;
{-10057, "Socket not connected"} ,;
{-10058, "Socket functionality shut down"} ,;
{-10060, "Timed-out attempting to connect"} ,;
{-10061, "Connection refused by remote host"} ,;
{-10064, "Host is down"} ,;
{-10065, "No route to host"} ,;
{-10091, "Network not yet ready"} ,;
{-10092, "WINSOCK doesn't support requested version"} ,;
{-10093, "Sockets not initialized. Call WSAStartup"} ,;
{-11001, "Host does not exist"} ,;
{-11002, "Host not found. Try again"} ,;
{-11003, "Non-recoverable error has occurred"} ,;
{-11004, "No data is available"} ,;
{-18550, "Missing Username and/or Password for authenticating."} } // Added 10/feb/2006 V.
n := ASCAN(aErrs, {|aVal| aVal[1] == x })
if n == 0
Return (CRLF + "SEE32 Error " + cvaltochar(x) + CRLF + " (Unknown Error)")
endif
if x <= (-74)
Return (CRLF + "SEE32 Error " + cvaltochar(x) + CRLF + aErrs[n, 2]+".") // SEE32 error
else
Return (CRLF + "WINSOCK Error " + cvaltochar(x) + CRLF + aErrs[n, 2]+".") // WINSOCK error
endif
RETURN(NIL)