Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="clamsharp.ClamEngine"/> class.
        ///
        /// This class drives the file scanning and reporting. It implements IDisposable, and
        /// is meant to be used in the context of a using statement. If the programmer does not
        /// do this, the engine allocated by libclamav will not be freed and this will lead to
        /// a memory leak. If the programmer is using a C# prior to .NET 2.0 profile, the programmer
        /// should call Dispose explicitly when done.
        /// </summary>
        /// <exception cref='Exception'>
        /// Represents errors that occur during application execution.
        /// </exception>
        public ClamEngine()
        {
            ClamReturnCode ret = ClamBindings.cl_init((uint)ClamDatabaseOptions.CL_DB_STDOPT);

            if (ret != ClamReturnCode.CL_SUCCESS)
            {
                throw new Exception("Expected CL_SUCCESS, got " + ret);
            }

            engine = ClamBindings.cl_engine_new();

            string dbDir = Marshal.PtrToStringAnsi(ClamBindings.cl_retdbdir());
            uint   signo = 0;

            ret = ClamBindings.cl_load(dbDir, engine, ref signo, (uint)ClamScanOptions.CL_SCAN_STDOPT);

            if (ret != ClamReturnCode.CL_SUCCESS)
            {
                throw new Exception("Expected CL_SUCCESS, got " + ret);
            }

            ret = (ClamReturnCode)ClamBindings.cl_engine_compile(engine);

            if (ret != ClamReturnCode.CL_SUCCESS)
            {
                throw new Exception("Expected CL_SUCCESS, got " + ret);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="clamsharp.ClamEngine"/> class.
        /// 
        /// This class drives the file scanning and reporting. It implements IDisposable, and
        /// is meant to be used in the context of a using statement. If the programmer does not
        /// do this, the engine allocated by libclamav will not be freed and this will lead to
        /// a memory leak. If the programmer is using a C# prior to .NET 2.0 profile, the programmer
        /// should call Dispose explicitly when done.
        /// </summary>
        /// <exception cref='Exception'>
        /// Represents errors that occur during application execution.
        /// </exception>
        public ClamEngine()
        {
            ClamReturnCode ret = ClamBindings.cl_init((uint)ClamDatabaseOptions.CL_DB_STDOPT);

            if (ret != ClamReturnCode.CL_SUCCESS)
                throw new Exception("Expected CL_SUCCESS, got " + ret);

            engine = ClamBindings.cl_engine_new();

            string dbDir = Marshal.PtrToStringAnsi(ClamBindings.cl_retdbdir());
            uint signo = 0;

            ret = ClamBindings.cl_load(dbDir, engine, ref signo,(uint)ClamScanOptions.CL_SCAN_STDOPT);

            if (ret != ClamReturnCode.CL_SUCCESS)
                throw new Exception("Expected CL_SUCCESS, got " + ret);

            ret = (ClamReturnCode)ClamBindings.cl_engine_compile(engine);

            if (ret != ClamReturnCode.CL_SUCCESS)
                throw new Exception("Expected CL_SUCCESS, got " + ret);
        }
Exemplo n.º 3
0
 public extern static ClamReturnCode cl_scanfile(string path, ref IntPtr virusName, ref ulong scanned, ClamEngineDescriptor engine, uint options);
Exemplo n.º 4
0
 public extern static ClamReturnCode cl_load(string path, ClamEngineDescriptor engine, ref uint signo, uint options);
Exemplo n.º 5
0
 public extern static ClamReturnCode cl_engine_free(ClamEngineDescriptor engine);
Exemplo n.º 6
0
 public static extern ClamReturnCode cl_load(string path, ClamEngineDescriptor engine, ref uint signo, uint options);
Exemplo n.º 7
0
 public static extern ClamReturnCode cl_engine_free(ClamEngineDescriptor engine);
Exemplo n.º 8
0
 public static extern ClamReturnCode cl_scanfile(string path, ref IntPtr virusName, ref ulong scanned, ClamEngineDescriptor engine, uint options);