!****************************************************************************
!* MODULE:       tlsdll.f90
!****************************************************************************
use dfwin
include 'tls.fi'
end
!****************************************************************************
!Purpose: Retreive TLS values and display (printf) them
!
!Inputs:  TlsIndex - TLS index value
!
!Returns: none
!
!Calls:   TlsGetValue - Gets the TLS value from the index
!                       based on the current thread.
!****************************************************************************
integer function TlsRetrieve (TlsIndex1)
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS :'_TlsRetrieve@4' :: TlsRetrieve
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS :'TlsRetrieve' :: TlsRetrieve
!DEC$ ENDIF
use dfwin

integer         TlsIndex1
integer*4       tlsvals
character*50    newstr
character*70    mesbuf
character*512   TempString

   tlsvals = TlsGetValue(TlsIndex1)   ! get the TLS value
   if (tlsvals == 0) then
      call ErrorOut("TlsGetValue"C)
   else
      iret = ConvertFToCString(TempString  ,tlsvals)
      i = lstrcpy(newstr, TempString)
      i  = lstrcpy(mesbuf,  'TLS value = 'C)
      i = lstrcat(mesbuf, newstr)
      iret = MessageBox(NULL,mesbuf,'DLL - TlsRetrieve'C,MB_OK)

   end if
   TlsRetrieve = 1
   return
end



!*************************************************************************
!Purpose: Allow DllMain to be executed for each thread
!
!Inputs:  none
!
!Returns: none
!
!Calls:   none
!*************************************************************************
integer function TlsInit ()
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_TlsInit@0' :: TlsInit
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'TlsInit' :: TlsInit
!DEC$ ENDIF
!DEC$ ATTRIBUTES DLLEXPORT :: TlsInit
use dfwin
   TlsInit = 1
   iret = MessageBox(NULL,'TLSINIT'C,'DLL - TlsInit'C,MB_OK)
   return
end


