gen_magic icon indicating copy to clipboard operation
gen_magic copied to clipboard

Use erlang term format instead of ascii

Open hrefhref opened this issue 5 years ago • 3 comments

This changes apprentice.c to use the erl_interface/ei.h instead of ascii.

Probably also fixes a possible buffer overflow in the old process_line, and will work with the maximum path length (4096).

Magic errors now try to uses magic_errno to have more generic errors (for example, my libmagic wasn't returning the same string as yours ("unable to access file").

perform/3 calls now support passing a binary instead of a file path ({:bytes, ...}).

The databases are now loaded by using message passing and not arguments.

Added GenMagic.Server.recycle and GenMagic.Server.reload which allows to manually recycle/reload the port, and also loading a new set of databases.

Fixes building on musl (was related to the arguments code, see #16, #18).

Handle timeouts a bit nicer in server.

Handle a recycle stop timeout by forcing the port close.

Added tests dedicated to the port.

Tested on: MacOS, FreeBSD, Alpine, Ubuntu, Debian, Fedora, Voidlinux. TODO: Open/Net BSD.

hrefhref avatar May 13 '20 17:05 hrefhref

Checked with Valgrind and everything seems nice.

hrefhref avatar May 14 '20 18:05 hrefhref

A test is failing on travis only, see #17. Otherwise tests are OK.

hrefhref avatar May 14 '20 19:05 hrefhref

Put it in WIP until I fix #17 and #18

hrefhref avatar May 18 '20 20:05 hrefhref