home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / SENDFAX.C < prev    next >
C/C++ Source or Header  |  1994-04-17  |  1KB  |  56 lines

  1. /* Experimental FAX interface code
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include "global.h"
  5. #include "smtp.h"
  6.   
  7. /* Send a mail message by FAX using Gamma Link interface board and software */
  8. int
  9. sendfax(dfile,num)
  10. FILE *dfile;
  11. char *num;
  12. {
  13.     int c;
  14.     FILE *fp;
  15.     long id;
  16.     char tiffile[128];
  17.   
  18.     id = get_msgid();
  19.   
  20.     /* Put body of message in temporary file */
  21.     fp = fopen("fax.tmp","w");
  22.     while((c = getc(dfile)) != EOF){
  23.         putc(c,fp);
  24.     }
  25.     fclose(fp);
  26.     fclose(dfile);
  27.   
  28.     /* Convert message to TIF format and delete original */
  29.     sprintf(tiffile,"\\fax\\faxw fax.tmp %s\\f%ldp001.TIF","\\fax",id);
  30.     printf("system(%s)\n",tiffile);
  31.     system(tiffile);
  32.     unlink("fax.tmp");
  33.   
  34.     /* Now create the command file */
  35.     fp = fopen("fax.tmp","w");
  36.     printf("fax.tmp:\n");
  37.     fprintf(fp,"send %s\\f%ldp001.TIF\n","\\fax",id);
  38.     printf("send %s\\f%ldp001.TIF\n","\\fax",id);
  39.   
  40.     /* Note temporary 9 prefix for Centrex line */
  41.     fprintf(fp,"dial =3 9%s\n",num);
  42.     printf("dial =3 9%s\n",num);
  43.   
  44.     fprintf(fp,"exit\n");
  45.     printf("exit\n");
  46.     fclose(fp);
  47.   
  48.     /* and give it to gcl */
  49.     printf("system(%s)\n","\\fax\\gcl fax.tmp");
  50.     system("\\fax\\gcl fax.tmp");
  51.     unlink("fax.tmp");
  52.   
  53.     return 0;
  54. }
  55.   
  56.