Category : Files from Magazines
Archive   : ITCAPR91.ZIP
Filename : DOGGIE.C
* DOGGIE.C - The access functions for the DOGGIE database. *
* To compile, see DOGDATA.C *
************************************************************************/
#include
#include "doggie.h"
#define MAX_REC 10
#define MAX_NAME 16
#define NUM_AWARDS 0x000F
#define CUST_NUM 0x0FFF
/************************************************************************
* Internal definition of the database *
************************************************************************/
struct DumbDogDefinition
{
unsigned CustNum; /* 0..11 = Customer #, 12-15 = # dogs */
char LName[MAX_NAME]; /* Customers' last name, reversed */
unsigned char OtherInfo; /* bits 0-3 hold the # of awards earned */
} DumbDogData[MAX_REC] = /* Array holding doggie records */
{
{ 0xF12D, "nosirraH", 11 }, { 0x4326, "nonneL", 9 },
{ 0x0CE3, "rratS", 0 }, { 0xC810, "yentraCcM", 12 },
{ 0x24FF, "eromliG", 1 }, { 0x82E4, "notpalC", 7 },
{ 0xA769, "iaV", 4 }, { 0x0129, "doowniW", 0 },
{ 0x1169, "appaZ", 3 }, { 0x0989, "snilloC", 0 }
};
static int RecNum; /* Current record number in the array */
/************************************************************************
* Access functions *
************************************************************************/
/*----------
* InitializeDoggieData - initializes the doggie database
* OUT: 0 if successful, -1 on failure
*/
int InitializeDoggieData(void)
{ return RecNum=0; } /* Set last record read */
/*----------
* CleanupAfterDoggies - tells information cluster that the
* application has no use for any more doggies.
* OUT: 0 if successful, -1 on failure
*/
int CleanupAfterDoggies(void)
{ return 0; } /* We just can't fail... */
/*----------
* StartDoggieSearch - tells the database that we're preparing
* to start a search.
* OUT: 0 on success, -1 on failure
*/
int StartDoggieSearch(void)
{ return RecNum=0; } /* Point to the first record */
/*----------
* GetNextRecord - return the next record in the doggie database
* OUT: -1 if no more records, record number otherwise
*/
int GetNextRecord(void)
{ return (++RecNum < MAX_REC) ? RecNum : -1; }
/*----------
* GetNextDogLover - scan the database for the next person who
* owns the specified number of dogs (or more).
* OUT: Record number if successful, -1 on failure
*/
int GetNextDogLover(int minDogs)
{
int numDoggies;
for (RecNum+=1; RecNum < MAX_REC; RecNum++)
{
numDoggies = DumbDogData[RecNum].CustNum>>12;
if ( numDoggies >= minDogs)
return RecNum;
}
return -1; /* No more doggie lovers */
}
/*----------
* GetDoggieData - return information from specified record
* INP: recordNum - the record to retrieve data from
* userRec - buffer to put data into
* OUT: 0 on success, -1 on failure
*/
int GetDoggieData(int recNo, struct DoggieDef *usrRec)
{
/* get customer name & remove security jumbling from it */
strncpy(usrRec->CustName,DumbDogData[recNo].LName,MAX_NAME-1);
usrRec->CustName[MAX_NAME-1]=0; /* Ensure that string ends */
strrev(usrRec->CustName); /* Reverse string in place */
usrRec->CustNum =DumbDogData[recNo].CustNum & CUST_NUM;
usrRec->NumAwards =DumbDogData[recNo].OtherInfo&NUM_AWARDS;
usrRec->NumDoggies=DumbDogData[recNo].CustNum>>12;
return 0;
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/