int upload(mo_window *win,FILE *fp, char *fname) { char *put_url,*xurl; int res=mo_fail; char *newtext=NULL,*newtexthead=NULL; char *last_modified=NULL,*expires=NULL; char *ref; if (!win) { return(0); } put_url=prompt_for_string("Enter the URL you wish to upload the file as:"); if (!put_url) { return(0); } /* if (win->current_node && win->current_node->url && *(win->current_node->url)) { ref=strdup(win->current_node->url); } else { */ ref=NULL; /* } */ xurl=mo_url_prepend_protocol(put_url); free(put_url); put_url=xurl; fseek(fp,0,SEEK_END); put_file_size=ftell(fp); rewind(fp); put_fp=fp; mo_busy (); if (win->target_anchor) { free(win->target_anchor); } /* win->target_anchor=mo_url_extract_anchor(put_url); */ win->target_anchor=NULL; mo_set_current_cached_win(win); newtext=mo_put_er_over(put_url, &newtexthead); if (newtext) { if ((!strncmp(newtext,"<H1>ERROR<H1>",10)) || (!strncmp(newtext,"<HEAD><TITLE>404 Not Found</TITLE></HEAD>",28))) { res=mo_fail; } } if (HTTP_last_modified) { last_modified=strdup(HTTP_last_modified); } if (HTTP_expires) { expires=strdup(HTTP_expires); } { /* Check use_this_url_instead from HTAccess.c. */ extern char *use_this_url_instead; if (use_this_url_instead) { mo_here_we_are_son(put_url); free(put_url); put_url=use_this_url_instead; /* Go get another target_anchor. */ if (win->target_anchor) { free(win->target_anchor); } /* win->target_anchor=mo_url_extract_anchor(put_url); */ win->target_anchor=NULL; } } if (newtext) { res=mo_do_window_text(win, put_url, newtext, newtexthead, 1, ref, last_modified, expires); HTMLTraverseTabGroups(win->view, XmTRAVERSE_HOME); } if (win->current_node) { mo_gui_check_security_icon(win->current_node->authType); } if (last_modified) { free(last_modified); last_modified=NULL; } if (expires) { free(expires); expires=NULL; } /* if (xurl==put_url) { if (put_url) { free(put_url); put_url=NULL; } } else { if (xurl) { free(xurl); xurl=NULL; } if (put_url) { free(put_url); put_url=NULL; } } */ if (ref) { free(ref); ref=NULL; } mo_gui_done_with_icon (); mo_not_busy (); return(res); }
static XmxCallback (mailhist_win_cb) { mo_window *win = mo_fetch_window_by_id (XmxExtractUniqid ((int)client_data)); char *to, *subj; FILE *fp; switch (XmxExtractToken ((int)client_data)) { case 0: XtUnmanageChild (win->mailhist_win); mo_busy (); to = XmxTextGetString (win->mailhist_to_text); if (!to) return; if (to[0] == '\0') return; subj = XmxTextGetString (win->mailhist_subj_text); /* Open a file descriptor to sendmail. */ fp = mo_start_sending_mail_message (to, subj, "text/x-html", NULL); if (!fp) goto oops; { mo_node *node; fprintf (fp, "<HTML>\n"); fprintf (fp, "<H1>History Path From %s</H1>\n", get_pref_string(eDEFAULT_AUTHOR_NAME)); fprintf (fp, "<DL>\n"); for (node = win->history; node != NULL; node = node->next) { fprintf (fp, "<DT>%s\n<DD><A HREF=\"%s\">%s</A>\n", node->title, node->url, node->url); } fprintf (fp, "</DL>\n"); fprintf (fp, "</HTML>\n"); } mo_finish_sending_mail_message (); oops: free (to); free (subj); mo_not_busy (); break; case 1: XtUnmanageChild (win->mailhist_win); /* Do nothing. */ break; case 2: mo_open_another_window (win, mo_assemble_help_url ("help-on-nested-hotlists.html"), NULL, NULL); break; } return; }