home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / network / src_1218.zip / SENDFAX.C < prev    next >
C/C++ Source or Header  |  1991-01-27  |  1KB  |  57 lines

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