Permalink
Browse files

Add example application using libcurl

  • Loading branch information...
1 parent d7c0ed6 commit d11e2fabfdf02bbb912aaf44579cf4593d51f51c @doublec committed Apr 22, 2011
Showing with 29 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +18 −0 CurlExample.oz
  3. +10 −1 Makefile
View
1 .gitignore
@@ -3,3 +3,4 @@
*.o
*.ozc
*.ozf
+*.oza
View
18 CurlExample.oz
@@ -0,0 +1,18 @@
+functor
+import
+ Module
+ Application
+define
+ [FFI] = {Module.link ['ffi.ozf']}
+ Curl = {FFI.load "libcurl.so"}
+ EasyInit = {FFI.bind Curl "curl_easy_init" pointer nil}
+ EasyCleanup = {FFI.bind Curl "curl_easy_cleanup" void [pointer]}
+ EasySetString = {FFI.bind Curl "curl_easy_setopt" uint32 [pointer uint32 string]}
+ EasyPerform = {FFI.bind Curl "curl_easy_perform" uint32 [pointer]}
+ C = {EasyInit}
+ _ = {EasySetString C 10002 "http://www.mozart-oz.org/"}
+ _ = {EasyPerform C}
+ _ = {EasyCleanup C}
+in
+ {Application.exit 0}
+end
View
11 Makefile
@@ -1,7 +1,7 @@
DLL=ozffi.so-$(shell oztool platform)
.PHONY: all
-all: $(DLL) ffi.ozf
+all: $(DLL) ffi.ozf CurlExample
ozffi.o: ozffi.cpp
oztool c++ -c $< -o $@
@@ -12,8 +12,17 @@ $(DLL): ozffi.o
ffi.ozf: ffi.oz
ozc -c $< -o $@
+CurlExample.oza: CurlExample.oz
+ ozc -c $< -o $@
+
+CurlExample: CurlExample.oza
+ ozl -x $< -o $@
+
.PHONY: clean
clean:
-rm $(DLL)
-rm ozffi.o
-rm ffi.ozf
+ -rm CurlExample
+ -rm CurlExample.oza
+ -rm *~

0 comments on commit d11e2fa

Please sign in to comment.