Ejemplo n.º 1
0
Bool TERMWINDOWMEMBER n_login(void)
    {
    changedir(cfg.homepath);    // for @ command
    doccr();
    cPrintf(getnetmsg(53));

    char Macro[256];

    strcpy(Macro, node->GetLoginMacro());

    if (!parseLine(Macro))
        {
        OC.ansiattr = cfg.wattr;
        cPrintf(getnetmsg(54));
        OC.ansiattr = cfg.attr;

        return (FALSE);
        }

    OC.ansiattr = cfg.wattr;
    cPrintf(getnetmsg(45));
    OC.ansiattr = cfg.attr;
    doccr();
    doccr();

    return (TRUE);
    }
Ejemplo n.º 2
0
int TERMWINDOWMEMBER dial(const char *dialstring, int timeout)
    {
    time_t ts, tx, ty;
    int checkbaud;

    pause(100);
    CommPort->FlushInput();

    CommPort->OutString(cfg.dialpref);
    CommPort->OutString(dialstring);
    CommPort->OutString(br);

    tx = time(&ts);

    for (;;)
        {
        if ((int) (time(&ty) - ts) > timeout)
            {
            OC.ansiattr = cfg.wattr;
            cPrintf(getnetmsg(41));
            OC.ansiattr = cfg.attr;

            return (FALSE);
            }

        if (tx != ty)
            {
            if (debug)
                {
                cPrintf(br);
                cPrintf(getdbmsg(5), cfg.dialpref, dialstring,
                        ltoac(ty - ts));
                }

            tx = ty;
            }

        if (KBReady())  // User abort
            {
            ciChar();
            OC.ansiattr = cfg.wattr;
            cPrintf(getnetmsg(43));
            OC.ansiattr = cfg.attr;

            return (-3);
            }

        if (CommPort->IsInputReady())
            {
            checkbaud = smartbaud(CommPort);

            if (checkbaud != FALSE) // TRUE || CERROR
                {
                return (checkbaud);
                }
            }
        }
    }
Ejemplo n.º 3
0
static Word v2p(Word vAddr, Bool userMode, Bool writing, int accsWidth) {
  Word pAddr;
  Word page, offset;
  int index;

  if (debugUse) {
    cPrintf("**** vAddr = 0x%08X", vAddr);
  }
  if ((vAddr & 0x80000000) != 0 && userMode) {
    /* trying to access a privileged address from user mode */
    mmuBadAccs = (writing ? MMU_ACCS_WRITE : MMU_ACCS_READ) | accsWidth;
    mmuBadAddr = vAddr;
    throwException(EXC_PRV_ADDRESS);
  }
  if ((vAddr & 0xC0000000) == 0xC0000000) {
    /* unmapped address space */
    /* simulate delay introduced by assoc when using mapped
       addresses but not experienced with unmapped addresses */
    assoc(0);
    pAddr = vAddr & ~0xC0000000;
  } else {
    /* mapped address space */
    page = vAddr & PAGE_MASK;
    offset = vAddr & OFFSET_MASK;
    index = assoc(page);
    if (index == -1) {
      /* TLB miss exception */
      mmuBadAccs = (writing ? MMU_ACCS_WRITE : MMU_ACCS_READ) | accsWidth;
      mmuBadAddr = vAddr;
      tlbEntryHi = page;
      throwException(EXC_TLB_MISS);
    }
    if (!tlb[index].valid) {
      /* TLB invalid exception */
      mmuBadAccs = (writing ? MMU_ACCS_WRITE : MMU_ACCS_READ) | accsWidth;
      mmuBadAddr = vAddr;
      tlbEntryHi = page;
      throwException(EXC_TLB_INVALID);
    }
    if (!tlb[index].write && writing) {
      /* TLB write exception */
      mmuBadAccs = (writing ? MMU_ACCS_WRITE : MMU_ACCS_READ) | accsWidth;
      mmuBadAddr = vAddr;
      tlbEntryHi = page;
      throwException(EXC_TLB_WRITE);
    }
    pAddr = tlb[index].frame | offset;
  }
  if (debugUse) {
    cPrintf(", pAddr = 0x%08X ****\n", pAddr);
  }
  return pAddr;
}
Ejemplo n.º 4
0
void CreateConfigurationFile(int FileNameIndex, int FileDataIndex, Bool PrintStuff)
    {
    discardable *d;

    if (!filexists(citfiles[FileNameIndex]))
        {
        if ((d = readData(16, FileDataIndex, FileDataIndex)) != NULL)
            {
            FILE *File;

            if ((File = fopen(citfiles[FileNameIndex], FO_W)) != NULL)
                {
                if (PrintStuff)
                    {
#ifndef WINCIT
                    cPrintf(getcfgmsg(133), citfiles[FileNameIndex]);
                    doccr();
#endif
                    }

                const char **Data = (const char **) d->aux;

                for (int i = 0; !SameString(Data[i], getcfgmsg(244)); i++)
                    {
                    fprintf(File, getmsg(472), Data[i], bn);
                    }

                fclose(File);
                }
            else
                {
                if (PrintStuff)
                    {
#ifndef WINCIT
                    cPrintf(getcfgmsg(134), citfiles[FileNameIndex]);
                    doccr();
#endif
                    }
                }

            discardData(d);
            }
        else
            {
            if (PrintStuff)
                {
                cOutOfMemory(51);
                }
            }
        }
    }
