home *** CD-ROM | disk | FTP | other *** search
-
- /* d4seek.c (c)Copyright Sequiter Software Inc., 1987, 1988, 1989. All rights reserved.
-
- Locates and reads the record.
-
- Returns
- 0 Success
- 1 Inexact Find
- 2 On record after
- 3 EOF
- -1 Error
-
- */
-
- #include "d4base.h"
- #include "u4error.h"
- #include <string.h>
-
- extern BASE *v4base ;
- extern INDEX *v4index ;
- extern int v4cur_base ;
-
-
- d4seek( search_string )
- void *search_string ;
- {
- BASE *base_ptr ;
- int rc, index_ref ;
-
- if ( v4cur_base < 0 )
- {
- u4error( E_D_MISSING, (char *) 0 ) ;
- return( -1 ) ;
- }
-
- base_ptr = v4base + v4cur_base ;
-
- if ( base_ptr->current_index >= 0)
- index_ref = base_ptr->current_index ;
- else
- index_ref = base_ptr->index_ref ;
-
- if (index_ref < 0)
- {
- u4error( E_NO_INDEX, base_ptr->name, (char *) 0 ) ;
- return( -1 ) ;
- }
-
- #ifdef CLIPPER
- if ( v4index[index_ref].i_type == 'N' ||
- v4index[index_ref].i_type == 'F' )
- {
- char seek_buf[32] ;
- c4dtok( index_ref, *((double *)search_string), seek_buf ) ;
- rc = i4seek( index_ref, seek_buf ) ;
- }
- else
- rc = i4seek( index_ref, search_string) ;
- #else
- if ( v4index[index_ref].i_type == 'D' )
- {
- double seek_doub ;
- if ( c4dt_index( search_string, &seek_doub ) < 0)
- {
- u4error( E_DATE, "d4seek Date:", search_string, (char *) 0 ) ;
- return -1 ;
- }
- rc = i4seek( index_ref, (char *) &seek_doub ) ;
- }
- else
- rc = i4seek( index_ref, search_string) ;
- #endif
-
- if ( rc == 3)
- {
- memset( base_ptr->buffer, (int) ' ', (size_t) base_ptr->buffer_len ) ;
- base_ptr->rec_num = 0 ;
- return( 3 ) ;
- }
-
- if ( d4go( b4key(base_ptr->current_index)->rec_num ) < 0 ) return( -1 ) ;
- return( rc ) ;
- }
-
-