home *** CD-ROM | disk | FTP | other *** search
-
- /* (c)Copyright Sequiter Software Inc., 1987, 1988, 1989. All rights reserved. */
-
- #include "d4base.h"
-
- #include <string.h>
-
-
- /* u4name_full.c
-
- If a file name does not have an extension, a default is added.
- */
-
- void u4name_full( result_name, in_name, default_extension )
- char *result_name, *in_name, *default_extension ;
- {
- int len, i ;
- char *ptr ;
-
- strcpy( result_name, in_name ) ;
-
- len = strlen( result_name ) ;
- if ( len > 64 ) len = 64 ;
- while ( len >= 0 && (result_name[len-1] == '\0' || result_name[len-1] == ' ') ) len-- ;
- result_name[len] = '\0' ;
-
- strupr( result_name ) ;
-
- for ( i=len-1, ptr= result_name+len-1; i >= 0; i--,ptr-- )
- {
- if ( *ptr == '\\' || *ptr == '\/' || *ptr == '.' ) break ;
- }
- if ( i < 0 || *ptr != '.' )
- {
- /* Add Extension */
- if ( *default_extension == '.' )
- strcat( result_name + len, default_extension ) ;
- else
- {
- result_name[len++] = '.' ;
- strcat( result_name + len, default_extension ) ;
- }
- }
- }
-
-
- /* u4name_char.c
-
- Returns TRUE iff it is a valid dBase field or function name character
- */
-
- u4name_char( ch)
- char ch ;
- {
- return ( ch>='a' && ch<='z' ||
- ch>='A' && ch<='Z' ||
- ch>='0' && ch<='9' ||
- ch=='\\' || ch=='.' || ch=='_' || ch==':' ) ;
- }
-
-
- /* u4name_part
-
- Copies up to 8 characters of the file name. No directory
- or file extension information is included.
- */
-
- void u4name_part( result_name, in_name, give_dir, give_ext )
- char *result_name, *in_name ;
- int give_dir, give_ext ;
- {
- char *start_ptr ;
- int len, i ;
-
- start_ptr = in_name ;
- len = strlen(in_name) ;
-
- if ( ! give_dir )
- {
- start_ptr = in_name+ len ;
-
- while ( --start_ptr >= in_name )
- if ( *start_ptr == ':' || *start_ptr == '\\' || *start_ptr == '\/' )
- break ;
-
- start_ptr++ ;
-
- len = strlen(start_ptr) ;
- }
-
- if ( ! give_ext )
- {
- if ( ! give_dir && len > 8 ) len = 8 ;
-
- for ( i=len; i >= 0; i-- )
- if ( start_ptr[i] == '.' )
- {
- len = i ;
- break ;
- }
- }
-
- memmove( result_name, start_ptr, (size_t) len ) ;
- result_name[len] = '\0' ;
- }