Пример #1
0
/* --------------------------------------------------------------------
 *  mpPrintf()       sends menu prompt output to modem & console
 * -------------------------------------------------------------------- */
void mpPrintf(char *fmt,...)
{
    va_list ap;
	char *p,*p2;
	int markers = 0;

    va_start(ap, fmt);
    vsprintf(buff, fmt, ap);
    va_end(ap);

	if (gl_term.ansiOn) {
		for (p=buff,p2=buff2;*p;++p,++p2) {
			if (*p == '<' && markers == 0) {	/* parse first marker */
				*p2++ = 1;		/* ^A */
				*p2 = TERM_BOLD;
				++markers;
			} else if (*p == '>' && markers == 1) {
				*p2++ = 1;		/* ^A */
				*p2 = TERM_NORMAL;
				++markers;
			} else {
				*p2 = *p;
			}
		}
		*p2 = '\0';
		mFormat(buff2);
	} else
		mFormat(buff);
}
Пример #2
0
/*
 * FindFileComment()
 *
 * This will find a file comment for file: see SYSDEP.DOC.
 */
int FindFileComment(char *fileName, char extraneous)
{
    char *c, Chatter = FALSE;
    int Last;

    if (fileTags == NULL) return FALSE;

    /* Check to see if already in buffer */
    if (specCmpU(fileName, msgBuf.mbtext) == SAMESTRING) return TRUE;

    /* 
     * No. If last search was successful, then we have to get the next
     * line right now.
     */
    if (tagFound) {
	do {
	    if ((c = fgets(msgBuf.mbtext, MAXTEXT-10, fileTags)) == NULL)
		break;
	    if (msgBuf.mbtext[0] == ';')
		if (extraneous) {
		    mFormat(msgBuf.mbtext + 1);
		    Last = strLen(msgBuf.mbtext + 1);	/* finicky check */
		    Chatter = TRUE;
		}
	} while (msgBuf.mbtext[0] == ';');
    }

    if (Chatter && Last > 1)/* need this for ";" stuff -- allows normal	*/
	doCR();		/* formatting without blank lines.		*/

    tagFound = FALSE;

    while (c != NULL && specCmpU(fileName, msgBuf.mbtext) > SAMESTRING) {
	do {
	    if ((c=fgets(msgBuf.mbtext, MAXTEXT-10, fileTags)) == NULL)
		break;
	    if (msgBuf.mbtext[0] == ';')
		if (extraneous) {
		    mFormat(msgBuf.mbtext + 1);
		    doCR();
		}
	} while (msgBuf.mbtext[0] == ';');
    }

    if (c != NULL)
	tagFound = (specCmpU(fileName, msgBuf.mbtext) == SAMESTRING);

    return tagFound;
}
Пример #3
0
// FSM
void disk_sched_irq_handler(){
	irq_disable();
	disk_job_str* current = disk_queue;
assert(current);
	ctx_s* owner = current->ctx;
	_dprint("DISK_IRQ\n");

	switch(disk_state){
		case DS_IDLE:
			fprintf(stderr, "WARNING - %s:%d - UNEXPECTED INTERRUPT IN IDLE STATE.\n", __FILE__, __LINE__);
			return;
		case DS_SEEK:{
			_dprint("SEEK TERMINE\n");
			// on vient de finir le seek.
			// Que faire maintenant ? > Dépend du type de tâche	
			switch(current->type){
				case DJT_READ:
					// on lance le read
					disk_state = DS_READ;
					read_sector(current->cyl, current->sect, current->buffer);
					irq_enable();
					return;
				case DJT_WRITE:
					// on lance le write
					disk_state = DS_WRITE;
					write_sector(current->cyl, current->sect, current->buffer);
					irq_enable();
					return;
				case DJT_FORMAT:
					// on lance le format
					disk_state = DS_FORMAT;
					mFormat(current->cyl, current->sect, 1, 0x0);
					irq_enable();
					return;
				default:
					// ???
					return;
			}
		}
		case DS_READ: // les données sont présentes dans le MASTERBUFFER. On les copie dans l buffer du job
			_dprint("READ TERMINE\n");
			assert(current->buffer);
			memcpy(current->buffer, MASTERBUFFER, secSize);
		case DS_WRITE:
		case DS_FORMAT:
			//disk_delete_job(current);
			disk_queue = current->next;

			// retour à idle
			disk_state = DS_IDLE;
			disk_ctx->status = CTXS_ACTIVABLE;
			// réactiver contexte propriétaire.
            owner->status = CTXS_ACTIVABLE;
			_dprint("JOB DONE\n");
			irq_enable();
			return;
		default:
			return;
	}
}
Пример #4
0
/*
 * OutsideEditorWork()
 *
 * This will execute an outside editor for anyone.
 */
