ca110us / go-clamav

go wrapper for libclamav
GNU General Public License v2.0
33 stars 12 forks source link

cannot use _Ctype_int(code) (value of type _Ctype_int) as type _Ctype_cl_error_t in argument to (_Cfunc_cl_strerror) #7

Closed TerminalFi closed 1 year ago

TerminalFi commented 1 year ago

Seems like I am running into this. Have you seen this?

/go/pkg/mod/github.com/ca110us/go-clamav@v0.6.0/define.go:128:45: cannot use _Ctype_int(code) (value of type _Ctype_int) as type _Ctype_cl_error_t in argument to (_Cfunc_cl_strerror)
TerminalFi commented 1 year ago

Looks like it needs updated

https://github.com/ca110us/go-clamav/blob/3f3081af252a147f9eb63a74167012dce5518c1e/define.go#L128

Should be

err := errors.New(C.GoString(C.cl_strerror(C.cl_error_t(code))))
TerminalFi commented 1 year ago

This may be with only the latest clamav

ca110us commented 1 year ago

It works fine for me in version 0.104.2, what's your Clamav version.

ca110us commented 1 year ago

Could you show me the current version header file clamav.h.

TerminalFi commented 1 year ago

I was building clamav from source. So whichever is in the master branch of clamav

richie-tt commented 1 year ago

How did you solved this problem, I have the same on ArchLinux

go/pkg/mod/github.com/ca110us/go-clamav@v0.6.0/define.go:128:45: cannot use _Ctype_int(code) (value of type _Ctype_int) as _Ctype_cl_error_t value in argument to (_Cfunc_cl_strerror)

package main

import (
    "fmt"

    clamav "github.com/ca110us/go-clamav"
)

func main() {
    c := new(clamav.Clamav)
    err := c.Init(clamav.SCAN_OPTIONS{
        General:   0,
        Parse:     clamav.CL_SCAN_PARSE_ARCHIVE | clamav.CL_SCAN_PARSE_ELF,
        Heuristic: 0,
        Mail:      0,
        Dev:       0,
    })

    if err != nil {
        panic(err)
    }

    // free clamav memory
    defer c.Free()

    // load db
    signo, err := c.LoadDB("./db", uint(clamav.CL_DB_DIRECTORY))
    if err != nil {
        panic(err)
    }
    fmt.Println("db load succeed:", signo)

    // compile engine
    err = c.CompileEngine()
    if err != nil {
        panic(err)
    }

    c.EngineSetNum(clamav.CL_ENGINE_MAX_SCANSIZE, 1024*1024*40)
    c.EngineSetNum(clamav.CL_ENGINE_MAX_SCANTIME, 9000)
    // fmt.Println(c.EngineGetNum(clamav.CL_ENGINE_MAX_SCANSIZE))

    // scan
    scanned, virusName, ret := c.ScanFile("test.txt")
    fmt.Println(scanned, virusName, ret)
}
ClamAV 1.0.1/26893/Mon May  1 09:22:05 2023