Branch libreoffice-5-0-4
[LibreOffice.git] / include / rtl / random.h
blobe606caed0df4315c5539a15b2e6732bb1190dc21
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_RTL_RANDOM_H
21 #define INCLUDED_RTL_RANDOM_H
23 #include <sal/config.h>
25 #include <sal/saldllapi.h>
26 #include <sal/types.h>
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
32 /*========================================================================
34 * rtlRandom interface.
36 *======================================================================*/
37 /** Random Pool opaque type.
39 typedef void* rtlRandomPool;
42 /** Error Code enumeration.
44 enum __rtl_RandomError
46 rtl_Random_E_None,
47 rtl_Random_E_Argument,
48 rtl_Random_E_Memory,
49 rtl_Random_E_Unknown,
50 rtl_Random_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
53 /** Error Code type.
55 typedef enum __rtl_RandomError rtlRandomError;
58 /** Create a Random Pool.
59 @return initialized Random Pool, or NULL upon failure.
61 SAL_DLLPUBLIC rtlRandomPool SAL_CALL rtl_random_createPool (void) SAL_THROW_EXTERN_C();
64 /** Destroy a Random Pool.
65 @param Pool [in] a Random Pool.
66 @return none. Pool is invalid.
68 SAL_DLLPUBLIC void SAL_CALL rtl_random_destroyPool (
69 rtlRandomPool Pool
70 ) SAL_THROW_EXTERN_C();
73 /** Add bytes to a Random Pool.
74 @param[in] Pool a Random Pool.
75 @param[in] Buffer a buffer containing the bytes to add.
76 @param[in] Bytes the number of bytes to read from the buffer.
77 @return rtl_Random_E_None upon success.
79 SAL_DLLPUBLIC rtlRandomError SAL_CALL rtl_random_addBytes (
80 rtlRandomPool Pool,
81 const void *Buffer,
82 sal_Size Bytes
83 ) SAL_THROW_EXTERN_C();
86 /** Retrieve bytes from a Random Pool.
87 @param[in] Pool a Random Pool.
88 @param[in,out] Buffer a buffer to receive the random bytes.
89 @param[in] Bytes the number of bytes to write to the buffer.
90 @return rtl_Random_E_None upon success.
92 SAL_DLLPUBLIC rtlRandomError SAL_CALL rtl_random_getBytes (
93 rtlRandomPool Pool,
94 void *Buffer,
95 sal_Size Bytes
96 ) SAL_THROW_EXTERN_C();
98 /*========================================================================
100 * The End.
102 *======================================================================*/
104 #ifdef __cplusplus
106 #endif
108 #endif // INCLUDED_RTL_RANDOM_H
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */