Apache Portable Runtime
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
include
apr_strings.h
Go to the documentation of this file.
1
/* Licensed to the Apache Software Foundation (ASF) under one or more
2
* contributor license agreements. See the NOTICE file distributed with
3
* this work for additional information regarding copyright ownership.
4
* The ASF licenses this file to You under the Apache License, Version 2.0
5
* (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
/* Portions of this file are covered by */
18
/* -*- mode: c; c-file-style: "k&r" -*-
19
20
strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
21
Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>
22
23
This software is provided 'as-is', without any express or implied
24
warranty. In no event will the authors be held liable for any damages
25
arising from the use of this software.
26
27
Permission is granted to anyone to use this software for any purpose,
28
including commercial applications, and to alter it and redistribute it
29
freely, subject to the following restrictions:
30
31
1. The origin of this software must not be misrepresented; you must not
32
claim that you wrote the original software. If you use this software
33
in a product, an acknowledgment in the product documentation would be
34
appreciated but is not required.
35
2. Altered source versions must be plainly marked as such, and must not be
36
misrepresented as being the original software.
37
3. This notice may not be removed or altered from any source distribution.
38
*/
39
40
#ifndef APR_STRINGS_H
41
#define APR_STRINGS_H
42
43
/**
44
* @file apr_strings.h
45
* @brief APR Strings library
46
*/
47
48
#include "
apr.h
"
49
#include "
apr_errno.h
"
50
#include "
apr_pools.h
"
51
#define APR_WANT_IOVEC
52
#include "
apr_want.h
"
53
54
#if APR_HAVE_STDARG_H
55
#include <stdarg.h>
56
#endif
57
58
#ifdef __cplusplus
59
extern
"C"
{
60
#endif
/* __cplusplus */
61
62
/**
63
* @defgroup apr_strings String routines
64
* @ingroup APR
65
* @{
66
*/
67
68
/**
69
* Do a natural order comparison of two strings.
70
* @param a The first string to compare
71
* @param b The second string to compare
72
* @return Either <0, 0, or >0. If the first string is less than the second
73
* this returns <0, if they are equivalent it returns 0, and if the
74
* first string is greater than second string it retuns >0.
75
*/
76
APR_DECLARE
(
int
)
apr_strnatcmp
(
char
const *a,
char
const *b);
77
78
/**
79
* Do a natural order comparison of two strings ignoring the case of the
80
* strings.
81
* @param a The first string to compare
82
* @param b The second string to compare
83
* @return Either <0, 0, or >0. If the first string is less than the second
84
* this returns <0, if they are equivalent it returns 0, and if the
85
* first string is greater than second string it retuns >0.
86
*/
87
APR_DECLARE
(
int
)
apr_strnatcasecmp
(
char
const *a,
char
const *b);
88
89
/**
90
* duplicate a string into memory allocated out of a pool
91
* @param p The pool to allocate out of
92
* @param s The string to duplicate
93
* @return The new string or NULL if s == NULL
94
*/
95
APR_DECLARE
(
char
*)
apr_pstrdup
(
apr_pool_t
*p, const
char
*s);
96
97
/**
98
* Create a null-terminated string by making a copy of a sequence
99
* of characters and appending a null byte
100
* @param p The pool to allocate out of
101
* @param s The block of characters to duplicate
102
* @param n The number of characters to duplicate
103
* @return The new string or NULL if s == NULL
104
* @remark This is a faster alternative to apr_pstrndup, for use
105
* when you know that the string being duplicated really
106
* has 'n' or more characters. If the string might contain
107
* fewer characters, use apr_pstrndup.
108
*/
109
APR_DECLARE
(
char
*)
apr_pstrmemdup
(
apr_pool_t
*p, const
char
*s, apr_size_t n)
110
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
111
__attribute__((alloc_size(3)))
112
#endif
113
;
114
115
/**
116
* Duplicate at most n characters of a string into memory allocated
117
* out of a pool; the new string will be NUL-terminated
118
* @param p The pool to allocate out of
119
* @param s The string to duplicate
120
* @param n The maximum number of characters to duplicate
121
* @return The new string or NULL if s == NULL
122
* @remark The amount of memory allocated from the pool is the length
123
* of the returned string including the NUL terminator
124
*/
125
APR_DECLARE
(
char
*)
apr_pstrndup
(
apr_pool_t
*p, const
char
*s, apr_size_t n);
126
127
/**
128
* Duplicate a block of memory.
129
*
130
* @param p The pool to allocate from
131
* @param m The memory to duplicate
132
* @param n The number of bytes to duplicate
133
* @return The new block of memory or NULL if m == NULL
134
*/
135
APR_DECLARE
(
void
*)
apr_pmemdup
(
apr_pool_t
*p, const
void
*m, apr_size_t n)
136
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
137
__attribute__((alloc_size(3)))
138
#endif
139
;
140