home *** CD-ROM | disk | FTP | other *** search
-
- /* (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- f4str.c
- */
-
- /* f4str
-
- Returns a pointer to static string corresponding to the field.
- This string will end in a NULL character.
- */
-
- #include "d4base.h"
- #include "p4misc.h"
-
- #include <string.h>
-
- extern int v4cur_base ;
- extern BASE *v4base ;
-
- static char buffer[258] ;
-
- char * f4str( long field_ref)
- {
- int width ;
-
- width = f4width( field_ref ) ;
- if (width < 0) return (char *) 0 ;
- if (width > 256) width = 256 ;
- memcpy( buffer, f4ptr( field_ref) , (size_t) width ) ;
-
- buffer[width] = '\000' ;
-
- return( buffer) ;
- }
-
- int f4ncpy( long f_ref, char *ptr, int n )
- {
- int num_cpy ;
-
- num_cpy = f4width(f_ref) ;
- if ( n < num_cpy ) num_cpy = n ;
-
- /* 'f4ptr' returns a pointer to the field within the database record buffer. */
- memcpy( ptr, f4ptr(f_ref), (size_t) num_cpy ) ;
-
- if ( num_cpy < n ) ptr[num_cpy] = '\000' ;
-
- return( num_cpy ) ;
- }
-
- void f4r_str( long f_ref, char *str )
- {
- char *f_ptr ;
- int f_len, copy_bytes ;
-
- f_ptr = f4ptr(f_ref) ;
- f_len = f4width(f_ref) ;
- copy_bytes = (int) strlen(str) ;
-
- if ( copy_bytes > f_len ) copy_bytes = f_len ;
-
- /* Copy the data into the record buffer. */
- memcpy( f_ptr, str, (size_t) copy_bytes ) ;
-
- /* Make the rest of the field blank. */
- memset( f_ptr+copy_bytes, (int) ' ', (size_t) (f_len-copy_bytes) ) ;
-
- if ( v4base[v4cur_base].eof == 0 ) d4ptr()->buffer_changed = 1 ;
- }
-