Annotation of q_a/samples/printer/lookup.c, revision 1.1.1.1

1.1       root        1: /******************************************************************************\
                      2: *
                      3: *  MODULE:      LOOKUP.C
                      4: *
                      5: *  PURPOSE:     Provides supporting functions for doing lookups in
                      6: *               LOOKUPENTRY tables.
                      7: *
                      8: *  FUNTIONS:    dwLookupWord()  - given WORD index returns DWORD value
                      9: *               iLookupWord()   - given WORD index returns int value
                     10: *               lpszLookupInt() - given int index returns LPSTR value
                     11: *
                     12: \******************************************************************************/
                     13: 
                     14: #include <windows.h>
                     15: #include "lookup.h"
                     16: 
                     17: 
                     18: 
                     19: /******************************************************************************\
                     20: *
                     21: *  FUNCTION:    dwLookupWord
                     22: *
                     23: *  INPUTS:      pLookup     - pointer to LOOKUPENTRY array
                     24: *               wIndex      - wIndex to search for in array
                     25: *               iMaxEntries - number elements in array
                     26: *
                     27: *  RETURNS:     DWORD value corresponding to wIndex in LOOKUPENTRY array,
                     28: *               or 0
                     29: *
                     30: *  LOCAL VARS:  int i - loop variable
                     31: *
                     32: \******************************************************************************/
                     33: 
                     34: DWORD dwLookupWord (PLOOKUPENTRY pLookup, WORD wIndex, int iMaxEntries)
                     35: {
                     36:   int i;
                     37: 
                     38:   for (i = 0; i < iMaxEntries; i++)
                     39: 
                     40:     if ((pLookup + i)->x.wIndex == wIndex)
                     41: 
                     42:       return (pLookup + i)->v.dwValue;
                     43: 
                     44:   return 0;
                     45: }
                     46: 
                     47: 
                     48: 
                     49: /******************************************************************************\
                     50: *
                     51: *  FUNCTION:    iLookupWord
                     52: *
                     53: *  INPUTS:      pLookup     - pointer to LOOKUPENTRY array
                     54: *               wIndex      - wIndex to search for in array
                     55: *               iMaxEntries - number elements in array
                     56: *
                     57: *  RETURNS:     int value corresponding to wIndex in LOOKUPENTRY array, or
                     58: *               0
                     59: *
                     60: *  LOCAL VARS:  int i - loop variable
                     61: *
                     62: \******************************************************************************/
                     63: 
                     64: int iLookupWord (PLOOKUPENTRY pLookup, WORD wIndex, int iMaxEntries)
                     65: {
                     66:   int i;
                     67: 
                     68:   for (i = 0; i < iMaxEntries; i++)
                     69: 
                     70:     if ((pLookup + i)->x.wIndex == wIndex)
                     71: 
                     72:       return (pLookup + i)->v.iValue;
                     73: 
                     74:   return 0;
                     75: }
                     76: 
                     77: 
                     78: 
                     79: /******************************************************************************\
                     80: *
                     81: *  FUNCTION:    lpszLookupInt
                     82: *
                     83: *  INPUTS:      pLookup     - pointer to LOOKUPENTRY array
                     84: *               iIndex      - iIndex to search for in array
                     85: *               iMaxEntries - number elements in array
                     86: *
                     87: *  RETURNS:     LPTSTR value corresponding to iIndex in LOOKUPENTRY array,
                     88: *               or 0
                     89: *
                     90: *  LOCAL VARS:  int i - loop variable
                     91: *
                     92: \******************************************************************************/
                     93: 
                     94: LPTSTR lpszLookupInt (PLOOKUPENTRY pLookup, int iIndex, int iMaxEntries)
                     95: {
                     96:   int i;
                     97: 
                     98:   for (i = 0; i < iMaxEntries; i++)
                     99: 
                    100:     if ((pLookup + i)->x.iIndex == iIndex)
                    101: 
                    102:       return (pLookup + i)->lpszValue;
                    103: 
                    104:   return (LPTSTR) NULL;
                    105: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.