home *** CD-ROM | disk | FTP | other *** search
- /* (C) Copyright 1984,85,86,87 Walter L. Peacock All Rights Reserved */
-
- /*----------------------------------------------------------------------------
- * bldkey() is an example of a routine that builds a concatenated key
- * that is to be stored in the B+tree index. USERBTR.EXE calls this function
- * to build the name key.
- *---------------------------------------------------------------------------*/
-
- /* patrec - structure for the patient record file */
-
- #include "cbtree.h"
- #include "patrec.str"
-
- char to_upper(c) /* need non-#define'd version */
- char c;
- {
- return((char)toupper(c));
- }
-
- /* build the search key and return length of key */
- int bldkey(keyfield, maxlen, pr)
- char *keyfield;
- uint maxlen;
- PATREC *pr;
- {
- extern char to_upper();
- register int i;
- char *prlnme, *prfnme, *prmint;
-
- i = 0; /* needs to be here for EC */
- prlnme = pr->lname;
- prfnme = pr->fname;
- prmint = pr->minit;
-
- while (i < maxlen && (keyfield[i] = to_upper(*prlnme++)) != NUL)
- ++i;
- if (i < maxlen) /* need space between names for proper ordering */
- keyfield[i++] = ' ';
- while (i < maxlen && (keyfield[i] = to_upper(*prfnme++)) != NUL)
- ++i;
- if (i < maxlen && keyfield[i-1] != ' ') /* only 1 space ! */
- keyfield[i++] = ' ';
- if (i < maxlen && (keyfield[i] = to_upper(*prmint)) != NUL)
- ++i;
- if (keyfield[i-1] == ' ') /* don't end in space ! */
- --i;
- keyfield[i] = '\0';
- return(i); /* return strlen of keyfield */
- }
-