xref: /freebsd/contrib/libdivsufsort/include/divsufsort.h.cmake (revision d8a0fe102c0cfdfcd5b818f850eff09d8536c9bc)
1/*
2 * divsufsort@W64BIT@.h for libdivsufsort@W64BIT@
3 * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following
12 * conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27#ifndef _DIVSUFSORT@W64BIT@_H
28#define _DIVSUFSORT@W64BIT@_H 1
29
30#ifdef __cplusplus
31extern "C" {
32#endif /* __cplusplus */
33
34@INCFILE@
35
36#ifndef DIVSUFSORT_API
37# ifdef DIVSUFSORT_BUILD_DLL
38#  define DIVSUFSORT_API @DIVSUFSORT_EXPORT@
39# else
40#  define DIVSUFSORT_API @DIVSUFSORT_IMPORT@
41# endif
42#endif
43
44/*- Datatypes -*/
45#ifndef SAUCHAR_T
46#define SAUCHAR_T
47typedef @SAUCHAR_TYPE@ sauchar_t;
48#endif /* SAUCHAR_T */
49#ifndef SAINT_T
50#define SAINT_T
51typedef @SAINT32_TYPE@ saint_t;
52#endif /* SAINT_T */
53#ifndef SAIDX@W64BIT@_T
54#define SAIDX@W64BIT@_T
55typedef @SAINDEX_TYPE@ saidx@W64BIT@_t;
56#endif /* SAIDX@W64BIT@_T */
57#ifndef PRIdSAINT_T
58#define PRIdSAINT_T @SAINT_PRId@
59#endif /* PRIdSAINT_T */
60#ifndef PRIdSAIDX@W64BIT@_T
61#define PRIdSAIDX@W64BIT@_T @SAINDEX_PRId@
62#endif /* PRIdSAIDX@W64BIT@_T */
63
64
65/*- Prototypes -*/
66
67/**
68 * Constructs the suffix array of a given string.
69 * @param T[0..n-1] The input string.
70 * @param SA[0..n-1] The output array of suffixes.
71 * @param n The length of the given string.
72 * @return 0 if no error occurred, -1 or -2 otherwise.
73 */
74DIVSUFSORT_API
75saint_t
76divsufsort@W64BIT@(const sauchar_t *T, saidx@W64BIT@_t *SA, saidx@W64BIT@_t n);
77
78/**
79 * Constructs the burrows-wheeler transformed string of a given string.
80 * @param T[0..n-1] The input string.
81 * @param U[0..n-1] The output string. (can be T)
82 * @param A[0..n-1] The temporary array. (can be NULL)
83 * @param n The length of the given string.
84 * @return The primary index if no error occurred, -1 or -2 otherwise.
85 */
86DIVSUFSORT_API
87saidx@W64BIT@_t
88divbwt@W64BIT@(const sauchar_t *T, sauchar_t *U, saidx@W64BIT@_t *A, saidx@W64BIT@_t n);
89
90/**
91 * Returns the version of the divsufsort library.
92 * @return The version number string.
93 */
94DIVSUFSORT_API
95const char *
96divsufsort@W64BIT@_version(void);
97
98
99/**
100 * Constructs the burrows-wheeler transformed string of a given string and suffix array.
101 * @param T[0..n-1] The input string.
102 * @param U[0..n-1] The output string. (can be T)
103 * @param SA[0..n-1] The suffix array. (can be NULL)
104 * @param n The length of the given string.
105 * @param idx The output primary index.
106 * @return 0 if no error occurred, -1 or -2 otherwise.
107 */
108DIVSUFSORT_API
109saint_t
110bw_transform@W64BIT@(const sauchar_t *T, sauchar_t *U,
111             saidx@W64BIT@_t *SA /* can NULL */,
112             saidx@W64BIT@_t n, saidx@W64BIT@_t *idx);
113
114/**
115 * Inverse BW-transforms a given BWTed string.
116 * @param T[0..n-1] The input string.
117 * @param U[0..n-1] The output string. (can be T)
118 * @param A[0..n-1] The temporary array. (can be NULL)
119 * @param n The length of the given string.
120 * @param idx The primary index.
121 * @return 0 if no error occurred, -1 or -2 otherwise.
122 */
123DIVSUFSORT_API
124saint_t
125inverse_bw_transform@W64BIT@(const sauchar_t *T, sauchar_t *U,
126                     saidx@W64BIT@_t *A /* can NULL */,
127                     saidx@W64BIT@_t n, saidx@W64BIT@_t idx);
128
129/**
130 * Checks the correctness of a given suffix array.
131 * @param T[0..n-1] The input string.
132 * @param SA[0..n-1] The input suffix array.
133 * @param n The length of the given string.
134 * @param verbose The verbose mode.
135 * @return 0 if no error occurred.
136 */
137DIVSUFSORT_API
138saint_t
139sufcheck@W64BIT@(const sauchar_t *T, const saidx@W64BIT@_t *SA, saidx@W64BIT@_t n, saint_t verbose);
140
141/**
142 * Search for the pattern P in the string T.
143 * @param T[0..Tsize-1] The input string.
144 * @param Tsize The length of the given string.
145 * @param P[0..Psize-1] The input pattern string.
146 * @param Psize The length of the given pattern string.
147 * @param SA[0..SAsize-1] The input suffix array.
148 * @param SAsize The length of the given suffix array.
149 * @param idx The output index.
150 * @return The count of matches if no error occurred, -1 otherwise.
151 */
152DIVSUFSORT_API
153saidx@W64BIT@_t
154sa_search@W64BIT@(const sauchar_t *T, saidx@W64BIT@_t Tsize,
155          const sauchar_t *P, saidx@W64BIT@_t Psize,
156          const saidx@W64BIT@_t *SA, saidx@W64BIT@_t SAsize,
157          saidx@W64BIT@_t *left);
158
159/**
160 * Search for the character c in the string T.
161 * @param T[0..Tsize-1] The input string.
162 * @param Tsize The length of the given string.
163 * @param SA[0..SAsize-1] The input suffix array.
164 * @param SAsize The length of the given suffix array.
165 * @param c The input character.
166 * @param idx The output index.
167 * @return The count of matches if no error occurred, -1 otherwise.
168 */
169DIVSUFSORT_API
170saidx@W64BIT@_t
171sa_simplesearch@W64BIT@(const sauchar_t *T, saidx@W64BIT@_t Tsize,
172                const saidx@W64BIT@_t *SA, saidx@W64BIT@_t SAsize,
173                saint_t c, saidx@W64BIT@_t *left);
174
175
176#ifdef __cplusplus
177} /* extern "C" */
178#endif /* __cplusplus */
179
180#endif /* _DIVSUFSORT@W64BIT@_H */
181