From 52cff627a53573f1c7b5daa0d8bf70d53a83e268 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 31 Mar 2017 09:30:23 +1000 Subject: [PATCH] Try another way --- Makefile.freebsd.WWW | 2 +- Makefile.netbsd.WWW | 2 +- Makefile.osx.WWW | 2 +- deps/aha/aha.c | 174 +++++++++++++++++++++++++++++++++++++++++++ www_msgs.c | 37 ++------- 5 files changed, 184 insertions(+), 33 deletions(-) diff --git a/Makefile.freebsd.WWW b/Makefile.freebsd.WWW index ec57509..5fc55d4 100644 --- a/Makefile.freebsd.WWW +++ b/Makefile.freebsd.WWW @@ -5,7 +5,7 @@ JAMLIB = deps/jamlib/jamlib.a ZMODEM = deps/Xmodem/libzmodem.a LUA = deps/lua/liblua.a B64 = deps/libb64-1.2/src/libb64.a -MICROHTTPD=-lmicrohttpd -liconv +MICROHTTPD=-lmicrohttpd ODOORS = deps/odoors/libs-`uname -s`/libODoors.a JSMN = deps/jsmn/libjsmn.a CDK = deps/cdk-5-20161210/libcdk.a diff --git a/Makefile.netbsd.WWW b/Makefile.netbsd.WWW index 639ef8d..1553c47 100644 --- a/Makefile.netbsd.WWW +++ b/Makefile.netbsd.WWW @@ -5,7 +5,7 @@ JAMLIB = deps/jamlib/jamlib.a ZMODEM = deps/Xmodem/libzmodem.a LUA = deps/lua/liblua.a B64 = deps/libb64-1.2/src/libb64.a -MICROHTTPD=-lmicrohttpd -liconv +MICROHTTPD=-lmicrohttpd ODOORS = deps/odoors/libs-`uname -s`/libODoors.a JSMN = deps/jsmn/libjsmn.a CDK = deps/cdk-5-20161210/libcdk.a diff --git a/Makefile.osx.WWW b/Makefile.osx.WWW index 296907f..cc27ad1 100644 --- a/Makefile.osx.WWW +++ b/Makefile.osx.WWW @@ -5,7 +5,7 @@ JAMLIB = deps/jamlib/jamlib.a ZMODEM = deps/Xmodem/libzmodem.a LUA = deps/lua/liblua.a B64 = deps/libb64-1.2/src/libb64.a -MICROHTTPD=-lmicrohttpd -liconv +MICROHTTPD=-lmicrohttpd ODOORS = deps/odoors/libs-`uname -s`/libODoors.a JSMN = deps/jsmn/libjsmn.a CDK = deps/cdk-5-20161210/libcdk.a diff --git a/deps/aha/aha.c b/deps/aha/aha.c index eae163f..c979b33 100644 --- a/deps/aha/aha.c +++ b/deps/aha/aha.c @@ -353,6 +353,180 @@ char * aha(char *input) } switch (c) { + case '\x01' : append_output(&output, "☺", &size, &outat); break; + case '\x02' : append_output(&output, "☻", &size, &outat); break; + case '\x03' : append_output(&output, "♥", &size, &outat); break; + case '\x04' : append_output(&output, "♦", &size, &outat); break; + case '\x05' : append_output(&output, "♣", &size, &outat); break; + case '\x06' : append_output(&output, "♠", &size, &outat); break; + case '\x07' : append_output(&output, "•", &size, &outat); break; + case '\x08' : append_output(&output, "◘", &size, &outat); break; + case '\x09' : append_output(&output, "○", &size, &outat); break; + case '\x0a' : append_output(&output, "◘", &size, &outat); break; + case '\x0b' : append_output(&output, "♂", &size, &outat); break; + case '\x0c' : append_output(&output, "♀", &size, &outat); break; + case '\x0d' : append_output(&output, "♪", &size, &outat); break; + case '\x0e' : append_output(&output, "♫", &size, &outat); break; + case '\x0f' : append_output(&output, "☼", &size, &outat); break; + case '\x10' : append_output(&output, "▸", &size, &outat); break; + case '\x11' : append_output(&output, "◂", &size, &outat); break; + case '\x12' : append_output(&output, "↕", &size, &outat); break; + case '\x13' : append_output(&output, "‼", &size, &outat); break; + case '\x14' : append_output(&output, "¶", &size, &outat); break; + case '\x15' : append_output(&output, "§", &size, &outat); break; + case '\x16' : append_output(&output, "▬", &size, &outat); break; + case '\x17' : append_output(&output, "↨", &size, &outat); break; + case '\x18' : append_output(&output, "↑", &size, &outat); break; + case '\x19' : append_output(&output, "↓", &size, &outat); break; + case '\x1a' : append_output(&output, "→", &size, &outat); break; + case '\x1b' : append_output(&output, "←", &size, &outat); break; + case '\x1c' : append_output(&output, "∟", &size, &outat); break; + case '\x1d' : append_output(&output, "↔", &size, &outat); break; + case '\x1e' : append_output(&output, "▴", &size, &outat); break; + case '\x1f' : append_output(&output, "▾", &size, &outat); break; + case '\x21' : append_output(&output, "!", &size, &outat); break; + case '\x22' : append_output(&output, """, &size, &outat); break; + case '\x23' : append_output(&output, "#", &size, &outat); break; + case '\x24' : append_output(&output, "$", &size, &outat); break; + case '\x25' : append_output(&output, "%", &size, &outat); break; + case '\x26' : append_output(&output, "&", &size, &outat); break; + case '\x27' : append_output(&output, "'", &size, &outat); break; + case '\x28' : append_output(&output, "(", &size, &outat); break; + case '\x29' : append_output(&output, ")", &size, &outat); break; + case '\x2a' : append_output(&output, "*", &size, &outat); break; + case '\x2b' : append_output(&output, "+", &size, &outat); break; + case '\x2c' : append_output(&output, ",", &size, &outat); break; + case '\x2d' : append_output(&output, "-", &size, &outat); break; + case '\x2e' : append_output(&output, ".", &size, &outat); break; + case '\x2f' : append_output(&output, "/", &size, &outat); break; + case '\x7f' : append_output(&output, "⌂", &size, &outat); break; + case '\x80' : append_output(&output, "Ç", &size, &outat); break; + case '\x81' : append_output(&output, "ü", &size, &outat); break; + case '\x82' : append_output(&output, "é", &size, &outat); break; + case '\x83' : append_output(&output, "â", &size, &outat); break; + case '\x84' : append_output(&output, "ä", &size, &outat); break; + case '\x85' : append_output(&output, "à", &size, &outat); break; + case '\x86' : append_output(&output, "å", &size, &outat); break; + case '\x87' : append_output(&output, "ç", &size, &outat); break; + case '\x88' : append_output(&output, "ê", &size, &outat); break; + case '\x89' : append_output(&output, "ë", &size, &outat); break; + case '\x8a' : append_output(&output, "è", &size, &outat); break; + case '\x8b' : append_output(&output, "ï", &size, &outat); break; + case '\x8c' : append_output(&output, "î", &size, &outat); break; + case '\x8d' : append_output(&output, "ì", &size, &outat); break; + case '\x8e' : append_output(&output, "Ä", &size, &outat); break; + case '\x8f' : append_output(&output, "Å", &size, &outat); break; + case '\x90' : append_output(&output, "É", &size, &outat); break; + case '\x91' : append_output(&output, "æ", &size, &outat); break; + case '\x92' : append_output(&output, "Æ", &size, &outat); break; + case '\x93' : append_output(&output, "ô", &size, &outat); break; + case '\x94' : append_output(&output, "ö", &size, &outat); break; + case '\x95' : append_output(&output, "ò", &size, &outat); break; + case '\x96' : append_output(&output, "û", &size, &outat); break; + case '\x97' : append_output(&output, "ù", &size, &outat); break; + case '\x98' : append_output(&output, "ÿ", &size, &outat); break; + case '\x99' : append_output(&output, "Ö", &size, &outat); break; + case '\x9a' : append_output(&output, "Ü", &size, &outat); break; + case '\x9b' : append_output(&output, "¢", &size, &outat); break; + case '\x9c' : append_output(&output, "£", &size, &outat); break; + case '\x9d' : append_output(&output, "¥", &size, &outat); break; + case '\x9e' : append_output(&output, "₧", &size, &outat); break; + case '\x9f' : append_output(&output, "ƒ", &size, &outat); break; + case '\xa0' : append_output(&output, "á", &size, &outat); break; + case '\xa1' : append_output(&output, "í", &size, &outat); break; + case '\xa2' : append_output(&output, "ó", &size, &outat); break; + case '\xa3' : append_output(&output, "ú", &size, &outat); break; + case '\xa4' : append_output(&output, "ñ", &size, &outat); break; + case '\xa5' : append_output(&output, "Ñ", &size, &outat); break; + case '\xa6' : append_output(&output, "ª", &size, &outat); break; + case '\xa7' : append_output(&output, "º", &size, &outat); break; + case '\xa8' : append_output(&output, "¿", &size, &outat); break; + case '\xa9' : append_output(&output, "⌐", &size, &outat); break; + case '\xaa' : append_output(&output, "¬", &size, &outat); break; + case '\xab' : append_output(&output, "½", &size, &outat); break; + case '\xac' : append_output(&output, "¼", &size, &outat); break; + case '\xad' : append_output(&output, "¡", &size, &outat); break; + case '\xae' : append_output(&output, "«", &size, &outat); break; + case '\xaf' : append_output(&output, "»", &size, &outat); break; + case '\xb0' : append_output(&output, "░", &size, &outat); break; + case '\xb1' : append_output(&output, "▒", &size, &outat); break; + case '\xb2' : append_output(&output, "▓", &size, &outat); break; + case '\xb3' : append_output(&output, "│", &size, &outat); break; + case '\xb4' : append_output(&output, "┤", &size, &outat); break; + case '\xb5' : append_output(&output, "╡", &size, &outat); break; + case '\xb6' : append_output(&output, "╢", &size, &outat); break; + case '\xb7' : append_output(&output, "╖", &size, &outat); break; + case '\xb8' : append_output(&output, "╕", &size, &outat); break; + case '\xb9' : append_output(&output, "╣", &size, &outat); break; + case '\xba' : append_output(&output, "║", &size, &outat); break; + case '\xbb' : append_output(&output, "╗", &size, &outat); break; + case '\xbc' : append_output(&output, "╝", &size, &outat); break; + case '\xbd' : append_output(&output, "╜", &size, &outat); break; + case '\xbe' : append_output(&output, "╛", &size, &outat); break; + case '\xbf' : append_output(&output, "┐", &size, &outat); break; + case '\xc0' : append_output(&output, "└", &size, &outat); break; + case '\xc1' : append_output(&output, "┴", &size, &outat); break; + case '\xc2' : append_output(&output, "┬", &size, &outat); break; + case '\xc3' : append_output(&output, "├", &size, &outat); break; + case '\xc4' : append_output(&output, "─", &size, &outat); break; + case '\xc5' : append_output(&output, "┼", &size, &outat); break; + case '\xc6' : append_output(&output, "╞", &size, &outat); break; + case '\xc7' : append_output(&output, "╟", &size, &outat); break; + case '\xc8' : append_output(&output, "╚", &size, &outat); break; + case '\xc9' : append_output(&output, "╔", &size, &outat); break; + case '\xca' : append_output(&output, "╩", &size, &outat); break; + case '\xcb' : append_output(&output, "╦", &size, &outat); break; + case '\xcc' : append_output(&output, "╠", &size, &outat); break; + case '\xcd' : append_output(&output, "═", &size, &outat); break; + case '\xce' : append_output(&output, "╬", &size, &outat); break; + case '\xcf' : append_output(&output, "╧", &size, &outat); break; + case '\xd0' : append_output(&output, "╨", &size, &outat); break; + case '\xd1' : append_output(&output, "╤", &size, &outat); break; + case '\xd2' : append_output(&output, "╥", &size, &outat); break; + case '\xd3' : append_output(&output, "╙", &size, &outat); break; + case '\xd4' : append_output(&output, "╛", &size, &outat); break; + case '\xd5' : append_output(&output, "╒", &size, &outat); break; + case '\xd6' : append_output(&output, "╓", &size, &outat); break; + case '\xd7' : append_output(&output, "╫", &size, &outat); break; + case '\xd8' : append_output(&output, "╪", &size, &outat); break; + case '\xd9' : append_output(&output, "┘", &size, &outat); break; + case '\xda' : append_output(&output, "┌", &size, &outat); break; + case '\xdb' : append_output(&output, "█", &size, &outat); break; + case '\xdc' : append_output(&output, "▄", &size, &outat); break; + case '\xdd' : append_output(&output, "▼", &size, &outat); break; + case '\xde' : append_output(&output, "▐", &size, &outat); break; + case '\xdf' : append_output(&output, "▀", &size, &outat); break; + case '\xe0' : append_output(&output, "α", &size, &outat); break; + case '\xe1' : append_output(&output, "β", &size, &outat); break; + case '\xe2' : append_output(&output, "Γ", &size, &outat); break; + case '\xe3' : append_output(&output, "π", &size, &outat); break; + case '\xe4' : append_output(&output, "Σ", &size, &outat); break; + case '\xe5' : append_output(&output, "σ", &size, &outat); break; + case '\xe6' : append_output(&output, "µ", &size, &outat); break; + case '\xe7' : append_output(&output, "τ", &size, &outat); break; + case '\xe8' : append_output(&output, "Φ", &size, &outat); break; + case '\xe9' : append_output(&output, "Θ", &size, &outat); break; + case '\xea' : append_output(&output, "Ω", &size, &outat); break; + case '\xeb' : append_output(&output, "δ", &size, &outat); break; + case '\xec' : append_output(&output, "∞", &size, &outat); break; + case '\xed' : append_output(&output, "∅", &size, &outat); break; + case '\xee' : append_output(&output, "∈", &size, &outat); break; + case '\xef' : append_output(&output, "∩", &size, &outat); break; + case '\xf0' : append_output(&output, "≡", &size, &outat); break; + case '\xf1' : append_output(&output, "±", &size, &outat); break; + case '\xf2' : append_output(&output, "≥", &size, &outat); break; + case '\xf3' : append_output(&output, "≤", &size, &outat); break; + case '\xf4' : append_output(&output, "⌠", &size, &outat); break; + case '\xf5' : append_output(&output, "⌡", &size, &outat); break; + case '\xf6' : append_output(&output, "÷", &size, &outat); break; + case '\xf7' : append_output(&output, "≈", &size, &outat); break; + case '\xf8' : append_output(&output, "°", &size, &outat); break; + case '\xf9' : append_output(&output, "∙", &size, &outat); break; + case '\xfa' : append_output(&output, "·", &size, &outat); break; + case '\xfb' : append_output(&output, "√", &size, &outat); break; + case '\xfc' : append_output(&output, "ⁿ", &size, &outat); break; + case '\xfd' : append_output(&output, "²", &size, &outat); break; + case '\xfe' : append_output(&output, "▪", &size, &outat); break; case '&': append_output(&output, "&", &size, &outat); break; case '\"': append_output(&output, """, &size, &outat); break; case '<': append_output(&output, "<", &size, &outat); break; diff --git a/www_msgs.c b/www_msgs.c index 101329a..d44cc8d 100644 --- a/www_msgs.c +++ b/www_msgs.c @@ -7,7 +7,6 @@ #ifdef __FreeBSD__ #include #endif -#include #include "bbs.h" #include "jamlib/jam.h" @@ -270,14 +269,10 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i char buffer[4096]; int chars; int i; - iconv_t ic; + char *aha_text; char *aha_out; - char *aha_cp437; - size_t insz; - size_t outsz; - char *iconv_cp437; - char *iconv_text; + if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) { return NULL; } @@ -470,28 +465,10 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i len += strlen(buffer); + aha_text = (char *)malloc(jmh.TxtLen + 1); - aha_text = (char *)malloc((jmh.TxtLen + 1) * 2); - aha_cp437 = (char *)malloc(jmh.TxtLen + 1); - - iconv_cp437 = aha_cp437; - iconv_text = aha_text; - - memcpy(aha_cp437, body, jmh.TxtLen); - aha_cp437[jmh.TxtLen] = '\0'; - - insz = jmh.TxtLen; - outsz = jmh.TxtLen * 2; - - memset(aha_text, 0, (jmh.TxtLen + 1) * 2); - - ic = iconv_open("UTF-8", "CP437"); - iconv(ic, &iconv_cp437, &insz, &iconv_text, &outsz); - iconv_close(ic); - free(aha_cp437); - - - + memcpy(aha_text, body, jmh.TxtLen); + aha_text[jmh.TxtLen] = '\0'; aha_out = aha(aha_text); while (len + strlen(aha_out) > max_len - 1) { max_len += 4096; @@ -502,7 +479,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i free(aha_out); free(aha_text); - + sprintf(buffer, "\n"); if (len + strlen(buffer) > max_len - 1) { max_len += 4096; @@ -513,7 +490,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i - sprintf(buffer, "
\n"); + sprintf(buffer, "
\n"); if (len + strlen(buffer) > max_len - 1) { max_len += 4096; page = (char *)realloc(page, max_len);