#include #include #include #include #include #include "dat.h" char machineused[64]; char userused[64]; int depthused; /* * translate mail address into a file name */ char* tryfile(char *machine, char *user, int ld) { static char file[128]; char *cp, *p; Biobuf *mf; sprint(file, "/lib/face/48x48x%d/.dict", 1< 1) depth = 1; file = getfile(machine, user, depth); if(file == 0) file = getfile(machine, "unknown", depth); if(file == 0) file = getfile("", "unknown", depth); if(file == 0){ out: memset(into, 0, sizeof(SRC)); label = machine; return; } strcpy(realmachine, machineused); fd = Bopen(file, OREAD); if(fd == 0) goto out; if(strcmp(userused, "unknown") == 0) label = machine; y = 0; while((cp=Brdline(fd, '\n')) != 0){ p = strtoul(cp, &cp, 16); q = strtoul(cp+1, &cp, 16); /* skip ',' */ r = strtoul(cp+1, 0, 16); /* skip ',' */ pp = into->pix[y]; for(x=0; x<16; x++){ if(depthused == 1){ pp[x] = tab1[(p&(3<<(30-2*x)))>>(30-2*x)]; pp[16+x] = tab1[(q&(3<<(30-2*x)))>>(30-2*x)]; pp[32+x] = tab1[(r&(3<<(30-2*x)))>>(30-2*x)]; }else{ pp[x] = (p&(1<<(15-x)))?255:0; pp[16+x] = (q&(1<<(15-x)))?255:0; pp[32+x] = (r&(1<<(15-x)))?255:0; } } if(y++ >= MAXY) break; } Bclose(fd); }