В детстве до 2000 года мне разрешали всего 1 час работы за компьютером, в 1996 году мне подарили книгу "Секреты программирования игр", и я прочитал книгу по Юниксу и меня вдховновила эта операционная система, вот сетевая версия, она подключается через COM-порт, это серверная часть, код с работой COM-порта взял из книжки "Секреты программирования игр":
https://i.ibb.co/WgsdZs4/1-min.jpg
https://i.ibb.co/SmV7JKc/2-min.jpg

Код:

// I N C L U D E S ///////////////////////////////////////////////////////////

#include <stdio.h>
#include <stdlib.h>
#include <bios.h>
#include <process.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <dir.h>
#include <dos.h>
#include <io.h>

//#include <graph.h>

// D E F I N E S  ////////////////////////////////////////////////////////////

// registers in UART

#define SER_RBF        0    // the read buffer
#define SER_THR        0    // the write buffer
#define SER_IER        1    // the int. enable register
#define SER_IIR        2    // the int. identification register
#define SER_LCR        3    // control data config. and divisor latch
#define SER_MCR        4    // modem control reg.
#define SER_LSR        5    // line status reg.
#define SER_MSR        6    // modem status of cts, ring etc.
#define SER_DLL        0    // the low byte of baud rate divisor
#define SER_DLH        1    // the hi byte of divisor latch

// bit patterns for control registers

#define SER_BAUD_1200  96   // baud rate divisors for 1200 baud - 19200
#define SER_BAUD_2400  48
#define SER_BAUD_9600  12
#define SER_BAUD_19200  6

#define SER_GP02        8     // enable interrupt


#define COM_1           0x3F8 // base port address of port 0
#define COM_2           0x2F8 // base port address of port 1

#define SER_STOP_1      0     // 1 stop bit per character
#define SER_STOP_2      4     // 2 stop bits per character

#define SER_BITS_5      0     // send 5 bit characters
#define SER_BITS_6      1     // send 6 bit characters
#define SER_BITS_7      2     // send 7 bit characters
#define SER_BITS_8      3     // send 8 bit characters

#define SER_PARITY_NONE 0     // no parity
#define SER_PARITY_ODD  8     // odd parity
#define SER_PARITY_EVEN 24    // even parity

#define SER_DIV_LATCH_ON 128  // used to turn reg 0,1 into divisor latch

#define PIC_IMR    0x21   // pic's interrupt mask reg.
#define PIC_ICR    0x20   // pic's interupt control reg.


#define INT_SER_PORT_0    0x0C  // port 0 interrupt com 1 & 3
#define INT_SER_PORT_1    0x0B  // port 0 interrupt com 2 & 4

#define SERIAL_BUFF_SIZE 128    // current size of circulating receive buffer

//void interrupt ( *oldhandler)(__CPPARGS);

// G L O B A L S /////////////////////////////////////////////////////////////

void (_interrupt _far *Old_Isr)();  // holds old com port interrupt handler


char ser_buffer[SERIAL_BUFF_SIZE];  // the receive buffer

int ser_end = -1,ser_start=-1;      // indexes into receive buffer
int ser_ch, char_ready=0;           // current character and ready flag
int old_int_mask;                   // the old interrupt mask on the PIC
int open_port;                      // the currently open port
int serial_lock = 0;                // serial ISR semaphore so the buffer
            // isn't altered will it is being written
            // to by the ISR

//////////////////////////////////////////////////////////////////////////////

void _interrupt _far Serial_Isr(void)
{

// this is the ISR (Interrupt Service Routine) for the com port.  It is very
// simple.  When it gets called, it gets the next character out of the receive
// buffer register 0 and places it into the software buffer. Note: C takes care
// of all the register saving and house work.  Cool huh!

// lock out any other functions so the buffer doesn't get corrupted

serial_lock = 1;

// place character into next position in buffer

ser_ch = inp(open_port + SER_RBF);

// wrap buffer index around

if (++ser_end > SERIAL_BUFF_SIZE-1)
    ser_end = 0;

// move character into buffer

ser_buffer[ser_end] = ser_ch;

++char_ready;

// restore PIC

outp(PIC_ICR,0x20);

// undo lock

serial_lock = 0;

} // end Serial_Isr

//////////////////////////////////////////////////////////////////////////////

int Ready_Serial()
{

// this functions returns true if there are any characters waiting and 0 if
// the buffer is empty

return(char_ready);

} // end Ready_Serial

//////////////////////////////////////////////////////////////////////////////

int Serial_Read()
{

// this function reads a character from the circulating buffer and returns it
// to the caller

int ch;

// wait for isr to end

while(serial_lock){}

// test if there is a character(s) ready in buffer

if (ser_end != ser_start)
   {

   // wrap buffer index if needed

   if (++ser_start > SERIAL_BUFF_SIZE-1)
       ser_start = 0;

   // get the character out of buffer

   ch = ser_buffer[ser_start];

   // one less character in buffer now

   if (char_ready > 0)
       --char_ready;

   // send data back to caller

   return(ch);

   } // end if a character is in buffer
else
   // buffer was empty return a NULL i.e. 0
   return(0);

} // end Serial_read


//////////////////////////////////////////////////////////////////////////////

void Serial_Write(char ch)
{

// this function writes a character to the transmit buffer, but first it
// waits for the transmit buffer to be empty.  note: it is not interrupt
// driven and it turns of interrupts while it's working

// wait for transmit buffer to be empty

while(!(inp(open_port + SER_LSR) & 0x20)){}

// turn off interrupts for a bit

_asm cli

// send the character

outp(open_port + SER_THR, ch);

// turn interrupts back on

_asm sti
} // end Serial_Write

//////////////////////////////////////////////////////////////////////////////

void Open_Serial(int port_base, int baud, int configuration)
{

// this function will open up the serial port, set it's configuration, turn
// on all the little flags and bits to make interrupts happen and load the
// ISR

// save the port for other functions

open_port = port_base;

// first set the baud rate

// turn on divisor latch registers

outp(port_base + SER_LCR, SER_DIV_LATCH_ON);

// send low and high bytes to divsor latches

outp(port_base + SER_DLL, baud);
outp(port_base + SER_DLH, 0);

// set the configuration for the port

outp(port_base + SER_LCR, configuration);

// enable the interrupts

outp(port_base + SER_MCR, SER_GP02);

outp(port_base + SER_IER, 1);

// hold off on enabling PIC until we have the ISR installed

if (port_base == COM_1)
   {
   Old_Isr = _dos_getvect(INT_SER_PORT_0);
   _dos_setvect(INT_SER_PORT_0, Serial_Isr);
   }
else
   {
   Old_Isr = _dos_getvect(INT_SER_PORT_1);
   _dos_setvect(INT_SER_PORT_1, Serial_Isr);
   }


// enable interrupt on PIC

old_int_mask = inp(PIC_IMR);

outp(PIC_IMR, (port_base==COM_1) ? (old_int_mask & 0xEF) : (old_int_mask & 0xF7 ));


} // Open_Serial

