#include "htf_common.hpp"
|
|
extern "C"
|
{
|
#include "utils/builtins.h"
|
#include "utils/elog.h"
|
}
|
|
namespace htf{
|
unsigned int symbol_digit(char *txtptr){
|
if(txtptr){
|
int encoding = GetDatabaseEncoding();
|
int char_len = pg_encoding_mblen(encoding, txtptr);
|
if(char_len == 1)
|
return (unsigned char)txtptr[0];
|
else{
|
pg_wchar wc_buf[2];
|
int conv = pg_mb2wchar_with_len(txtptr, wc_buf, char_len);
|
if (conv > 0){
|
return (unsigned int)wc_buf[0];
|
}
|
}
|
}
|
return 0;
|
}
|
char *
|
escape_to_numeric_entity(text *input, bool full)
|
{
|
const char *data = VARDATA_ANY(input);
|
int len = VARSIZE_ANY_EXHDR(input);
|
StringInfoData result;
|
|
/* Инициализация буфера для результата */
|
initStringInfo(&result);
|
if (len == 0)
|
return result.data;
|
|
int encoding = GetDatabaseEncoding();
|
int byte_pos = 0;
|
|
while (byte_pos < len)
|
{
|
int char_len = pg_encoding_mblen(encoding, data + byte_pos);
|
if (char_len <= 0 || byte_pos + char_len > len)
|
break;
|
|
if (char_len == 1)
|
{
|
unsigned char c = data[byte_pos];
|
if(full) {
|
if(c == '"'){
|
appendStringInfo(&result, """);
|
byte_pos += char_len;
|
continue;
|
}
|
if(c == '<'){
|
appendStringInfo(&result, "<");
|
byte_pos += char_len;
|
continue;
|
}
|
if(c == '>'){
|
appendStringInfo(&result, ">");
|
byte_pos += char_len;
|
continue;
|
}
|
if(c == '&'){
|
appendStringInfo(&result, "&");
|
byte_pos += char_len;
|
continue;
|
}
|
if(c<='~'){
|
appendStringInfoChar(&result, c);
|
byte_pos += char_len;
|
continue;
|
}
|
}
|
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
|
(c >= '0' && c <= '9') || c == '_' || c == '-' || c == '.' ||
|
c == ',')
|
{
|
appendStringInfoChar(&result, c);
|
byte_pos += char_len;
|
continue;
|
}
|
}
|
|
/* Для однобайтовых небезопасных и многобайтовых — декодируем */
|
pg_wchar wc_buf[2];
|
int conv = pg_mb2wchar_with_len(data + byte_pos, wc_buf, char_len);
|
if (conv > 0){
|
int digits = 1;
|
unsigned int temp = wc_buf[0];
|
while (temp > 15) {
|
temp >>= 4;
|
digits++;
|
}
|
// Если цифр нечётное - увеличиваем на 1 (добавим один ведущий ноль)
|
if (digits % 2 != 0) {
|
digits++;
|
}
|
appendStringInfo(&result, "&#x%0*X;", digits, (unsigned int) wc_buf[0]);
|
}
|
else
|
appendStringInfoChar(&result, '?');
|
|
byte_pos += char_len;
|
}
|
|
return result.data;
|
}
|
char *
|
escape_to_ltgt(text *input)
|
{
|
const char *data = VARDATA_ANY(input);
|
int len = VARSIZE_ANY_EXHDR(input);
|
StringInfoData result;
|
|
/* Инициализация буфера для результата */
|
initStringInfo(&result);
|
if (len == 0)
|
return result.data;
|
|
int encoding = GetDatabaseEncoding();
|
int byte_pos = 0;
|
|
while (byte_pos < len)
|
{
|
int char_len = pg_encoding_mblen(encoding, data + byte_pos);
|
if (char_len <= 0 || byte_pos + char_len > len)
|
break;
|
|
if (char_len == 1)
|
{
|
unsigned char c = data[byte_pos];
|
|
if(c == '<'){
|
appendStringInfo(&result, "<");
|
byte_pos += char_len;
|
continue;
|
}
|
if(c == '>'){
|
appendStringInfo(&result, ">");
|
byte_pos += char_len;
|
continue;
|
}
|
|
// просто добавление любого однобайтового символа
|
appendStringInfoChar(&result, c);
|
byte_pos += char_len;
|
continue;
|
|
}
|
|
const char *sym = data + byte_pos;
|
for(int i = 0; i<char_len; i++){
|
appendStringInfoChar(&result, sym[i]);
|
}
|
byte_pos += char_len;
|
}
|
|
return result.data;
|
}
|
char *escape_special_chars(text *input){
|
if(input == NULL)
|
return NULL;
|
char *str = text_to_cstring(input);
|
xmlBufferPtr buf = xmlBufferCreate();
|
if (!buf) return NULL;
|
xmlOutputBufferPtr out = xmlOutputBufferCreateBuffer(buf, NULL);
|
if (!out) {
|
xmlBufferFree(buf);
|
return NULL;
|
}
|
|
xmlChar *escaped_code = xmlEncodeSpecialChars(NULL, (xmlChar*)str);
|
xmlOutputBufferWriteString(out, (char*)escaped_code);
|
xmlFree(escaped_code);
|
pfree(str);
|
|
|
xmlOutputBufferFlush(out);
|
const xmlChar *content = xmlBufferContent(buf);
|
size_t len = xmlBufferLength(buf);
|
|
char *result = (char*)palloc(len + 1);
|
if (result) {
|
memcpy(result, content, len);
|
result[len] = '\0';
|
}
|
|
xmlOutputBufferClose(out); // также освобождает buf
|
return result; // освобождать через pfree()
|
}
|
char *
|
get_string_argument(FunctionCallInfo fcinfo, int argnum, StringEscapeFormat type)
|
{
|
if (PG_ARGISNULL(argnum))
|
return NULL;
|
text *arg_txt = PG_GETARG_TEXT_PP(argnum);
|
char *result = NULL;
|
if (VARSIZE_ANY_EXHDR(arg_txt) == 0)
|
return NULL;
|
switch(type){
|
case StringEscapeFormatSpecialChars:
|
result = escape_special_chars(arg_txt);
|
break;
|
case StringEscapeFormatOracle:
|
result = escape_to_numeric_entity(arg_txt);
|
break;
|
case StringEscapeFormatOracleFull:
|
result = escape_to_numeric_entity(arg_txt, true);
|
break;
|
case StringEscapeFormatNone:
|
result = text_to_cstring(arg_txt);
|
default:
|
result = escape_to_ltgt(arg_txt);
|
break;
|
}
|
return result;
|
}
|
char *
|
get_numeric_argument_as_string(FunctionCallInfo fcinfo, int argnum)
|
{
|
/* Проверяем, не NULL ли аргумент */
|
if (PG_ARGISNULL(argnum))
|
return NULL;
|
|
/* Получаем Datum с аргументом типа NUMERIC */
|
Datum numeric_datum = PG_GETARG_DATUM(argnum);
|
|
/* Преобразуем NUMERIC в C-строку через выходную функцию типа */
|
Datum str_datum = DirectFunctionCall1(numeric_out, numeric_datum);
|
|
/* Возвращаем строку (char* уже в памяти palloc) */
|
return DatumGetCString(str_datum);
|
}
|
void append_attribute_string(StringInfo res, const char *value){
|
if(value)
|
appendStringInfo(res, " %s", value);
|
}
|
void append_attribute_quot(StringInfo res, const char *name, const char *value, bool nullvalok){
|
if(name){
|
if(value)
|
appendStringInfo(res, " %s=\"%s\"", name, value);
|
else{
|
if(nullvalok)
|
appendStringInfo(res, " %s=\"\"", name);
|
}
|
}
|
}
|
void append_attribute(StringInfo res, const char *name, const char *value, bool nullvalok){
|
if(name){
|
if(value)
|
appendStringInfo(res, " %s=%s", name, value);
|
else{
|
if(nullvalok)
|
appendStringInfo(res, " %s=", name);
|
}
|
}
|
}
|
|
text *generate_applet_tag(const char *ccode, const char *cwidth, const char *cheight, const char *cattr){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<applet");
|
|
append_attribute(result, "code", ccode);
|
append_attribute(result, "width", cwidth);
|
append_attribute(result, "height", cheight);
|
append_attribute_string(result, cattr);
|
|
|
appendStringInfo(result, ">");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_address_tag(const char *cvalue, const char *cnowrap, const char *cclear, const char *cattr)
|
{
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<address");
|
|
append_attribute_quot(result, "clear", cclear);
|
if(cnowrap){
|
appendStringInfo(result, " nowrap=\"nowrap\"");
|
}
|
append_attribute_string(result, cattr);
|
|
|
appendStringInfo(result, ">%s</address>", cvalue ? cvalue : "");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_body_tag(const char *cbackground, const char *cattr)
|
{
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<body");
|
|
append_attribute_quot(result, "background", cbackground);
|
append_attribute_string(result, cattr);
|
|
appendStringInfo(result, ">");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_formselect_tag(const char *cname, const char *cprompt, const char *csize, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
if(cprompt){
|
appendStringInfo(result, "%s", cprompt);
|
}
|
appendStringInfo(result, "<select");
|
|
append_attribute_quot(result, "name", cname);
|
append_attribute_quot(result, "size", csize);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_map_tag(const char *cname, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<map");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_formtext_tag(const char *cname, const char *csize, const char *cmaxlength, const char *cvalue, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"text\"");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_quot(result, "size", csize);
|
append_attribute_quot(result, "maxlength", cmaxlength);
|
append_attribute_quot(result, "value", cvalue);
|
|
if(cattributes){
|
appendStringInfo(result, " %s", cattributes);
|
}
|
appendStringInfo(result, " />");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_textarea_tag(const char *cname, const char *crows, const char *ccols, const char * calign, const char *cattributes,
|
const char *cwrap){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<textarea");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_quot(result, "rows", crows, true);
|
append_attribute_quot(result, "cols", ccols, true);
|
append_attribute_quot(result, "align", calign);
|
append_attribute_quot(result, "wrap", cwrap);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_formtextarea_tag(const char *cname, const char *crows, const char *ccolumns, const char *calign, const char *cattributes,
|
const char *cwrap){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<textarea");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_quot(result, "rows", crows, true);
|
append_attribute_quot(result, "cols", ccolumns, true);
|
append_attribute_quot(result, "align", calign);
|
append_attribute_quot(result, "wrap", cwrap);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, "></textarea>");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_anchor_tag(const char *curl, const char *ctext, const char *cname, const char *cattributes,
|
const char *ctarget){
|
StringInfo result = makeStringInfo();
|
if(curl == NULL || cname == NULL){
|
appendStringInfo(result, "<!-- ERROR in anchor2 usage, curl and cname cannot be NULL --><a name=\" \">");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
appendStringInfo(result, "<a");
|
|
append_attribute_quot(result, "href", curl);
|
append_attribute_quot(result, "name", cname);
|
append_attribute_quot(result, "target", ctarget);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">%s</a>", ctext ? ctext : "");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_area_tag(const char *ccoord, const char *cshape, const char *chref, const char *cnohref, const char *ctarget, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<area");
|
|
append_attribute_quot(result, "shape", cshape);
|
append_attribute_quot(result, "coords", ccoord, true);
|
append_attribute_quot(result, "href", chref);
|
if(cnohref){
|
appendStringInfo(result, " nohref=\"nohref\"");
|
}
|
append_attribute_quot(result, "target", ctarget);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, " />");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_basefont_tag(const char *csize, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<basefont");
|
|
append_attribute_quot(result, "size", csize, true);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, " />");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_bgsound_tag(const char *csrc, const char *cloop, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<bgsound");
|
|
append_attribute_quot(result, "src", csrc, true);
|
append_attribute_quot(result, "loop", cloop);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">");
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text* generate_big_tag(const char *ctext, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<big");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">");
|
appendStringInfo(result, "%s</big>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_blockquote_tag(bool cnowrap, const char *cclear, const char * cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<blockquote");
|
|
append_attribute_quot(result, "clear", cclear);
|
if(cnowrap){
|
appendStringInfo(result, " nowrap=\"nowrap\"");
|
}
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_bold_tag(const char *ctext, const char *cattr){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<b");
|
|
append_attribute_string(result, cattr);
|
appendStringInfo(result, ">%s</b>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_br_tag(const char *cclear, const char * cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<br");
|
|
append_attribute_quot(result, "clear", cclear);
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_center_tag(const char *ctext){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<center>");
|
|
appendStringInfo(result, "%s</center>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_cite_tag(const char *ctext, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<cite");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s</cite>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_code_tag(const char *ctext, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<code");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s</code>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_comment_tag(const char *ctext){
|
StringInfo result = makeStringInfo();
|
|
appendStringInfo(result, "<!-- ''%s -->", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_dfn_tag(const char *ctext, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<dfn");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s</dfn>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_div_tag(const char *calign, const char * cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<div");
|
|
append_attribute_quot(result, "align", calign);
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_dlistdef_tag(const char *ctext, const char *cclear, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<dd");
|
|
append_attribute_quot(result, "clear", cclear);
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_dlistopen_tag(const char *cclear, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<dl");
|
|
append_attribute_quot(result, "clear", cclear);
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_dlistterm_tag(const char *ctext, const char *cclear, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<dt");
|
|
append_attribute_quot(result, "clear", cclear);
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_em_tag(const char *ctext, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<em");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s</em>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_font_tag(const char *ccolor, const char *cface, const char *csize, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<font");
|
|
append_attribute_quot(result, "color", ccolor);
|
append_attribute_quot(result, "face", cface);
|
append_attribute_quot(result, "size", csize);
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_tabledata_tag(const char *cvalue, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<td");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">");
|
|
if (cvalue) {
|
appendStringInfo(result, "%s", cvalue);
|
}
|
|
appendStringInfo(result, "</td>");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_formcheckbox_tag(const char *cname, const char *cvalue, const char *cchecked, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"checkbox\"");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_quot(result, "value", cvalue);
|
|
if(cchecked){
|
appendStringInfo(result, " checked=\"checked\"");
|
}
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formfile_tag(const char *cname, const char *caccept, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"file\"");
|
|
append_attribute_quot(result, "name", cname);
|
append_attribute_quot(result, "accept", caccept);
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formhidden_tag(const char *cname, const char *cvalue, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"hidden\"");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_quot(result, "value", cvalue, true);
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formimage_tag(const char *cname, const char *cvalue, const char *calign, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"image\"");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_quot(result, "src", cvalue, true);
|
append_attribute_quot(result, "align", calign);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formopen_tag(const char *curl, const char *cmethod, const char *ctarget, const char *cenctype, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<form");
|
|
append_attribute_quot(result, "action", curl, true);
|
append_attribute_quot(result, "method", cmethod, true);
|
append_attribute_quot(result, "target", ctarget);
|
append_attribute_quot(result, "enctype", cenctype);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formpassword_tag(const char *cname, const char *csize, const char *cmaxlength, const char *cvalue, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"password\"");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_quot(result, "size", csize);
|
append_attribute_quot(result, "maxlength", cmaxlength);
|
append_attribute_quot(result, "value", cvalue);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formradio_tag(const char *cname, const char *cvalue, const char *cchecked, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"radio\"");
|
|
append_attribute_quot(result, "name", cname, true);
|
append_attribute_quot(result, "value", cvalue, true);
|
|
if(cchecked){
|
appendStringInfo(result, " checked=\"checked\"");
|
}
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formreset_tag(const char *cvalue, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"reset\"");
|
|
append_attribute_quot(result, "VALUE", cvalue, true);
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formselectoption_tag(const char *cvalue, const char *cselected, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<option");
|
|
if(cselected){
|
appendStringInfo(result, " selected=\"selected\"");
|
}
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s</option>", cvalue ? cvalue : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_formsubmit_tag(const char *cname, const char *cvalue, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<input type=\"submit\"");
|
|
append_attribute_quot(result, "name", cname);
|
append_attribute_quot(result, "value", cvalue);
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_frame_tag(const char *csrc, const char *cname, const char *cmarginwidth, const char *cmarginheight, const char *cscrolling, const char *cnoresize, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<frame");
|
|
append_attribute_quot(result, "src", csrc, true);
|
append_attribute_quot(result, "name", cname);
|
append_attribute_quot(result, "marginwidth", cmarginwidth);
|
append_attribute_quot(result, "marginheight", cmarginheight);
|
append_attribute_quot(result, "scrolling", cscrolling);
|
if(cnoresize){
|
appendStringInfo(result, " noresize=\"noresize\"");
|
}
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_frameset_tag(const char *crows, const char *ccols, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<frameset");
|
|
append_attribute_quot(result, "rows", crows);
|
append_attribute_quot(result, "cols", ccols);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_header_tag(const char *clevel, const char *cheader, const char *calign, const char *cnowrap, const char *cclear, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<h%s", clevel ? clevel : "");
|
|
append_attribute_quot(result, "align", calign);
|
append_attribute_quot(result, "clear", cclear);
|
if(cnowrap){
|
appendStringInfo(result, " nowrap=\"nowrap\"");
|
}
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">%s</h%s>", cheader ? cheader : "", clevel ? clevel : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_hr_tag(const char *cclear, const char *csrc, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<hr");
|
|
append_attribute_quot(result, "clear", cclear, false);
|
append_attribute_quot(result, "src", csrc, false);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_htitle_tag(const char *ctitle, const char *csize, const char *calign, const char *cnowrap, const char *cclear, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
|
// Генерируем тег <title>
|
appendStringInfo(result, "<title>%s</title>", ctitle ? ctitle : "");
|
|
// Генерируем тег <h>
|
appendStringInfo(result, "<h%s", csize ? csize : "");
|
|
append_attribute_quot(result, "align", calign);
|
append_attribute_quot(result, "clear", cclear);
|
if(cnowrap){
|
appendStringInfo(result, " nowrap=\"nowrap\"");
|
}
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">%s</h%s>", ctitle ? ctitle : "", csize ? csize : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_img_tag(const char *csrc, const char *calign, const char *calt, const char *cismap, const char *cattributes, const char *cusemap){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<img");
|
|
append_attribute_quot(result, "src", csrc, true);
|
append_attribute_quot(result, "align", calign);
|
append_attribute_quot(result, "alt", calt);
|
if(cismap){
|
appendStringInfo(result, " ismap=\"ismap\"");
|
}
|
append_attribute_quot(result, "usemap", cusemap);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_isindex_tag(const char *cprompt, const char *chref){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<isindex");
|
|
append_attribute_quot(result, "prompt", cprompt);
|
append_attribute_quot(result, "href", chref);
|
|
appendStringInfo(result, ">");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_italic_tag(const char *ctext, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<i");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s</i>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_kbd_tag(const char *ctext, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<kbd");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s</kbd>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_linkrel_tag(const char *crel, const char *curl, const char *ctitle,
|
bool rel_is_rev){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<link");
|
|
append_attribute_quot(result, rel_is_rev ? "rev":"rel", crel, true);
|
append_attribute_quot(result, "href", curl, true);
|
append_attribute_quot(result, "title", ctitle);
|
appendStringInfo(result, " />");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
text *generate_listheader_tag(const char *ctext, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<lh");
|
|
append_attribute_string(result, cattributes);
|
appendStringInfo(result, ">%s</lh>", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
text *generate_listitem_tag(const char *ctext, const char *cclear, const char *cdingbat, const char *csrc, const char *cattributes){
|
StringInfo result = makeStringInfo();
|
appendStringInfo(result, "<li");
|
|
|
append_attribute_quot(result, "clear", cclear);
|
append_attribute_quot(result, "dingbat", cdingbat);
|
append_attribute_quot(result, "src", csrc);
|
append_attribute_string(result, cattributes);
|
|
appendStringInfo(result, ">%s", ctext ? ctext : "");
|
|
text *ret = cstring_to_text(result->data);
|
destroyStringInfo(result);
|
return ret;
|
}
|
|
} // namespace htf
|
extern "C"
|
{
|
} // extern "C"
|