define show_xface()
{
      save_current_article("/home/ra/News/art_xfce");
   
      variable header_file, xfce_file;
      variable fp, xfce_fp;
      variable line, face;
   
      fp = fopen ("/home/ra/News/art_xfce", "r");
      if (fp == NULL)
          return;
   
      while (-1 != fgets (&line, fp))
     {
	        % X-Face can appear anywhere, even in the subject line
	        % and I've seen it CaPitaLizED differently, even.
	        % Compare first 7 characters of line with X-FACE:
	        if (strncmp(substr(strup(line), 1, 7), "X-FACE:", 7) == 0)
	  {
	                 % write headerline with xface
	                 xfce_fp = fopen("/home/ra/News/hdr_xface", "w");
	                 if (xfce_fp == NULL)
	                     return;
	                 () = fputs(line, xfce_fp);
	                 () = fputs("\n", xfce_fp);
	                 () = fclose(xfce_fp);
	                 % display it
	                 xfce_fp = popen ("cat /home/ra/News/hdr_xface | /usr/local/bin/view-x-face.sh", "r");
	                 if (xfce_fp == NULL) return;
	                 popup_window ("X-Face:", strjoin (fgetslines(xfce_fp), ""));
	                 () = pclose (xfce_fp);
	                 break;
	  }
     }
   
      () = system ("rm -f /home/ra/News/art_xfce /home/ra/News/hdr_xface /home/ra/News/rslt_xface");
      % No need to close files unless we want to check for errors.  When
      % file pointer variables go out of scope, slang will close the file.
}

definekey ("show_xface", "x", "article");
