📄 io.c
字号:
#include "includes.h"
/****************************************************************************
* Function: void QuitGpsBuilder(void)
*
* Perform an orderly shutdown of the GPS Builder.
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void QuitGpsBuilder(void)
{
int stack_counter; /* The stack number. */
PROTECT++;
nosound(); /* In case a speaker tone was being generated. */
ClearToEndOfLine(1,25);
gotoxy(1,24);
Rx2Stop(); /* Close Rinex2 files if they are open. */
/* Close the COM port if RTCM input was previously assigned to it .*/
if(BeacPort)
RestoreSerialInt();
disable();
outpw(GPIMASK,MASK_INTERRUPT); /* Mask interrupts. */
setvect(gpvec,oldisrK); /* Restore old ISRs. */
outp(0x21,oldmskA); /* Restore old interrupt masks. */
outp(0xA1,oldmskB);
RestoreCursor();
enable();
/* Return previously allocated memory blocks to the far heap. */
for(stack_counter=2;stack_counter<=0;stack_counter--)
if(ISTACKS[stack_counter] != NULL)
farfree(ISTACKS[stack_counter]);
if(obsbuff != NULL) farfree(obsbuff);
stack_counter = 0;
while(stricmp(TCB[stack_counter].TNAME,"MAIN"))
{
if(TCB[stack_counter].TSTACK!=NULL)
farfree(TCB[stack_counter].TSTACK);
stack_counter++;
}
fcloseall(); /* Close all open streams. */
ClearToEndOfLine(1,25);
OutputString(1,25,"Press Any Key To Return To DOS");
while(!kbhit());
ClearScreen();
exit(0); /* Exit to DOS. */
}
/****************************************************************************
* Function: int GetKey(void)
*
* Performs interpretation of key presses.
*
* Input: None.
*
* Output: None.
*
* Return Value: A code representing the key pressed.
****************************************************************************/
int GetKey(void)
{
int key;
if((key=getch())==0) /* An extended key was pressed. */
{
key = getch(); /* Read the next character if extended. */
key = key + 128; /* So Starlink constants can be used. */
return(key);
}
else /* Non extended key was pressed. */
return(toupper(key));
}
/****************************************************************************
* Function: void OutputString(int column, int row, char *string)
*
* Displays string at cursor position column, row. 1,1 is top left corner.
*
* Input: column - the column number (1-80).
* row - the row number (1-25).
* *string - pointer to the string to be displayed.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void OutputString(int column, int row, char *string)
{
PROTECT++;
gotoxy(column,row);
cputs(string);
PROTECT--;
}
/****************************************************************************
* Function: void OutputCharacter(int column, int row, char character)
*
* Display character at cursor position column, row. 1,1 is top left corner.
*
* Input: column - the column number (1-80).
* row - the row number (1-25).
* character - the character to be displayed.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void OutputCharacter(int column, int row, char character)
{
PROTECT++;
gotoxy(column,row);
putch(character);
PROTECT--;
}
/****************************************************************************
* Function: void ClearToEndOfLine(int column, int row)
*
* Clears line from cursor at position column, row to the end of the line.
* 1,1 is top left corner.
*
* Input: column - the column number (1-80).
* row - the row number (1-25).
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void ClearToEndOfLine(int column, int row)
{
PROTECT++;
gotoxy(column,row);
clreol();
PROTECT--;
}
/****************************************************************************
* Function: void Keyboard(void)
*
* Checks for command input from keyboard or file and process the command
* if present.
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void Keyboard(void)
{
GetCommand(); /* Process command characters (if any). */
if(cbready==1)
{
ProcessCommand();
cbindex=0;
cb[cbindex]=0;
}
}
/****************************************************************************
* Function: void QuitGpsBuilderWithError(void)
*
* Perform an orderly shutdown of the GPS Builder when an error condition
* occurs.
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void QuitGpsBuilderWithError(void)
{
int stack_counter; /* The stack number. */
PROTECT++;
nosound(); /* In case a speaker tone was being generated. */
ClearToEndOfLine(1,25);
gotoxy(1,24);
Rx2Stop(); /* Close Rinex2 files if they are open. */
/* Close the COM port if RTCM input was previously assigned to it. */
if(BeacPort)
RestoreSerialInt();
disable();
outpw(GPIMASK,MASK_INTERRUPT); /* Mask interrupts. */
setvect(gpvec,oldisrK); /* Restore old ISRs. */
outp(0x21,oldmskA); /* Restore old interrupt masks. */
outp(0xA1,oldmskB);
RestoreCursor();
enable();
/* Return previously allocated memory blocks to the far heap. */
for(stack_counter=2;stack_counter<=0;stack_counter--)
if(ISTACKS[stack_counter] != NULL)
farfree(ISTACKS[stack_counter]);
if(obsbuff != NULL) farfree(obsbuff);
stack_counter = 0;
while(stricmp(TCB[stack_counter].TNAME,"MAIN"))
{
if(TCB[stack_counter].TSTACK!=NULL)
farfree(TCB[stack_counter].TSTACK);
stack_counter++;
}
fcloseall(); /* Close all open streams. */
ClearToEndOfLine(1,25);
OutputString(1,25,"A FATAL ERROR HAS OCCURRED - Press Any Key");
while(!kbhit())
continue;
textmode(BW80);
exit(0); /* Exit to DOS. */
}
/****************************************************************************
* Function: void ScreenSave(FILE *fpScreenSave)
*
* Save the currently displayed screen to a text file.
*
* Input: *fpScreenSave - pointer to the target file.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void ScreenSave(FILE *fpScreenSave)
{
char screen[4000]; /* Screen is saved in here. Entries alternate between
character and character attribute. */
int character; /* Index to screen array */
int column; /* Number of columns */
gettext(1,1,80,25,screen); /* Coord 1,1 to 80,25 */
column = 1;
for(character=0;character<4000;character+=2)
{
fputc(screen[character],fpScreenSave);
column++;
if(column==81) /* Insert newline */
{
fputc('\n',fpScreenSave);
column = 1;
}
}
}
/****************************************************************************
* Function: void WarningMessage(char *message)
*
* Display a warning message at line 25.
*
* Input: *message - pointer to the warning message.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void WarningMessage(char *message)
{
char buff[90]; /* Warning string to be displayed. */
sprintf(buff,"WARNING: %s",message);
ClearToEndOfLine(1,25);
OutputString(1,25,buff);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -