|
| 1 | +!> Interface to the minizip library for creating and extracting zip files. |
| 2 | +module stdlib_io_minizip |
| 3 | + use, intrinsic :: iso_c_binding, only: c_char, c_ptr, c_int, c_long |
| 4 | + implicit none |
| 5 | + private |
| 6 | + |
| 7 | + integer, parameter, public :: UNZ_OK = 0 |
| 8 | + integer, parameter, public :: UNZ_END_OF_LIST_OF_FILE = -100 |
| 9 | + integer, parameter, public :: UNZ_ERRNO = -1 |
| 10 | + integer, parameter, public :: UNZ_EOF = 0 |
| 11 | + integer, parameter, public :: UNZ_PARAMERROR = -102 |
| 12 | + integer, parameter, public :: UNZ_BADZIPFILE = -103 |
| 13 | + integer, parameter, public :: UNZ_INTERNALERROR = -104 |
| 14 | + integer, parameter, public :: UNZ_CRCERROR = -105 |
| 15 | + |
| 16 | + public :: unz_get_global_info |
| 17 | + public :: unz_open |
| 18 | + public :: unz_go_to_first_file |
| 19 | + public :: unz_get_current_file_info |
| 20 | + public :: unz_open_current_file |
| 21 | + public :: unz_read_current_file |
| 22 | + public :: unz_close_current_file |
| 23 | + public :: unz_go_to_next_file |
| 24 | + public :: unz_close |
| 25 | + |
| 26 | + type, bind(c), public :: unz_global_info |
| 27 | + integer(kind=c_long) :: number_of_files |
| 28 | + integer(kind=c_long) :: comment_size |
| 29 | + end type |
| 30 | + |
| 31 | + type, bind(c), public :: unz_file_info |
| 32 | + integer(kind=c_long) :: version |
| 33 | + integer(kind=c_long) :: version_needed |
| 34 | + integer(kind=c_long) :: flag |
| 35 | + integer(kind=c_long) :: compression_method |
| 36 | + integer(kind=c_long) :: dos_date |
| 37 | + integer(kind=c_long) :: crc |
| 38 | + integer(kind=c_long) :: compressed_size |
| 39 | + integer(kind=c_long) :: uncompressed_size |
| 40 | + integer(kind=c_long) :: size_filename |
| 41 | + integer(kind=c_long) :: size_file_extra |
| 42 | + integer(kind=c_long) :: size_file_comment |
| 43 | + integer(kind=c_long) :: disk_num_start |
| 44 | + integer(kind=c_long) :: internal_file_attributes |
| 45 | + integer(kind=c_long) :: external_file_attributes |
| 46 | + end type |
| 47 | + |
| 48 | + interface |
| 49 | + function unz_open(path) bind(c, name='unzOpen') |
| 50 | + import :: c_char, c_ptr |
| 51 | + implicit none |
| 52 | + character(kind=c_char), intent(in) :: path |
| 53 | + type(c_ptr) :: unz_open |
| 54 | + end |
| 55 | + |
| 56 | + function unz_get_global_info(file, global_info) bind(c, name='unzGetGlobalInfo') |
| 57 | + import :: c_ptr, c_int, unz_global_info |
| 58 | + implicit none |
| 59 | + type(c_ptr), intent(in), value :: file |
| 60 | + type(unz_global_info), intent(out) :: global_info |
| 61 | + integer(kind=c_int) :: unz_get_global_info |
| 62 | + end |
| 63 | + |
| 64 | + function unz_go_to_first_file(file) bind(c, name='unzGoToFirstFile') |
| 65 | + import :: c_ptr, c_int |
| 66 | + implicit none |
| 67 | + type(c_ptr), intent(in), value :: file |
| 68 | + integer(kind=c_int) :: unz_go_to_first_file |
| 69 | + end |
| 70 | + |
| 71 | + function unz_get_current_file_info(file, file_info, filename, filename_buffer_size, & |
| 72 | + & extra_field, extra_field_buffer_size, comment, comment_buffer_size) & |
| 73 | + & bind(c, name='unzGetCurrentFileInfo') |
| 74 | + import :: c_ptr, c_int, c_char, c_long, unz_file_info |
| 75 | + implicit none |
| 76 | + type(c_ptr), intent(in), value :: file |
| 77 | + type(unz_file_info), intent(out) :: file_info |
| 78 | + character(kind=c_char), intent(out) :: filename(*) |
| 79 | + integer(kind=c_long), intent(in), value :: filename_buffer_size |
| 80 | + character(kind=c_char), intent(out) :: extra_field(*) |
| 81 | + integer(kind=c_long), intent(in), value :: extra_field_buffer_size |
| 82 | + character(kind=c_char), intent(out) :: comment(*) |
| 83 | + integer(kind=c_long), intent(in), value :: comment_buffer_size |
| 84 | + integer(kind=c_int) :: unz_get_current_file_info |
| 85 | + end |
| 86 | + |
| 87 | + function unz_open_current_file(file) bind(c, name='unzOpenCurrentFile') |
| 88 | + import :: c_ptr, c_int |
| 89 | + implicit none |
| 90 | + type(c_ptr), intent(in), value :: file |
| 91 | + integer(kind=c_int) :: unz_open_current_file |
| 92 | + end |
| 93 | + |
| 94 | + function unz_read_current_file(file, buffer, size) bind(c, name='unzReadCurrentFile') |
| 95 | + import :: c_ptr, c_int, c_char |
| 96 | + implicit none |
| 97 | + type(c_ptr), intent(in), value :: file |
| 98 | + character(kind=c_char), intent(out) :: buffer(*) |
| 99 | + integer(kind=c_int), intent(in), value :: size |
| 100 | + integer(kind=c_int) :: unz_read_current_file |
| 101 | + end |
| 102 | + |
| 103 | + function unz_go_to_next_file(file) bind(c, name='unzGoToNextFile') |
| 104 | + import :: c_ptr, c_int |
| 105 | + implicit none |
| 106 | + type(c_ptr), intent(in), value :: file |
| 107 | + integer(kind=c_int) :: unz_go_to_next_file |
| 108 | + end |
| 109 | + |
| 110 | + function unz_close_current_file(file) bind(c, name='unzCloseCurrentFile') |
| 111 | + import :: c_ptr, c_int |
| 112 | + implicit none |
| 113 | + type(c_ptr), intent(in), value :: file |
| 114 | + integer(kind=c_int) :: unz_close_current_file |
| 115 | + end |
| 116 | + |
| 117 | + function unz_close(file) bind(c, name='unzClose') |
| 118 | + import :: c_ptr, c_int |
| 119 | + implicit none |
| 120 | + type(c_ptr), intent(in), value :: file |
| 121 | + integer(kind=c_int) :: unz_close |
| 122 | + end |
| 123 | + end interface |
| 124 | +end |
0 commit comments