tool_libinfo.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #include "tool_setup.h"
00023 
00024 #include "strcase.h"
00025 
00026 #define ENABLE_CURLX_PRINTF
00027 /* use our own printf() functions */
00028 #include "curlx.h"
00029 
00030 #include "tool_libinfo.h"
00031 
00032 #include "memdebug.h" /* keep this as LAST include */
00033 
00034 /* global variable definitions, for libcurl run-time info */
00035 
00036 curl_version_info_data *curlinfo = NULL;
00037 long built_in_protos = 0;
00038 
00039 /*
00040  * libcurl_info_init: retrieves run-time information about libcurl,
00041  * setting a global pointer 'curlinfo' to libcurl's run-time info
00042  * struct, and a global bit pattern 'built_in_protos' composed of
00043  * CURLPROTO_* bits indicating which protocols are actually built
00044  * into library being used.
00045  */
00046 
00047 CURLcode get_libcurl_info(void)
00048 {
00049   static struct proto_name_pattern {
00050     const char *proto_name;
00051     long        proto_pattern;
00052   } const possibly_built_in[] = {
00053     { "dict",   CURLPROTO_DICT   },
00054     { "file",   CURLPROTO_FILE   },
00055     { "ftp",    CURLPROTO_FTP    },
00056     { "ftps",   CURLPROTO_FTPS   },
00057     { "gopher", CURLPROTO_GOPHER },
00058     { "http",   CURLPROTO_HTTP   },
00059     { "https",  CURLPROTO_HTTPS  },
00060     { "imap",   CURLPROTO_IMAP   },
00061     { "imaps",  CURLPROTO_IMAPS  },
00062     { "ldap",   CURLPROTO_LDAP   },
00063     { "ldaps",  CURLPROTO_LDAPS  },
00064     { "pop3",   CURLPROTO_POP3   },
00065     { "pop3s",  CURLPROTO_POP3S  },
00066     { "rtmp",   CURLPROTO_RTMP   },
00067     { "rtsp",   CURLPROTO_RTSP   },
00068     { "scp",    CURLPROTO_SCP    },
00069     { "sftp",   CURLPROTO_SFTP   },
00070     { "smb",    CURLPROTO_SMB    },
00071     { "smbs",   CURLPROTO_SMBS   },
00072     { "smtp",   CURLPROTO_SMTP   },
00073     { "smtps",  CURLPROTO_SMTPS  },
00074     { "telnet", CURLPROTO_TELNET },
00075     { "tftp",   CURLPROTO_TFTP   },
00076     {  NULL,    0                }
00077   };
00078 
00079   struct proto_name_pattern const *p;
00080   const char *const *proto;
00081 
00082   /* Pointer to libcurl's run-time version information */
00083   curlinfo = curl_version_info(CURLVERSION_NOW);
00084   if(!curlinfo)
00085     return CURLE_FAILED_INIT;
00086 
00087   /* Build CURLPROTO_* bit pattern with libcurl's built-in protocols */
00088   built_in_protos = 0;
00089   if(curlinfo->protocols) {
00090     for(proto = curlinfo->protocols; *proto; proto++) {
00091       for(p = possibly_built_in; p->proto_name; p++) {
00092         if(curl_strequal(*proto, p->proto_name)) {
00093           built_in_protos |= p->proto_pattern;
00094           break;
00095         }
00096       }
00097     }
00098   }
00099 
00100   return CURLE_OK;
00101 }
00102 


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:07