From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,a63c305ffc73f56a X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-01-06 07:42:23 PST Newsgroups: comp.unix.osf.osf1 Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!rutgers!dziuxsolim.rutgers.edu!uunet!salliemae!europa.eng.gtefsd.com!howland.reston.ans.net!news.sprintlink.net!demon!betanews.demon.co.uk!ncgrafix.demon.co.uk!mark From: mark@ncgrafix.demon.co.uk (Mark Wassell) Subject: Re: rgb.txt Message-ID: Sender: news@ncgrafix.demon.co.uk (News Keeper) NntpPostingHost: oa2 ReplyTo: mark@ncgrafix.demon.co.uk Organization: N.C.Graphics References: <3eh2hl$7a1@reseau.cict.fr> Date: Fri, 6 Jan 1995 15:42:23 GMT 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 #include 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"