Ejemplo n.º 5
0
void timerWrite(Word addr, Word data) {
  if (debug) {
    cPrintf("\n**** TIMER WRITE to 0x%08X, data = 0x%08X ****\n",
            addr, data);
  }
  if (addr == TIMER_CTRL) {
    if (data & TIMER_IEN) {
      timerCtrl |= TIMER_IEN;
    } else {
      timerCtrl &= ~TIMER_IEN;
    }
    if (data & TIMER_EXP) {
      timerCtrl |= TIMER_EXP;
    } else {
      timerCtrl &= ~TIMER_EXP;
    }
    if ((timerCtrl & TIMER_IEN) != 0 &&
        (timerCtrl & TIMER_EXP) != 0) {
      /* raise timer interrupt */
      cpuSetInterrupt(IRQ_TIMER);
    } else {
      /* lower timer interrupt */
      cpuResetInterrupt(IRQ_TIMER);
    }
  } else
  if (addr == TIMER_DIVISOR) {
    timerDivisor = data;
    timerCounter = data;
  } else {
    /* illegal register */
    throwException(EXC_BUS_TIMEOUT);
  }
}
Ejemplo n.º 6
0
/* -------------------------------------------------------------------- */
void hallinfo()
{
	uchar i;

    mPrintf(" Hallway %s", hallBuf->hall[thisHall].hallname);

    if (hallBuf->hall[thisHall].owned) {
        mPrintf(", owned by group %s",
		grpBuf->group[hallBuf->hall[thisHall].grpno].groupname);
    }

	if (hallBuf->hall[thisHall].mult_grp) {
		for(i=0; i<MAXGROUPS; i++) {
			if(debug) {
				if( grpBuf->group[i].g_inuse) {
					cPrintf("grpBuf=%d hallgrp=%d   ",
						grpBuf->group[i].groupgen,
						hallgrp->hall[thisHall].grp[i].grpgen);
				}
			}
			if ( grpBuf->group[i].g_inuse &&
				(hallgrp->hall[thisHall].grp[i].grpgen ==
				grpBuf->group[i].groupgen))
			{
				mPrintf(", shared by group %s",
				grpBuf->group[i].groupname);
			}
		}
	}
	doCR();
}
Ejemplo n.º 7
0
void getHall(void)
{
    int i;
    
    fseek(hallfl, 0L, 0);

    if (fread(hallBuf, sizeof (struct hallBuffer), 1, hallfl) != 1)
    {
        crashout("getHall-EOF detected!");
    }

#ifdef NEWMSGTAB    
    if (fread(roomPos, MAXROOMS, 2, hallfl) != 2)
#else
    if (fread(roomPos, MAXROOMS, 1, hallfl) != 1)
#endif

    {
        cPrintf("\nCreating room position table.\n");
        
        for (i=0; i<MAXROOMS; i++)
            roomPos[i] = i;
            
        putHall();
    }
}
Ejemplo n.º 8
0
const char *strip_punct(const char *str)
	{
	if (strlen(str) > MAXWORDLEN)
		{
#ifndef WINCIT
		cPrintf(getmsg(655));
		doccr();
#endif
		return (str);
		}

	const char *pc;
	for (pc = str; *pc && ispunct(*pc); pc++);

	strcpy(fmtBuf, pc);

	Bool done = FALSE;
	for (int i = strlen(fmtBuf); i && !done; i--)
		{
		if (ispunct(fmtBuf[i-1]))
			{
			fmtBuf[i-1] = 0;
			}
		else
			{
			done = TRUE;
			}
		}

	return (fmtBuf);
	}
