[9521] Let build map extractor at Mac OSX

Also restore build at Windows (Win32 not have unistd.h)

Win32 ad.exe binary updated but not expected any functional differences.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
imbecile 2010-03-05 06:45:59 +03:00 committed by VladimirMangos
parent eaf5934c99
commit 24540e4b03
5 changed files with 28 additions and 37 deletions

Binary file not shown.

View file

@ -22,7 +22,11 @@
#define _CRT_SECURE_NO_DEPRECATE
//#include <dirent.h>
#include <sys/stat.h>
//#include <unistd.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@ -30,6 +34,17 @@
#include "common.h"
#include <ctype.h>
unsigned int libmpq_lseek(mpq_archive* mpq_a, unsigned int pos)
{
#ifdef WIN32
return (unsigned int)_lseeki64(mpq_a->fd, pos, SEEK_SET);
#elif defined(__APPLE__)
return (unsigned int)lseek(mpq_a->fd, pos, SEEK_SET);
#else
return (unsigned int)lseek64(mpq_a->fd, pos, SEEK_SET);
#endif
}
/*
* This function decrypts a MPQ block.
*/
@ -396,11 +411,7 @@ int libmpq_read_hashtable(mpq_archive *mpq_a) {
/* Read the hash table into the buffer */
bytes = mpq_a->header->hashtablesize * sizeof(mpq_hash);
#ifdef WIN32
_lseeki64(mpq_a->fd, mpq_a->header->hashtablepos, SEEK_SET);
#else
lseek64(mpq_a->fd, mpq_a->header->hashtablepos, SEEK_SET);
#endif
libmpq_lseek(mpq_a, mpq_a->header->hashtablepos);
rb = _read(mpq_a->fd, mpq_a->hashtable, bytes);
if (rb != bytes) {
@ -455,11 +466,7 @@ int libmpq_read_blocktable(mpq_archive *mpq_a) {
bytes = mpq_a->header->blocktablesize * sizeof(mpq_block);
memset(mpq_a->blocktable, 0, mpq_a->header->blocktablesize * sizeof(mpq_block));
#ifdef WIN32
_lseeki64(mpq_a->fd, mpq_a->header->blocktablepos, SEEK_SET);
#else
lseek64(mpq_a->fd, mpq_a->header->blocktablepos, SEEK_SET);
#endif
libmpq_lseek(mpq_a, mpq_a->header->blocktablepos);
rb = _read(mpq_a->fd, mpq_a->blocktable, bytes);
if (rb != bytes) {
@ -519,12 +526,7 @@ int libmpq_file_read_block(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int blo
unsigned int nread;
if (mpq_f->mpq_b->filepos != mpq_a->filepos) {
#ifdef WIN32
_lseeki64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET);
#else
lseek64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET);
#endif
libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos);
}
/* Read block positions from begin of file. */
@ -569,12 +571,7 @@ int libmpq_file_read_block(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int blo
if (mpq_f->blockpos[0] != nread) {
/* Try once again to detect file seed and decrypt the blocks */
#ifdef WIN32
_lseeki64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET);
#else
lseek64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET);
#endif
libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos);
nread = _read(mpq_a->fd, mpq_f->blockpos, (mpq_f->nblocks + 1) * sizeof(int));
mpq_f->seed = libmpq_detect_fileseed(mpq_a, mpq_f->blockpos, nread);
@ -611,13 +608,7 @@ int libmpq_file_read_block(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int blo
/* Set file pointer, if necessary. */
if (mpq_a->filepos != readpos) {
#ifdef WIN32
mpq_a->filepos = _lseeki64(mpq_a->fd, readpos, SEEK_SET);
#else
mpq_a->filepos = lseek64(mpq_a->fd, readpos, SEEK_SET);
#endif
mpq_a->filepos = libmpq_lseek(mpq_a, readpos);
}
/* 15018F87 - Read all requested blocks. */

View file

@ -70,3 +70,5 @@ char *libmpq_conf_delete_char(char *buf, char *chars);
int libmpq_conf_get_array(FILE *fp, char *search_value, char ***filelist, int *entries);
int libmpq_free_listfile(char **filelist);
int libmpq_read_listfile(mpq_archive *mpq_a, FILE *fp);
unsigned int libmpq_lseek(mpq_archive* mpq_a, unsigned int pos);

View file

@ -76,12 +76,10 @@ int libmpq_archive_open(mpq_archive *mpq_a, unsigned char *mpq_filename) {
while (!ncnt) {
mpq_a->header->id = 0;
#ifdef WIN32
_lseeki64(mpq_a->fd, mpq_a->mpqpos, SEEK_SET);
#else
lseek64(mpq_a->fd, mpq_a->mpqpos, SEEK_SET);
#endif
rb = _read(mpq_a->fd, mpq_a->header, sizeof(mpq_header));
libmpq_lseek(mpq_a, mpq_a->mpqpos);
rb = _read(mpq_a->fd, mpq_a->header, sizeof(mpq_header));
/* if different number of bytes read, break the loop */
if (rb != sizeof(mpq_header)) {

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9520"
#define REVISION_NR "9521"
#endif // __REVISION_NR_H__