1 diff -ruN mutt-1.4./README.xface mutt-1.4/README.xface
2 --- mutt-1.4./README.xface Thu Jan 1 01:00:00 1970
3 +++ mutt-1.4/README.xface Sat Aug 24 02:29:23 2002
5 +This is slrnface, a small helper utility which displays X-Faces on behalf
6 +of programs like slrn and mutt when they are run in the X11 terminal
12 +b) Terminal emulator which sets WINDOWID environment variable. Most of the
13 + ones in common use will set it. If you're using some terminal emulator
14 + which doesn't have this capability, you'll have to set it yourself.
18 +a) Install libcompface. I recommend getting the source from the nearest
19 + Debian GNU/Linux mirror because there's a patch which adds the
20 + ability to output XBM image, as well as the historic brain dead
21 + format. Slrnface doesn't use that feature, but it might be handy for
28 +d) Install with "make install".
30 +Upgrading from version 1.x:
32 + If you have used one of the older versions of slrnface, you probably
33 + have .slrnface file in your home directory. You can delete it, because
34 + the new version doesn't use it any more. Instead, the pipes will be
35 + created in $HOME/.slrnfaces directory. There are no other user visible
38 +Using slrnface with slrn:
40 + This version requires S-Lang 1.4 or later and slrn 0.9.7.4. It might
41 + work with slrn 0.9.7.3, but I haven't tested that configuration. It
42 + will not work properly with older versions.
44 + In case you can't or won't upgrade, take a look at the slrnface home
45 + page. You'll find older versions which might work with what you have.
47 + Take a look at slrnface.sl, edit if you want and then include it in
48 + your .slrnrc, like this:
50 + interpret slrnface.sl
54 +Using slrnface with mutt:
56 + Mutt doesn't have a way to use some kind of embeded interpreter, like
57 + S-Lang. Since Mutt's current capabilities are not good enough for our
58 + purposes, a patch for the source is provided. It has been tested with
59 + mutt 1.4, but it should work with the 1.3.x series, if x is high
62 + Uncompress mutt 1.4 source and apply mutt.patch from the slrnface
65 + Compile mutt as usual.
67 + Edit your ~/.muttrc and add:
73 +If you think X-Faces are not placed at the appropriate location on your
74 +terminal emulator window or you don't like the colors, set some X resources.
75 +Read the man page for more information. Additional documentation is in the
78 +Licence: GPL. See file called COPYING.
80 +Special thanks to Mark R. Bowyer for proofreading the man page.
82 +Home page: http://dave.willfork.com/slrnface/
85 diff -ruN mutt-1.4./globals.h mutt-1.4/globals.h
86 --- mutt-1.4./globals.h Mon Jan 20 00:17:02 2003
87 +++ mutt-1.4/globals.h Mon Jan 20 00:28:31 2003
89 WHERE ALIAS *Aliases INITVAL (0);
90 WHERE LIST *UserHeader INITVAL (0);
92 +WHERE int slrnface_fd INITVAL (-1);
95 WHERE FILE *debugfile INITVAL (0);
96 WHERE int debuglevel INITVAL (0);
97 diff -ruN mutt-1.4./init.c mutt-1.4/init.c
98 --- mutt-1.4./init.c Mon Jan 20 00:17:02 2003
99 +++ mutt-1.4/init.c Mon Jan 20 00:28:31 2003
102 #include <sys/utsname.h>
104 +#include <sys/types.h>
106 #include <sys/wait.h>
108 void toggle_quadoption (int opt)
109 @@ -1971,3 +1973,131 @@
114 +void mutt_start_slrnface(void)
117 + int pathlen, status;
121 + if (!option(OPTXFACE))
125 + * If we don't have display, there's no point. The user probably knows,
126 + * so fail silently.
128 + if (!getenv("DISPLAY"))
130 + /* If there is no WINDOWID, complain. */
131 + if (!getenv ("WINDOWID"))
133 + mutt_error (_("Cannot run slrnface: WINDOWID not found in environment."));
138 + pathlen = strlen (Homedir) + sizeof("/.slrnfaces/")
139 + + strlen (u.nodename) + 30;
140 + fifo = safe_malloc (pathlen);
141 + sprintf (fifo, "%s/.slrnfaces", Homedir);
142 + if (mkdir (fifo, 0700))
144 + if (errno != EEXIST)
146 + mutt_error (_("Cannot run slrnface: failed to create %s: %s."),
147 + fifo, strerror(errno));
155 + /* We'll abuse fifo filename memory here. It's long enough. */
156 + sprintf (fifo, "%s/.slrnfaces/README", Homedir);
157 + if ((fp = fopen (fifo, "w")) != NULL)
160 +"This directory is used to create named pipes for communication between\n"
161 +"slrnface and its parent process. It should normally be empty because\n"
162 +"the pipe is deleted right after it has been opened by both processes.\n\n"
163 +"File names generated by slrnface have the form \"hostname.pid\". It is\n"
164 +"probably an error if they linger here longer than a fraction of a second.\n\n"
165 +"However, if the directory is mounted from an NFS server, you might see\n"
166 +"special files created by your NFS server while slrnface is running.\n"
167 +"Do not try to remove them.\n"), fp);
172 + status = snprintf (fifo, pathlen, "%s/.slrnfaces/%s.%ld", Homedir,
173 + u.nodename, (long)getpid());
178 + if (mkfifo (fifo, 0600) < 0)
180 + mutt_error (_("Cannot run slrnface, failed to create %s: %s."), fifo,
189 + case 0: execlp ("slrnface", "slrnface", fifo, (char *)0);
190 + /* This is child, exit on error. */
193 + pidst = waitpid (pid, &status, 0);
194 + } while (pidst == -1 && errno == EINTR);
196 + if (!WIFEXITED (status))
197 + mutt_error (_("Slrnface abnormaly exited, code %d."), status);
202 + switch (WEXITSTATUS (status))
204 + case 0: /* All fine, open the pipe */
205 + slrnface_fd = open (fifo, O_WRONLY, 0600);
206 + write (slrnface_fd, "start\n", sizeof "start");
208 + case 1: message = "couldn't connect to display";
210 + case 2: message = "WINDOWID not found in environment";
212 + case 3: message = "couldn't find controlling terminal";
214 + case 4: message = "terminal doesn't export width and height";
216 + case 5: message = "cannot open FIFO";
218 + case 6: message = "fork() failed";
220 + case 10: message = "executable not found";
222 + default: message = "unknown error";
224 + mutt_error (_("Slrnface failed: %s."), message);
233 +void mutt_stop_slrnface(void)
235 + if (slrnface_fd >= 0)
236 + close(slrnface_fd);
239 + /* FIFO has been unlinked in the startup function. */
241 diff -ruN mutt-1.4./init.h mutt-1.4/init.h
242 --- mutt-1.4./init.h Mon Jan 20 00:17:02 2003
243 +++ mutt-1.4/init.h Mon Jan 20 00:28:31 2003
244 @@ -2437,6 +2437,12 @@
245 ** Controls whether mutt writes out the Bcc header when preparing
246 ** messages to be sent. Exim users may wish to use this.
248 + { "xface", DT_BOOL, R_NONE, OPTXFACE, 0 },
251 + ** Controls whether mutt uses slrnface to display X-Faces when run
252 + ** in an X11 terminal emulator.
257 diff -ruN mutt-1.4./main.c mutt-1.4/main.c
258 --- mutt-1.4./main.c Mon Jan 20 00:17:02 2003
259 +++ mutt-1.4/main.c Mon Jan 20 00:28:31 2003
262 mutt_folder_hook (folder);
264 + mutt_start_slrnface();
266 if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL))
270 safe_free ((void **)&Context);
272 mutt_endwin (Errorbuf);
274 + mutt_stop_slrnface();
278 diff -ruN mutt-1.4./mutt.h mutt-1.4/mutt.h
279 --- mutt-1.4./mutt.h Mon Jan 20 00:17:02 2003
280 +++ mutt-1.4/mutt.h Mon Jan 20 00:28:31 2003
284 OPTWRITEBCC, /* write out a bcc header? */
291 LIST *references; /* message references (in reverse order) */
292 LIST *in_reply_to; /* in-reply-to header content */
293 + LIST *x_face; /* X-Face header content */
294 LIST *userhdrs; /* user defined headers */
297 diff -ruN mutt-1.4./muttlib.c mutt-1.4/muttlib.c
298 --- mutt-1.4./muttlib.c Mon Jan 20 00:17:02 2003
299 +++ mutt-1.4/muttlib.c Mon Jan 20 00:28:31 2003
301 safe_free ((void **) &(*p)->date);
302 mutt_free_list (&(*p)->references);
303 mutt_free_list (&(*p)->in_reply_to);
304 + mutt_free_list (&(*p)->x_face);
305 mutt_free_list (&(*p)->userhdrs);
306 safe_free ((void **) p);
308 diff -ruN mutt-1.4./pager.c mutt-1.4/pager.c
309 --- mutt-1.4./pager.c Mon Jan 20 00:17:02 2003
310 +++ mutt-1.4/pager.c Mon Jan 20 00:28:31 2003
311 @@ -1431,6 +1431,66 @@
316 +mutt_display_xface (HEADER *hdr)
321 + if (slrnface_fd < 0)
327 + face = hdr->env->x_face;
329 + if (face == NULL || face->data == NULL)
330 + write(slrnface_fd, "clear\n", sizeof "clear");
335 + len = snprintf (buf, sizeof (buf), "xface %s\n", face->data);
336 + if (len <= sizeof (buf))
338 + write (slrnface_fd, buf, len);
342 + * slrnface will ignore X-Faces larger than approx. 2000 chars, so
343 + * try the next one, if it exists.
345 + } while (face = face->next);
349 +mutt_clear_xface (void)
351 + if (slrnface_fd < 0)
354 + write(slrnface_fd, "clear\n", sizeof "clear");
358 +mutt_suppress_xface (void)
360 + if (slrnface_fd < 0)
363 + write(slrnface_fd, "suppress\n", sizeof "suppress");
367 +mutt_show_xface (void)
369 + if (slrnface_fd < 0)
372 + write(slrnface_fd, "show\n", sizeof "show");
375 static struct mapping_t PagerHelp[] = {
376 { N_("Exit"), OP_EXIT },
377 { N_("PrevPg"), OP_PREV_PAGE },
378 @@ -1535,6 +1595,9 @@
379 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
382 + if (IsHeader (extra))
383 + mutt_display_xface(extra->hdr);
388 @@ -2035,7 +2098,9 @@
392 + mutt_suppress_xface ();
393 mutt_help (MENU_PAGER);
394 + mutt_show_xface ();
395 redraw = REDRAW_FULL;
398 @@ -2329,59 +2394,71 @@
400 CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
402 + mutt_suppress_xface ();
403 ci_send_message (0, NULL, NULL, NULL, NULL);
404 + mutt_show_xface ();
405 redraw = REDRAW_FULL;
409 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
411 + mutt_suppress_xface();
412 if (IsMsgAttach (extra))
413 mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
414 extra->idxlen, extra->bdy,
417 ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr);
418 + mutt_show_xface ();
419 redraw = REDRAW_FULL;
422 case OP_RECALL_MESSAGE:
423 CHECK_MODE(IsHeader (extra));
425 + mutt_suppress_xface();
426 ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr);
427 + mutt_show_xface ();
428 redraw = REDRAW_FULL;
432 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
434 + mutt_suppress_xface();
435 if (IsMsgAttach (extra))
436 mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
437 extra->idxlen, extra->bdy, SENDREPLY|SENDGROUPREPLY);
439 ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr);
440 + mutt_suppress_xface ();
441 redraw = REDRAW_FULL;
445 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
447 + mutt_suppress_xface();
448 if (IsMsgAttach (extra))
449 mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
450 extra->idxlen, extra->bdy, SENDREPLY|SENDLISTREPLY);
452 ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr);
453 + mutt_show_xface ();
454 redraw = REDRAW_FULL;
457 case OP_FORWARD_MESSAGE:
458 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
460 + mutt_suppress_xface();
461 if (IsMsgAttach (extra))
462 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
463 extra->idxlen, extra->bdy);
465 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
466 + mutt_show_xface ();
467 redraw = REDRAW_FULL;
470 @@ -2430,7 +2507,9 @@
473 case OP_SHELL_ESCAPE:
474 + mutt_suppress_xface ();
475 mutt_shell_escape ();
476 + mutt_show_xface ();
477 MAYBE_REDRAW (redraw);
480 @@ -2573,5 +2652,6 @@
481 safe_free ((void **) &lineInfo);
483 mutt_menuDestroy(&index);
484 + mutt_clear_xface ();
485 return (rc != -1 ? rc : 0);
487 diff -ruN mutt-1.4./parse.c mutt-1.4/parse.c
488 --- mutt-1.4./parse.c Tue Jan 29 11:05:20 2002
489 +++ mutt-1.4/parse.c Mon Jan 20 00:28:32 2003
494 +static LIST *mutt_add_x_face (LIST *lst, char *face)
498 + n = safe_malloc(sizeof(LIST));
499 + n->data = safe_strdup(face);
506 + for(l = lst; l->next; l = l->next);
515 static LIST *mutt_parse_references (char *s, int in_reply_to)
517 LIST *t, *lst = NULL;
518 @@ -1207,6 +1228,11 @@
519 e->x_label = safe_strdup(p);
522 + else if (ascii_strcasecmp (line+1, "-face") == 0)
524 + e->x_face = mutt_add_x_face (e->x_face, p);
530 diff -ruN mutt-1.4./sendlib.c mutt-1.4/sendlib.c
531 --- mutt-1.4./sendlib.c Sat Apr 20 09:25:49 2002
532 +++ mutt-1.4/sendlib.c Mon Jan 20 00:28:32 2003
533 @@ -1663,6 +1663,15 @@
537 + /* Add X-Face headers */
542 + for (face = env->x_face; face; face = face->next)
543 + fprintf (fp, "X-Face: %s\n", face->data);
546 if (mode == 0 && !privacy && option (OPTXMAILER))
548 /* Add a vanity header */