[lwatch-cvs] files/src acolors.c,1.1,1.2 acolors.h,1.2,1.3
Brought to you by:
arturcz
|
From: <ar...@us...> - 2002-07-13 00:29:12
|
Update of /cvsroot/lwatch/files/src In directory usw-pr-cvs1:/tmp/cvs-serv417 Modified Files: acolors.c acolors.h Log Message: Intro for better color support. Index: acolors.c =================================================================== RCS file: /cvsroot/lwatch/files/src/acolors.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** acolors.c 18 Jun 2002 19:11:25 -0000 1.1 --- acolors.c 13 Jul 2002 00:29:10 -0000 1.2 *************** *** 96,97 **** --- 96,120 ---- NULL,-1 }; + + /* + * Thanks to Andrzej Oszer <os...@po...> for idea to those functions. + * This idea have been taken from LIB - http://sf.net/projects/lib + */ + int scprintf(char *str, char *format) { + strcpy(str,format); /* temporary workaround */ + return(strlen(str)); + } + + int ascprintf(char **pstr, char *format) { + *pstr=(char*)malloc(strlen(format)+1); + return(scprintf(*pstr,format)); + } + + int cprintf(char *format) { + char *str; + int i; + i=ascprintf(&str,format); + printf("%s",str); + free(str); + return(i); + } Index: acolors.h =================================================================== RCS file: /cvsroot/lwatch/files/src/acolors.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** acolors.h 27 Jun 2002 23:05:14 -0000 1.2 --- acolors.h 13 Jul 2002 00:29:10 -0000 1.3 *************** *** 128,129 **** --- 128,134 ---- extern const char *colmode[]; extern const struct s_convert colstr[]; + + int scprintf(char *str, char *format); + int ascprintf(char **str, char *format); + int cprintf(char *format); + |