//////////////////////////////////////////////////////////////////////////////


void Close_Serial(int port_base)
{

// this function closes the port which entails turning off interrupts and
// restoring the old interrupt vector

// disable the interrupts

outp(port_base + SER_MCR, 0);

outp(port_base + SER_IER, 0);

outp(PIC_IMR, old_int_mask );

// reset old isr handler

if (port_base == COM_1)
   {
   _dos_setvect(INT_SER_PORT_0, Old_Isr);
   }
else
   {
   _dos_setvect(INT_SER_PORT_1, Old_Isr);
   }

} // end Close_Serial


void PrintE (char *str) {
int j = 0 ;
for (j=0; j<strlen (str) ; j++)
    {
    Serial_Write (str[j]) ;
    }
}

void PrintE2 (char *str, char *a1, char *a2, char *a3, char *a4) {
char *buf ;
sprintf (buf, "%s", str, a1, a2, a3, a4) ;
PrintE (buf) ;
}

//////////////////////////////////////////////////////////////////////////////

struct users {
	int UserId ;
	char username[11] ;
	char password[11] ;
	char systempolice[1024] ;
//	char admin[3] ;
} usr ;

FILE *in ;

void OpenSystemFile () {
in = fopen ("d:\\sanix\\system.cfg", "r") ;
}

void CloseSystemFile () {
fclose (in) ;
}

// Поиск данных.
int FindUser () {
char buf[3000] ;
char *res ;
// 1024.
fgets (buf, 1044, in) ;
if (buf[strlen(buf)-1] == '\n')
    buf[strlen(buf)-1] = '\0' ;
res = strtok (buf, ",") ;
usr.UserId = 0 ;
strcpy (usr.username, "") ;
strcpy (usr.password, "") ;
strcpy (usr.systempolice, "") ;
//strcpy (usr.admin, "") ;

if (res)
   usr.UserId = atoi (res) ;
res = strtok (NULL, ",") ;
if (res)
   strcpy (usr.username, res) ;
res = strtok (NULL, ",") ;
if (res)
   strcpy (usr.password, res) ;
res = strtok (NULL, ",") ;
if (res)
   strcpy (usr.systempolice, res) ;
/*res = strtok (NULL, ",") ;
if (res)
   strcpy (usr.admin, res) ;*/
if (feof (in)) return 0 ;
return 1 ;
}

int WaitI (char str[23500]) {
char ch = 0;
int j = 0 ;
strcpy (str, "") ;
START:
ch = Serial_Read () ;
if (ch == '\n' || ch == '\r') goto START ;
ch = 0 ;
while (1)
      {
      if (kbhit ())
	 {
	 PrintE ("\nПрерывания пользователя.") ;
	 PrintE ("\nСервер закрывается...") ; // 
	 PrintE ("\nКомандный интерпретатор закрывается..") ; // 
	 PrintE ("\n\nТеперь консоль можно выключить.") ;
	 Close_Serial (COM_2) ;
	 exit (0) ;
	 }
	if (ch == '')
	   {
	   PrintE ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") ;
	   PrintE ("Произошло прерывания Саникс ПРО v1.0\n") ;
	   PrintE ("1. Отобразить список задач.\n") ;
	   PrintE ("2. Прервать задачу.\n") ;
	   PrintE ("3. Завершить сеанс.\n") ;
	   PrintE ("Выбор:\n") ;
	   switch (Serial_Read () )
      {
      case '1':
      break ;
      case '2':
                  }
	   }
      if (ch == '') // 0x22
	 {
	 return -1 ;
	 }
      if (j >= 280) j = 0 ;
      if (ch != 0)
	 {
	 j++ ;
	 //delay (100) ;
	 //printf ("%c", ch) ;
	 }
      ch = Serial_Read () ;
      if (ch == '\r') { ch = '\n' ; break ; }
      if (ch == '\n')
	  {
	  str[j+1] = '\0';
	  return 0 ;
//	  break ;
	  }
      str[j] = ch ;
      }
str[j+1] = '\0';
return 0 ;
}

FILE *in;
int error_level = 0 ;    // ERRORLEVEL (Значение завершонной программы).
    	 // Равносильно RET код (-32,768..+32,767).
int curr_in = 0 ;
char curr_path[MAXDIR] ; // Текущий путь
char labels[40][20] ;    // Метки (максимум 40).

char vars[10][80] ;      // Переменные #0..#9
char vars2[26]    ;      // Переменные #a..#z
char vals2[26][80];      // Значения (vars2[n]).
int lb_pos[40] ;         // Позиция метdк.
int isSound = 0 ;        // Звук ?
int jumps = 0  ;         // Чтобы небыло зависаний.
char varibles[47][80] ;  // Переменные среды для команды VAR.
char values[47][220] ;   // Значения переменных сред для команды VAR.
char protectd[47] ;      // Защищенны ли переменные среды от стирания (VAR CLEAR)?
int var_count = 0 ;      // Кол-во переменных.
int lbl_count = 0 ;      // Кол-во метк.
int secho = 0 ;          // Эхо: secho = 1 - Да, 0 - Нет.
int snew = 0 ;           // Переход на следующую строку : secho = 1 - Да, 0 - Нет.
int int_file = 0 ;       // Пакетный файл или непосредственный ввод int_file = 2 - API ExecInterp (), 1 - Да, 0 - Нет ?
int iscmd = 0 ;
char *commands [] = {"CON",            // 0
         "PRN",            // 1
         "F",              // 2
         "D",              // 3
         "DEL",            // 4
         "IF",             // 5
         "Q.",             // 6
         "MD",             // 7
         "CD",             // 8
         "FOR",            // 9
         "WAIT",           // 10
         "REM",            // 11
         "VR",             // 12
         "VAR",            //13
         "BEEP",           // 14
         "JMP",            //15
         "CL",             // 16
         "GXY",            // 17
         "RET",            // 18
         "ENUM",           // 19
         "RUN",            // 20
         "DR",             // 21
         "ED",             // 22
         "MSG",            // 23
         "CAL",            // 24
         "none"};          // 25

char str2[4250] ; //
char splits[10][250]; // Расщипленное значение
char strng[80];
char buffer[80];
/* Из-за соображения безопасности я не использую INTERRUPT. */