void OutsideEditorWork(char *EditLine)
{
    char cmdline[90];
    extern FILE *upfd;
    extern int outPut;

    doCR();	/* this gets crtColumn back to zero */
    sprintf(cmdline, "%stempmsg.sys", cfg.DepData.EditArea);

    if (!redirect(cmdline, INPLACE_OF)) return;

    mFormat(msgBuf.mbtext, oChar, doCR);
    undirect();

    MakeCmdLine(cmdline, EditLine, "", sizeof cmdline - 1);
    if (cfg.DepData.IBM) ModemShutdown(FALSE);
    CitSystem(TRUE, "%s %stempmsg.sys", cmdline, cfg.DepData.EditArea);
    if (cfg.DepData.IBM) {
	ModemOpen(FALSE);
	if (!gotCarrier() && strLen(cfg.DepData.sDisable) == 0)
	    DisableModem(FALSE);
    }
    /* homeSpace(); */    /* Commented out for 120.692 */
    msgBuf.mbtext[0] = 0;

    sprintf(cmdline, "%stempmsg.sys", cfg.DepData.EditArea);
    msgBuf.mbtext[0] = 0;
    ingestFile(cmdline, msgBuf.mbtext);
    unlink(cmdline);
}
Пример #5
0
/*
** printdir() prints out one filename and size, for a dir listing
*/
static int printdir (struct dirList *fn)
{
    char *desc;
    extern char *getTag();
    extern char *monthTab[];

    if (fn->fd_name[0] != '$')  /* $dir is the directory file */
    {
        outFlag = OUTOK;

        if (FDextended) 
        {
            desc = getTag(fn->fd_name);
            CRfill = (termWidth > 62) ? "%13c|                " : "  ";
            mPrintf("%-13s|%7ld ", fn->fd_name,fn->fd_size);
            mPrintf("%02d%s%02d ", fn->fd_date._year,
                monthTab[fn->fd_date._month],
                fn->fd_date._day);
            if (desc) 
            {
                if (termWidth <= 62)
                    doCR();
                mFormat(desc);
            }
            CRfill = NULL;
            doCR();
        }
        else
            mPrintf("%-14s%7ld ", fn->fd_name, fn->fd_size);
        FDSectCount += fn->fd_size;
        mAbort();                       /* chance to next(!)/pause/skip */
    }
    return (outFlag != OUTSKIP);
}
Пример #6
0
/* -------------------------------------------------------------------- */
dumpf(char *filename)
{
    FILE *fbuf;
    char line[MAXWORD];
    int returnval = TRUE;

    /* last itteration might have been N>exted */
    outFlag = OUTOK;
    setio(whichIO, echo, outFlag);

    doCR();

    if ( (fbuf = fopen(filename, "r")) == NULL)
    {
        mPrintf(" No helpfile %s", filename);
        return(ERROR);
    }
    /* looks like a kludge, but we need speed!! */

    while ( fgets(line, MAXWORD, fbuf) && (outFlag != OUTNEXT)
    && (outFlag != OUTSKIP) && !mAbort(FALSE) )
    {
        mFormat(line);
    }
    if ( outFlag == OUTSKIP) returnval = ERROR;
    
    fclose(fbuf);

    return  returnval;
}
Пример #7
0
int TERMWINDOWMEMBER Brent(const char **Format, int *colCount, char *collect)
	{
	char thisFormat = **Format;
	char toOutput = thisFormat;

	if (thisFormat == '^')
		{
		toOutput = *(++(*Format));

		if (toupper(toOutput) >= 'A' && toupper(toOutput) <= 'Z')
			{
			toOutput = (char) (toupper(toOutput) - 64);
			}

		}
	else if (thisFormat == '\\')
		{
		toOutput = *(++(*Format));

		switch (toupper(toOutput))
			{
			case 'N':
				{
				if (*colCount)
					{
					collect[*colCount] = 0;
					mFormat(collect);
					*colCount = 0;
					}

				OC.Formatting = TRUE;
				doCR();
				OC.Formatting = FALSE;

				toOutput = 0;
				break;
				}

			case 'T':
				{
				toOutput = '\t';
				break;
				}

			case 'B':
				{
				toOutput = '\b';
				break;
				}
			}
		}

	if (toOutput)
		{
		collect[(*colCount)++] = toOutput;
		}

	return (**Format);
	}
