MD_Sendfile.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include "MagiDoor.h"
  4. void md_sendfile(const char *filename, int pause) {
  5. FILE *fptr;
  6. char c, d;
  7. int lines = 0;
  8. char lastch = 'x';
  9. fptr = fopen(filename, "r");
  10. if (fptr != NULL) {
  11. c = fgetc(fptr);
  12. while (!feof(fptr) && c != 0x1a) {
  13. if (c == '\n') {
  14. lines++;
  15. if (lastch != '\r') {
  16. md_printf("\r\n");
  17. } else {
  18. md_printf("\n");
  19. }
  20. if (lines == 22 && pause == TRUE) {
  21. md_printf("More (Y/N)");
  22. d = md_getc();
  23. if (tolower(d) == 'n') {
  24. fclose(fptr);
  25. return;
  26. }
  27. md_printf("\r\n");
  28. lines = 0;
  29. }
  30. } else {
  31. md_putchar(c);
  32. }
  33. lastch = c;
  34. c = fgetc(fptr);
  35. }
  36. fclose(fptr);
  37. return;
  38. }
  39. return;
  40. }