this routine encodes data of type int8 to base64 format
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=c_int_least8_t), | intent(in), | target | :: | indata(iplen) |
data to be encoded |
|
integer, | intent(in) | :: | iplen |
size of data to be encoded |
||
integer, | intent(in) | :: | outfile |
output file unit |
subroutine int8_to_base64( indata, iplen, outfile ) ! --------------------------------------------------------------------------- !> size of data to be encoded integer, intent(in) :: iplen !> data to be encoded integer(kind=c_int_least8_t), target, intent(in) :: indata(iplen) !> output file unit integer, intent(in) :: outfile ! --------------------------------------------------------------------------- integer(kind=c_int) :: baserc integer(kind=c_int) :: insize, outsize, ipindex, min_iplen integer :: ind type(c_ptr) :: base64_out type(c_ptr) :: base64_in type(c_ptr) :: encoder_in character, target :: base64_string(encoderlen), encoder_str(encoderblocklen) ! --------------------------------------------------------------------------- base64_in = c_loc(indata) insize = int(c_sizeof(indata(1))*iplen, kind=4) ! write insize i.e bit size in the beginning of the string call convert_to_base64_single( insize, outfile ) outsize = ceiling(insize/3._rk)*4 base64_out = c_loc(base64_string) encoder_in = c_loc(encoder_str) ipindex = 0 do do ind = 0, 2 baserc = encodeindex( base64_in, encoder_in, insize, ind, ipindex ) ipindex = ipindex + 1 end do min_iplen = min(insize - ipindex + 3, 3) baserc = encodeblock( encoder_in, base64_out, min_iplen, outsize ) write(outfile) base64_string if (ipindex >= insize) exit end do end subroutine int8_to_base64