Hexadecimal To Decimal Read input of up to 8 characters presented as hexadecimal number and print this number as decimal number. In case that input can not be presented as hexadecimal input it has to print 0

Rules:
It is not allowed to use any function that takes or returns strings/characters, beside function that reads string/char from input and return strings/char as-is, function that takes integer and prints that integer to output as decimal number and function (if needed) that takes character and return its ASCII/UNICODE represented integer. 

Shortest code wins 

Example input
C0cAc01a

output
3234512922
Ruby, 74 characters
n=0;p gets.gsub(/./).all?{|x|n=n*16+(x&gt;?9?9:0)+x.ord%16;/[\da-f]/i=~x}?n:0

Input must be given on STDIN. With command line option -ln (counted as 4) it can be shortened to 69 characters.
n=0;p chars.all?{|x|n=n*16+(x&gt;?9?9:0)+x.ord%16;/[\da-f]/i=~x}?n:0