Another string.
This commit is contained in:
11
src/form.cc
11
src/form.cc
@ -150,7 +150,7 @@ public: //BUG: for now everything is public
|
||||
entries, it is the initial value */
|
||||
DilloHtmlSelect *select;
|
||||
bool init_val; /* only meaningful for buttons */
|
||||
Dstr *file_data; /* only meaningful for file inputs.
|
||||
std::string file_data; /* only meaningful for file inputs.
|
||||
TODO: may become a list... */
|
||||
|
||||
private:
|
||||
@ -1639,7 +1639,6 @@ DilloHtmlInput::DilloHtmlInput (DilloHtmlInputType type2, Embed *embed2,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
file_data = NULL;
|
||||
reset ();
|
||||
}
|
||||
|
||||
@ -1648,7 +1647,6 @@ DilloHtmlInput::DilloHtmlInput (DilloHtmlInputType type2, Embed *embed2,
|
||||
*/
|
||||
DilloHtmlInput::~DilloHtmlInput ()
|
||||
{
|
||||
dStr_free(file_data, 1);
|
||||
if (select)
|
||||
delete select;
|
||||
}
|
||||
@ -1714,9 +1712,8 @@ void DilloHtmlInput::readFile (BrowserWindow *bw)
|
||||
const char *filename = a_UIcmd_select_file();
|
||||
if (filename) {
|
||||
a_UIcmd_set_msg(bw, "Loading file...");
|
||||
dStr_free(file_data, 1);
|
||||
file_data = a_Misc_file2dstr(filename);
|
||||
if (file_data) {
|
||||
if (not file_data.empty()) {
|
||||
a_UIcmd_set_msg(bw, "File loaded.");
|
||||
LabelButtonResource *lbr = (LabelButtonResource*)embed->getResource();
|
||||
lbr->setLabel(filename);
|
||||
@ -1775,8 +1772,8 @@ void DilloHtmlInput::appendValuesTo(std::vector< std::string > &values, bool is_
|
||||
LabelButtonResource *lbr = (LabelButtonResource*)embed->getResource();
|
||||
const char *filename = lbr->getLabel();
|
||||
if (filename[0] && strcmp(filename, init_str.value().c_str())) {
|
||||
if (file_data) {
|
||||
values.push_back( file_data->str );
|
||||
if (not file_data.empty()) {
|
||||
values.push_back( file_data );
|
||||
} else {
|
||||
MSG("FORM file input \"%s\" not loaded.\n", filename);
|
||||
}
|
||||
|
||||
@ -466,19 +466,18 @@ char *a_Misc_encode_base64(const char *in)
|
||||
* Return value: dStr on success, NULL on error.
|
||||
* TODO: a filesize threshold may be implemented.
|
||||
*/
|
||||
Dstr *a_Misc_file2dstr(const char *filename)
|
||||
std::string a_Misc_file2dstr(const char *filename)
|
||||
{
|
||||
FILE *F_in;
|
||||
int n;
|
||||
char buf[4096];
|
||||
Dstr *dstr = NULL;
|
||||
std::string str;
|
||||
|
||||
if ((F_in = fopen(filename, "r"))) {
|
||||
dstr = dStr_sized_new(4096);
|
||||
while ((n = fread (buf, 1, 4096, F_in)) > 0) {
|
||||
dStr_append_l(dstr, buf, n);
|
||||
std::copy_n( buf, n, std::back_inserter( str ) );
|
||||
}
|
||||
fclose(F_in);
|
||||
}
|
||||
return dstr;
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include <string_view>
|
||||
std::string a_Misc_escape_chars(std::string_view str, std::string_view esc_set);
|
||||
std::optional< std::string > a_Misc_parse_content_type(const char *str, char **major, char **minor);
|
||||
std::string a_Misc_file2dstr(const char *filename);
|
||||
#endif
|
||||
|
||||
int a_Misc_expand_tabs(char **start, char *end, char *buf, int buflen);
|
||||
@ -19,4 +20,3 @@ int a_Misc_content_type_cmp(const char* ct1, const char *ct2);
|
||||
int a_Misc_parse_geometry(char *geom, int *x, int *y, int *w, int *h);
|
||||
int a_Misc_parse_search_url(char *source, char **label, char **urlstr);
|
||||
char *a_Misc_encode_base64(const char *in);
|
||||
Dstr *a_Misc_file2dstr(const char *filename);
|
||||
|
||||
@ -1074,12 +1074,11 @@ void StyleEngine::init () {
|
||||
}
|
||||
|
||||
void StyleEngine::buildUserStyle () {
|
||||
Dstr *style;
|
||||
char *filename = dStrconcat(dGethomedir(), "/.flenser/style.css", NULL);
|
||||
|
||||
if ((style = a_Misc_file2dstr(filename))) {
|
||||
CssParser::parse (NULL,NULL,cssContext,style->str, style->len,CSS_ORIGIN_USER);
|
||||
dStr_free (style, 1);
|
||||
const std::string style= a_Misc_file2dstr(filename);
|
||||
if (not style.empty()) {
|
||||
CssParser::parse (NULL,NULL,cssContext, style.c_str(), style.size(), CSS_ORIGIN_USER);
|
||||
}
|
||||
dFree (filename);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user