A class of C*-algebras generalizing both graph algebras and homeomorphism C*-algebras I, fundamental results