Skip to content

Commit

Permalink
Patched to compile (but not link!) on Windows with VS.NET 2005.
Browse files Browse the repository at this point in the history
 libfetch isn't ported, everything else builds.
  • Loading branch information
icculus committed Sep 25, 2007
1 parent 0b1c5cc commit 246c039
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 21 deletions.
8 changes: 4 additions & 4 deletions archive_tar.c
Expand Up @@ -129,7 +129,7 @@ static int64 MojoInput_gzip_read(MojoInput *io, void *buf, uint32 bufsize)
if (br > GZIP_READBUFSIZE)
br = GZIP_READBUFSIZE;

br = origio->read(origio, info->buffer, br);
br = origio->read(origio, info->buffer, (uint32) br);
if (br <= 0)
return -1;

Expand Down Expand Up @@ -338,7 +338,7 @@ static int64 MojoInput_bzip2_read(MojoInput *io, void *buf, uint32 bufsize)
if (br > BZIP2_READBUFSIZE)
br = BZIP2_READBUFSIZE;

br = origio->read(origio, info->buffer, br);
br = origio->read(origio, info->buffer, (uint32) br);
if (br <= 0)
return -1;

Expand Down Expand Up @@ -444,15 +444,15 @@ static int64 MojoInput_tar_read(MojoInput *io, void *buf, uint32 bufsize)
TARinput *input = (TARinput *) io->opaque;
int64 pos = io->tell(io);
if ((pos + bufsize) > input->fsize)
bufsize = input->fsize - pos;
bufsize = (uint32) (input->fsize - pos);
return input->ar->io->read(input->ar->io, buf, bufsize);
} // MojoInput_tar_read

static boolean MojoInput_tar_seek(MojoInput *io, uint64 pos)
{
TARinput *input = (TARinput *) io->opaque;
boolean retval = false;
if (pos < input->fsize)
if (pos < ((uint64) input->fsize))
retval = input->ar->io->seek(input->ar->io, input->offset + pos);
return retval;
} // MojoInput_tar_seek
Expand Down
4 changes: 2 additions & 2 deletions archive_zip.c
Expand Up @@ -79,8 +79,8 @@ static PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
PHYSFS_uint32 size, PHYSFS_uint32 count)
{
MojoInput *io = (MojoInput *) opaque;
uint32 rc = io->read(io, buffer, size * count);
return rc / size;
int64 rc = io->read(io, buffer, size * count);
return rc / size; // !!! FIXME: what if rc == -1?
}

static int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos)
Expand Down
6 changes: 3 additions & 3 deletions buildver.c
Expand Up @@ -28,15 +28,15 @@
#endif

#ifndef __VERSION__
#define __VERSION__ (Unknown compiler version)
#define __VERSION__ "(Unknown compiler version)"
#endif

#ifndef __DATE__
#define __DATE__ (Unknown build date)
#define __DATE__ "(Unknown build date)"
#endif

#ifndef __TIME__
#define __TIME__ (Unknown build time)
#define __TIME__ "(Unknown build time)"
#endif

#ifndef COMPILER
Expand Down
2 changes: 1 addition & 1 deletion checksum_crc32.c
Expand Up @@ -12,7 +12,7 @@ void MojoCrc32_append(MojoCrc32 *_crc, const uint8 *buf, uint32 len)
{
uint32 crc = (uint32) *_crc;

int n;
uint32 n;
for (n = 0; n < len; n++)
{
uint32 xorval = (uint32) ((crc ^ buf[n]) & 0xFF);
Expand Down
19 changes: 10 additions & 9 deletions gui_www.c
Expand Up @@ -25,11 +25,11 @@ CREATE_MOJOGUI_ENTRY_POINT(www)

// tapdance between things WinSock and BSD Sockets define differently...
#if PLATFORM_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <winsock.h>

typedef int socklen_t;

#define setprotoent(x) assert(x == 0)
#define sockErrno() WSAGetLastError()
#define wouldBlockError(err) (err == WSAEWOULDBLOCK)
#define intrError(err) (err == WSAEINTR)
Expand Down Expand Up @@ -204,7 +204,7 @@ static void unescapeUri(char *uri)

static int strAdd(char **ptr, size_t *len, size_t *alloc, const char *fmt, ...)
{
int bw = 0;
size_t bw = 0;
size_t avail = *alloc - *len;
va_list ap;
va_start(ap, fmt);
Expand Down Expand Up @@ -567,7 +567,7 @@ static SOCKET create_listen_socket(short portnum)
#if ((!defined _NDEBUG) && (!defined NDEBUG))
{
int on = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on));
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*) &on, sizeof (on));
}
#endif

Expand Down Expand Up @@ -978,6 +978,13 @@ static boolean MojoGui_www_insertmedia(const char *medianame)
char *htmltext = NULL;
char *text = NULL;
size_t len = 0, alloc = 0;
int i, rc;

const char *buttons[] = { "cancel", "ok" };
const char *locButtons[] = {
htmlescape(entry->_("Cancel")),
htmlescape(entry->_("OK")),
};

// !!! FIXME: better text.
char *title = entry->xstrdup(entry->_("Media change"));
Expand All @@ -987,12 +994,6 @@ static boolean MojoGui_www_insertmedia(const char *medianame)
htmltext = htmlescape(text);
free(text);

int i, rc;
const char *buttons[] = { "cancel", "ok" };
const char *locButtons[] = {
htmlescape(entry->_("Cancel")),
htmlescape(entry->_("OK")),
};
assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons));

rc = doPromptPage(title, htmltext, true, "insertmedia", buttons,
Expand Down
4 changes: 2 additions & 2 deletions lua_glue.c
Expand Up @@ -834,7 +834,7 @@ static int luahook_archive_enumnext(lua_State *L)
lua_newtable(L);
set_string(L, entinfo->filename, "filename");
set_string(L, entinfo->linkdest, "linkdest");
set_number(L, entinfo->filesize, "filesize");
set_number(L, (lua_Number) entinfo->filesize, "filesize");
set_string(L, typestr, "type");
} // else

Expand Down Expand Up @@ -1257,7 +1257,7 @@ static int luahook_gui_destination(lua_State *L)

if (lua_istable(L, 1))
{
int i;
size_t i;

reccount = lua_objlen(L, 1);
recommend = (char **) alloca(reccount * sizeof (char *));
Expand Down
13 changes: 13 additions & 0 deletions universal.h
Expand Up @@ -20,6 +20,19 @@
#include <assert.h>
#include <time.h> // !!! FIXME: maybe use this in platform layer?

// Windows system headers conflict with MojoSetup typedefs, so chop out
// all the massive and unnecessary dependencies that windows.h pulls in...
#if PLATFORM_WINDOWS
#define WIN32_LEAN_AND_MEAN 1
#endif

#if _MSC_VER
#include <malloc.h> // need this to get alloca() in MSVC.
// !!! FIXME: temporary solution.
#define snprintf _snprintf
#define strcasecmp(x,y) _stricmp(x,y)
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down

0 comments on commit 246c039

Please sign in to comment.