#include "dbinc.h"
/*****************************************************************************
*                                                                            *
*      COMMON OCEANOGRAPHIC DATA ACCESS SYSTEM (CODAS)                       *
*                                                                            *
*      WRITTEN BY:  RAMON CABRERA, ERIC FIRING, and JULIE RANADA             *
*                   JOINT INSTITUTE FOR MARINE AND ATMOSPHERIC RESEARCH      *
*                   1000 POPE ROAD  MSB 404                                  *
*                   HONOLULU, HI 96822                                       *
*                                                                            *
*      VERSION:     3.00                                                     *
*                                                                            *
*      DATE:        APRIL 1989                                               *
*                                                                            *
*****************************************************************************/
/*

       FILE:  dbset.c

*/
/*-----------------------------------------------------------------------------

   FUNCTION:  DBSET

      It switches the current database.

   PARAMETERS:
   
      db_id = pointer to new database number to switch to

      ierr = pointer to error code

   RETURNS:  VOID

*/
#if PROTOTYPE_ALLOWED
void DBSET(int *db_id, int *ierr)
#else
void DBSET(db_id, ierr)
int *db_id, *ierr;
#endif
{
   int id;

   *ierr = 0;
   id = *db_id - 1;
   if (first_database_call)
   {
      *ierr = DB_IS_NOT_OPEN;
      return;
   }
   if ((id < 0) || (id >= MAX_OPEN_DATABASES))
   {
      *ierr = INVALID_DATABASE_NUMBER;
      return;
   }
   if (!(database_table[id]))
   {
      *ierr = DB_IS_NOT_OPEN;
      return;
   }
   db = database_table[id];
   current_database = id;
}

