From 36429c35e1662f8dcbd58bb7149779a3603d1d58 Mon Sep 17 00:00:00 2001 From: Pavel Vymetálek Date: Tue, 19 Feb 2019 16:44:30 +0100 Subject: Všechny texty v angličtině, opravy warningů MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- sercp.c | 34 ++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 4178903..3163e3b 100644 --- a/Makefile +++ b/Makefile @@ -20,4 +20,4 @@ debug: $(PROJECT).c gcc $(PROJECT).c -o $(PROJECT) -Wall -pedantic -MP -MD -std=gnu11 -Werror=format-security -g -O0 clean: - rm -f $(PROJECT) $(PROJECT).d $(PROJECT).o + rm -f $(PROJECT) $(PROJECT).d $(PROJECT).o $(PROJECT).res $(PROJECT)*.d $(PROJECT)*.exe diff --git a/sercp.c b/sercp.c index 33edcc7..dfa2eaf 100644 --- a/sercp.c +++ b/sercp.c @@ -106,7 +106,7 @@ typedef struct { FILEINFO fileinfo; void usage(void) { - printf ("sercp %s (c)2018-2019 Pavel Vymetálek \n", _version); + printf ("sercp %s (c)2018-2019 Pavel Vymetalek \n", _version); printf ("serial copy for transfering file to/from ZX Spectrum 128 AY's RS232\n"); printf ("Uses 1109bytes of fileinfo - blocks sums, filename, etc.\n"); printf ("Usage:\nsercp [-v] [-h] -d /dev/serial [-b baud_rate] [-w time] [-r] \n"); @@ -355,7 +355,6 @@ uint32_t GetOverallLen(FILEINFO *p_fi) { void sercpRecv(void) { int recv_phase = 0; // 0 - fileinfo, 1 - blok 16kiB, 2 - posledni blok uint8_t block_index = 0; - int result; uint16_t len; uint16_t length = 0; uint16_t expected_len = 0; @@ -363,12 +362,16 @@ void sercpRecv(void) { // uint8_t expected_sum; uint32_t overall_length = 0; // celkova delka souboru uint32_t recv_length = 0; // zatim prijatych dat ze souboru +#ifndef __WIN32 + int result; int err; - unsigned long ulNumBytes; - +#endif FILEINFO *p_fileinfo = &fileinfo; unsigned char *p_buff = buff; tapout_fd = NULL; +#ifdef __WIN32 + unsigned long ulNumBytes; +#endif memset (p_fileinfo, 0, sizeof(fileinfo)); while (is_continue) { @@ -396,9 +399,9 @@ void sercpRecv(void) { if (length == sizeof(fileinfo)) { memcpy((unsigned char*) p_fileinfo, buff, sizeof(fileinfo)); if (CheckFileInfo(p_fileinfo) == 0) { - printf("Prijato fileinfo\n"); +// printf("Fileinfo received\n"); overall_length = GetOverallLen(p_fileinfo); - printf("Nazev souboru: \"%s\" pocet bloku:%d, delka souboru: %u\n", p_fileinfo->fi_name, p_fileinfo->fi_numblocks, overall_length); + printf("File: \"%s\" number of blocks:%d, length of file: %u\n", p_fileinfo->fi_name, p_fileinfo->fi_numblocks, overall_length); recv_phase++; // priste se uz prijimaji bloky block_index = 0; // zacina se prvnim blokem p_buff = buff; // buffer na zacatek @@ -406,17 +409,17 @@ void sercpRecv(void) { expected_len = p_fileinfo->fi_blocks[block_index].block_len; tapout_fd = fopen ((char*)p_fileinfo->fi_name, "wb"); if (tapout_fd == NULL) { - err = errno; #ifdef __WIN32 printf ("can't open output file"); exit (EXIT_FAILURE); #else + err = errno; error (1, err, "can't open output file"); #endif } } else { - printf("Fileinfo neni v cajku. Koncim...\n"); + printf("Fileinfo corrupted. End...\n"); break; } break; @@ -428,7 +431,8 @@ void sercpRecv(void) { len = read (serial_fd, p_buff, sizeof(fileinfo)); #endif - printf("Nejaky bordel. Koncim...\n"); + printf("Received unknown data. End...\n"); + exit (EXIT_FAILURE); break; } // } @@ -463,7 +467,7 @@ void sercpRecv(void) { expected_len = p_fileinfo->fi_blocks[block_index].block_len; } if (expected_len == 0 || block_index == 255) { - printf ("\nKonec prenosu\n"); + printf ("\nTransfer successful\n"); recv_phase++; is_continue = 0; break; @@ -485,7 +489,6 @@ void sercpRecv(void) { fflush (tapout_fd); fclose (tapout_fd); } - printf ("\n\nulozeno...\n"); } /************************************************************************/ @@ -494,7 +497,7 @@ void sercpSend(void) { char *bname, *basec; // pinter na kopii nazvu souboru - basename char *shortfilename; size_t fn_len; - unsigned int err, no, len; + unsigned int no, len; //err, struct stat st; FILEINFO *p_fileinfo = &fileinfo; unsigned char *p_buff = buff; @@ -504,12 +507,15 @@ void sercpSend(void) { uint32_t len_sent; uint16_t sent_size; uint32_t overall_sent; +#ifdef __WIN32 unsigned long ulNumBytes; +#endif + no = stat(sercp_file, &st); if (no != 0) { - err = errno; +// err = errno; // error(1, err, "can't stat input file"); printf ("can't stat input file\n"); exit (EXIT_FAILURE); @@ -517,7 +523,7 @@ void sercpSend(void) { tap_fd = fopen(sercp_file, "rb"); if (tap_fd == NULL) { - err = errno; +// err = errno; // error(1, err, "can't open input file"); printf ("can't open input file\n"); exit (EXIT_FAILURE); -- cgit