diff --git a/debug.c b/debug.c index bd725d6..a00bdbe 100644 --- a/debug.c +++ b/debug.c @@ -747,8 +747,8 @@ void HexDump(unsigned char *buf, int len, int step) for(j=0; j= len) break; if((j&0x07) == 0x07) - PrintLog("%c ", isprint(buf[i+j]) ? buf[i+j] : '.'); - else PrintLog("%c", isprint(buf[i+j]) ? buf[i+j] : '.'); + PrintLog("%c ", canprint(buf[i+j]) ? buf[i+j] : '.'); + else PrintLog("%c", canprint(buf[i+j]) ? buf[i+j] : '.'); } PrintLog("\n"); diff --git a/dvdisaster.h b/dvdisaster.h index d6f2ab8..fc721fe 100644 --- a/dvdisaster.h +++ b/dvdisaster.h @@ -1089,6 +1089,7 @@ void CallMethodDestructors(void); *** misc.c ***/ +int canprint(char); char* sgettext(char*); char* sgettext_utf8(char*); diff --git a/large-io.c b/large-io.c index 38c41a4..01fbb02 100644 --- a/large-io.c +++ b/large-io.c @@ -36,6 +36,34 @@ * Also, individual behaviour may deviate from standard functions. */ +#ifdef SYS_MINGW + +#include + +#define stat _stati64 +#define lseek _lseeki64 + +/* The original windows ftruncate has off_size (32bit) */ + +int large_ftruncate(int fd, gint64 size) +{ gint32 handle; + + if((handle=_get_osfhandle(fd)) == -1) + return -1; + + if(_lseeki64(fd, size, SEEK_SET) == -1) + return -1; + + if(SetEndOfFile((HANDLE)handle) == 0) + return -1; + + return 0; +} + +#else + #define large_ftruncate ftruncate +#endif /* SYS_MINGW */ + /* * convert special chars in file names to correct OS encoding */ @@ -279,7 +307,7 @@ int LargeClose(LargeFile *lf) int LargeTruncate(LargeFile *lf, off_t length) { int result; - result = (ftruncate(lf->fileHandle, length) == 0); + result = (large_ftruncate(lf->fileHandle, length) == 0); if(result) lf->size = length; @@ -319,6 +347,19 @@ FILE *portable_fopen(char *path, char *modes) return file; } +#ifdef SYS_MINGW +int portable_mkdir(char *path) +{ int status; + char *cp_path; + + cp_path = os_path(path); + status = mkdir(cp_path); + g_free(cp_path); + + return status; +} +#endif + /*** *** Convenience functions ***/ diff --git a/misc.c b/misc.c index 4644ebe..6063584 100644 --- a/misc.c +++ b/misc.c @@ -22,6 +22,11 @@ #include "dvdisaster.h" +int canprint(char c) +{ + return ((isascii(c) && !iscntrl(c)) ? 1 : 0); +} + /*** *** gettext() convenience ***/ diff --git a/raw-editor.c b/raw-editor.c index d5a7bf0..e327ea0 100644 --- a/raw-editor.c +++ b/raw-editor.c @@ -623,7 +623,7 @@ static void render_sector(raw_editor_context *rec) gdk_gc_set_rgb_fg_color(Closure->drawGC,Closure->foreground); - sprintf(byte, "%c", isprint(buf[idx]) ? buf[idx] : '.'); + sprintf(byte, "%c", canprint(buf[idx]) ? buf[idx] : '.'); idx++; SetText(rec->layout, byte, &w, &h); gdk_draw_layout(d, Closure->drawGC, x, y, rec->layout); diff --git a/rs01-fix.c b/rs01-fix.c index 09f4b3e..31e609f 100644 --- a/rs01-fix.c +++ b/rs01-fix.c @@ -726,8 +726,8 @@ void RS01Fix(Image *image) PrintCLI(_("-> Error located in sector %lld at byte %4d (value %02x '%c', expected %02x '%c')\n"), block_idx[location], bi, - old, isprint(old) ? old : '.', - new, isprint(new) ? new : '.'); + old, canprint(old) ? old : '.', + new, canprint(new) ? new : '.'); } if(!erasure_map[location]) diff --git a/rs02-fix.c b/rs02-fix.c index 4de0fff..1097b3d 100644 --- a/rs02-fix.c +++ b/rs02-fix.c @@ -734,8 +734,8 @@ void RS02Fix(Image *image) PrintCLI(msg, sector, bi, - old, isprint(old) ? old : '.', - new, isprint(new) ? new : '.'); + old, canprint(old) ? old : '.', + new, canprint(new) ? new : '.'); } fc->imgBlock[location][offset] ^= gf_alpha_to[mod_fieldmax(gf_index_of[num1] + gf_index_of[num2] + GF_FIELDMAX - gf_index_of[den])]; diff --git a/rs03-fix.c b/rs03-fix.c index 7cca67e..acc0cb1 100644 --- a/rs03-fix.c +++ b/rs03-fix.c @@ -800,8 +800,8 @@ void RS03Fix(Image *image) PrintCLI(msg, sector, type, bi, - old, isprint(old) ? old : '.', - new, isprint(new) ? new : '.'); + old, canprint(old) ? old : '.', + new, canprint(new) ? new : '.'); } fc->imgBlock[location][offset] ^= gf_alpha_to[mod_fieldmax(gf_index_of[num1] + gf_index_of[num2] + GF_FIELDMAX - gf_index_of[den])]; diff --git a/scsi-layer.c b/scsi-layer.c index e706809..539f7d0 100644 --- a/scsi-layer.c +++ b/scsi-layer.c @@ -124,7 +124,7 @@ int InquireDevice(DeviceHandle *dh, int probe_only) if(i>0 && !isspace((int)ibuf[i-1])) /* separate the version string */ ibuf[i++] = ' '; } - if( isprint(ab->buf[j]) /* eliminate multiple spaces and unprintables */ + if( canprint(ab->buf[j]) /* eliminate multiple spaces and unprintables */ && (!isspace(ab->buf[j]) || (i>0 && !isspace((int)ibuf[i-1])))) { vbuf[i] = ab->buf[j]; ibuf[i++] = ab->buf[j]; @@ -724,11 +724,11 @@ static int query_dvd(DeviceHandle *dh, int probe_only) Verbose("#DVD: physical info contains lead-in data\n"); for(j=0; j<6; j++) - dh->manuID[j] = isprint(buf[0x225+j]) ? buf[0x225+j] : ' '; + dh->manuID[j] = canprint(buf[0x225+j]) ? buf[0x225+j] : ' '; dh->manuID[6] = ' '; for(j=0; j<6; j++) - dh->manuID[j+7] = isprint(buf[0x22d+j]) ? buf[0x22d+j] : ' '; + dh->manuID[j+7] = canprint(buf[0x22d+j]) ? buf[0x22d+j] : ' '; dh->manuID[13] = 0; for(j=11; j>=0; j--) @@ -784,7 +784,7 @@ static int query_dvd(DeviceHandle *dh, int probe_only) Verbose("#DVD: assuming DVD plus; phy_info4/6 now 0x%x 0x%x\n", phy_info4, phy_info6); for(i=0; i<11; i++) - dh->manuID[i] = isprint(buf[23+i]) ? buf[23+i] : ' '; + dh->manuID[i] = canprint(buf[23+i]) ? buf[23+i] : ' '; dh->manuID[11] = 0; for(i=10; i>=0; i--) @@ -828,11 +828,11 @@ static int query_dvd(DeviceHandle *dh, int probe_only) Verbose("#DVD: assuming DVD dash\n"); for(i=0; i<6; i++) - dh->manuID[i] = isprint(buf[21+i]) ? buf[21+i] : ' '; + dh->manuID[i] = canprint(buf[21+i]) ? buf[21+i] : ' '; dh->manuID[6] = ' '; for(i=0; i<6; i++) - dh->manuID[i+7] = isprint(buf[29+i]) ? buf[29+i] : ' '; + dh->manuID[i+7] = canprint(buf[29+i]) ? buf[29+i] : ' '; dh->manuID[13] = 0; for(i=11; i>=0; i--) @@ -1010,7 +1010,7 @@ static int query_bd(DeviceHandle *dh, int probe_only) for(i=0,j=-1; i<6; i++) /* Disc Manufacturer ID */ { char c = buf[4+100+i]; - if(isprint(c)) + if(canprint(c)) { dh->manuID[i] = c; j=i; } else dh->manuID[i] = ' '; @@ -1019,7 +1019,7 @@ static int query_bd(DeviceHandle *dh, int probe_only) for(i=0; i<3; i++) /* Media type ID */ { char c = buf[4+106+i]; - dh->manuID[++j] = isprint(c) ? c : ' '; + dh->manuID[++j] = canprint(c) ? c : ' '; } if(dh->manuID[j] == ',') dh->manuID[j]=0;