Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / libcaptive / rtl / string.c
1 /* $Id$
2  * captive_reactos_str*() for reactos wrappers of libcaptive
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "reactos/ntos/rtl.h"   /* self */
23 #include <glib/gmessages.h>
24 #include <string.h>
25
26
27 /**
28  * captive_reactos_strchr:
29  * @s: 0-terminated string to search @c in.
30  * %NULL value is forbidden.
31  * @c: #guint8 byte to search for in @s.
32  *
33  * Simple wrapper around system strchr() to prevent possible declaration conflicts.
34  *
35  * Returns: Pointer to the found @c in @s or %NULL if not found.
36  */
37 char *captive_reactos_strchr(const char *s, int c)
38 {
39         g_return_val_if_fail(s!=NULL,NULL);
40
41         return strchr(s,c);
42 }
43
44
45 /**
46  * captive_reactos_strcmp:
47  * @s1: 0-terminated first string to compare.
48  * %NULL value is forbidden.
49  * @s2: 0-terminated second string to compare.
50  * %NULL value is forbidden.
51  *
52  * Simple wrapper around system strcmp() to prevent possible declaration conflicts.
53  *
54  * Returns: integer less than, equal to, or greater than zero if @s1 (or the
55  * first n bytes thereof) is found, respectively, to be less than, to match, or
56  * be greater than @s2.
57  */
58 int captive_reactos_strcmp(const char *s1, const char *s2)
59 {
60         g_return_val_if_fail(s1!=NULL,0);
61         g_return_val_if_fail(s2!=NULL,0);
62
63         return strcmp(s1,s2);
64 }
65
66
67 /**
68  * captive_reactos_strcpy:
69  * @to: Target memory to copy @from to.
70  * %NULL value is forbidden.
71  * @s2: 0-terminated string to copy to @to.
72  * %NULL value is forbidden.
73  *
74  * Simple wrapper around system strcpy() to prevent possible declaration conflicts.
75  *
76  * Returns: The same pointer @to as received.
77  */
78 char *captive_reactos_strcpy(char *to, const char *from)
79 {
80 char *r;
81
82         g_return_val_if_fail(to!=NULL,NULL);
83         g_return_val_if_fail(from!=NULL,NULL);
84
85         r=strcpy(to,from);
86         g_assert(r==to);
87
88         return r;
89 }
90
91
92 /**
93  * captive_reactos_strlen:
94  * @str: 0-terminated string to measure its length.
95  * %NULL value is forbidden.
96  *
97  * Simple wrapper around system strlen() to prevent possible declaration conflicts.
98  *
99  * Returns: Number of characters in @str.
100  */
101 size_t captive_reactos_strlen(const char *str)
102 {
103         g_return_val_if_fail(str!=NULL,0);
104
105         return strlen(str);
106 }