/*----------------------------------------------------------------------
    Routine to execute command mailcap says is used to display MIME segment
    under UNIX

 The exported routine is:

    exec_viewer -- 

 ----*/


/* ----------------------------------------------------------------------
   Execute the given 

  Args: cmd -- 
	image_file --
  
     
  ----*/
void
exec_mailcap_cmd(cmd, image_file)
    char *cmd;
    char *image_file;
{
    char   *command = NULL, *result_file = NULL;
    PIPE_S *syspipe;

    command = (char *)fs_get((32 + strlen(cmd) + (2*strlen(image_file)))
			     * sizeof(char));
    sprintf(command, "(%s ; rm -f %s) &\n", cmd, image_file);
    dprint(9, (debugfile, "run_viewer: command=%s\n", command)) ;
    result_file = temp_nam(NULL, "pine_cmd");
    if(syspipe = open_system_pipe(command, &result_file, PIPE_SYS)){
	(void)close_system_pipe(&syspipe) ;
	display_system_pipe_output(result_file, "VIEWER") ;
    }
    else
      q_status_message1(0, 1, 4, "Cannot spawn command : %s", cmd);

    fs_give((void **)&command);
    fs_give((void **)&result_file);
}
