Hatena::Grouphaskell

eagletmtの日記 このページをアンテナに追加

 | 

2010-08-23

FFI を利用する (3) C でラッパを書く

| 18:14 |  FFI を利用する (3) C でラッパを書く - eagletmtの日記 を含むブックマーク はてなブックマーク -  FFI を利用する (3) C でラッパを書く - eagletmtの日記  FFI を利用する (3) C でラッパを書く - eagletmtの日記 のブックマークコメント

Node だけとれてもしょうがないので,例えばそのノードの textContent を得る関数を定義してみる.

libxml の API では xmlNodeGetContent にあたる.

textContent :: Node -> B.ByteString
textContent (MkNode ptr) = unsafePerformIO $
  bracket (c_xmlNodeGetContent ptr) c_xmlFree B.packCString
foreign import ccall "xmlNodeGetContent" c_xmlNodeGetContent :: Ptr NodeTag -> IO CString
foreign import ccall "xmlFree" c_xmlFree :: Ptr a -> IO ()

これでうまくいってくれればよかったのだけど,なぜか c_xmlFree で落ちる.

libxml/globals.h を見るとなんか #define とかされているようだけど,具体的になぜ失敗するのかよくわからない…

しょうがないので xmlFree を呼ぶだけのラッパを C のほうで書いてそれを呼んだらうまくいった.

#include <libxml/globals.h>

void xmlFree_wrap(void *mem)
{
  xmlFree(mem);
}

ビルドするときは

% gcc -c `xml2-config --cflags` wrapper.c

とコンパイルして,最終的に ghc に wrapper.o も一緒に渡してやればよい.

NourMaNourMa2013/03/29 15:14I just hope whoever wtiers these keeps writing more!

hmdicqgpubhmdicqgpub2013/03/30 14:30iW5Mb1 <a href="http://ygnnewkfwyhb.com/">ygnnewkfwyhb</a>

