Subject: Re: How do I get pine to treat a mime type as text?

From: "MAS Inc." <[email-masked]>
Date: Mon, 1 Jul 1996 10:47:00 -0700

On 26 Jun 1996, Antonio Enrique Prats wrote:

> My school (as many do) does not allow CGI access, so I've just had my
> forms mail the responses to me, and I just sort through the gobbledygook
> myself.  However, something must have changed, because I used to just be
> able to read the response right in pine, and now what I see is
>
> [Part 1, Application/X-WWW-FORM-URLENCODED  86bytes]
>   [Can not display this part. Use the "V" command to save in a file]
>
> When I do that, it's just a simple text file as before.  Is there anyway
> to get pine to just display it, like it used to?  I haven't changed
> versions of pine, I'm sure it's just that some server software got
> upgraded or something like that.

I don't know if this will help you, but I have written simple urldecoder
in C.  If you can convince the system administrator at the school to
compile it for you (or maybe you can do it in your personal directory),
call it urldecode and put it in a bin directory.  Then when you see the
above message, press pipe (|) and type in urldecode.  You will see your
message in plain text.

I guess there's also a way to get this setup in the new mailcap file.  I
don't know how to do this, though.  Good luck.

I've attached the source code.  You can also get it at

	ftp.teleport.com/vendors/masi/pickup

if that's your cup of tea.

(To real C coders: please don't laugh at my code, I'm just a beginner.  Is
there a standard header file for hex to int conversion?  I couldn't find
one, so I wrote it.)

Replies can be send to : [email-masked]

---MAS Inc.			   email: [email-masked]
   15050 SW Koll Parkway, Suite C    web: http://www.teleport.com/~masi
   Beaverton, OR  97006		   phone: (503) 641-6200
/*
 * urldecode - decodes url text
 *
 * Send url text to my standard input, and I will send parsed text
 * to my standard output.  Do with it as you will.
 */

#include <stdio.h>
#include "xtoi.h"

int gethex()
{
	char s[2];

	if ( (s[0] = getchar()) == EOF) return EOF;
	if ( (s[1] = getchar()) == EOF) return EOF;
	s[2] = '\0';
	return (int)xtoi(s, 2);
}

void main()
{
	int ch;

	for(;;) {

		if ( (ch = getchar()) == EOF ) break;

		switch(ch) {
			case '&': ch = '\n'; break;
			case '+': ch = ' '; break;
			case '%': ch = gethex(); break;
		}

		if (ch == EOF || ch == BAD_HEX_DIGIT) break;
		putchar(ch);

	}
}
/*
 *  xtoi.h - Convert a "hex" string to a long integer
 */

#define BAD_HEX_DIGIT -1

int hdigit(char in)
{
	switch (in) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		case 'A': return 10;
		case 'B': return 11;
		case 'C': return 12;
		case 'D': return 13;
		case 'E': return 14;
		case 'F': return 15;
		default: return BAD_HEX_DIGIT;
	}
}

long xtoi(char *in, int len)
{
	long int out = 0;
	int i, d;

	for (i = 0; i < len && in[i] != '\0'; i++) {
		d = hdigit(in[i]);
		if ( d == BAD_HEX_DIGIT )
			return d;
		else
			out = out * 16 + d;
	}

	return out;
}