Annotation of embedaddon/curl/docs/examples/sslbackend.c, revision 1.1

1.1     ! misho       1: /***************************************************************************
        !             2:  *                                  _   _ ____  _
        !             3:  *  Project                     ___| | | |  _ \| |
        !             4:  *                             / __| | | | |_) | |
        !             5:  *                            | (__| |_| |  _ <| |___
        !             6:  *                             \___|\___/|_| \_\_____|
        !             7:  *
        !             8:  * Copyright (C) 1998 - 2019, 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: /* <DESC>
        !            23:  * Shows HTTPS usage with client certs and optional ssl engine use.
        !            24:  * </DESC>
        !            25:  */
        !            26: #include <assert.h>
        !            27: #include <ctype.h>
        !            28: #include <stdio.h>
        !            29: #include <stdlib.h>
        !            30: #include <string.h>
        !            31: 
        !            32: #include <curl/curl.h>
        !            33: 
        !            34: /*
        !            35:  * An SSL-enabled libcurl is required for this sample to work (at least one
        !            36:  * SSL backend has to be configured).
        !            37:  *
        !            38:  *  **** This example only works with libcurl 7.56.0 and later! ****
        !            39: */
        !            40: 
        !            41: int main(int argc, char **argv)
        !            42: {
        !            43:   const char *name = argc > 1 ? argv[1] : "openssl";
        !            44:   CURLsslset result;
        !            45: 
        !            46:   if(!strcmp("list", name)) {
        !            47:     const curl_ssl_backend **list;
        !            48:     int i;
        !            49: 
        !            50:     result = curl_global_sslset(-1, NULL, &list);
        !            51:     assert(result == CURLSSLSET_UNKNOWN_BACKEND);
        !            52: 
        !            53:     for(i = 0; list[i]; i++)
        !            54:       printf("SSL backend #%d: '%s' (ID: %d)\n",
        !            55:              i, list[i]->name, list[i]->id);
        !            56: 
        !            57:     return 0;
        !            58:   }
        !            59:   else if(isdigit((int)(unsigned char)*name)) {
        !            60:     int id = atoi(name);
        !            61: 
        !            62:     result = curl_global_sslset((curl_sslbackend)id, NULL, NULL);
        !            63:   }
        !            64:   else
        !            65:     result = curl_global_sslset(-1, name, NULL);
        !            66: 
        !            67:   if(result == CURLSSLSET_UNKNOWN_BACKEND) {
        !            68:     fprintf(stderr, "Unknown SSL backend id: %s\n", name);
        !            69:     return 1;
        !            70:   }
        !            71: 
        !            72:   assert(result == CURLSSLSET_OK);
        !            73: 
        !            74:   printf("Version with SSL backend '%s':\n\n\t%s\n", name, curl_version());
        !            75: 
        !            76:   return 0;
        !            77: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>