view python/pydc/examples/atoi.py @ 1:5e159be89d73

- ruby and sh binding updates for dc r0.9
author cslag
date Thu, 31 Dec 2015 20:17:37 +0100
parents 0cfcc391201f
children bf5625bb6f05
line wrap: on
line source

from pydc import *
from sys  import platform

if platform == "win32":
  libc = load("msvcrt")
elif platform == "darwin":
  libc = load("/usr/lib/libc.dylib")
else:
  libc = load("/lib/libc.so.6")

fp_atoi = find(libc,"atoi")
fp_atof = find(libc,"atof")

def atoi(s): return call(fp_atoi,"p)i",s)
def atod(s): return call(fp_atof,"p)d",s)

print atoi( "3".join(["12","45"]) )
print atod( "3".join(["12","45"]) )