Ejemplo n.º 9
0
const char *special_deansi(const char *str, const char *strip)
	{
	int i = 0;
	const char *pc;
	int len = strlen(strip);

	if (strlen(str) > ((LABELSIZE * 4) + 1))
		{
#ifndef WINCIT
		cPrintf(getmsg(651));
		doccr();
#endif
		return (str);
		}

	pc = str;

	while (*pc)
		{
		if (*pc == CTRL_A && ((toupper(*(pc + 1)) == 'X' &&
				strnicmp(pc + 2, strip, len)) ||
				(*(pc + 1) == strip[0] && len == 1)))
			{
			if (*(pc + 1))
				{
				pc += 2;

				if (toupper(*(pc - 1)) == 'X')
					{
					while (*pc > CTRL_B && !isspace(*pc) &&
							toupper(*pc) != 'X' && *pc != '\r' && *pc != '\n')
						{
						pc++;
						}

					if (toupper(*pc) == 'X')
						{
						pc++;
						}
					}
				}
			else
				{
				pc++;
				}
			}
		else
			{
			fmtBuf[i] = *pc;
			i++;
			pc++;
			}
		}

	fmtBuf[i] = 0;

	return (fmtBuf);
	}
Ejemplo n.º 10
0
void TERMWINDOWMEMBER sendFiles(const protocols *theProt)
	{
	cPrintf(getnetmsg(100));
	doccr();

	wxsnd(LocalTempPath, roomdataOut, theProt, 0);

	unlink(roomdataOut);
	}
Ejemplo n.º 11
0
void TERMWINDOWMEMBER sendRequest(const protocols *theProt)
	{
	cPrintf(getnetmsg(86));
	doccr();

	wxsnd(LocalTempPath, roomreqOut, theProt, 0);

	unlink(roomreqOut);
	}
Ejemplo n.º 12
0
/* -------------------------------------------------------------------- */
static void sendRequest(void)
{
    cPrintf(" Sending room request file.");
    doccr();

    wxsnd(cfg.temppath, roomreqout, 
         (char)strpos((char)tolower(node.ndprotocol[0]), extrncmd));
    
    unlink(roomreqout);
}
Ejemplo n.º 13
0
/* -------------------------------------------------------------------- */
static void sendFiles(void)
{
    cPrintf(" Sending mail and rooms.");
    doccr();

    wxsnd(cfg.temppath, roomdataout, 
         (char)strpos((char)tolower(node.ndprotocol[0]), extrncmd));
    
    unlink(roomdataout);
}
Ejemplo n.º 14
0
void mmuSetTLB(int index, TLB_Entry tlbEntry) {
  index &= TLB_MASK;
  tlb[index] = tlbEntry;
  if (debugWrite) {
    cPrintf("**** TLB[%02d] <- 0x%08X 0x%08X %c %c ****\n",
            index, tlb[index].page, tlb[index].frame,
            tlb[index].write ? 'w' : '-',
            tlb[index].valid ? 'v' : '-');
  }
}
Ejemplo n.º 15
0
static void xmtrCallback(int dev) {
  if (debug) {
    cPrintf("\n**** TERM XMTR CALLBACK ****\n");
  }
  fputc(terminals[dev].xmtrData & 0xFF, terminals[dev].out);
  terminals[dev].xmtrCtrl |= TERM_XMTR_RDY;
  if (terminals[dev].xmtrCtrl & TERM_XMTR_IEN) {
    /* raise terminal xmtr interrupt */
    cpuSetInterrupt(terminals[dev].xmtrIRQ);
  }
}
Ejemplo n.º 16
0
const char *deansi(const char *str)
	{
	int i = 0;
	const char *pc;

	if (strlen(str) > ((LABELSIZE * 4) + 1))
		{
#ifndef WINCIT
		cPrintf(getmsg(651));
#endif
		return (str);
		}

	pc = str;

	while (*pc)
		{
		if (*pc == CTRL_A || *pc == CTRL_B)
			{
			if (*(pc + 1))
				{
				pc += 2;

				if (toupper(*(pc - 1)) == 'X')
					{
					while (*pc > CTRL_B && !isspace(*pc) &&
							toupper(*pc) != 'X' && *pc != '\r' && *pc != '\n')
						{
						pc++;
						}

					if (toupper(*pc) == 'X')
						{
						pc++;
						}
					}
				}
			else
				{
				pc++;
				}
			}
		else
			{
			fmtBuf[i] = *pc;
			i++;
			pc++;
			}
		}

	fmtBuf[i] = 0;

	return (fmtBuf);
	}
