/***********************************************************************************************
* SuperproNativeApi.cs
*
* Developed by     : SafeNet, Inc
*
* Copyright (C) 2009 SafeNet, Inc. All rights reserved.
*
* Description - SuperPro Native Api's
*
***********************************************************************************************/
using System.Runtime.InteropServices;

public sealed class SuperproNativeApi
{
   SuperproNativeApi(){ }

   #region Import Superpro API from Superpro Dyanamic Library (sx32w.dll)

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproFormatPacket")]
   public static extern ushort RNBOsproFormatPacket(/* IN */ byte[] packet,
      /* IN */ uint packetSize);
   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproInitialize")]
   public static extern ushort RNBOsproInitialize(/* IN */ byte[] packet);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproFindFirstUnit")]
   public static extern ushort RNBOsproFindFirstUnit(/* IN */ byte[] packet,
      /* IN */ ushort developerID);
   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproFindNextUnit")]
   public static extern ushort RNBOsproFindNextUnit(/* IN */ byte[] packet);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproRead")]
   public static extern ushort RNBOsproRead( /* IN  */ byte[] packet,
      /* IN  */ ushort address,
      /* OUT */ ref ushort data);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproExtendedRead")]
   public static extern ushort RNBOsproExtendedRead(/* IN  */  byte[] packet,
      /* IN  */  ushort address,
      /* OUT */  ref ushort data,
      /* OUT */  ref byte accessCode);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproWrite")]
   public static extern ushort RNBOsproWrite(/* IN */ byte[] packet,
      /* IN */ ushort writePassword,
      /* IN */ ushort address,
      /* IN */ ushort data,
      /* IN */ byte accessCode);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproOverwrite")]
   public static extern ushort RNBOsproOverwrite(/* IN */ byte[] packet,
      /* IN */ ushort writePassword,
      /* IN */ ushort overwritePassword1,
      /* IN */ ushort overwritePassword2,
      /* IN */ ushort address,
      /* IN */ ushort data,
      /* IN */ byte accessCode);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproDecrement")]
   public static extern ushort RNBOsproDecrement( /* IN */ byte[] packet,
      /* IN */ ushort writePassword,
      /* IN */ ushort address);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproActivate")]
   public static extern ushort RNBOsproActivate(/* IN */ byte[] packet,
      /* IN */ ushort writePassword,
      /* IN */ ushort activatePassword1,
      /* IN */ ushort activatePassword2,
                                                         ushort address);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproQuery")]
   public static extern ushort RNBOsproQuery(/* IN  */ byte[] packet,
      /* IN  */ ushort address,
      /* IN  */ byte[] queryData,
      /* OUT */ byte[] response,
      /* OUT */ ref uint response32,
      /* IN  */ ushort length);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproGetFullStatus")]
   public static extern ushort RNBOsproGetFullStatus( /* IN */byte[] packet);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproGetVersion")]
   public static extern ushort RNBOsproGetVersion(/* IN  */ byte[] packet,
      /* OUT */ ref byte majVerion,
      /* OUT */ ref byte minVersion,
      /* OUT */ ref byte revision,
      /* OUT */ ref byte osDrvrType);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproGetKeyType")]
   public static extern ushort RNBOsproGetKeyType(/* IN */  byte[] packet,
      /* OUT */ ref int keyFamily,
      /* OUT */ ref int formFactor,
      /* OUT */ ref int memUsed);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproCleanup")]
   public static extern void RNBOsproCleanup();

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproGetHardLimit")]
   public static extern ushort RNBOsproGetHardLimit( /* IN  */ byte[] packet,
      /* OUT */ out ushort hardLimit);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproGetSubLicense")]
   public static extern ushort RNBOsproGetSubLicense(/* IN */ byte[] packet,
      /* IN */ ushort address);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproReleaseLicense")]
   public static extern ushort RNBOsproReleaseLicense(/* IN     */byte[] packet,
      /* IN     */ushort address,
      /* IN/OUT */ ref ushort numSubLic);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproSetContactServer")]
   public static extern ushort RNBOsproSetContactServer(/* IN */ byte[] packet,
      /* IN */ [MarshalAs(UnmanagedType.LPStr)] string serverName);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproGetContactServer")]
   public static extern ushort RNBOsproGetContactServer(/* IN  */ byte[] packet,
      /* OUT */ byte[] serverNameBuffer,
      /* IN  */ uint serverNameBufferSize);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproEnumServer")]
   public static extern ushort RNBOsproEnumServer(int enumFlag,
                                                    ushort developerID,
                                                    byte[] nsproServerInfo,
                                                    ref ushort numServerInfo);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproGetKeyInfo")]
   public static extern ushort RNBOsproGetKeyInfo(/* IN */  byte[] packet,
      /* IN */  ushort developerID,
      /* IN */  ushort keyIndex,
      /* OUT */ byte[] nsproMonitorInfo);

   [DllImport("sx32w.dll",
       CharSet = CharSet.Ansi,
       EntryPoint = "RNBOsproGetKeyInfoEx")]
   public static extern ushort RNBOsproGetKeyInfoEx(/* IN */  byte[] packet,
      /* IN */  uint developerID,
      /* IN */  uint keyIndex,
      /* IN */  uint subLicAddress, 
      /* OUT */ byte[] nsproMonitorInfoEx,
      /* IN */  uint size);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproSetProtocol")]
   public static extern ushort RNBOsproSetProtocol(/* IN */ byte[] packet,
      /* IN */ int protocol);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproSetHeartBeat")]
   public static extern ushort RNBOsproSetHeartBeat(/* IN */ byte[] packet,
      /* IN */ int heartBeatValue);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproSetSharedLicense")]
   public static extern ushort RNBOsproSetSharedLicense(/* IN */ byte[] packet,
      /* IN */ ushort shareMainLic,
      /* IN */ ushort shareSubLic);

   [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproCheckTerminalService")]
   public static extern ushort RNBOsproCheckTerminalService(/* IN */ byte[] packet,
      /* IN */ int termserv);

   [DllImport("sx32w.dll",
       CharSet = CharSet.Ansi,
       EntryPoint = "RNBOsproSetDeveloperCode")]
   public static extern ushort RNBOsproSetDeveloperCode(/* IN */ byte[] packet,
      /* IN */ byte[] devCode,
      /* IN */ uint size);

    [DllImport("sx32w.dll",
           CharSet = CharSet.Ansi,
           EntryPoint = "RNBOsproSetConfigFile")]
    public static extern ushort RNBOsproSetConfigFile(/* IN */ byte[] packet,
        /* IN */ [MarshalAs(UnmanagedType.LPStr)] string cfgFileName);

   #endregion
}
