home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / comm / jmodem.zip / SHOW.C < prev    next >
Text File  |  1990-06-20  |  2KB  |  53 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*   This program shows that JMODEM will execute without crashing the       */
  4. /*   system from a DOS Shell executed from any properly written BBS         */
  5. /*   system or BBS window. This program allocates memory just like BBS      */
  6. /*   systems do, it writes to the memory, then spawns JMODEM as a sub-      */
  7. /*   process from a DOS Shell ( Microsoft C _system(); ). Then it returns   */
  8. /*   and the parent process again writes to memory. The program then exits  */
  9. /*   to DOS. There will ne NO errors and NO crashes.                        */
  10. /****************************************************************************/
  11.  
  12. #include <stdio.h>           /* for _puts()   */
  13. #include <stdlib.h>          /* for _system() */
  14. #if defined (TURBOC)
  15.     #include <alloc.h>
  16. #else
  17.     #include <malloc.h>          /* for _malloc() */
  18. #endif
  19.  
  20. void main(void);
  21.  
  22.  
  23. #define BYTES 32767
  24.  
  25. void main ()
  26. {
  27.     unsigned short i;
  28.     unsigned char *memory;
  29.  
  30.     memory = (unsigned char *) malloc(BYTES);  /*  Get some memory (a lot)  */
  31.     if (!memory)
  32.     {
  33.        puts ("Memory allocation failed!");
  34.        return;
  35.     }
  36.  
  37.     system ("CLS");
  38.     puts ("I am writing to memory I own ...");
  39.  
  40.     for (i = 0; i< BYTES; i++)
  41.         *memory++ = (unsigned char) i;        /* Write to the memory */
  42.  
  43.     puts ("Now I'll execute JMODEM ...");
  44.     puts ("Type CTRL-BRK to exit from JMODEM (it will take 5 seconds)....");
  45.     system("JMODEM S1 NUL");
  46.  
  47.     for (i = 0; i< BYTES; i++)
  48.         *(--memory) = (unsigned char) i;    /* Write to the memory again */
  49.  
  50.     puts ("\nAs you can see, the system did not crash ....");
  51.     free (memory);
  52. }
  53.