int IsDeviceReady (int dev) {
struct diskinfo_t dinfo;
int result;
static char dbuf[512];

dinfo.drive =  dev;
dinfo.head  =  0;
dinfo.track =  0;
dinfo.sector  =  1;
dinfo.nsectors =  1;
dinfo.buffer = dbuf;
RETRY:
result = _bios_disk(_DISK_READ, &dinfo);
if ((result & 0xff00) != 0)
   {
   sprintf (str2, "Устройство %c: не готово\n", dev+'A') ;
   PrintE (str2) ;
   sprintf (str2, "1=Отменить 2=Повтор 3=Пропустить 4=Выход\n") ;
   PrintE (str2) ;
RETR:
   switch (getch ())
	  {
	  case '1':
    return -1 ;
	  break ;
	  case '2':
    goto RETRY ;
	  break ;
	  case '3':
    return -2 ;
	  break ;
	  case '4':
    // return 0 ;
    exit (0) ;
	  break ;
	  default:
    goto RETR ;
	  break ;
	  }
   }
return 0 ;
}

void ToUpper (int idx) {
int i = 0 ;
for (i=0; i<strlen(splits[idx]); i++)
{
   splits[idx][i] = toupper(splits[idx][i]);
}
}

char *GetFiles (int num, char *buf) {
int j = 0, i = 0, n = 0, m = 0 ;
char temp[80] ;
strcpy (temp, "") ;
for (j=0; j<strlen (buf); j++)
    {
    if (buf[j] == '{')
       {
       i = j ;
       for (j=i; j<strlen (buf); j++)
	   {
	   temp[m] = buf[j] ;
	   m++ ;
	   if (buf[j] == ',')
	      { // if (num = n)
	      if (num == n) return *temp ;
	      m = 0 ; n++ ;
	      }
	   }
       }
    }
}


char *GetFromBuf (int num, char *buf) {
int j = 0, i = 0, n = 0, m = 0 ;
char temp[80] ;
strcpy (temp, "") ;
for (j=0; j<strlen (buf); j++)
    {
    for (i=j; i<strlen (buf); i++)
	{
	if (buf[i] == ' ')
	   {
	   temp[m] = '\0' ;
	   if (num = n) return *temp ;
	   m = 0 ; n++ ;
	   }
	temp[m] = buf[i] ;
	m++ ;
       }
    }
}

void ToLower (int idx) {
int i = 0 ;
for (i=0; i<strlen(splits[idx]); i++)
{
   splits[idx][i] = toupper(splits[idx][i]);
}

}

int SplitStr(char *buf, char spl, int idx) {
int j=0, i=0, k=-1;
for(j=0; j<idx; j++)
   splits[j][0] = '\0';
for(j=0; j<strlen(buf); j++)
   {
   k++;
   splits[i][k] = buf[j];
   if(buf[j] == spl)
     {
     splits[i][k] = '\0';
     i++;
     k=-1;
     }
   }
splits[i][k+1] = '\0';
return i;
}
char *GetSplitted(int idx) {
return splits[idx];
}
char *GetSplittedExt2 (int idx) {
if (splits[idx][strlen(splits[idx])-1] == '\n') splits[idx][strlen(splits[idx])-1] = '\0';
return splits[idx];
}

char *GetSplittedExt(int idx) {
ToUpper (idx) ;
return splits[idx];
}

void prscr (char *str) {
PrintE (str) ;
}

void cls () {
PrintE ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") ;
}

void inpkbd (char *str) {
if (int_file == 0)
   {
   RD:
   if (WaitI (str) == -1)
      {
      PrintE ("Отмена\n") ;
      goto RD ;
      }
   }
   else
   {
   if (feof(in)) { int_file = 0; return ; }
   fgets (str, 280, in) ;
   str[strlen(str)-1] = '\0';
   }
}

void kbdwai (void) { while (1) { if (Serial_Read () != 0) break ; } }

void echo (char *buf) {
int j=0, i=0;
for (j=0; j<strlen (buf); j++)
    {
    if (buf[j] == ' ') break ;
    }
for (i=j+1; i<strlen (buf); i++)
    {
    if (buf[i] == '\7') { PrintE ("") ; }
    else Serial_Write (buf[i]) ;
    }
}

int GetLabel (char *buf) {
int j = 0 ;
for (j=0; j<40; j++)
    {
    if (strcmp (buf, labels[j]) == 0)
       return j ;
    }
return -1 ;

}

void ResetLabel (void) {
int j=0;
lbl_count = 0 ;
for (j=0; j<40; j++) { sprintf (labels[j], "") ; lb_pos[j] = 0 ; }
}

void SetLabel (char *buf, int pos) {
int j=0;
if (lbl_count >= 39) { PrintE ("Слишком много (меток) лейблов\n") ; lbl_count = 0 ; return ; }
for (j=0; j<strlen (buf); j++)
    {
    if (buf[j] != ':')
       {
       labels[lbl_count][j] = buf[j] ;
       }
    else
    goto END;
    }
END:
lb_pos[lbl_count] = pos ;
lbl_count ++ ;
}

int IsLabel (char *buf) {
int j=0;
for (j=0; j<strlen (buf); j++)
    if (buf[j] == ' ') return -1 ;
for (j=strlen (buf); j>0; j--)
    {
    if (buf[j] == '\n' && buf[j-1] == ':' && j > 1 || buf[j] == '\0' && buf[j-1] == ':' && j > 1)
       return 0;
    }
return -1 ;
}

void ClearVar () {
int j=0;
var_count = 0 ;
for (j=0; j<40; j++)
    {
    varibles[j][0] = '\0';
    values[j][0] = '\0';
    }
}

int SetVar (char *var_name, char *value) {
if (var_count >= 39) return -1 ;
if (FindInVaribleExt (var_name) == -1)
   {
   if (protectd[var_count] == 0)
      {
      strcpy (varibles[var_count], var_name) ;
      strcpy (values[var_count], value) ;
      var_count++ ;
      }
   }
   else
   {
   strcpy (values[FindInVarible(var_name)], value) ;
   }
return 0 ; /// NEW
}

int SetVarExt (char *var_name, char *value) {
if (var_count >= 39) return -1 ;
if (FindInVaribleExt (var_name) == -1)
   {
   strcpy (varibles[var_count], var_name) ;
   strcpy (values[var_count], value) ;
   protectd[var_count] = 1 ;
   var_count++ ;
   }
}

int FindInVarible (char *var_name) {
int j = 0 ;
for (j=0; j<47; j++)
    {
    if (strcmp (var_name, varibles[j]) == 0)
       return j ;
    }
return -1 ;
}

