/* DEF_FILE (c) Adeline 1993 */ #include "\projet\lib386\lib_sys\adeline.h" #include "\projet\lib386\lib_sys\lib_sys.h" #include #include #include #include #include /*══════════════════════════════════════════════════════════════════════════* █▀▀▀▄ █▀▀▀▀ █▀▀▀▀ █▀▀▀▀ █ █ █▀▀▀▀ ██ █ ██▀▀ ██▀▀ ██▀▀ ██ ██ ██▀▀ ▀▀▀▀ ▀▀▀▀▀ ▀▀ ▀▀▀▀▀ ▀▀ ▀▀ ▀▀▀▀▀ ▀▀▀▀▀ *══════════════════════════════════════════════════════════════════════════*/ /*──────────────────────────────────────────────────────────────────────────*/ UBYTE DefString[256] ; UBYTE DefValue[50] ; LONG DefHandle ; //LONG DefHandleC ; //LONG DefModeCopy = FALSE ; UBYTE *PtrDef ; UBYTE *OrgPtrDef ; UBYTE *EndPtrDef ; /*══════════════════════════════════════════════════════════════════════════*/ #ifdef OCAZOU void NextLine() { UBYTE c ; do /* saute cr/lf espace */ { if( Read( DefHandle, &c, 1L ) == 0L ) return ; if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ; } while( c >= 32 ) ; } #endif /*══════════════════════════════════════════════════════════════════════════*/ /* LONG ReadWord() { UBYTE *ptr ; UBYTE c ; ptr = DefString ; do // saute cr/lf espace { if( Read( DefHandle, &c, 1L ) == 0L ) return FALSE ; if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ; } while( c <= 32 ) ; do // lit mot { *ptr++ = c ; if( Read( DefHandle, &c, 1L ) == 0L ) c = 26 ; else if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ; } while( c > 32 ) ; *ptr++ = 0 ; return TRUE ; } */ LONG PtrDefReadWord() { UBYTE *ptr ; UBYTE c ; ptr = DefString ; do /* saute cr/lf espace */ { c = *PtrDef++ ; if( PtrDef >= EndPtrDef ) return FALSE ; } while( c <= 32 ) ; do /* lit mot */ { *ptr++ = c ; c = *PtrDef++ ; if( PtrDef >= EndPtrDef ) c = 26 ; } while( c > 32 ) ; *ptr++ = 0 ; return TRUE ; } LONG PtrDefReadIdent() { UBYTE *ptr ; UBYTE c ; ptr = DefString ; do /* saute cr/lf espace */ { c = *PtrDef++ ; if( PtrDef >= EndPtrDef ) return FALSE ; } while( c <= 32 ) ; do /* lit mot */ { *ptr++ = c ; c = *PtrDef++ ; if( PtrDef >= EndPtrDef ) c = 26 ; } while( (c >= 32) AND (c != ':') ) ; while ( *--ptr == 32 ) ; *(ptr+1) = 0 ; return TRUE ; } /*══════════════════════════════════════════════════════════════════════════*/ /* LONG ReadString() { UBYTE *ptr ; UBYTE c ; ptr = DefString ; do // saute cr/lf espace { if( Read( DefHandle, &c, 1L ) == 0L ) return FALSE ; } while( c <= 32 ) ; do // lit phrase jusqu'a CR/LF { *ptr++ = c ; if( Read( DefHandle, &c, 1L ) == 0L ) c = 13 ; } while( c != 13 ) ; Read( DefHandle, &c, 1L ) ; // lit LF ou rien si fin *ptr++ = 0 ; return TRUE ; } */ void PtrDefReadString() { UBYTE *ptr ; UBYTE c ; ptr = DefString ; *ptr = 0 ; do // saute espace / tab { c = *PtrDef++ ; if(( PtrDef >= EndPtrDef ) OR ( c == 13 ) OR ( c == 10 ) ) return; } while( c <= 32 ) ; do /* lit phrase jusqu'a CR/LF */ { *ptr++ = c ; c = *PtrDef++ ; if( PtrDef >= EndPtrDef ) c = 13 ; } while( c >= 32 ) ; while ( *--ptr == 32 ) ; // PtrDef++ ; /* lit LF ou rien si fin */ *(ptr+1) = 0 ; } /*══════════════════════════════════════════════════════════════════════════*/ /* LONG ReadThisString() { UBYTE *ptr ; UBYTE c ; ptr = DefString ; do // saute espace { if( Read( DefHandle, &c, 1L ) == 0L ) { *ptr = 0 ; return TRUE ; } } while( c == 32 ) ; if( c > 31 ) { do // lit phrase jusqu'a CR/LF { *ptr++ = c ; if( Read( DefHandle, &c, 1L ) == 0L ) c = 13 ; } while( c != 13 ) ; } Read( DefHandle, &c, 1L ) ; // lit LF ou rien si fin *ptr++ = 0 ; return TRUE ; } */ LONG PtrDefReadThisString() { UBYTE *ptr ; UBYTE c ; ptr = DefString ; do // saute espace { c = *PtrDef++ ; if( PtrDef >= EndPtrDef ) return FALSE ; } while( c == 32 ) ; if( c>31 ) // on a pu lire un cr { do // lit phrase jusqu'a CR/LF { *ptr++ = c ; c = *PtrDef++ ; if( PtrDef >= EndPtrDef ) c = 13 ; } while( c != 13 ) ; } PtrDef++ ; // lit LF ou rien si fin *ptr++ = 0 ; return TRUE ; } /*══════════════════════════════════════════════════════════════════════════*/ /* LONG SearchIdentificator( UBYTE *identificateur ) { while( ReadWord() ) { if( DefString[strlen(DefString)-1] == ':' ) { DefString[strlen(DefString)-1] = 0 ; if( !strnicmp( identificateur, DefString, strlen( identificateur ) ) ) { return TRUE ; // identificateur trouve } } } return FALSE ; } */ LONG PtrDefSearchIdentificator( UBYTE *identificateur ) { while( PtrDefReadIdent() ) { /* if( DefString[strlen(DefString)-1] == ':' ) { DefString[strlen(DefString)-1] = 0 ; */ if( !stricmp( identificateur, DefString ) ) { return TRUE ; // identificateur trouve } // } } return FALSE ; } /*══════════════════════════════════════════════════════════════════════════*/ /* UBYTE *Def_ReadString( UBYTE *deffic, UBYTE *identificateur ) { DefHandle = OpenRead( deffic ) ; if( !DefHandle ) return 0L ; if( SearchIdentificator( identificateur ) ) { if( ReadThisString() ) { Close( DefHandle ) ; return DefString ; } } Close( DefHandle ) ; return 0L ; } */ UBYTE *Def_ReadString( UBYTE *deffic, UBYTE *identificateur ) { OrgPtrDef = PtrDef = LoadMalloc( deffic ) ; if( !PtrDef ) return 0 ; EndPtrDef = PtrDef + LoadMallocFileSize ; if( PtrDefSearchIdentificator( identificateur ) ) { PtrDefReadString() ; Free( OrgPtrDef ) ; return DefString ; } Free( OrgPtrDef ) ; return 0 ; } /*══════════════════════════════════════════════════════════════════════════*/ /* LONG Def_ReadValue( UBYTE *deffic, UBYTE *identificateur ) { LONG i ; LONG handle ; LONG value ; UBYTE c ; DefHandle = OpenRead( deffic ) ; if( !DefHandle ) return -1L ; if( SearchIdentificator( identificateur ) ) { if( ReadWord() ) { Close( DefHandle ) ; c =DefString[strlen(DefString)-1]&~32 ; if( c == 'H' ) { // hexa value = 0 ; for( i=0; i