From: mark@ncgrafix.demon.co.uk (Mark Wassell)
Subject: Re: rgb.txt
Date: Fri, 6 Jan 1995 15:42:23 GMT [thread overview]
Message-ID: <D1zqAn.HAt@ncgrafix.demon.co.uk> (raw)
In-Reply-To: 3eh2hl$7a1@reseau.cict.fr
In <3eh2hl$7a1@reseau.cict.fr> manu@ecstasy.cemes.fr (Emmanuel Courcelle)
writes:
> I already introduced the color in the rgb.txt file with an editor, but
> I do not know how to update the rgb.pag and rgb.dir files (all those
> files are under /usr/lib/X11).
The rgb.pag and rgb.dir files make up a database which can be accessed, created
and updated using the dbm(3) family of subroutines. I've included a little
C program I wrote to do what you want to do (it might need a little tweaking
to fit in with your needs). Perl also has dbm cabilities.
Having said all this I'm sure that someone has written a better utility for
this.
I hope this helps.
#include <ndbm.h>
#include <stdio.h>
DBM *mydb;
main()
{
mydb=dbm_open("rgb",DBM_REPLACE,0);
AddColour(203,203,192,"scobackground"); /* ivory3 */
AddColour(11, 0, 113,"scoforeground"); /* navyblue */
AddColour(255, 240, 248,"scotopshadow"); /* lav blush */
AddColour(255,206,137,"scoactivebackground");
AddColour(43, 45, 49,"scoactiveforeground");
AddColour(254, 222, 255,"scoactivetopshadow");
AddColour(172, 186, 204,"scoaltbackground");
AddColour(141, 178, 215,"scohighlight");
PrintDb();
dbm_close(mydb);
}
DeleteColor(keystr)
char *keystr;
{
datum key;
MakeKey(&key,"blue");
dbm_delete(mydb,key);
}
MakeKey(key,keystr)
datum *key;
char *keystr;
{
key>dsize = strlen(keystr);
key>dptr = (char*)malloc(key>dsize+1);
strcpy(key>dptr,keystr);
}
AddColour(c1,c2,c3,keystr)
char *keystr;
unsigned char c1,c2,c3;
{
datum data;
datum key;
MakeKey(&key,keystr);
data.dsize=6;
data.dptr = (char*)malloc(data.dsize);
data.dptr[0]=c1;
data.dptr[1]=c1;
data.dptr[2]=c2;
data.dptr[3]=c2;
data.dptr[4]=c3;
data.dptr[5]=c3;
dbm_store(mydb,key,data,DBM_INSERT);
}
PrintDb()
{
datum key;
datum data;
int i;
unsigned char colval[3];
char colname[100];
for(key=dbm_firstkey(mydb);key.dptr!=NULL;key=dbm_nextkey(mydb))
{
data=dbm_fetch(mydb,key);
strncpy(colname,key.dptr,key.dsize);
colname[key.dsize]=0;
printf("%s %d %d %d\n",colname,(unsigned char)data.dptr[0],
(unsigned char)data.dptr[2],(unsigned char)data.dptr[4]);
}
}
___ ___
|\ | | Mark Wassell
| \ |\ \ | N.C. Graphics,
| \| \__ \__| Waterbeach, Cambridge
N.C. Graphics (Cambridge) Ltd. Tel:(0223) 861539 UK, CB5 9NN
#include "disclaimer.h"
next prev parent reply other threads:[~1995-01-06 15:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-01-05 15:17 rgb.txt Emmanuel Courcelle
1995-01-06 15:42 ` Mark Wassell [this message]
1995-01-12 17:42 ` rgb.txt Dave Hill
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox