Home | History | Annotate | Line # | Download | only in lib
      1  1.1  christos /*
      2  1.1  christos  * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
      3  1.1  christos  *
      4  1.1  christos  * Licensed under the Apache License 2.0 (the "License").  You may not use
      5  1.1  christos  * this file except in compliance with the License.  You can obtain a copy
      6  1.1  christos  * in the file LICENSE in the source distribution or at
      7  1.1  christos  * https://www.openssl.org/source/license.html
      8  1.1  christos  */
      9  1.1  christos 
     10  1.1  christos #include <string.h>
     11  1.1  christos #include <openssl/bio.h>
     12  1.1  christos #include <openssl/safestack.h>
     13  1.1  christos #include "names.h"
     14  1.1  christos #include "openssl/crypto.h"
     15  1.1  christos 
     16  1.1  christos int name_cmp(const char * const *a, const char * const *b)
     17  1.1  christos {
     18  1.1  christos     return OPENSSL_strcasecmp(*a, *b);
     19  1.1  christos }
     20  1.1  christos 
     21  1.1  christos void collect_names(const char *name, void *vdata)
     22  1.1  christos {
     23  1.1  christos     STACK_OF(OPENSSL_CSTRING) *names = vdata;
     24  1.1  christos 
     25  1.1  christos     sk_OPENSSL_CSTRING_push(names, name);
     26  1.1  christos }
     27  1.1  christos 
     28  1.1  christos void print_names(BIO *out, STACK_OF(OPENSSL_CSTRING) *names)
     29  1.1  christos {
     30  1.1  christos     int i = sk_OPENSSL_CSTRING_num(names);
     31  1.1  christos     int j;
     32  1.1  christos 
     33  1.1  christos     sk_OPENSSL_CSTRING_sort(names);
     34  1.1  christos     if (i > 1)
     35  1.1  christos         BIO_printf(out, "{ ");
     36  1.1  christos     for (j = 0; j < i; j++) {
     37  1.1  christos         const char *name = sk_OPENSSL_CSTRING_value(names, j);
     38  1.1  christos 
     39  1.1  christos         if (j > 0)
     40  1.1  christos             BIO_printf(out, ", ");
     41  1.1  christos         BIO_printf(out, "%s", name);
     42  1.1  christos     }
     43  1.1  christos     if (i > 1)
     44  1.1  christos         BIO_printf(out, " }");
     45  1.1  christos }
     46