volpe@camelback.crd.ge.com (Christopher R Volpe) (02/21/91)
In article <1025@tfsg.UUCP>, mark@tfsg.UUCP (Mark Crafts) writes: |>Quick question: |> |>What's the best way to send binary files through E-mail (you know, with |>a "---cut here---" line) so that when "cut there", it can be saved to |>a file and executed (or unpacked then executed or whatever). Well, C doesn't have any built-in "mail binary file" operator, so we'll have to fudge it. It would probably be easier to use "system()" to invoke mail, although using "popen()" might be more efficient. #include <stdio.h> int main() { FILE *binfile,*textfile; int c; binfile=fopen("fname.bin","r"); textfile=fopen("fname.txt","w"); fprintf(textfile,"---cut here---\n"); while ((c=getc(binfile))!=EOF) { fprintf(textfile,"%#X ",c); } fclose(textfile); fclose(binfile); system("mail user@domain < fname.txt"); } |> |> Mark |> |>Please E-Mail, thanks I would have, but seeing how this is just so applicable to comp.lang.c, I thought I'd post it. ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com
espie@flamingo.Stanford.EDU (Marc Espie) (02/21/91)
In article <16968@crdgw1.crd.ge.com> volpe@camelback.crd.ge.com (Christopher R Volpe) writes: >In article <1025@tfsg.UUCP>, mark@tfsg.UUCP (Mark Crafts) writes: >|>Quick question: >|> >|>What's the best way to send binary files through E-mail (you know, with >|>a "---cut here---" line) so that when "cut there", it can be saved to >|>a file and executed (or unpacked then executed or whatever). > >Well, C doesn't have any built-in "mail binary file" operator, so we'll >have to fudge it. [much deleted] >I would have, but seeing how this is just so applicable to comp.lang.c, I >thought I'd post it. >================== >Chris Volpe >G.E. Corporate R&D >volpecr@crd.ge.com So what's wrong with uuencode/uudecode ? I don't know of any reasonable machine which doesn't support it (AMIGA/UNIX/PC/MAC). It does precisely what you want in a standard and reasonably efficient way... you may even build a better interface on top of it (like a filter which scans uuencoded message, pass them through, creating decoded files automatically. I have such a filter on a permanent basis in my terminal emulator setting... which does only support 7bits ascii.) (I know this does not precisely belong in comp.lang.c, except that folks were starting to spout code redesigning the wheel.) You can program what you want, but you will gain some time if you use the uuencoded files standard. Better still ! There's a good chance you can *use* code written by other people :-). -- Marc (espie@flamingo.stanford.edu) So many FORTRAN programmers, so little time...
meissner@osf.org (Michael Meissner) (02/21/91)
In article <1991Feb20.224539.23290@Neon.Stanford.EDU> espie@flamingo.Stanford.EDU (Marc Espie) writes: | So what's wrong with uuencode/uudecode ? The original uuencode/uudecode (ie, the one your UNIX vendor typically provides) does not work too well if sent through a PR1ME system, which strips trailing blanks from a line. I've also heard some of the characters used don't arrive intact if passed through an ASCII -> EBCDIC -> translation system, but I may be misremembering it.... Also, uuencode transmits more characters than atob/btoa (which come with the B news release), but those suffer from not being as universal as uuencode/uudecode. -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET?