Rewrite aha to work with new tree system ready for messages and files
This commit is contained in:
parent
71b465eba2
commit
947d4ab37f
367
deps/aha/aha.c
vendored
367
deps/aha/aha.c
vendored
@ -20,6 +20,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "../../src/www_tree.h"
|
||||||
|
|
||||||
extern void unmangle_ansi(char *body, int len, char **body_out, int *body_len);
|
extern void unmangle_ansi(char *body, int len, char **body_out, int *body_len);
|
||||||
|
|
||||||
@ -84,17 +85,7 @@ void deleteParse(pelem elem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void append_output(char **output, char *stuff, int *size, int *at) {
|
struct www_tag * aha(char *input, struct www_tag *parent)
|
||||||
while (*at + strlen(stuff) + 1 >= *size) {
|
|
||||||
*size += 256;
|
|
||||||
*output = realloc(*output, *size);
|
|
||||||
}
|
|
||||||
|
|
||||||
strcat(*output, stuff);
|
|
||||||
*at += strlen(stuff);
|
|
||||||
}
|
|
||||||
|
|
||||||
char * aha(char *input)
|
|
||||||
{
|
{
|
||||||
//Searching Parameters
|
//Searching Parameters
|
||||||
char *unmangle_out;
|
char *unmangle_out;
|
||||||
@ -116,13 +107,11 @@ char * aha(char *input)
|
|||||||
int newline=-1;
|
int newline=-1;
|
||||||
int temp;
|
int temp;
|
||||||
char *ptr = unmangle_out;
|
char *ptr = unmangle_out;
|
||||||
char *output = (char *)malloc(256);
|
|
||||||
int size = 256;
|
int size = 256;
|
||||||
int outat = 0;
|
int outat = 0;
|
||||||
char minibuf[2];
|
char minibuf[2];
|
||||||
|
struct www_tag *child = NULL;
|
||||||
|
stralloc data = EMPTY_STRALLOC;
|
||||||
memset(output, 0, 256);
|
|
||||||
|
|
||||||
while (*ptr != '\0')
|
while (*ptr != '\0')
|
||||||
{
|
{
|
||||||
@ -138,7 +127,7 @@ char * aha(char *input)
|
|||||||
//Searching the end (a letter) and safe the insert:
|
//Searching the end (a letter) and safe the insert:
|
||||||
c= *ptr++;
|
c= *ptr++;
|
||||||
if (c == '\0') {
|
if (c == '\0') {
|
||||||
return output;
|
return parent;
|
||||||
}
|
}
|
||||||
if ( c == '[' ) // CSI code, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
if ( c == '[' ) // CSI code, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||||
{
|
{
|
||||||
@ -149,7 +138,7 @@ char * aha(char *input)
|
|||||||
{
|
{
|
||||||
c=*ptr++;
|
c=*ptr++;
|
||||||
if (c == '\0') {
|
if (c == '\0') {
|
||||||
return output;
|
return parent;
|
||||||
}
|
}
|
||||||
buffer[counter]=c;
|
buffer[counter]=c;
|
||||||
if (c=='>') //end of htop
|
if (c=='>') //end of htop
|
||||||
@ -238,340 +227,202 @@ char * aha(char *input)
|
|||||||
//Checking the differences
|
//Checking the differences
|
||||||
if ((fc!=ofc) || (bc!=obc) || (ul!=oul) || (bo!=obo) || (bl!=obl)) //ANY Change
|
if ((fc!=ofc) || (bc!=obc) || (ul!=oul) || (bo!=obo) || (bl!=obl)) //ANY Change
|
||||||
{
|
{
|
||||||
if ((ofc!=-1) || (obc!=-1) || (oul!=0) || (obo!=0) || (obl!=0))
|
|
||||||
append_output(&output, "</span>", &size, &outat);
|
|
||||||
if ((fc!=-1) || (bc!=-1) || (ul!=0) || (bo!=0) || (bl!=0))
|
if ((fc!=-1) || (bc!=-1) || (ul!=0) || (bo!=0) || (bl!=0))
|
||||||
{
|
{
|
||||||
append_output(&output, "<span style=\"", &size, &outat);
|
if (data.len > 0) {
|
||||||
|
stralloc_0(&data);
|
||||||
|
struct www_tag *datatag = www_tag_new(NULL, data.s);
|
||||||
|
free(data.s);
|
||||||
|
data = EMPTY_STRALLOC;
|
||||||
|
if (child == NULL) {
|
||||||
|
www_tag_add_child(parent, datatag);
|
||||||
|
} else {
|
||||||
|
www_tag_add_child(child, datatag);
|
||||||
|
www_tag_add_child(parent, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
child = www_tag_new("span", NULL);
|
||||||
|
|
||||||
|
stralloc output = EMPTY_STRALLOC;
|
||||||
|
|
||||||
switch (fc)
|
switch (fc)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (bo) {
|
if (bo) {
|
||||||
append_output(&output, "color:dimgray;", &size, &outat);
|
stralloc_cats(&output, "color:dimgray;");
|
||||||
} else {
|
} else {
|
||||||
append_output(&output, "color:dimgray;", &size, &outat);
|
stralloc_cats(&output, "color:dimgray;");
|
||||||
}
|
}
|
||||||
break; //Black
|
break; //Black
|
||||||
case 1:
|
case 1:
|
||||||
if (bo) {
|
if (bo) {
|
||||||
append_output(&output, "color:#FF8888;", &size, &outat);
|
stralloc_cats(&output, "color:#FF8888;");
|
||||||
} else {
|
} else {
|
||||||
append_output(&output, "color:red;", &size, &outat);
|
stralloc_cats(&output, "color:red;");
|
||||||
}
|
}
|
||||||
break; //Red
|
break; //Red
|
||||||
case 2:
|
case 2:
|
||||||
if (bo) {
|
if (bo) {
|
||||||
append_output(&output, "color:lime;", &size, &outat);
|
stralloc_cats(&output, "color:lime;");
|
||||||
} else {
|
} else {
|
||||||
append_output(&output, "color:#00ff00;", &size, &outat);
|
stralloc_cats(&output, "color:#00FF00;");
|
||||||
}
|
}
|
||||||
break; //Green
|
break; //Green
|
||||||
case 3:
|
case 3:
|
||||||
if (bo) {
|
if (bo) {
|
||||||
append_output(&output, "color:yellow;", &size, &outat);
|
stralloc_cats(&output, "color:yellow;");
|
||||||
} else {
|
} else {
|
||||||
append_output(&output, "color:olive;", &size, &outat);
|
stralloc_cats(&output, "color:olive;");
|
||||||
}
|
}
|
||||||
break; //Yellow
|
break; //Yellow
|
||||||
case 4:
|
case 4:
|
||||||
if (bo) {
|
if (bo) {
|
||||||
append_output(&output, "color:#8888FF;", &size, &outat);
|
stralloc_cats(&output, "color:#8888FF;");
|
||||||
} else {
|
} else {
|
||||||
append_output(&output, "color:#0000FF;", &size, &outat);
|
stralloc_cats(&output, "color:#0000FF;");
|
||||||
}
|
}
|
||||||
break; //Blue
|
break; //Blue
|
||||||
case 5:
|
case 5:
|
||||||
if (bo) {
|
if (bo) {
|
||||||
append_output(&output, "color:fuchsia;", &size, &outat);
|
stralloc_cats(&output, "color:fuchsia;");
|
||||||
} else {
|
} else {
|
||||||
append_output(&output, "color:#FF00FF;", &size, &outat);
|
stralloc_cats(&output, "color:#FF00FF;");
|
||||||
}
|
}
|
||||||
break; //Purple
|
break; //Purple
|
||||||
case 6:
|
case 6:
|
||||||
if (bo) {
|
if (bo) {
|
||||||
append_output(&output, "color:aqua;", &size, &outat);
|
stralloc_cats(&output, "color:aqua;");
|
||||||
} else {
|
} else {
|
||||||
append_output(&output, "color:#008888;", &size, &outat);
|
stralloc_cats(&output, "color:#008888;");
|
||||||
}
|
}
|
||||||
break; //Cyan
|
break; //Cyan
|
||||||
case 7:
|
case 7:
|
||||||
if (bo) {
|
if (bo) {
|
||||||
append_output(&output, "color:white;", &size, &outat);
|
stralloc_cats(&output, "color:white;");
|
||||||
} else {
|
} else {
|
||||||
append_output(&output, "color:grey;", &size, &outat);
|
stralloc_cats(&output, "color:grey;");
|
||||||
}
|
}
|
||||||
break; //White
|
break; //White
|
||||||
case 8:
|
case 8:
|
||||||
append_output(&output, "color:black;", &size, &outat);
|
stralloc_cats(&output, "color:black;");
|
||||||
break; //Background Colour
|
break; //Background Colour
|
||||||
case 9:
|
case 9:
|
||||||
append_output(&output, "color:white;", &size, &outat);
|
stralloc_cats(&output, "color:white;");
|
||||||
break; //Foreground Color
|
break; //Foreground Color
|
||||||
}
|
}
|
||||||
switch (bc)
|
switch (bc)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
append_output(&output, "background-color:black;", &size, &outat);
|
stralloc_cats(&output, "background-color:black;");
|
||||||
break; //Black
|
break; //Black
|
||||||
case 1:
|
case 1:
|
||||||
append_output(&output, "background-color:red;", &size, &outat);
|
stralloc_cats(&output, "background-color:red;");
|
||||||
break; //Red
|
break; //Red
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
append_output(&output, "background-color:lime;", &size, &outat);
|
stralloc_cats(&output, "background-color:lime;");
|
||||||
break; //Green
|
break; //Green
|
||||||
case 3:
|
case 3:
|
||||||
append_output(&output, "background-color:yellow;", &size, &outat);
|
stralloc_cats(&output, "background-color:yellow;");
|
||||||
break; //Yellow
|
break; //Yellow
|
||||||
case 4:
|
case 4:
|
||||||
append_output(&output, "background-color:#3333FF;", &size, &outat);
|
stralloc_cats(&output, "background-color:#3333FF;");
|
||||||
break; //Blue
|
break; //Blue
|
||||||
case 5:
|
case 5:
|
||||||
append_output(&output, "background-color:fuchsia;", &size, &outat);
|
stralloc_cats(&output, "background-color:fuchsia;");
|
||||||
break; //Purple
|
break; //Purple
|
||||||
case 6:
|
case 6:
|
||||||
append_output(&output, "background-color:aqua;", &size, &outat);
|
stralloc_cats(&output, "background-color:aqua;");
|
||||||
break; //Cyan
|
break; //Cyan
|
||||||
case 7:
|
case 7:
|
||||||
append_output(&output, "background-color:white;", &size, &outat);
|
stralloc_cats(&output, "background-color:white;");
|
||||||
break; //White
|
break; //White
|
||||||
case 8:
|
case 8:
|
||||||
append_output(&output, "background-color:black;", &size, &outat);
|
stralloc_cats(&output, "background-color:black;");
|
||||||
break; //Background Colour
|
break; //Background Colour
|
||||||
case 9:
|
case 9:
|
||||||
append_output(&output, "background-color:white;", &size, &outat);
|
stralloc_cats(&output, "background-color:white;");
|
||||||
break; //Foreground Colour
|
break; //Foreground Colour
|
||||||
}
|
}
|
||||||
if (ul)
|
if (ul)
|
||||||
{
|
{
|
||||||
append_output(&output, "text-decoration:underline;", &size, &outat);
|
stralloc_cats(&output, "text-decoration:underline;");
|
||||||
}
|
}
|
||||||
if (bl)
|
if (bl)
|
||||||
{
|
{
|
||||||
append_output(&output, "text-decoration:blink;", &size, &outat);
|
stralloc_cats(&output, "text-decoration:blink;");
|
||||||
}
|
}
|
||||||
|
|
||||||
append_output(&output, "\">", &size, &outat);
|
stralloc_0(&output);
|
||||||
|
www_tag_add_attrib(child, "style", output.s);
|
||||||
|
free(output.s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (c==13)
|
|
||||||
{
|
|
||||||
//for (;line<80;line++)
|
|
||||||
|
|
||||||
// append_output(&output, " ", &size, &outat);
|
|
||||||
line=0;
|
|
||||||
momline++;
|
|
||||||
append_output(&output, "<br />\n", &size, &outat);
|
|
||||||
}
|
|
||||||
else if (c!=8)
|
else if (c!=8)
|
||||||
{
|
{
|
||||||
line++;
|
line++;
|
||||||
if (newline>=0)
|
|
||||||
{
|
|
||||||
while (newline>line)
|
|
||||||
{
|
|
||||||
append_output(&output, " ", &size, &outat);
|
|
||||||
line++;
|
|
||||||
}
|
|
||||||
newline=-1;
|
|
||||||
}
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '\x01' : append_output(&output, "☺", &size, &outat); break;
|
|
||||||
case '\x02' : append_output(&output, "☻", &size, &outat); break;
|
case '\n':
|
||||||
case '\x03' : append_output(&output, "♥", &size, &outat); break;
|
case 13:
|
||||||
case '\x04' : append_output(&output, "♦", &size, &outat); break;
|
momline++;
|
||||||
case '\x05' : append_output(&output, "♣", &size, &outat); break;
|
line=0;
|
||||||
case '\x06' : append_output(&output, "♠", &size, &outat); break;
|
struct www_tag *brtag = www_tag_new("br", NULL);
|
||||||
case '\x07' : append_output(&output, "•", &size, &outat); break;
|
if (data.len > 0) {
|
||||||
case '\x08' : append_output(&output, "◘", &size, &outat); break;
|
if (child != NULL) {
|
||||||
case '\x09' : append_output(&output, "○", &size, &outat); break;
|
stralloc_0(&data);
|
||||||
//case '\x0a' : append_output(&output, "◘", &size, &outat); break;
|
struct www_tag *datatag = www_tag_new(NULL, data.s);
|
||||||
case '\x0b' : append_output(&output, "♂", &size, &outat); break;
|
free(data.s);
|
||||||
case '\x0c' : append_output(&output, "♀", &size, &outat); break;
|
data = EMPTY_STRALLOC;
|
||||||
//case '\x0d' : append_output(&output, "♪", &size, &outat); break;
|
www_tag_add_child(child, datatag);
|
||||||
case '\x0e' : append_output(&output, "♫", &size, &outat); break;
|
www_tag_add_child(child, brtag);
|
||||||
case '\x0f' : append_output(&output, "☼", &size, &outat); break;
|
www_tag_add_child(parent, child);
|
||||||
case '\x10' : append_output(&output, "▸", &size, &outat); break;
|
child = www_tag_duplicate(child);
|
||||||
case '\x11' : append_output(&output, "◂", &size, &outat); break;
|
} else {
|
||||||
case '\x12' : append_output(&output, "↕", &size, &outat); break;
|
stralloc_0(&data);
|
||||||
case '\x13' : append_output(&output, "‼", &size, &outat); break;
|
struct www_tag *datatag = www_tag_new(NULL, data.s);
|
||||||
case '\x14' : append_output(&output, "¶", &size, &outat); break;
|
free(data.s);
|
||||||
case '\x15' : append_output(&output, "§", &size, &outat); break;
|
data = EMPTY_STRALLOC;
|
||||||
case '\x16' : append_output(&output, "▬", &size, &outat); break;
|
www_tag_add_child(parent, datatag);
|
||||||
case '\x17' : append_output(&output, "↨", &size, &outat); break;
|
www_tag_add_child(parent, brtag);
|
||||||
case '\x18' : append_output(&output, "↑", &size, &outat); break;
|
}
|
||||||
case '\x19' : append_output(&output, "↓", &size, &outat); break;
|
} else {
|
||||||
case '\x1a' : append_output(&output, "→", &size, &outat); break;
|
|
||||||
case '\x1b' : append_output(&output, "←", &size, &outat); break;
|
|
||||||
case '\x1c' : append_output(&output, "∟", &size, &outat); break;
|
if (child != NULL) {
|
||||||
case '\x1d' : append_output(&output, "↔", &size, &outat); break;
|
www_tag_add_child(child, brtag);
|
||||||
case '\x1e' : append_output(&output, "▴", &size, &outat); break;
|
www_tag_add_child(parent, child);
|
||||||
case '\x1f' : append_output(&output, "▾", &size, &outat); break;
|
child = www_tag_duplicate(child);
|
||||||
case '\x21' : append_output(&output, "!", &size, &outat); break;
|
|
||||||
case '\x22' : append_output(&output, """, &size, &outat); break;
|
} else {
|
||||||
case '\x23' : append_output(&output, "#", &size, &outat); break;
|
www_tag_add_child(parent, brtag);
|
||||||
case '\x24' : append_output(&output, "$", &size, &outat); break;
|
}
|
||||||
case '\x25' : append_output(&output, "%", &size, &outat); break;
|
}
|
||||||
case '\x26' : append_output(&output, "&", &size, &outat); break;
|
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 '\n':case 13: momline++;
|
|
||||||
line=0;
|
|
||||||
append_output(&output, "<br />\n", &size, &outat);
|
|
||||||
break;
|
|
||||||
case ' ': append_output(&output, " ", &size, &outat); break;
|
|
||||||
default: {
|
default: {
|
||||||
sprintf(minibuf, "%c", c);
|
stralloc_append1(&data, c);
|
||||||
append_output(&output, minibuf, &size, &outat);
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Footer
|
if (data.len > 0) {
|
||||||
if ((fc!=-1) || (bc!=-1) || (ul!=0) || (bo!=0) || (bl!=0))
|
stralloc_0(&data);
|
||||||
append_output(&output, "</span>\n", &size, &outat);
|
struct www_tag *datatag = www_tag_new(NULL, data.s);
|
||||||
|
free(data.s);
|
||||||
|
data = EMPTY_STRALLOC;
|
||||||
|
if (child == NULL) {
|
||||||
|
www_tag_add_child(parent, datatag);
|
||||||
|
} else {
|
||||||
|
www_tag_add_child(child, datatag);
|
||||||
|
www_tag_add_child(parent, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
free(unmangle_out);
|
free(unmangle_out);
|
||||||
return output;
|
return parent;
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,12 @@
|
|||||||
|
|
||||||
#include "../deps/hashids/hashids.h"
|
#include "../deps/hashids/hashids.h"
|
||||||
|
|
||||||
|
#include "www_tree.h"
|
||||||
#include "bbs.h"
|
#include "bbs.h"
|
||||||
|
|
||||||
extern struct bbs_config conf;
|
extern struct bbs_config conf;
|
||||||
extern struct user_record *gUser;
|
extern struct user_record *gUser;
|
||||||
extern char *aha(char *input);
|
extern struct www_tag * aha(char *input, struct www_tag *parent);
|
||||||
|
|
||||||
static int digit2nibble(int digit) {
|
static int digit2nibble(int digit) {
|
||||||
static const char *const hex = "0123456789abcdef";
|
static const char *const hex = "0123456789abcdef";
|
||||||
@ -298,7 +299,6 @@ char *www_files_display_listing(int dir, int sub) {
|
|||||||
|
|
||||||
stralloc page = EMPTY_STRALLOC;
|
stralloc page = EMPTY_STRALLOC;
|
||||||
char pathbuf[PATH_MAX];
|
char pathbuf[PATH_MAX];
|
||||||
char *aha_out = NULL;
|
|
||||||
sqlite3 *db = NULL;
|
sqlite3 *db = NULL;
|
||||||
sqlite3_stmt *res = NULL;
|
sqlite3_stmt *res = NULL;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
@ -372,9 +372,13 @@ char *www_files_display_listing(int dir, int sub) {
|
|||||||
if (*p == '\n')
|
if (*p == '\n')
|
||||||
*p = '\r';
|
*p = '\r';
|
||||||
}
|
}
|
||||||
aha_out = aha(description);
|
struct www_tag *aha_out = www_tag_new(NULL, "");
|
||||||
stralloc_cats(&page, aha_out);
|
aha(description, aha_out);
|
||||||
free(aha_out);
|
|
||||||
|
char *aha_data = www_tag_unwravel(aha_out);
|
||||||
|
|
||||||
|
stralloc_cats(&page, aha_data);
|
||||||
|
free(aha_data);
|
||||||
free(description);
|
free(description);
|
||||||
free(filename);
|
free(filename);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
|
#include "www_tree.h"
|
||||||
#include "jamlib/jam.h"
|
#include "jamlib/jam.h"
|
||||||
#include "libuuid/uuid.h"
|
#include "libuuid/uuid.h"
|
||||||
|
|
||||||
@ -15,9 +15,8 @@
|
|||||||
|
|
||||||
#define IN 0
|
#define IN 0
|
||||||
#define OUT 1
|
#define OUT 1
|
||||||
extern char *aha(char *input);
|
|
||||||
extern struct bbs_config conf;
|
extern struct bbs_config conf;
|
||||||
|
extern struct www_tag * aha(char *input, struct www_tag *parent);
|
||||||
static char *www_wordwrap(char *content, int cutoff);
|
static char *www_wordwrap(char *content, int cutoff);
|
||||||
char *www_sanitize(char *inp) {
|
char *www_sanitize(char *inp) {
|
||||||
int i;
|
int i;
|
||||||
@ -241,7 +240,6 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
char *to_s;
|
char *to_s;
|
||||||
int l1, l2;
|
int l1, l2;
|
||||||
char *aha_text;
|
char *aha_text;
|
||||||
char *aha_out;
|
|
||||||
char *nodename;
|
char *nodename;
|
||||||
struct fido_addr *nodeno;
|
struct fido_addr *nodeno;
|
||||||
|
|
||||||
@ -421,10 +419,13 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
stralloc_cats(&page, "<div id=\"msgbody\">\n");
|
stralloc_cats(&page, "<div id=\"msgbody\">\n");
|
||||||
|
|
||||||
aha_text = strndup(body, jmh.TxtLen);
|
aha_text = strndup(body, jmh.TxtLen);
|
||||||
aha_out = aha(aha_text);
|
struct www_tag *aha_out = www_tag_new(NULL, "");
|
||||||
stralloc_cats(&page, aha_out);
|
aha(aha_text, aha_out);
|
||||||
|
|
||||||
free(aha_out);
|
char *aha_data = www_tag_unwravel(aha_out);
|
||||||
|
|
||||||
|
stralloc_cats(&page, aha_data);
|
||||||
|
free(aha_data);
|
||||||
free(aha_text);
|
free(aha_text);
|
||||||
|
|
||||||
stralloc_cats(&page, "</div>\n");
|
stralloc_cats(&page, "</div>\n");
|
||||||
|
526
src/www_tree.c
526
src/www_tree.c
@ -28,12 +28,528 @@ struct www_tag *www_tag_new(char *tag, char *data) {
|
|||||||
case '>':
|
case '>':
|
||||||
stralloc_cats(&str, ">");
|
stralloc_cats(&str, ">");
|
||||||
break;
|
break;
|
||||||
|
case '\x01':
|
||||||
|
stralloc_cats(&str, "☺");
|
||||||
|
break;
|
||||||
|
case '\x02':
|
||||||
|
stralloc_cats(&str, "☻");
|
||||||
|
break;
|
||||||
|
case '\x03':
|
||||||
|
stralloc_cats(&str, "♥");
|
||||||
|
break;
|
||||||
|
case '\x04':
|
||||||
|
stralloc_cats(&str, "♦");
|
||||||
|
break;
|
||||||
|
case '\x05':
|
||||||
|
stralloc_cats(&str, "♣");
|
||||||
|
break;
|
||||||
|
case '\x06':
|
||||||
|
stralloc_cats(&str, "♠");
|
||||||
|
break;
|
||||||
|
case '\x07':
|
||||||
|
stralloc_cats(&str, "•");
|
||||||
|
break;
|
||||||
|
case '\x08':
|
||||||
|
stralloc_cats(&str, "◘");
|
||||||
|
break;
|
||||||
|
case '\x09':
|
||||||
|
stralloc_cats(&str, "○");
|
||||||
|
break;
|
||||||
|
case '\x0b':
|
||||||
|
stralloc_cats(&str, "♂");
|
||||||
|
break;
|
||||||
|
case '\x0c':
|
||||||
|
stralloc_cats(&str, "♀");
|
||||||
|
break;
|
||||||
|
case '\x0e':
|
||||||
|
stralloc_cats(&str, "♫");
|
||||||
|
break;
|
||||||
|
case '\x0f':
|
||||||
|
stralloc_cats(&str, "☼");
|
||||||
|
break;
|
||||||
|
case '\x10':
|
||||||
|
stralloc_cats(&str, "▸");
|
||||||
|
break;
|
||||||
|
case '\x11':
|
||||||
|
stralloc_cats(&str, "◂");
|
||||||
|
break;
|
||||||
|
case '\x12':
|
||||||
|
stralloc_cats(&str, "↕");
|
||||||
|
break;
|
||||||
|
case '\x13':
|
||||||
|
stralloc_cats(&str, "‼");
|
||||||
|
break;
|
||||||
|
case '\x14':
|
||||||
|
stralloc_cats(&str, "¶");
|
||||||
|
break;
|
||||||
|
case '\x15':
|
||||||
|
stralloc_cats(&str, "§");
|
||||||
|
break;
|
||||||
|
case '\x16':
|
||||||
|
stralloc_cats(&str, "▬");
|
||||||
|
break;
|
||||||
|
case '\x17':
|
||||||
|
stralloc_cats(&str, "↨");
|
||||||
|
break;
|
||||||
|
case '\x18':
|
||||||
|
stralloc_cats(&str, "↑");
|
||||||
|
break;
|
||||||
|
case '\x19':
|
||||||
|
stralloc_cats(&str, "↓");
|
||||||
|
break;
|
||||||
|
case '\x1a':
|
||||||
|
stralloc_cats(&str, "→");
|
||||||
|
break;
|
||||||
|
case '\x1b':
|
||||||
|
stralloc_cats(&str, "←");
|
||||||
|
break;
|
||||||
|
case '\x1c':
|
||||||
|
stralloc_cats(&str, "∟");
|
||||||
|
break;
|
||||||
|
case '\x1d':
|
||||||
|
stralloc_cats(&str, "↔");
|
||||||
|
break;
|
||||||
|
case '\x1e':
|
||||||
|
stralloc_cats(&str, "▴");
|
||||||
|
break;
|
||||||
|
case '\x1f':
|
||||||
|
stralloc_cats(&str, "▾");
|
||||||
|
break;
|
||||||
|
case '\x21':
|
||||||
|
stralloc_cats(&str, "!");
|
||||||
|
break;
|
||||||
|
case '\x22':
|
||||||
|
stralloc_cats(&str, """);
|
||||||
|
break;
|
||||||
|
case '\x23':
|
||||||
|
stralloc_cats(&str, "#");
|
||||||
|
break;
|
||||||
|
case '\x24':
|
||||||
|
stralloc_cats(&str, "$");
|
||||||
|
break;
|
||||||
|
case '\x25':
|
||||||
|
stralloc_cats(&str, "%");
|
||||||
|
break;
|
||||||
|
case '\x27':
|
||||||
|
stralloc_cats(&str, "'");
|
||||||
|
break;
|
||||||
|
case '\x28':
|
||||||
|
stralloc_cats(&str, "(");
|
||||||
|
break;
|
||||||
|
case '\x29':
|
||||||
|
stralloc_cats(&str, ")");
|
||||||
|
break;
|
||||||
|
case '\x2a':
|
||||||
|
stralloc_cats(&str, "*");
|
||||||
|
break;
|
||||||
|
case '\x2b':
|
||||||
|
stralloc_cats(&str, "+");
|
||||||
|
break;
|
||||||
|
case '\x2c':
|
||||||
|
stralloc_cats(&str, ",");
|
||||||
|
break;
|
||||||
|
case '\x2d':
|
||||||
|
stralloc_cats(&str, "-");
|
||||||
|
break;
|
||||||
|
case '\x2e':
|
||||||
|
stralloc_cats(&str, ".");
|
||||||
|
break;
|
||||||
|
case '\x2f':
|
||||||
|
stralloc_cats(&str, "/");
|
||||||
|
break;
|
||||||
|
case '\x7f':
|
||||||
|
stralloc_cats(&str, "⌂");
|
||||||
|
break;
|
||||||
|
case '\x80':
|
||||||
|
stralloc_cats(&str, "Ç");
|
||||||
|
break;
|
||||||
|
case '\x81':
|
||||||
|
stralloc_cats(&str, "ü");
|
||||||
|
break;
|
||||||
|
case '\x82':
|
||||||
|
stralloc_cats(&str, "é");
|
||||||
|
break;
|
||||||
|
case '\x83':
|
||||||
|
stralloc_cats(&str, "â");
|
||||||
|
break;
|
||||||
|
case '\x84':
|
||||||
|
stralloc_cats(&str, "ä");
|
||||||
|
break;
|
||||||
|
case '\x85':
|
||||||
|
stralloc_cats(&str, "à");
|
||||||
|
break;
|
||||||
|
case '\x86':
|
||||||
|
stralloc_cats(&str, "å");
|
||||||
|
break;
|
||||||
|
case '\x87':
|
||||||
|
stralloc_cats(&str, "ç");
|
||||||
|
break;
|
||||||
|
case '\x88':
|
||||||
|
stralloc_cats(&str, "ê");
|
||||||
|
break;
|
||||||
|
case '\x89':
|
||||||
|
stralloc_cats(&str, "ë");
|
||||||
|
break;
|
||||||
|
case '\x8a':
|
||||||
|
stralloc_cats(&str, "è");
|
||||||
|
break;
|
||||||
|
case '\x8b':
|
||||||
|
stralloc_cats(&str, "ï");
|
||||||
|
break;
|
||||||
|
case '\x8c':
|
||||||
|
stralloc_cats(&str, "î");
|
||||||
|
break;
|
||||||
|
case '\x8d':
|
||||||
|
stralloc_cats(&str, "ì");
|
||||||
|
break;
|
||||||
|
case '\x8e':
|
||||||
|
stralloc_cats(&str, "Ä");
|
||||||
|
break;
|
||||||
|
case '\x8f':
|
||||||
|
stralloc_cats(&str, "Å");
|
||||||
|
break;
|
||||||
|
case '\x90':
|
||||||
|
stralloc_cats(&str, "É");
|
||||||
|
break;
|
||||||
|
case '\x91':
|
||||||
|
stralloc_cats(&str, "æ");
|
||||||
|
break;
|
||||||
|
case '\x92':
|
||||||
|
stralloc_cats(&str, "Æ");
|
||||||
|
break;
|
||||||
|
case '\x93':
|
||||||
|
stralloc_cats(&str, "ô");
|
||||||
|
break;
|
||||||
|
case '\x94':
|
||||||
|
stralloc_cats(&str, "ö");
|
||||||
|
break;
|
||||||
|
case '\x95':
|
||||||
|
stralloc_cats(&str, "ò");
|
||||||
|
break;
|
||||||
|
case '\x96':
|
||||||
|
stralloc_cats(&str, "û");
|
||||||
|
break;
|
||||||
|
case '\x97':
|
||||||
|
stralloc_cats(&str, "ù");
|
||||||
|
break;
|
||||||
|
case '\x98':
|
||||||
|
stralloc_cats(&str, "ÿ");
|
||||||
|
break;
|
||||||
|
case '\x99':
|
||||||
|
stralloc_cats(&str, "Ö");
|
||||||
|
break;
|
||||||
|
case '\x9a':
|
||||||
|
stralloc_cats(&str, "Ü");
|
||||||
|
break;
|
||||||
|
case '\x9b':
|
||||||
|
stralloc_cats(&str, "¢");
|
||||||
|
break;
|
||||||
|
case '\x9c':
|
||||||
|
stralloc_cats(&str, "£");
|
||||||
|
break;
|
||||||
|
case '\x9d':
|
||||||
|
stralloc_cats(&str, "¥");
|
||||||
|
break;
|
||||||
|
case '\x9e':
|
||||||
|
stralloc_cats(&str, "₧");
|
||||||
|
break;
|
||||||
|
case '\x9f':
|
||||||
|
stralloc_cats(&str, "ƒ");
|
||||||
|
break;
|
||||||
|
case '\xa0':
|
||||||
|
stralloc_cats(&str, "á");
|
||||||
|
break;
|
||||||
|
case '\xa1':
|
||||||
|
stralloc_cats(&str, "í");
|
||||||
|
break;
|
||||||
|
case '\xa2':
|
||||||
|
stralloc_cats(&str, "ó");
|
||||||
|
break;
|
||||||
|
case '\xa3':
|
||||||
|
stralloc_cats(&str, "ú");
|
||||||
|
break;
|
||||||
|
case '\xa4':
|
||||||
|
stralloc_cats(&str, "ñ");
|
||||||
|
break;
|
||||||
|
case '\xa5':
|
||||||
|
stralloc_cats(&str, "Ñ");
|
||||||
|
break;
|
||||||
|
case '\xa6':
|
||||||
|
stralloc_cats(&str, "ª");
|
||||||
|
break;
|
||||||
|
case '\xa7':
|
||||||
|
stralloc_cats(&str, "º");
|
||||||
|
break;
|
||||||
|
case '\xa8':
|
||||||
|
stralloc_cats(&str, "¿");
|
||||||
|
break;
|
||||||
|
case '\xa9':
|
||||||
|
stralloc_cats(&str, "⌐");
|
||||||
|
break;
|
||||||
|
case '\xaa':
|
||||||
|
stralloc_cats(&str, "¬");
|
||||||
|
break;
|
||||||
|
case '\xab':
|
||||||
|
stralloc_cats(&str, "½");
|
||||||
|
break;
|
||||||
|
case '\xac':
|
||||||
|
stralloc_cats(&str, "¼");
|
||||||
|
break;
|
||||||
|
case '\xad':
|
||||||
|
stralloc_cats(&str, "¡");
|
||||||
|
break;
|
||||||
|
case '\xae':
|
||||||
|
stralloc_cats(&str, "«");
|
||||||
|
break;
|
||||||
|
case '\xaf':
|
||||||
|
stralloc_cats(&str, "»");
|
||||||
|
break;
|
||||||
|
case '\xb0':
|
||||||
|
stralloc_cats(&str, "░");
|
||||||
|
break;
|
||||||
|
case '\xb1':
|
||||||
|
stralloc_cats(&str, "▒");
|
||||||
|
break;
|
||||||
|
case '\xb2':
|
||||||
|
stralloc_cats(&str, "▓");
|
||||||
|
break;
|
||||||
|
case '\xb3':
|
||||||
|
stralloc_cats(&str, "│");
|
||||||
|
break;
|
||||||
|
case '\xb4':
|
||||||
|
stralloc_cats(&str, "┤");
|
||||||
|
break;
|
||||||
|
case '\xb5':
|
||||||
|
stralloc_cats(&str, "╡");
|
||||||
|
break;
|
||||||
|
case '\xb6':
|
||||||
|
stralloc_cats(&str, "╢");
|
||||||
|
break;
|
||||||
|
case '\xb7':
|
||||||
|
stralloc_cats(&str, "╖");
|
||||||
|
break;
|
||||||
|
case '\xb8':
|
||||||
|
stralloc_cats(&str, "╕");
|
||||||
|
break;
|
||||||
|
case '\xb9':
|
||||||
|
stralloc_cats(&str, "╣");
|
||||||
|
break;
|
||||||
|
case '\xba':
|
||||||
|
stralloc_cats(&str, "║");
|
||||||
|
break;
|
||||||
|
case '\xbb':
|
||||||
|
stralloc_cats(&str, "╗");
|
||||||
|
break;
|
||||||
|
case '\xbc':
|
||||||
|
stralloc_cats(&str, "╝");
|
||||||
|
break;
|
||||||
|
case '\xbd':
|
||||||
|
stralloc_cats(&str, "╜");
|
||||||
|
break;
|
||||||
|
case '\xbe':
|
||||||
|
stralloc_cats(&str, "╛");
|
||||||
|
break;
|
||||||
|
case '\xbf':
|
||||||
|
stralloc_cats(&str, "┐");
|
||||||
|
break;
|
||||||
|
case '\xc0':
|
||||||
|
stralloc_cats(&str, "└");
|
||||||
|
break;
|
||||||
|
case '\xc1':
|
||||||
|
stralloc_cats(&str, "┴");
|
||||||
|
break;
|
||||||
|
case '\xc2':
|
||||||
|
stralloc_cats(&str, "┬");
|
||||||
|
break;
|
||||||
|
case '\xc3':
|
||||||
|
stralloc_cats(&str, "├");
|
||||||
|
break;
|
||||||
|
case '\xc4':
|
||||||
|
stralloc_cats(&str, "─");
|
||||||
|
break;
|
||||||
|
case '\xc5':
|
||||||
|
stralloc_cats(&str, "┼");
|
||||||
|
break;
|
||||||
|
case '\xc6':
|
||||||
|
stralloc_cats(&str, "╞");
|
||||||
|
break;
|
||||||
|
case '\xc7':
|
||||||
|
stralloc_cats(&str, "╟");
|
||||||
|
break;
|
||||||
|
case '\xc8':
|
||||||
|
stralloc_cats(&str, "╚");
|
||||||
|
break;
|
||||||
|
case '\xc9':
|
||||||
|
stralloc_cats(&str, "╔");
|
||||||
|
break;
|
||||||
|
case '\xca':
|
||||||
|
stralloc_cats(&str, "╩");
|
||||||
|
break;
|
||||||
|
case '\xcb':
|
||||||
|
stralloc_cats(&str, "╦");
|
||||||
|
break;
|
||||||
|
case '\xcc':
|
||||||
|
stralloc_cats(&str, "╠");
|
||||||
|
break;
|
||||||
|
case '\xcd':
|
||||||
|
stralloc_cats(&str, "═");
|
||||||
|
break;
|
||||||
|
case '\xce':
|
||||||
|
stralloc_cats(&str, "╬");
|
||||||
|
break;
|
||||||
|
case '\xcf':
|
||||||
|
stralloc_cats(&str, "╧");
|
||||||
|
break;
|
||||||
|
case '\xd0':
|
||||||
|
stralloc_cats(&str, "╨");
|
||||||
|
break;
|
||||||
|
case '\xd1':
|
||||||
|
stralloc_cats(&str, "╤");
|
||||||
|
break;
|
||||||
|
case '\xd2':
|
||||||
|
stralloc_cats(&str, "╥");
|
||||||
|
break;
|
||||||
|
case '\xd3':
|
||||||
|
stralloc_cats(&str, "╙");
|
||||||
|
break;
|
||||||
|
case '\xd4':
|
||||||
|
stralloc_cats(&str, "╛");
|
||||||
|
break;
|
||||||
|
case '\xd5':
|
||||||
|
stralloc_cats(&str, "╒");
|
||||||
|
break;
|
||||||
|
case '\xd6':
|
||||||
|
stralloc_cats(&str, "╓");
|
||||||
|
break;
|
||||||
|
case '\xd7':
|
||||||
|
stralloc_cats(&str, "╫");
|
||||||
|
break;
|
||||||
|
case '\xd8':
|
||||||
|
stralloc_cats(&str, "╪");
|
||||||
|
break;
|
||||||
|
case '\xd9':
|
||||||
|
stralloc_cats(&str, "┘");
|
||||||
|
break;
|
||||||
|
case '\xda':
|
||||||
|
stralloc_cats(&str, "┌");
|
||||||
|
break;
|
||||||
|
case '\xdb':
|
||||||
|
stralloc_cats(&str, "█");
|
||||||
|
break;
|
||||||
|
case '\xdc':
|
||||||
|
stralloc_cats(&str, "▄");
|
||||||
|
break;
|
||||||
|
case '\xdd':
|
||||||
|
stralloc_cats(&str, "▌");
|
||||||
|
break;
|
||||||
|
case '\xde':
|
||||||
|
stralloc_cats(&str, "▐");
|
||||||
|
break;
|
||||||
|
case '\xdf':
|
||||||
|
stralloc_cats(&str, "▀");
|
||||||
|
break;
|
||||||
|
case '\xe0':
|
||||||
|
stralloc_cats(&str, "α");
|
||||||
|
break;
|
||||||
|
case '\xe1':
|
||||||
|
stralloc_cats(&str, "β");
|
||||||
|
break;
|
||||||
|
case '\xe2':
|
||||||
|
stralloc_cats(&str, "Γ");
|
||||||
|
break;
|
||||||
|
case '\xe3':
|
||||||
|
stralloc_cats(&str, "π");
|
||||||
|
break;
|
||||||
|
case '\xe4':
|
||||||
|
stralloc_cats(&str, "Σ");
|
||||||
|
break;
|
||||||
|
case '\xe5':
|
||||||
|
stralloc_cats(&str, "σ");
|
||||||
|
break;
|
||||||
|
case '\xe6':
|
||||||
|
stralloc_cats(&str, "µ");
|
||||||
|
break;
|
||||||
|
case '\xe7':
|
||||||
|
stralloc_cats(&str, "τ");
|
||||||
|
break;
|
||||||
|
case '\xe8':
|
||||||
|
stralloc_cats(&str, "Φ");
|
||||||
|
break;
|
||||||
|
case '\xe9':
|
||||||
|
stralloc_cats(&str, "Θ");
|
||||||
|
break;
|
||||||
|
case '\xea':
|
||||||
|
stralloc_cats(&str, "Ω");
|
||||||
|
break;
|
||||||
|
case '\xeb':
|
||||||
|
stralloc_cats(&str, "δ");
|
||||||
|
break;
|
||||||
|
case '\xec':
|
||||||
|
stralloc_cats(&str, "∞");
|
||||||
|
break;
|
||||||
|
case '\xed':
|
||||||
|
stralloc_cats(&str, "∅");
|
||||||
|
break;
|
||||||
|
case '\xee':
|
||||||
|
stralloc_cats(&str, "∈");
|
||||||
|
break;
|
||||||
|
case '\xef':
|
||||||
|
stralloc_cats(&str, "∩");
|
||||||
|
break;
|
||||||
|
case '\xf0':
|
||||||
|
stralloc_cats(&str, "≡");
|
||||||
|
break;
|
||||||
|
case '\xf1':
|
||||||
|
stralloc_cats(&str, "±");
|
||||||
|
break;
|
||||||
|
case '\xf2':
|
||||||
|
stralloc_cats(&str, "≥");
|
||||||
|
break;
|
||||||
|
case '\xf3':
|
||||||
|
stralloc_cats(&str, "≤");
|
||||||
|
break;
|
||||||
|
case '\xf4':
|
||||||
|
stralloc_cats(&str, "⌠");
|
||||||
|
break;
|
||||||
|
case '\xf5':
|
||||||
|
stralloc_cats(&str, "⌡");
|
||||||
|
break;
|
||||||
|
case '\xf6':
|
||||||
|
stralloc_cats(&str, "÷");
|
||||||
|
break;
|
||||||
|
case '\xf7':
|
||||||
|
stralloc_cats(&str, "≈");
|
||||||
|
break;
|
||||||
|
case '\xf8':
|
||||||
|
stralloc_cats(&str, "°");
|
||||||
|
break;
|
||||||
|
case '\xf9':
|
||||||
|
stralloc_cats(&str, "∙");
|
||||||
|
break;
|
||||||
|
case '\xfa':
|
||||||
|
stralloc_cats(&str, "·");
|
||||||
|
break;
|
||||||
|
case '\xfb':
|
||||||
|
stralloc_cats(&str, "√");
|
||||||
|
break;
|
||||||
|
case '\xfc':
|
||||||
|
stralloc_cats(&str, "ⁿ");
|
||||||
|
break;
|
||||||
|
case '\xfd':
|
||||||
|
stralloc_cats(&str, "²");
|
||||||
|
break;
|
||||||
|
case '\xfe':
|
||||||
|
stralloc_cats(&str, "▪");
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
stralloc_cats(&str, " ");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
stralloc_append1(&str, *p);
|
stralloc_append1(&str, *p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stralloc_0(&str);
|
||||||
new_tag->data = str.s;
|
new_tag->data = str.s;
|
||||||
} else {
|
} else {
|
||||||
new_tag->tag = strdup(tag);
|
new_tag->tag = strdup(tag);
|
||||||
@ -48,6 +564,14 @@ struct www_tag *www_tag_new(char *tag, char *data) {
|
|||||||
return new_tag;
|
return new_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct www_tag *www_tag_duplicate(struct www_tag *oldtag) {
|
||||||
|
struct www_tag *newtag = www_tag_new(oldtag->tag, oldtag->data);
|
||||||
|
for (int i=0;i<oldtag->attribs.len;i++) {
|
||||||
|
www_tag_add_attrib(newtag, strdup(ptr_vector_get(&oldtag->attribs, i)), strdup(ptr_vector_get(&oldtag->values, i)));
|
||||||
|
}
|
||||||
|
return newtag;
|
||||||
|
}
|
||||||
|
|
||||||
void www_tag_add_attrib(struct www_tag *tag, char *attrib, char *value) {
|
void www_tag_add_attrib(struct www_tag *tag, char *attrib, char *value) {
|
||||||
ptr_vector_append(&tag->attribs, strdup(attrib));
|
ptr_vector_append(&tag->attribs, strdup(attrib));
|
||||||
ptr_vector_append(&tag->values, strdup(value));
|
ptr_vector_append(&tag->values, strdup(value));
|
||||||
|
@ -15,6 +15,7 @@ struct www_tag {
|
|||||||
|
|
||||||
extern struct www_tag *www_tag_new(char *tag, char *data);
|
extern struct www_tag *www_tag_new(char *tag, char *data);
|
||||||
extern void www_tag_add_attrib(struct www_tag *tag, char *attrib, char *value);
|
extern void www_tag_add_attrib(struct www_tag *tag, char *attrib, char *value);
|
||||||
|
extern struct www_tag *www_tag_duplicate(struct www_tag *oldtag);
|
||||||
extern void www_tag_add_child(struct www_tag *tag, struct www_tag *child);
|
extern void www_tag_add_child(struct www_tag *tag, struct www_tag *child);
|
||||||
extern char *www_tag_unwravel(struct www_tag *tag);
|
extern char *www_tag_unwravel(struct www_tag *tag);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user