Function: x-load-color-file
x-load-color-file is a function defined in xfaces.c.
Signature
(x-load-color-file FILENAME)
Documentation
Create an alist of color entries from an external file.
The file should define one named RGB color per line like so:
R G B name
where R,G,B are numbers between 0 and 255 and name is an arbitrary string.
Source Code
// Defined in /usr/src/emacs/src/xfaces.c
{
FILE *fp;
Lisp_Object cmap = Qnil;
Lisp_Object abspath;
CHECK_STRING (filename);
abspath = Fexpand_file_name (filename, Qnil);
block_input ();
fp = emacs_fopen (SSDATA (abspath), "r" FOPEN_TEXT);
if (fp)
{
char buf[512];
int red, green, blue;
int num;
while (fgets (buf, sizeof (buf), fp) != NULL)
if (sscanf (buf, "%d %d %d %n", &red, &green, &blue, &num) == 3)
{
#ifdef HAVE_NTGUI
int color = RGB (red, green, blue);
#else
int color = (red << 16) | (green << 8) | blue;
#endif
char *name = buf + num;
ptrdiff_t len = strlen (name);
len -= 0 < len && name[len - 1] == '\n';
cmap = Fcons (Fcons (make_string (name, len), make_fixnum (color)),
cmap);
}
fclose (fp);
}
unblock_input ();
return cmap;
}