mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 01:49:05 +00:00
build
cmake_modules
conf
debian
docs
dtd
freeswitch.xcodeproj
htdocs
libs
apr
atomic
build
docs
dso
file_io
helpers
images
include
locks
memory
misc
netware
apr.xdc
aprlib.def
charset.c
libprews.c
rand.c
start.c
unix
win32
mmap
network_io
passwd
poll
random
shmem
strings
support
tables
test
threadproc
time
user
.update
CHANGES
CMakeLists.txt
LICENSE
Makefile.in
NOTICE
NWGNUmakefile
README.dev
apr-config.in
apr.dsp
apr.dsw
apr.pc.in
apr.spec
build-outputs.mk
build.conf
buildconf
config.layout
configure.gnu
configure.in
emacs-mode
libapr.dsp
libapr.rc
libaprnw.mcp.zip
renames_pending
apr-util
curl
esl
iksemel
ilbc
js
libdingaling
libedit
libg722_1
libnatpmp
libsndfile
libteletone
miniupnpc
pcre
portaudio
sofia-sip
spandsp
speex
sqlite
srtp
stfu
tiff-3.8.2
udns
unimrcp
voipcodecs
win32
xmlrpc-c
yaml
patches
scripts
src
support-d
w32
CMakeLists.txt
Freeswitch.2005.unsupported.sln
Freeswitch.2008.express.sln
Freeswitch.2008.sln
INSTALL
Makefile.am
acinclude.m4
bootstrap.sh
configure.in
freeswitch.spec
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3733 d0543943-73ff-0310-b7d9-9358b9ac24b2
71 lines
1.7 KiB
C
71 lines
1.7 KiB
C
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership.
|
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
* (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#define APR_WANT_MEMFUNC
|
|
#include "apr_want.h"
|
|
#include "apr_general.h"
|
|
#include "apr_private.h"
|
|
|
|
#if APR_HAS_RANDOM
|
|
|
|
#include <nks/plat.h>
|
|
|
|
static int NXSeedRandomInternal( size_t width, void *seed )
|
|
{
|
|
static int init = 0;
|
|
int *s = (int *) seed;
|
|
union { int x; char y[4]; } u;
|
|
|
|
if (!init) {
|
|
srand(NXGetSystemTick());
|
|
init = 1;
|
|
}
|
|
|
|
if (width > 3)
|
|
{
|
|
do
|
|
{
|
|
*s++ = rand();
|
|
}
|
|
while ((width -= 4) > 3);
|
|
}
|
|
|
|
if (width > 0)
|
|
{
|
|
char *p = (char *) s;
|
|
|
|
u.x = rand();
|
|
|
|
while (width > 0)
|
|
*p++ = u.y[width--];
|
|
}
|
|
|
|
return APR_SUCCESS;
|
|
}
|
|
|
|
APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf,
|
|
apr_size_t length)
|
|
{
|
|
if (NXSeedRandom(length, buf) != 0) {
|
|
return NXSeedRandomInternal (length, buf);
|
|
}
|
|
return APR_SUCCESS;
|
|
}
|
|
|
|
|
|
|
|
#endif /* APR_HAS_RANDOM */
|