tool_libinfo.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at https://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  ***************************************************************************/
22 #include "tool_setup.h"
23 
24 #include "strcase.h"
25 
26 #define ENABLE_CURLX_PRINTF
27 /* use our own printf() functions */
28 #include "curlx.h"
29 
30 #include "tool_libinfo.h"
31 
32 #include "memdebug.h" /* keep this as LAST include */
33 
34 /* global variable definitions, for libcurl run-time info */
35 
37 long built_in_protos = 0;
38 
39 /*
40  * libcurl_info_init: retrieves run-time information about libcurl,
41  * setting a global pointer 'curlinfo' to libcurl's run-time info
42  * struct, and a global bit pattern 'built_in_protos' composed of
43  * CURLPROTO_* bits indicating which protocols are actually built
44  * into library being used.
45  */
46 
48 {
49  static struct proto_name_pattern {
50  const char *proto_name;
51  long proto_pattern;
52  } const possibly_built_in[] = {
53  { "dict", CURLPROTO_DICT },
54  { "file", CURLPROTO_FILE },
55  { "ftp", CURLPROTO_FTP },
56  { "ftps", CURLPROTO_FTPS },
57  { "gopher", CURLPROTO_GOPHER },
58  { "http", CURLPROTO_HTTP },
59  { "https", CURLPROTO_HTTPS },
60  { "imap", CURLPROTO_IMAP },
61  { "imaps", CURLPROTO_IMAPS },
62  { "ldap", CURLPROTO_LDAP },
63  { "ldaps", CURLPROTO_LDAPS },
64  { "pop3", CURLPROTO_POP3 },
65  { "pop3s", CURLPROTO_POP3S },
66  { "rtmp", CURLPROTO_RTMP },
67  { "rtsp", CURLPROTO_RTSP },
68  { "scp", CURLPROTO_SCP },
69  { "sftp", CURLPROTO_SFTP },
70  { "smb", CURLPROTO_SMB },
71  { "smbs", CURLPROTO_SMBS },
72  { "smtp", CURLPROTO_SMTP },
73  { "smtps", CURLPROTO_SMTPS },
74  { "telnet", CURLPROTO_TELNET },
75  { "tftp", CURLPROTO_TFTP },
76  { NULL, 0 }
77  };
78 
79  struct proto_name_pattern const *p;
80  const char *const *proto;
81 
82  /* Pointer to libcurl's run-time version information */
84  if(!curlinfo)
85  return CURLE_FAILED_INIT;
86 
87  /* Build CURLPROTO_* bit pattern with libcurl's built-in protocols */
88  built_in_protos = 0;
89  if(curlinfo->protocols) {
90  for(proto = curlinfo->protocols; *proto; proto++) {
91  for(p = possibly_built_in; p->proto_name; p++) {
92  if(curl_strequal(*proto, p->proto_name)) {
93  built_in_protos |= p->proto_pattern;
94  break;
95  }
96  }
97  }
98  }
99 
100  return CURLE_OK;
101 }
102 
#define CURLPROTO_FTPS
Definition: curl.h:847
#define CURLPROTO_HTTP
Definition: curl.h:844
#define CURLPROTO_FILE
Definition: curl.h:854
#define CURLPROTO_SCP
Definition: curl.h:848
CURL_EXTERN curl_version_info_data * curl_version_info(CURLversion)
Definition: version.c:342
#define CURLPROTO_SMB
Definition: curl.h:870
#define CURLPROTO_DICT
Definition: curl.h:853
curl_version_info_data * curlinfo
Definition: tool_libinfo.c:36
#define CURLPROTO_IMAP
Definition: curl.h:856
#define CURLPROTO_SMBS
Definition: curl.h:871
#define CURLPROTO_SMTPS
Definition: curl.h:861
CURLcode
Definition: curl.h:454
#define CURLPROTO_GOPHER
Definition: curl.h:869
#define CURLPROTO_FTP
Definition: curl.h:846
const char ** p
Definition: unit1394.c:76
#define CURLPROTO_SFTP
Definition: curl.h:849
#define CURLPROTO_HTTPS
Definition: curl.h:845
#define CURLPROTO_RTSP
Definition: curl.h:862
#define CURLPROTO_LDAP
Definition: curl.h:851
#define CURLPROTO_LDAPS
Definition: curl.h:852
#define CURLPROTO_POP3S
Definition: curl.h:859
#define CURLPROTO_IMAPS
Definition: curl.h:857
#define CURLPROTO_RTMP
Definition: curl.h:863
#define CURLPROTO_TFTP
Definition: curl.h:855
Definition: curl.h:455
CURLcode get_libcurl_info(void)
Definition: tool_libinfo.c:47
CURL_EXTERN int curl_strequal(const char *s1, const char *s2)
Definition: strcase.c:170
#define CURLPROTO_TELNET
Definition: curl.h:850
#define CURLPROTO_SMTP
Definition: curl.h:860
#define CURLVERSION_NOW
Definition: curl.h:2603
long built_in_protos
Definition: tool_libinfo.c:37
#define CURLPROTO_POP3
Definition: curl.h:858
const char *const * protocols
Definition: curl.h:2615


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:16