home *** CD-ROM | disk | FTP | other *** search
-
- /* (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved. */
-
- #include "d4all.h"
- #include "p4misc.h"
-
- #include <string.h>
-
-
- /* u4name_full.c
-
- If a file name does not have an extension, a default is added.
- */
-
- void u4name_full( char *result_name, char *in_name, char *default_extension )
- {
- int len, i ;
- char *ptr ;
-
- strcpy( result_name, in_name ) ;
-
- len = (int) strlen( result_name ) ;
- if ( len > 64 ) len = 64 ;
- while ( len >= 0 && (result_name[len-1] == '\000' || result_name[len-1] == ' ') ) len-- ;
- result_name[len] = '\000' ;
- result_name[len+1] = '\000' ; /* For the 'strcat' after '.' has been added. */
-
- u4upper( 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( 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( char *result_name, char *in_name, int give_dir, int give_ext)
- {
- char *start_ptr ;
- int len, i ;
-
- start_ptr = in_name ;
- len = (int) 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 = (int) 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 ;
- }
- }
-
- /* Trim any extra blanks. */
- while ( start_ptr[len-1] == ' ' && len > 0 ) len-- ;
- memmove( result_name, start_ptr, (size_t) len ) ;
- result_name[len] = '\000' ;
- }
-
-
- int u4ptr_equal( void *p1, void *p2 )
- {
- return( p1 == p2 ) ;
- }
-