* Replace __u32's with uint32_t.

This commit is contained in:
Justin Maggard 2011-03-02 22:23:36 +00:00
parent 107b808021
commit 36c1ae3948
3 changed files with 45 additions and 44 deletions

View File

@ -20,7 +20,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <linux/types.h> // Defines __u32
#include <sqlite3.h> #include <sqlite3.h>
#include "tivo_utils.h" #include "tivo_utils.h"
@ -85,20 +84,22 @@ decodeString(char * string, int inplace)
/* These next functions implement a repeatable random function with a user-provided seed */ /* These next functions implement a repeatable random function with a user-provided seed */
static int static int
seedRandomByte(__u32 seed) { seedRandomByte(uint32_t seed)
{
unsigned char t; unsigned char t;
if( !sqlite3Prng.isInit ) if( !sqlite3Prng.isInit )
{ {
int i; int i;
char k[256]; char k[256];
sqlite3Prng.j = 0; sqlite3Prng.j = 0;
sqlite3Prng.i = 0; sqlite3Prng.i = 0;
memset(&k, 0, 256); memset(&k, '\0', sizeof(k));
memcpy(&k, &seed, 4); memcpy(&k, &seed, 4);
for(i=0; i<256; i++){ for(i=0; i<256; i++)
sqlite3Prng.s[i] = i; sqlite3Prng.s[i] = i;
} for(i=0; i<256; i++)
for(i=0; i<256; i++){ {
sqlite3Prng.j += sqlite3Prng.s[i] + k[i]; sqlite3Prng.j += sqlite3Prng.s[i] + k[i];
t = sqlite3Prng.s[sqlite3Prng.j]; t = sqlite3Prng.s[sqlite3Prng.j];
sqlite3Prng.s[sqlite3Prng.j] = sqlite3Prng.s[i]; sqlite3Prng.s[sqlite3Prng.j] = sqlite3Prng.s[i];
@ -118,18 +119,19 @@ seedRandomByte(__u32 seed) {
} }
void void
seedRandomness(int N, void *pBuf, __u32 seed){ seedRandomness(int n, void *pbuf, uint32_t seed)
unsigned char *zBuf = pBuf; {
unsigned char *zbuf = pbuf;
while( N-- ){ while( n-- )
*(zBuf++) = seedRandomByte(seed); *(zbuf++) = seedRandomByte(seed);
}
} }
void void
TiVoRandomSeedFunc(sqlite3_context *context, int argc, sqlite3_value **argv) TiVoRandomSeedFunc(sqlite3_context *context, int argc, sqlite3_value **argv)
{ {
sqlite_int64 r, seed; sqlite_int64 r, seed;
if( argc != 1 || sqlite3_value_type(argv[0]) != SQLITE_INTEGER ) if( argc != 1 || sqlite3_value_type(argv[0]) != SQLITE_INTEGER )
return; return;
seed = sqlite3_value_int64(argv[0]); seed = sqlite3_value_int64(argv[0]);

View File

@ -91,4 +91,4 @@ struct album_art_name_s * album_art_names = NULL;
struct client_cache_s clients[CLIENT_CACHE_SLOTS]; struct client_cache_s clients[CLIENT_CACHE_SLOTS];
short int scanning = 0; short int scanning = 0;
volatile short int quitting = 0; volatile short int quitting = 0;
volatile __u32 updateID = 0; volatile uint32_t updateID = 0;

View File

@ -50,7 +50,6 @@
#define __UPNPGLOBALVARS_H__ #define __UPNPGLOBALVARS_H__
#include <time.h> #include <time.h>
#include <linux/types.h> // Defines __u32
#include "minidlnatypes.h" #include "minidlnatypes.h"
#include "config.h" #include "config.h"
@ -203,6 +202,6 @@ extern struct album_art_name_s * album_art_names;
extern struct client_cache_s clients[CLIENT_CACHE_SLOTS]; extern struct client_cache_s clients[CLIENT_CACHE_SLOTS];
extern short int scanning; extern short int scanning;
extern volatile short int quitting; extern volatile short int quitting;
extern volatile __u32 updateID; extern volatile uint32_t updateID;
#endif #endif