/*************************************/ /* */ /* AUoH Progressive Door Prize Lotto */ /* */ /* DataBase extract routine */ /* */ /* Michael D. Groshart - 16 Aug 89 */ /* */ /*************************************/ #include typedef struct sb_block { long id; char user[4]; char fill1[13]; char code; char fill2; char data[105]; } SBblock; #define NUMBLOCKS 8 #define BLOCKSIZE (sizeof(SBblock)) #define BUFFERLEN (NUMBLOCKS*BLOCKSIZE) SBblock buffer[NUMBLOCKS]; #define DATABLOCK 0x80000000 /* Bit mask to determine block type */ read_db(name,add) char *name; void (*add)(); { register int fd, bytes, i, nent; if ((fd = open(name,O_RDONLY)) < 0) return 0; while ((bytes = read(fd,buffer,BUFFERLEN)) > 0) { for (i = 0; i < (bytes / BLOCKSIZE); i++) { if (buffer[i].id & DATABLOCK) { switch(buffer[i].code) { case 'N': case 'R': add(buffer[i].user,buffer[i].data); default: break; } } } } close(fd); return 1; }