[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Mldonkey-tasks] [task #5324] filetype recognition with libmagic
From: |
jave |
Subject: |
[Mldonkey-tasks] [task #5324] filetype recognition with libmagic |
Date: |
Wed, 15 Mar 2006 20:58:21 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051202 Fedora/1.5-0.fc4 Firefox/1.5 |
Follow-up Comment #1, task #5324 (project mldonkey):
heres how to perform the test:
- make a magic.i file like this:
%module ocamlmagic
%{
/* Includes the header in the wrapper code */
#include "/usr/include/magic.h"
%}
/* Parse the header file to generate wrappers */
%include "/usr/include/magic.h"
- compile it like so:
swig -ocaml magic.i
we get ocaml interface files and a c wrapper.
- guess it must all be compiled and linked...
swig -ocaml -co swig.mli
swig -ocaml -co swig.ml
ocamlc -c swig.mli
ocamlc -c swig.ml
ocamlc -c -ccopt "-I/usr/include/" magic_wrap.c
ocamlc -c ocamlmagic.mli
ocamlc -c ocamlmagic.ml
- making custom toplevel
ocamlmktop -cclib -lmagic -cclib -lz -custom magic_wrap.o swig.cmo
ocamlmagic.cmo -o magic_top
ticky to get the linking right
- calling the funs
(maybe not necessary)
./magic_top
#load "ocamlmagic.cmo";;
open Swig;;
open Ocamlmagic;;
let magiccookie = _magic_open (C_int 0);;(*just opens the lib*)
_magic_load (C_list [magiccookie; (C_int 0)]);; (* returns 0 on ok*)
let fileinfo= _magic_file (C_list [magiccookie; (C_string
"/tmp/142328-5.pdf")]);;
(* returns val fileinfo : Ocamlmagic.c_obj = C_string "PDF document, version
1.2" *)
_magic_close magiccookie;; (*close the lib*)
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/task/?func=detailitem&item_id=5324>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/