Пример #8
0
/* -------------------------------------------------------------------- */
void mPrintf(char *fmt,...)
{
    va_list ap;

    va_start(ap, fmt);
    vsprintf(buff, fmt, ap);
    va_end(ap);

    mFormat(buff);
}
Пример #9
0
/* --------------------------------------------------------------------
 *  mtPrintf()      Sends formatted output to modem & console
 *                  with termCap attributes.  Resets attributes when
 *                  done.
 * -------------------------------------------------------------------- */
void mtPrintf(char attr, char *fmt,...)
{
    va_list ap;

    termCap(attr);
    va_start(ap, fmt);
    vsprintf(buff, fmt, ap);
    va_end(ap);

    mFormat(buff);
    termCap(TERM_NORMAL);
}
Пример #10
0
void cdecl TERMWINDOWMEMBER Andy(const char *Format, const char *Codes, ...)
	{
	char *Vals[32], collect[512];
	const char *Code;
	int n, CodeCount, colCount;
	va_list ap;

	va_start(ap, Codes);

	for (n = 0, CodeCount = strlen(Codes); n < CodeCount && n < 32; ++n)
		{
		Vals[n] = va_arg(ap, char *);
		}

	va_end(ap);

	for (colCount = 0; *Format != '\0'; ++Format)
		{
		if (*Format != '%')
			{
			if (!Brent(&Format, &colCount, collect))
				{
				break;
				}
			continue;
			}

		if (*(++Format) == '\0')
			{
			break;
			}

		if (*Format == '%')
			{
			collect[colCount++] = *Format;
			continue;
			}

		// not stuff
		if (*Format == '[')
			{
			// Scan for close and include-location.
			for (Code = Format; *Code != 0 && *Code != ']'; ++Code);

			if (*Code == '\0')
				{
				break;
				}

			if ((n = strpos(*(Code + 1), Codes)) != 0)
				{
				if (Vals[n - 1][0] == '\0')
					{
					for (++Format; Format < Code; ++Format)
						{
						if (!Brent(&Format, &colCount, collect))
							{
							break;
							}
						}

					if (*Format)
						{
						Format++;
						}
					}
				else
					{
					Format = Code + 1;
					}
				}

			continue;
			}

		if (*Format != '{')
			{
			if ((n = strpos(*Format, Codes)) != 0)
				{
				if (colCount)
					{
					collect[colCount] = 0;
					mFormat(collect);
					colCount = 0;
					}

				mFormat(Vals[n - 1]);
				}

			continue;
			}

		// Scan for close and include-location.
		const char *Include = NULL;
		for (Code = Format; *Code != 0 && *Code != '}'; ++Code)
			{
			if (*Code == '&')
				{
				Include = Code;
				}
			}

		if (*Code == '\0')
			{
			break;
			}

		if (Include == NULL)
			{
			if ((n = strpos(*(Code + 1), Codes)) != 0)
				{
				if (Vals[n - 1][0] != '\0')
					{
					if (colCount)
						{
						collect[colCount] = 0;
						mFormat(collect);
						colCount = 0;
						}

					for (++Format; Format < Code; ++Format)
						{
						if (!Brent(&Format, &colCount, collect))
							{
							break;
							}
						}

					if (*Format)
						{
						Format++;
						}
					}
				else
					{
					Format = Code + 1;
					}
				}
			}
		else
			{
			if ((n = strpos(*(Code + 1), Codes)) != 0)
				{
				if (Vals[n - 1][0] != '\0')
					{
					if (colCount)
						{
						collect[colCount] = 0;
						mFormat(collect);
						colCount = 0;
						}

					for (++Format; Format < Include; ++Format)
						{
						if (!Brent(&Format, &colCount, collect))
							{
							break;
							}
						}

					if (colCount)
						{
						collect[colCount] = 0;
						mFormat(collect);
						colCount = 0;
						}

					mFormat(Vals[n - 1]);

					for (++Format; Format < Code; ++Format)
						{
						if (!Brent(&Format, &colCount, collect))
							{
							break;
							}
						}

					if (*Format)
						{
						Format++;
						}
					}
				else
					{
					Format = Code + 1;
					}
				}
			}
		}

	if (colCount)
		{
		collect[colCount] = 0;
		mFormat(collect);
		}
	}
