home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_01
/
8n01032a
< prev
next >
Wrap
Text File
|
1990-02-19
|
1KB
|
44 lines
Listing 4
#define MAXDATEPRINTS 10
date_print2(date)
date date; /* internal date form */
{
static struct datecache {
date internal;
printable_date external;
} dates[MAXDATEPRINTS];
static struct datecache *d_last_used = dates;
#define next_date(x) ((x==&dates[MAXDATEPRINTS-1])?dates:x+1)
/* last one used is highly likely */
struct datecache *d = d_last_used;
do {
if (d->internal == date) {
d_last_used = d;
return(d->external);
}
d = next_date(d);
} while (d != d_last_used);
/* we have moved all the way around the buffer */
/* and didn't find it in cache */
/* get next buffer */
d_last_used = next_date(d);
/* actually do the work and convert date */
/* into a printable representation */
.....
memcpy(d_last_used->external,....);
return(d_last_used->external);
}