86728d203f7108352fbfa5efb3bf161dd11916d6
[deliverable/linux.git] / drivers / staging / wilc1000 / wilc_strutils.h
1 #ifndef __WILC_STRUTILS_H__
2 #define __WILC_STRUTILS_H__
3
4 /*!
5 * @file wilc_strutils.h
6 * @brief Basic string utilities
7 * @author syounan
8 * @sa wilc_oswrapper.h top level OS wrapper file
9 * @date 16 Aug 2010
10 * @version 1.0
11 */
12
13 #include <linux/types.h>
14 #include <linux/string.h>
15 #include "wilc_errorsupport.h"
16
17
18 /*!
19 * @brief Internal implementation for memory copy
20 * @param[in] pvTarget the target buffer to which the data is copied into
21 * @param[in] pvSource pointer to the second memory location
22 * @param[in] u32Count the size of the data to copy
23 * @note this function should not be used directly, use WILC_memcpy instead
24 * @author syounan
25 * @date 18 Aug 2010
26 * @version 1.0
27 */
28 void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, u32 u32Count);
29
30 /*!
31 * @brief Copies the contents of a memory buffer into another
32 * @param[in] pvTarget the target buffer to which the data is copied into
33 * @param[in] pvSource pointer to the second memory location
34 * @param[in] u32Count the size of the data to copy
35 * @return WILC_SUCCESS if copy is successfully handeled
36 * WILC_FAIL if copy failed
37 * @note this function repeats the functionality of standard memcpy,
38 * however memcpy is undefined if the two buffers overlap but this
39 * implementation will check for overlap and report error
40 * @author syounan
41 * @date 18 Aug 2010
42 * @version 1.0
43 */
44 static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, u32 u32Count)
45 {
46 if (
47 (((u8 *)pvTarget <= (u8 *)pvSource)
48 && (((u8 *)pvTarget + u32Count) > (u8 *)pvSource))
49
50 || (((u8 *)pvSource <= (u8 *)pvTarget)
51 && (((u8 *)pvSource + u32Count) > (u8 *)pvTarget))
52 ) {
53 /* ovelapped memory, return Error */
54 return WILC_FAIL;
55 } else {
56 WILC_memcpy_INTERNAL(pvTarget, pvSource, u32Count);
57 return WILC_SUCCESS;
58 }
59 }
60
61
62
63 /*!
64 * @brief Compares two strings up to u32Count characters
65 * @details Compares 2 strings reporting which is bigger, NULL is considered
66 * the smallest string, then a zero length string then all other
67 * strings depending on thier ascii characters order with small case
68 * converted to uppder case
69 * @param[in] pcStr1 the first string, NULL is valid and considered smaller
70 * than any other non-NULL string (incliding zero lenght strings)
71 * @param[in] pcStr2 the second string, NULL is valid and considered smaller
72 * than any other non-NULL string (incliding zero lenght strings)
73 * @param[in] u32Count copying will proceed until a null character in pcStr1 or
74 * pcStr2 is encountered or u32Count of bytes copied
75 * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2,
76 * -1 if pcStr1 smaller than pcStr2
77 * @author aabozaeid
78 * @date 7 Dec 2010
79 * @version 1.0
80 */
81 s32 WILC_strncmp(const char *pcStr1, const char *pcStr2,
82 u32 u32Count);
83
84
85 #endif
This page took 0.032884 seconds and 4 git commands to generate.