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

📄 p80.c

📁 這是我個人編寫
💻 C
字号:
#include <dos.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#define Revision"\
     Port 80  Test Utility      Rev1.01                   Built date:07/14/2004 \n\
-----------------------------------------------------------------Jonathan_chiou\n"
#define Help"\
Usage: comp.exe <Command>\n\
<Commands>\n\
  /T:[Time]	:It sets for waiting time.[Time]unit is * ms . \n\
  /P		:Establish and see one off and stop and wait for the wanton key\n\
		:each time. \n\
  /R		:Send repeatedly off within waiting time. \n\
  /D:[Data]	:Output Port 80 Data\n\
<Example>\n\
  comp.exe /D:AA,FF,00,55 /P\n\n\
<Return Code>\n\
  PASS : 0\n\
  FAIL : 1\n"

char HexToInt(char *);
int DecToInt(char *);
int Fail(void);
int Pass(void);

unsigned char Buffer[32];
char BufferCount;
char P_F,R_F;
int time;

int main(int argc,char *argv[])
{
  int i,j;
  char *p;
  char temp;
  char d_time;
  time = 0;
  P_F = 0;
  R_F = 0;
  BufferCount = 0;

  if((argc == 2) && (argv[1][1] == '?'))
  {
  clrscr();
  puts(Revision);
  puts(Help);
  return(1);
  }

  for(i = 1;i < argc;i++)
     {
	if((argv[i][1] == 'T') || (argv[i][1] == 't'))
	{   time = DecToInt(&argv[i][3]);  }
	else if((argv[i][1] == 'P') || (argv[i][1] == 'p'))   P_F = 1;
	else if((argv[i][1] == 'R') || (argv[i][1] == 'r'))   R_F = 1;
	else if((argv[i][1] == 'D') || (argv[i][1] == 'd'))
	  {
	    p = strtok(&argv[i][3],",");
	    while( p != NULL)
	    {Buffer[BufferCount] = HexToInt(p);
	     BufferCount ++;
	     p = strtok(NULL,",");
	    }
	  }
     }
  clrscr();
  puts(Revision);
  for(i = 0 ; i < BufferCount; i++)
  {
	if( R_F == 1 )
	{
	  d_time = time / 1000;
	  for(j = 0;j < 1000;j++)
	  {
	  outportb(0x80,Buffer[i]);
	  delay(d_time);
	  }
	}
	else
	{
	  outportb(0x80,Buffer[i]);
	  delay(time);
	}
	if( P_F == 1 )
	  { printf("\n\nCheck whether DEBUG LED is [ %x ].\n[Y/N]?\n",Buffer[i]);
	    do
	    {
	      temp = getch();
	      if((temp == 'Y') || (temp == 'y')) break;
	      if((temp == 'N') || (temp == 'n')) return Fail();
	    }while(1);
	  }

  }
  return Pass();
}
char HexToInt(char *string)
{
       char sum = 0;
       int i,length;
       length = strlen(string);
       strupr(string);
       if((string[length-1] == '\n') ||(string[length-1] == '\0')) length--;
       for(i = 0;i < length;i++)
       {
	 if(!((('0'<=string[i])&&(string[i]<='9'))||(('A'<=string[i])&&(string[i]<='F'))))
		return(-1);
	 if(string[i] >= 'A') sum = ((sum * 16) + (string[i] - 'A' + 10));
	 else sum = ((sum * 16) + (string[i] - '0'));
       }
       return(sum);
}

int DecToInt(char *string)
{
       int sum = 0;
       int i,length;
       length = strlen(string);
       strupr(string);
       if((string[length-1] == '\n') ||(string[length-1] == '\0')) length--;
       for(i = 0;i < length;i++)
       {
	 if(!(('0'<=string[i])&&(string[i]<='9')))
		return(-1);
	 else sum = ((sum * 10) + (string[i] - '0'));
       }
       return(sum);
}

int Fail()
{
 char FAIL[]={"圹圹圹圹?                                圹郯  "
	      "圹圹圹圹?  圹圹郯   圹圹圹郯 圹郯       圹圹郯 "
	      "圹郯       圹圹圹郯    圹郯   圹郯      圹圹圹郯"
	      "圹郯      圹郯  圹郯   圹郯   圹郯      圹圹圹郯"
	      "圹圹圹圹?圹郯  圹郯   圹郯   圹郯       圹圹郯 "
	      "圹圹圹圹?圹圹圹圹郯   圹郯   圹郯        圹郯  "
	      "圹郯      圹郯  圹郯   圹郯   圹郯         郯   "
	      "圹郯      圹郯  圹郯   圹郯   圹郯   郯         "
	      "圹郯      圹郯  圹郯 圹圹圹郯 圹圹圹圹?  圹郯  "};
 char buffer[864];
 int i,j = 0;
 clrscr();
 for(i = 0 ;i < 864;i++,j++)
    {
     buffer[i] = FAIL[j];
     i++;
     buffer[i] = 0x8c;
    }
 puttext(18,16,65,24,buffer);
 return(1);
}

int Pass()
{
 char PASS[]={" 圹圹圹?                                 圹郯  "
	      "圹圹圹圹?  圹圹郯    圹圹郯   圹圹郯    圹圹郯 "
	      "圹?  圹? 圹圹圹郯  圹?  郯 圹?  郯  圹圹圹郯"
	      "圹?  圹?圹郯  圹郯 圹?     圹?      圹圹圹郯"
	      "圹圹圹圹?圹郯  圹郯 圹圹郯   圹圹郯     圹圹郯 "
	      "圹圹圹郯  圹圹圹圹郯  圹圹圹? 圹圹圹?   圹郯  "
	      "圹郯      圹郯  圹郯      圹?     圹?    郯   "
	      "圹郯      圹郯  圹郯 郯   圹?郯   圹?         "
	      "圹郯      圹郯  圹郯 圹圹圹? 圹圹圹?    圹郯  "};
 char buffer[864];
 int i,j = 0;
 clrscr();
 for(i = 0 ;i < 864;i++,j++)
    {
     buffer[i] = PASS[j];
     i++;
     buffer[i] = 0x8a;
    }
 puttext(18,16,65,24,buffer);
 return(0);
}

⌨️ 快捷键说明

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