File:  [WindowsNT SDKs] / q_a / samples / printer / lookup.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 18:29:19 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: ntsdk-jun-1992, HEAD
Microsoft Windows NT Build 297 06-28-1992

/******************************************************************************\
*
*  MODULE:      LOOKUP.C
*
*  PURPOSE:     Provides supporting functions for doing lookups in
*               LOOKUPENTRY tables.
*
*  FUNTIONS:    dwLookupWord()  - given WORD index returns DWORD value
*               iLookupWord()   - given WORD index returns int value
*               lpszLookupInt() - given int index returns LPSTR value
*
\******************************************************************************/

#include <windows.h>
#include "lookup.h"



/******************************************************************************\
*
*  FUNCTION:    dwLookupWord
*
*  INPUTS:      pLookup     - pointer to LOOKUPENTRY array
*               wIndex      - wIndex to search for in array
*               iMaxEntries - number elements in array
*
*  RETURNS:     DWORD value corresponding to wIndex in LOOKUPENTRY array,
*               or 0
*
*  LOCAL VARS:  int i - loop variable
*
\******************************************************************************/

DWORD dwLookupWord (PLOOKUPENTRY pLookup, WORD wIndex, int iMaxEntries)
{
  int i;

  for (i = 0; i < iMaxEntries; i++)

    if ((pLookup + i)->x.wIndex == wIndex)

      return (pLookup + i)->v.dwValue;

  return 0;
}



/******************************************************************************\
*
*  FUNCTION:    iLookupWord
*
*  INPUTS:      pLookup     - pointer to LOOKUPENTRY array
*               wIndex      - wIndex to search for in array
*               iMaxEntries - number elements in array
*
*  RETURNS:     int value corresponding to wIndex in LOOKUPENTRY array, or
*               0
*
*  LOCAL VARS:  int i - loop variable
*
\******************************************************************************/

int iLookupWord (PLOOKUPENTRY pLookup, WORD wIndex, int iMaxEntries)
{
  int i;

  for (i = 0; i < iMaxEntries; i++)

    if ((pLookup + i)->x.wIndex == wIndex)

      return (pLookup + i)->v.iValue;

  return 0;
}



/******************************************************************************\
*
*  FUNCTION:    lpszLookupInt
*
*  INPUTS:      pLookup     - pointer to LOOKUPENTRY array
*               iIndex      - iIndex to search for in array
*               iMaxEntries - number elements in array
*
*  RETURNS:     LPTSTR value corresponding to iIndex in LOOKUPENTRY array,
*               or 0
*
*  LOCAL VARS:  int i - loop variable
*
\******************************************************************************/

LPTSTR lpszLookupInt (PLOOKUPENTRY pLookup, int iIndex, int iMaxEntries)
{
  int i;

  for (i = 0; i < iMaxEntries; i++)

    if ((pLookup + i)->x.iIndex == iIndex)

      return (pLookup + i)->lpszValue;

  return (LPTSTR) NULL;
}

unix.superglobalmegacorp.com

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