Commit 0bf396d6 authored by Warren Dukes's avatar Warren Dukes

some quick hacks to avoid signedness warnings with gcc4

git-svn-id: https://svn.musicpd.org/mpd/trunk@4387 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 7fdcd56a
......@@ -38,7 +38,7 @@ extern int command_listNum;
int processListOfCommands(FILE * fp, int * permission, int * expired,
int listOK, List * list);
int processCommand(FILE * fp, unsigned int * permission, char * commandString);
int processCommand(FILE * fp, int * permission, char * commandString);
void initCommands();
......
......@@ -93,7 +93,7 @@ static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char * path)
dc->state = DECODE_STATE_DECODE;
{
int ret, eof = 0, current = 0;
unsigned char chunk[CHUNK_SIZE];
char chunk[CHUNK_SIZE];
while(!eof) {
if(dc->seek) {
......
......@@ -68,7 +68,7 @@ typedef struct _Interface {
int fd; /* file descriptor */
FILE * fp; /* file pointer */
int open; /* open/used */
unsigned int permission;
int permission;
time_t lastTime;
List * commandList; /* for when in list mode */
int commandListOK; /* print OK after each command execution */
......@@ -116,7 +116,7 @@ static void openInterface(Interface * interface, int fd) {
#ifdef SO_SNDBUF
{
int getSize;
int sockOptLen = sizeof(int);
unsigned int sockOptLen = sizeof(int);
if(getsockopt(interface->fd,SOL_SOCKET,SO_SNDBUF,
(char *)&getSize,&sockOptLen) < 0)
......
......@@ -34,10 +34,10 @@
static List * permission_passwords;
static unsigned int permission_default;
static int permission_default;
static unsigned int parsePermissions(char * string) {
unsigned int permission = 0;
static int parsePermissions(char * string) {
int permission = 0;
char * temp;
char * tok;
......@@ -72,7 +72,7 @@ void initPermissions(void) {
char * temp;
char * cp2;
char * password;
unsigned int * permission;
int * permission;
ConfigParam * param;
permission_passwords = makeList(free, 1);
......@@ -104,7 +104,7 @@ void initPermissions(void) {
password = temp;
permission = malloc(sizeof(unsigned int));
permission = malloc(sizeof(int));
*permission = parsePermissions(strtok_r(NULL,"",&cp2));
insertInList(permission_passwords,password,permission);
......@@ -118,11 +118,11 @@ void initPermissions(void) {
sortList(permission_passwords);
}
int getPermissionFromPassword(char * password, unsigned int * permission) {
int getPermissionFromPassword(char * password, int * permission) {
void * foundPermission;
if(findInList(permission_passwords,password,&foundPermission)) {
*permission = *((unsigned int *)foundPermission);
*permission = *((int *)foundPermission);
return 0;
}
......@@ -133,6 +133,6 @@ void finishPermissions(void) {
freeList(permission_passwords);
}
unsigned int getDefaultPermissions(void) {
int getDefaultPermissions(void) {
return permission_default;
}
......@@ -28,10 +28,10 @@
void initPermissions();
int getPermissionFromPassword(char * password, unsigned int * permission);
int getPermissionFromPassword(char * password, int * permission);
void finishPermissions();
unsigned int getDefaultPermissions();
int getDefaultPermissions();
#endif
......@@ -347,13 +347,13 @@ MpdTag * apeDup(char * file) {
MpdTag * ret = NULL;
FILE * fp = NULL;
int tagCount;
unsigned char * buffer = NULL;
unsigned char * p;
char * buffer = NULL;
char * p;
int tagLen;
int size;
unsigned long flags;
int i;
unsigned char * key;
char * key;
struct {
unsigned char id[8];
......@@ -411,10 +411,10 @@ MpdTag * apeDup(char * file) {
tagCount = readLEuint32(footer.tagCount);
p = buffer;
while(tagCount-- && tagLen > 10) {
size = readLEuint32(p);
size = readLEuint32((unsigned char *)p);
p += 4;
tagLen -= 4;
flags = readLEuint32(p);
flags = readLEuint32((unsigned char *)p);
p += 4;
tagLen -= 4;
......
......@@ -22,30 +22,31 @@
#include <string.h>
#include <stdlib.h>
static unsigned char * latin1ToUtf8(unsigned char c) {
static char * latin1ToUtf8(char c) {
static unsigned char utf8[3];
unsigned char uc = c;
memset(utf8,0,3);
if(c < 128) utf8[0] = c;
else if(c<192) {
if(uc < 128) utf8[0] = uc;
else if(uc<192) {
utf8[0] = 194;
utf8[1] = c;
utf8[1] = uc;
}
else {
utf8[0] = 195;
utf8[1] = c-64;
utf8[1] = uc-64;
}
return utf8;
return (char *)utf8;
}
unsigned char * latin1StrToUtf8Dup(unsigned char * latin1) {
char * latin1StrToUtf8Dup(char * latin1) {
/* utf8 should have at most two char's per latin1 char */
int len = strlen(latin1)*2+1;
unsigned char * ret = malloc(len);
unsigned char * cp = ret;
unsigned char * utf8;
char * ret = malloc(len);
char * cp = ret;
char * utf8;
memset(ret,0,len);
......@@ -63,21 +64,24 @@ unsigned char * latin1StrToUtf8Dup(unsigned char * latin1) {
return realloc(ret,len+1);
}
static unsigned char utf8ToLatin1(unsigned char * utf8) {
static char utf8ToLatin1(char * inUtf8) {
unsigned char c = 0;
unsigned char * utf8 = (unsigned char *)inUtf8;
if(utf8[0]<128) return utf8[0];
else if(utf8[0]==195) c+=64;
else if(utf8[0]!=194) return '?';
return c+utf8[1];
return (char)(c+utf8[1]);
}
static int validateUtf8Char(unsigned char * utf8Char) {
static int validateUtf8Char(char * inUtf8Char) {
unsigned char * utf8Char = (unsigned char *)inUtf8Char;
if(utf8Char[0]<0x80) return 1;
if(utf8Char[0]>=0xC0 && utf8Char[0]<=0xFD) {
int count = 1;
unsigned char t = 1 << 5;
char t = 1 << 5;
int i;
while(count < 6 && (t & utf8Char[0])) {
t = (t >> 1);
......@@ -92,7 +96,7 @@ static int validateUtf8Char(unsigned char * utf8Char) {
else return 0;
}
int validUtf8String(unsigned char * string) {
int validUtf8String(char * string) {
int ret;
while(*string) {
......@@ -104,11 +108,11 @@ int validUtf8String(unsigned char * string) {
return 1;
}
unsigned char * utf8StrToLatin1Dup(unsigned char * utf8) {
char * utf8StrToLatin1Dup(char * utf8) {
/* utf8 should have at most two char's per latin1 char */
int len = strlen(utf8)+1;
unsigned char * ret = malloc(len);
unsigned char * cp = ret;
char * ret = malloc(len);
char * cp = ret;
int count;
memset(ret,0,len);
......
......@@ -19,10 +19,10 @@
#ifndef UTF_8_H
#define UTF_8_H
unsigned char * latin1StrToUtf8Dup(unsigned char * latin1);
char * latin1StrToUtf8Dup(char * latin1);
unsigned char * utf8StrToLatin1Dup(unsigned char * utf8);
char * utf8StrToLatin1Dup(char * utf8);
int validUtf8String(unsigned char * string);
int validUtf8String(char * string);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment