! Copyright (c) 2021 Approximatrix, LLC ! ! Permission is hereby granted, free of charge, to any person obtaining a copy ! of this software and associated documentation files (the "Software"), to deal ! in the Software without restriction, including without limitation the rights ! to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ! copies of the Software, and to permit persons to whom the Software is ! furnished to do so, subject to the following conditions: ! ! The above copyright notice and this permission notice shall be included in ! all copies or substantial portions of the Software. ! ! The Software shall be used for Good, not Evil. ! ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ! SOFTWARE. module talking implicit none contains function request_to_file(url, filename) result(status_code) use utilities use gemini_protocol implicit none character(*), intent(in)::url character(*), intent(in)::filename character(64)::return_type integer::unit_number integer::status_code integer::istatus character(len=:), allocatable::mod_url allocate(character(len=len_trim(url)) :: mod_url) mod_url = url open(newunit=unit_number, file=filename, status='UNKNOWN', & access='STREAM', iostat=istatus) ! form='FORMATTED', if(istatus == 0) then status_code = request_url(mod_url, unit_number, return_type) else status_code = STATUS_LOCALFAIL Print *, "Failed to open: "//trim(filename) end if close(unit_number) deallocate(mod_url) end function request_to_file function request_to_temporary_file(url, filename) result(status_code) use utilities, only: generate_temporary_filename use gemini_protocol, only: STATUS_LOCALFAIL implicit none character(*), intent(in)::url character(:), pointer::filename integer::status_code filename => generate_temporary_filename() if(.not. associated(filename)) then status_code = STATUS_LOCALFAIL else status_code = request_to_file(url, filename) end if end function request_to_temporary_file function request_to_ignored(url) result(status_code) use gemini_protocol implicit none character(*), intent(in)::url integer::status_code integer::io character(64)::return_type character(len=:), allocatable::mod_url allocate(character(len=len_trim(url)) :: mod_url) mod_url = url open(newunit=io, status="scratch", access='stream') status_code = request_url(mod_url, io, return_type) Print *, status_code close(io) deallocate(mod_url) end function request_to_ignored function send_file(url, filename) result(status_code) use gemini_protocol use config, only: token, identity implicit none character(*), intent(in)::url character(*), intent(in)::filename integer::status_code integer::io character(64)::return_type character(len=:), allocatable::mod_url integer(kind=8)::file_size integer::unit_number, istatus allocate(character(len=len_trim(url)) :: mod_url) mod_url = url inquire(file=filename, size=file_size) open(newunit=unit_number, file=trim(filename), status='OLD', & access='STREAM', form='UNFORMATTED', iostat=istatus) if(istatus == 0) then status_code = titan_post_url(mod_url, unit_number, file_size, trim(identity)//":"//trim(token)) close(unit_number) else status_code = STATUS_LOCALFAIL end if deallocate(mod_url) end function send_file end module talking