Standard preamble:
========================================================================
..
.... Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.
If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.
Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================
Title "DEFINE_STACK_OF 3"
way too many mistakes in technical documents.
\s-1STACK_OF\s0() returns the name for a stack of the specified \s-1TYPE\s0. \s-1DEFINE_STACK_OF\s0() creates set of functions for a stack of \s-1TYPE\s0. This will mean that type \s-1TYPE\s0 is stored in each stack, the type is referenced by \s-1STACK_OF\s0(\s-1TYPE\s0) and each function name begins with sk_TYPE_. For example:
.Vb 1 TYPE *sk_TYPE_value(STACK_OF(TYPE) *sk, int idx); .Ve
\s-1DEFINE_STACK_OF_CONST\s0() is identical to \s-1DEFINE_STACK_OF\s0() except each element is constant. For example:
.Vb 1 const TYPE *sk_TYPE_value(STACK_OF(TYPE) *sk, int idx); .Ve
\s-1DEFINE_SPECIAL_STACK_OF\s0() defines a stack of \s-1TYPE\s0 but each function uses \s-1FUNCNAME\s0 in the function name. For example:
.Vb 1 TYPE *sk_FUNCNAME_value(STACK_OF(TYPE) *sk, int idx); .Ve
\s-1DEFINE_SPECIAL_STACK_OF_CONST\s0() is similar except that each element is constant:
.Vb 1 const TYPE *sk_FUNCNAME_value(STACK_OF(TYPE) *sk, int idx); .Ve
\fBsk_TYPE_num() returns the number of elements in sk or -1 if sk is \fB\s-1NULL\s0.
\fBsk_TYPE_value() returns element idx in sk, where idx starts at zero. If idx is out of range then \s-1NULL\s0 is returned.
\fBsk_TYPE_new() allocates a new empty stack using comparison function compare. If compare is \s-1NULL\s0 then no comparison function is used. This function is equivalent to sk_TYPE_new_reserve(compare, 0).
\fBsk_TYPE_new_null() allocates a new empty stack with no comparison function. This function is equivalent to sk_TYPE_new_reserve(\s-1NULL, 0\s0).
\fBsk_TYPE_reserve() allocates additional memory in the sk structure such that the next n calls to sk_TYPE_insert(), sk_TYPE_push() or sk_TYPE_unshift() will not fail or cause memory to be allocated or reallocated. If n is zero, any excess space allocated in the \fBsk structure is freed. On error sk is unchanged.
\fBsk_TYPE_new_reserve() allocates a new stack. The new stack will have additional memory allocated to hold n elements if n is positive. The next n calls to sk_TYPE_insert(), sk_TYPE_push() or sk_TYPE_unshift() will not fail or cause memory to be allocated or reallocated. If n is zero or less than zero, no memory is allocated. sk_TYPE_new_reserve() also sets the comparison function \fBcompare to the newly created stack. If compare is \s-1NULL\s0 then no comparison function is used.
\fBsk_TYPE_set_cmp_func() sets the comparison function of sk to compare. The previous comparison function is returned or \s-1NULL\s0 if there was no previous comparison function.
\fBsk_TYPE_free() frees up the sk structure. It does not free up any elements of sk. After this call sk is no longer valid.
\fBsk_TYPE_zero() sets the number of elements in sk to zero. It does not free \fBsk so after this call sk is still valid.
\fBsk_TYPE_pop_free() frees up all elements of sk and sk itself. The free function freefunc() is called on each element to free it.
\fBsk_TYPE_delete() deletes element i from sk. It returns the deleted element or \s-1NULL\s0 if i is out of range.
\fBsk_TYPE_delete_ptr() deletes element matching ptr from sk. It returns the deleted element or \s-1NULL\s0 if no element matching ptr was found.
\fBsk_TYPE_insert() inserts ptr into sk at position idx. Any existing elements at or after idx are moved downwards. If idx is out of range the new element is appended to sk. sk_TYPE_insert() either returns the number of elements in sk after the new element is inserted or zero if an error (such as memory allocation failure) occurred.
\fBsk_TYPE_push() appends ptr to sk it is equivalent to:
.Vb 1 sk_TYPE_insert(sk, ptr, -1); .Ve
\fBsk_TYPE_unshift() inserts ptr at the start of sk it is equivalent to:
.Vb 1 sk_TYPE_insert(sk, ptr, 0); .Ve
\fBsk_TYPE_pop() returns and removes the last element from sk.
\fBsk_TYPE_shift() returns and removes the first element from sk.
\fBsk_TYPE_set() sets element idx of sk to ptr replacing the current element. The new element value is returned or \s-1NULL\s0 if an error occurred: this will only happen if sk is \s-1NULL\s0 or idx is out of range.
\fBsk_TYPE_find() searches sk for the element ptr. In the case where no comparison function has been specified, the function performs a linear search for a pointer equal to ptr. The index of the first matching element is returned or -1 if there is no match. In the case where a comparison function has been specified, sk is sorted then \fBsk_TYPE_find() returns the index of a matching element or -1 if there is no match. Note that, in this case, the matching element returned is not guaranteed to be the first; the comparison function will usually compare the values pointed to rather than the pointers themselves and the order of elements in sk could change.
\fBsk_TYPE_find_ex() operates like sk_TYPE_find() except when a comparison function has been specified and no matching element is found. Instead of returning -1, sk_TYPE_find_ex() returns the index of the element either before or after the location where ptr would be if it were present in sk.
\fBsk_TYPE_sort() sorts sk using the supplied comparison function.
\fBsk_TYPE_is_sorted() returns 1 if sk is sorted and 0 otherwise.
\fBsk_TYPE_dup() returns a copy of sk. Note the pointers in the copy are identical to the original.
\fBsk_TYPE_deep_copy() returns a new stack where each element has been copied. Copying is performed by the supplied copyfunc() and freeing by freefunc(). The function freefunc() is only called if an error occurs.
Any comparison function supplied should use a metric suitable for use in a binary search operation. That is it should return zero, a positive or negative value if a is equal to, greater than or less than b respectively.
Care should be taken when checking the return values of the functions \fBsk_TYPE_find() and sk_TYPE_find_ex(). They return an index to the matching element. In particular 0 indicates a matching first element. A failed search is indicated by a -1 return value.
\s-1STACK_OF\s0(), \s-1DEFINE_STACK_OF\s0(), \s-1DEFINE_STACK_OF_CONST\s0(), and \s-1DEFINE_SPECIAL_STACK_OF\s0() are implemented as macros.
The underlying utility OPENSSL_sk_ \s-1API\s0 should not be used directly. It defines these functions: OPENSSL_sk_deep_copy(), \fBOPENSSL_sk_delete(), OPENSSL_sk_delete_ptr(), OPENSSL_sk_dup(), \fBOPENSSL_sk_find(), OPENSSL_sk_find_ex(), OPENSSL_sk_free(), \fBOPENSSL_sk_insert(), OPENSSL_sk_is_sorted(), OPENSSL_sk_new(), \fBOPENSSL_sk_new_null(), OPENSSL_sk_num(), OPENSSL_sk_pop(), \fBOPENSSL_sk_pop_free(), OPENSSL_sk_push(), OPENSSL_sk_reserve(), \fBOPENSSL_sk_set(), OPENSSL_sk_set_cmp_func(), OPENSSL_sk_shift(), \fBOPENSSL_sk_sort(), OPENSSL_sk_unshift(), OPENSSL_sk_value(), \fBOPENSSL_sk_zero().
\fBsk_TYPE_value() returns a pointer to a stack element or \s-1NULL\s0 if the index is out of range.
\fBsk_TYPE_new(), sk_TYPE_new_null() and sk_TYPE_new_reserve() return an empty stack or \s-1NULL\s0 if an error occurs.
\fBsk_TYPE_reserve() returns 1 on successful allocation of the required memory or 0 on error.
\fBsk_TYPE_set_cmp_func() returns the old comparison function or \s-1NULL\s0 if there was no old comparison function.
\fBsk_TYPE_free(), sk_TYPE_zero(), sk_TYPE_pop_free() and sk_TYPE_sort() do not return values.
\fBsk_TYPE_pop(), sk_TYPE_shift(), sk_TYPE_delete() and sk_TYPE_delete_ptr() return a pointer to the deleted element or \s-1NULL\s0 on error.
\fBsk_TYPE_insert(), sk_TYPE_push() and sk_TYPE_unshift() return the total number of elements in the stack and 0 if an error occurred. sk_TYPE_push() further returns -1 if sk is \s-1NULL\s0.
\fBsk_TYPE_set() returns a pointer to the replacement element or \s-1NULL\s0 on error.
\fBsk_TYPE_find() and sk_TYPE_find_ex() return an index to the found element or -1 on error.
\fBsk_TYPE_is_sorted() returns 1 if the stack is sorted and 0 if it is not.
\fBsk_TYPE_dup() and sk_TYPE_deep_copy() return a pointer to the copy of the stack.
\fBsk_TYPE_reserve() and sk_TYPE_new_reserve() were added in OpenSSL 1.1.1.
Licensed under the OpenSSL license (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.