home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / D4SEEK_S.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-19  |  1.3 KB  |  69 lines

  1.  
  2. /*  d4seek_str.c   (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3.  
  4.     Locates and reads the record.
  5.  
  6.     Returns
  7.  
  8.        0 Success
  9.        1 Inexact Find
  10.        2 On record after
  11.        3 EOF
  12.       -1 Error
  13. */
  14.  
  15. #include <string.h>
  16.  
  17. #include "d4all.h"
  18. #include "u4error.h"
  19.  
  20. extern  INDEX *v4index ;
  21.  
  22.  
  23. int  d4seek_str( char *str )
  24. {
  25.    INDEX *index_ptr ;
  26.    int    index_ref ;
  27.  
  28.    if ( (index_ref = i4seek_ref()) < 0 )
  29.    {
  30.       u4error( E_NO_INDEX, d4name(), (char *) 0 ) ;
  31.       return( -1 ) ;
  32.    }
  33.  
  34.    index_ptr=  v4index+ index_ref ;
  35.  
  36.    #ifdef CLIPPER
  37.    if ( index_ptr->i_type == 'N' )
  38.    {
  39.       char  seek_buf[33] ;
  40.  
  41.       strncpy( seek_buf, str, sizeof(seek_buf) ) ;
  42.       seek_buf[32] = '\000' ;
  43.       c4clip( seek_buf, (int) strlen(seek_buf) ) ;
  44.  
  45.       d4seek_key( index_ref, seek_buf ) ;
  46.    }
  47.    else
  48.       return( d4seek_key( index_ref, str)) ;
  49.    #else
  50.    {
  51.       double d ;
  52.  
  53.       switch ( index_ptr->i_type )
  54.       {
  55.      case 'C':
  56.           return( d4seek_key( index_ref, str) ) ;
  57.  
  58.      case 'D':
  59.         c4dt_julian( str, &d ) ;
  60.           return( d4seek_key( index_ref, &d)) ;
  61.  
  62.      default:
  63.         d =  c4atod( str, (int) strlen(str) ) ;
  64.           return( d4seek_key( index_ref, &d)) ;
  65.       }
  66.    }
  67.    #endif
  68. }
  69.