Debian Codegraph @

R/options.R

raw
1 #' List curl version and options.
2 #'
3 #' `curl_version()` shows the versions of libcurl, libssl and zlib and
4 #' supported protocols. `curl_options()` lists all options available in
5 #' the current version of libcurl. The dataset `curl_symbols` lists all
6 #' symbols (including options) provides more information about the symbols,
7 #' including when support was added/removed from libcurl.
8 #'
9 #' @export
10 #' @rdname curl_options
11 #' @param filter string: only return options with string in name
12 #' @examples # Available options
13 #' curl_options()
14 #'
15 #' # List proxy options
16 #' curl_options("proxy")
17 #'
18 #' # Symbol table
19 #' curl_symbols("proxy")
20 curl_options <- function(filter = ""){
21 option_type_table <- make_option_type_table()
22 opts <- structure(option_type_table$value, names = option_type_table$name)
23 m <- grep(filter, names(opts), ignore.case = TRUE)
24 opts[m]
25 }
26
27 #' @export
28 #' @rdname curl_options
29 curl_options_table <- function(filter = ""){
30 option_type_table <- make_option_type_table()
31 m <- grep(filter, option_type_table$name, ignore.case = TRUE)
32 option_type_table[m,]
33 }
34
35 #' @useDynLib curl R_option_types
36 make_option_type_table <- local({
37 cache <- NULL
38 function(){
39 if(is.null(cache)){
40 out <- .Call(R_option_types)
41 if(!length(out)) return(out)
42 out$name <- tolower(out$name)
43 out$type <- factor(out$type, levels = 0:8, labels = c("long", "values", "off_t",
44 "object", "string", "slist", "cbptr", "blob", "function"))
45 cache <<- structure(out, class = 'data.frame', row.names = seq_along(out$name))
46 }
47 return(cache)
48 }
49 })