//-------------------------------------------------------------- // constructor mgFormParser::mgFormParser( mgFormPane* form) { m_cntlNames = NULL; m_form = form; pushCntl(m_form); pushText(m_form->m_text); }
void editMailcap(char *mailcap, struct parsed_tagarg *args) { TextList *t = newTextList(); TextListItem *ti; FILE *f; Str tmp; char *type, *viewer; struct parsed_tagarg *a; bool delete_it; if ((f = fopen(mailcap, "rt")) == NULL) bye("Can't open", mailcap); while (tmp = Strfgets(f), tmp->length > 0) { if (tmp->ptr[0] == '#') continue; Strchop(tmp); extractMailcapEntry(tmp->ptr, &type, &viewer); delete_it = false; for (a = args; a != NULL; a = a->next) { if (!strcmp(a->arg, "delete") && !strcmp(a->value, type)) { delete_it = true; break; } } if (!delete_it) pushText(t, Sprintf("%s;\t%s\n", type, viewer)->ptr); } type = tag_get_value(args, "newtype"); viewer = tag_get_value(args, "newcmd"); if (type != NULL && *type != '\0' && viewer != NULL && *viewer != '\0') pushText(t, Sprintf("%s;\t%s\n", type, viewer)->ptr); fclose(f); if ((f = fopen(mailcap, "w")) == NULL) bye("Can't write to", mailcap); for (ti = t->first; ti != NULL; ti = ti->next) fputs(ti->ptr, f); fclose(f); printf("Content-Type: text/plain\n"); printf("w3m-control: BACK\nw3m-control: BACK\n"); printf("w3m-control: REINIT MAILCAP\n"); }
char * acceptableMimeTypes() { static Str types = NULL; TextList *l; Hash_si *mhash; char *p; int i; if (types != NULL) return types->ptr; /* generate acceptable media types */ l = newTextList(); mhash = newHash_si(16); /* XXX */ /* pushText(l, "text"); */ putHash_si(mhash, "text", 1); pushText(l, "image"); putHash_si(mhash, "image", 1); for (i = 0; i < mailcap_list->nitem; i++) { struct mailcap *mp = UserMailcap[i]; char *mt; if (mp == NULL) continue; for (; mp->type; mp++) { p = strchr(mp->type, '/'); if (p == NULL) continue; mt = allocStr(mp->type, p - mp->type); if (getHash_si(mhash, mt, 0) == 0) { pushText(l, mt); putHash_si(mhash, mt, 1); } } } types = Strnew(); Strcat_charp(types, "text/html, text/*;q=0.5"); while ((p = popText(l)) != NULL) { Strcat_charp(types, ", "); Strcat_charp(types, p); Strcat_charp(types, "/*"); } return types->ptr; }
//-------------------------------------------------------------- // constructor mgFormParser::mgFormParser( mgFormPane* form, const char* fileName) { m_cntlNames = NULL; m_form = form; pushCntl(m_form); pushText(m_form->m_text); parseFile(fileName); }
int insert_bookmark(char *bmark, struct parsed_tagarg *data) { char *url, *title, *section; FILE *f; TextList *tl = newTextList(); int section_found = 0; int bmark_added = 0; Str tmp, section_tmp; url = tag_get_value(data, "url"); title = tag_get_value(data, "title"); section = tag_get_value(data, "newsection"); if (section == NULL || *section == '\0') section = tag_get_value(data, "section"); if (section == NULL || *section == '\0') section = DEFAULT_SECTION; if (url == NULL || *url == '\0' || title == NULL || *title == '\0') { /* Bookmark not added */ return FALSE; } url = html_quote(url); title = html_quote(title); section = html_quote(section); f = fopen(bmark, "r"); if (f == NULL) return create_new_bookmark(bmark, section, title, url, "w"); section_tmp = Sprintf("<h2>%s</h2>\n", section); for (;;) { tmp = Strfgets(f); if (tmp->length == 0) break; if (Strcasecmp(tmp, section_tmp) == 0) section_found = 1; if (section_found && !bmark_added) { Strremovefirstspaces(tmp); if (Strcmp_charp(tmp, end_section) == 0) { pushText(tl, Sprintf("<li><a href=\"%s\">%s</a>\n", url, title)->ptr); bmark_added = 1; } } if (!bmark_added && Strcasecmp_charp(tmp, "</body>\n") == 0) { pushText(tl, Sprintf("<h2>%s</h2>\n<ul>\n", section)->ptr); pushText(tl, Sprintf("<li><a href=\"%s\">%s</a>\n", url, title)->ptr); pushText(tl, end_section); pushText(tl, "</ul>\n"); bmark_added = 1; } pushText(tl, tmp->ptr); } fclose(f); if (!bmark_added) { /* Bookmark not added; perhaps the bookmark file is ill-formed */ /* In this case, a new bookmark is appeneded after the bookmark file */ return create_new_bookmark(bmark, section, title, url, "a"); } f = fopen(bmark, "w"); while (tl->nitem) { fputs(popText(tl), f); } fclose(f); return TRUE; }