char *mo_post_pull_er_over (char *url, char *content_type, char *data, char **texthead) { char *rv; extern int binary_transfer; do_post = 1; post_content_type = content_type; post_data = data; if (binary_transfer) { force_dump_to_file = 1; force_dump_filename = mo_tmpnam(url); } if (HTTP_last_modified) { free(HTTP_last_modified); HTTP_last_modified = 0; } rv = doit (url, texthead); if (binary_transfer) { force_dump_to_file = 0; force_dump_filename = NULL; } do_post = 0; return rv; }
/**************************************************************************** * name: mo_pull_er_over * purpose: Given a URL, pull 'er over. * inputs: * - char *url: The URL to pull over. * - char **texthead: Return pointer to head of allocated block. * returns: * Text to display (char *). * remarks: * ****************************************************************************/ char *mo_pull_er_over (char *url, char **texthead) { char *rv; extern int binary_transfer; if (binary_transfer) { force_dump_to_file = 1; force_dump_filename = mo_tmpnam(url); } if (saveFileName!=NULL) { free(saveFileName); } saveFileName=strdup(url); if (HTTP_last_modified) { free(HTTP_last_modified); HTTP_last_modified = 0; } rv = doit (url, texthead); if (binary_transfer) { force_dump_to_file = 0; force_dump_filename = NULL; } return rv; }
/* Take action using a system command ** ---------------------------------- ** ** Creates temporary file, writes to it, executes system command ** on end-document. The suffix of the temp file can be given ** in case the application is fussy, or so that a generic opener can ** be used. ** ** WARNING: If force_dump_to_file is high, pres may be NULL ** (as we may get called directly from HTStreamStack). */ PUBLIC HTStream* HTSaveAndExecute ARGS5( HTPresentation *, pres, HTParentAnchor *, anchor, /* Not used */ HTStream *, sink, HTFormat, format_in, int, compressed) /* Not used */ { char *command; WWW_CONST char * suffix; HTStream* me; me = (HTStream*)malloc(sizeof(*me)); me->isa = &HTFWriter; me->interrupted = 0; me->write_error = 0; me->fnam = NULL; me->end_command = NULL; me->compressed = compressed; if (!format_in || !format_in->name || !*(format_in->name)) { me->mime_type=NULL; } else { if (!strncmp(format_in->name,"image",5)) { me->mime_type=strdup(format_in->name); } else { me->mime_type=NULL; } } #ifndef DISABLE_TRACE if (www2Trace) fprintf (stderr, "[HTSaveAndExecute] me->compressed is '%d'\n", me->compressed); #endif /* Save the file under a suitably suffixed name */ if (!force_dump_to_file) { extern char *mo_tmpnam (char *); suffix = HTFileSuffix(pres->rep); me->fnam = mo_tmpnam(anchor->address); if (suffix) { char *freeme = me->fnam; me->fnam = (char *)malloc (strlen (me->fnam) + strlen (suffix) + 8); strcpy(me->fnam, freeme); strcat(me->fnam, suffix); free (freeme); } } else { me->fnam = strdup (force_dump_filename); } me->fp = fopen (me->fnam, "w"); if (!me->fp) { HTProgress("Can't open temporary file -- serious problem."); me->write_error = 1; return me; } /* If force_dump_to_file is high, we're done here. */ if (!force_dump_to_file) { if (!strstr (pres->command, "mosaic-internal-reference")) { /* If there's a "%s" in the command, or if the command is magic... */ #ifndef DISABLE_TRACE if (www2Trace) fprintf (stderr, "HTFWriter: pres->command is '%s'\n", pres->command); #endif if (strstr (pres->command, "%s") || strstr (pres->command, "mosaic-internal")) { /* Make command to process file */ command = (char *)malloc ((strlen (pres->command) + 10 + 3*strlen(me->fnam)) * sizeof (char)); /* Cute. pres->command will be something like "xv %s"; me->fnam gets filled in as many times as appropriate. */ sprintf (command, pres->command, me->fnam, me->fnam, me->fnam); me->end_command = (char *)malloc ((strlen (command) + 32 + strlen(me->fnam)) * sizeof (char)); sprintf (me->end_command, "(%s ; /bin/rm -f %s) &", command, me->fnam); free (command); } else { /* Make command to process file -- but we have to cat to the viewer's stdin. */ me->end_command = (char *)malloc ((strlen (pres->command) + 64 + (2 * strlen(me->fnam))) * sizeof (char)); sprintf (me->end_command, "((cat %s | %s); /bin/rm -f %s) &", me->fnam, pres->command, me->fnam); } } else { /* Overload me->end_command to be what we should write out as text to communicate back to client code. */ me->end_command = (char *)malloc (strlen ("mosaic-internal-reference") + strlen (me->fnam) + 32); sprintf (me->end_command, "<%s \"%s\">\n", "mosaic-internal-reference", me->fnam); } } return me; }