Ejemplo n.º 17
0
Word timerRead(Word addr) {
  Word data;

  if (debug) {
    cPrintf("\n**** TIMER READ from 0x%08X", addr);
  }
  if (addr == TIMER_CTRL) {
    data = timerCtrl;
  } else
  if (addr == TIMER_DIVISOR) {
    data = timerDivisor;
  } else {
    /* illegal register */
    throwException(EXC_BUS_TIMEOUT);
  }
  if (debug) {
    cPrintf(", data = 0x%08X ****\n", data);
  }
  return data;
}
Ejemplo n.º 18
0
void timerReset(void) {
  Timer *timer;

  cPrintf("Resetting Timer...\n");
  while (activeTimers != NULL) {
    timer = activeTimers;
    activeTimers = timer->next;
    timer->next = freeTimers;
    freeTimers = timer;
  }
}
Ejemplo n.º 19
0
/* -------------------------------------------------------------------- */
zapMsgFile()
{
    int i;
    unsigned sect;
    char buff[1024];

    /* Clear it out just in case */
    for (i = 0;  i < 1024;  i++) buff[i] = 0;

    /* put null message in first sector... */
    buff[0]  = 0xFF; /*                                   */
    buff[1]  = DUMP; /*  \  To the dump                   */
    buff[2]  = '\0'; /*  /  Attribute                     */
    buff[3]  =  '1'; /*  >                                */
    buff[4]  = '\0'; /*  \  Message ID "1" MS-DOS style   */
    buff[5]  =  'M'; /*  /         Null messsage          */
    buff[6]  = '\0'; /*                                   */
                                                  
    cfg.newest = cfg.oldest = 1l;

    cfg.catLoc = 7l;

    if (fwrite(buff, 1024, 1, msgfl) != 1)
    {
        cPrintf("zapMsgFil: write failed"); doccr();
    }

    for (i = 0;  i < 7;  i++) buff[i] = 0;

    doccr();  doccr();
    cPrintf("MESSAGEK=%d", cfg.messagek);  doccr();
    for (sect = 1;  sect < cfg.messagek;  sect++)
    {
        cPrintf("Clearing block %u\r", sect);
        if (fwrite(buff, 1024, 1, msgfl) != 1)
        {
            cPrintf("zapMsgFil: write failed");  doccr();
        }
    }
    return TRUE;
}
Ejemplo n.º 20
0
void mmuReset(void) {
  int i;

  cPrintf("Resetting MMU...\n");
  for (i = 0; i < TLB_SIZE; i++) {
    tlb[i].page = rand() & PAGE_MASK;
    tlb[i].frame = rand() & PAGE_MASK;
    tlb[i].write = rand() & 0x1000 ? true : false;
    tlb[i].valid = rand() & 0x1000 ? true : false;
    if (debugWrite) {
      cPrintf("**** TLB[%02d] <- 0x%08X 0x%08X %c %c ****\n",
              i, tlb[i].page, tlb[i].frame,
              tlb[i].write ? 'w' : '-',
              tlb[i].valid ? 'v' : '-');
    }
  }
  tlbIndex = rand() & TLB_MASK;
  tlbEntryHi = rand() & PAGE_MASK;
  tlbEntryLo = rand() & (PAGE_MASK | TLB_WRITE | TLB_VALID);
  mmuBadAddr = rand();
  mmuBadAccs = rand() & MMU_ACCS_MASK;
}
Ejemplo n.º 21
0
/* -------------------------------------------------------------------- */
int getModStr(char *str)
{
    long tm;
    int l = 0, c;

    tm = cit_timer();

    if (debug)
        cPrintf("[");

    while (
        (cit_timer() - tm) < 4
        && !KBReady()
        && l < 40
    ) {
        if (MIReady()) {
            c = getMod();

            if (c == 13 || c == 10) {   /* CR || LF */
                str[l] = EOS;
                if (debug)
                    cPrintf("]\n");
                return TRUE;
            } else {
                if (debug)
                    cPrintf("%c", c);
                str[l] = (char) c;
                l++;
            }
        }
    }

    if (debug)
        cPrintf(":F]\n");

    str[0] = EOS;

    return FALSE;
}
Ejemplo n.º 22
0
/* -------------------------------------------------------------------- */
int getModStr(char *str)
{
    long tm;
    int  l = 0, c;

    time(&tm);

    if (debug) cPrintf("[");

    while (
             (time(NULL) - tm) < 4 
          && !KBReady() 
          && l < 40 
          )
    {
        if (MIReady())
        {
            c = getMod();

            if (c == 13 || c == 10) /* CR || LF */
            {
                str[l] = NULL;
                if (debug) cPrintf("]\n");
                return TRUE;
            }else{
                if (debug) cPrintf("%c", c);
                str[l] = (char)c;
                l++;
            }
        }
    }

    if (debug) cPrintf(":F]\n");

    str[0] = NULL;

    return FALSE;
}
Ejemplo n.º 23
0
/* -------------------------------------------------------------------- */
static void reciveFiles(void)
{
    cPrintf(" Receiving mail and rooms.");
    doccr();

    wxrcv(cfg.temppath, roomdatain, 
            (char)strpos((char)tolower(node.ndprotocol[0]), extrncmd));

    if (!filexists(roomdatain))
    {
        drop_dtr();
        netFailed = TRUE;
    }
}
Ejemplo n.º 24
0
/* -------------------------------------------------------------------- */
static void reciveRequest(void)
{
    cPrintf(" Receiving room request file.");
    doccr();

    wxrcv(cfg.temppath, roomreqin, 
            (char)strpos((char)tolower(node.ndprotocol[0]), extrncmd));
            
    if (!filexists(roomreqin))
    {
        drop_dtr();
        netFailed = TRUE;
    }
}
Ejemplo n.º 25
0
void termReset(void) {
  int i;

  cPrintf("Resetting Terminals...\n");
  for (i = 0; i < numTerminals; i++) {
    terminals[i].rcvrCtrl = 0;
    terminals[i].rcvrData = 0;
    terminals[i].rcvrIRQ = IRQ_TERM_0_RCVR + 2 * i;
    timerStart(TERM_RCVR_MSEC, rcvrCallback, i);
    terminals[i].xmtrCtrl = TERM_XMTR_RDY;
    terminals[i].xmtrData = 0;
    terminals[i].xmtrIRQ = IRQ_TERM_0_XMTR + 2 * i;
  }
}
Ejemplo n.º 26
0
void mmuTbwi(void) {
  int index;

  index = tlbIndex & TLB_MASK;
  tlb[index].page = tlbEntryHi & PAGE_MASK;
  tlb[index].frame = tlbEntryLo & PAGE_MASK;
  tlb[index].write = tlbEntryLo & TLB_WRITE ? true : false;
  tlb[index].valid = tlbEntryLo & TLB_VALID ? true : false;
  if (debugWrite) {
    cPrintf("**** TLB[%02d] <- 0x%08X 0x%08X %c %c ****\n",
            index, tlb[index].page, tlb[index].frame,
            tlb[index].write ? 'w' : '-',
            tlb[index].valid ? 'v' : '-');
  }
}
Ejemplo n.º 27
0
void termInit(int numTerms) {
  int master, slave;
  char ptyName[100];
  char ptyTitle[100];
  struct termios termios;
  int i;

  numTerminals = numTerms;
  for (i = 0; i < numTerminals; i++) {
    /* open pseudo terminal */
    if (openPty(&master, &slave, ptyName) < 0) {
      error("cannot open pseudo terminal %d", i);
    }
    if (debug) {
      cPrintf("pseudo terminal '%s': master fd = %d, slave fd = %d\n",
              ptyName, master, slave);
    }
    /* set mode to raw */
    tcgetattr(slave, &termios);
    makeRaw(&termios);
    tcsetattr(slave, TCSANOW, &termios);
    /* fork and exec a new xterm */
    terminals[i].pid = fork();
    if (terminals[i].pid < 0) {
      error("cannot fork xterm process %d", i);
    }
    if (terminals[i].pid == 0) {
      char geo[20];
      /* terminal process */
      setpgid(0, 0);
      close(2);
      close(master);
      /* it's annoying to have to adjust the window-position every time eco-sim starts :) */
      sprintf(geo, "+%d+%d", 1600 + (i % 2) * 500,(i / 2) * 400);
      sprintf(ptyName, "-Sab%d", slave);
      sprintf(ptyTitle, "ECO32 Terminal %d", i);
      execlp("xterm", "xterm", "-geo", geo, "-title", ptyTitle, ptyName, NULL);
      error("cannot exec xterm process %d", i);
    }
    terminals[i].in = fdopen(master, "r");
    setvbuf(terminals[i].in, NULL, _IONBF, 0);
    terminals[i].out = fdopen(master, "w");
    setvbuf(terminals[i].out, NULL, _IONBF, 0);
    /* skip the window id written by xterm */
    while (fgetc(terminals[i].in) != '\n') ;
  }
  termReset();
}
Ejemplo n.º 28
0
void mmuTbwr(void) {
  int index;

  /* choose a random index, but don't touch fixed entries */
  do {
    index = rand() & TLB_MASK;
  } while (index < TLB_FIXED);
  tlb[index].page = tlbEntryHi & PAGE_MASK;
  tlb[index].frame = tlbEntryLo & PAGE_MASK;
  tlb[index].write = tlbEntryLo & TLB_WRITE ? true : false;
  tlb[index].valid = tlbEntryLo & TLB_VALID ? true : false;
  if (debugWrite) {
    cPrintf("**** TLB[%02d] <- 0x%08X 0x%08X %c %c ****\n",
            index, tlb[index].page, tlb[index].frame,
            tlb[index].write ? 'w' : '-',
            tlb[index].valid ? 'v' : '-');
  }
}
Ejemplo n.º 29
0
void TERMWINDOWMEMBER receiveFiles(const protocols *theProt)
	{
	cPrintf(getnetmsg(101));
	doccr();

	wxrcv(LocalTempPath, roomdataIn, theProt);

	if (!filexists(roomdataIn))
		{
		CITWINDOW *w = ScreenSaver.IsOn() ? NULL : CitWindowsMsg(NULL, getmsg(685), getmsg(74));

		Hangup();
		netFailed = TRUE;

		if (w)
			{
			destroyCitWindow(w, FALSE);
			}
		}
	}
Ejemplo n.º 30
0
static void rcvrCallback(int dev) {
  int c;

  if (debug) {
    cPrintf("\n**** TERM RCVR CALLBACK ****\n");
  }
  timerStart(TERM_RCVR_MSEC, rcvrCallback, dev);
  c = fgetc(terminals[dev].in);
  if (c == EOF) {
    /* no character typed */
    return;
  }
  /* any character typed */
  terminals[dev].rcvrData = c & 0xFF;
  terminals[dev].rcvrCtrl |= TERM_RCVR_RDY;
  if (terminals[dev].rcvrCtrl & TERM_RCVR_IEN) {
    /* raise terminal rcvr interrupt */
    cpuSetInterrupt(terminals[dev].rcvrIRQ);
  }
}