int FindInVaribleExt (char *var_name) {
int j = 0 ;
for (j=0; j<40; j++)
    {
    if (strcmp (var_name, varibles[j]) == 0)
       return j ;
    }
return -1 ;
}

void SetGoto (long strng) {
int j=0;
char buf[80] ;
rewind (in) ;
for (j=0; j<strng; j++)
    fgets (buf, 80, in) ;
}

void LoadLabels() {
int strng = 0 ;
int j = 0     ;
char buf[80] ;
rewind (in) ;
strng = 0 ;
while (1)
      {
      NEXT:
      if (feof (in)) break ;
      fgets (buf, 80, in) ;
      if (IsLabel (buf) != -1)
	  {
	  SetLabel (buf, strng) ;
	  }
      strng++;
      }
rewind (in) ;
}

void UpdateThisVaribles () {
// 42 - Current Time
struct  time t ;
struct date d ;
gettime (&t) ;
getdate (&d) ;
sprintf (values[42], "Текущее время: %02d:%02d:%02d.%02d\0", t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund) ;
// 43 - Current Date
sprintf (values[43], "Текущая дата: %02d.%02d.%d", d.da_day, d.da_mon, d.da_year) ;
// 44 - Current Path
// 45 - Current Text (Keyboard);
// 46 - Version 1.0
// 47 - KBD
}

int GetFileType (char *fname) {
int sz=0;
sz = strlen (fname) ;
if (fname[sz-1] == 'm' && fname[sz-2] == 'o' && fname[sz-3] == 'c') return 1 ;
if (fname[sz-1] == 'n' && fname[sz-2] == 'u' && fname[sz-3] == 'r') return 2 ;
if (fname[sz-1] == 't' && fname[sz-2] == 'n' && fname[sz-3] == 'i') return 3 ;
if (fname[sz-1] == 'e' && fname[sz-2] == 'x' && fname[sz-3] == 'e') return 4 ;
if (fname[sz-1] == 'M' && fname[sz-2] == 'O' && fname[sz-3] == 'C') return 1 ;
if (fname[sz-1] == 'N' && fname[sz-2] == 'U' && fname[sz-3] == 'R') return 2 ;
if (fname[sz-1] == 'T' && fname[sz-2] == 'N' && fname[sz-3] == 'I') return 3 ;
if (fname[sz-1] == 'E' && fname[sz-2] == 'X' && fname[sz-3] == 'E') return 4 ;
return -1 ;
}

