⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utilities.c

📁 在嵌入式系统中对Lattice CPLD软件升级时所需的VME文件生成所需源代码。将一个链上的不同厂家的CPLD产生的SVF文件转换成VME文件
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <malloc.h>

void TrimRight( char * a_pszLine )
{
	int iIndex;

	if (!a_pszLine) {
		return;
	}

	for ( iIndex = strlen( a_pszLine ); iIndex >= 0; iIndex-- ) {
		if ( ( a_pszLine[ iIndex ] < 0x21 ) || ( a_pszLine[ iIndex ] > 0x7E ) ) {
			a_pszLine[ iIndex ] = '\0';
		}
		else {
			break;
		}
	}
}

void TrimLeft( char * a_pszLine )
{
	int iTemp;
	char * pszTempLine;

	if ( !a_pszLine ) {
		return;
	}

	pszTempLine = ( char * ) malloc( strlen( a_pszLine ) + 1 );
	strcpy( pszTempLine, a_pszLine );
	
	for ( iTemp = 0; iTemp < ( int ) strlen( a_pszLine ); iTemp++ ) {
		if ( ( a_pszLine[ iTemp ] >= 0x21 ) && ( a_pszLine[ iTemp ] <= 0x7E ) ) {
			break;
		}
	}

	strcpy( a_pszLine, pszTempLine + iTemp );
	free( pszTempLine );
	pszTempLine = NULL;
}

int stricmp( const char * a_szFirst, const char * a_szSecond )
{
	int iRetCode;
	char * pszFirst = NULL;
	char * pszSecond = NULL;

	if ( !a_szFirst || !a_szSecond ) {
		return -1;
	}

	pszFirst = ( char * ) malloc( strlen( a_szFirst ) + 1 );
	pszSecond = ( char * ) malloc( strlen( a_szSecond ) + 1 );
	
	if ( !pszFirst || !pszSecond ) {
		return -1;
	}

	strcpy( pszFirst, a_szFirst );
	strcpy( pszSecond, a_szSecond );
	strlwr( pszFirst );
	strlwr( pszSecond );

	iRetCode = strcmp( pszFirst, pszSecond );

	free( pszFirst );
	free( pszSecond );
	pszFirst = NULL;
	pszSecond = NULL;
	return ( iRetCode );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -