(a) Upon a hearing on a writ of habeas corpus, if it appears that the detained party is charged with a public offense which is bailable, he must be admitted to bail on offering sufficient bail.
(b) If sufficient bail is not offered, the amount of bail required must be endorsed on the warrant, and the court to which he is required to appear, and the detained party may be afterwards discharged by the sheriff of the county on giving sufficient bail in the amount so required.
(c) All undertakings of bail taken by any judge or sheriff under the provisions of this section must be transmitted by him to the clerk of the court before which the party is bound to appear by the first day of the next succeeding session and may be forfeited, and the same proceedings thereon had, as against other bail in criminal cases.