* RE: uudecode?
@ 1999-01-31 23:52 Mark Newnham
1999-01-31 23:52 ` uudecode? $Bill Luebkert
0 siblings, 1 reply; 23+ messages in thread
From: Mark Newnham @ 1999-01-31 23:52 UTC (permalink / raw)
To: 'John Cooper'; +Cc: mh, gnu-win32
The problem appears to be with the uuencode portion, because a file
encoded on a different system will uudecode correctly with the source
supplied.
If you compare a file encoded with the source code, against the same
file encoded on a Unix system, although the files are the same size,
each line on the Unix encoded file starts with a 'M' (or possibly the
'M' is after the newline on the previous. This does not appear with the
source code version.
Also when an attempt is made to decode a file uuencoded with the source
code version on a Unix system, the error "No end line" appears.
Excuse me for not being able to offer a solution, but this information
might help those more capable than myself.....
Mark Newnham
Application Design Associates, Inc
6021 S.Syracuse Way #302
Englewood, CO 80111, USA
+1 303 779 8958
-----Original Message-----
From: John Cooper [SMTP:John.Cooper@citrix.com]
Sent: Tuesday, January 19, 1999 7:40 AM
To: mark@adacorp.com
Cc: 'John Cooper'; mh@mike.franken.de; gnu-win32@cygnus.com
Subject: Re: uudecode?
Bernard Dautrevaux <DAUTREVAUX@microprocess.com> writes:
> I'm not sure, but I'll bet that you have to sligthly change
the uudecode
> source code to ensure that the open of the output file is
done in binary
> mode : open(... O_BINARY) or fopen(..., "wb")). Your problem
is most surely
> this infamous text!=binary feature :-( of Losedows...
It already does this - is there a known problem with `fopen'?
Do I need to use
`open' instead?
4 lines matching "open" in buffer uudecode.c.
9: FILE *out, *in = fopen(fname, "rb");
11: fprintf(stderr,"Impossible to open %s\n",fname);
33: out = fopen(outname, "wb");
35: fprintf(stderr,"Impossible to open %s\n",outname);
1 line matching "open" in buffer uuencode.c.
10: if ((in = fopen(nom, "rb")) == NULL)
--- John
-
For help on using this list (especially unsubscribing), send a
message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 uudecode? Mark Newnham
@ 1999-01-31 23:52 ` $Bill Luebkert
0 siblings, 0 replies; 23+ messages in thread
From: $Bill Luebkert @ 1999-01-31 23:52 UTC (permalink / raw)
To: Mark Newnham; +Cc: 'John Cooper', gnu-win32
Mark Newnham wrote:
>
> The problem appears to be with the uuencode portion, because a file
> encoded on a different system will uudecode correctly with the source
> supplied.
>
> If you compare a file encoded with the source code, against the same
> file encoded on a Unix system, although the files are the same size,
> each line on the Unix encoded file starts with a 'M' (or possibly the
> 'M' is after the newline on the previous. This does not appear with the
> source code version.
This is due to a bug on this line:
outbuf[idx++] = ENC(ch); # ch is not active at this time
which I changed to:
outbuf[idx++] = ENC(n); # n is the number of chars read
I'll send my version to John.
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles http://www.wgn.net/~dbe/
/ ) /--< o // // Mailto:dbe@wgn.net V3: http://come.to/dbe
-/-' /___/_<_</_</_ http://www.freeyellow.com/members/dbecoll/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* RE: uudecode?
@ 1999-01-31 23:52 Lincoln, W. Terry
0 siblings, 0 replies; 23+ messages in thread
From: Lincoln, W. Terry @ 1999-01-31 23:52 UTC (permalink / raw)
To: John Cooper, 'gnu-win32 mail list'
[-- Attachment #1: Type: text/plain, Size: 2927 bytes --]
All,
The source code that was submitted uses an uninitialized variable and it
will generate garbage on some compilers.
See:
------------------------------------------------------cut here:
uuencode.c
#include <stdio.h>
#define ENC(c) ((c) ? ((c) & 077) + ' ': '`')
static int uuencode(char *nom) /* nom means 'name' in french :-) */
{
int ch, n, idx;
/* ^^
** Declaration */
register char *p;
char buf[80], outbuf[250];
FILE *in;
if ((in = fopen(nom, "rb")) == NULL)
return 1; /* please add some error checking/reporting */
printf("begin 0666 %s\n",nom);/* note: no attempt to fake any
permissions
*/
while ((n = fread(buf, 1, 45, in)) != 0) {
idx = 0;
outbuf[idx++] = ENC(ch);
/* ^^ first use.
Where is first initialization? */
for (p = buf; n > 0; n -= 3, p += 3) {
ch = *p >> 2;
ch = ENC(ch);
outbuf[idx++] = ch;
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
ch = ENC(ch);
outbuf[idx++] = ch;
ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
ch = ENC(ch);
outbuf[idx++] = ch;
ch = p[2] & 077;
ch = ENC(ch);
outbuf[idx++] = ch;
}
outbuf[idx++] = '\n';
outbuf[idx] = 0;
printf("%s", outbuf);
}
printf("%c\nend\n", ENC(0));
fclose(in);
return 0;
}
W. Terry Lincoln \ \ | | /
Senior Engineer \ _| |_
Ultimate Technology Corporation \ |_ _|
division of Tridex(NASDAQ/trdx) \ | |
WTerryLincoln@engineer.com \ / | | \
http://www.angelfile.com/ny/TerryLincoln \ | |
========================================== ~~~
Opinions expressed do not represent the management
of UTC.
-----Original Message-----
From: John Cooper [ mailto:John.Cooper@citrix.com ]
Sent: Wednesday, January 20, 1999 2:23 PM
To: root
Cc: John Cooper; gnu-win32
Subject: Re: uudecode?
----------------------------------------------------
root@jacob.remcomp.fr (root) writes:
> Let's stop this uuencode/decode discussion. Here are two small little
> programs in that old but powerful language we all know somehow.
This source simply doesn't work for me - it generates all sorts of
different
characters at the beginning of encoded lines, rather than the "M" that I
see
with most uuencoders.
I finally pulled over the sharutils-4.2 source, got that to build under
NT and
then carefully enabled (or disabled) the binary flag on the fopen calls.
It
now seems to work fine - without mucking with mounts or using bash (I
prefer
zsh).
Thanks for all the ideas...
--- John
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
[[ WARREN~1.VCF : 3851 in WARREN~1.VCF ]]
[-- Attachment #2: WARREN~1.VCF --]
[-- Type: text/vcard, Size: 744 bytes --]
BEGIN:VCARD
VERSION:2.1
N:Lincoln;Warren;;Mr.;
FN:Warren Terry Lincoln (E-mail)
ORG:UTC;Engineering
TITLE:Senior Engineer
TEL;WORK;VOICE:(716) 924-9500
TEL;HOME;VOICE:(716) 377-3959
TEL;CELL;VOICE:(716) 261-3959
TEL;CAR;VOICE:
TEL;WORK;FAX:(716) 924-1434
ADR;WORK:;Victor;100 Rawson Road;Victor;NY;14564-0000;United States of America
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Victor=0D=0A100 Rawson Road=0D=0AVictor, NY 14564-0000=0D=0AUnited States of=
America
ADR;HOME:;;100 Courtshire Lane;Penfield;NY;10526-2678;United States of America
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:100 Courtshire Lane=0D=0APenfield, NY 10526-2678=0D=0AUnited States of Ameri=
ca
EMAIL;PREF;MS:ULTIMATE/UTCPO/LincolnT
REV:19990121T133603Z
END:VCARD
^ permalink raw reply [flat|nested] 23+ messages in thread
* RE: uudecode?
@ 1999-01-31 23:52 Bernard Dautrevaux
1999-01-31 23:52 ` uudecode? John Cooper
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Dautrevaux @ 1999-01-31 23:52 UTC (permalink / raw)
To: 'John Cooper', mh; +Cc: gnu-win32
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1762 bytes --]
> -----Message d'origine-----
> De: John Cooper [SMTP:John.Cooper@citrix.com]
> Date: lundi 18 janvier 1999 11:33
> Ã: mh@mike.franken.de
> Cc: gnu-win32@cygnus.com
> Objet: Re: uudecode?
>
> mh@mike.franken.de (Michael Hirmke) writes:
>
> > >Can anyone point me to a reliable version of the command line
> > >uudecode.exe/uuencode.exe utilities for NT 4.0?
> >
> > Don't know, what you mean by reliable, but you can get the
> sharutils-4.2c
> > package, which contains uuencode/uudecode among other utilities
>
> These just don't work at all:
>
> $ cp c:/WINNT/NOTEPAD.EXE n.exe
> $ ./n.exe # works fine!
> $ uuencode n.exe n.exe > n.uu
> $ rm n.exe
> $ ls n.*
> n.uu
> $ uudecode n.uu
> $ ls n.*
> n.exe* n.uu
> $ ./n.exe
> zsh: exec format error: .\n.exe
> $
> $ ls -l n.exe
> -rwxrwxrwx 1 JCooper Domain_Users 594 Jan 18 10:37
> n.exe*
> $
>
> Any ideas what's wrong with it?
>
I'm not sure, but I'll bet that you have to sligthly change the
uudecode source code to ensure that the open of the output file is done
in binary mode : open(... O_BINARY) or fopen(..., "wb")). Your problem
is most surely this infamous text!=binary feature :-( of Losedows...
Regards,
Bernard
>
------------------------------------------------------------------------
------
Bernard Dautrevaux
Microprocess Ingéniérie
97 bis, rue de Colombes
92400 COURBEVOIE
FRANCE
Tel: +33 (0) 1 47 68 80 80
Fax: +33 (0) 1 47 88 97 85
e-mail: dautrevaux@microprocess.com
b.dautrevaux@usa.net
------------------------------------------------------------------------
------
>
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 uudecode? Bernard Dautrevaux
@ 1999-01-31 23:52 ` John Cooper
1999-01-31 23:52 ` uudecode? Anil K Ruia
1999-01-31 23:52 ` uudecode? Benjamin Riefenstahl
0 siblings, 2 replies; 23+ messages in thread
From: John Cooper @ 1999-01-31 23:52 UTC (permalink / raw)
To: Bernard Dautrevaux; +Cc: 'John Cooper', mh, gnu-win32
Bernard Dautrevaux <DAUTREVAUX@microprocess.com> writes:
> I'm not sure, but I'll bet that you have to sligthly change the uudecode
> source code to ensure that the open of the output file is done in binary
> mode : open(... O_BINARY) or fopen(..., "wb")). Your problem is most surely
> this infamous text!=binary feature :-( of Losedows...
It already does this - is there a known problem with `fopen'? Do I need to use
`open' instead?
4 lines matching "open" in buffer uudecode.c.
9: FILE *out, *in = fopen(fname, "rb");
11: fprintf(stderr,"Impossible to open %s\n",fname);
33: out = fopen(outname, "wb");
35: fprintf(stderr,"Impossible to open %s\n",outname);
1 line matching "open" in buffer uuencode.c.
10: if ((in = fopen(nom, "rb")) == NULL)
--- John
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? John Cooper
@ 1999-01-31 23:52 ` Anil K Ruia
1999-01-31 23:52 ` uudecode? Benjamin Riefenstahl
1 sibling, 0 replies; 23+ messages in thread
From: Anil K Ruia @ 1999-01-31 23:52 UTC (permalink / raw)
To: John Cooper; +Cc: Bernard Dautrevaux, mh, gnu-win32
I think uudecode should open its input in text rather than binary mode.
- Anil
> 4 lines matching "open" in buffer uudecode.c.
> 9: FILE *out, *in = fopen(fname, "rb");
> 11: fprintf(stderr,"Impossible to open %s\n",fname);
> 33: out = fopen(outname, "wb");
> 35: fprintf(stderr,"Impossible to open %s\n",outname);
>
> 1 line matching "open" in buffer uuencode.c.
> 10: if ((in = fopen(nom, "rb")) == NULL)
>
> --- John
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? Anil K Ruia
@ 1999-01-31 23:52 ` Benjamin Riefenstahl
1 sibling, 0 replies; 23+ messages in thread
From: Benjamin Riefenstahl @ 1999-01-31 23:52 UTC (permalink / raw)
To: gnu-win32
John Cooper wrote:
> 4 lines matching "open" in buffer uudecode.c.
> 9: FILE *out, *in = fopen(fname, "rb");
> 11: fprintf(stderr,"Impossible to open %s\n",fname);
The input of uudecode *is* text, isn't it. I think the read mode should
be "r".
======================================
Benjamin Riefenstahl (benny@crocodial.de)
Crocodial Communications EntwicklungsGmbH
Ruhrstr. 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* RE: uudecode?
@ 1999-01-31 23:52 Tom St Denis
0 siblings, 0 replies; 23+ messages in thread
From: Tom St Denis @ 1999-01-31 23:52 UTC (permalink / raw)
To: John Cooper, gnu-win32
>Can anyone point me to a reliable version of the command line
>uudecode.exe/uuencode.exe utilities for NT 4.0?
try
http://members.tripod.com/~tomstdenis/uuencode.com
http://members.tripod.com/~tomstdenis/uudecode.com
They are DOS .com binaries
Tom
+--------------------------------------------------------------------------+
| The coolest site for free home pages, email, chat, e-cards, movie info.. |
| http://www.goplay.com - it's time to Go Play! |
+--------------------------------------------------------------------------+
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
@ 1999-01-31 23:52 N8TM
0 siblings, 0 replies; 23+ messages in thread
From: N8TM @ 1999-01-31 23:52 UTC (permalink / raw)
To: John.Cooper, gnu-win32
In a message dated 1/15/99 4:56:50 PM Pacific Standard Time,
John.Cooper@citrix.com writes:
<< Can anyone point me to a reliable version of the command line
uudecode.exe/uuencode.exe utilities for NT 4.0? >>
Those are part of the gnu sharutils package, and they have worked fine for me
when built normally under cygwin. I have had some difficulties with more
complicated usage of sharutils, however.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
@ 1999-01-31 23:52 Earnie Boyd
0 siblings, 0 replies; 23+ messages in thread
From: Earnie Boyd @ 1999-01-31 23:52 UTC (permalink / raw)
To: John Cooper, root; +Cc: gnu-win32, john.cooper
---John Cooper <John.Cooper@citrix.com> wrote:
8<
> If nobody has a solution, I guess I'll try debugging it when I get
time.
Well, maybe.
>
> --- John
>
> $ cp c:/winnt/NOTEPAD.EXE n.exe
> $ ls -l n.exe
> -rwxrwxrwx 1 JCooper Domain_Users 45328 Jan 19 10:28
n.exe*
> $
> $ ./uuencode n.exe n.exe > n.uu
This is the AhHa!! Try `SET CYGWIN=binmode' before starting bash.
If this fixes the problem then the program needs to change the mode of
the stdout so that it is also binary. Note you probably should change
the stdin as well.
==
- \\||//
-------------------o0O0--Earnie--0O0o-------------------
-- earnie_boyd@yahoo.com --
-- http://www.freeyellow.com/members5/gw32/index.html --
----------------------ooo0O--O0ooo----------------------
PS: Newbie's, you should visit my page.
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* RE: uudecode?
@ 1999-01-31 23:52 Bernard Dautrevaux
0 siblings, 0 replies; 23+ messages in thread
From: Bernard Dautrevaux @ 1999-01-31 23:52 UTC (permalink / raw)
To: 'John Cooper', Bernard Dautrevaux; +Cc: mh, gnu-win32
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2239 bytes --]
> -----Message d'origine-----
> De: John Cooper [SMTP:John.Cooper@citrix.com]
> Date: mardi 19 janvier 1999 15:40
> Ã: Bernard Dautrevaux
> Cc: 'John Cooper'; mh@mike.franken.de; gnu-win32@cygnus.com
> Objet: Re: uudecode?
>
> Bernard Dautrevaux <DAUTREVAUX@microprocess.com> writes:
>
> > I'm not sure, but I'll bet that you have to sligthly change the
> uudecode
> > source code to ensure that the open of the output file is done in
> binary
> > mode : open(... O_BINARY) or fopen(..., "wb")). Your problem is
> most surely
> > this infamous text!=binary feature :-( of Losedows...
>
> It already does this - is there a known problem with `fopen'? Do I
> need to use
> `open' instead?
>
> 4 lines matching "open" in buffer uudecode.c.
> 9: FILE *out, *in = fopen(fname, "rb");
> 11: fprintf(stderr,"Impossible to open %s\n",fname);
> 33: out = fopen(outname, "wb");
> 35: fprintf(stderr,"Impossible to open %s\n",outname);
>
> 1 line matching "open" in buffer uuencode.c.
> 10: if ((in = fopen(nom, "rb")) == NULL)
>
>
Oh yes but all opens are done in binary mode.. What I imply is that
opens of binary files (input for uuencode and output for uudecode) must
use binary mode; however opens of text files (output of uuencode and
input of uudecode) should be in text mode, and anyway most surely the
output of uuencode is in text mode, as this is simply stdout, that all C
run-times assume (unless special settings in the environment or your
program) that stdin, stdout and stderr should be opened in text mode...
What properly happens is that at some point uudecode, which read text in
binary mode, get a raw ^M at end of line, and then either go wild or
just stop...
------------------------------------------------------------------------
------
Bernard Dautrevaux
Microprocess Ingéniérie
97 bis, rue de Colombes
92400 COURBEVOIE
FRANCE
Tel: +33 (0) 1 47 68 80 80
Fax: +33 (0) 1 47 88 97 85
e-mail: dautrevaux@microprocess.com
b.dautrevaux@usa.net
------------------------------------------------------------------------
------
>
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* uudecode?
@ 1999-01-31 23:52 John Cooper
1999-01-31 23:52 ` uudecode? Michael Hirmke
1999-01-31 23:52 ` uudecode? Corinna Vinschen
0 siblings, 2 replies; 23+ messages in thread
From: John Cooper @ 1999-01-31 23:52 UTC (permalink / raw)
To: gnu-win32
Can anyone point me to a reliable version of the command line
uudecode.exe/uuencode.exe utilities for NT 4.0?
Thanks,
--- John
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 uudecode? John Cooper
@ 1999-01-31 23:52 ` Michael Hirmke
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? Corinna Vinschen
1 sibling, 1 reply; 23+ messages in thread
From: Michael Hirmke @ 1999-01-31 23:52 UTC (permalink / raw)
To: gnu-win32
Hi John,
>
>Can anyone point me to a reliable version of the command line
>uudecode.exe/uuencode.exe utilities for NT 4.0?
Don't know, what you mean by reliable, but you can get the
sharutils-4.2c package, which contains uuencode/uudecode among other
utilities
- on ftp.franken.de
- in /pub/win32/develop/gnuwin32/cygwin32/porters/Hirmke_Michael/B20
- as sharutils-4.2c-cygwin-b20-bin.tar.gz
- or sharutils-4.2c-cygwin-b20-bin.zip
>
>Thanks,
>
> --- John
Bye.
Michael.
--
Michael Hirmke | Telefon +49 (911) 557999
Georg-Strobel-Strasse 81 | FAX +49 (911) 557664
90489 Nuernberg | E-Mail mailto:mh@mike.franken.de
| WWW http://aquarius.franken.de/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? Michael Hirmke
@ 1999-01-31 23:52 ` John Cooper
1999-01-31 23:52 ` uudecode? root
1999-01-31 23:52 ` uudecode? Glenn Spell
0 siblings, 2 replies; 23+ messages in thread
From: John Cooper @ 1999-01-31 23:52 UTC (permalink / raw)
To: Michael Hirmke; +Cc: gnu-win32
mh@mike.franken.de (Michael Hirmke) writes:
> >Can anyone point me to a reliable version of the command line
> >uudecode.exe/uuencode.exe utilities for NT 4.0?
>
> Don't know, what you mean by reliable, but you can get the sharutils-4.2c
> package, which contains uuencode/uudecode among other utilities
These just don't work at all:
$ cp c:/WINNT/NOTEPAD.EXE n.exe
$ ./n.exe # works fine!
$ uuencode n.exe n.exe > n.uu
$ rm n.exe
$ ls n.*
n.uu
$ uudecode n.uu
$ ls n.*
n.exe* n.uu
$ ./n.exe
zsh: exec format error: .\n.exe
$
$ ls -l n.exe
-rwxrwxrwx 1 JCooper Domain_Users 594 Jan 18 10:37 n.exe*
$
Any ideas what's wrong with it?
Thanks,
--- John
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? John Cooper
@ 1999-01-31 23:52 ` root
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? Glenn Spell
1 sibling, 2 replies; 23+ messages in thread
From: root @ 1999-01-31 23:52 UTC (permalink / raw)
To: John Cooper; +Cc: gnu-win32
Let's stop this uuencode/decode discussion.
Here are two small little programs in that old but powerful language we all
know somehow.
------------------------------------------------------cut here: uuencode.c
#include <stdio.h>
#define ENC(c) ((c) ? ((c) & 077) + ' ': '`')
static int uuencode(char *nom) /* nom means 'name' in french :-) */
{
int ch, n, idx;
register char *p;
char buf[80], outbuf[250];
FILE *in;
if ((in = fopen(nom, "rb")) == NULL)
return 1; /* please add some error checking/reporting */
printf("begin 0666 %s\n",nom);/* note: no attempt to fake any permissions */
while ((n = fread(buf, 1, 45, in)) != 0) {
idx = 0;
outbuf[idx++] = ENC(ch);
for (p = buf; n > 0; n -= 3, p += 3) {
ch = *p >> 2;
ch = ENC(ch);
outbuf[idx++] = ch;
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
ch = ENC(ch);
outbuf[idx++] = ch;
ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
ch = ENC(ch);
outbuf[idx++] = ch;
ch = p[2] & 077;
ch = ENC(ch);
outbuf[idx++] = ch;
}
outbuf[idx++] = '\n';
outbuf[idx] = 0;
printf("%s", outbuf);
}
printf("%c\nend\n", ENC(0));
fclose(in);
return 0;
}
int main(int argc, char *argv[]) // add error checking here if you feel like
{
return uuencode(argv[1]);
}
---------------------------------------------------cut here uudecode.c
#include <stdio.h>
#include <string.h>
#define DEC(c) (((c) - ' ') & 077)
static int uudecode(char *fname)
{
register int n;
register char ch, *p;
char buf[2 * BUFSIZ],outname[512];
FILE *out, *in = fopen(fname, "rb");
if (in == NULL) {
fprintf(stderr,"Impossible to open %s\n",fname);
return 1;
}
while (fgets(buf, 80, in)) {
if (!strncmp(buf, "begin", 5))
goto decodeStart;
}
fprintf(stderr,"No 'begin' line found in %s\n",fname);
return 1;
decodeStart:
p = buf + sizeof("begin");
while (*p == ' ' || *p == '\t')
p++;
while (*p >= '0' && *p <= '9') // ignore any permissions setting
p++;
while (*p == ' ' || *p == '\t')
p++;
strcpy(outname, p);
p = outname;
while (*p >= ' ') // This supposes file name chars are >= ' '
p++;
*p = 0;
out = fopen(outname, "wb");
if (out == NULL) {
fprintf(stderr,"Impossible to open %s\n",outname);
return 1;
}
while (1) {
if (!fgets(buf, 80, in))
break;
if (!strncmp(buf, "end\r\n", 5))
break;
p = buf;
n = DEC(*p);
if (n <= 0)
break;
for (++p; n > 0; p += 4, n -= 3) {
if (n >= 3) {
ch = DEC(p[0]) << 2 | DEC(p[1]) >> 4;
fputc(ch, out);
ch = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
fputc(ch, out);
ch = DEC(p[2]) << 6 | DEC(p[3]);
fputc(ch, out);
}
else {
if (n >= 1) {
ch = DEC(p[0]) << 2 | DEC(p[1]) >> 4;
fputc(ch, out);
}
if (n >= 2) {
ch = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
fputc(ch, out);
}
}
}
}
fclose(out);
fclose(in);
return 0;
}
int main(int argc, char *argv[]) // Add error checking here if you feel like
{
return uudecode(argv[1]);
}
---------------------------------------------------------------------------
enjoy!
--
Jacob Navia Logiciels/Informatique
41 rue Maurice Ravel Tel 01 48.23.51.44
93430 Villetaneuse Fax 01 48.23.95.39
France
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? root
@ 1999-01-31 23:52 ` John Cooper
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? John Cooper
1 sibling, 1 reply; 23+ messages in thread
From: John Cooper @ 1999-01-31 23:52 UTC (permalink / raw)
To: root; +Cc: gnu-win32, john.cooper
root@jacob.remcomp.fr (root) writes:
> Let's stop this uuencode/decode discussion. Here are two small little
> programs in that old but powerful language we all know somehow.
These also don't work (see below).
This doesn't look like a "mount" problem? The cygwin FAQ states about mount:
"The '-b' option to mount mounts the mountpoint in binary mode where text and
binary files are treated equivalently. This should only be necessary for badly
ported Unix programs where binary flags are missing from open calls."
... and your code does open the files in binary mode, so shouldn't it work
regardless of mount?
It even seems to fail when I do mount a directory in binary mode...
If nobody has a solution, I guess I'll try debugging it when I get time.
--- John
$ cp c:/winnt/NOTEPAD.EXE n.exe
$ ls -l n.exe
-rwxrwxrwx 1 JCooper Domain_Users 45328 Jan 19 10:28 n.exe*
$
$ ./uuencode n.exe n.exe > n.uu
$ ls -l n.uu
-rw-rw-rw- 1 JCooper Domain_Users 62479 Jan 19 10:28 n.uu
$
$ ./uudecode n.uu
$ ls -l n.exe
-rwxrwxrwx 1 JCooper Domain_Users 261 Jan 19 10:28 n.exe*
$
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? John Cooper
@ 1999-01-31 23:52 ` John Cooper
0 siblings, 0 replies; 23+ messages in thread
From: John Cooper @ 1999-01-31 23:52 UTC (permalink / raw)
To: John Cooper; +Cc: root, gnu-win32, john.cooper
"John Cooper" <John.Cooper@citrix.com> writes:
> These also don't work (see below).
Oddly, if I use the combination of the sharutils uuencode.exe and the
uudecode.exe that I compiled from the source posted here, it works.
Other combinations don't seem to work...
I've also hacked the uudecode source to read from stdin when given no args, so
I can use uudecode.exe with Emacs' call-process-region. At last uuencoded
attachments from Outlook can be quickly decoded from pGnus!
--- John
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? root
1999-01-31 23:52 ` uudecode? John Cooper
@ 1999-01-31 23:52 ` John Cooper
1999-01-31 23:52 ` uudecode? Pierre A. Humblet
1 sibling, 1 reply; 23+ messages in thread
From: John Cooper @ 1999-01-31 23:52 UTC (permalink / raw)
To: root; +Cc: John Cooper, gnu-win32
root@jacob.remcomp.fr (root) writes:
> Let's stop this uuencode/decode discussion. Here are two small little
> programs in that old but powerful language we all know somehow.
This source simply doesn't work for me - it generates all sorts of different
characters at the beginning of encoded lines, rather than the "M" that I see
with most uuencoders.
I finally pulled over the sharutils-4.2 source, got that to build under NT and
then carefully enabled (or disabled) the binary flag on the fopen calls. It
now seems to work fine - without mucking with mounts or using bash (I prefer
zsh).
Thanks for all the ideas...
--- John
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? John Cooper
@ 1999-01-31 23:52 ` Pierre A. Humblet
0 siblings, 0 replies; 23+ messages in thread
From: Pierre A. Humblet @ 1999-01-31 23:52 UTC (permalink / raw)
To: John Cooper, root; +Cc: John Cooper, gnu-win32
This has taken enough bandwidth that we might at least understand what
happened.
As stated in their README, the shareutils from ftp.franken.de require
binary mount. On a text mounted system the uuencode INPUT file gets
truncated at ^Z.
Ideally uuencode should binary open its input file AND setmode stdin to
binary (for use with cygwin shells, other shells always open stdin binary).
Similarly the output of uudecode should be binary.
It doesn't matter if the output of uuencode and the input of uudecode are
text or binary. Those programs encode the line length, usually taking in 45
characters at a time (they have to, to survive inclusion in e-mails).
uuencoded lines start with M because M is the 45th printable character
(above " "). Those 45 characters are expanded to 45 * 8/6 = 60 characters
per line, plus the length.
The uuencode.c program contributed in
http://www.cygnus.com/ml/gnu-win32/1999-Jan/0493.html has a bug: the first
ENC(ch) should have been ENC(n). That's why the uuencoded lines did not
start with M.
There is also a bug in uudecode.c
if (!strncmp(buf, "end\r\n", 5))
will fail when the file ends with "end\n". The bug is not exposed because
the program normally terminates at the next to last line, which has zero
length.
Pierre
At 02:22 PM 1/20/99 +0000, John Cooper wrote:
>I finally pulled over the sharutils-4.2 source, got that to build under NT
and
>then carefully enabled (or disabled) the binary flag on the fopen calls. It
>now seems to work fine - without mucking with mounts or using bash (I prefer
>zsh).
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? root
@ 1999-01-31 23:52 ` Glenn Spell
1 sibling, 0 replies; 23+ messages in thread
From: Glenn Spell @ 1999-01-31 23:52 UTC (permalink / raw)
To: gnu-win32
John Cooper wrote:
>
> mh@mike.franken.de (Michael Hirmke) writes:
>
> > >Can anyone point me to a reliable version of the command line
> > >uudecode.exe/uuencode.exe utilities for NT 4.0?
> >
> > Don't know, what you mean by reliable, but you can get the sharutils-4.2c
> > package, which contains uuencode/uudecode among other utilities
>
> These just don't work at all:
For decode only, you might try uu.com from:
< http://www.walbeehm.com/mrcode.html >.
(That was: http://www.walbeehm.com/mrcode.html ).
-glenn
--
Glenn Spell <glenn@gs.fay.nc.us>
Fayetteville, North Carolina, U. S. A.
____________________________________________________
... blue skies ... happy trails ... sweet dreams ...
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1999-01-31 23:52 uudecode? John Cooper
1999-01-31 23:52 ` uudecode? Michael Hirmke
@ 1999-01-31 23:52 ` Corinna Vinschen
1 sibling, 0 replies; 23+ messages in thread
From: Corinna Vinschen @ 1999-01-31 23:52 UTC (permalink / raw)
To: John Cooper, gnu-win32
John Cooper wrote:
>
> Can anyone point me to a reliable version of the command line
> uudecode.exe/uuencode.exe utilities for NT 4.0?
Try sharutils-4.2 from http://www.gnu.org/software/software.html
It compiles out of the box.
Corinna
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* uudecode?
@ 1997-09-09 23:33 John Cooper
1997-09-10 10:28 ` uudecode? root
0 siblings, 1 reply; 23+ messages in thread
From: John Cooper @ 1997-09-09 23:33 UTC (permalink / raw)
To: GNU-Win32
Can anyone point me to an NT version of the unix "uudecode" program?
Thanks,
--- John
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: uudecode?
1997-09-09 23:33 uudecode? John Cooper
@ 1997-09-10 10:28 ` root
0 siblings, 0 replies; 23+ messages in thread
From: root @ 1997-09-10 10:28 UTC (permalink / raw)
To: john.cooper; +Cc: gnu-win32
To satisfy popular demand, here is uudecode:
------------------------------------------------------------cut here
#include <stdio.h>
#include <string.h>
#define DEC(c) (((c) - ' ') & 077)
static char outname[200];
int ReadDataLine(FILE *f,char *buf)
{
int c,i;
i=0;
while ((c=fgetc(f)) != EOF) {
if (c == '\n') break;
if (c != '\r') {
buf[i++] = c;
}
}
buf[i] = 0;
return(c == EOF ? 0 : 1);
}
static char *uudecode (FILE *f)
{
register int n;
register char ch, *p;
char buf[2 * BUFSIZ];
FILE *out;
do {
if (!ReadDataLine(f,buf)) return(NULL);
}
while (strncmp(buf,"begin",5));
p = buf + 6;
while (*p && (*p == ' '|| *p == '0' || *p == '6')) p++;
strcpy(outname,p);
/* Create output file and set mode. */
out = fopen(outname,"wb");
/* For each input line: */
while (1)
{
if (!ReadDataLine(f,buf)) break;
if (!strncmp(buf,"end\r\n",5)) break;
p = buf;
/* N is used to avoid writing out all the characters at the end of
the file. */
n = DEC (*p);
if (n <= 0)
break;
for (++p; n > 0; p += 4, n -= 3)
{
if (n >= 3)
{
ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
fputc(ch,out);
ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
fputc (ch,out);
ch = DEC (p[2]) << 6 | DEC (p[3]);
fputc (ch,out);
}
else
{
if (n >= 1)
{
ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
fputc (ch,out);
}
if (n >= 2)
{
ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
fputc (ch,out);
}
}
}
}
fclose(out);
return outname;
}
int main(int argc,char *argv[])
{
FILE *f;
if (argc <= 1) {
printf("Usage: %s <input file>\n",argv[0]);
return(1);
}
f = fopen(argv[1],"rb");
if (f == NULL) {
printf("Impossible to open %s\n",argv[1]);
return(1);
}
uudecode(f);
fclose(f);
printf("Result decoded into %s\n",outname);
return(0);
}
----------------------------------------------------------------cut here
--
Jacob Navia Logiciels/Informatique
41 rue Maurice Ravel Tel 01 48.23.51.44
93430 Villetaneuse Fax 01 48.23.95.39
France
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 23+ messages in thread
[parent not found: <root@jacob.remcomp.fr's>]
end of thread, other threads:[~1999-01-31 23:52 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-31 23:52 uudecode? Mark Newnham
1999-01-31 23:52 ` uudecode? $Bill Luebkert
-- strict thread matches above, loose matches on Subject: below --
1999-01-31 23:52 uudecode? Lincoln, W. Terry
1999-01-31 23:52 uudecode? Bernard Dautrevaux
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? Anil K Ruia
1999-01-31 23:52 ` uudecode? Benjamin Riefenstahl
1999-01-31 23:52 uudecode? Tom St Denis
1999-01-31 23:52 uudecode? N8TM
1999-01-31 23:52 uudecode? Earnie Boyd
1999-01-31 23:52 uudecode? Bernard Dautrevaux
1999-01-31 23:52 uudecode? John Cooper
1999-01-31 23:52 ` uudecode? Michael Hirmke
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? root
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? John Cooper
1999-01-31 23:52 ` uudecode? Pierre A. Humblet
1999-01-31 23:52 ` uudecode? Glenn Spell
1999-01-31 23:52 ` uudecode? Corinna Vinschen
1997-09-09 23:33 uudecode? John Cooper
1997-09-10 10:28 ` uudecode? root
[not found] <root@jacob.remcomp.fr's>
[not found] ` <message>
[not found] ` <of>
[not found] ` <"Mon,>
[not found] ` <18>
[not found] ` <Jan>
[not found] ` <1999>
[not found] ` <19:42:30>
[not found] ` <+0100>
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).