mmlib/mmat: replace some variables by literal constants
[mmondor.git] / mmsoftware / mmlib / mmstring.h
1 /* $Id: mmstring.h,v 1.18 2007/12/05 23:47:56 mmondor Exp $ */
2
3 /*
4 * Copyright (C) 1989-2004, Matthew Mondor
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Matthew Mondor.
18 * 4. The name of Matthew Mondor may not be used to endorse or promote
19 * products derived from this software without specific prior written
20 * permission.
21 * 5. Redistribution of source code may not be released under the terms of
22 * any GNU Public License derivate.
23 *
24 * THIS SOFTWARE IS PROVIDED BY MATTHEW MONDOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL MATTHEW MONDOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36
37 #ifndef MMSTRING_H
38 #define MMSTRING_H
39
40
41 #include <stdbool.h>
42 #include <stdint.h>
43
44
45 #ifndef MMSTRING_OBSOLETE
46 #include <string.h>
47 #define mm_memclr(a, l) (void) memset((a), 0, (l))
48 #endif
49
50 #ifdef MMSTRING_OBSOLETE
51
52 #define mm_memclr(a, l) (void) mm_memset((a), 0, (l))
53
54 extern size_t mm_strlen(const char *);
55
56 extern int mm_strcmp(const char *, const char *);
57 extern int mm_strncmp(const char *, const char *, size_t);
58 extern int mm_strcasecmp(const char *, const char *);
59 extern int mm_strncasecmp(const char *, const char *, size_t);
60
61 extern char * mm_strchr(const char *, int);
62 extern char * mm_strrchr(const char *, int);
63
64 /* To not conflict with libmm! */
65 extern char * _mm_strdup(const char *);
66 extern char * mm_strndup(const char *, size_t);
67
68 extern int mm_memcmp(const void *, const void *, size_t);
69 extern void * mm_memcpy(void *, const void *, size_t);
70 extern void * mm_memmove(void *, const void *, size_t);
71 extern void * mm_memset(void *, int, size_t);
72 /*extern void mm_memclr(void *, size_t);*/
73
74 #endif /* MMSTRING_OBSOLETE */
75
76 extern char * mm_strcat(char *, const char *);
77 extern char * mm_strncat(char *, const char *, size_t);
78 extern char * mm_strcpy(char *, const char *);
79 extern size_t mm_strncpy(char *, const char *, size_t);
80 extern char * mm_strnchr(const char *, int, size_t);
81 extern size_t mm_strnlen(const char *, size_t);
82 extern char * mm_strnrchr(const char *, int, size_t);
83 extern void mm_strlower(char *);
84 extern void mm_strupper(char *);
85
86 extern uint32_t mm_strpack32(const char *, size_t);
87 extern int mm_straspl(char **, char *, int);
88 extern int mm_strasplq(char **, char *, int);
89 extern bool mm_cmdparse(char **, int *, char **, char *, int);
90 extern int mm_strspl(char **, char *, int, char);
91
92 extern unsigned long mm_htol(const char *);
93 extern void mm_strrev(char *);
94 extern void mm_strrevto(char *, const char *);
95 extern uint64_t mm_strhash64(const char *);
96 extern uint64_t mm_memhash64(const void *, size_t);
97
98 extern uint32_t mm_memhash32(const void *, size_t);
99 extern uint32_t mm_memcasehash32(const void *, size_t);
100 extern int mm_memcasecmp(const void *, const void *, size_t);
101
102
103 #endif