--- hatari/tools/hmsa/hmsa.c 2019/04/09 08:52:24 1.1.1.6 +++ hatari/tools/hmsa/hmsa.c 2019/04/09 08:54:51 1.1.1.8 @@ -1,8 +1,8 @@ /* Hatari tool: MSA and ST disk image creator and converter - hmsa.c - This file is distributed under the GNU Public License, version 2 or at - your option any later version. Read the file gpl.txt for details. + This file is distributed under the GNU General Public License, version 2 + or at your option any later version. Read the file gpl.txt for details. */ #include @@ -40,6 +40,13 @@ static void print_prefix(LOGTYPE nType) fputs(sType, stdout); } +/* output newline if it's missing from text */ +static void do_newline(const char *text) +{ + if (text[strlen(text)-1] != '\n') + fputs("\n", stdout); +} + /** * Output Hatari log string. */ @@ -62,9 +69,7 @@ extern void Log_AlertDlg(LOGTYPE nType, va_start(argptr, psFormat); vfprintf(stdout, psFormat, argptr); va_end(argptr); - /* Add a new-line if necessary: */ - if (psFormat[strlen(psFormat)-1] != '\n') - fputs("\n", stdout); + do_newline(psFormat); } /** @@ -73,9 +78,29 @@ extern void Log_AlertDlg(LOGTYPE nType, int DlgAlert_Query(const char *text) { puts(text); + do_newline(text); return TRUE; } + +/** + * ../src/file.c requires zip.c, which calls IPF_FileNameIsIPF + * We create an empty function to replace it, as we don't use IPF here + * and don't want to compile with all the IPF related files. + * We do it also for STX. + */ +extern bool IPF_FileNameIsIPF(const char *pszFileName, bool bAllowGZ); /* function prototype */ +extern bool IPF_FileNameIsIPF(const char *pszFileName, bool bAllowGZ) +{ + return FALSE; +} +extern bool STX_FileNameIsSTX(const char *pszFileName, bool bAllowGZ); /* function prototype */ +extern bool STX_FileNameIsSTX(const char *pszFileName, bool bAllowGZ) +{ + return FALSE; +} + + /** * Create MSA or ST image of requested size. * return error string or NULL for success. @@ -124,8 +149,8 @@ based on the file name extension (.msa o If the given file doesn't exist and you give also a disk size\n\ (SS, DS, HD, ED), an empty disk of the given size will be created.\n\ \n\ -This software is distributed under the GNU Public License, version 2 or\n\ -at your option any later version. Please read the file gpl.txt for details.\n\ +This software is distributed under the GNU General Public License, version 2\n\ +or at your option any later version. Please read the file gpl.txt for details.\n\ \n", name); } @@ -141,6 +166,8 @@ int main(int argc, char *argv[]) unsigned char *diskbuf; const char *srcfile, *srcdot; char *dstfile, *dstdot; + int ImageType; + int drive; if(argc < 2 || argv[1][0] == '-') { usage(argv[0]); @@ -202,10 +229,12 @@ int main(int argc, char *argv[]) free(dstfile); return -1; } - + + drive = 0; /* drive is not used for ST/MSA/DIM, set it to 0 */ + if (isMsa) { /* Read the source disk image */ - diskbuf = MSA_ReadDisk(srcfile, &disksize); + diskbuf = MSA_ReadDisk(drive, srcfile, &disksize, &ImageType); if (!diskbuf || disksize < 512*8) { fprintf(stderr, "ERROR: could not read MSA disk %s!\n", srcfile); retval = -1; @@ -222,7 +251,7 @@ int main(int argc, char *argv[]) retval = -1; } else { printf("Converting %s to %s (%li Bytes).\n", srcfile, dstfile, disksize); - retval = MSA_WriteDisk(dstfile, diskbuf, disksize); + retval = MSA_WriteDisk(drive, dstfile, diskbuf, disksize); } }