An appeals court has struck down California's ban on openly carrying firearms in most parts of the US state.