Пример #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);
            }
        }
Пример #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);
        }
Пример #3
0
 public extern static ClamReturnCode cl_scanfile(string path, ref IntPtr virusName, ref ulong scanned, ClamEngineDescriptor engine, uint options);
Пример #4
0
 public extern static ClamReturnCode cl_load(string path, ClamEngineDescriptor engine, ref uint signo, uint options);
Пример #5
0
 public extern static ClamReturnCode cl_engine_free(ClamEngineDescriptor engine);
Пример #6
0
 public static extern ClamReturnCode cl_load(string path, ClamEngineDescriptor engine, ref uint signo, uint options);
Пример #7
0
 public static extern ClamReturnCode cl_engine_free(ClamEngineDescriptor engine);
Пример #8
0
 public static extern ClamReturnCode cl_scanfile(string path, ref IntPtr virusName, ref ulong scanned, ClamEngineDescriptor engine, uint options);