5
5
! Author: Philipp Engel
6
6
! Licence: ISC
7
7
module curl
8
- use , intrinsic :: iso_c_binding, only: c_associated, c_char, c_f_pointer, c_funptr, &
9
- c_int, c_int64_t, c_loc, c_long, c_ptr, c_size_t
8
+ use , intrinsic :: iso_c_binding
10
9
implicit none
11
10
12
- public :: c_f_str_ptr
13
-
14
- public :: curl_easy_init
15
- public :: curl_easy_perform
16
- public :: curl_easy_cleanup
17
- public :: curl_easy_setopt
18
- public :: curl_easy_setopt_c_ptr
19
- public :: curl_easy_setopt_c_funptr
20
- public :: curl_slist_append
21
- public :: curl_slist_free_all
22
- public :: curl_version_info
23
- public :: curl_version_now
24
-
25
- private :: curl_easy_setopt_char
26
- private :: curl_easy_setopt_fptr
27
- private :: curl_easy_setopt_int
28
- private :: curl_easy_setopt_long
29
- private :: curl_easy_setopt_ptr
30
-
31
11
integer (kind= c_int), parameter :: CURLOPTTYPE_LONG = 0
32
12
integer (kind= c_int), parameter :: CURLOPTTYPE_OBJECTPOINT = 10000
33
13
integer (kind= c_int), parameter :: CURLOPTTYPE_STRINGPOINT = 10000
@@ -394,19 +374,22 @@ module curl
394
374
! CURL *curl_easy_init(void)
395
375
function curl_easy_init () bind(c, name= ' curl_easy_init' )
396
376
import :: c_ptr
377
+ implicit none
397
378
type (c_ptr) :: curl_easy_init
398
379
end function curl_easy_init
399
380
400
381
! CURLcode curl_easy_perform(CURL *curl)
401
382
function curl_easy_perform (curl ) bind(c, name= ' curl_easy_perform' )
402
383
import :: c_int, c_ptr
384
+ implicit none
403
385
type (c_ptr), intent (in ), value :: curl
404
386
integer (kind= c_int) :: curl_easy_perform
405
387
end function curl_easy_perform
406
388
407
389
! CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...)
408
390
function curl_easy_setopt_c_ptr (curl , option , parameter ) bind(c, name= ' curl_easy_setopt' )
409
391
import :: c_int, c_ptr
392
+ implicit none
410
393
type (c_ptr), intent (in ), value :: curl
411
394
integer (kind= c_int), intent (in ), value :: option
412
395
type (c_ptr), intent (in ), value :: parameter
@@ -416,6 +399,7 @@ end function curl_easy_setopt_c_ptr
416
399
! CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...)
417
400
function curl_easy_setopt_c_funptr (curl , option , parameter ) bind(c, name= ' curl_easy_setopt' )
418
401
import :: c_funptr, c_int, c_ptr
402
+ implicit none
419
403
type (c_ptr), intent (in ), value :: curl
420
404
integer (kind= c_int), intent (in ), value :: option
421
405
type (c_funptr), intent (in ), value :: parameter
@@ -425,6 +409,7 @@ end function curl_easy_setopt_c_funptr
425
409
! struct curl_slist *curl_slist_append(struct curl_slist *list, const char *string)
426
410
function curl_slist_append (list , string ) bind(c, name= ' curl_slist_append' )
427
411
import :: c_char, c_ptr
412
+ implicit none
428
413
type (c_ptr), intent (in ), value :: list
429
414
character (kind= c_char), intent (in ) :: string
430
415
type (c_ptr) :: curl_slist_append
@@ -433,19 +418,22 @@ end function curl_slist_append
433
418
! curl_version_info_data *curl_version_info(CURLversion age)
434
419
function curl_version_info_ (age ) bind(c, name= ' curl_version_info' )
435
420
import :: c_int, c_ptr
421
+ implicit none
436
422
integer (kind= c_int), intent (in ), value :: age
437
423
type (c_ptr) :: curl_version_info_
438
424
end function curl_version_info_
439
425
440
426
! void curl_easy_cleanup(CURL *curl)
441
427
subroutine curl_easy_cleanup (curl ) bind(c, name= ' curl_easy_cleanup' )
442
428
import :: c_ptr
429
+ implicit none
443
430
type (c_ptr), intent (in ), value :: curl
444
431
end subroutine curl_easy_cleanup
445
432
446
433
! void curl_slist_free_all(struct curl_slist *list)
447
434
subroutine curl_slist_free_all (list ) bind(c, name= ' curl_slist_free_all' )
448
435
import :: c_ptr
436
+ implicit none
449
437
type (c_ptr), intent (in ), value :: list
450
438
end subroutine curl_slist_free_all
451
439
end interface
@@ -456,6 +444,7 @@ function curl_version_now() bind(c, name='curl_version_now')
456
444
! ! Interface to wrapper function `curl_version_now()` for C constant
457
445
! ! `CURLVERSION_NOW`.
458
446
import :: c_int
447
+ implicit none
459
448
integer (kind= c_int) :: curl_version_now
460
449
end function curl_version_now
461
450
end interface
@@ -476,10 +465,31 @@ end function curl_version_now
476
465
! size_t strlen(const char *str)
477
466
function c_strlen (str ) bind(c, name= ' strlen' )
478
467
import :: c_ptr, c_size_t
468
+ implicit none
479
469
type (c_ptr), intent (in ), value :: str
480
470
integer (kind= c_size_t) :: c_strlen
481
471
end function c_strlen
482
472
end interface
473
+
474
+ public :: c_f_str_ptr
475
+ public :: curl_easy_init
476
+ public :: curl_easy_perform
477
+ public :: curl_easy_cleanup
478
+ public :: curl_easy_setopt
479
+ public :: curl_easy_setopt_c_ptr
480
+ public :: curl_easy_setopt_c_funptr
481
+ public :: curl_slist_append
482
+ public :: curl_slist_free_all
483
+ public :: curl_version_info
484
+ public :: curl_version_now
485
+
486
+ private :: c_strlen
487
+ private :: copy
488
+ private :: curl_easy_setopt_char
489
+ private :: curl_easy_setopt_fptr
490
+ private :: curl_easy_setopt_int
491
+ private :: curl_easy_setopt_long
492
+ private :: curl_easy_setopt_ptr
483
493
contains
484
494
pure function copy (a )
485
495
character , intent (in ) :: a(:)
@@ -577,7 +587,7 @@ subroutine c_f_str_ptr(c_str, f_str, size)
577
587
sz = c_strlen(c_str)
578
588
end if
579
589
580
- if (sz <= 0 ) return
590
+ if (sz < 0 ) return
581
591
call c_f_pointer(c_str, ptrs, [ sz ])
582
592
allocate (character (len= sz) :: f_str)
583
593
f_str = copy(ptrs)
0 commit comments