main (int argc, char **argv) {
{
FILE *fio ;
struct ftime ft;
int done = 0 ;
long files = 0 ;
long fsize = 0 ;
char ch ;
char login[10] ;
char passw[10] ;
int  j = 0 ;
int  i = 0   ;
int  lines = 0 ;
int  n = 0   ;
//long pos = 0 ;
char spls[280] ;
char con[280] ;
char buf[280] ;
char tbuf[28] ;
struct ffblk ffblk ;
clrscr () ;
printf ("Copyright(C) 2003-2004 ************* - САНИКС v1.0\n") ;
printf ("Кол-во подключаемых консолей:1\n") ;
printf ("\n") ;
//RESTART:
Open_Serial(COM_2,SER_BAUD_9600,SER_PARITY_NONE | SER_BITS_8 | SER_STOP_1);
for (j=0; j<10; j++) Serial_Read () ;
RESTART:
j= -1 ;
OpenSystemFile () ;
PrintE ("\nИмя?") ;
if (WaitI (login) == -1) goto RESTART ;

//login[j+1] = '\0' ;
ch = 0 ;
while (1)
      {
      if (FindUser () == 0)
	 goto RESTART ;
      if (strcmp (login, usr.username) == 0)
	 {
	 PrintE ("\nПароль?") ;
	 if (WaitI (passw) == -1) goto RESTART ;
	 if (strcmp (passw, usr.password) == 0)
	    goto LOADING ;
	 else
	    goto ERR0 ;
	 }
      }
  {
  ERR0:
  PrintE ("\nНеверное имя или пароль!") ; // 
  CloseSystemFile () ;
  goto RESTART ;
  }
LOADING:
CloseSystemFile () ;
chdir (usr.systempolice) ;
cls () ;
PrintE ("Copyright(C) 2003-2004 ************* - САНИКС версия 1.00\n") ;
PrintE ("Запускается...\n") ;
delay (1000) ;
int_file = 1;
in = fopen ("d:\\sanix\\startup.all", "r") ;
if (in == NULL)
   {
   PrintE ("Файл: startup.all отсутсвует.\n") ;
   PrintE ("Невозможно продолжить загрузку.\n") ;
   PrintE ("Сейчас будит создан типичный startup.all.\n") ;
   in = fopen ("d:\\sanix\\startup.all", "w") ;
   fprintf (in, "%s", "REM NULL\nQ.\n") ;
   fclose (in) ;
   delay (1000) ;
   delay (1000) ;
   int_file = 0 ;
   goto RESTART ;
   }
cls () ;
LoadLabels () ;
FIRST:
strcpy (varibles[41], "$WELCOME") ;
varibles[41][strlen (varibles[41])] = '\0';
strcpy (values[41], "Командный интерпретатор для САНИКС Версия 1.0\nCopyright(C) 2003-2004 *************.\n") ;
strcpy (varibles[42], "$TIME") ;
strcpy (varibles[43], "$DATE") ;
strcpy (varibles[46], "$VER") ;
strcpy (values[46], "Интерпретатор для САНИКС: v1.00\n") ;
START:
if (argc > 1 && int_file == 0) { exit (0) ; }
if (feof (in)) { fclose (in) ; int_file = 0 ; }
if (int_file == 0)
    {
    if (strcmp(usr.systempolice, "ADMIN") == 0)
       prscr (":") ;
    else
       prscr ("?") ;
    }
else PrintE ("") ;
SECOND:
if (isSound == 1)
   {
   delay (200) ;
   PrintE ("") ;
   delay (200) ;
   nosound () ;
   isSound = 0 ;
   }
if (iscmd == 1)
   {
   strcpy (buf, "") ;
   if (argc == 3)
      {
      strcpy (buf, argv[2]) ;
      iscmd = 0 ;
      argc = 0 ;
      }
   else
   {
   for (i=2; i<argc+1; i++)
       {
       strcat (buf, argv[i]) ;
       strcat (buf, " ") ;
       }
   }
   }
else
   inpkbd (buf) ;
if (secho == 1)
   {
   sprintf (str2, "%s\n", buf) ;
   PrintE (str2) ;
   }
if (strcmp (buf, "") == 0) goto START ;
EXECUTE:
SplitStr (buf, ' ', 7) ;
for (j=0; j<24; j++)
    {
    if (strcmp (GetSplittedExt (0), commands[j]) == 0)
       {
       if (j != 15) jumps = 0 ;
       break;
       }
    }
switch (j)
       {
       case 0:
       UpdateThisVaribles () ;
       if (strcmp (GetSplitted (1), "/?") == 0)
	  {
	  PrintE ("CON параметры\n") ;
	  PrintE ("Выполняет операции с консолью.\n") ;
	  PrintE ("CON CLS               - Очистка экрана\n") ;
	  PrintE ("CON COLOR:фон,текст   - Устанавливает цвет (Саникс v1.0 Про).\n") ;
	  PrintE ("CON FILE <имяфайла>   - Загружает файл\n") ;
	  PrintE ("CON $CD               - Отображает текущий путь\n") ;
	  PrintE ("CON CODE              - Отображает код (0-255).\n") ;
	  PrintE ("CON переменная        - Выводит переменную\n") ;
	  PrintE ("EON/EOFF              - Эхо команд Вкл/Выкл. \n");
	  PrintE ("NON/NOFF              - Перенос Вкл/Выкл. \n");
	  goto START;
	  }
       if (strcmp (GetSplitted (1), "CODE") == 0)
	  {
	  sprintf (str2, "%c", atoi(GetSplitted(2))) ;
	  PrintE (str2) ;
	  if (snew == 1) PrintE ("\n") ;
	  goto START;
	  }
       if (strcmp (GetSplitted (1), "FILE") == 0)
	  {
	  fio = fopen (GetSplitted(2), "r") ;
	  if (fio == NULL)
	     {
	     PrintE ("Файл не существует.\n") ;
	     goto START ;
	     }
	  while (1)
    {
    if (Serial_Read () == '') { fclose (fio) ; goto START ; }
//    if (feof (fio)) break ;
    fgets (str2, 80, in) ;
    if (feof (fio)) break ;
    PrintE (str2) ;
    lines++ ;
    if (lines >= 24) { WaitI (buf) ; lines=0 ; }
    }
	  fclose (fio) ;
	  goto START ;
	  }
       if (strcmp (GetSplitted (1), "EON") == 0) { secho = 1 ; goto START; }
       if (strcmp (GetSplitted (1), "EOFF") == 0) { secho = 0 ; goto START; }
       if (strcmp (GetSplitted (1), "NON") == 0) { snew = 1 ; goto START; }
       if (strcmp (GetSplitted (1), "NOFF") == 0) { snew = 0 ; goto START; }
       if (strcmp (GetSplittedExt (1), "$CD") == 0)
	  {
	  getcurdir(0, curr_path) ;
	  sprintf (str2, "%s", curr_path) ;
	  PrintE (str2) ;
	  if (snew == 1) PrintE ("\n") ;
	  goto START;
	  }
       if (strcmp (GetSplittedExt (1), "CLS") == 0)
	  {
	  //
	  PrintE ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") ;
	  goto START ;
	  }
      if (strlen(GetSplitted (1)) != 0)
	  {
	  if (FindInVarible (GetSplitted (1)) != -1)
	     {
	     sprintf (str2, "%s", values[FindInVarible (GetSplitted (1))]) ;
	     PrintE (str2) ;
	     if (snew == 1)
    PrintE ("\n") ;
	     goto START;
	     }
	  if (int_file == 1)
	     {
	     for (i=0; i<10; i++)
     {
     sprintf (spls, "#%d", i) ;
     if (strcmp (GetSplitted (1), spls) == 0)
        {
        sprintf (str2, "%s", vars[i]) ;
        PrintE (str2) ;
        if (snew == 1)
        PrintE ("\n") ;
        goto START ;
        }
     }
	      }
	 if (strcmp (GetSplitted (1), "#ERRORLEVEL") == 0) { sprintf (str2, "%d\n", error_level) ; PrintE (str2) ; goto START ;}
	  echo (buf) ;
	  if (snew == 1)
	     PrintE ("\n") ;
	  goto START;
	  }
	  if (strlen (GetSplitted (1)) == 0)
	     {
	     PrintE ("Состояние ЭХО:") ;
	     if (secho == 1)
    PrintE ("Включено") ;
	     else
    PrintE ("Выключено") ;
	     PrintE (", перенос:") ;
	     if (snew == 1)
    PrintE ("Есть") ;
	     else
    PrintE ("Нет") ;
	     PrintE (".\n") ;
	     goto START ;
	     }
       break ;
       case 1:

       break ;
       case 2:
	  if (strcmp (GetSplitted (1), "/?") == 0)
	     {
	     PrintE ("F [[диск:\][\директория\]]\имяфайла операция [[диск:\][\директория\]]\имяфайла [парам-ры]\n") ;
	     PrintE ("Производит операцию с файлами.\n") ;
	     PrintE ("Операции:\n") ;
	     PrintE (">  - Копировать файл.\n") ;
	     PrintE (">> - Перенести файл.\n") ;
	     PrintE ("Параметры:\n") ;
	     PrintE ("/REN Переименовать\n") ;
	     goto START ;
	     }
	  if (strlen (GetSplitted (1)) != 0 && strlen (GetSplitted (3)) != 0)
	     {
	     if (strcmp (GetSplitted (2), ">") == 0)
    {
    sprintf (str2, "Идет копирование файла: %s в %s.\n", GetSplitted (1), GetSplitted (3)) ;
    PrintE (str2) ;
    }
	     if (strcmp (GetSplitted (2), ">>") == 0)
    {
    sprintf (str2, "Идет перенос файла: %s в %s.\n", GetSplitted (1), GetSplitted (3)) ;
    PrintE (str2) ;
    }
	     goto START ;
	     }
       break ;
       case 3:
	  if (strcmp (GetSplitted (1), "/?") == 0)
	     {
	     PrintE ("D [диск:\]\директория операция [диск:\]\директория [парам-ры]\n") ;
	     PrintE ("Производит операцию с директориями.\n") ;
	     PrintE ("Операции:\n") ;
	     PrintE (">  - Копировать директорию.\n") ;
	     PrintE (">> - Перенести директорию.\n") ;
	     PrintE ("Параметры:\n") ;
	     PrintE ("\n") ;
	     goto START ;
	     }
	  if (strlen (GetSplitted (1)) != 0 && strlen (GetSplitted (3)) != 0)
	     {
	     if (strcmp (GetSplitted (2), ">") == 0)
    {
    sprintf (str2, "Идет копирование директории: %s в %s.\n", GetSplitted (1), GetSplitted (3)) ;
    PrintE (str2) ;
    }
	     if (strcmp (GetSplitted (2), ">>") == 0)
    {
    sprintf (str2, "Идет перенос директории: %s в %s.\n", GetSplitted (1), GetSplitted (3)) ;
    PrintE (str2) ;
    }
	     goto START ;
	     }
       break ;
       case 5:
	  if (strlen (GetSplitted (1)) == 0)
	     {
	     PrintE ("Опущены параметры\n") ;
	     goto START ;
	     }
	  if (strcmp (GetSplitted (1), "/?") == 0)
	     {
	     PrintE ("IF #переменная = Значение THEN метка\n") ;
	     PrintE ("IF $переменная = Значение THEN метка\n") ;
	     PrintE ("IF #FEXIST имя_файла.ext THEN метка\n") ;
	     PrintE ("IF #ERRORLEVEL число THEN метка\n") ;
	     PrintE ("Где #переменная = #0..#9\n") ;
	     goto START ;
	     }
	  if (int_file == 1)
	     {
	     if (strcmp (GetSplitted (1), "#ERRORLEVEL") == 0)
    {
    if (atoi (GetSplitted (2)) == error_level)
       {
       if (GetLabel (GetSplittedExt2 (5)) == -1)
          {
          goto ERR ;
          }
       SetGoto (lb_pos[GetLabel (GetSplitted (5))]) ;
       goto START ;
       }
    }
	     if (strcmp (GetSplitted (1), "#NOTERRORLEVEL") == 0)
    {
    if (atoi (GetSplitted (2)) != error_level)
       {
       if (GetLabel (GetSplittedExt2 (5)) == -1)
          {
          goto ERR ;
          }
       SetGoto (lb_pos[GetLabel (GetSplitted (5))]) ;
       goto START ;
       }
    }
	     if (strcmp (GetSplitted (1), "#FEXIST") == 0)
    {
    if (strlen (GetSplitted (2)) > 0)
       {
       if (fopen (GetSplitted (3), "r") != NULL)
          {
          if (GetLabel (GetSplittedExt2 (5)) == -1)
    	 {
    	 goto ERR ;
    	 }
    	 SetGoto (lb_pos[GetLabel (GetSplitted (5))]) ;
    	 goto START ;
         }
       }
    goto START ;
    }
	     if (strcmp (GetSplitted (1), "#NOTFEXIST") == 0)
    {
    if (strlen (GetSplitted (2)) > 0)
       {
       if (fopen (GetSplitted (3), "r") == NULL)
          {
    	 if (GetLabel (GetSplittedExt2 (5)) == -1)
    	    {
    	    goto ERR ;
    	    }
    	 SetGoto (lb_pos[GetLabel (GetSplitted (5))]) ;
    	 goto START ;
         }
       }
    goto START ;
    }
/////////////////////////////////////
	     if (splits[1][0] == '$')
    {
    if (strcmp (GetSplitted (2), "=") == 0)
       {
       if (strcmp (values[FindInVarible (GetSplitted (1))], GetSplitted (3)) == 0)
          {
          if (GetLabel (GetSplittedExt2 (5)) == -1)
    	 {
    	 goto ERR ;
    	 }
          SetGoto (lb_pos[GetLabel (GetSplitted (5))]) ;
          goto START ;
          }
       }
     if (strcmp (GetSplitted (2), "NOT") == 0)
        {
        if (strcmp (values[FindInVarible (GetSplitted (1))], GetSplitted (3)) != 0)
           {
    	if (GetLabel (GetSplittedExt2 (5)) == -1)
    	   {
    	   goto ERR ;
/*    	   printf ("Метка %s не найдена.\n", GetSplitted (5)) ;
    	   goto START ;*/
    	   }
           SetGoto (lb_pos[GetLabel (GetSplitted (5))]) ;
           goto START ;
           }
     }
    goto START ;
    }
	     for (i=0; i<10; i++)
     {
     sprintf (spls, "#%d", i) ;
//     }
     if (strcmp (GetSplitted (1), spls) == 0 && strcmp (GetSplitted (2), "=") == 0)
        {
        if (strcmp (vars[i], GetSplitted (3)) == 0)
           {
    	if (GetLabel (GetSplittedExt2 (5)) == -1)
    	   {
    	   goto ERR ;
    	   }
           SetGoto (lb_pos[GetLabel (GetSplitted (5))]) ;
           goto START ;
           }
        }
     if (strcmp (GetSplitted (1), spls) == 0 && strcmp (GetSplitted (2), "NOT") == 0)
        {
        if (strcmp (vars[i], GetSplitted (3)) != 0)
           {
    	if (GetLabel (GetSplittedExt2 (5)) == -1)
    	   {
    	   goto ERR ;
/*    	   printf ("Метка %s не найдена.\n", GetSplitted (5)) ;
    	   goto START ;*/
    	   }
           SetGoto (lb_pos[GetLabel (GetSplitted (5))]) ;
           goto START ;
           }
        }
     }
	      }
 goto START ;
 ERR:
 sprintf (str2, "Метка '%s' не найдена.\n", GetSplitted (5)) ;
 PrintE (str2) ;
 goto START ;
 /*IF errorcode = число THEN
IF !errorcode = число THEN
IF строка1 = строка2 THEN
IF !строка1 = строка2 THEN
IF FILE имя_файла THEN
IF !FILE имя_файла THEN
DO ENUM переменная IN файлы команда*/
      break ;
       case 6:
	  if (int_file == 1) { ResetLabel () ; int_file = 0 ; fclose (in) ; goto START; }
	  if (int_file == 0) { chdir ("C:\\") ; chdir ("c:\\sanix") ; }
	  goto RESTART ;
       break ;
       case 7:
	  if (strlen (GetSplitted (1)) == 0)
	     {
	     PrintE ("Опущены параметры\n") ;
	     goto START ;
	     }
	  if (strcmp (GetSplitted (1), "/?") == 0)
	     {
	     PrintE ("MD <путь>\\имя_каталога.рас\n") ;
	     goto START ;
	     }
	  if (!mkdir (GetSplitted (1)))
	     {
	     sprintf (str2, "Каталог %s создан.\n", GetSplitted (1)) ;
	     PrintE (str2) ;
	     goto START ;
	     }
	     else
	     {
	     sprintf (str2, "Каталог %s не создан.", GetSplitted (1)) ;
	     PrintE (str2) ;
	     goto START ;
	     }
       break ;
       case 8:
	  if (strlen (GetSplitted (1)) == 0)
	     {
	     getcurdir(0, curr_path) ;
	     sprintf (str2, "%s", curr_path) ;
	     PrintE (str2) ;
	     if (snew == 1) PrintE ("\n") ;
	     goto START;
	     }
	  if (strcmp (GetSplitted (1), "\?") == 0)
	     {
	     PrintE ("CD <путь>\n") ;
	     PrintE ("Переходит на указанный путь.\n") ;
	     goto START ;
	     }
	  chdir (GetSplitted (1)) ;
	  goto START ;
       break ;
       case 10:
	  PrintE ("Нажми любую клавишу . . .\n") ;
	  PrintE ("\n") ;
	  WaitI (buf) ;
	  goto START ;
       break ;
       case 11:
	  goto START ;
       break ;
       case 12:
	  //printf ("\nCON VER\n%s\n", values[FindInVarible ("VER")]) ;
	  sprintf (str2, "%s\n", values[FindInVarible ("$VER")]) ;
	  PrintE (str2) ;
      break ;

       case 13:
	 if (strlen(GetSplitted (1)) == 0) { PrintE ("Опущены параметры\n") ; goto START; }
	  if (strcmp (GetSplitted (1), "/?") == 0)
	     {
	     PrintE ("VAR $имя значение\n") ;
	     PrintE ("VAR $имя значение CONST\n") ;
	     PrintE ("VAR CLEAR - Очистка переменных\n") ;
	     PrintE ("VAR $KEY   - Ожидание ввода строки\n") ;
	     PrintE ("VAR #KEY  - Ожидание ввода строки\n") ;
	     PrintE ("VAR $KBD  - Ожидание ввода клавиши\n") ;
	     PrintE ("VAR FREE  - Информация свободных переменных\n") ;
	     PrintE ("VAR $TIME  - Установка времени\n") ;
	     PrintE ("VAR $DATE  - Установка даты\n") ;
	     goto START;
	     }
	  if (strcmp (GetSplitted (1), "$KBD") == 0)
	     {
	     strcpy (varibles[47], "$KBD") ;
	     values[47][0] = getch () ;
	     values[47][1] = '\0';
	     goto START ;
	     }
	  if (strcmp (GetSplitted (1), "$TIME") == 0)
	     {
	     PrintE ("Введите время:") ;
	     goto START ;
	     }
	  if (strcmp (GetSplitted (1), "$DATE") == 0)
	     {
	     PrintE ("Введите дату:") ;
	     goto START ;
	     }
	  if (strcmp (GetSplitted (1), "FREE") == 0)
	     {
	     sprintf (str2, "Свободных переменных:%d\n", 40-var_count) ;
	     PrintE (str2) ;
	     goto START ;
	     }
	  if (strcmp (GetSplitted (1), "$KEY") == 0)
	     {
	     strcpy (varibles[45], "$KEY") ;
	     WaitI (values[45]) ;
	     goto START ;
	     }
	  if (strcmp (GetSplitted (1), "CLEAR") == 0) { ClearVar () ; goto START; }
	     if (strlen (GetSplitted (1)) != 0 && strlen (GetSplitted (2)) != 0)
    {
    if (splits[1][0] != '$') goto START ;
    if (strcmp (GetSplitted(3), "CONST") == 0)
       SetVarExt (GetSplitted (1), GetSplitted (2)) ;
    else
       SetVar (GetSplitted (1), GetSplitted (2)) ;
    goto START;
    }
       break ;
       case 14:
	     if (strlen (GetSplitted (1)) == 0) { isSound = 1 ; goto START ; }
	     if (strcmp (GetSplitted (1), "/?") == 0)
    {
    PrintE ("BEEP\n") ;
    PrintE ("BEEP Частота Задержка\n") ;
    PrintE ("Выводит звуковой сигнал на встроенный динамик\n") ;
    goto START ;
    }
	     if (splits[1][0] >= '0' && splits[1][0] <= '9' && splits[2][0] >= '0' && splits[2][0] <= '9')
    {
    //sound (atoi (GetSplitted (1))) ;
    PrintE ("") ;
    delay (atoi (GetSplitted (2))) ;
    nosound () ;
    goto START ;
    }
       break;
       case 15:
	  if (strcmp (GetSplitted (1), "/?") == 0)
	     {
	     PrintE ("JMP метка\n") ;
	     PrintE ("Переходит на указанную метку.\n") ;
	     PrintE ("Только для выполнения из пакетного файла.\n") ;
	     goto START ;
	     }
	     if (int_file == 1)
    {
    if (Serial_Read () == '') { int_file = 0 ; PrintE ("Аварийное прерывание\n") ; goto START ; }
 /*    jumps ++ ;
    if (jumps > 20)
       {
       PrintE ("Цикл бесконечный прервать выполнения? (1=Да 2=Нет):\n") ;
       switch (getch ())
    	  {
    	  case '1':
        int_file = 0 ;
//        printf ("\n") ;
        goto START ;
    	  break ;
    	  default:
        jumps = 0 ;
    	  break ;
    	  }
       }*/
    if (GetLabel (GetSplitted (1)) == -1)
       {
       sprintf (str2 , "Метка %s не найдена.\n", GetSplitted (1)) ;
       PrintE (str2) ;
       goto START ;
       }
	       SetGoto (lb_pos[GetLabel (GetSplitted (1))]) ;
	       goto START ;
	       }
	     PrintE ("Требуется пакетный файл.\n") ;
	     goto START ;
       break ;
       case 16:
	  cls () ;
       break ;
       case 17:
	  if (strlen (GetSplitted(1)) == 0)
	     {
	     PrintE ("Опущены параметры\n") ;
	     goto START ;
	     }
	  if (strcmp (GetSplitted(1), "\?") == 0)
	     {
	     PrintE ("GXY x y\n") ;
	     PrintE ("Переводит курсор на позицию x, y.") ;
	     }
//	  if (int_file == 1) gotoxy (atoi (GetSplitted(1)), atoi (GetSplitted(2))) ;
	  goto START ;
       break ;
       case 18:
	  if (strlen (GetSplitted (1)) == 0)
	     {
	     PrintE ("Опущены параметры\n") ;
	     goto START ;
	     }
	  if (int_file == 1) error_level = atoi (GetSplitted(1)) ;
	  goto START ;
       break ;
       case 19:
	  // ENUM #переменная {файлы} DO команда.
	  if (strlen (GetSplitted (1)) == 0 && splits[1][0] != '#')
	     {
	     PrintE ("Опущены параметры\n") ;
	     goto START ;
	     }
	  if (strcmp (GetSplitted (1), "/?") == 0)
	     {
	     PrintE ("ENUM #переменная {файлы} DO команда [параметры].\n") ;
	     PrintE ("Начинает выполнять команды в зависимости от количества файлов, и \n") ;
	     PrintE ("подставляет имя файла в #переменная.\n") ;
	     PrintE ("Пример:ENUM #a {*.exe} DO con #a\n") ;
	     goto START ;
	     }
	  if (splits[1][0] == '#' && splits[1][1] > 0)
	     {
	     for (i=0; i<255; i++) vars2[i] = 0 ;
	     vars2[splits[1][1]] = 1 ;
	     strcpy (buf, GetSplitted(5)) ;
	     GetFiles (1, GetSplitted(3)) ;
//	     done = findfirst("*.*",&ffblk,0);
//	     vals[] ;
	     }
       break ;
       case 20:
	  n = 0 ;
	  strcpy (tbuf, "") ;
	  for (i=4; i<strlen (buf) ; i++)
	      {
	      NEXT:
	      if (buf[i] == ' ')
     {
     strcat (tbuf, " ") ;
     n = i  ;
     for (j=strlen (tbuf) + 1 ; j< strlen (buf) ; j++)
         {
         if (buf[j] == ' ') { i++ ; goto NEXT ; }
         tbuf[j] = buf[n] ;
         n++ ;
         }
//     n ++ ;
     }
	      if (buf[i] == '#')
     {
     for (j=0; j<10; j++)
         {
         if(buf[i+1] == j+'0')
           {
           strcat (tbuf, vars[j]) ;
           }
         }
//     for (j=i ; j<strlen (buf) ; j++)
     }
	      }
 /*	      strcpy (buf, tbuf) ;
	      printf ("%s %s", buf, tbuf) ;*/
	      goto EXECUTE ;
       break ;
       case 21:
	  fsize = 0 ;
	  files = 0 ;
	  lines = 0 ;

	  if (strlen (GetSplitted (1)) == 0)
	     {
	     getcurdir(0, curr_path) ;
	     sprintf (str2, "Текущий каталог: %s\n", curr_path) ;
	     PrintE (str2) ;
	     sprintf (str2, "Владелиц       : %s\n", usr.username) ;
	     PrintE (str2) ;
	     if (strlen (GetSplitted (1)) == 0) done = findfirst("*.*",&ffblk, FA_DIREC);
	     if (strlen (GetSplitted (1)) != 0) done = findfirst(GetSplitted (1),&ffblk,0);
	     while (!done)
       {
//       if (ffblk.attrib = 0)
       if (++lines == 23) { PrintE ("Нажмите любую клавишу...") ; WaitI (buf) ; lines = 0 ; }
       if (strcmp (ffblk.ff_name, ".") != 0 || strcmp (ffblk.ff_name, "..") != 0)
          {
          files ++ ;
          sprintf(str2,"  %12s %11ld", ffblk.ff_name, ffblk.ff_fsize);
          if (ffblk.ff_attrib == FA_DIREC)
    	 {
    	 files -- ;
    	 sprintf(str2,"  %12s %11s", ffblk.ff_name, "<ДИР>");
    	 }
          fsize = fsize + ffblk.ff_fsize ;
          PrintE (str2) ;
          fio = fopen (ffblk.ff_name, "r") ;
          getftime (fileno (fio), &ft) ;
          fclose (fio) ;
          sprintf (str2, " %02d.%02d.%02d %02d:%02d:%02d\n", ft.ft_day, ft.ft_month, ft.ft_year, ft.ft_hour, ft.ft_min, ft.ft_tsec * 2) ;
          PrintE (str2) ;
//          delay (100) ;
          }
       done = findnext(&ffblk);
       }
	     sprintf (str2, "Файлов : %ld, Размер: %ld\n\n", files, fsize) ;
	     PrintE (str2) ;
	     goto START ;
	     }
       break ;
       case 22:
	    if (int_file == 1) { PrintE ("В состояние выполнения пакетного файла невозможно редактировать.\n") ; goto START ; }
	    if (strlen (GetSplitted (1)) == 0)
	       {
	       PrintE ("ED <имя_файл.рас>\n") ;
	       goto START ;
	       }
	    fio = fopen (GetSplitted (1), "w") ;
	    PrintE ("Для выхода введите команду q. и нажмите <ENTER>.") ;
	    while (1)
      {
      PrintE ("\n~") ;  // PrintE ("\n~") ;
      WaitI (buf) ;
      if (strcmp (buf, "q.") == 0) { fclose (fio) ; break ; }
      fprintf (fio, "%s", buf) ;
      }
       break ;
       case 23:
       if (strlen (GetSplitted (1)) == 0)
	  {
	  PrintE ("Опущены параметры\n") ;
	  goto START ;
	  }
       if (strcmp (GetSplitted (1), "/?") == 0)
	  {
	  PrintE ("MSG <Имя компьютера>\n") ;
	  PrintE ("MSG Выводит сообщение\n") ;
	  goto START ;
	  }
       if (strcmp (GetSplitted (1), "main") == 0)
	  {
	  PrintE ("Сообщение:") ;
	  WaitI (buf) ;
	  sound (500) ;
	  delay (500) ;
	  sound (600) ;
	  delay (500) ;
	  nosound ()  ;
	  printf ("%s\n", buf) ;
	  gotoxy (1, 4) ;
	  goto START ;
	  }
       break ;
       default:
	  if (int_file == 1)
	     {
	     if (IsLabel (buf) != -1) goto START;
	     if (strcmp (GetSplitted (1), "device") == 0)
    {
    // ...
    }
	     }
	  switch(GetFileType(GetSplitted (0)))
    {
    case 1: // com
    break ;
    case 2: // run

    break ;
    case 3: // int
       fclose (in) ;
//       curr_in--;
       in = fopen (GetSplitted(0), "r") ;
       int_file = 1 ;
       if (in == NULL) {int_file = 0 ; goto GERR ; }
       i = getc (in) ;
       if (feof (in)) { sprintf (str2, "Ошибка в файле '%s'. ", GetSplitted(0)) ; fclose (in) ; int_file = 0 ; PrintE (str2) ; PrintE ("\n") ; goto START ; }
       rewind (in) ;
       ResetLabel () ;
       LoadLabels () ;
       curr_in++ ;
       for (i=0; i<10; i++)
           sprintf (vars[i], "") ;
       for (i=0; i<10; i++)
           strcpy (vars[i], GetSplitted(i)) ;
       if (in != NULL) { int_file = 1 ; goto START ; } // { printf ("Не могу открыть файл:%s\n", buf) ; goto START ; }
//       else { int_file = 1 ; goto START ; }
    break ;
    case 4: // exe
        system (buf) ;
        goto START ;
    break ;
    }
	  GERR:
	  PrintE ("Команда или файл не найден.\n");
	  if (int_file == 1) { sprintf (str2, "%s\n", buf) ; PrintE (str2) ; }
       break ;
       }
goto START;
Close_Serial(COM_2);

} // end main

}