int LYUpload_options( char **newfile, char *directory ) { static char tempfile[256]; static char curloc[256]; FILE *fp0 = InternalPageFP( tempfile, 1 ); lynx_list_item_type *cur_upload; int count; char *cp; if ( fp0 == 0 ) { return -1; } cp = HTnameOfFile_WWW( directory, 0, 1 ); strcpy( curloc, cp ); LYTrimPathSep( curloc ); if ( cp != 0 ) { free( cp ); cp = 0; } LYLocalFileToURL( newfile, tempfile ); LYRegisterUIPage( newfile, 10 ); BeginInternalPage( fp0, gettext( "Upload Options" ), "Lynx_users_guide.html.gz#DirEd" ); fwrite( "<pre>\n", 1, 6, fp0 ); fprintf( fp0, " <em>%s</em> %s\n", gettext( "Upload To:" ), curloc ); fprintf( fp0, "\n%s\n", gettext( "Upload options:" ) ); if ( uploaders != 0 ) { count = 0; cur_upload = uploaders; for ( ; cur_upload != 0; count++ ) { fprintf( fp0, " <a href=\"LYNXDIRED://UPLOAD=%d/TO=%s\">", count, curloc ); fputs( cur_upload->name == 0 ? gettext( "No Name Given" ) : cur_upload->name, fp0 ); fwrite( "</a>\n", 1, 5, fp0 ); cur_upload = &cur_upload; //count++; } } else fwrite( " <NONE>\n", 1, 16, fp0 ); fwrite( "</pre>\n", 1, 7, fp0 ); EndInternalPage( fp0 ); LYCloseTempFP( fp0 ); LYforce_no_cache = 1; return 0; }
/* * LYdownload_options writes out the current download choices to a file so that * the user can select downloaders in the same way that they select all other * links. Download links look like: * LYNXDOWNLOAD://Method=<#>/File=<STRING>/SugFile=<STRING> */ int LYdownload_options(char **newfile, char *data_file) { static char tempfile[LY_MAXPATH] = "\0"; char *downloaded_url = NULL; char *sug_filename = NULL; FILE *fp0; lynx_list_item_type *cur_download; int count; /* * Get a suggested filename. */ StrAllocCopy(sug_filename, *newfile); change_sug_filename(sug_filename); if ((fp0 = InternalPageFP(tempfile, TRUE)) == 0) return (-1); StrAllocCopy(downloaded_url, *newfile); LYLocalFileToURL(newfile, tempfile); LYStrNCpy(LYValidDownloadFile, data_file, (sizeof(LYValidDownloadFile) - 1)); LYforce_no_cache = TRUE; /* don't cache this doc */ BeginInternalPage(fp0, DOWNLOAD_OPTIONS_TITLE, DOWNLOAD_OPTIONS_HELP); fprintf(fp0, "<pre>\n"); fprintf(fp0, "<em>%s</em> %s\n", gettext("Downloaded link:"), downloaded_url); FREE(downloaded_url); fprintf(fp0, "<em>%s</em> %s\n", gettext("Suggested file name:"), sug_filename); fprintf(fp0, "\n%s\n", (user_mode == NOVICE_MODE) ? gettext("Standard download options:") : gettext("Download options:")); if (!no_disk_save) { #if defined(DIRED_SUPPORT) /* * Disable save to disk option for local files. */ if (!lynx_edit_mode) #endif /* DIRED_SUPPORT */ { fprintf(fp0, " <a href=\"%s//Method=-1/File=%s/SugFile=%s%s\">%s</a>\n", STR_LYNXDOWNLOAD, data_file, NonNull(lynx_save_space), sug_filename, gettext("Save to disk")); /* * If it is not a binary file, offer the opportunity to view the * downloaded temporary file (see HTSaveToFile). */ if (SuffixIs(data_file, HTML_SUFFIX) || SuffixIs(data_file, TEXT_SUFFIX)) { char *target = NULL; char *source = LYAddPathToSave(data_file); LYLocalFileToURL(&target, source); fprintf(fp0, " <a href=\"%s\">%s</a>\n", target, gettext("View temporary file")); FREE(source); FREE(target); } } } else { fprintf(fp0, " <em>%s</em>\n", gettext("Save to disk disabled.")); } if (user_mode == NOVICE_MODE) fprintf(fp0, "\n%s\n", gettext("Local additions:")); if (downloaders != NULL) { for (count = 0, cur_download = downloaders; cur_download != NULL; cur_download = cur_download->next, count++) { if (!no_download || cur_download->always_enabled) { fprintf(fp0, " <a href=\"%s//Method=%d/File=%s/SugFile=%s\">", STR_LYNXDOWNLOAD, count, data_file, sug_filename); fprintf(fp0, "%s", (cur_download->name ? cur_download->name : gettext("No Name Given"))); fprintf(fp0, "</a>\n"); } } } fprintf(fp0, "</pre>\n"); EndInternalPage(fp0); LYCloseTempFP(fp0); LYRegisterUIPage(*newfile, UIP_DOWNLOAD_OPTIONS); /* * Free off temp copy. */ FREE(sug_filename); return (0); }
/* * This procedure outputs the Visited Links list into a temporary file. - FM * Returns links's number to make active (1-based), or 0 if not required. */ int LYShowVisitedLinks(char **newfile) { static char tempfile[LY_MAXPATH] = "\0"; char *Title = NULL; char *Address = NULL; int x, tot; FILE *fp0; VisitedLink *vl; HTList *cur = Visited_Links; int offset; int ret = 0; const char *arrow, *post_arrow; if (!cur) return (-1); if ((fp0 = InternalPageFP(tempfile, TRUE)) == 0) return (-1); LYLocalFileToURL(newfile, tempfile); LYRegisterUIPage(*newfile, UIP_VLINKS); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ BeginInternalPage(fp0, VISITED_LINKS_TITLE, VISITED_LINKS_HELP); #ifndef NO_OPTION_FORMS fprintf(fp0, "<form action=\"%s\" method=\"post\">\n", STR_LYNXOPTIONS); LYMenuVisitedLinks(fp0, FALSE); fprintf(fp0, "<input type=\"submit\" value=\"Accept Changes\">\n"); fprintf(fp0, "</form>\n"); fprintf(fp0, "<P>\n"); #endif fprintf(fp0, "<pre>\n"); fprintf(fp0, "<em>%s</em>\n", gettext("You visited (POSTs, bookmark, menu and list files excluded):")); if (Visited_Links_As & VISITED_LINKS_REVERSE) tot = x = HTList_count(Visited_Links); else tot = x = -1; if (Visited_Links_As & VISITED_LINKS_AS_TREE) { vl = First_tree; } else if (Visited_Links_As & VISITED_LINKS_AS_LATEST) { if (Visited_Links_As & VISITED_LINKS_REVERSE) vl = Latest_last.prev_latest; else vl = Latest_first.next_latest; if (vl == &Latest_last || vl == &Latest_first) vl = NULL; } else { if (Visited_Links_As & VISITED_LINKS_REVERSE) vl = Last_by_first; else vl = (VisitedLink *) HTList_nextObject(cur); } while (NULL != vl) { /* * The number of the document (most recent highest), its title in a * link, and its address. - FM */ post_arrow = arrow = ""; if (Visited_Links_As & VISITED_LINKS_REVERSE) x--; else x++; if (vl == PrevActiveVisitedLink) { if (Visited_Links_As & VISITED_LINKS_REVERSE) ret = tot - x + 2; else ret = x + 3; } if (vl == PrevActiveVisitedLink) { post_arrow = "<A NAME=current></A>"; /* Otherwise levels 0 and 1 look the same when with arrow: */ arrow = (vl->level && (Visited_Links_As & VISITED_LINKS_AS_TREE)) ? "==>" : "=>"; StrAllocCat(*newfile, "#current"); } if (Visited_Links_As & VISITED_LINKS_AS_TREE) { offset = 2 * vl->level; if (offset > 24) offset = (offset + 24) / 2; if (offset > LYcols * 3 / 4) offset = LYcols * 3 / 4; } else offset = (x > 99 ? 0 : x < 10 ? 2 : 1); if (non_empty(vl->title)) { StrAllocCopy(Title, vl->title); LYEntify(&Title, TRUE); LYTrimLeading(Title); LYTrimTrailing(Title); if (*Title == '\0') StrAllocCopy(Title, NO_TITLE); } else { StrAllocCopy(Title, NO_TITLE); } if (non_empty(vl->address)) { StrAllocCopy(Address, vl->address); LYEntify(&Address, FALSE); fprintf(fp0, "%-*s%s<em>%d</em>. <tab id=t%d><a href=\"%s\">%s</a>\n", offset, arrow, post_arrow, x, x, Address, Title); } else { fprintf(fp0, "%-*s%s<em>%d</em>. <tab id=t%d><em>%s</em>\n", offset, arrow, post_arrow, x, x, Title); } if (Address != NULL) { StrAllocCopy(Address, vl->address); LYEntify(&Address, TRUE); } fprintf(fp0, "<tab to=t%d>%s\n", x, ((Address != NULL) ? Address : gettext("(no address)"))); if (Visited_Links_As & VISITED_LINKS_AS_TREE) vl = vl->next_tree; else if (Visited_Links_As & VISITED_LINKS_AS_LATEST) { if (Visited_Links_As & VISITED_LINKS_REVERSE) vl = vl->prev_latest; else vl = vl->next_latest; if (vl == &Latest_last || vl == &Latest_first) vl = NULL; } else { if (Visited_Links_As & VISITED_LINKS_REVERSE) vl = vl->prev_first; else vl = (VisitedLink *) HTList_nextObject(cur); } } fprintf(fp0, "</pre>\n"); EndInternalPage(fp0); LYCloseTempFP(fp0); FREE(Title); FREE(Address); return (ret); }
int showlist(DocInfo *newdoc, BOOLEAN titles) { int cnt; int refs, hidden_links; static char tempfile[LY_MAXPATH]; static BOOLEAN last_titles = TRUE; FILE *fp0; char *Address = NULL, *Title = NULL, *cp = NULL; char *LinkTitle = NULL; /* Rel stored as property of link, not of dest */ BOOLEAN intern_w_post = FALSE; const char *desc = "unknown field or link"; void *helper; refs = HText_sourceAnchors(HTMainText); hidden_links = HText_HiddenLinkCount(HTMainText); if (refs <= 0 && hidden_links > 0 && LYHiddenLinks != HIDDENLINKS_SEPARATE) { HTUserMsg(NO_VISIBLE_REFS_FROM_DOC); return (-1); } if (refs <= 0 && hidden_links <= 0) { HTUserMsg(NO_REFS_FROM_DOC); return (-1); } if ((fp0 = InternalPageFP(tempfile, titles == last_titles)) == 0) return (-1); LYLocalFileToURL(&(newdoc->address), tempfile); LYRegisterUIPage(newdoc->address, titles ? UIP_LIST_PAGE : UIP_ADDRLIST_PAGE); last_titles = titles; LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ #ifdef EXP_ADDRLIST_PAGE if (titles != TRUE) BeginInternalPage(fp0, ADDRLIST_PAGE_TITLE, LIST_PAGE_HELP); else #endif BeginInternalPage(fp0, LIST_PAGE_TITLE, LIST_PAGE_HELP); StrAllocCopy(Address, HTLoadedDocumentURL()); LYEntify(&Address, FALSE); fprintf(fp0, "%s%s<p>\n", gettext("References in "), (non_empty(Address) ? Address : gettext("this document:"))); FREE(Address); if (refs > 0) { fprintf(fp0, "<%s compact>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol" : "ul")); if (hidden_links > 0) fprintf(fp0, "<lh><em>%s</em>\n", gettext("Visible links:")); } if (hidden_links > 0) { if (LYHiddenLinks == HIDDENLINKS_IGNORE) hidden_links = 0; } helper = NULL; /* init */ for (cnt = 1; cnt <= refs; cnt++) { HTChildAnchor *child = HText_childNextNumber(cnt, &helper); HTAnchor *dest_intl = NULL; HTAnchor *dest; HTParentAnchor *parent; char *address; const char *title; if (child == 0) { /* * child should not be 0 unless form field numbering is on and cnt * is the number of a form input field. HText_FormDescNumber() * will set desc to a description of what type of input field this * is. We'll list it to ensure that the link numbers on the list * page match the numbering in the original document, but won't * create a forward link to the form. - FM && LE * * Changed to create a fake hidden link, to get the numbering right * in connection with always treating this file as * HIDDENLINKS_MERGE in GridText.c - kw */ if (fields_are_numbered()) { HText_FormDescNumber(cnt, &desc); fprintf(fp0, "<li><a id=%d href=\"#%d\">form field</a> = <em>%s</em>\n", cnt, cnt, desc); } continue; } #ifndef DONT_TRACK_INTERNAL_LINKS dest_intl = HTAnchor_followTypedLink(child, HTInternalLink); #endif dest = dest_intl ? dest_intl : HTAnchor_followLink(child); parent = HTAnchor_parent(dest); if (!intern_w_post && dest_intl && HTMainAnchor && HTMainAnchor->post_data && parent->post_data && BINEQ(HTMainAnchor->post_data, parent->post_data)) { /* * Set flag to note that we had at least one internal link, if the * document from which we are generating the list has associated * POST data; after an extra check that the link destination really * has the same POST data so that we can believe it is an internal * link. */ intern_w_post = TRUE; } address = HTAnchor_address(dest); title = titles ? HTAnchor_title(parent) : NULL; if (dest_intl) { HTSprintf0(&LinkTitle, "(internal)"); } else if (titles && child->type && dest == child->dest && !strncmp(HTAtom_name(child->type), "RelTitle: ", 10)) { HTSprintf0(&LinkTitle, "(%s)", HTAtom_name(child->type) + 10); } else { FREE(LinkTitle); } StrAllocCopy(Address, address); FREE(address); LYEntify(&Address, TRUE); if (non_empty(title)) { LYformTitle(&Title, title); LYEntify(&Title, TRUE); if (*Title) { cp = findPoundSelector(Address); } else { FREE(Title); } } fprintf(fp0, "<li><a href=\"%s\"%s>%s%s%s%s%s</a>\n", Address, dest_intl ? " TYPE=\"internal link\"" : "", NonNull(LinkTitle), ((HTAnchor *) parent != dest) && Title ? "in " : "", (char *) (Title ? Title : Address), (Title && cp) ? " - " : "", (Title && cp) ? (cp + 1) : ""); FREE(Address); FREE(Title); } FREE(LinkTitle); if (hidden_links > 0) { if (refs > 0) fprintf(fp0, "\n</%s>\n\n<p>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol" : "ul")); fprintf(fp0, "<%s compact>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol continue" : "ul")); fprintf(fp0, "<lh><em>%s</em>\n", gettext("Hidden links:")); } for (cnt = 0; cnt < hidden_links; cnt++) { StrAllocCopy(Address, HText_HiddenLinkAt(HTMainText, cnt)); LYEntify(&Address, FALSE); if (isEmpty(Address)) { FREE(Address); continue; } fprintf(fp0, "<li><a href=\"%s\">%s</a>\n", Address, Address); FREE(Address); } fprintf(fp0, "\n</%s>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol" : "ul")); EndInternalPage(fp0); LYCloseTempFP(fp0); /* * Make necessary changes to newdoc before returning to caller. If the * intern_w_post flag is set, we keep the POST data in newdoc that have * been passed in. They should be the same as in the loaded document for * which we generated the list. In that case the file we have written will * be associated with the same POST data when it is loaded after we are * done here, so that following one of the links we have marked as * "internal link" can lead back to the underlying document with the right * address+post_data combination. - kw */ if (intern_w_post) { newdoc->internal_link = TRUE; } else { LYFreePostData(newdoc); newdoc->internal_link = FALSE; } newdoc->isHEAD = FALSE; newdoc->safe = FALSE; return (0); }