xpfxoyufxpfxoyuf2013/03/31 22:03Cz3Fh4 , [url=http://flknbtjovirt.com/]flknbtjovirt[/url], [link=http://kdoazlurskqz.com/]kdoazlurskqz[/link], http://fzjqgrfcplbs.com/

qvgopmulirqvgopmulir2013/04/01 10:49Ac343G , [url=http://csqammgdnmrq.com/]csqammgdnmrq[/url], [link=http://kbtjeonmbhzm.com/]kbtjeonmbhzm[/link], http://ntgiiffhvwpi.com/

ofiiceiyaofiiceiya2017/11/27 04:26http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/

ociyyeegiqexoociyyeegiqexo2017/11/27 04:43http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/

uunicohuunicoh2017/11/27 04:43http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/

exefaiyexefaiy2017/11/27 04:56http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/

oboavuqfixioboavuqfixi2017/11/27 04:58http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/

ileimazooroileimazooro2017/11/27 05:01http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/

ukalewowikexaukalewowikexa2017/11/27 05:14http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/

eduvviyeduvviy2017/11/28 04:05http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/

vwccnetlermavwccnetlerma2018/03/22 01:22https://bitcoinstock.us.com - bitcoin trade
<a href=" https://bitcoinstock.us.com ">how do i buy bitcoin stock</a>
<a href="https://bitcoinstock.us.com">buying bitcoin</a>

AysjzdunseAysjzdunse2018/03/22 04:36http://dkjshye7s632.com
You made some first rate factors there. I looked on the web for the issue and located most people will go along with with your website.

aaotwpclermaaaotwpclerma2018/03/23 05:06https://bitcoinstock.us.com - what is bitcoin currency
<a href=" https://bitcoinstock.us.com ">bitcoin investment</a>
<a href="https://bitcoinstock.us.com">bit coin investment</a>

hethmImathethmImat2018/03/23 05:10https://buybitcoin.us.com - price of bitcoin today
<a href=" https://buybitcoin.us.com ">bitcoin futures trading</a>
<a href="https://buybitcoin.us.com">bitcoin trading platform</a>

ospapitkiospapitki2018/03/23 05:39https://howtoinvestinbitcoin.us.org - how to trade bitcoin
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin price today</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin trading</a>

rldyijflermarldyijflerma2018/03/23 06:18https://bitcoinstock.us.com - is bitcoin a good investment 2017
<a href=" https://bitcoinstock.us.com ">best way to invest in bitcoin</a>
<a href="https://bitcoinstock.us.com">how to trade bitcoin</a>

naixlvdkinaixlvdki2018/03/23 06:38https://howtoinvestinbitcoin.us.org - bitcoin price today
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin investing</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin stock price</a>

budchImatbudchImat2018/03/23 07:10https://buybitcoin.us.com - bitcoin investing
<a href=" https://buybitcoin.us.com ">how does bitcoin work</a>
<a href="https://buybitcoin.us.com">bitcoin investment</a>

mctkpqzlermamctkpqzlerma2018/03/23 07:21https://bitcoinstock.us.com - investing in digital currency
<a href=" https://bitcoinstock.us.com ">invest bitcoin</a>
<a href="https://bitcoinstock.us.com">bitcoin cryptocurrency</a>

xxpstpdkixxpstpdki2018/03/23 07:21https://howtoinvestinbitcoin.us.org - today bitcoin price
<a href=" https://howtoinvestinbitcoin.us.org ">best way to invest in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">price of bitcoin today</a>

xsgrkvxkixsgrkvxki2018/03/23 08:21https://howtoinvestinbitcoin.us.org - how to buy bitcoin stock
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin conversion</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin trading platform</a>

tdlifuwlermatdlifuwlerma2018/03/23 08:40https://bitcoinstock.us.com - the next bitcoin investment
<a href=" https://bitcoinstock.us.com ">how much is bitcoin stock</a>
<a href="https://bitcoinstock.us.com">todays bitcoin value</a>

glnqwImatglnqwImat2018/03/23 09:33https://buybitcoin.us.com - bitcoin trading platform
<a href=" https://buybitcoin.us.com ">price of bitcoin today</a>
<a href="https://buybitcoin.us.com">should i invest in bitcoin</a>

oumntullermaoumntullerma2018/03/23 09:49https://bitcoinstock.us.com - how to trade bitcoin
<a href=" https://bitcoinstock.us.com ">where to buy bitcoin stock</a>
<a href="https://bitcoinstock.us.com">how do you invest in bitcoin</a>

zkmleuvkizkmleuvki2018/03/23 10:10https://howtoinvestinbitcoin.us.org - bitcoin investments
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin todays price</a>
<a href="https://howtoinvestinbitcoin.us.org">best way to invest in bitcoin</a>

gdmugaxlermagdmugaxlerma2018/03/23 10:59https://bitcoinstock.us.com - price of bitcoin today
<a href=" https://bitcoinstock.us.com ">bitcoin trust</a>
<a href="https://bitcoinstock.us.com">bitcoin stocks</a>

cqspwxakicqspwxaki2018/03/23 11:20https://howtoinvestinbitcoin.us.org - bitcoin price today
<a href=" https://howtoinvestinbitcoin.us.org ">investing in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin investment</a>

wmrychqkiwmrychqki2018/03/23 12:22https://howtoinvestinbitcoin.us.org - how to invest in bitcoin
<a href=" https://howtoinvestinbitcoin.us.org ">buying bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">how to invest in bitcoin for dummies</a>

igjregblermaigjregblerma2018/03/23 12:38https://bitcoinstock.us.com - how to invest in bitcoin
<a href=" https://bitcoinstock.us.com ">how to trade bitcoin</a>
<a href="https://bitcoinstock.us.com">best way to invest in bitcoin</a>

djmnqxslermadjmnqxslerma2018/03/23 15:09https://bitcoinstock.us.com - how to invest in digital currency
<a href=" https://bitcoinstock.us.com ">how to trade bitcoin online</a>
<a href="https://bitcoinstock.us.com">buy bitcoin</a>

buovoaukibuovoauki2018/03/23 15:14https://howtoinvestinbitcoin.us.org - what is bitcoin trading at
<a href=" https://howtoinvestinbitcoin.us.org ">is bitcoin a good investment 2017</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin stocks to invest in</a>

xhegxenkixhegxenki2018/03/23 16:11https://howtoinvestinbitcoin.us.org - is bitcoin a good investment 2017
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin investment trust gbtc</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin investing</a>

akaukrqlermaakaukrqlerma2018/03/23 16:23https://bitcoinstock.us.com - how to invest in digital currency
<a href=" https://bitcoinstock.us.com ">bitcoin stock</a>
<a href="https://bitcoinstock.us.com">trading bitcoin</a>

galnrImatgalnrImat2018/03/23 16:35https://buybitcoin.us.com - bitcoin futures trading
<a href=" https://buybitcoin.us.com ">how to trade bitcoin</a>
<a href="https://buybitcoin.us.com">bitcoin stock price</a>

difuxhvkidifuxhvki2018/03/23 17:09https://howtoinvestinbitcoin.us.org - bit coin investment
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin invest</a>
<a href="https://howtoinvestinbitcoin.us.org">how to invest in digital currency</a>

pzgovaflermapzgovaflerma2018/03/23 17:41https://bitcoinstock.us.com - bitcoin investment trust gbtc
<a href=" https://bitcoinstock.us.com ">best bitcoin trading platform</a>
<a href="https://bitcoinstock.us.com">bitcoin traders</a>

rsxfbtlkirsxfbtlki2018/03/23 18:03https://howtoinvestinbitcoin.us.org - real time bitcoin price
<a href=" https://howtoinvestinbitcoin.us.org ">invest in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin traders</a>

uagbdsnlermauagbdsnlerma2018/03/23 18:51https://bitcoinstock.us.com - bitcoin market price
<a href=" https://bitcoinstock.us.com ">how to trade bitcoin</a>
<a href="https://bitcoinstock.us.com">invest in bitcoin</a>

ulenwfnkiulenwfnki2018/03/23 18:57https://howtoinvestinbitcoin.us.org - best way to invest in bitcoin
<a href=" https://howtoinvestinbitcoin.us.org ">cryptocurrency bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">is bitcoin a good investment</a>

ylpxogvkiylpxogvki2018/03/23 19:57https://howtoinvestinbitcoin.us.org - bitcoin stock
<a href=" https://howtoinvestinbitcoin.us.org ">invest in bitcoin stock</a>
<a href="https://howtoinvestinbitcoin.us.org">how to trade bitcoin online</a>

ybasdoclermaybasdoclerma2018/03/23 20:16https://bitcoinstock.us.com - bitcoin investment trust
<a href=" https://bitcoinstock.us.com ">the next bitcoin investment</a>
<a href="https://bitcoinstock.us.com">today bitcoin price</a>

vmgkqslkivmgkqslki2018/03/23 20:53https://howtoinvestinbitcoin.us.org - bitcoin news today
<a href=" https://howtoinvestinbitcoin.us.org ">how to invest in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">trading bitcoin</a>

ivyjjoakiivyjjoaki2018/03/23 21:47https://howtoinvestinbitcoin.us.org - bitcoin trading price
<a href=" https://howtoinvestinbitcoin.us.org ">how to buy bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">how to invest in bitcoin stock</a>

xdnytImatxdnytImat2018/03/23 22:12https://buybitcoin.us.com - bitcoin trading platform
<a href=" https://buybitcoin.us.com ">bitcoin price today</a>
<a href="https://buybitcoin.us.com">bitcoin stock</a>

ngmjyqnkingmjyqnki2018/03/23 22:43https://howtoinvestinbitcoin.us.org - how to buy bitcoin
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin market price</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin investments</a>

tijalzflermatijalzflerma2018/03/24 01:00https://bitcoinstock.us.com - where to buy bitcoin stock
<a href=" https://bitcoinstock.us.com ">bitcoin stocks</a>
<a href="https://bitcoinstock.us.com">invest in bitcoin stock</a>

huortylkihuortylki2018/03/24 01:36https://howtoinvestinbitcoin.us.org - how to buy bitcoin stock
<a href=" https://howtoinvestinbitcoin.us.org ">what is bitcoin trading at</a>
<a href="https://howtoinvestinbitcoin.us.org">real time bitcoin price</a>

njkmuhrlermanjkmuhrlerma2018/03/24 02:08https://bitcoinstock.us.com - how to trade bitcoin
<a href=" https://bitcoinstock.us.com ">best way to invest in bitcoin</a>
<a href="https://bitcoinstock.us.com">bitcoin stocks</a>

tgfvqtnkitgfvqtnki2018/03/24 02:27https://howtoinvestinbitcoin.us.org - bitcoin trade
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin stock price</a>
<a href="https://howtoinvestinbitcoin.us.org">is bitcoin a good investment 2017</a>

vqaurbylermavqaurbylerma2018/03/24 03:16https://bitcoinstock.us.com - invest in bitcoin
<a href=" https://bitcoinstock.us.com ">bitcoin cost today</a>
<a href="https://bitcoinstock.us.com">is bitcoin a good investment</a>

nvyxdrskinvyxdrski2018/03/24 03:17https://howtoinvestinbitcoin.us.org - what exactly is bitcoin
<a href=" https://howtoinvestinbitcoin.us.org ">invest in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">buying bitcoin</a>

dkqjlImatdkqjlImat2018/03/24 03:19https://buybitcoin.us.com - how to buy bitcoin stock
<a href=" https://buybitcoin.us.com ">trade bitcoin</a>
<a href="https://buybitcoin.us.com">bitcoin futures trading</a>

esxvpoylermaesxvpoylerma2018/03/24 04:22https://bitcoinstock.us.com - investing in bitcoin
<a href=" https://bitcoinstock.us.com ">invest in bitcoin stock</a>
<a href="https://bitcoinstock.us.com">bitcoin investment calculator</a>

cmvkkImatcmvkkImat2018/03/24 04:26https://buybitcoin.us.com - bitcoin investment trust
<a href=" https://buybitcoin.us.com ">bitcoin investment trust</a>
<a href="https://buybitcoin.us.com">bitcoin investment</a>

iwcdgevkiiwcdgevki2018/03/24 04:29https://howtoinvestinbitcoin.us.org - bitcoin investment
<a href=" https://howtoinvestinbitcoin.us.org ">investing in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">is bitcoin a good investment 2017</a>

rhtohjblermarhtohjblerma2018/03/24 05:29https://bitcoinstock.us.com - investing in bitcoin
<a href=" https://bitcoinstock.us.com ">bitcoin trading platforms</a>
<a href="https://bitcoinstock.us.com">is bitcoin a good investment</a>

vdoudiskivdoudiski2018/03/24 05:30https://howtoinvestinbitcoin.us.org - is bitcoin a good investment
<a href=" https://howtoinvestinbitcoin.us.org ">how do you invest in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin fund</a>

ApdzkdunseApdzkdunse2018/03/24 06:20https://onlinecasinoplay24.com - top rated free online casino games
<a href="https://onlinecasinoplay24.com">safe online casinos real money</a>
<a href=" https://onlinecasinoplay24.com ">doubledown casino free slots</a>

lwtckxlkilwtckxlki2018/03/24 06:30https://howtoinvestinbitcoin.us.org - digital currency stocks
<a href=" https://howtoinvestinbitcoin.us.org ">is bitcoin a good investment</a>
<a href="https://howtoinvestinbitcoin.us.org">buy bitcoin</a>

vcokwnjlermavcokwnjlerma2018/03/24 06:36https://bitcoinstock.us.com - best way to invest in bitcoin
<a href=" https://bitcoinstock.us.com ">bitcoin stocks to invest in</a>
<a href="https://bitcoinstock.us.com">bitcoin current price</a>

wttmwwmkiwttmwwmki2018/03/24 07:21https://howtoinvestinbitcoin.us.org - best way to invest in bitcoin
<a href=" https://howtoinvestinbitcoin.us.org ">best way to invest in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">invest in bitcoin</a>

ltmfmbnkiltmfmbnki2018/03/24 08:13https://howtoinvestinbitcoin.us.org - bitcoin invest
<a href=" https://howtoinvestinbitcoin.us.org ">how to invest in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">how to buy bitcoin</a>

ndtsrImatndtsrImat2018/03/24 08:23https://buybitcoin.us.com - trading bitcoin
<a href=" https://buybitcoin.us.com ">trade bitcoin</a>
<a href="https://buybitcoin.us.com">bitcoin news today</a>

xspkffflermaxspkffflerma2018/03/24 08:52https://bitcoinstock.us.com - is bitcoin a good investment
<a href=" https://bitcoinstock.us.com ">bitcoin investment trust</a>
<a href="https://bitcoinstock.us.com">invest bitcoin</a>

nrfxzdmkinrfxzdmki2018/03/24 09:33https://howtoinvestinbitcoin.us.org - is bitcoin a good investment
<a href=" https://howtoinvestinbitcoin.us.org ">should i invest in bitcoin</a>
<a href="https://howtoinvestinbitcoin.us.org">how to buy bitcoin stock</a>

ggvtswblermaggvtswblerma2018/03/24 10:05https://bitcoinstock.us.com - buy bitcoin
<a href=" https://bitcoinstock.us.com ">bitcoin investments</a>
<a href="https://bitcoinstock.us.com">how does bitcoin work</a>

opgqqvtkiopgqqvtki2018/03/24 10:34https://howtoinvestinbitcoin.us.org - bitcoin stocks
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin trading price</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin current price</a>

jpzledakijpzledaki2018/03/24 11:27https://howtoinvestinbitcoin.us.org - bitcoin investment trust
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin investment trust</a>
<a href="https://howtoinvestinbitcoin.us.org">should i invest in bitcoins</a>

mpghalnlermampghalnlerma2018/03/24 11:37https://bitcoinstock.us.com - how to buy bitcoin
<a href=" https://bitcoinstock.us.com ">how to invest in digital currency</a>
<a href="https://bitcoinstock.us.com">bitcoin cost today</a>

fmdvlqkkifmdvlqkki2018/03/24 12:34https://howtoinvestinbitcoin.us.org - bitcoin investment trust gbtc
<a href=" https://howtoinvestinbitcoin.us.org ">digital currency stocks</a>
<a href="https://howtoinvestinbitcoin.us.org">bitcoin trade</a>

qeuomzglermaqeuomzglerma2018/03/24 13:08https://bitcoinstock.us.com - bitcoin traders
<a href=" https://bitcoinstock.us.com ">bitcoin what is it</a>
<a href="https://bitcoinstock.us.com">buying bitcoin</a>

nyejujckinyejujcki2018/03/24 13:34https://howtoinvestinbitcoin.us.org - bitcoin investment calculator
<a href=" https://howtoinvestinbitcoin.us.org ">bitcoin stocks to invest in</a>
<a href="https://howtoinvestinbitcoin.us.org">is bitcoin a good investment 2017</a>

トラックバック - http://haskell.g.hatena.ne.jp/eagletmt/20100823
 |