home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 32 / hot34.iso / ficheros / NINET / ALML303D.ZIP / EXAMPLES / DUMPMAIL.C next >
C/C++ Source or Header  |  1996-06-18  |  772b  |  41 lines

  1. /* Program:            DUMPMAIL                                            */
  2. /* Author:            Brian Dorricott                                        */
  3. /* Date:            11th January 1996                                    */
  4. /* Copyright:        (C)opyright 1996, Internet Shopper Ltd                */
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <winsock.h>
  9. #include <windows.h>
  10.  
  11.  
  12. #define MAX_LINE            16384
  13.  
  14. main(int argc, char *argv[])
  15. {
  16.     FILE *f;
  17.     char line[MAX_LINE];
  18.     int  done = FALSE;
  19.  
  20.     if (argc == 2)
  21.     {
  22.         f = fopen(argv[1], "w");
  23.  
  24.         while (!done)
  25.         {
  26.             fgets(line, MAX_LINE, stdin);
  27.             while (*(line+strlen(line)-1) == '\r' || *(line+strlen(line)-1) == '\n')
  28.                 *(line+strlen(line)-1) = '\0';
  29.  
  30.             if (strcmp(line, ".") == 0)
  31.                 done = TRUE;
  32.             if (f != NULL && !done)
  33.                 fprintf(f, "%s\n", line);
  34.         }
  35.         if (f != NULL)
  36.             fclose(f);
  37.     }
  38.         
  39.     return 0;
  40. }
  41.