Пример #11
0
BOOL editBuf (char *buf, int lim)
{
#define MAXEWORD 50
	int i;
	unsigned int c = 0;
    int done = FALSE;
	char beeped = FALSE;
	int wsize = 0;
    unsigned int lastCh;
    int toReturn;
    unsigned char word[MAXEWORD];
	
    if (!oldFlag) {
		*buf='\0';
    }

	i = strlen(buf);
	/* kill trailing CR's */
    while (i && buf[i - 1] == '\n') {
        buf[i - 1] = 0;
		--i;
	}
    mFormat(buf);
	
    do {
        i = strlen(buf);
        if (i)
            c = buf[i];
        else
            c = '\n';

        while (!done && i < lim && (!ExitToMsdos && (haveCarrier || onConsole))) {
            if (i)
                lastCh = c;

            c = iChar();

            switch (c) {    /* Analize what they typed       */
                case 1:     /* CTRL-A>nsi   */
				{
					unsigned int temp, d;
					
                    temp = echo;
                    echo = NEITHER;
                    d = (char) iChar();
                    echo = temp;

                    if (d >= '0' && toupper(d) <= 'H' && gl_term.ansiOn) {
                        if (d == '?') { /* ansi help */
                            mPrintf("ansi.hlp");
                            nexthelp("ansi", &(cfg.cnt.ansitut), 1);
                        } else {
                            termCap(d);
                            buf[i++] = 0x01;
                            buf[i++] = d;
                        }
                    } else {
                        oChar(7);
                    }
                    break;
				}
                case '\n':      /* NEWLINE      */
                    if ((lastCh == '\n') || (i == 0))
                        done = TRUE;
                    if (!done)
                        buf[i++] = '\n';  /* A CR might be nice   */
                    break;
                case 27:        /* An ESC? No, No, NO!  */
                    oChar('\a');
                    break;
                case 0x1a:      /* CTRL-Z       */
                    done = TRUE;
                    entered++;  /* increment # messages entered */
                    break;
                case '\b':      /* CTRL-H bkspc */
                    if ((i > 0) && (buf[i - 1] == '\t')) {  /* TAB  */
                        i--;
                        while ((crtColumn % 8) != 1)
                            doBS();
                    } else if ((i > 0) && (buf[i - 1] != '\n')) {
                        i--;
                        if (wsize > 0)
                            wsize--;
                    } else {
                        oChar(32);
                        oChar('\a');
                    }
                    break;
                default:        /* '\r' and '\n' never get here */
                    if ((c == ' ') || (c == '\t') || (wsize == MAXEWORD)) {
                        wsize = 0;
                    } else if (crtColumn >= (gl_term.termWidth - 1)) {
                        if (wsize) {
							int j;
						
                            for (j = 0; j < (wsize + 1); j++)
                                doBS();
                            doCR();
                            for (j = 0; j < wsize; j++)
                                echocharacter(word[j]);
                            echocharacter(c);
                        } else {
                            doBS();
                            doCR();
                            echocharacter(c);
                        }
                        wsize = 0;
                    } else {
                        word[wsize] = c;
                        wsize++;
                    }

                    if (c != 0)
                        buf[i++] = c;

                    if (i > cfg.maxtext - 80 && !beeped) {
                        beeped = TRUE;
                        oChar('\a');
                    }
                    break;
            }

            buf[i] = '\0';  /* null to terminate message */
            if (i)
                lastCh = buf[i - 1];

            if (i == lim)
                mPrintf(" Buffer overflow.\n ");
        }
        done = FALSE;       /* In case they Continue */

        termCap(TERM_NORMAL);

        if (c == 0x1a && i != lim) {    /* if was CTRL-Z */
            buf[i++] = '\n';    /* end with NEWLINE */
            buf[i] = '\0';
            toReturn = TRUE;    /* yes, save it */
            doCR();
            mPrintf(" Saving message");
            doCR();
        } else          /* done or lost carrier */
            toReturn = editText(buf, lim);

    } while ((toReturn == ERROR) && (!ExitToMsdos && (haveCarrier || onConsole)));
    /* ERROR returned from editor means continue    */

    if (toReturn == TRUE) { /* Filter null messages */
        toReturn = FALSE;
        for (i = 0; buf[i] != 0 && !toReturn; i++)
            toReturn = (buf[i] > ' ' && buf[i] < 127);
    }
	return (BOOL) toReturn;
}
Пример #12
0
BOOL fedit(char *filename)
{
	FILE *fp;
	char *buf;
	unsigned int lim;			/* can't edit more then a segment anyway */
	long filesize;
	int rc = FALSE;
	int err;
	char path[64];
	
	getcwd(path,64);

	err = errno = 0;
	/* set the message entry flags and buffer */
	clearmsgbuf();
    setmem(msgBuf, sizeof(struct msgB), 0);
    mailFlag = FALSE;
    oldFlag = FALSE;
    limitFlag = FALSE;
    linkMess = FALSE;
	if (loggedIn)
		strcpy(msgBuf->mbauth,logBuf.lbname);
	
	/* try to edit an existing file */
	if (filexists(filename)) {
		fp = fopen(filename,"rt");
		if (fp) {
			filesize = filelength(fileno(fp));
			if ((unsigned int) (filesize + (long) cfg.maxtext) > UINT_MAX) {
				err = -2;
				cPrintf("\nFile too long\n");
			} else {
				lim = cfg.maxtext + (int) filesize;
				buf = calloc(1,lim);
				if (buf) {
					errno = 0;
					if (!fread(buf,1,lim,fp)) {
						cPrintf("\nFile read error\n");
						err = errno;
					}
					if (fclose(fp) && !err) {/* we need to 'recreate' later */
						cPrintf("\nFile close error\n");
						err = errno;
					}
					if (!err)
						mFormat(buf);		/* display the file */
					oldFlag = TRUE;
					
				}
			}
		} else {
			lim = cfg.maxtext;
			buf = calloc(1,lim);
			oldFlag = FALSE;
		}
	}
	
	if (buf && !err && editBuf(buf,lim)) {
		changedir(path);		/* because silly edit routines loose path */
		if (!strblank(buf)) {
			rc = TRUE;
			lim = strlen(buf);
			errno = 0;			/* because silly video routines set it */
			fp = fopen(filename,"wt");
			if (!fp && !err) {
				cPrintf("\nFile open error 2\n");
				err = errno;
			}
			if (fp) {
				/* because silly DOS doesn't 'error' on disk full	*/
				if(!fwrite(buf,1,lim,fp) && !errno) {
					cPrintf("\nFile write error\n");
					err = -1;
				}
				errno = 0;
				if (!fclose(fp)&& !err) {
					cPrintf("\nFile close error 2\n");
					err = errno;
				}
			}
		} else {				/* we won't save empty files */
			rc = FALSE;
		}
	}
	if (!buf) {					/* out of memory condition */
		mtPrintf(TERM_BOLD," \n Out of memory editing file %s.\n",filename);
		rc = FALSE;
	} else {
		switch (err) {
			case 0:		/* no error */
			break;
			
			case -1:	/* disk full condition */
				mtPrintf(TERM_BOLD,
					" \n Disk full saving %s, file truncated.\n",filename);
				rc = FALSE;
			break;
			
			case -2:	/* file >64k condition */
				mtPrintf(TERM_BOLD,
					" \n File %s is too large to edit.\n",filename);
				rc = FALSE;
			break;
			
			default:	/* DOS error condition */
				mtPrintf(TERM_BOLD, " \n DOS error '%s' editing %s: \n",
					strerror(err),filename);
				rc = FALSE;
			break;
		}
	}
	if (buf) {
		free(buf);
		buf = NULL;
	}
	return rc;
}
Пример #13
0
/* -------------------------------------------------------------------- */
int editText(char *buf, int lim)
{
    char ch, x;
    FILE *fd;
    int eom;

    dowhat = PROMPT;

    do {
        outFlag = IMPERVIOUS;
        while (MIReady())   /* flush modem input buffer */
            getMod();
		doCR();
		strcpy(gprompt,"Entry command:");	/* in case of ^A? */
        mtPrintf(TERM_REVERSE,gprompt);
		mPrintf(" ");
        switch (ch = (char) toupper(iChar())) {
            case 'A':
                mPrintf("\bAbort\n ");
                if (strblank(buf))
                    return FALSE;
                else if (getYesNo(confirm, 0)) {
                    heldMessage = TRUE;

                    memcpy(msgBuf2, msgBuf, sizeof(struct msgB));

                    dowhat = DUNO;
                    return FALSE;
                }
                break;
            case 'C':
                mPrintf("\bContinue");
				/* dump message to display */
				outFlag = IMPERVIOUS;
                doCR();
                putheader();
                doCR();
				outFlag = OUTOK;
                mFormat(buf);
                doBS();
                eom = strlen(buf);
                if (eom > 0)
                    buf[eom - 1] = '\0';    /* zap last character ('\n') */
				outFlag = IMPERVIOUS;
                return ERROR;				/* to return to this routine */
            case 'F':
                mPrintf("\bFind & Replace text\n ");
                replaceString(buf, lim, TRUE);
                break;
            case 'P':
                mPrintf("\bPrint formatted\n ");
                doCR();
				outFlag = IMPERVIOUS;
                putheader();
                doCR();
				outFlag = OUTOK;
                mFormat(buf);
                termCap(TERM_NORMAL);
                doCR();
                break;
            case 'R':
                mPrintf("\bReplace text\n ");
                replaceString(buf, lim, FALSE);
                break;
            case 'S':
                mPrintf("\bSave buffer\n ");
                entered++;      /* increment # messages entered */
                dowhat = DUNO;
                return TRUE;
            case 'W':
                mPrintf("\bWord count\n ");
                wordcount(buf);
                break;
            case '?':
                nextmenu("edit", &(cfg.cnt.edittut), 1);
                break;
            default:
                if ((x = (char) strpos((char) tolower(ch), editcmd)) != 0) {
                    x--;
                    mPrintf("\b%s", edit[x].ed_name);
                    doCR();
                    if (edit[x].ed_local && !onConsole) {
                        mPrintf("\n Local editor only!\n ");
                    } else {
                        changedir(cfg.aplpath);
                        if ((fd = fopen("message.apl", "wb")) != NULL) {
                            xPutStr(fd, msgBuf->mbtext);
                            fclose(fd);
                        }
                        readMessage = FALSE;
                        extFmtRun(edit[x].ed_cmd, "message.apl");
                        changedir(cfg.aplpath);
                        if ((fd = fopen("message.apl", "rb")) != NULL) {
                            GetStr(fd, msgBuf->mbtext, cfg.maxtext);
                            fclose(fd);
                            unlink("message.apl");
                        }
                    }
                    break;
                }
                if (!gl_user.expert)
                    nextmenu("edit", &(cfg.cnt.edittut), 1);
                else
                    mPrintf("\n '?' for menu.\n \n");
                break;
        }
    } while (!ExitToMsdos && (haveCarrier || onConsole));
    dowhat = DUNO;
    return FALSE;
}