#ifndef lint static char sccsid[] = "@(#)rdfamily.c 9.2 88/01/19 Copyright 1985 Sun Micro"; #endif /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ /*- Read a font family file rdfamily.c, Tue Dec 3 14:58:04 1985 James Gosling, Sun Microsystems */ #include #ifdef REF #include #endif #include #include "fontcache.h" struct fontfamily * cst_readfamily(name) char *name; { int fd = open(name, 0); struct stat st; register struct fontfamily *ret; register i; register struct cachedfont *f; char dir[200]; char *s; #ifndef SYSVREF extern char *rindex(); #endif strcpy(dir, name); if (s = rindex(dir, '/')) *s = 0; else strcpy(dir, "."); if (fd < 0) return 0; if (fstat(fd, &st) < 0) { close(fd); return 0; } ret = (struct fontfamily *) snoopalloc("rdfamily.c", st.st_size + strlen(dir) + 1); read(fd, ret, st.st_size); close(fd); if (ret->m.magic != FONTFAMILYMAGIC) { free(ret); return 0; } #define fixup(p) ((p) ? *(int *) &(p) += (int) ret : 0) fixup(ret->FamilyName); if (ret->printermatched) { fixup(ret->printermatched); fixup(ret->printermatched->font.name); } ret->directory = ((char *) ret) + st.st_size; strcpy(ret->directory, dir); for (i = 0; i < FONTTABLESIZE; i++) fixup(ret->table[i]); for (i = 0; i < FONTHASHSIZE; i++) { fixup(ret->hash[i]); for (f = ret->hash[i]; f; f = f->next) { fixup(f->next); fixup(f->font.name); } } return ret; }