/
Sapphire/bin/
Sapphire/db/
Sapphire/db/OLC_rooms/
Sapphire/db/abi/
Sapphire/db/em_src/
Sapphire/db/helps/
Sapphire/db/helps/emman/ifunc/
Sapphire/db/npcs/Tatt/
Sapphire/db/objects/Tatt/
Sapphire/db/q_data/
Sapphire/db/rooms/Tatt/
Sapphire/doc/
Sapphire/doc/em/
Sapphire/etc/
Sapphire/src/abic/
Sapphire/src/areacon/
Sapphire/src/client/
Sapphire/src/embc/
Sapphire/src/emi/
Sapphire/src/emi/test/
Sapphire/src/include/
Sapphire/src/sapphire/em/
Sapphire/src/tcon/
/*
 * Copyright (C) 1995-1997 Christopher D. Granz
 *
 * This header may not be removed.
 *
 * Refer to the file "License" included in this package for further
 * information and before using any of the following.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "sapphire.h"


/*
 * Functions
 */

/*
 * Returns a file type number given a filename.
 */
int get_file_type( char *pFilename )
{
    if ( ( pFilename = strrchr( pFilename, '.' ) ) != NULL )
    {
        int i;

        for ( i = 0; snFileTypeTable[i].pName[0] != '\0'; i++ )
        {
            if ( str_compare( snFileTypeTable[i].pName, pFilename ) == TRUE )
                return ( snFileTypeTable[i].iNumber );
        }
    }

    return ( 0 );
}


/*
 * Returns a help structure given a keyword.
 */
HELP_DATA *get_help( char *pKeyword )
{
    HELP_DATA *pHelp;

    for ( pHelp = pHelpList; pHelp != NULL; pHelp = pHelp->pNext )
    {
        if ( multi_compare_2( pKeyword, pHelp->pKeywords ) == TRUE )
            return ( pHelp );
    }

    return ( NULL );
}


/*
 * Returns an NPC index structure given a number.
 */
NPC_INDEX_DATA *get_npc_index( int iNumber )
{
    NPC_INDEX_DATA *pNPCIndex;

    for ( pNPCIndex = *( ppNPCIndexList + ( iNumber % iHashListSize ) );
      pNPCIndex != NULL; pNPCIndex = pNPCIndex->pNext )
    {
        if ( pNPCIndex->iNumber == iNumber )
            return ( pNPCIndex );
    }

    return ( NULL );
}


/*
 * Returns an object index structure given a number.
 */
OBJ_INDEX_DATA *get_object_index( int iNumber )
{
    OBJ_INDEX_DATA *pObjIndex;

    for ( pObjIndex = *( ppObjIndexList + ( iNumber % iHashListSize ) );
      pObjIndex != NULL; pObjIndex = pObjIndex->pNext )
    {
        if ( pObjIndex->iNumber == iNumber )
            return ( pObjIndex );
    }

    return ( NULL );
}


/*
 * Returns a room index structure given a number.
 */
ROOM_INDEX_DATA *get_room_index( int iNumber )
{
    ROOM_INDEX_DATA *pRoomIndex;

    for ( pRoomIndex = *( ppRoomIndexList + ( iNumber % iHashListSize ) );
      pRoomIndex != NULL; pRoomIndex = pRoomIndex->pNext )
    {
        if ( pRoomIndex->iNumber == iNumber )
            return ( pRoomIndex );
    }

    return ( NULL );
}


/*
 * Returns a sex number given a string.
 */
int get_sex_number( char *pName )
{
    int i;

    for ( i = 0; snSexTable[i].pName[0] != '\0'; i++ )
    {
        if ( str_compare( snSexTable[i].pName, pName ) == TRUE )
            return ( snSexTable[i].iNumber );
    }

    return ( 0 );
}


/*
 * Returns a sex string given a number.
 */
char *get_sex_string( int iNumber )
{
    int i;

    for ( i = 0; snSexTable[i].pName[0] != '\0'; i++ )
    {
        if ( iNumber == snSexTable[i].iNumber )
            return ( snSexTable[i].pName );
    }

    return ( EMPTY_STRING );
}


