xref: /trunk/main/sal/inc/rtl/random.h (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _RTL_RANDOM_H_
29 #define _RTL_RANDOM_H_ "$Revision: 1.7 $"
30 
31 #include <sal/types.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*========================================================================
38  *
39  * rtlRandom interface.
40  *
41  *======================================================================*/
42 /** Random Pool opaque type.
43  */
44 typedef void* rtlRandomPool;
45 
46 
47 /** Error Code enumeration.
48  */
49 enum __rtl_RandomError
50 {
51 	rtl_Random_E_None,
52 	rtl_Random_E_Argument,
53 	rtl_Random_E_Memory,
54 	rtl_Random_E_Unknown,
55 	rtl_Random_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
56 };
57 
58 /** Error Code type.
59  */
60 typedef enum __rtl_RandomError rtlRandomError;
61 
62 
63 /** Create a Random Pool.
64 	@return initialized Random Pool, or NULL upon failure.
65  */
66 rtlRandomPool SAL_CALL rtl_random_createPool (void) SAL_THROW_EXTERN_C();
67 
68 
69 /** Destroy a Random Pool.
70 	@param  Pool [in] a Random Pool.
71 	@return none. Pool is invalid.
72  */
73 void SAL_CALL rtl_random_destroyPool (
74 	rtlRandomPool Pool
75 ) SAL_THROW_EXTERN_C();
76 
77 
78 /** Add bytes to a Random Pool.
79 	@param Pool    [in] a Random Pool.
80 	@param pBuffer [in] a buffer containing the bytes to add.
81 	@param nBufLen [in] the number of bytes to read from the buffer.
82 	@return rtl_Random_E_None upon success.
83  */
84 rtlRandomError SAL_CALL rtl_random_addBytes (
85 	rtlRandomPool  Pool,
86 	const void    *Buffer,
87 	sal_Size       Bytes
88 ) SAL_THROW_EXTERN_C();
89 
90 
91 /** Retrieve bytes from a Random Pool.
92 	@param Pool    [in] a Random Pool.
93 	@param pBuffer [inout] a buffer to receive the random bytes.
94 	@param nBufLen [in] the number of bytes to write to the buffer.
95 	@return rtl_Random_E_None upon success.
96  */
97 rtlRandomError SAL_CALL rtl_random_getBytes (
98 	rtlRandomPool  Pool,
99 	void          *Buffer,
100 	sal_Size       Bytes
101 ) SAL_THROW_EXTERN_C();
102 
103 /*========================================================================
104  *
105  * The End.
106  *
107  *======================================================================*/
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* _RTL_RANDOM_H_ */
114 
115