예제 #1
0
파일: clibrary.c 프로젝트: fjrti/remix
/* print a double to a stream without using printf/sprintf */
void PrintFP(double Num, struct OutputStream *Stream)
{
    int Exponent = 0;
    int MaxDecimal;
    
    if (Num < 0)
    {
        PrintCh('-', Stream);
        Num = -Num;    
    }
    
    if (Num >= 1e7)
        Exponent = log10(Num);
    else if (Num <= 1e-7 && Num != 0.0)
        Exponent = log10(Num) - 0.999999999;
    
    Num /= pow(10.0, Exponent);    
    PrintInt((long)Num, 0, FALSE, FALSE, Stream);
    PrintCh('.', Stream);
    Num = (Num - (long)Num) * 10;
    if (abs(Num) >= 1e-7)
    {
        for (MaxDecimal = 6; MaxDecimal > 0 && abs(Num) >= 1e-7; Num = (Num - (long)(Num + 1e-7)) * 10, MaxDecimal--)
            PrintCh('0' + (long)(Num + 1e-7), Stream);
    }
    else
        PrintCh('0', Stream);
        
    if (Exponent != 0)
    {
        PrintCh('e', Stream);
        PrintInt(Exponent, 0, FALSE, FALSE, Stream);
    }
}
예제 #2
0
파일: clibrary.c 프로젝트: fjrti/remix
/* print a type to a stream without using printf/sprintf */
void PrintType(struct ValueType *Typ, IOFILE *Stream)
{
    switch (Typ->Base)
    {
        case TypeVoid:          PrintStr("void", Stream); break;
        case TypeInt:           PrintStr("int", Stream); break;
        case TypeShort:         PrintStr("short", Stream); break;
        case TypeChar:          PrintStr("char", Stream); break;
        case TypeLong:          PrintStr("long", Stream); break;
        case TypeUnsignedInt:   PrintStr("unsigned int", Stream); break;
        case TypeUnsignedShort: PrintStr("unsigned short", Stream); break;
        case TypeUnsignedLong:  PrintStr("unsigned long", Stream); break;
#ifndef NO_FP
        case TypeFP:            PrintStr("double", Stream); break;
#endif
        case TypeFunction:      PrintStr("function", Stream); break;
        case TypeMacro:         PrintStr("macro", Stream); break;
        case TypePointer:       if (Typ->FromType) PrintType(Typ->FromType, Stream); PrintCh('*', Stream); break;
        case TypeArray:         PrintType(Typ->FromType, Stream); PrintCh('[', Stream); if (Typ->ArraySize != 0) PrintSimpleInt(Typ->ArraySize, Stream); PrintCh(']', Stream); break;
        case TypeStruct:        PrintStr("struct ", Stream); PrintStr(Typ->Identifier, Stream); break;
        case TypeUnion:         PrintStr("union ", Stream); PrintStr(Typ->Identifier, Stream); break;
        case TypeEnum:          PrintStr("enum ", Stream); PrintStr(Typ->Identifier, Stream); break;
        case TypeGotoLabel:     PrintStr("goto label ", Stream); break;
        case Type_Type:         PrintStr("type ", Stream); break;
    }
}
예제 #3
0
void PlatformVPrintf(const char *Format, va_list Args)
{
    const char *FPos;
    
    for (FPos = Format; *FPos != '\0'; FPos++)
    {
        if (*FPos == '%')
        {
            FPos++;
            switch (*FPos)
            {
            case 's': PrintStr(va_arg(Args, char *), CStdOut); break;
            case 'd': PrintSimpleInt(va_arg(Args, int), CStdOut); break;
            case 'c': PrintCh(va_arg(Args, int), CStdOut); break;
            case 't': PrintType(va_arg(Args, struct ValueType *), CStdOut); break;
#ifndef NO_FP
            case 'f': PrintFP(va_arg(Args, double), CStdOut); break;
#endif
            case '%': PrintCh('%', CStdOut); break;
            case '\0': FPos--; break;
            }
        }
        else
            PrintCh(*FPos, CStdOut);
    }
}
예제 #4
0
static VOID PrintPound()
{
	WORD  wr = 0x0700;
	
	wr += '#';
	GotoHome();
	ChangeLine();
	PrintCh(wr);
}
예제 #5
0
void PrintSourceTextErrorLine(const char *FileName, const char *SourceText, int Line, int CharacterPos)
{
    int LineCount;
    const char *LinePos;
    const char *CPos;
    int CCount;

    PlatformSourceError(FileName, SourceText, Line, CharacterPos);
    return;

    if (SourceText != NULL)
    {
        /* find the source line */
        for (LinePos = SourceText, LineCount = 1; *LinePos != '\0' && LineCount < Line; LinePos++)
        {
            if (*LinePos == '\n')
                LineCount++;
        }

        /* display the line */
        for (CPos = LinePos; *CPos != '\n' && *CPos != '\0'; CPos++)
            PrintCh(*CPos, CStdOut);
        PrintCh('\n', CStdOut);

        /* display the error position */
        for (CPos = LinePos, CCount = 0; *CPos != '\n' && *CPos != '\0' && (CCount < CharacterPos || *CPos == ' '); CPos++, CCount++)
        {
            if (*CPos == '\t')
                PrintCh('\t', CStdOut);
            else
                PrintCh(' ', CStdOut);
        }
    }
    else
    {
        /* assume we're in interactive mode - try to make the arrow match up with the input text */
        for (CCount = 0; CCount < CharacterPos + strlen(INTERACTIVE_PROMPT_STATEMENT); CCount++)
            PrintCh(' ', CStdOut);
    }
    PlatformPrintf("^\n%s:%d: ", FileName, Line, CharacterPos);

}
예제 #6
0
파일: clibrary.c 프로젝트: fjrti/remix
/* sprintf(): print to a string */
void LibSPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
{
    struct OutputStream StrStream;
    
    StrStream.Putch = &SPutc;
    StrStream.i.Str.Parser = Parser;
    StrStream.i.Str.WritePos = Param[0]->Val->Pointer;

    GenericPrintf(Parser, ReturnValue, Param+1, NumArgs-1, &StrStream);
    PrintCh(0, &StrStream);
    ReturnValue->Val->Pointer = *Param;
}
예제 #7
0
파일: clibrary.c 프로젝트: fjrti/remix
/* print an integer to a stream without using printf/sprintf */
void PrintInt(long Num, int FieldWidth, int ZeroPad, int LeftJustify, struct OutputStream *Stream)
{
    if (Num < 0)
    {
        PrintCh('-', Stream);
        Num = -Num;
        if (FieldWidth != 0)
            FieldWidth--;
    }
    
    PrintUnsigned((unsigned long)Num, 10, FieldWidth, ZeroPad, LeftJustify, Stream);
}
예제 #8
0
//Shell thread's event handler.
static BOOL EventHandler(WORD wCommand,WORD wParam,DWORD dwParam)
{
	WORD wr = 0x0700;
	BYTE bt = 0x00;

	switch(wCommand)
	{
	case MSG_KEY_DOWN:
		bt = (BYTE)(dwParam);
		if(VK_RETURN == bt)
		{
			if(BufferPtr)
			{
				DoCommand();
			}
			PrintPrompt();
			break;
		}
		if(VK_BACKSPACE == bt)
		{
			if(0 != BufferPtr)
			{
				GotoPrev();
				BufferPtr --;
			}
			break;
		}
		else
		{
			if(MAX_BUFFER_LEN - 1 > BufferPtr)
			{
				CmdBuffer[BufferPtr] = bt;
				BufferPtr ++;
				wr += (BYTE)(dwParam);
				PrintCh(wr);
			}
		}
		break;
	case KERNEL_MESSAGE_TIMER:
	default:
		break;
	}
	return 0;
}
예제 #9
0
파일: clibrary.c 프로젝트: fjrti/remix
/* intrinsic functions made available to the language */
void GenericPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs, struct OutputStream *Stream)
{
    char *FPos;
    struct Value *NextArg = Param[0];
    struct ValueType *FormatType;
    int ArgCount = 1;
    int LeftJustify = FALSE;
    int ZeroPad = FALSE;
    int FieldWidth = 0;
    char *Format = Param[0]->Val->Pointer;
    
    for (FPos = Format; *FPos != '\0'; FPos++)
    {
        if (*FPos == '%')
        {
            FPos++;
            if (*FPos == '-')
            {
                /* a leading '-' means left justify */
                LeftJustify = TRUE;
                FPos++;
            }
            
            if (*FPos == '0')
            {
                /* a leading zero means zero pad a decimal number */
                ZeroPad = TRUE;
                FPos++;
            }
            
            /* get any field width in the format */
            while (isdigit((int)*FPos))
                FieldWidth = FieldWidth * 10 + (*FPos++ - '0');
            
            /* now check the format type */
            switch (*FPos)
            {
                case 's': FormatType = CharPtrType; break;
                case 'd': case 'u': case 'x': case 'b': case 'c': FormatType = &IntType; break;
#ifndef NO_FP
                case 'f': FormatType = &FPType; break;
#endif
                case '%': PrintCh('%', Stream); FormatType = NULL; break;
                case '\0': FPos--; FormatType = NULL; break;
                default:  PrintCh(*FPos, Stream); FormatType = NULL; break;
            }
            
            if (FormatType != NULL)
            { 
                /* we have to format something */
                if (ArgCount >= NumArgs)
                    PrintStr("XXX", Stream);   /* not enough parameters for format */
                else
                {
                    NextArg = (struct Value *)((char *)NextArg + MEM_ALIGN(sizeof(struct Value) + TypeStackSizeValue(NextArg)));
                    if (NextArg->Typ != FormatType && 
                            !((FormatType == &IntType || *FPos == 'f') && IS_NUMERIC_COERCIBLE(NextArg)) &&
                            !(FormatType == CharPtrType && (NextArg->Typ->Base == TypePointer || 
                                                             (NextArg->Typ->Base == TypeArray && NextArg->Typ->FromType->Base == TypeChar) ) ) )
                        PrintStr("XXX", Stream);   /* bad type for format */
                    else
                    {
                        switch (*FPos)
                        {
                            case 's':
                            {
                                char *Str;
                                
                                if (NextArg->Typ->Base == TypePointer)
                                    Str = NextArg->Val->Pointer;
                                else
                                    Str = &NextArg->Val->ArrayMem[0];
                                    
                                if (Str == NULL)
                                    PrintStr("NULL", Stream); 
                                else
                                    PrintStr(Str, Stream); 
                                break;
                            }
                            case 'd': PrintInt(ExpressionCoerceInteger(NextArg), FieldWidth, ZeroPad, LeftJustify, Stream); break;
                            case 'u': PrintUnsigned(ExpressionCoerceUnsignedInteger(NextArg), 10, FieldWidth, ZeroPad, LeftJustify, Stream); break;
                            case 'x': PrintUnsigned(ExpressionCoerceUnsignedInteger(NextArg), 16, FieldWidth, ZeroPad, LeftJustify, Stream); break;
                            case 'b': PrintUnsigned(ExpressionCoerceUnsignedInteger(NextArg), 2, FieldWidth, ZeroPad, LeftJustify, Stream); break;
                            case 'c': PrintCh(ExpressionCoerceUnsignedInteger(NextArg), Stream); break;
#ifndef NO_FP
                            case 'f': PrintFP(ExpressionCoerceFP(NextArg), Stream); break;
#endif
                        }
                    }
                }
                
                ArgCount++;
            }
        }
        else
            PrintCh(*FPos, Stream);
    }
}
예제 #10
0
파일: clibrary.c 프로젝트: fjrti/remix
/* print a single character a given number of times */
void PrintRepeatedChar(char ShowChar, int Length, struct OutputStream *Stream)
{
    while (Length-- > 0)
        PrintCh(ShowChar, Stream);
}
예제 #11
0
파일: clibrary.c 프로젝트: fjrti/remix
/* print a string to a stream without using printf/sprintf */
void PrintStr(const char *Str, struct OutputStream *Stream)
{
    while (*Str != 0)
        PrintCh(*Str++, Stream);
}
예제 #12
0
void ChartGridRelation()
{
    char sz[cchSzDef];
    int i, j, k, tot = cObjOpt, temp, m;
    char ignoreT[objMax];

    PrintHeader();     /* Display chart info */

#ifdef INTERPRET
    if (us.fInterpret && !us.fGridConfig) {
        InterpretGridRelation();
        return;
    }
#endif

    if (us.nRel == rcTransit) {
        for (m = 0; m <= cObjOpt; m++)
            ignoreT[m] = ignore2[m];
    } else if (us.nRel == rcProgress) {
        for (m = 0; m <= cObjOpt; m++)
            ignoreT[m] = ignore3[m];
    } else {
        for (m = 0; m<= cObjOpt; m++)
            ignoreT[m] = ignore[m];
    }

    PrintSz(" 2>");
    for (temp = 0, i = 0; i <= cObjOpt; i++) if (!ignoreT[i] && i != us.objCenter) {
            PrintCh(chV);
            AnsiColor(kObjA[i]);
            sprintf(sz, "%c%c%c", chObj3(i));
            PrintSz(sz);
            AnsiColor(kDefault);
            temp++;
        }
    PrintSz("\n1  ");
    for (i = 0; i <= tot; i++) if (!ignoreT[i] && i != us.objCenter) {
            PrintCh(chV);
            AnsiColor(kSignA(SFromZ(cp2.obj[i])));
            sprintf(sz, "%2d%c", (int)cp2.obj[i] % 30, chDeg0);
            PrintSz(sz);
            AnsiColor(kDefault);
        }
    PrintSz("\nV  ");
    for (i = 0; i <= tot; i++) if (!ignoreT[i] && i != us.objCenter) {
            PrintCh(chV);
            temp = SFromZ(cp2.obj[i]);
            AnsiColor(kSignA(temp));
            sprintf(sz, "%c%c%c", chSig3(temp));
            PrintSz(sz);
            AnsiColor(kDefault);
        }
    PrintL();
    for (j = 0; j <= cObjOpt; j++) if (!ignore[j] && j != us.objCenter)
            for (k = 1; k <= 4; k++) {
                if (k < 2)
                    PrintTab(chH, 3);
                else if (k == 2) {
                    AnsiColor(kObjA[j]);
                    sprintf(sz, "%c%c%c", chObj3(j));
                    PrintSz(sz);
                } else {
                    temp = SFromZ(cp1.obj[j]);
                    AnsiColor(kSignA(temp));
                    if (k == 3)
                        sprintf(sz, "%2d%c", (int)cp1.obj[j] - (temp-1)*30, chDeg0);
                    else
                        sprintf(sz, "%c%c%c", chSig3(temp));
                    PrintSz(sz);
                }
                if (k > 1)
                    AnsiColor(kDefault);
                for (i = 0; i <= tot; i++) if (!ignoreT[i] && i != us.objCenter) {
                        PrintCh((char)(k < 2 ? chC : chV));
                        temp = grid->n[i][j];
                        if (k > 1) {
                            if (i == j)
                                AnsiColor(kReverse);
                            AnsiColor(us.fGridConfig ? kSignA(temp) :
                                      kAspA[temp]);
                        }
                        if (k < 2)
                            PrintTab(chH, 3);
                        else if (k == 2) {
                            if (us.fGridConfig)
                                sprintf(sz, "%c%c%c", chSig3(temp));
                            else
                                sprintf(sz, "%s", temp ? szAspectAbbrev[temp] : "   ");
                            PrintSz(sz);
                        } else if (k == 3) {
                            if (us.fGridConfig) {
                                sprintf(sz, "%2d%c", grid->v[i][j]/3600, chDeg0);
                                PrintSz(sz);
                            } else if (grid->n[i][j]) {
                                if (grid->v[i][j] < 360000)
                                    sprintf(sz, "%c%2d", us.fAppSep ?
                                            (grid->v[i][j] < 0 ? 'a' : 's') :
                                                    (grid->v[i][j] < 0 ? '-' : '+'), abs(grid->v[i][j])/3600);
                                else
                                    sprintf(sz, "%3d", abs(temp)/60);
                                PrintSz(sz);
                            } else
                                PrintSz("   ");
                        } else {
                            if (grid->n[i][j]) {
                                sprintf(sz, "%02d'", (abs(grid->v[i][j])%3600)/60);
                                PrintSz(sz);
                            } else
                                PrintSz("   ");
                        }
                        AnsiColor(kDefault);
                    }
                PrintL();
            }
}
예제 #13
0
//Process user input.
//This is a private function can only be called by heditEntry.
static VOID __UserInput(HANDLE hFile)
{
#ifdef __CFG_SYS_DDF
	BYTE*                       pDataBuffer      = NULL;
	BYTE*                       pCurrPos         = NULL;
	DWORD                       dwDefaultSize    = 8192;      //Default file size is 8K.
	BOOL                        bCtrlDown        = FALSE;
	BYTE                        bt;
	WORD                        wr                            = 0x0700;
	__KERNEL_THREAD_MESSAGE     Msg;
	DWORD                       dwWrittenSize    = 0;

	pDataBuffer = (BYTE*)KMemAlloc(dwDefaultSize,KMEM_SIZE_TYPE_ANY);
	if(NULL == pDataBuffer)
	{
		PrintLine("  Can not allocate memory.");
		goto __TERMINAL;
	}
	pCurrPos = pDataBuffer;

	while(TRUE)
	{
		if(GetMessage(&Msg))
		{
			if(MSG_KEY_DOWN == Msg.wCommand)    //This is a key down message.
			{
				bt = (BYTE)Msg.dwParam;
				switch(bt)
				{
				case VK_RETURN:                  //This is a return key.
					if((DWORD)(pCurrPos - pDataBuffer) < dwDefaultSize - 2)
					{
						*pCurrPos ++ = '\r';     //Append a return key.
						*pCurrPos ++ = '\n';
						GotoHome();
						ChangeLine();            //Change to next line.
					}
					break;
				case VK_BACKSPACE:
					if(*pCurrPos == '\n')  //Enter encountered.
					{
						pCurrPos -= 2;     //Skip the \r\n.
					}
					else
					{
						pCurrPos -= 1;
					}
					GotoPrev();
					break;
				default:
					if(('c' == bt) || ('C' == bt) || ('z' == bt) || ('Z' == bt))
					{
						if(bCtrlDown)  //CtrlC or CtrlZ encountered.
						{
							goto __TERMINAL;
						}
					}
					if((DWORD)(pCurrPos - pDataBuffer) < dwDefaultSize)
					{
						*pCurrPos ++ = bt; //Save this character.
						wr += bt;
						PrintCh(wr);
						wr  = 0x0700;
					}
					break;
				}
			}
			else
			{
				if(VIRTUAL_KEY_DOWN == Msg.wCommand)
				{
					bt = (BYTE)Msg.dwParam;
					if(VK_CONTROL == bt)
					{
						bCtrlDown = TRUE;
					}
				}
				if(VIRTUAL_KEY_UP   == Msg.wCommand)
				{
					bt = (BYTE)Msg.dwParam;
					if(VK_CONTROL == bt)    //Control key up.
					{
						bCtrlDown = FALSE;
					}
				}
			}
		}
	}

__TERMINAL:
	IOManager.WriteFile((__COMMON_OBJECT*)&IOManager,
		hFile,
		(DWORD)(pCurrPos - pDataBuffer),
		pDataBuffer,
		&dwWrittenSize);
	if(pDataBuffer)
	{
		KMemFree(pDataBuffer,KMEM_SIZE_TYPE_ANY,0);
	}
	return;
#else
#endif
}
예제 #14
0
DWORD SysDiagStart(LPVOID p)
{
	CHAR                        strCmdBuffer[MAX_BUFFER_LEN];
	BYTE                        ucCurrentPtr                  = 0;
	BYTE                        bt;
	WORD                        wr                            = 0x0700;
	__KERNEL_THREAD_MESSAGE     Msg;
	DWORD                       dwRetVal;

	PrintPound();    //Print out the prompt.

	while(TRUE)
	{
		if(KernelThreadManager.GetMessage((__COMMON_OBJECT*)KernelThreadManager.lpCurrentKernelThread,&Msg))
		{
			if(MSG_KEY_DOWN == Msg.wCommand)    //This is a key down message.
			{
				bt = (BYTE)(Msg.dwParam);
				switch(bt)
				{
				case VK_RETURN:                //This is a return key.
					if(0 == ucCurrentPtr)      //There is not any character before this key.
					{
						PrintPound();
						break;
					}
					else
					{
						strCmdBuffer[ucCurrentPtr] = 0;    //Set the terminal flag.
						dwRetVal = CommandParser(strCmdBuffer);
						switch(dwRetVal)
						{
						case SYS_DIAG_CMD_PARSER_TERMINAL: //Exit command is entered.
							goto __TERMINAL;
						case SYS_DIAG_CMD_PARSER_INVALID:  //Can not parse the command.
							PrintLine("    Invalid command.");
							//PrintPound();
							break;
						case SYS_DIAG_CMD_PARSER_FAILED:
							PrintLine("Failed to process the command.");
							break;
						case SYS_DIAG_CMD_PARSER_SUCCESS:      //Process the command successfully.
							//PrintPound();
							break;
						default:
							break;
						}
						ucCurrentPtr = 0;    //Re-initialize the buffer pointer.
						PrintPound();
					}
					break;
				case VK_BACKSPACE:
					if(ucCurrentPtr)
					{
						ucCurrentPtr --;
						GotoPrev();
					}
					break;
				default:
					if(ucCurrentPtr < MAX_BUFFER_LEN)    //The command buffer is not overflow.
					{
						strCmdBuffer[ucCurrentPtr] = bt;
						ucCurrentPtr ++;
						wr += bt;
						PrintCh(wr);
						wr  = 0x0700;
					}
					break;
				}
			}
			else
			{
				if(Msg.wCommand == KERNEL_MESSAGE_TIMER)
				{
					PrintLine("Timer message received.");
				}
			}
		}
	}

__TERMINAL:
	return 0;
}
예제 #15
0
DWORD IoCtrlStart(LPVOID p)
{
	DWORD                    dwCurrentPtr       = 0;
	__KERNEL_THREAD_MESSAGE  Msg;
	BYTE                     bt;
	WORD                     wr                 = 0x0700;
	DWORD                    dwMapIndex         = 0;
	BOOL                     bValidCmd          = FALSE;
	__CMD_PARA_OBJ*          lpParamObj         = NULL;
	DWORD                    dwRetVal           = 0;

	PrintPound();            //Print out the prompt of this application.

	while(TRUE)
	{
		if(KernelThreadManager.GetMessage((__COMMON_OBJECT*)KernelThreadManager.lpCurrentKernelThread,&Msg))
		{
			if(MSG_KEY_DOWN == Msg.wCommand)  //This is a key down event.
			{
				bt = (BYTE)Msg.dwParam;
				if(VK_RETURN == bt)    //The ENTER key is pressed.
				{
					strCmdBuffer[dwCurrentPtr] = 0;  //Set the end flag.
					dwCurrentPtr               = 0;  //Set the pointer to begin.
					//
					//The following code handles the command.
					//

					lpParamObj = FormParameterObj(&strCmdBuffer[0]);
					if(NULL == lpParamObj)    //Can not create parameter object.
					{
						PrintLine("Fatal error occurs,application exit.");
						goto __TERMINAL;    //Exit the application.
					}
					if(0 != lpParamObj->byParameterNum)  //Valid parameter(s) exits.
					{
						while(IOCtrlCmdMap[dwMapIndex].lpszCommand)
						{
							if(StrCmp(IOCtrlCmdMap[dwMapIndex].lpszCommand,
								lpParamObj->Parameter[0]))
							{
								bValidCmd = TRUE;    //Find the valid command.
								break;
							}
							dwMapIndex ++;
						}
						if(bValidCmd)  //Handle the command.
						{
							dwRetVal = IOCtrlCmdMap[dwMapIndex].CommandRoutine(lpParamObj);
						}
						else
						{
							PrintLine("Unrecognized command.");
						}
					}

					bValidCmd      = FALSE;
					dwMapIndex     = 0;
					ReleaseParameterObj(lpParamObj);  //Release the parameter object.
					if(IOCTRL_TERMINAL == dwRetVal)
						goto __TERMINAL;
					PrintPound();
				}
				else
				if(VK_BACKSPACE == bt)  //Delete one character.
				{
					if(dwCurrentPtr)
					{
						dwCurrentPtr --;
						GotoPrev();    //Erase one character from screen.
					}
				}
				else  //This only a normal key down event.
				{
					if(dwCurrentPtr < MAX_BUFFER_LEN)  //If the buffer is not overflow.
					{
						strCmdBuffer[dwCurrentPtr] = bt;
						dwCurrentPtr ++;
						wr += bt;
						PrintCh(wr);                   //Print the character to screen.
						wr  = 0x0700;                  //Restore the chatacter's display
						                               //attribute.
					}
				}
			}
		}
	}

__TERMINAL:
	return 0;
}
예제 #16
0
static DWORD type(__CMD_PARA_OBJ* pCmdObj)
{
#ifdef __CFG_SYS_DDF
	HANDLE   hFile = NULL;
	CHAR     Buffer[128];
	DWORD    dwReadSize   = 0;
	DWORD    dwTotalRead  = 0;
	DWORD    i;
	CHAR     FullName[MAX_FILE_NAME_LEN];
	WORD     ch = 0x0700;

	if(pCmdObj->byParameterNum < 2)
	{
		PrintLine("  Please specify the file name to be displayed.");
		goto __TERMINAL;
	}
	strcpy(FullName,FsGlobalData.CurrentDir);
	strcat(FullName,pCmdObj->Parameter[1]);
	ToCapital(FullName);
		
	//Try to open the target file.
	hFile = IOManager.CreateFile((__COMMON_OBJECT*)&IOManager,
		FullName,
		FILE_ACCESS_READ,
		0,
		NULL);
	if(NULL == hFile)
	{
		PrintLine("  Please specify a valid and present file name.");
		goto __TERMINAL;
	}
	//Try to read the target file and display it.
	GotoHome();
	ChangeLine();
	do{
		if(!IOManager.ReadFile((__COMMON_OBJECT*)&IOManager,
			hFile,
			128,
			Buffer,
			&dwReadSize))
		{
			PrintLine("  Can not read the target file.");
			goto __TERMINAL;
		}
		for(i = 0;i < dwReadSize;i ++)
		{
			if('\r' == Buffer[i])
			{
				GotoHome();
				continue;
			}
			if('\n' == Buffer[i])
			{
				ChangeLine();
				continue;
			}
			ch += Buffer[i];
			PrintCh(ch);
			ch = 0x0700;
		}
		dwTotalRead += dwReadSize;
	}while(dwReadSize == 128);

	GotoHome();
	ChangeLine();
	_hx_sprintf(Buffer,"%d byte(s) read.",dwTotalRead);
	PrintLine(Buffer);

__TERMINAL:
	if(NULL != hFile)
	{
		IOManager.CloseFile((__COMMON_OBJECT*)&IOManager,
			hFile);
	}
	return SHELL_CMD_PARSER_SUCCESS;;
#else
	return FS_CMD_FAILED;
#endif
}
예제 #17
0
static void   SC_PrintCh(__SYSCALL_PARAM_BLOCK*  pspb)
{
	PrintCh((WORD)PARAM(0));
}
예제 #18
0
void ChartMidpointRelation()
{
    int cs[cSign + 1];
    char sz[cchSzDef];
    int mcut = -1, icut=-1, jcut=-1, mlo=-1, ilo=-1, jlo=-1, m, i, j, count = 0, l;
    long lSpanSum = 0;
    char ignoreT[objMax];

    if (us.nRel == rcTransit) {
        for (l = 0; l <= cObjOpt; l++)
            ignoreT[l] = FIgnore2(l);
    } else if (us.nRel == rcProgress) {
        for (l = 0; l <= cObjOpt; l++)
            ignoreT[l] = FIgnore3(l);
    } else {
        for (l = 0; l <= cObjOpt; l++)
            ignoreT[l] = FIgnore(l);
    }

    ClearB((lpbyte)cs, (cSign + 1)*(int)sizeof(int));
    loop {
        mlo = 21600;

        /* Search for the next closest midpoint farther down in the zodiac. */

        for (i = 0; i <= cObjOpt; i++) if (!FIgnore(i))
                for (j = 0; j <= cObjOpt; j++) if (!ignoreT[j]) {
                        m = (grid->n[j][i]-1)*30*60 + grid->v[j][i];
                        if ((m > mcut || (m == mcut && (i > icut ||
                                                        (i == icut && j > jcut)))) && m < mlo) {
                            ilo = i;
                            jlo = j;
                            mlo = m;
                        }
                    }
        if (mlo >= 21600)    /* Exit when no midpoint farther in zodiac found. */
            break;
        mcut = mlo;
        icut = ilo;
        jcut = jlo;
        count++;                               /* Display the current midpoint. */
#ifdef INTERPRET
        if (us.fInterpret) {                   /* Interpret it if -I in effect. */
            InterpretMidpointRelation(ilo, jlo);
            continue;
        }
#endif
        cs[mlo/60/30+1]++;
        sprintf(sz, "%4d: ", count);
        PrintSz(sz);
        PrintZodiac((real)mlo/60.0);
        PrintCh(' ');
        PrintAspect(ilo, SFromZ(cp1.obj[ilo]), (int)RSgn(cp1.dir[ilo]), 0,
                    jlo, SFromZ(cp2.obj[jlo]), (int)RSgn(cp2.dir[jlo]), 'M');
        AnsiColor(kDefault);
        m = (int)(MinDistance(cp1.obj[ilo], cp2.obj[jlo])*60.0);
        lSpanSum += m;
        sprintf(sz, "-%4d%c%02d' degree span.\n", m/60, chDeg1, m%60);
        PrintSz(sz);
    }

    PrintMidpointSummary(cs, count, lSpanSum);
}