int get_hair_color_number( char *pName )
{
    int i;

    for ( i = 0; snHairColorTable[i].pName[0] != '\0'; i++ )
    {
        if ( str_compare( snHairColorTable[i].pName, pName ) == TRUE )
            return ( snHairColorTable[i].iNumber );
    }

    return ( 0 );
}


char *get_hair_color_string( int iNumber )
{
    int i;

    for ( i = 0; snHairColorTable[i].pName[0] != '\0'; i++ )
    {
        if ( iNumber == snHairColorTable[i].iNumber )
            return ( snHairColorTable[i].pName );
    }

    return ( EMPTY_STRING );
}


int get_eye_color_number( char *pName )
{
    int i;

    for ( i = 0; snEyeColorTable[i].pName[0] != '\0'; i++ )
    {
        if ( str_compare( snEyeColorTable[i].pName, pName ) == TRUE )
            return ( snEyeColorTable[i].iNumber );
    }

    return ( 0 );
}


char *get_eye_color_string( int iNumber )
{
    int i;

    for ( i = 0; snEyeColorTable[i].pName[0] != '\0'; i++ )
    {
        if ( iNumber == snEyeColorTable[i].iNumber )
            return ( snEyeColorTable[i].pName );
    }

    return ( EMPTY_STRING );
}


int get_race_number( char *pName )
{
    int i;

    for ( i = 0; rRaceTable[i].pName[0] != '\0'; i++ )
    {
        if ( str_compare( rRaceTable[i].pName, pName ) == TRUE )
            return ( rRaceTable[i].iNumber );
    }

    return ( 0 );
}


char *get_race_string( int iNumber )
{
    int i;

    for ( i = 0; rRaceTable[i].pName[0] != '\0'; i++ )
    {
        if ( iNumber == rRaceTable[i].iNumber )
            return ( rRaceTable[i].pName );
    }

    return ( EMPTY_STRING );
}


char *get_race_string_2( int iNumber )
{
    char *pOutput = EMPTY_STRING;
    int i;

    for ( i = 0; rRaceTable[i].pName[0] != '\0'; i++ )
    {
        if ( iNumber == rRaceTable[i].iNumber )
        {
            sprintf( ( pOutput = new_buffer( ) ), "%s %s",
              rRaceTable[i].pConj, rRaceTable[i].pName );
            break;
        }
    }

    return ( pOutput );
}


int get_race_index( int iNumber )
{
    int i;

    for ( i = 0; rRaceTable[i].pName[0] != '\0'; i++ )
    {
        if ( rRaceTable[i].iNumber == iNumber )
            break;
    }

    return ( i );
}


int get_position_number( char *pName )
{
    int i;

    for ( i = 0; snPositionTable[i].pName[0] != '\0'; i++ )
    {
        if ( str_compare( snPositionTable[i].pName, pName ) == TRUE )
            return ( snPositionTable[i].iNumber );
    }

    return ( 0 );
}


char *get_position_string( int iNumber )
{
    int i;

    for ( i = 0; snPositionTable[i].pName[0] != '\0'; i++ )
    {
        if ( iNumber == snPositionTable[i].iNumber )
            return ( snPositionTable[i].pName );
    }

    return ( EMPTY_STRING );
}


int get_sector_number( char *pName )
{
    int i;

    for ( i = 0; snSectorTable[i].pName[0] != '\0'; i++ )
    {
        if ( str_compare( snSectorTable[i].pName, pName ) == TRUE )
            return ( snSectorTable[i].iNumber );
    }

    return ( 0 );
}


char *get_sector_string( int iNumber )
{
    int i;

    for ( i = 0; snSectorTable[i].pName[0] != '\0'; i++ )
    {
        if ( iNumber == snSectorTable[i].iNumber )
            return ( snSectorTable[i].pName );
    }

    return ( EMPTY_STRING );
}


/*
 * End of lookup.c
 */