1

Windows fixes

This commit is contained in:
Alex Yatskov 2021-01-10 11:51:14 -08:00
parent 4e432fa545
commit 7c4b1f8c8b
3 changed files with 10 additions and 5 deletions

View File

@ -29,12 +29,17 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
#include <sys/socket.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#ifdef WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#endif
#include "linebuf.h" #include "linebuf.h"
/* /*

View File

@ -7,7 +7,6 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"path"
zig "github.com/FooSoft/zero-epwing-go" zig "github.com/FooSoft/zero-epwing-go"
) )
@ -66,7 +65,7 @@ func main() {
) )
flag.Usage = func() { flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [options] path\n", path.Base(os.Args[0])) fmt.Fprintf(os.Stderr, "Usage: zero-epwing [options] path\n")
fmt.Fprintf(os.Stderr, "Parameters:\n") fmt.Fprintf(os.Stderr, "Parameters:\n")
flag.PrintDefaults() flag.PrintDefaults()
} }

5
zig.go
View File

@ -10,7 +10,8 @@ import (
) )
/* /*
#cgo LDFLAGS: -lz #cgo linux LDFLAGS: -lz
#cgo windows LDFLAGS: -lz -lws2_32
#include "zig.h" #include "zig.h"
*/ */
import "C" import "C"
@ -74,7 +75,7 @@ func (c *Context) initialize() error {
return fmt.Errorf("eb_initialize_library failed with code: %s", formatError(errEb)) return fmt.Errorf("eb_initialize_library failed with code: %s", formatError(errEb))
} }
c.book = (*C.EB_Book)(C.calloc(1, C.size_t(unsafe.Sizeof(C.EB_Book{}))+8)) c.book = (*C.EB_Book)(C.calloc(1, C.size_t(unsafe.Sizeof(C.EB_Book{}))))
C.eb_initialize_book(c.book) C.eb_initialize_book(c.book)
c.hookset = (*C.EB_Hookset)(C.calloc(1, C.size_t(unsafe.Sizeof(C.EB_Hookset{})))) c.hookset = (*C.EB_Hookset)(C.calloc(1, C.size_t(unsafe.Sizeof(C.EB_Hookset{}))))