SETJMP H SBRK C ERRNO H PORTAB H  WRITEL C DOSCAN C HFILBUF C CLEANUP C PERROR C qrstFREOPEN C uvwxREADL C yCREAT C z{|}he programmer sees a return from the */ /* previous "setjmp" as the result. */ /* */ /* Calling sequenMALLOCDBC <=>NOBINARYC ?NOASCII C @NOLONG C ADigital Research. All rights reserved. */ /* */ /* Long jumps are implemented as follows: */ /* STDIO H  OSIFERR H SIGNAL H SGTTY H PRTSHORTC FFLUSH C FPUTN C FPUTS C BLKFILL C ~FILESZ C "FGETC C CLOSE C ce: */ /* */ /* #include (definitions) */ /* jmp_buf env; (define a buffer for saved BLKIO C *BCDEFGLSTOUT C HIEXEC C JKLFLSBUF C MNOP */ /* 1). Routine "setjmp" is called to setup a special */ /* buffer for return. The return address, stack OPTION H .CTYPE H OSIF H [ !"#$%&'WRITEBINC 6()*+,-.CALLOC C FDOPEN C FTELL C MAIN C CHKUSER C DOPRTFP C :STRLEN C EXIT C stuff) */ /* */ /* setjmp(env); */ /* a: */ /* */ /* longjmp(env,val); FPUTC C QRXMAIN C MSTUVWXYZ[\OSATTR C ]^_`READBIN C 1abcdefg */ /* pointer and frame pointer are saved. This allows */ /* the calling program to do the proper number of */ C SUB/CLINK SUB0NOFILESZC 1NOFLOAT C 2/****************************************************************************/ /* */ /* L o n g j u m p H eCTYPE C FCLOSE C FDECLS C FSEEK C  */ /* */ /* Setjmp returns a WORD of 0 on first call, and "val" on the */ /* subsequent "longjmp" callPRTLD C hiATOI C jYESSTARTC kFOPEN C "lmnop /* "pops". */ /* */ /* 2). At some later time, the procedure "longjmp" is */ /* called. TNODISK C 3NOTTYIN C 456REAR SUB789NOSTART C :; a d e r F i l e */ /* --------------------------------------- */ /* */ /* Copyright 1982,83 by . The longjmp call causes execution to */ /* resume at "a:" above. */ /* */ /***********************ude "portab.h" #include "osif.h" #include "osiferr.h" #include "errno.h" /****************************/ EXTERN BYTE * * * addr = sbrk(incr); * * Where: * incr Is the incremental numincr); /* Initialize to 0's */ return(t1); /* And return */ } /****************************/  the old break */ t2 = _break + inc; /* New break value */ /****************************/ if(brk(t2) == FAI*****************************************************/ typedef long jmp_buf[13]; _break; /* Old break address */ /****************************/ BYTE * sbrk(incr) /* CLEAR FUNCTION ***********/ber of bytes to be added to * the program heap area. * * addr Is the beginning address of the aX>/<NX>/<NX#By.a n2n B*nJg(HHм @g H| `HR`*n/*************************************************************************** * * s b r k F u n c t i oLURE) /* Allocate */ RETERR(FAILURE,ENOMEM); /* Can't */ /****************************/ blkfill(t1,NULL****************************************************/ typedef long jmp_buf[13];  WORD incr; /* Incremental storage */ /* */ { /****************************/ REG BYTE *t1,*t2; /*llocated area. * -1 is returned if allocation failed * * Last modified: * 1/84 whf refresh incJgJgHHм @gR`Jg "g 'fDH>/ RNX(@ f./ aX > M2GBRG.Ra&`BG M2G n * ------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. ,incr); /* Initialize to 0's */ return(t1); /* And return */ } /****************************/ ****************************************************/ typedef long jmp_buf[13];  Temporary */ REG LONG inc; /* Temp size increment */ inc = ((LONG)incr) & 0xffffL; /* Un sign-extend */ ilude files for 68K (sbrk in asm for 8086) ****************************************************************************/ #inclJg5pHHм @fRG`J5pg M2GBRGH`8BWNBW/ RNXJ@g.R/<a\X`>NBW/ RNX| * * The "sbrk" function is used to allocate memory dynamically. * * Calling Sequence: incr); /* Initialize to 0's */ return(t1); /* And return */ } /****************************/ f(inc & 1) /* Disallow odd incr's */ inc++; /* Round up to next */ /* */ t1 = _break; /* Saveg.R/<a*X`>?/ NXJf>*/ NXJg(|.4?<NT>/ ?<N\<f../ aXRL21|L22L18L23L24L25L26L10004L27ftware */ #define EDOM 33 #define ERANGE 34 /* hereafter is available to CP/M specials */ #define ENODSPC 35 #define EREN. All rights reserved. * * This is an include file for assisting the user to write portable * programs for C. All processorne ENXIO 6 #define E2BIG 7 #define ENOEXEC 8 #define EBADF 9 #define ECHILD 10 #define EAGAIN 11 #define ENOMEM 12 #definL39,l,l,l<LD4<g^.H?/ a>\.N>RWN&@./ NX.a>/ ?<N\``.a`|g`L28L29.L31L30~__toascpL32L7L1~~_errAME 36 /****** end of errno.h ******/  dependencies should be located here. * ****************************************************************************/ /* * e EACCES 13 #define EFAULT 14 #define ENOTBLK 15 #define EBUSY 16 #define EEXIST 17 #define EXDEV 18 #define ENODEV 19 #d$$`BaSy.?9NT>NJL8N^NuNV.N>/.?<N\. N>/. ?<N\>/<9~s1~s2 L359L340~~addarg4~ptr L38^L37f~~_toascpME 36 /****** end of errno.h ******/ Standard type definitions */ #define BYTE char /* Signed byte */ #define UBYTE char /* Unsigned byte */ #defiefine ENOTDIR 20 #define EISDIR 21 #define EINVAL 22 #define ENFILE 23 #define EMFILE 24 #define ENOTTY 25 #define ETXTBSY/**************************************************************************** * * C P / M C R U N T I M E L I B H ?<N\>NN^NuNVH *n(y.XNJ@gN(RyJL0N^NuNVH*n. (n&MH@H4B.~f ~buf L40L41;L42L43L44L46L45HL4ME 36 /****** end of errno.h ******/ ne BOOLEAN int /* 2 valued (true/false) */ #define WORD int /* Signed word (16 bits) */ #define UWORD unsigned int 26 #define EFBIG 27 #define ENOSPC 28 #define ESPIPE 29 #define EROFS 30 #define EMLINK 31 #define EPIPE 32 /* math soE A D E R F I L E * ------------------------------------------------------------- * Copyright 1982 by Digital Research Inc /* * errno.h - error codes */ #define EPERM 1 #define ENOENT 2 #define ESRCH 3 #define EINTR 4 #define EIO 5 #defi8DL100058L10007BL47DL50NL49L52L10008L10010L51 /* unsigned word */ #define LONG long /* signed long (32 bits) */ #define ULONG unsigned long /* Unsigned long ************************************************/ #define EOF (-1) /* EOF Value */ #define TRUE (1) /* Function TRUE value */ #define FALSE (0) /* Function FALS******************************************************* * Stream I/O File Definitions ************************************************************************/ /* Miscellaneous Definitions: */ /**************************************************/***************************************************************************** * * C P / M C H E A D E R F I L E * */ #define REG register /* register variable */ #define LOCAL auto /* Local var on 68000 */ #define EXTERN exL26L27<,E value */ /****************************************************************************/ /****************************************************************/ #define BUFSIZ 512 /* Standard (ascii) buf size */ #define MAXFILES 16 /* Max # op**************************/ #define FAILURE (-1) /* Function failure return val */ #define SUCCESS (0) /* Function success ----------------------------------- * Copyright 1982,83 by Digital Research Inc. All rights reserved. * * This is the tern /* External variable */ #define MLOCAL static /* Local to module */ #define GLOBAL /**/ /* Global variable,<,,$$*************************************************/ en files ( < 32 ) */ struct _iobuf { /* */ WORD _fd; /* file descriptor for low level io */ WORD _flag; /* return val */ #define YES 1 /* "TRUE" */ #define NO 0 /* "FALSE" */ #define FOREVER for(;;) /* Infinite lostandard include file for the CP/M C Run Time Library. * ********************************************************************* */ #define VOID /**/ /* Void function return */ #define DEFAULT int /* Default size */ #define FLOAT float <,4************************************************/ stream info flags */ BYTE *_base; /* base of buffer */ BYTE *_ptr; /* current r/w pointer */ WORD _cnt;op declaration */ #define NULL 0 /* Null character value */ #define NULLPTR (char *) 0 /* Null pointer value */ ********/ /* */ #include /* Portability Definitions */ /* */ /********************* /* Floating Point */ #define DOUBLE double /* Double precision */ /******************************************** /* # chars to be read/have been wrt */ }; /* */ #ifndef FILE /* conditionally include: */ extern struct **********************/ /* */ /* M A C R O S */ /* ----------- */ /* */ /* Defierr(p) ((p)->_flag &= ~_IOERR) /* clear error flag */ #define feof(p) ((p)->_flag & _IOEOF) /* EOF encountered on stream _strlen_petoa_pftoa__doprt~~_doprtL2~longf~nchrs~widthdefine _IOEOF 0x20 /* EOF has occurred */ #define _IOLBUF 0x40 /* handle as line buffer */ #define _IOSTRI 0x80 ****************** end of stdio.h *********************************/ _iobuf _iob[MAXFILES]; /* an array of this info */ #define FILE struct _iobuf /* stream definition */ #endif /**ne some stuff as macros .... */ /* */ /******************************************************************** */ #define ferror(p) ((p)->_flag & _IOERR) /* error encountered on stream */ #define fileno(p) ((p)->_fd) /* get strea~c~n~s~padchar~pb ~fn~sp~pw~buf /* this stream is really a string */ #define _IOASCI 0x100 /* this was opened as an ascii file */ /********************************** end of stdio.h *********************************/ **********************************/ #define NULLFILE ((FILE *)0) /* Null return values */ /* flag byte definition ********/ #define abs(x) ((x) < 0 ? -(x) : (x)) /* Absolute value function */ #define MAX(x,y) (((x) > (y)) ? (x) : m's file descriptor */ #define getchar() getc(stdin) /* get char from stdin */ #define putchar(c) putc(c,stdout) /* /* OSIF Error handling *************************************/ EXTERN WORD errno; /* error place for assigning */ EX*******************/ #define stdin (&_iob[0]) /* standard input stream */ #define stdout (&_iob[1]) /* " output ***************** end of stdio.h *********************************/  */ #define _IOREAD 0x01 /* readable file */ #define _IOWRT 0x02 /* writeable file */ #define _IOABUF 0x04 (y)) /* Max function */ #define MIN(x,y) (((x) < (y)) ? (x) : (y)) /* Min function */ #define max(x,y) (((x) > put char to stdout */ #define putc fputc #define getc fgetc /******************************************************TERN WORD __cpmrv; /* the last BDOS return value (AX) */ EXTERN WORD _errcpm; /* place to save __cpmrv */ #define RET " */ #define stderr (&_iob[2]) /* " error " */ /************************************/ #define clear(|__iob_fputc___prtld___prtin___prtsh /* alloc'd buffer */ #define _IONBUF 0x08 /* no buffer */ #define _IOERR 0x10 /* error has occurred */ # (y)) ? (x) : (y)) /* Max function */ #define min(x,y) (((x) < (y)) ? (x) : (y)) /* Min function */ /*********ERR(val,err) {errno=(err);_errcpm=__cpmrv;return(val);} /************************************/ n PDP-11) */ #define SIGEMT 7 /* EMT instruction (TRAP on 68k) */ #define SIGFPE 8 /* Floating point exception will */ /* not get compile-time errors. Some functions are not implemented. */ /* */ /********************* /* sgtty.h - tty control information */ /* Note reduced contents for CP/M implementation... */ struct sgttyb{ char sg_ispee*L46*L45LL48PL47xL50|L49L1*/ #define SIG_DFL (0L) /* Default action on signal call */ #define SIG_IGN (1L) /* Ignore */ /************RR(val,err) {errno=(err);_errcpm=__cpmrv;return(val);} /************************************/  */ #define SIGKILL 9 /* Kill (cannot be intercepted) */ #define SIGBUS 10 /* BUSERR (non-ex memory reference) */ #*******************************************************/ #define NSIG 16 /* 16 simulated signals */ #define SIGHUP 1 d; /* ignored */ char sg_ospeed; /* ignored */ char sg_erase; /* ignored */ char sg_kill; /* ignored */ int sg_flags; /****************************************************************************/ /* */ /* S i g n a l H e a************************/ RR(val,err) {errno=(err);_errcpm=__cpmrv;return(val);} /************************************/ define SIGSEGV 11 /* Segmentation (MMU) violation */ #define SIGSYS 12 /* Bad argument to system call */ #define S /* Hangup */ #define SIGINT 2 /* Interrupt (^C) */ #define SIGQUIT 3 /* Quit signal */ #define SIGILL }; #define XTABS 0006000 #define RAW 0000040 #define CRMOD 0000020 #define ECHO 0000010 #define LCASE 0000004 #define CB d e r F i l e */ /* ----------------------------------- */ /* */ /* Copyright 1982 by Digital***********************/ L10022L10024L29L30L31L32L33L34L35IGPIPE 13 /* Write on a broken pipe */ #define SIGALRM 14 /* Alarm clock (what a name!) */ #define SIGTERM 15 /* 4 /* Illegal Instruction trap */ #define SIGTRAP 5 /* Trace Trap */ #define SIGIOT 6 /* IOT instruction (oREAK 0000002  Research, Inc. All rights reserved. */ /* */ /* Define the "signal" arguments, so anyone using the function ***********************/ L36L37>L38>L39L40L41L42L43PL44 Software termination signal */ /************************************/ #define BADSIG (-1L) /* Error return EAK 0000002  The programmer can * choose broad sets of options (i.e. "MINIMAL"), or can choose specific * options to stub out of the finconversions, the code in the "printf()" * routine will never be used. The "option.h" module gives the programmer * a mechanisining * the tag definitions, and then link this module and the OPTION* library * along with the rest of the program. For exam------------------------------- * Copyright 1983 by Digital Research Inc. * * Date: 1/5/84 * * The CLEAR*.L86 libraries prm * the OPTION* library which contains "nofloat()". This module also contains * certain stubroutines which satisfy functionalEAK 0000002 al program (i.e. "NOFLOAT"). * * Each definition contains a "tag declaration". The tag declaration * will link in a module fm of communicating to the linker that certain low level functions * are optional (not used by the program), and can be left outple, to reduce the size of * the "hello.c" program load image, the programmer could prepare a file * (named "opt.c" in this eovide a large number of functions which * are not needed by every program, but which must be linked into the program * because references to the floating * point conversion routines in "printf()". Thus, the code for these * conversions will not be linNVH*n<.H n0H.JngJl D. n P-"n R`μJg./NX. 9` NqJL N^Nu_uldivrom the OPTION*.L86 (OPTIONS.L86 or OPTIONL.L86) * library which also contains a "stubroutine" for some internal * function o to save space * in the program load image (.CMD file). * * "option.h" provides a set of definitions which allow the programmxample) that looks like: * opt.c: * #include "option.h" * MINIMAL * Then, after compiling hello.c and opt.c, the link com their usage is data driven. One example is the floating point * conversion routines in the "printf()" function. The programked into the final program load image. If * the program happens to use the "%f", "%g" or "%e" printf() conversions, * the st_uldivr___prtsh~~__prts~b~n~p ~signed~base~digsf the CLEAR* Run Time Library. * * For example, the definition of NOFLOAT is "int nofloat();". When * the programmer specifier * to specify certain options of the CLEAR* Run Time libraries (CLEARS.L86 or * CLEARL.L86) which the program does not use. mand should look like: * LINK86 HELLO,OPT,OPTIONS.L86[SEARCH * Note that the "[SEARCH]" option is very important, since LImer can specify * "%f", "%g" or "%e" conversions which the linker can not detect. If the * program never needs or uses these ubroutines provided will print an error message and exit. * * We recommend that the programmer compile a separate module conta/*************************************************************************** * * O P T I O N H e a d e r F i l e * ----es "NOFLOAT" in the source file and then links the * final program with the OPTION* library, the linker links in the module froNK86 will pull * in all routines in OPTIONS.L86 if you do not use this option. * * * Specific options are documented below. evel Disk I/O subroutines. * Watch out when you do binary file i/o: openb(), creatb(), * fopenb(), freopb(). * Saves: CPM sm*********** * MAXFILES5: reduces the maximum number of open files allowed from 16 to 5. * Note: this includes console files. programmers. **************/ #define NOSTARTUP int nostartup();  to "read()" from the console. * Watch out when you use STDIN on reads. * Saves: CPM small 300, big 350 *************/ #defiESZ MAXFILES5 NOWILDCARDS \ NOASCII NOBINARY /************* * NOSTARTUP: links out all of the CLEAR initialization r * ****************************************************************************/ /************* * NOFLOAT: link out floatall 2200, big 2900 *************/ #define NOBINARY int nobinary(); /************* * NOASCII: eliminates ASCII low level Di* Saves: CPM small 1950, big 1950 *************/ #define MAXFILES5 int maxfiles5(); /************* * NOFILESZ: eliminates programmers. **************/ #define NOSTARTUP int nostartup(); ne NOTTYIN int nottyin(); /************* * NOWILDCARDS: eliminates wildcard expansion on command line. * Saves: CPM smaoutines, including * command line redirection (">", "<", and ">>" command line ops) and * wildcard expansion. Also leaves outing point conversion routines in "printf()", * "fprintf()", and "sprintf()". **************/ #define NOFLOAT int nofloat(); sk I/O subroutines. * Watch out when you redirect output to a file, or do any ascii file i/o: * open(), opena(), creat(), creathe functions to calculate the size of a file. * Watch out when you append 'fopen(name,"a")' or use 'lseek(fd,xx,2)'. * Saves:,ll 500, big 650 *************/ #define NOWILDCARDS int nowildcards(); /************************************************ opening STDIN, STDOUT, and STDERR. * Warning: this could have peculiar side effects, and should be used only * by experienced /************* * NOLONG: link out long integer conversion routines in "printf()", * "fprintf()", and "sprintf()". * Saves: tb(), fopen(), fopena(), freopen(). * Saves: CPM small 1100, big 1500 *************/ #define NOASCII int noascii(); /* CPM small 550, big 800 *************/ #define NOFILESZ int nofilesz(); /************* * NOBINARY: eliminates BINARY low lfdopen.o`************************* * DISK I/O Options *************************************************************************/ /** programmers. **************/ #define NOSTARTUP int nostartup(); CPM small 3200, big 3500 **************/ #define NOLONG int nolong(); /************* * NOTTYIN: eliminates the functions************ * MINIMAL: tags to make "hello.c" as small as possible. *************/ #define MINIMAL NOFLOAT NOTTYIN NOFIL/****************************************************************************/ /* */ /* CTYPE */ /* ower(ch) ? (ch)+('A'-'a') : (ch)) #define toascii(ch) ((ch) & 0177) r(ch) (__atab[ch] & __l) #define isdigit(ch) (__atab[ch] & __d) #define isalnum(ch) (__atab[ch] & (__u | __l | __d)) #define ure. * * This file contains O.S. specific definitions for the * DRI CLEAR/C Run Time Library. **********************************************/ /* * Bit patterns for character class DEFINEs */ #define __c 01 #define * 7-Mar-84 sw Fix for 68K * 28-Feb-84 whf Add C_STAT for ttyinraw() * 5-Jan-84 whf Moved MAXCCBS to channel.c ----- */ /* */ /* CTYPE.H - macros to classify ASCII-coded integers by table lookup. */ /* ower(ch) ? (ch)+('A'-'a') : (ch)) #define toascii(ch) ((ch) & 0177) isspace(ch) (__atab[ch] & __s) #define ispunct(ch) (__atab[ch] & __p) #define isprint(ch) (__atab[ch] & (__u | __l | __d | __p * This file is intended only for inclusion with those functions * dealing directly with the O.S. interface, as w __p 02 #define __d 04 #define __u 010 #define __l 020 #define __s 040 #define __cs 041 #define __ps 042 #ifndef CTYPE * 29-Dec-83 whf Added F_TRUNC for tclose() * 12-Dec-83 whf Change from "CPM.H" to "OSIF.H" * 9-Dec-83 */ /* */ /* Note: Integer args are undefined for all int values > 127, */ /* except for macro 'isascii()) #define iscntrl(ch) (__atab[ch] & __c) #define tolower(ch) (isupper(ch) ? (ch)+('a'-'A') : (ch)) #define toupper(ch) (isell as any function * which has hardware dependent code (byte storage order, for * instance). * extern char ___atab(); extern char __atab[]; #endif /* * Character Class Testing and Conversion DEFINEs: */ #define i whf Handle PCDOS differences * 3-Nov-83 whf Add multi-sector i/o * 19-Oct-83 whf Add QUEUE handling info )'. */ /* Assumes: */ /* User will link with standard library functions. */ /* Compiler can handle de/*************************************************************************** * * O S I F . H * lower(ch) ? (ch)+('A'-'a') : (ch)) #define toascii(ch) ((ch) & 0177)  ****************************************************************************/ /* * "machine.h": to determine what sascii(ch) ((ch) < 0200) #define isalpha(ch) (__atab[ch] & (__u | __l)) #define isupper(ch) (__atab[ch] & __u) #define islowe * 6-Oct-83 whf Redefine reserved area in fcb for parsefn() return * 25-June-83 sw Add user number to file "fd" structclarator initializers and */ /* '#defines' with parameters. */ /* */ /****************************** ----------- * Copyright 1982,1983 by Digital Research Inc. All rights reserved. * * Edits: kind of machine you want to run on. */ #ifdef pcdos #define PCDOS 1 /* IBM PC DOS */ #define CPM 0 /* CP/M version 2.2 */resvd[7]; /* More "system reserved" */ LONG record; /* Note -- we overlap [32-36]*/ /* current record field to ***/ #if CPM /****************************/ struct fcbtab /****************************/ { /* */ BYTE d*******/ /* */ #define SECSIZ 128 /* size of CP/M sector */ /* to obtain nsecs on err */ /*CCPM 0 /* Concurrent (multi-tasking) */ #define CPM3 0 /* CP/M version 3.x (Concurrent & Plus) */ #define CPM4 0 /* CP/M versi3]; /* File type [9-11] */ WORD fcb_curblk; /* Curr 128 byte blk [12-13]*/ WORD fcb_lrecsiz; /* Logical record siz #else /* assume CP/M: */ #define CPM 1 /* CP/M version 2.2 */ #define PCDOS 0 /* IBM PC DOS */ #endif #define I8086 0*/ /* make this useful. */ }; /****************************/ #endif /****************************/ /**rive; /* Disk drive field [0] */ BYTE fname[8]; /* File name [1-8] */ BYTE ftype[3]; /* File type [9-11] ***************************/ /*************************************************************************** * on 4.x (Portable Concurrent) */ #define UNIX 0 /* UNIX */ #define VMS 0 /* DEC VMS */ /*** Compiler ***/ #define ALCYONe[14-15]*/ LONG fcb_filsiz; /* Num bytes in file [16-19]*/ WORD fcb_date; /* Last updated [20-21] */ BYTE fcb_resv /* Intel 8086/8088 */ #define DRC 0 /* Digital Research C Compiler */ /**** Unused DEFINEs: ****/ /* #ifdef UNdefin************************************************************************** * PC-DOS FCB definition **************************/ BYTE extent; /* Current extent number[12]*/ BYTE s1,s2; /* "system reserved" [13-14]*/ BYTE reccnt; /* Record * Channel Control Block (CCB) * * One CCB is allocated (statically) for each of the 16 possible open 1 /* Alcyon C Compiler */ /* #endif */ /************************/ /************************************************d[10]; /* System reserved [22-31] */ BYTE fcb_currec; /* Rel Rec# within curblk[32]*/ LONG record; /* Rel Rec# from ed */ /*** Processor ***/ #define MC68000 1 /* Motorola 68000 */ #define VAX 0 /* DEC VAX */ #define PDP11 0 /* DEC PD***************************************************/ #if PCDOS /****************************/ struct fcbtab { /********counter [15] */ BYTE fpasswd[8]; /* Parsefn passwd area[16-23]*/ BYTE fuser; /* Parsefn user# area [24] */ BYTE * files under C (including STDIN, STDOUT, STDERR). Permanent data * regarding the channel is kept here. * **************************** * CP/M FCB definition *************************************************************************bgn file */ /* [33-36] depends on lrecsiz*/ }; /****************************/ #endif /*********************P-11 */ #define Z8000 0 /* Zilog Z8000 */ /*** Operating System ***/ #define CPM68K 1 /* CP/M 68000 ver 2.2 */ #define ********************/ BYTE drive; /* Disk drive field [0] */ BYTE fname[8]; /* File name [1-8] */ BYTE ftype[ * ****************************************************************************/ struct ccb /*getccb(i) (&_fds[i]) /* Get CCB addr */ /**************************************************************************CII file attached */ #define ATEOF 0x20 /* End of file encountered */ #define DIRTY 0x40 /* Buffer needs writing #define C_STAT 11 /* Get console status */ #define S_BDOSVER 12 /* Get System BDOS Ver Num */ #define OPEN 15 /* /* */ /* Declare storage */ #define FD struct ccb /* FD Type definition */ #define NULLFD ((FD *)0) /* NULLPTR f */ #define __OSIF(fn,arg) __BDOS((fn),(arg)) /* DRC does it this way */ #endif /* */ #if CPM /****************************************/ { /* */ WORD flags; /*sw Flags byte */ BYTE user; /*sw User # * * * O S I F F u n c t i o n D e f i n i t i o n s * -------------------------------------------- */ #define ISSPTTY 0x80 /* Special tty info */ #define ISAUX 0x100 /*sw Auxiliary device */ #define ISQUE 0x02 OPEN a disk file */ #define CLOSE 16 /* Close a disk file */ #define SEARCHF 17 /* Search for first */ #deor FD */ /************************************/ /* Flags word bit definitions */ /*******************************************/ #define EXIT 0 /* Exit to BDOS */ #define CONIN 1 /* direct echoing con input */ #defin */ BYTE chan; /* Channel number being used */ LONG offset; /* File offset word (bytes) */ LONG sector; /* Se----- * * Following are OSIF function definitions used by the C runtime * library. * 00 /*whf Queue device */ /************************************/ #define READ 0 /* Read mode parameter for open fine SEARCHN 18 /* Search for next */ #define DELETE 19 /* Delete a disk file */ #define CREATE 22 /* Create ****************/ #define OPENED 0x01 /* Channel is OPEN */ #define ISTTY 0x02 /* Channel open to TTT */ #definee CONOUT 2 /* Direct console output */ #define LSTOUT 5 /* Direct list device output*/ #define CONIO 6 /* Direcctor currently in buffer */ LONG hiwater; /* High water mark */ struct fcbtab fcb; /* File FCB (may have TTY info)*/ ****************************************************************************/ /************************* */ #define WRITE 1 /* Write mode */ /* CCB manipulation macros *************************************/ #define _a disk file */ #define F_RENAME 23 /* Rename a disk file */ #define SETDMA 26 /* Set DMA address */ #define ISLPT 0x04 /* Channel open to LPT */ #define ISREAD 0x08 /* Channel open readonly */ #define ISASCII 0x10 /* ASt console I/O */ #define C_WRITESTR 9 /* Console string output */ #define CONBUF 10 /* Read console buffer */ BYTE buffer[SECSIZ]; /* Read/write buffer */ }; /************************************/ extern struct ccb _fds[];***/ #if CPM68K /* */ #define __OSIF(fn,arg) __BDOS((fn),(LONG)(arg)) /* CPM68K does it this way */ #else /* USER 32 /*sw Get / set user number */ #define B_READ 33 /* Read Random record */ #define B_WRITE 34 /* Write Ran*************************/ /* Other CP/M definitions */ /************************************************************st */ #define SEARCHN 18 /* Search for next */ #define DELETE 19 /* Delete a disk file */ #define CREATE 22/* ordered words in 32 bit*/ WORD lwlo; /* LONG qtys. */ }; /* */ #else /***********************S */ #define CONIN 1 /* direct echoing con input */ #define CONOUT 2 /* Direct console output */ #define LSTOne HILO 1 /* used when bytes stored */ #else /* */ #define HILO 0 /* used when bytes stored */ #endif dom record */ #define FILSIZ 35 /* Compute File Size */ #define F_MULTISEC 44 /* Set Multi-Sector Count */ #de****************/ #define TERM "CON:" /* Console file name */ #define LIST "LST:" /* List device file name */ #d /* Create a disk file */ #define F_RENAME 23 /* Rename a disk file */ #define SETDMA 26 /* Set DMA address *****/ struct long_struct{ /* Lo/Hi storage use on */ BYTE lblolo; /* PDP-11, VAX, 8086,... */ BYTE lblohi; UT 5 /* Direct list device output*/ #define CONIO 6 /* Direct console I/O */ #define C_WRITESTR 9 /* Console str /* */ /* */ #if HILO /* Hi/Lo storage used in */ struct long_struct{ /* 68K */ BYTEfine P_CHAIN 47 /* Program Chain */ #define SETVEC 61 /* Set exception vector */ #define N_NETSTAT 68 /* Get Nefine EOFCHAR 0x1a /* End of file character-^Z */ /****************************/ /******************************** */ #define B_READ 33 /* Read Random record */ #define B_WRITE 34 /* Write Random record */ #define FILSIZ 35 /* */ BYTE lbhilo; /* */ BYTE lbhihi; /* */ }; /* */ struct word_struct{ /* *ing output */ #define CONBUF 10 /* Read console buffer */ #define C_STAT 11 /* Get console status */ #define lbhihi; /* Use this for accessing */ BYTE lbhilo; /* ordered bytes in 32 bit*/ BYTE lblohi; /* LONG qtys. etwork Status */ #define F_TRUNC 99 /* Truncate file function */ #define S_OSVER 163 /* Get OS Version Number *********************************************/ /* Hardware dependencies */ /****************************************** /* Compute File Size */ #endif /****************************/ /***************************************************/ WORD lwlo; /* */ WORD lwhi; /* */ }; /* */ #endif /****************************/ /*** OPEN 15 /* OPEN a disk file */ #define CLOSE 16 /* Close a disk file */ #define SEARCHF 17 /* Search for fir */ BYTE lblolo; /* */ }; /* */ struct word_struct{ /* Use this for accessing */ WORD lwhi; / #endif /****************************/ #if PCDOS /****************************/ #define EXIT 0 /* Exit to BDO**********************************/ /****************************/ #if MC68000 | Z8000 /* 68K or Z8000 */ #defi************************ end of osif.h **********************************/ ffer address * bytes Is the number of bytes to write * * ret Is the number of bytes actually n * ------------------------------ * Copyright 1984, Digital Research Inc. All rights reserved. * * Need to advance? */ fp->hiwater = fp->offset; /* then do so */ return ii; /* Number written */ } close.o`nNVH>N*@ fp`H0|g>N>N; /* # bytes to write */ { /****************************/ #if PCDOS /*=======================================*********************** end of osif.h **********************************/  written * ****************************************************************************/ #include "por * Function "wrtbin" is called from "write" to take advantage of a * potential multi-sector transfer for binary f/****************************/ #endif /*=============================================================*/ #if CPM /B@`&-g:-f2 - l>B?.N\>/<?.N\-gB>"/</ 4/-/ N|g3======================*/ UWORD ii; /* Byte counter */ UWORD _pc_writeblk(); /* OS function Write Rnd Blk*/ *********************** end of osif.h **********************************/ tab.h" #include "osif.h" #include "osiferr.h" #include "errno.h" #define NDEBUG #include "assert.h" #define OFFSECT iles. * * Completely re-written 7 Feb 1984 whf. * * Calling sequence: * ret = _wrtbin(fp*=============================================================*/ REG UWORD nbs; /* counter */ UWORD xsector; /* Cur3p`.?< NT>-H@g-HH.?< NT.?<NT<-H@g0G.?< NT|f3/* */ ii = _pc_writeblk(&(fp->fcb),fp->offset,buff,(WORD)bytes,1); /* */ if( ii==0 ) /* Problems? */ RE__iob(fp->offset & ~(SECSIZ-1)) #define HIWSECT (fp->hiwater-1 & ~(SECSIZ-1)) UWORD _wrtbin(fp,buff,bytes) /************,buffer,bytes); * * Where: * fp Points to the affected ccb. * buffer Is the burent sector */ UWORD nsector; /* Multi-sector count */ UWORD written; /* # bytes to written */ UWORD BufP/*************************************************************************** * * W r t b i n F u n c t i oTERR(FAILURE,EIO); /* Tell them so */ fp->offset += ii; /* Incr pos in file */ if( fp->offset > fp->hiwater ) /****************/ /* */ REG FD *fp; /* -> CCB */ BYTE *buff; /* -> User's buffer */ UWORD bytesos; /* Position in buffer */ /****************************/ /****************************/ written = 0; */ fp->offset += nbs; /* " " " */ buff += nbs; /* Ground we've covered */ bytes -= ufPos = fp->offset & (SECSIZ-1); /* Where are we in buffer? */ nbs = SECSIZ - BufPos; /* Room left in buffer */ if( nwritten += nbs; /* Indicate we've written */ fp->offset += nbs; /* " " " */ buff += nbs; /out the buffer */ else if(_blkio(fp,(LONG)xsector,fp->buffer,1L,B_READ) != 1) RETERR(FAILURE,EIO); /* Can't preread *********/ } /****************************/ /* */ /****************************/ if( bytes >= SECSIZ /* Num written so far */ /* Get buffer cleaned and */ /* current: */ xsector = fp->offset >> 7; nbs; /* num bytes left to write */ if( BufPos + nbs != SECSIZ ) { /* Buffer full? */ fp->flags |= DIRTY; /* Nbs > bytes ) /* More room than we need? */ nbs = bytes; /* Adjust to bytes to xfer*/ else if( nbs == SECSIZ ) * Ground we've covered */ bytes -= nbs; /* num bytes left to write */ } /****************************/ buffer */ fp->flags &= ~DIRTY; /* Clear dirty bit */ fp->sector = xsector; /* Buffer labelled */ } ) { /* Can we do multisector io?*/ nsector = bytes >> 7; /* divide by 128 for sectors*/ if(_blkio(fp,(LONG)xsect/* Calculate present sector */ if(xsector != fp->sector) { /* Do sectors match? */ if(fp->flags & DIRTY) /* No, io, mark it */ fp->sector = xsector; /* Label buffer */ } else { /* */ if(_blkio(fp,(LONG)xsector/* Sector aligned multi-sec?*/ nbs = 0; /* Don't buffer now. */ if( nbs > 0 ) { /* Any room/data to buffer? /****************************/ if( bytes > 0 ) { /* Any room/data to buffer? */ ASSERT( fp->flags & DIRTY == 0 ); /* /****************************/ /****************************/ /* Xfer data to buffer until*/ /* 1) end oor,buff,(LONG)nsector,B_WRITE) != nsector) /* Multi-sector xfer */ RETERR(FAILURE,EIO); /* Just quit on error s buffer dirty? */ if(_blkio(fp,fp->sector,fp->buffer,1L,B_WRITE) != 1) /* */ RETERR(FAILURE,EIO); /* Couldn't,fp->buffer,1L,B_WRITE) != 1) RETERR(FAILURE,EIO); /* Couldn't */ fp->flags &= ~DIRTY; /* turn off dirty bit */ blkmove(fp->buffer+BufPos,buff,nbs);/* Move into write buffer */ written += nbs; /* Indicate we've written Buffer should be clean */ if( OFFSECT > HIWSECT) /* Within the hiwater area? */ blkfill(fp->buffer,0,SECSIZ); /* f data, */ /* 2) end of buffer, or */ /* 3) sector aligned multi- */ /* sector write. */ B */ xsector += nsector; /* Update current sector */ nbs = nsector << 7; /* number bytes xferred */ write buffer */ if( OFFSECT > HIWSECT) /* Within the hiwater area? */ blkfill(fp->buffer,0,SECSIZ); /* No: Zero */ fp->sector = -1; /* buffer clean */ xsector++; /* Bump sector counter */ } /*******************No: Zero out the buffer */ else if(_blkio(fp,(LONG)xsector,fp->buffer,1L,B_READ) != 1) RETERR(FAILURE,EIO); /* Can'ra $1.s =====*/ NT n(gHH.?<NTp`l ` <*E.?< NT.HH̼l0| .?<Nater) /* See if above hiwater mark*/ fp->hiwater = fp->offset; /* Fix if necessary */ return written; /* Return req$ t preread buffer */ ASSERT( bytes < SECSIZ ); /* Should be cut to size */ blkmove(fp->buffer,buff,bytes); /*a $1.s flags |= DIRTY; /* Mark buffer */ fp->sector = xsector; /* and label $BL34NL35L36L37L38L40L39t___BDOS__ttyin~~_ttyin~bytes~p ~ttybuf~xbytes~fp ~nbs======*/ lo68 -r -u_nofloat -o $1.68k 0:s.o $1.o $2.o $3.o $4.o $5.o $6.o $7.o $8.o $9.o 0:clib  */ written += bytes; /* Indicate we've written */ fp->offset += bytes; /* " " " */ buf $ cp68 -i 0: $1.c $1.i c068 $1.i $1.1 $1.2 $1.3 -f era $1.i c168 $1.1 $1.2 $1.s era $1.1 era $1.2 as68 -l -u -s 0: $1.s e~tyb~buff L2 L3LL1L4 L5L6L10000=====*/ o68 -r -u_nofloat -o $1.68k 0:s.o $1.o $2.o $3.o $4.o $5.o $6.o $7.o $8.o $9.o 0:clib f += bytes; /* Ground we've covered */ } /****************************/ /* */ if(fp->offset > fp->hiw$L10002L7L8L9L10003L10005L10\L12`L11; } _pftoa() { _optoff(__nofloat_msg); } _pgtoa() { _optoff(__nofloat_msg); } _atof() { _optoff(__nofloat_mst); } ,g>// aP`|,f./ / atP`d-EBJoX ,-@B ,gN,gF>"/</ 4/,/ N_nodisk_io_msg); } _wrtbin() { _optoff(__nodisk_io_msg); }  int _filesz() { return 32767; } /* NODISK: pulls out as much disk i/o as possible. */ nodisk() { ; } /* stubroutine 'tag' */ char * __nodisk_i|L13tL14,; } _pftoa() { _optoff(__nofloat_msg); } _pgtoa() { _optoff(__nofloat_msg); } _atof() { _optoff(__nofloat_mst); } /* NOFLOAT: provides 'stubroutines' to satisfy floating point library */ /* references from 'printf' et al. */ NL15pL14L16L17L18L19L20L21L22_allocc___open_freec_unlink~~unlink~ch~filenam~retL2o_msg = "disk i/o rtns"; _rdasc() { _optoff(__nodisk_io_msg); } _rdbin() { _optoff(__nodisk_io_msg); } _wrtasc() { _optoff(/* NOFILESZ: eliminates routine to calculate filesize (used in lseek()) */ nofilesz() { ; } /* stubroutine 'tag' */ 4/./ N|g33p`fR -@Job -m .Юo U+|>"/./ /./ N nofloat() { ; } /* stubroutine 'tag' */ char * __nofloat_msg = "floating point"; _petoa() { _optoff(__nofloat_msg~~_wrtbi ~nsectorL24L25 L26L27L23L28L29L1@,$4<ilwrite.o`__nodisk_io_msg); } _wrtbin() { _optoff(__nodisk_io_msg); }  int _filesz() { return 32767; } H".g33p` . . .ѭ - o+m Jf .`-gB>"/</ 4/-/ N); } _pftoa() { _optoff(__nofloat_msg); } _pgtoa() { _optoff(__nofloat_msg); } _atof() { _optoff(__nofloat_mst); } L30__clear L32L314L33\L34TL35L36L37NVH*n B:.>N(@ fp`JnB@`,g3 3p`,g>// aP`_nodisk_io_msg); } _wrtbin() { _optoff(__nodisk_io_msg); }  int _filesz() { return 32767; } |g33p`tU@ -+@ -"- S¼n&>!/</ 4/-/ N`>/ 4/* NOTTYIN: eliminates console input functions from read(). */ nottyin() { ; } /* stubroutine 'tag' */ static chly 1 channel. *****************************************************************************/ __chinit(i) { /*********** Include std definitions */ #include /* Include CP/M definitions */ #define MAXCCBS 9 FD _fds[MAXCCBS]; /~fp ~bdosfun~fcbp _get_tok6L2_stuff_dL3rL1L4--------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * Routine "_chinit" is called from th>.Jg.JGg*HHм @g H|`HRSG`JL0N^NuNVH *n(n >.Jg"H>/9NXJf JGgSG`B Nqar * __nottyin_msg = "tty input"; _ttyin() { _optoff(__nottyin_msg); } ******************/ REG FD *ch; /* -> CCB */ REG BYTE *p; /* Byte pointer temporary */ ch = _getccb(i); * Allocate CCB storage */ _chinit() /****************************/ { /* */ REG WORD i; /* Index __strcpyL5L6 L7L8pL9BL10bL11L12e run-time initialization to clear * out all the CCB storage. * Calling sequence: * _chinit(); * * Routine "__chinit(fd)" JL0N^NuNVH*n(n &nBGHHм @g H@|G`Jg*HHм @g H|`H|RJf -only 9 files instead of 16 * chkc.c - (to be consistent with chinit() * doprt.c - stripped down, does not support longs/* convert fd to CCB */ ch -> chan = i; /* Load channel byte */ ch -> flags = 0; /* clear flag word */ */ for(i=0;i.,=:+-&/\|()[]*__fds @_errno___cpmrv__errcpm___atab_fill__ & floats * _ttyin.c - dummy routine * _filesz - dummy rtn * * (last mod 12/21/83 WHF ) */ /********************** convert fd to CCB */ ch -> chan = i; /* Load channel byte */ ch -> flags = 0; /* clear flag word */ ******/ /***************************************************************************** * The __chinit routine initializes onWLIB channel5.o xmainnw.o MALLOCDB.O NOASCII.O NOBINARY.O NODISK.O NOFILESZ.O NOFLOAT.O NOLONG.O NOTTYIN.O ;;;;;;; ;;;;;;; = file descriptor # * *****************************************************************************/ #include /_BDOS__index___open~~__open~xuser~i~p~filnam ~tokbuf~ch******************************************************** * * C C B I N I T I A L I Z A T I O N * --------------* convert fd to CCB */ ch -> chan = i; /* Load channel byte */ ch -> flags = 0; /* clear flag word */ ;;;;;;; ; SUBMIT R2 ;;;;;;; ;STEP 2: ARCHIVE ORDINARY C OBJECTS $2AR68 RF $1 NEWLIB ACCESS.O ATOI.O ATOL.O CALLOC.O EXEREN CLIB=NEWLIB PIP $2[G0]=CLIB PIP $1[G0]=S.O PIP $2[G0]=S.O REN S.X=S.O ERA *.O REN S.O=S.X USER 7!MAKE $1 $2 AT.O STRNCMP.O STRNCPY.O STRCPY.O $2AR68 RF $1 NEWLIB STRLEN.O CTYPE.O XSTRCMP.O YESFLOAT.O YESSTART.O XATOF.O ;;;;;;; ;;;;; /* NOSTART.C - provides a routine to prevent the linkage of the */ /* 'normal' RTL startup routine, '_main()'. */ L.O XMAIN.O CREAT.O EXIT.O CLEANUP.O FCLOSE.O CLOSE.O $2AR68 RF $1 NEWLIB FDECLS.O FFLUSH.O OPEN.O LSEEK.O FILESZ.O SPRINTF.O D<4,C.O FDOPEN.O $2AR68 RF $1 NEWLIB FGETS.O FOPEN.O FPUTS.O FREAD.O FREOPEN.O FSEEK.O FTELL.O $2AR68 RF $1 NEWLIB FWRITE.O GETLREN CLIB=NEWLIB PIP $2[G0]=CLIB PIP $1[G0]=S.O PIP $2[G0]=S.O REN S.X=S.O ERA *.O REN S.O=S.X USER 7!MAKE $1 $2 ;; ;;;;;;; ; SUBMIT R3 ;;;;;;; ; STEP 3: ARCHIVE ASSEMBLER STUFF $2AR68 RF $1 NEWLIB ABORT.O ALDIV.O ALMUL.O ALREM.O /* When this module is linked in, there will be no redirected */ /* i/o, the command line will not be parsed into argc/argvOPRT.O $2AR68 RF $1 NEWLIB DOPRTFP.O FPUTN.O FPUTC.O FLSBUF.O ISATTY.O MALLOC.O MALLOCND.O $2AR68 RF $1 NEWLIB PRTINT.O PRTLD.$.O GETPASS.O GETS.O GETW.O MAIN.O $2AR68 RF $1 NEWLIB MKTEMP.O GETPID.O OPTOFF.O PERROR.O PRINTF.O PUTL.O PUTS.O $2AR68 RF $1 ~~getpasL2~prompt~ibuf__noecho>L1:~~_noech>~bf~chLDIV.O LMUL.O LREM.O $2AR68 RF $1 NEWLIB SALLOC.O SETJMP.O ULDIV.O SIGNAL.O XSIGNAL.O BLIVOT.O ;;;;;;; ;;;;;;; ERA CLIB , standard */ /* i/o channels will not be opened, and files will not be closed */ /* automatically on termination. O PRTSHORT.O SBRK.O WRITE.O $2AR68 RF $1 NEWLIB CHANNELS.O WRITEASC.O WRITEBIN.O BLKIO.O OSATTR.O WRTCHR.O LSTOUT.O $2AR68 RF ttyname.o `$NV>NJ@g <``BNqN^Nu__fds @_errNEWLIB PUTW.O QSORT.O RAND.O READL.O RENAME.O STRRCHR.O SCANF.O $2AR68 RF $1 NEWLIB SETBUF.O SGTTY.O SSCANF.O DOSCAN.O FGETC.O~ln ~curL5FL7L8bL9bL10pL6L11 REN CLIB=NEWLIB PIP $2[G0]=CLIB PIP $1[G0]=S.O PIP $2[G0]=S.O REN S.X=S.O ERA *.O REN S.O=S.X USER 7!MAKE $1 $2  */ /* NOTE: 'argc/argv' is replaced by 'cmd/len', where cmd -> command tail */ /* and len is the length of this string$1 NEWLIB TTYOUT.O XOPEN.O CHKUSER.O ERRNO.O STRCHR.O PARSEFN.O BLKFILL.O blkmove.o $2AR68 RF $1 NEWLIB STRCAT.O STRCMP.O STRNCno___cpmrv__errcpm___tname_isatty_ttyname~~ttynam~fdL2L1 FILBUF.O READ.O $2AR68 RF $1 NEWLIB READASC.O READBIN.O SWAB.O TTYIN.O TTYINRAW.O UNGETC.O UNLINK.O $2AR68 RF $1 NEWLIB WRITErL12L13L3L14L15L16L17L18L4. */ nostart() { ; } /* stubroutine tag */ _main(cmd,len) /* stubroutine for starup '_main()' */ char malloc() * To be included in OPTION?.lib * * 10/83 whf *****************************************************************.?< NT 2HЁ`@0Hހ0H0Hր0@H`v-Hng0n.?< NT NqJL0N^Nu__fds @_errno'free()' */ /* */ /*** end of "malloc.h" ******/ /*****************************************************3B@` NqJL N^Nu__fds @_errno___cpmrv__errcpm__chkc~~_chkc~chB_HDR *_aflistptr; /* ptr into ring of freeblks*/ /* */ #define AOFFS 1L /* alignment offset: 0=br *cmd; /* ptr to CP/M command tail */ int len; /* length of CP/M command tail */ { _exit(main(cmd,len)); /* c*******/ #include /************************* #include "malloc.h" *****************************/ #define FB_HD___cpmrv__errcpm___BDOS__blkio~~_blkio~nsecs~count~xuser~buffer ~s***********************/ _errmalloc(etype) int etype; /* type of error */ { switch(etype) { case ERR_FI~xcb L2(L1XL3T  yte, 1=word, 3=quad */ #define AMASK(c) ((char *)((long)(c) & ~AOFFS)) /* mask alignment bits */ #define AFUDGE 4 /* all the main program */ } R struct hdr /* free block header type */ /* */ FB_HDR { /* mem_block header */ struct hdr *ptr; /eccnt~sector~ccb ~bdosfunL2VL4VL3L5L6L7NDBLOCK: printf("malloc() error: corrupt arena\n"); break; case ERR_GETMEM: printf("malloc() error: out of memory\nN^blkio.o`PNVH? *n.. (n,.:.B.?< Nleeway for passing block as is */ #define ACHUNKS 64 /* chunks to alloc from O.S.*/ /* */ #define ERR_FINDBLOll the main program */ } * ptr next blk (when freed)*/ UWORD size; /* block size (always) */ UWORD chksize; /* 1's complement of size */ /************************************************************************ * _errmalloc / MALLOCDB.C : prints error messages fo"); break; case ERR_FREE: printf("free() error: pointer was not from malloc()\n"); break; } exit(1); } /*T=@-Hng-HH.?< NTJo.?<NT+G0x.?NTJ@g>|o89Bp d`BD-Hng0nCK 1 /* error in 'findblock()' */ #define ERR_GETMEM 2 /* error in 'getmemory()' */ #define ERR_FREE 3 /* error in ll the main program */ }  }; /****************************/ /* */ EXTERN FB_HDR _afreebase; /* initial (empty) block */ EXTERN F***************************************************************************/ /* malloc_debug(): checks the free list to see if  } qsort.o`  /* */ } /* */ cp = cp->ptr; /* move on down the list */ if( cp == _aflistptr ) /* end /* NOASCII: pulls out as much ASCII disk i/o as possible. */ noascii() { ; } /* stubroutine 'tag' */ char * __everything is ok. */ /************************************************* */ WORD malloc_debug() /* */ {  } /* NOBINARY: pulls out as much BINARY disk i/o as possible. */ nobinary() { ; } /* stubroutine 'tag' */ char *H`R rNVH>.ZGB0>RGJf <##By(y*Tmb60X@me(`&M0of list? */ return SUCCESS; /* */ } /* */ } /****************************/ noascii_io_msg = "ascii disk i/o rtns"; _rdasc() { _optoff(__noascii_io_msg); } _wrtasc() { _optoff(__noascii_io_msg); } /****************************/ REG FB_HDR *cp; /* ptr to current block */ /* */ cp = _aflistptr; /* sL3L11L12>L1B~~_swapL~a ~b ~wid~tmp __nobinary_io_msg = "binary disk i/o rtns"; _rdbin() { _optoff(__nobinary_io_msg); } _wrtbin() { _optoff(__nobinary_io_msg)0-G7@&(;G# \`f>a*@ fB`(M*T`JL8N^NuNVH >.|?GG0>N*@fB` Rf list? */ return SUCCESS; /* */ } /* */ } /****************************/  tart search here */ while(1) /* do forever */ { /* */ if(~(cp->size^cp->chksize)) /* does cp ptL14xL16dL15xL17rL13x; } *@(M9G.\a 9NqJL0N^NuNVH *n](yceeebf#`J(T` 2-Ёf T0(m T*`* 2,f list? */ return SUCCESS; /* */ } /* */ } /****************************/   to valid blk? */ { /* no... */ _errmalloc(ERR_FINDBLOCK); /* handle this error */ return FAILURE; /* NOLONG: provides 'stubroutines' to satisfy long int conversion library references from 'printf' et al. */ nolong() { ;* 8-Dec-83 whf handle PC-DOS changes. * * Calling Sequence: * ret = _blkio(ccbp,sector,buf o n * ----------------------------- * Copyright 1982,1983 by Digital Research Inc. All rights reserved. /*=============================================================*/ REG WORD seccnt; /* number sectors xferred */ WORDL15L14_free~~free~fmpL18L10000L176L10001e "portab.h" #include "osif.h" #include "osiferr.h" #include "osattr.h" #define MIN(x,y) ( ((x) < (y)) ? (x) : (y) ) L } /* stubroutine 'tag' */ char * __nolong_msg = "long int conversion"; __prtld(){ _optoff(__nolong_msg); }fer,count,bdosfunc); * * Where: * ret = sectors actually read/written * ccbp -> t * * The _blkio function is used to read / write a set of contiguous * sectors in an open file. _pc_readblk(), _pc_writeblk(); /* functions to read/write */ if( bdosfunc == B_READ ) return _pc_readblk(&(ccbp->fc&L202L16|L192L21VL22XL23tL24v_realloc~~realloONG _blkio(ccbp,sector,buffer,count,bdosfunc) /****************************/ FD *ccbp; /* open file pointer } /* stubroutine 'tag' */ char * __nolong_msg = "long int conversion"; __prtld(){ _optoff(__nolong_msg); }he open file channel control block * sector = The desired starting sector number * buffer = The memory addr * Note: if CPM, it will use CP/M function 44 (Set Multi-Sector Count) * if os_multisectorio is TRUE (BDOS versions 3.0 andb),sector,buffer,(WORD)count,SECSIZ); else return _pc_writeblk(&(ccbp->fcb),sector,buffer,(WORD)count,SECSIZ); } #endif ~fp~ss~np2~siz ~ptrL26L25NL27HL28 */ LONG sector; /* Sector number */ BYTE *buffer; /* User's buffer area */ LONG count; /* # } /* stubroutine 'tag' */ char * __nolong_msg = "long int conversion"; __prtld(){ _optoff(__nolong_msg); }ess to begin transfer * count = the number of sectors to read/write * bdosfunc= The BDOS function number (B_ above). * Note 2: if PC-DOS, it will use block read and write functions. * * Edits: /*==============================================================*/ #if CPM /*=======================================/*************************************************************************** * * _ b l k i o F u n c t iof sectors to do */ int bdosfunc; /* BDOS function to use */ { /****************************/ #if PCDOS_getmemoL12L7L5~~getmem~fbp ~mmp ~utg~numuREAD / B_WRITE) * ****************************************************************************/ #includ=======================*/ WORD nsecs; /* # secs to xfer each time */ LONG seccnt; /* # sectors processed */ WORDg multi-sec?*/ { /* yes! do error handling */ if( os_oldmultisec ) /* Older msecio? */ nsecs = __cdmultisec ) nsecs = MIN(16,count); /* Older version of msecio */ else nsecs = MIN(128,count);/* Later version of ms============*/ Set new DMA address */ #if HILO /*==========================================================*/ ccbp->fcb.record = sect/* Increment address */ } /****************************/ _uchkuser(ccbp->user,xuser); /* Reset user # if needed * xuser; /* old user number */ WORD retcode; /* return code from BDOS */ WORD Used_Multisec; /* flag for resettpmrv >> 12; /* adjust nsecs read like so*/ else nsecs = __cpmrv >> 8;/* later versions: use AH */ } /*** ecio */ ++Used_Multisec; /* Flag: need to reset */ __OSIF(F_MULTISEC,nsecs); /* make the call */ } ============*/ or; /* Set new record number */ #else /*----------------------------------------------------------*/ ccbp->fcb.record = / if( Used_Multisec ) /* Need to reset msecio? */ __OSIF(F_MULTISEC,1); /* then do so... */ return(seccnt)ing msecio*/ /****************************/ seccnt = 0; /* Zero count initally */ Used_Multisec = 0; /* Have */ else nsecs = 0; /* ow. assume 0 secs read */ seccnt += nsecs; /* Return nfg */ break; /* /******* */ /****************************/ retcode = __OSIF(bdosfunc,&(ccbp->fcb));/* do the read/write*/ lrem.o`bNV/. /.N 9N^Nu_ldivr_ldiv_lremsector << 8; /* Set new record number */ #endif /*==========================================================*/ /*; /* All is OK */ } /****************************/ #endif /*=====================================================n't used it yet */ xuser = _chkuser(ccbp->user); /* Check for changed user # */ nsecs = 1; /* default: xfer singly Return from bottom */ } /****************************/ /* */ sector += nsecs; /* Increment sector num /****************************/ if(retcode != 0) { /****************************/ if(nsecs>1) /* were we tryinlrem~~lrem~l2 ~al1 _luldiv.o$`z Multi Sector I/O xfer? */ if( (count > 1 && os_multisectorio ) || nsecs > 1 ) { /* yes! */ if( os_ol=============*/  */ /* */ while (count > 0) /* Until all sectors xferred*/ { /* */ __OSIF(SETDMA,buffer); /* ber */ count -= nsecs; /* Down count */ seccnt += nsecs; /* Bump sector count */ buffer += nsecs*SECSIZ;  NVH..,. Jf# <`Jc #B` 1st char output * The execl function is called from anywhere to pass control to * another program from the the executing o n * ------------------------------- * * Function "_lstout" is called to perform "write" opexstrcmp.o`xNVH *n(n JfJg&H>a,NqJLN^Nu_uldivr_uldiv~~uldiv~b~q~l1~l2~al1al count */ } /***************************/  */ { /***************************/ REG WORD count; /* = # bytes to xfer */ WORD xcount; /* save area for C program. * Note that the stream files are closed via '_cleanup()'. * * Calling Sequence: rations to the * list device. * * Calling Sequence: * ret = _lstout(buffer,count,fH>a"op`lp``B@NqJL0N^NuNVH. <am <zn< HNqJLN^Nu__strcmp~~_strcm~a~al2 L2&L1pL34L4>L5fL7@L6RL9TL8al count */ } /***************************/ count */ /* */ xcount = count = (0xFF & *buffer++); /* Copy for later */ /* */ while(count-- > * * execl(name,arg0,arg1,...,argn,NULLPTR); * * Where: * name, arg0unc); * * Where: * buffer -> the output buffer (byte 0 is count) * ret = count /*************************************************************************** * * E x e c F u n c t i o fL10`p#T`0#`$#`#(` # H yNLNw___signa@__illins__ 0) /* Until all written */ __OSIF(LSTOUT,*buffer++); /* Output next character */ return(xcount); /* return origi, arg1...argn are pointers to character strings * **********************************************************on return * ****************************************************************************/ #include "n * ------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * /*************************************************************************** * * _ l s t o u t F u n c t i trace__trap__buserr(__arith6epaprocess@******************/ #include "portab.h" #include "osif.h" #include "osiferr.h" #include "errno.h" #include "ctype.h" UWO*****************/ le differently ifso */ _pc_chain(cmdline); /* special home grown func */ #else /* O.S. handles it? */ cmdline[0] lsbuf( ch, stream ) * Where: * ch = the 1st char to be buffered * stream -> where its going (FILE *) * chr = ch if write; --i >= 0; ) /* uppercase command name */ cmdline[i+1] = toupper(cmdline[i+1]); /* */ #endif /*****************/************************************************************************ * * _ f l s b u f F u n c t i o n * ---------RD execl(name,arg0) /* CLEAR FUNCTION ***********/ UBYTE *name,*arg0; /* pointers arguments */ { /* */ *****************/ = strlen(cmdline+1); /* Compute length */ __OSIF(SETDMA,cmdline); /* DMA -> Command line */ __OSIF(P_CHAIN,0); /* ok, FAILURE (-1 WORD) o.w. * * Modifications: * 19-Oct-83 whf Handle IONBUF differently ********************************************/ args = &arg0; /* Copy args */ args++; /* arg0 is a dup of the */ /* command name */ ---------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * '_flsbuf' handles writes to the stREG UBYTE **args; /* used to index into args */ UBYTE cmdline[128]; /* CP/M command line area */ REG WORD i; /***startPserial@xcleard_brkbrkok___BDOSnoovfovf_fill chain to program */ #endif /* */ RETERR(FAILURE,ENOENT); /* error: file not found */ } /****************************************************/ #include "stdio.h" WORD _flsbuf(c,sp) /****************************/ REG while(*args != NULLPTR) /***************************/ { /* */ strcat(cmdline+1," "); /* Add a blanream when its buffer is full. * Included is the ability to handle 'non-buffered' (_IONBUF), as * well as line buffered (_IOLBU************************/ /* */ _cleanup(); /* Close all (stream) files*/ /* now build cmdline */ filldonefillit__indexxindexnotend___pname___tname___lname___xeof#******************/ BYTE c; /* char to be written */ REG FILE *sp; /* stream to write to */ { /****************************/ k */ strcat(cmdline+1,*args++); /* Add next arg */ } /***************************/ #if PCDOS /* handF) output. It is supposed to be * called by 'putc'. It will init the buffers, as needed. * * Calling sequence: * chr = _fstrcpy(cmdline+1,name); /* Copy name portion */ #if PCDOS == 0 /* Don't do for PCDOS */ for(i = strlen(cmdline+1) BYTE csave; /* a temp save area */ BYTE *malloc(); /* alloc memory */ REG WORD n, /* number chars written_ptr >= sp->_base+BUFSIZ ) /* buf full or '\n'*/ { /* */ n=write(sp->_fd,sp->_base, /* output the line */_flag & _IONBUF ) /* insure this pts ok */ sp->_ptr = sp->_base = &csave; /* give buff a temp place */ *sp->_ptr++ = /* everything ok, quit */ } /****************************/  else { /* o.w. we have a buffer! */ sp->_flag |= _IOABUF; /* mark it as alloc'd */ if( isatty(sp->_fd) ) end buf handlers**********/ if( ns != n ) /* error on write? */ { /* */ sp->_flag |= _IOERR; /* mark */ ns; /* num chars sposed to be w.*/ /* */ ns = n = 0; /* init them */ if( (sp->_flag & (ns=sp->_ptr-sp->_base)); /* */ sp->_ptr = sp->_base; /* reset the buffer */ } /* */ c; /* put this somewhere */ if( sp->_flag & _IONBUF ) /* if a no buff file */ { /* */ n=write(DpX.F/<F"NDpX.F"NDHмF"S#FN^NuNVByH^.a ymEf3sat`` yeEf 3sa\`J y_flag |= _IOLBUF; /* yessir, this is a linbuf */ else { /* o.w. **************** stream */ return(FAILURE); /* and die */ } /****************************/ return(((WORD) c) & 0xff ); _IOWRT) == 0 ) /* is this file writeable? */ return(FAILURE); /* no! */ if( sp->_base == NULLPTR && /* if no i sp->_cnt = 0; /* enforce coming right back*/ } /****************************/ else /* o.w. we really have a */sp->_fd,sp->_base,(ns=1)); /* write single char */ sp->_cnt = 0; /* enforce coming back again*/ } /**********/***************************************************************************** * * f p u t c F u n c t i o n * --------*****/ sp->_cnt = BUFSIZ-2; /* lv room for 1st & last ch*/ return(*sp->_ptr++ = c); /* store 1st & quit */ /* everything ok, quit */ } /****************************/ nit yet and */ (sp->_flag & _IONBUF) == 0 ) /* and not a no buff file */ { /* ifso...*******************/ { /* full buffer */ n=write(sp->_fd,sp->_base, /* output the whole buff */ (ns=sp->_ptr-sp->_base)); /* ******************/ else if( sp->_flag & _IOLBUF ) /* if a line buff file */ { /* */ if(c=='\n' || sp->------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "fputc" does the inserting of a char } /*tty chk********************/ } /*malloc*********************/ } /*NULL buff******************/ if( sp-> /* everything ok, quit */ } /****************************/  if( (sp->_ptr=sp->_base=malloc(BUFSIZ)) == NULLPTR ) /* alloc ok?*/ sp->_flag |= _IONBUF; /* set to a no buff file */ */ sp->_cnt = BUFSIZ-1; /* lv room for last char */ sp->_ptr = sp->_base; /* init ptr */ } /* into a stream buffer, * calling _flsbuf when the buffer fills up. * Returns the character put, or FAILURE (-1) if any errors. NVH yFH"yFR>?</<F"NN\<JFm0`.F"/<IN!X>aJLN^NuNV 9Eѹ^ 9Eѹan 9/<IN!PRyFN^NuNVH >ND&#R9RgRR 9Rм#R#RZ3,Z*|\(|]BG| l *B(* excluding the termination character (CR/LF). * **************************************************************************) & 0377);/* put it! */ else return(_flsbuf(ch,sp)); /* o.w. flush & put */ /****************************/ (note upper case) is defined in the compile line. * * Edits: * 28-Feb-84 whf "_salloc()" goes to NOWILD region * 02-Feb- * * Calling sequence: * ret=fputc(ch,s) * Where: * ch = the char to put * s -> the stream (FILE *) * ret= ch or FAILU/***************************************************************************** * * "__main()" Subroutine to "_main()" * ---BRG`JL0N^NuNVHa @HЮ#` y`*h f*yZ` y` P!yZ.a NqJL N^NuNVH*n(M&yZBG|lLg***/ #include "portab.h" /* Include std definitions */ #include "osif.h" /* Include CP/M Definitions */ #include "ctyp} 84 whf nowild -> NOWILD, removed write() * 01-Jan-84 whf add in handle for OPTION*.h * 08-Dec-83 whf handle PC-DOS diffs,RE * *****************************************************************************/ #include "stdio.h" WORD fputc(ch,sp)------------------------------- * Copyright 1983 by Digital Research Inc. All rights reserved. * * Routine "__main()" is ent*m`RG` NqJL8N^NuNV y` Z y`Jf y`!yZaN^NuNVZ 9ZְRe<>ND&f.INe.h" /* char type definitions */ #define STDIN 0 /* file descriptors */ #define STDOUT 1 /* */ #defi  add ">>" redirection * 11-Oct-83 whf converted to DRC from CPM68K * * Calling Sequence: * return = _main(command,length) /* CLEAR FUNCTION ***********/ REG BYTE ch; /* char to put */ REG FILE *sp; /* stream to put it to */ { ered from the "_main()" routine to start a * C program. The command string from CP/M is parsed into * a UNIX-like "argc/argv!>N'`RydZN^NuNVHBG*yZBF|l H@RF`0|>NqJL N^NuNVH *n(n BG|l8RG`JL0N^Nune STDERR 2 /* */ #define ISWHITE(ch) ((ch)==NULL || isspace(ch)) /* */ #ifndef NOWILD EXTERN BYTE *_sallo ; * * Where: * command Is the address of the command line from CP/M * length Is the number of characters in the line, /****************************/ if( --(sp->_cnt) >= 0 ) /* if there's room in buf */ return(((WORD)(*sp->_ptr++ = ch)" setup, including simple I/O redirection. * * This module can be compiled without wildcard parsing if the * symbol "NOWILD"c(); /* Stack allocation routine */ #endif EXTERN BYTE *sbrk(); /* Incr break location */ EXTERN BYTE *strchr(); /* } /****************************/ else /* */ { /****************************/ for(i = 0; !ISWHITE(s[i] ++s; /* */ if (!*s) /* End of line? */ break; /* Yes, don't continue */ if(*s == '"' || *s == '\ } /* */ break; /****************************/ /* */ default: /* Just a regulaYTE *p; /* Another "" */ REG BYTE c; /* Character temp */ FD *pfd; /* File Desc temp */ BYTE tmpbuf[3********************/ case '>': /* Redirecting output?? */ close(STDOUT); /* Close output */ i V7 "index" function */ EXTERN BYTE __pname[]; /* Default Program name */ MLOCAL WORD argc; /* Arg count */ ); ++i)/* How many characters? */ ; /* */ if (s[i]) /* If last is space, etc... */ s[i++] = '\0'; /*'') /* Quoted string */ { /* */ c = *s; /* c = quote character */ p = strchr(s+1,c); /* Finr arg */ /****************************/ #ifndef NOWILD /*******************************************************0]; /* Filename temp */ BYTE *strchr(); /* V7 index() func */ /****************************/ argv2 = argvf(s[1]=='>') { /* Appending? */ if(opena(s+2,WRITE)!=STDOUT /* Try to open old */ || -1 == lseek(STDO MLOCAL BYTE *argv; /* -> array of pointers */ MLOCAL BYTE *argv2; /* Companion ptr to argv */ __main(com, len) Make it a null for C */ switch(*s) /* Now do i/o scan */ { /****************************/ case '<': d next */ if (p == NULLPTR) /* Any? */ _err(s,": unmatched quote");/* No, bitch. */ i = (WORD)*/ /********************************************************/ if(strchr(s,'?') || /* Wild */ strc = sbrk(0); /* -> first free location */ argc = 0; /* No args yet */ addargv(__pname); /* */ for (s = UT,0L,2) ) /* At EOF */ _err("Cannot append ",s+1); /* Can't */ } else { /*** */ /****************************/ BYTE *com; /* Command address */ WORD len; /* Command length */ { /* /* Redirecting input?? */ close(STDIN); /* Yes, close TTY */ if (opena(s + 1,READ) != STDIN) /* Open Newp-s; /* Compute length */ s[i++] = '\0'; /* Nullify at end */ addargv(s+1); /* Add to arg list */ hr(s,'*')) /* Cards? */ { /****************************/ pfd = _getccb(STDERR+1); /* Use unused channelcom; *s; s += i) /* One arg at a time */ { /* */ while (*s && isspace(*s)) /* Skip leading spaces */ if (creata(s+1,0)!=STDOUT) /* Try to open new */ _err("Cannot create ", s + 1); /* Can't */ ***************************/ REG WORD i; /* Define a count var. */ REG BYTE *s; /* Temp byte pointer */ REG B */ _err("Cannot open ", s + 1) ;/* Can't ... */ break; /* Done with this one */ /******** */ __OSIF(SETDMA,pfd->buffer);/* Use buffer for DMA */ c=__open(STDERR+1,s,SEARCHF); /* Do the searchexit(-1); /* And fail hard */ } /****************************/ /* * Addargv function -- adds a pointer to the argc,argv,NULLPTR)); /* Invoke C program (No Env)*/ } /* */ MLOCAL _err(s1,s2) /* Error routine */ c /* */ *buf = NULL; /* Nullify at first */ i = FALSE; /*****************************/ f = p->buffer; / } else /* */ /********************************************************/ #endif /****************************************/ #ifndef NOWILD /* * Toasc routine -- combines the FCB name in the DMA and the user number * / dri */ if(c == 0xff) /* Failed ... */ _err(s,": No match"); /* Complain */ while(c != 0xff) /argv array, getting the * space from the heap. */ MLOCAL addargv(ptr) /****************************/ REG BYTE *ptr; har *s1; /* Message text */ char *s2; /* Filename */ { /****************************/ char buf[128]; /* Pnt to results of search */ #if CPM /*================================================================*/ f += c*32; ***************************************/ addargv(s); /* save in argv */ } /* */ } /* */ }ve field to produce an ascii file name for SEARCHes. * */ MLOCAL _toasc(p,c,buf) /*****************************/ REG FD* Do search next's */ { /****************************/ _toasc(pfd,c,tmpbuf); /* Convert file to ascii */ /* -> Argument string to add*/ { /* */ *((BYTE **)argv2) = ptr; /* Load pointer */ argv2 += sizeof(char * /* place to build message */ /* */ strcpy(buf,s1); /* Output error message */ strcat(buf,s2); /* /* c == directory search code*/ if( p->user ) /* User # not default? */ { /* Yes */ i = (p->user) -1; /****************************/ addargv(NULLPTR); /* Insure terminator */ argc--; /* Back off by 1 */ if *p; /* -> Data area */ REG BYTE c; /* 0 .. 3 search code */ REG BYTE *buf; /* Output buffer area */ p = _salloc(strlen(tmpbuf)+1);/* Allocate area */ strcpy(p,tmpbuf); /* Move in filename */ addargv(p); /* ); /* More room from heap */ argc++; /* Increment arg count */ } /****************************/ /*******And filename */ strcat(buf,"\r\n$"); /* + Newline */ __OSIF(C_WRITESTR,buf); /* output directly to CON: */ /* Cvt to real user # */ if( i>=10 ) *buf++ = '1'; /* Assume user # <15 */ *buf++ = '0' + (i % 10); /* now for( brk(argv2)==FAILURE) /* Allocate the pointers */ _err("Stack Overflow",""); /* Call "Stack Overflow" rtn*/ exit(main( { /*****************************/ REG BYTE *f; /* -> Fcb in DMA buffer */ WORD i; /* Temp. */ Add this file to argv */ c=__open(STDERR+1,s,SEARCHN); /* Search next */ } /**************************************************************************************************/ /****************************************************** digits */ *buf++ = ':'; /* finish off with this */ i = TRUE; /* remember */ }; /***************H*n(n ..-G --@ -g -g-gF>"/</ 4/-/ N@P|g3Mt3NVMvph package */ { } #endif /*****************************************************************************/ /****************; /* What OS are we running? */ os_version = __cpmrv; /* Use AX, not AL ret by OSIF*/ /* */ switch( os_ver */ *buf++ = tolower((f[i]&0x7f)); /* Yes, move it in */ } /*****************************/ *buf++ = '.'; /* 1/4/83 whf & rsw - add CPMZ8KV11 * 12/29/83 whf - add os_truncates * 11/4/83 whf - handle CCPM3.1 and networking ************************/ #endif /*================================================================*/ if(p->fcb.drive) /* Drive s`U>!/</ 4/./ N@P|g3Mt3NVMvp`~+n&M -4 мdJo SR`J*************************************************************/ sion ) /* What kind of OS? */ { /* */ case CCPM86V10: /* CCP/M-86 PC v1.0 */ case MPM86V21: * Put in delimiter */ for(i=9; i<12; i++) /* Move in extension */ { /* */ if(f[i] != ' ') /* N*******************************************************************/ #include "portab.h" #include "osif.h" #include "osiferpecified? */ { /* Yes */ if(i) /* User #? */ buf--; /* Yes, back up over ':' */ *bf - o+m .`.RB -@Jo >!/./ /./ N@PH,ݮ ѭ   - o+m gU ************************************************************/  /* MP/M-86 v2.0, v2.1 */ os_abilities |= _os_multitasking|_os_oldmultisec|_os_f_parse| _os_filesharing|_os_datetion-blank? */ *buf++ = tolower((f[i]&0x7f)); /* Yes, move it in */ } /*****************************/ *buf++r.h" #define OSATTR #include "osattr.h" unsigned short os_abilities = 0; unsigned short os_version = 0; WORD osattruf++ = p->fcb.drive - 1 + 'a'; /* Put in drive code */ *buf++ = ':'; /* And delimiter */ } /* */ /**************************************************************************** * OSATTR.C - sets "os_abilities" word, depending ************************************************************/ me|_os_interrupts; break; /* */ /****************************/ case CCPM86V20: /* CCP/M-86 v2.0 = NULL; /* Null at end */ } /*****************************/ #else nowildcards() /* stubroutine for OPTION*.() { #if CPM /*================================================================*/ /* */ __OSIF(S_BDOSVER,0) for(i=1;i<9;i++) /* Move the filename */ { /*****************************/ if(f[i] != ' ') /* Non-blank? on which OS we are running. * * Last modified: * 2/28/84 whf - add os_interrupts * 1/25/84 whf - handle 68K linker problem */ __OSIF(S_OSVER,0); /* Get the truth */ switch(__cpmrv) /* Which OS really? */ { /* o attributes... */ } /****************************/ #endif /*====================================================uncates|_os_datetime|_os_fastconio|_os_interrupts; break; /* */ /* case 0x0014: /* CP/M-80 v1.4 */ /*************************************************************************** * * R d b i n F u n c t i o / case 0x1420: /* Definitely CCP/M-86 v2.0 */ default: /* Maybe CCP/M-86 v2.0 */ os_abilities |= _os* Yes, there's a net */ return SUCCESS; /* If called by someone else*/ } else return FAILURE; /* */ } / */ case CPM86V31: /* Fooled by the network! */ os_abilities |= _os_fastconio; /* plus all of this: */ =============*/ #if PCDOS /*================================================================*/ #endif /*================/* case 0x0022: /* CP/M-80 v2.2 */ /* case 0x0031: /* CP/M-80 Plus */ /* case 0x0122: /* MP/M-80 v1.1n * --------------------------- * * The "_rdbin" function performs a read operation for bin_multitasking|_os_newmultisec|_os_f_parse| _os_filesharing|_os_datetime|_os_loadtime| _os_truncates|_os_fastconio|_os_in****************************/ #endif /*=================================================================*/  case CPM86V11: /* Fooled by the network! */ /* Network will emulate these*/ os_abilities |= _os_newmultisec|_=================================================*/ } #if CPM /*=========================================================== */ /* case 0x0130: /* MP/M-80 v2.0, v2.1 */ default: /* */ case CPM86V11: /* CP/M-86 v1.0, ary files. * * Calling Sequence: * ret = _rdbin(fp,buffer,bytes); * * terrupts; } /* */ net_check(); /* is there a network? */ break; /*****************************************************/ #endif /*=================================================================*/ os_f_parse| _os_filesharing|_os_datetime|_os_loadtime; break; /* */ /****** */ case 0x143======*/ net_check() /****************************/ { /* */ __OSIF(N_NETSTAT,0); /* Is net installed? *v1.1 */ case CPM68KV11: /* CP/M-68K v1.1 */ case CPMZ8KV11: /* CP/M-Z8000 v1.1 */ break; /* nWhere: * fp -> to the open CCB * buffer -> the user's buffer * bytes = the number of bytes**/ case CPM86V31: /* CP/M-86 Plus */ os_abilities |= _os_multitasking|_os_newmultisec|_os_f_parse| _os_tr***************************/ #endif /*=================================================================*/ 1: /* Fooled! CCP/M-86 v3.1 */ os_abilities |= _os_swaps8087; /* 8087 support? */ /* plus all the rest: */ if( __cpmrv != 0xFFFF && __cpmrv != 0 ) /* non bogus return? */ { /* */ os_abilities|=_os_netinstalled; / to be read * ret = the number of bytes actually read * ***************************************O); /* Must be EOF */ fp->sector = xsector; /* Mark buffer */ } /****************************/ p =h? */ { /* */ if((fp->flags & DIRTY) != 0) /* Buffer dirty? */ { /* */ if(_ >> 7; /* Compute number of sectors*/ if(nsector > 0) /* need to transfer?? */ i=_blkio(fp,xsector,buff,nsector, */ LOCAL LONG xsector; /* Temp sector number */ LOCAL LONG nsector; /* Multi-sector count */ LOCAL LONG xbytes; fp->hiwater=fp->offset; /* necessary */ return(xbytes); /* Yes, just return */ } /* */ xsector+*************************************/ #include "portab.h" #include "osif.h" #include "osiferr.h" #include "errno.h" WO &fp->buffer[(int)fp->offset&(SECSIZ-1)];/* buffer offset */ /* */ while(p < &(fp->buffer[SECSIZ]) && /* Mblkio(fp,fp->sector, /* */ fp->buffer,1L,B_WRITE) != 1) /* Try to write old buffer */ RETERR(FAILURE,EIO); /* Can /* Do the */ B_READ); /* transfer */ /* */ xsector += i; /* Update sector counter */ f /* byte count temp */ REG LONG i; /* Temp index */ /****************************/ xbytes = bytes; /+; /* Bump sector pointer */ } /****************************/ /*************************************************RD _rdbin(fp,buff,bytes) /****************************/ /* */ REG FD *fp; /* -> ccb for the file */ REG ove the bytes */ bytes > 0) /* */ { /* */ *buff++ = *p++; /* Copy data byte */ bytes--;'t; just quit. */ fp->flags &= ~DIRTY; /* not dirty anymore */ } /****************************/ p->offset += i*SECSIZ; /* Update offset */ bytes -= i*SECSIZ; /* Update byte count */ buff += i*SECSIZ; /* * Preserve org byte cnt */ xsector = fp->offset >> 7; /* Calculate starting sector*/ /* */ if((fp->offset &************************** * At this point, a multi-sector transfer may be accomplished. */ /*************************BYTE *buff; /* -> buffer to receive data*/ REG LONG bytes; /* = # bytes to xfer */ { /************************ /* Decrement byte counter */ fp->offset++; /* Increment offset */ } /****************************/ if( if(_blkio(fp,xsector,fp->buffer, /* Now read the */ 1L,B_READ) != 1) /* next sector */ RETERR(FAILURE,EIUpdate buffer address */ /* */ if(fp->offset > fp->hiwater) /* Adjust hiwater */ fp->hiwater = fp->off (SECSIZ-1)) != 0) /* If not on boundary, */ { /* must buffer */ if(fp->sector != xsector) /* Do sectors matc***************************************************/ /* */ i = 0; /* In case no xfer */ nsector = bytes****/ #if CPM /*===============================================================*/ REG BYTE *p; /* Temp byte pointer bytes == 0) /* Zero byte count now? */ { /* */ if(fp->offset > fp->hiwater) /* Adjust hiwater if */ set; /* if needed */ if (i != nsector) /* Short read?? */ { /* */ fp->flags |= ATEOF; /* set EOF Fytes,1); /* */ if( xbytes==0 ) /* EOF or error condition */ fp->flags |= ATEOF; /* Set EOF flag */ fp->offseh 1st byte */ while (bytes > 0) /* Count down */ { /* bytes */ *buff++ = *p++; /* Move a byte  fp->flags &= ~DIRTY; /* not dirty anymore */ } /****************************/ if(_blkio(fp,xsector,fp->buffer,1Lead fully satisfied */ } /****************************/ lag */ return(xbytes - bytes); /* Return actual read count */ } /****************************/ if(bytes == 0) t += xbytes; /* Calculate new offset */ #endif /*===============================================================*/ */ bytes--; /* Down count */ } /****************************/ #endif /*=====================================, /* Read into buffer */ B_READ) != 1) /* */ { /* */ fp->flags |= ATEOF; /* End of file */  /* Done? */ return(xbytes); /* Yes, return */ /****************************/ if((fp->flags & DIRTY) if(fp->offset > fp->hiwater) /* Fix up hiwater mark */ fp->hiwater = fp->offset; /* */ return(xbytes); /* ==========================*/ #if PCDOS /*===============================================================*/ UWORD xbytes;  return(xbytes-bytes); /* return corrected count */ } /****************************/ /* */ fp->sector != 0) /* Buffer dirty? */ { /* This can be true for */ if(_blkio(fp,fp->sector, /* boundary conditions Read fully satisfied */ } /****************************/  /* More byte count temps */ /****************************/ xbytes = _pc_readblk(&(fp->fcb),fp->offset,buff,(WORD)b= xsector; /* Update data area */ fp->offset += bytes; /* Increment offset */ p = &fp->buffer[0]; /* Start wit */ fp->buffer,1L,B_WRITE) != 1) /* Try to write old buffer */ RETERR(FAILURE,EIO); /* Can't; just quit. */ ead fully satisfied */ } /****************************/ /************************************************************************* * * _ _ p r t l d F u n c t i o n * ----------se { if (signed && n < 0) { *(*pbuf)++ = '-'; n = -n; } while (n) { n = uldiv(n,b); /* n>0 (or unsigned), d; extern long uldivr; struct long_struct *p_uldivr; p_uldivr = &uldivr; p = digs; b = base; n = *pobj; if (bastr) ) str++; if( *str == '+' ) str++; else if( *str == '-' ) { str++; isneg++; } while( *str >= '0' && *st--------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "__prtld" prints LONGs, for use wito unsigned div*/ *p++ = p_uldivr->lblolo; } } return (p); } e == 16) { /* special because of negatives */ ii = 8; while (n && ii) { *p++ = (int)n & 0xf; /* HY */ n >>= 4; /r <= '9' ) val = 10 * val + ( *str++ - '0' ); if( isneg ) val = -val; return( val ); } h "_doprt". * **************************************************************************/ #include "portab.h" #include "osif unsigned div*/ *p++ = p_uldivr->lblolo; } } return (p); }  /* YESSTART.C: provides 'stubroutine' to satisfy 'nostart' ref, in case */ /* the OPTION?.lib 'nostart()' was not linked i* MGL */ ii--; } } else if (base == 8) { ii = 11; while (n && ii) { *p++ = (int)n & 7; /* HY */ n >>=  <= '9' ) val = 10 * val + ( *str++ - '0' ); if( isneg ) val = -val; return( val ); } .h" /* used for hardware dependencies: byte store order */ BYTE *__prtld(pobj, pbuf, base, signed, digs) LONG *pobj; BYTE * /* atoi - convert decimal number in ascii to integer */ #include "portab.h" #include "ctype.h" WORD atoi(str) /* CLE unsigned div*/ *p++ = p_uldivr->lblolo; } } return (p); } n. */ /* This routine belongs in the main RTL lib. */ nostart() { ; } /* stubroutine tag */ 3; /* MGL */ ii--; } if (ii==0) { *(p-1) &= 3; /* only 2 bits in upper octal digit */ /* MGL */ } } el <= '9' ) val = 10 * val + ( *str++ - '0' ); if( isneg ) val = -val; return( val ); } *pbuf; WORD base; WORD signed; BYTE *digs; { REG LONG n; REG LONG b; REG BYTE *p; REG WORD ii; extern long uldiv()AR FUNCTION ***********/ REG BYTE *str; { REG WORD val; REG WORD isneg; val = 0; isneg = FALSE; while( isspace(*s. */ /* This routine belongs in the main RTL lib. */ nostart() { ; } /* stubroutine tag */ umed. * mode -> "r" for read only, * "w" for write only, * "a" to append (write only) to end of file. * ascii = for binary files, and the default (presently to * ascii files). * * Calling sequence: * stream = fopena(name,mode) (ascii off end of table */ break; /* */ if( ii >= MAXFILES ) /* */ return(NULLFILE); /* fail **/ REG BYTE *name, /* file name */ *mode; /* "r","w", or "a" */ BOOLEAN ascii; /* CP/M text file . */ /* This routine belongs in the main RTL lib. */ nostart() { ; } /* stubroutine tag */  0 if the file is handled as a CP/M text file * (newline -> CRLF xlation, ^Z EOF convention). * Otherwise, file is treatedfiles) * stream = fopenb(name,mode) (binary files) * stream = fopen(name,mode) (default-ascii files) * stream = _fopen(nam/ if( *mode == 'w' || *mode == 'W' ) /* 'w'rite mode? */ fd=_creat(name,CREATMODE,ascii);/* create file *********/ el/************************************************************************** * * f o p e n F u n c t i o n * ----------- */ { /****************************/ REG FILE *sp; /* stream pointer */ REG WORD ii, /* index into _iob */ as a binary file. * *****************************************************************************/ #include "stdio.h" /e,mode,ascii) * Where: * stream -> file opened (FILE *), NULLPTR if failure * name -> NULL terminated string containing fse if( *mode == 'a' || *mode == 'A' ) /* 'a'ppend mode? */ { /* */ if( (fd=_open(name,WRITE,ascii)) < 0 ) /* ---------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "fopen" opens a buffered stream file, ei fd; /* file descriptor */ /****************************/ for( ii=0; /* look at _iob table */ ****************************/ #define READ 0 /* read mode val */ #define WRITE 1 /* write mode val */ #defineilename, * name="CON:" means the console, * name="LST:" goes to the line printer, and * otherwise a disk file is asstry open */ fd=_creat(name,CREATMODE,ascii);/* ow. do create */ else lseek(fd,0L,2); /* its out there, seef EOF ther on disk, console, or * line printer. * Note that "fopen" comes in three (3) flavors, one for ascii CP/M * files, another (sp=(&_iob[ii]))->_flag&(_IOREAD|_IOWRT); /* not marked rd/wrt */ ii++ ) /* */ if( ii >= MAXFILES ) /* if CREATMODE 1 /* mode to use for 'creat' */ /****************************/ FILE * _fopen(name,mode,ascii) /* */ } /* ************************/ else if( *mode == 'r' || *mode == 'R' ) /* 'r'ead mode? */ fd=_open(name,REA */ { /* */ return(_fopen(name,mode,1)); } /* binary file open */ NCTION ***********/ BYTE *name,*mode; /* */ { /* */ return(_fopen(name,mode,0)); } /* ascii file open on stderr describing * the last error encountered during a call to the system. * It assumes the variable "errno" contains thite mode */ if( ascii == 0 ) /* ascii mode? */ sp->_flag |= _IOASCI; /* */ /***********************D,ascii); /* try open ************/ else return(NULLFILE); /* bad mode barf... */ /****************************/  */ /****************************/ FILE * fopenb(name,mode) /* CLEAR FUNCTION ***********/ BYTE *name, *mode; /* s error. * Note: "errno" is set when errors occur, but is not cleared. * Note also that some of the UNIX errors are meaningles*****/ return(sp); /* return the stream ptr */ } /****************************/ /************************ if(fd<0) /* did one of those work? */ return(NULLFILE); /* no, oh well */ sp->_cnt = 0; /* init count * */ { /* */ return(_fopen(name,mode,1)); } /* binary file open */ s under * CP/M, and will print an undefined message (defined below). * Finally, note that the defines in """errno.h""" will i****/ FILE * fopen(name,mode) /* CLEAR FUNCTION ***********/ BYTE *name, *mode; /* */ { /* */ return(/*********************************************************************** * * p e r r o r F u n c t i o n * ------------/ sp->_fd = fd; /* and file des */ sp->_base = sp->_ptr = NULLPTR; /* and buffer pointers */ if( *mode == 'r */ { /* */ return(_fopen(name,mode,1)); } /* binary file open */ ndex * appropriately into the sys_errlist table, below. * * Calling sequence: * ret = perror(s) * Where: * ret = errno _fopen(name,mode,0)); } /* ascii file open */ /****************************/ FILE * fopena(name,mode) /* CLEAR FU----------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "perror" produces a short error message' || *mode == 'R' ) /* 'r'ead mode? */ sp->_flag = _IOREAD; /* say so */ else sp->_flag = _IOWRT; /* else 'w'ri * s -> a string containing a message printed with * the explanatory error message. * ********************************** /* 20 */ _undeferr, /* 21 */ "EINVAL Invalid argument", /* 22 */ "ENFILE File table overflow", /* 23 */ "EMFILE Too 1 */ "ENOENT No such file", /* 2 */ _undeferr, /* 3 */ _undeferr, /* 4 */ "EIO I/O error", /* 5 */ _undeferr,  write(STDERR,err,strlen(err)); write(STDERR," (",2); buf = _itoa(errno,lbuf); if( _errcpm != 0 ) /* assume this had soODSPC No directory space", /* 35 */ "ERENAME Can't rename file" /* 36 */ }; ****************************************/ #include "portab.h" #include "osif.h" #include "osiferr.h" #define NUMERRS 37 # many open files", /* 24 */ "ENOTTY Not a typewriter", /* 25 */ _undeferr, /* 26 */ "EFBIG File too big", /* 27 */ "E /* 6 */ "E2BIG Arg list too long", /* 7 */ _undeferr, /* 8 */ "EBADF Bad file number", /* 9 */ _undeferr, /* 10 */ mething to do */ { *buf++ = '.'; buf = _itoa(_errcpm,buf); } *buf++ = ')'; *buf++ = '\n'; *buf = NULL; write(STDERODSPC No directory space", /* 35 */ "ERENAME Can't rename file" /* 36 */ }; define STDERR 2 MLOCAL BYTE _undeferr[] = "Error undefined" ; WORD sys_nerr = NUMERRS; VOID perror(str) /* CLEAR FUNCTIONOSPC No space left on device",/* 28 */ _undeferr, /* 29 */ "EROFS Read-only file system", /* 30 */ _undeferr, /* 31 * _undeferr, /* 11 */ "ENOMEM Not enough core", /* 12 */ "EACCES Permission denied", /* 13 */ _undeferr, /* 14 */ _uR,lbuf,strlen(lbuf)); return(errno); } MLOCAL BYTE *_itoa(nm,bp) WORD nm; REG BYTE *bp; { /* temporary... */ sprinN ***********/ BYTE *str; { REG BYTE *err; BYTE lbuf[20], *buf, *_itoa(); EXTERN BYTE *sys_errlist[]; if( errno<0 ||/ _undeferr, /* 32 */ _undeferr, /* 33 */ _undeferr, /* 34 */ /* end of UNIX v7, start of CPM specific */ "Endeferr, /* 15 */ _undeferr, /* 16 */ _undeferr, /* 17 */ _undeferr, /* 18 */ _undeferr, /* 19 */ _undeferr,tf(bp,"%d",nm); while(*bp) bp++; return(bp); } BYTE *sys_errlist[NUMERRS] = { _undeferr, /* 0 */ _undeferr, /* errno>=sys_nerr ) err = _undeferr; else err = sys_errlist[errno]; write(STDERR,str,strlen(str)); write(STDERR,": ",2);NODSPC No directory space", /* 35 */ "ERENAME Can't rename file" /* 36 */ }; /***************************************************************************** * * f r e o p e n F u n c t i o n * ---- /****************************/ if( fclose(sp) == FAILURE ) /* try closing the file 1st */ return(NULLFILE); /* oop***************************************/ #include "stdio.h" /****************************/ #define READ 0 /* read modse 'w'rite mode */ if( ascii == 0 ) /* ascii file? */ sp->_flag |= _IOASCI; /* */ /***************ULLPTR if failure * name -> NULL terminated string containing filename, * name="CON:" means the console, * name="LSTname,READ,ascii); /* try open ************/ else return(NULLFILE); /* bad mode barf... */ /**********************--------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "freopen" opens a buffered sts, it failed */ if( *mode == 'w' || *mode == 'W' ) /* 'w'rite mode? */ fd=_creat(name,0,ascii); /* create file ****e val */ #define WRITE 1 /* write mode val */ FILE *_freope(name,mode,sp,ascii) /****************************/ *************/ return(sp); /* return the stream ptr */ } /****************************/ FILE * freopen(name,mod:" goes to the line printer, and * otherwise a disk file is assumed. * mode -> "r" for read only, * "w" for write o******/ if(fd<0) /* did one of those work? */ return(NULLFILE); /* no, oh well */ sp->_cnt = 0; /* init counream file, either on disk, console, or * line printer. It first closes the given stream, and reuses that slot. * Comes in 3 f*****/ else if( *mode == 'a' || *mode == 'A' ) /* 'a'ppend mode? */ { /* */ if( (fd=_open(name,WRITE,asci REG BYTE *name, /* file name */ *mode; /* "r","w", or "a" */ REG FILE *sp; /* stream pointer */ e,sp) /* CLEAR FUNCTION ***********/ BYTE *name, *mode; FILE *sp; { return(_freope(name,mode,sp,0)); } /* reopen ascii filenly, * "a" to append (write only) to end of file. * ascii = 0 if the file is handled as a CP/M text file * (newline -t */ sp->_fd = fd; /* and file des */ sp->_base = sp->_ptr = NULLPTR; /* and buffer pointers */ if( *molavors, like "fopen". * * Calling sequence: * stream = freopen(name,mode,stream) * stream = freopa(name,mode,stream) * si)) < 0 ) /* try open */ fd=_creat(name,0,ascii);/* do create if needed */ else lseek(fd,0L,2); /* its out there, se BOOLEAN ascii; /* CP/M text file */ { /****************************/ REG WORD fd; /* file descriptor */ */ FILE * freopa(name,mode,sp) /* CLEAR FUNCTION ***********/ BYTE *name, *mode; FILE *sp; { return(_freope(name,mo> CRLF xlation, ^Z EOF convention). * Otherwise, file is treated as a binary file. * **************************************de == 'r' || *mode == 'R' ) /* 'r'ead mode? */ sp->_flag = _IOREAD; /* say so */ else sp->_flag = _IOWRT; /* eltream = freopb(name,mode,stream) * stream = _freopen(name,mode,stream,ascii) * Where: * stream -> file reopened (FILE *), Nef EOF */ } /* ************************/ else if( *mode == 'r' || *mode == 'R' ) /* 'r'ead mode? */ fd=_open(de,sp,0)); } /* reopen ascii file */ FILE * freopb(name,mode,sp) /* CLEAR FUNCTION ***********/ BYTE *name, *mode; FIjBWBg/ RN\|g.R/<17aXX` N2n!MRn` N2n!|.?.NT>NJL N^NuNV; /* number of bytes read */ } e[]; /* List device name */ /****************************/ WORD _creat (fname,prot,type) /***********************f\|g..P/<.N@XNBy,JBWB?9,HN\a JL N^NuNVH*|,,BG|l.,HN:RG` y`,,g, y`t) * fid = _creat(fname,prot,type); * * Where: * * fname is the address of a null terminated file name. * prot is the ULE *sp; { return(_freope(name,mode,sp,1)); } /* reopen binary file */ /**************************************************************************** * * C F I L E C R E A T E R O U T I N  /* number of bytes read */ } *****/ BYTE *fname; /* -> File name */ WORD prot; /* Open mode */ WORD type; /* ASCII/BINARY flag *#include "portab.h" LONG readl(fd,buf,lnum) /* CLEAR FUNCTION ***********/ WORD fd; /* file descriptor */ REG BYTE *bufNIX file protection * type is 0 for ASCII, 1 for BINARY * ******************************************************************E *sp; { return(_freope(name,mode,sp,1)); } /* reopen binary file */ E * ----------------------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * The "c /* number of bytes read */ } / { /****************************/ REG WORD ich; /* Channel number for open */ WORD _allocc(); /* gets a chann; /* addr */ LONG lnum; /* size */ { LONG R; REG UWORD tmp; R = lnum; while (lnum != 0) { tmp = (lnum < 3***********/ #include "portab.h" /* Include std definitions */ #include "osif.h" /* Include CP/M definitions */ #includeE *sp; { return(_freope(name,mode,sp,1)); } /* reopen binary file */ reat" routine opens a new "C" file and returns a file id. * Comes in 3 flavors: ascii (CP/M text files), binary, and default Hм3( @g 5pH| `5pH"M4GRG`J5pg M2GBRG f0>Nel */ REG FD *ch; /* -> CCB for channel */ /* */ if((ich = _allocc()) == FAILURE) /* Allocate a cha2768L)? (int)lnum : 32768; if (read(fd,buf,tmp) != tmp) break; buf += tmp; lnum -= tmp; } return(R-lnum) "osiferr.h" #include "errno.h" /* Error codes */ EXTERN BYTE __tname[]; /* Terminal name */ EXTERN BYTE __lnam.N@.2.< H?NTJLN^NuNVH*n>/<,H/ NP3,Hl./<.N@XN#.P>/<,,?9,HN* (currently ascii). * * Calling Sequence: * fid = creat(fname,prot) * fid = creata(fname,prot) * fid = creatb(fname,pronnel */ return (FAILURE); /* Can't (EMFILE) */ /* */ __chinit(ich); /* Clear out channel's ccb */*****/ BYTE *fname; WORD prot; { return(_creat(fname,prot,1)); } /* binary file open */ n(_creat(fname,prot,0)); } /* default to ascii */ WORD creata(fname,prot) /* CLEAR FUNCTION ***********/ BYTE *fna * The blkfill function sets a region of memory to a given value. * * Calling Sequence: -> flags |= ISLPT|OPENED; /* set flag */ return(ich); /* */ } /* */ /************************+XJ@fU0`f>/.?N"\J@g>N(33$343&p`2U>B-H?N\BWB-H?N\0NqJL N^ ch = _getccb(ich); /* Get address of ccb */ /* */ if(type==0) /* ASCII file? */ ch -> flags |.?<#NT-H@g0F.?< NT <0-gJ0o.-0Sg-gF>"/</ 4/-/ N&me; WORD prot; { return(_creat(fname,prot,0)); } /* ascii file open */ WORD creatb(fname,prot) /* CLEAR FUNCTION ***** * * blkfill(addr,fc,num); * * Where: * addr Is a pointer to region of mem****/ if(__open(ich,fname,CREATE) != 0) /* Use BDOS interface */ RETERR(FAILURE,ENODSPC); /* Oops, No dir space. *NuNVH*n B:.>N&^(@ fp`,gB@`x,g3 3$343&p`X,g./ / NnP`>,f./ / = ISASCII; /* Yes, mark it. */ /****************************/ if(_strcmp(fname,__tname) == 0) /* Terminal file? |g33$343&p`U>!/</ 4// N&|g33$343&p`V+G -+@I4Gd ******/ BYTE *fname; WORD prot; { return(_creat(fname,prot,1)); } /* binary file open */ ory to blkfill * fc Is a character to blkfill with * num Is the number of chars to blkfill with * / /* Else: */ ch -> flags |= OPENED; /* Set OPEN bit */ return(ich); /* Return Channel # */ } /*************************************************************************** * * b l k f i l l F u n c t i o */ { /* */ ch -> flags |= ISTTY|OPENED; /* Set flag */ return(ich); /* Return file descriptor */ gR` " Ҽ4ѭ`B` -0+@+m U -NqJL8N^NuNVBW?. /.a:\NqN^NuNVBW?. /.a"\NqN^NuNV>?. *****/ BYTE *fname; WORD prot; { return(_creat(fname,prot,1)); } /* binary file open */  ****************************************************************************/ #include VOID blkfill(addr,f /****************************/ WORD creat(fname,prot) /* CLEAR FUNCTION ***********/ BYTE *fname; WORD prot; { return * ------------------------------- * Copyright 1983 by Digital Research Inc. All rights reserved. * } /****************************/ else if(_strcmp(fname,__lname) == 0) /* List device? */ { /* */ ch /.a\NqN^NuNVHN'>JGlp`>N%0*@4"Jn fUJnfU.,!/.N+XJ@f U0``.,&/.Nc,num) /* CLEAR FUNCTION ***********/ REG BYTE *addr; REG BYTE fc; REG WORD num; { while( num-- > 0 ) *adling sequence: * size = _filesz(fd) * where: * size = # bytes in file; * 0 if not disk file; * -1 if I/O error * fd/ 4/-/ N&|g33$343&p`tU -"- S¼nD>!/</ 4/./ N&|g=============================================*/ if( fp->flags & DIRTY ) { /* File been used? */ fp->offset = fp->g>// aP`,g>// aP`|,f./ / atP`d-EBJoX ,-@B ,gN,gF>"/</  /* Current user # */ /****************************/ if((fp = _chkc(fd)) == NULLFD) /* Convert to pointer */dr++ = fc; }  = file descriptor returned by open. * ***********************************************************************/ #include /********************************************************************** * * _ f i l e s z f u n c t i o n * -----------hiwater; /* yes: this must be right */ } else { /****************************/ xuser = _chkuser(fp->user); /* Chec4/,/ N&|g33$343&p`T ,", S¼n$>!/</ 4/./ N&)n , return(FAILURE); /* Can't: EBADF */ if(fp->flags&(ISTTY|ISLPT)) /* Non disk file? */ return(0); /* *r++ = fc; } "portab.h" #include "osif.h" #include "osiferr.h" #include "errno.h" LONG _filesz(fd) /****************************/ -------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * This routine computes the size of a k user # for change */ __OSIF(FILSIZ,&(fp->fcb)); /* Do BDOS call */ _uchkuser(fp->user,xuser); /* Change back if ne-@&L4, мd"Jo  f < g< `SR` мe4>"/</ 4/./ N&|g ./ #if PCDOS /*================================================================*/ fp->offset = (fp->fcb).fcb_filsiz; /* simpler++ = fc; } WORD fd; /* file descriptor */ { REG FD *fp; /* file's ccb pointer */ REG BYTE *p1, *p2; /* temps for buffer CP/M file, and leaves the fd * pointing to the end of file. * Note that the file must have been previously opened. * * Caleded */ #if HILO /*--------------------------*/ fp->fcb.record &= 0xFFFFFFL; /* mask off cr byte */ xsector = f`$`T@Jf , o)l .``JL8N^NuNVH*n(n ..-G --@ -gj -g-gF>"/<, eh? */ #endif /*================================================================*/ #if CPM /*===================SS`Jo R "ҼNqJL8N^NuNVH*n B:.>N&^(@ fp`JnB@`,g3 3$343&p`,work */ REG LONG xsector; /* where we are in file */ FD *_chkc(); /* cvt & check fd to fp */ REG WORD xuser;p->fcb.record - 1; /* last sector in file */ #else /*--------------------------*/ xsector = (fp->fcb.record >>8) - *******************/ } /****************************/ #endif /*===================================================er[0]); /* start of buf */ p2 = &(fp->buffer[SECSIZ]); /* end of buf */ while( p1.,=:+-&/\|()[]*3!!!!", /* Write out */ 1L,B_WRITE) != 1) /* the buffer */ RETERR(FAILURE,EIO); /* */ fp->flags &C RTL -- Program not linked for floating point $Cannot open Cannot create B ^ 1; /* last sector in file */ #endif /*--------------------------*/ if( fp->flags & ISASCII ) /********************=============*/ fp->hiwater = fp->offset; /* whatever happened, set it*/ fp->flags |= ATEOF; /* make sure they kn) /* look for EOFCHAR */ p1++; /* */ fp->offset += p1-&(fp->buffer[0]); /* update offset to EOF */ CP/M-68K(tm), Version 1.2, Copyright (c) 1983, Digital R= ~DIRTY; /* turn off this bit */ } /* */ if(_blkio(fp,xsector,fp->buffer, /* scan this last sect 0 4 B ^ ********/ { /* Ascii file: posit to EOF */ if(xsector >= 0) /* if any size at all */ { /* **************ow */ return(fp->offset); /* this is it */ } /****************************/  } /* *********************/ else fp->offset=0; /* o.w. beginning of file */ /****************************/ /************************************************************************** * * f g e t c F u n c t i o n * -----------or */ 1L,B_READ) != 1) /* for EOFCHAR */ RETERR(FAILURE,EIO); /* */ } /* got correct 0 8   *******/ if( xsector != fp->sector ) /* need to change sector? */ { /* get correct sector********/ ifw */ return(fp->offset); /* this is it */ } /****************************/  } else { /* Binary file:compute size */ fp->offset = (xsector+1) << 7; /* set to end of last record*/ } /*********---------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * Function "fgetc" does the yanking of a csector********/ fp->sector = xsector; /* */ fp->offset = xsector << 7; /* */ p1 = &(fp->buff ((fp->flags & DIRTY) != 0) /* Something to write 1st? */ { /* */ if(_blkio(fp,fp->sector,fp->bufferw */ return(fp->offset); /* this is it */ } /****************************/ har out of the stream. * * Calling sequence: * ch = fgetc(s) * Where: * ch = a (WORD) character (-1 on EOF) * s -> a stfd) /* CLEAR FUNCTION ***********/ REG WORD fd; /* File descriptor to close */ { /****************************/ EXsp) ); /* o.w. whatever happens */ } /****************************/  * * Modifications: * 12/83: PC-DOS mods whf * 10/83: changed user # handling wream file (FILE *) * *****************************************************************************/ #include "stdio.h" #de/*************************************************************************** * * C l o s e F u n c t i o TERN FD *_chkc(); /* fd -> fp conversion MGL */ REG FD *fp; /* file pointer Temporary */ REG WORD rv; /* return valup) ); /* o.w. whatever happens */ } /****************************/ hf * 9/83: add steve's user # mods, change _chkc whf * 8/83: improve error handling whf **********fine CMASK 0xFF WORD fgetc(sp) /* CLEAR FUNCTION ***********/ REG FILE *sp; /* stream pointer */ { /********n * --------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * e */ REG WORD xuser; /* User number temporary */ /* */ if((fp=_chkc(fd)) == NULLFD) /* File Open? p) ); /* o.w. whatever happens */ } /****************************/ ******************************************************************/ #include "portab.h" #include "osif.h" #include "osiferr.h********************/ EXTERN WORD _filbuf(); /* use this when we run shrt*/ if( --sp->_cnt >= 0 ) /* any chars left in b * The close function is used to terminate access to a file / device. * * Calling Sequence:  */ RETERR(FAILURE,EBADF); /* no, quit */ rv = SUCCESS; /* assume it will work */ if ((fp->flags & (ISTT" #include "errno.h" /****************************/ EXTERN BYTE __xeof; /* End of file for ASCII */ WORD close(uf? */ return(((WORD) *sp->_ptr++) & CMASK);/* return & advance ptr ifso*/ else /* */ return( _filbuf( * * ret = close(fd); * * Where "fd" is an open file descriptor to be CLOSEd. Y|ISLPT)) == 0) /* Character device? */ { /* if not, handle file: *****/ #if CPM /*================================ */ } /****************************/  /* */ #endif /*================================================================*/ } /* end of file handling *der CPM before * version 4. The user number is stored in the ccb structure; * if a zero, the default user # is a= FAILURE; /* can't */ xuser = _chkuser(fp->user); /* Check user # for change */ if((__OSIF(CLOSE,&(fp->fcb))&0================================*/ if((fp->flags & ISASCII) != 0 && (fp->flags & ISREAD) == 0) /* */ { /* ASCII fil */ } /****************************/ ****/ __chinit(fd); /* Release the space */ _freec(fd); /* Release the channel */ if( rv == SUCCESS ) /* Wssumed, else the _chkuser() * routine sets the user number to the desired user number (one less * than the stored usxFF) == 0xFF)/* Close the fcb */ rv = FAILURE; /* */ _uchkuser(fp->user,xuser); /* Change user # if needee? not ReadOnly?*/ if( fp->offset < fp->hiwater ) /* Have we been seeking? */ lseek(fd,0L,2); /* Seek to EOas everything ok? */ return(rv); /* Yes, return Success */ else RETERR(FAILURE,EIO); /* else let them know er number, since user 0 is valid - similar to the * default drive spec for an FCB). * '_uchkuser()' sets the user d */ #endif /*================================================================*/ #if PCDOS /*=============================/*************************************************************************** * * _ c h k u s e r F u n c t F ifso */ write(fd,&__xeof,1); /* Write a ^Z character */ } /****************************/ if((fp->fl */ } /****************************/ number back to its previous value. * *********************************************************************===================================*/ if((__OSIF(CLOSE,&(fp->fcb))&0xFF) == 0xFF)/* Close the fcb */ rv = FAILURE;i o n * --------------------------------- * * '_chkuser' and '_uchkuser' handle user numbers unags & DIRTY) != 0) /* Buffer dirty? */ if(_blkio(fp,fp->sector,fp->buffer,1L,B_WRITE) != 1)/* write it */ rv *******/ #include "portab.h" #include "osif.h" /****************************/ WORD _chkuser(newu) /* */ W==========================*/ } /****************************/ ======================================*/ if( newu == 0 ) /* Default user #? */ return; /* assume no change * Entry Points: * * _petoa(^float, ^buff, prec); * _pftoa(^float, ^buff, pre/ return prevu; /* Return the previous */ #else /*===============================================================/*************************************************************************** * * d o p r t f p R o u t i n e ORD newu; /* Desired user number */ { /****************************/ #if CPM /*==========================================================*/ } /****************************/ */ if( newu != prevu ) /* Are they different? */ __OSIF(USER,prevu-1); /* Yes, set to what it was*/ #else /*c); * _pgtoa(^float, ^buff, prec); * * ^float is a pointer to the floating number to convert */ return 0; #endif /*===============================================================*/ } /************************ * ----------------------------- * * This file contains subroutines called from "_doprt()" which ===============================*/ REG WORD prevu; /* Previous user number */ /****************************/ if(===============================================================*/ return 0; #endif /*==================================== * ^buff is a pointer to the buffer * prec is the precision specifier * * Modifications: ****/ /****************************/ _uchkuser(newu,prevu) /* */ WORD newu; /* Desired user number *are * specific to floating point. The purpose of having a separate file * is so that these routines may be declared gl newu == 0 ) /* Default user # desired? */ return 0; /* Yes, return */ prevu = __OSIF(USER,0xFF)+1; /* Get pre===========================*/ } /****************************/  * 1/84 whf - change to include "osif.h" * 8/83 whf - add in DRC floating point call * 10/83 whf - get it to wo/ WORD prevu; /* Previous user number */ { /****************************/ #if CPM /*=========================obal in a special * version of "s.o", to allow running without the floating point * library routines. *v and adjust */ if( newu != prevu ) /* Are they different? */ __OSIF(USER,newu-1); /* Yes, set to desired u# *rk on DRC * *****************************************************************************/ /* /* */ BYTE *_pgtoa(addr,buf,prec) /* Print "G" format */ FLOAT *addr; /* -> Number to convert */ BYTE * /* */ BYTE *_petoa(addr,buf,prec) /* Print "E" format */ FLOAT *addr; /* -> Number to convert */ B (f, e, or g) */ { /************************************/ REG BYTE *ss; /* Temp pointer for adjustment */ REG Wc) /* Print "F" format */ FLOAT *addr; /* -> Number to convert */ BYTE *buf; /* -> Output buffer */ WOR***********************************************************/ #else /* for DRC */ /******************************************* */ #include "portab.h" /* */ #include "osif.h" /* */ /* */ /********************************buf; /* -> Output buffer */ WORD prec; /* Fraction precision specifier */ { /******************************YTE *buf; /* -> Output buffer */ WORD prec; /* Fraction precision specifier */ { /*************************ORD nn; /* Counter */ WORD len; /* */ /* */ ss = buf; /* Save til later */ if( prec 17 ) prec = 17; /* If >17, make it 17 */ if( kind == 'f' ) nn = */ /************************************/ prec = (prec < 0) ? 6 : prec; /* If < 0, make it 6 */ fp = *addr; // BYTE *_drcftoa(addr,buf,prec,kind) /* Use DRC ftoa routine */ DOUBLE *addr; /* -> Number to convert */ REG BYT***********************************************************************/ BYTE *ftoa(); /* Converts float to ascii "F" fmt */ry F first */ if(strlen(buf) > (7+prec)) /* Smallest FP string */ sp = _petoa(addr,buf,prec); /* Do E format /* Load temp */ return(etoa(fp,buf,prec)); /* Do conversion */ } /************************************/ 17; /* use max. precision */ else if( kind == 'e' || kind == 'E' ) nn = prec + 1; else if( (nn = prec) == 0 ) /* G f* Load float number */ return(ftoa(fp,buf,prec)); /* Do conversion */ } /************************************/ E *buf; /* -> Output buffer */ REG WORD prec; /* Fraction precision specifier */ BYTE kind; /* Kind of convert BYTE *etoa(); /* Converts float to ascii "E" fmt */ /************************************/ BYTE *_pftoa(addr,buf,preinstead */ return sp; /* */ } /************************************/ /* */ /*****************ormat */ ++nn; if (nn > 17) nn = 17; *buf = ' '; ftoa(addr, &buf[1], 80, nn, kind); /* go convert */ if( k /************************************/ return(_drcftoa(addr,buf,prec,ch));/* Do conversion */ } /****************** Fraction precision specifier */ BYTE ch; /* Char format specifier */ { /************************************/ *******/ > Number to convert */ BYTE *buf; /* -> Output buffer */ WORD prec; /* Fraction precision specifier */ BYrailing zeros */ p = dot + prec + 1; lastdig = *p; *p = '\0'; if (lastdig >= '5') { while (1) { /* round preceeind == 'f' ) _ffmt(ss,prec); len = strlen(buf); if(buf[len-1] == '.') /* Zap trailing decimal point */ buf[len******************/ /****************************************************************************/ MLOCAL _ffmt(s, prec) return(_drcftoa(addr,buf,prec,ch));/* Do conversion */ } /************************************/ /* */ *******/ TE ch; /* Char format specifier */ { /************************************/ return(_drcftoa(addr,buf,prec,ch));/* ding digit */ if (*--p == '.') p--; if ((*p += 1) <= '9') break; *p = '0'; } if (*p < '1') { if (*p == '-1] = NULL; /* */ while( *buf == ' ' ) /* Zap leading blanks */ ++buf; /* */ if( ss != buf ) char *s; register prec; { register char *p; register int i; char *dot, lastdig; p = s; while (*++p) { if (BYTE *_pgtoa(addr,buf,prec,ch) /* Print "G" format */ FLOAT *addr; /* -> Number to convert */ BYTE *buf; /* -> N^NuNVn n n n .NqN^NuNVn nN^NuNVJfa`>da8BWaN^NuNVH.aJ@fZ>/.NDo conversion */ } /************************************/ /* */ BYTE *_petoa(addr,buf,prec,ch) /* Print .') *(p-1) = '-'; *p = '1'; } } } #endif /********************************************************************/* Did we zap leading blanks? */ strcpy(ss,buf); /* Ifso, shift everything into place*/ return ss; /* */ *p == '.') dot = p; /* found decimal pt. */ else if (*p == 'e') { s = dot + prec + 1; if (s < p) while (*s++ Output buffer */ WORD prec; /* Fraction precision specifier */ BYTE ch; /* Char format specifier */ { X>JGl./<xa./97?<??97a^ >NJLN^NuNV.a`J@f$. Number to convert */ BYTE *buf; /* -> Output buffer */ WORD prec; /*********/ } /************************************/ BYTE *_pftoa(addr,buf,prec,ch) /* Print "F" format */ FLOAT *addr; /* - = *p++); /* remove extra zeros */ return; } } i = p - dot - 1; while (i++ < prec) *p++ = '0'; /* fill t7a N^NuNVN\N^NuNVaJ@g >a`N^NuNV>/<7t?97N \|fJ97tf Ry7B@`pNqN^NuNVHJyn * ------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * nce *p until NULL. */ ; return((WORD)p-str); } 0.nl Jnm=n0.n=@J.fZ .0f, n -f"Sn. nH?NTRRn0.SnJ@o..H?NT` in s. * * WORD strlen(s) * BYTE *s; **********************************************************************/ #include "po(code) /* CLEAR FUNCTION ***********/ WORD code; /* Exit status */ { /* */ _cleanup(); /* Close all 7fj.97gRJng0>ca.7/97?<?97?97a` `&>/?97N\Jl./<5MNX>/<5MNX-|5C n2n B=|*nJgJgHHм?f @Rn0.SnJ@o. nH?NTR`Rn0.SnJ@o..H?NT`Rn`l0.NqJL N^NuNVH /<@J?.?.rtab.h" WORD strlen(str) /* CLEAR FUNCTION ***********/ REG BYTE *str; { REG BYTE *p; for( p = str; *p; p++ ) /* adv(stream) files*/ _exit(code); /* return to O.S. */ } /***************************/ *n(n Hf Jfp``B@NqJL0N^NuNVH*|:»:d >/aX`JL N^NuNVH*n<. >SGm 0]fT`.>l?N * Note that the stream files are closed via '_cleanup()'. * * Calling Sequence: * gR`JgBG M2GJgJ5pHHм?f @f45pHHм?f @g 5pH| `5pH"M4GRG`J5pg M2GBRG l. H?NT.>l?< NTaN^NuNVH *n(n >.JGggSG`SGoB`JL0N^NuNV * exit(code); * * Where: * code Is the exit status (ignored) * /*************************************************************************** * * E x i t F u n c t i o SE``j nf&z JgJEg SE`JEf-`"/</ 4/-/ N/|g3?b3@D?dp`U>!/<LOBAL UBYTE __atab[] = { /* table of ascii char types */ /***************************************************************** __l, __p, __p, __p, __p, __c }; ___atab() { } t>NN^NuNVHBG|l0м>^.NRG`JLN^NuNVH*n0-|g*.N-g .N2@B@H+@+@Bme f g */ /*14m*/ __p, __l, __l, __l, __l, __l, __l, __l, /* h i j k l m n o */ /*15m*/ __l, __l, __l, __l, __l, __l, ____p, __p, __p, __p, __p, __p, __p, __p, /* 0 1 2 3 4 5 6 7 */ /*06m*/ __d, __d, __d, __d, __d, __d, __d, __d, /* 8 9 : / 4/./ N/|g3?b3@D?dp`~+n&M -4 мdJo SR`Jf - o+m ***/ /* nn0 nn1 nn2 nn3 nn4 nn5 nn6 nn7 */ /* nul soh stx etx eot enq ack bel */ /*00m*/ __c, __c, __c, __c, __c, __c, __c@D?dp`X,g./ / N$"P`>,f./ / a6P`&-EJo.,g,gF>"/</ 4/,/ N//************************************************************************** * CTYPE.C - provides static tables for 'ctype.hl, __l, /* p q r s t u v w */ /*16m*/ __l, __l, __l, __l, __l, __l, __l, __l, /* x y z { | } ~ del */ /*17m*/ __l, __l; < = > ? */ /*07m*/ __d, __d, __p, __p, __p, __p, __p, __p, /* @ A B C D E F G */ /*10m*/ __p, __u, __u, __u, __u, __u .`.RB -@Jo >!/./ /./ N/H,ݮ ѭ   - o+m gU .`Jf ., __c, /* bs ht nl vt np cr so si */ /*01m*/ __c, __cs, __cs, __c, __cs, __cs, __c, __c, /* dle dc1 dc2 dc3 dc4 nak syn |g3?b3@D?dp`T>!/</ 4// N/|gT .`)G ,-@&L4 м' extern defs. * Modified 10/31/82 by MGL to add ___atab() for forced loading ************************************************, __l, __p, __p, __p, __p, __c }; ___atab() { } , __u, __u, /* H I J K L M N O */ /*11m*/ __u, __u, __u, __u, __u, __u, __u, __u, /* P Q R S T U V W */ /*12m*/ __u,`-gD>"/</ 4/-/ N/|g3?b3@D?dp`hU>!/</ 4/./ N/|g U .etb */ /*02m*/ __c, __c, __c, __c, __c, __c, __c, __c, /* can em sub esc fs gs rs us */ /*03m*/ __c, __c, __c, __c, __c, _dDJo@<fT , o)l .`6`< fRR` SRR`` , o)l .NqJL8N^NuNVH*n(n ..***************************/ #include "portab.h" #define CTYPE /* tells ctype.h who's boss */ #include "ctype.h" G __l, __p, __p, __p, __p, __c }; ___atab() { } /********************************************************************* * * f c l o s e F u n c t i o n * --------------4/-/ N/|g3?b3@D?dp`tU@ -+@ -"- S¼n&>!/</ 4/-/ N/e(sp->_fd)); /* and return */ } /****************************/ LLPTR, NULLPTR, 0}, { 3, 0, NULLPTR, NULLPTR, 0 }, { 4, 0, NULLPTR, NULLPTR, 0 }, { 5, 0, NULLPTR, NULLPTR, 0 }, to close */ { /* */ /****************************/ if( sp->_flag & (_IOREAD|_IOWRT) ) /* is it closeabHerein lie the data definitions for the stdio.h functions. * Note: function __fdecls() is here so _main can force this module t--------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "fclose" flushes a stream (buffered file)`>/ 4a XG4JoS` .NqJL8N^NuNVH*n>. 0SGJ@oB`JL N^NuNVH*n.. <.-GJo,  f0| .(sp->_fd)); /* and return */ } /****************************/  { 6, 0, NULLPTR, NULLPTR, 0 }, { 7, 0, NULLPTR, NULLPTR, 0 }, { 8, 0, NULLPTR, NULLPTR, 0 }, { 9, 0, NULLPTRle? */ { /* yup... */ fflush(sp); /* do the flush */ if( sp->_flag & _IOABUF ) /* was buf alloc'd? o * be loaded. * *****************************************************************************/ #define FILE /* avoid d and releases the * channel and any allocated buffers. * * Calling sequence: * ret = fclose(stream) * Where: * stream ->?NTHH.?NTS` .NqJL N^NuNVH*n 0.(@@ZG.?< NT<F> // aP*@ (sp->_fd)); /* and return */ } /****************************/ , NULLPTR, 0 }, { 10, 0, NULLPTR, NULLPTR, 0 }, { 11, 0, NULLPTR, NULLPTR, 0 }, { 12, 0, NULLPTR, NULLPTR, 0 }, */ free(sp->_base); /* free it ifso */ sp->_base = sp->_ptr = NULL; /* reset these */ sp->_cnt = 0; /* uplicate decls */ #include "stdio.h" #if MAXFILES != 16 compile snafu: fix following table #endif struct _iobuf _i file to be closed (FILE *) * ret = SUCCESS or FAILURE (if IO error) * *****************************************************/**************************************************************************** * * D a t a D e c l a r a t i o n s M o d u/ /./ N/H".g3?b3@D?dp` . . .ѭ - o+m Jf .`-gB>"/</ { 13, 0, NULLPTR, NULLPTR, 0 }, { 14, 0, NULLPTR, NULLPTR, 0 }, { 15, 0, NULLPTR, NULLPTR, 0 } }; __fdecls() */ } /* reset all flags */ sp->_flag &= ~(_IOREAD|_IOWRT|_IOABUF|_IONBUF|_IOERR|_IOEOF|_IOLBUF); return(closob[16] ={ { 0, _IOREAD, NULLPTR, NULLPTR, 0}, { 1, _IOWRT+_IONBUF, NULLPTR, NULLPTR, 0}, { 2, _IOWRT+_IONBUF, NU************************/ #include "stdio.h" WORD fclose(sp) /* CLEAR FUNCTION ***********/ REG FILE *sp; /* stream l e * ----------------------------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * { } offs,sense); sp->_flag &= ~_IOEOF; /* any seek clears EOF flag */ return( p==(LONG) FAILURE ? FAILURE : SUCCESS); } to seek on * offset = signed number of bytes * sense = 0 => offset from beginning of file * 1 => offset from current po#include "portab.h" LONG writel(fd,buf,lnum) /* CLEAR FUNCTION ***********/ WORD fd; REG BYTE *buf; /* addr */ LONG B@H@ѮJngSS n"nSn` .NqN^NuNVH >.HμgR*y@@(G@@.N|fp` NqJL0N^NuNVH/ WORD rewind(sp) /* CLEAR FUNCTION ***********/ FILE *sp; { return(fseek(sp,0L,0)); }  } /************************************************************************ * * r e w i n d F u n c t i o n * -----------sition * 2 => from end of file * ret = 0 for success, -1 for failure * *************************************************lnum; /* size */ { LONG R; REG UWORD tmp; R = lnum; while (lnum != 0) { tmp = (lnum < 32768L)? (int)lnum : 32/************************************************************************** * * f s e e k F u n c t i o n * ----------- WORD rewind(sp) /* CLEAR FUNCTION ***********/ FILE *sp; { return(fseek(sp,0L,0)); }  } ------------------ * Copyright 1982 by Digital Research Inc. All rights reserved. * * "rewind" sets the read/write pointer o****************************/ #include "stdio.h" WORD fseek(sp,offs,sense) /* CLEAR FUNCTION ***********/ REG FILE *sp;768; if (write(fd,buf,tmp) != tmp) break; buf += tmp; lnum -= tmp; } return(R-lnum); /* number of bytes---------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "fseek" sets the read/write pointer of a WORD rewind(sp) /* CLEAR FUNCTION ***********/ FILE *sp; { return(fseek(sp,0L,0)); } bf#?^`J(T` 2-Ёf T0(m T*`* 2,Ёf 0-l(`(#?^JL0N^NuNV .]-@ n0(=@f a stream file to the * beginning of the stream. * * Calling sequence: * ret = rewind(sp) * Where: * sp -> a stream fil LONG offs; WORD sense; { LONG p, lseek(); if ( fflush(sp) == FAILURE ) return( FAILURE ); p = lseek(fileno(sp), written */ }  stream to an arbitrary * offset. * * Calling sequence: * ret = fseek(sp,offset,sense) * Where: * sp -> (FILE *) stream one of drtwx flags required only one of abi flags allowed cannot create %s temp file write error seek error on %s Unable t> aV-@fB`.a@ .g~0. nd=n .d&-nJng n"nRRSn``< .B2.Ё-@0.H@e (FILE *) * ret = 0 for success, -1 for failure * *************************************************************************written */ } acter */ REG WORD ni; /* Input char */ BOOLEAN noassign, /* Suppress assignment flag */ invert, /* Inv1/84 whf fix "%1s" bug * 12/02/83 HY ??? *****************************************************************************/ #inclin input */ ungetc(ni,sp); /* back up once */ if( c == NULL ) /* check for this here */ break; /* --------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "_doscan" is the common subro8], /* Area for '[...]' sets */ *sb; /* Ptr into setbuf */ DOUBLE _atof(); /* */ /**************written */ } ert flag (_ismember) */ numfound, /* Number found flag */ longf, /* Long ptr flag */ shortf; /* Short ude "stdio.h" #include "ctype.h" #define INFINITY 32767 #define NXTNI(d) if( ((d)=getc(sp)) == EOF ) return(EOF) WORD _d */ } /* c points to non space */ /****************************/ if( c != '%' ) /* match spec chautine to "scanf", "fscanf", and * "sscanf". * * Calling sequence: * ret = _doscan(sp,fmt,aps) * Where: * WORD ret number**************/ nitems = 0; /* */ while( c = *fmt++ ) { if( isspace(c) ) /* if space in spec str */ ?B<>.,=:+-&/\|()[]*?Xptr flag */ REG WORD width; /* Max field width */ WORD tval, /* Temp val holder */ base, /* For nuoscan(sp,fmt,aps) /****************************/ REG FILE *sp; /* Stream ptr */ BYTE *fmt; /* Input format spr (non'%')?*/ { /* */ NXTNI(ni); /* grab from input */ if( ni != c ) /* & test */ { items matched AND assigned * EOF when encountered on stream sp * FILE *sp pointer to input stream * BYTE *fmt input spe { /* */ do{ /* deblank leading blanks */ c = *fmt++; /* */ } while( isspace(c) ); /* !!!!"meric conversion */ nitems; /* Number items mtchd & assd*/ LONG val, /* For numeric conversion */ locval; /ec ptr */ BYTE **aps; /* Argument ptrs ptr */ { /****************************/ REG BYTE c; /* Spec char/* */ ungetc(ni,sp); /* nope, put it back */ return(nitems); /* return early */ } /* cification string * BYTE **aps pointer to (pointers to) arguments * * Edits: * 3/15/84 sw Fix Atof / Nofloat problem * 1/1 */ do{ /* deblank input stream */ NXTNI(ni); /* */ } while( isspace(ni) ); /* read past space /***************************************************************************** * * _ d o s c a n F u n c t i o n * ----* Local value area */ BYTE locbuf[BUFSIZ], /* Local buffer area */ *db, /* Destination ptr */ setbuf[12*/ continue; /* yup, do the next char */ } else /****************************/ c = *fmt++; /* look for an '-' ) invert++; width--; NXTNI(ni); } val = 0L; /* initial value */ numfound = FALSE; /* assu*/ case 'x': base = 16; procnum: /****************************/ if( isupper(c) ) /* upper case means long assign */ nitems++; /* */ break; /****************************/ case 's': /* string input */ if( c == 'l' ) /* unless they say otherwise*/ { longf++; c = *fmt++; } else if( c=='h' ) ***/ ungetc(ni,sp); /* back off input */ if( numfound == FALSE ) /* was it there? */ return(nitems); /*assignment */ noassign = FALSE; /* assume we will assign */ if( c == '*' ) /* unless they say otherwise*/ me guilty til proven */ while( width-- > 0 ) { /* for each char ************/ tval = ni = toupper(ni); /* should work */ longf++; do{ NXTNI(ni); /* grab a char from input */ } while( isspace(ni) ); /* until non-blank */ case 'c': /* char input */ case '[': /* input 'one of' */ NXTNI(ni); /* grab a character { shortf++; c = *fmt++; } /****************************/ switch( c ) /* which conversion char? no, too bad */ if( invert ) /* leading minus? */ val = -val; /* */ if( longf ) /* store this { noassign++; c = *fmt++; } width = INFINITY; /* assume no special width */ while( c >= '0' && for numbers */ if( tval<'0' || tval>'F') break; if( tval>'9' && tval<'A') break; tval -= '0'; */ if( noassign ) db = &locval; /* got to put it somewhere */ else db = *aps++; /* like to put it here **/ if( c== 's' ) /* scan string **************/ { sb = " \t\n"; /* point set to white chars */ while(_ism */ { /****************************/ case 'D': /* decimal input */ case 'd': base = 10; goto pro value */ *( long *)db = val; /* somewhere */ else if( shortf ) /* */ *( short *)db = val; /* c <= '9' ) /* unless they say otherwise*/ { if( width == INFINITY ) width = 0; width = 10 * width + (c - '0' if( tval>9 ) tval = tval+('0'-'A'+10); if( tval >= base ) break; numfound++; /* is a number / invert = FALSE; /* assume pos number */ if( ni=='+' || ni=='-' ) { /* leading plus or minus */ if( ni ==em(ni,sb,FALSE)) /* keep reading whitespace */ NXTNI(ni); /* if there is any */ invert = TRUE; /* after, readcnum; case 'O': /* octal input */ case 'o': base = 8; goto procnum; case 'X': /* hex input somehow */ else /* */ *( int *)db = val; /* sometime */ if( !noassign ) /* increment only if ); c = *fmt++; } longf = FALSE; /* assume ptrs not to LONGs */ shortf = FALSE; /* and not to SHORTs */ val = base * val + tval; /* */ NXTNI(ni); /* next input, please */ } /* ****************** until whites */ } else if( c == 'c' ) /* scan char ****************/ { sb = ""; /* Null set */ if( ni != '.') && (ni != 'e') && (ni != 'E') && (ni != '-') && (ni != '+')) break; NXTNIented **********/ case 'e': case 'F': case 'f': if( isupper(c) ) /* upper case means long */ lonreturn( invert ? !rv : rv ); /* return (maybe inverted) #*/ } /****************************/ here to pt */ else db = *aps++; /* o.w. grab the desired ptr*/ while( width-- > 0 && _ismem(ni,sb,invert) ) { /****************************/ MLOCAL WORD _ismem(c,set,invert) /* is_member of a set */ BYTE c; /* candidawidth == INFINITY ) /* handle default width */ width = 1; invert = TRUE; /* invert "_ismem" func */ } els(ni); } ungetc(ni,sp); *--sb = '\0'; if (longf) *(double *)db = _atof(setbuf); else *(float *)db =gf++; do { NXTNI(ni); /* grab a char from input */ } while( isspace(ni) ); /* until non-blank */ if( noreturn( invert ? !rv : rv ); /* return (maybe inverted) #*/ } /****************************/ *db++ = ni; NXTNI(ni); } ungetc(ni,sp); /* we've always read 1 past */ if( c != 'c' ) /* not char type? te for set element*/ BYTE *set; /* null terminated string */ BOOLEAN invert; /* invert sense of function */ { e /* scan set *****************/ { /* must be a '[' */ invert = FALSE; if( (c = *fmt++) == '^' ) /* i (float) _atof(setbuf); if (!noassign) nitems++; break; case '%': default: NXTNI(ni); if(assign ) db = &locval; /* got to put it somewhere */ else db = *aps++; /* like to put it here */ sb = set/**************************************************************************** * * _ f i l b u f F u n c t i o n * ----- */ *db = NULL; /* then null terminate */ if( !noassign ) nitems++; /* successful assignment */ /****************************/ REG WORD rv; /* temp return val */ rv = strchr(set,c); /* look for c in set */ nvert "_ismem" ??? */ { invert = TRUE; c = *fmt++; } for( sb=setbuf; c != NULL && c != ']'; sb+ ni != c ) /* must match c */ { ungetc(ni,sp); return(nitems); } break; } /***** end swibuf; /* setup up addr to hold string */ while (width-- > 0) { *sb++ = ni; if ((ni < '0' || ni > '9') && (-------------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "_filbuf" function is called bbreak; /****************************/ /****************************/ case 'E': /*********** not fully implem return( invert ? !rv : rv ); /* return (maybe inverted) #*/ } /****************************/ +, c = *fmt++) *sb = c; *sb = NULL; sb = setbuf; } if( noassign ) db = locbuf; /* give rtn somewtch ***********/ } /***** end while loop *******/ return(nitems); /* */ } /****************************/ y getc to fill the buffer. * It performs any initialization of the buffered on the first * call. * * Calling sequence: * c = read(sp->_fd, sp->_base, /* read to our buffer */ sp->_flag & _IONBUF ? 1 : BUFSIZ); /* the right # of bytes */ || /* is the No Buf flag set? */ (sp->_base=malloc(BUFSIZ))==NULL) /* can't we get buffer? */ sp->_flag |= _IONBU/********************************************************************** * * _ c l e a n u p F u n c t i o n * ---------oc(); /* someplace to get mem */ /****************************/ if((sp->_flag & _IOREAD) == 0) /* is readable fi } /****************************/ har = _filbuf(stream) * Where: * stream -> file info * char = the first character returned, or FAILURE (-1) * on error if( sp->_cnt <= 0 ) /* did read screw up? */ { /* yup...********************/ if( sp->_cnt == FAILURE ) /*F; /* set No Buf flag */ else sp->_flag |= _IOABUF; /* we're all set */ } /****************************------------------------ * Copyright 1982 by Digital Research Inc. All rights reserved. * * "_cleanup" closes all buffered fle? */ return(FAILURE); /* no */ if( sp->_flag & _IOSTRI ) /* is this stream a string? */ { /* yes: } /****************************/  or EOF * *****************************************************************************/ #include "stdio.h" #define CMASK really bad? */ sp->_flag |= _IOERR|_IOEOF; /* say so */ else sp->_flag |= _IOEOF; /* or just say / if( sp->_flag & _IONBUF ) /* insure this set right */ sp->_base = &onebuf[sp->_fd]; /* set 'buf' to small buf */ iles * * Calling sequence: * _cleanup() * ***************************************************************************/ handle EOS as EOF*/ sp->_flag |= _IOEOF; /* */ return(FAILURE); /* */ } /****************************/} /****************************/ 0xFF WORD _filbuf(sp) /* fill buffer */ REG FILE *sp; /* from this stream */ { /***********************we can't read*/ return(FAILURE); /* */ } /****************************/ sp->_cnt--; /* take the 1st iteif( sp==stdin && (stdout->_flag&_IOLBUF))/* console i/o? */ fflush(stdout); /* output whatever to con */ sp->_cnt#include "stdio.h" _cleanup() { REG WORD ii; for( ii=0; ii_base == NULL ) /* has this been done? */ { /* no...*********************/ if( sp->_flag & _IONBUF *****/ static BYTE onebuf[MAXFILES]; /* a place if no mem avail. */ /* small buf for ungetc */ EXTERN BYTE *mallm */ sp->_ptr=sp->_base; /* set up stream */ return(((WORD)(*sp->_ptr++) & CMASK)); /* and return the char */ LEAR termination routine */ }  /*--------------------------*/ p = digs; b = base; if (signed) if ((int)n < 0) { n = -n; *(*pbuf)++ = '-'; in a stream to be written out * to the file. The stream remains open. * * Calling sequence: * ret = fflush(stream) * Wherbase; WORD signed; BYTE *digs; { /* 05/27/83 - changed to do divide in short (HY) */ /* 08/11/83 - changed to handle EAR termination routine */ }  } while (n != 0) { *p++ = n % b; n = n / b; } return (p); } e: * stream is a (FILE *) * ret = SUCCESS or FAILURE (I/O error) * * 9/83 fix fseek(stream,xx,1) bug whf * ***********68K arg passing (as longs) (WHF) */ REG UWORD n; REG BYTE *p; REG WORD b; #if HILO /*--------------------------*/ EAR termination routine */ }  } while (n != 0) { *p++ = n % b; n = n / b; } return (p); } ******************************************************************/ #include "stdio.h" WORD fflush(sp) /* CLEAR FUNCTIO LONG ln; /* declare a placeholder */ /* */ ln = *pobj; /* assign arg to long */ n = ln & 0xFFF/**************************************************************************** * * f f l u s h F u n c t i o n * ------- } while (n != 0) { *p++ = n % b; n = n / b; } return (p); } N ***********/ REG FILE *sp; /* stream to flush */ { /****************************/ REG WORD n, /* num writtenFL; /* then to WORD */ #else /*--------------------------*/ n = *pobj; /* assign arg to WORD */ #endif ---------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * 'fflush' causes any buffered data #include "portab.h" #include "osif.h" BYTE *__prtshort(pobj, pbuf, base, signed, digs) WORD *pobj; BYTE **pbuf; WORD */ ns; /* num sposed to be written */ /****************************/ if((sp->_flag&(_IONBUF|_IOWRT))==_IOWRXN x>/<)?9*N6\<|g.*/<*NXN x y`)g$ y`)g.*/<*NXN x.*/<************************/ 1 WORD) o.w. * *****************************************************************************/ #include "stdio.h" WORD fpase != NULL ) /* written to already? */ { /* */ if(sp->_flag&_IONBUF) /* is this a nobuf stream? */ /************************************************************************ * * f p u t n F u n c t i o n * -------------T /* does it have a wrt buf? */ && (ns=(WORD)(sp->_ptr-sp->_base)) > 0)/* and does buf need wrt?*/ { /* yes! NX 9)й*й*-@.)ap.,?<+N T.*aT.,?<+N T.*a8.,?<=N T.a.***********************/ utn(buf,num,sp) /* CLEAR FUNCTION ***********/ REG BYTE *buf; /* chars to be written */ REG WORD num; /* num chars sp->_cnt = 1; /* yes */ else sp->_cnt = BUFSIZ-1; /* standard size */ } /* */ } else { /* i-------------- * Copyright 1983 by Digital Research Inc. All rights reserved. * * 'fputn()' writes 'n' chars to a buffered f */ n=write(sp->_fd,sp->_base,ns); /* do it */ if(ns!=n) /* did they all git writ? */ { /* oooops */N.a.*N.*a.,?< N T y`)fb>/Y?9*N6\.*N.aJ>/Y?9*N6\.**********************/  to be written */ REG FILE *sp; /* stream to write to */ { /****************************/ if( sp->_flag & _IONBs a readable file */ lseek(sp->_fd,(LONG) -(sp->_cnt),1);/* back up cur position ptr */ sp->_cnt = 0; /* zap oile. It optimizes * for 'non-buffered' (_IONBUF) output. * * Calling sequence: * rv = fputn(cp,n,stream) * Where: * cp sp->_flag |= _IOERR; /* this stream no good */ return(FAILURE); /* let em know */ } /* */ } *N.a".,?< N TRG`JLN^NuNVH*|*nB%BG|l2 .<| l|0`|7 .-@JgRG`./Bg/9*N\3*l.*/<*tNUF ) /* Non-buffered file? */ { /* */ sp->_cnt = 0; /* Always force to zero */ if(num!=write(sp->_fut count */ } /* */ sp->_ptr=sp->_base; /* reset buf */ return(SUCCESS); /* */ } /*****-> chars to be put * n = num chars to be put * stream -> where its going (FILE *) * rv = SUCCESS if write ok, FAILURE (- /****************************/ if( sp->_flag & _IOWRT ) /* is this a writable file? */ { /* */ if( sp->_b*NXJL N^NuNVH*|*nB%BG| l, . H@H<|0 . H-@JgRG`./<*NXJL N^NuNV>?. d,buf,num)) /* try to write */ { /* no good */ sp->_flag |= _IOERR; /* mark this file */ return FAI*****/ REG BYTE *str; /* null term string */ REG FILE *sp; /* stream file pointer */ { /******************------------ * Copyright 1982 by Digital Research Inc. All rights reserved. * * "fputs" copies a null terminated string to a0-gJ0o.-0Sg-gF>"/</ 4/-/ N$|g3-3--p`U>!/<n FAILURE; /* no good */ return SUCCESS; /* everything a-ok */ } /****************************/ return(rv); /* it worked */ } /****************************/ LURE; /* and complain */ } /* */ return SUCCESS; /* */ } /****************************/ **********/ REG WORD rv; /* return val */ rv = NULL; /* init for *s==NULL */ while(*str) /* for all char stream file. * To be compatible with Unix, it does NOT append a newline. * * Calling sequence: * ret = fputs(s,stream) * / 4// N$|g3-3--p`V+G -+@I4Gd gR` " Ҽ4ѭ`B` -0+@+m N^NuNVH /<-?.?./ /. nN*@-fB(n -g%H| lp0`p7@`B NqJL0N^NuNVH*n<.0`<>/.?N f\J@g>N%3#-3--p`U0NqJL N^NuNVH>N$.*@ fp`d0.`4+n `> . ѭ`4 /* */ while(num--) /* Buffered output */ if( FAILURE==fputc(*buf++,sp)) /* try to put in buf */ retus in s */ if((rv=putc(*str++,sp))==FAILURE) /* if putc fouls up */ return(FAILURE); /* give up */ Where: * ret = last char out, on error FAILURE * s = string to put * stream -> stream (FILE *) * **********************/******************************************************************** * * calloc.c - memory allocator for sets of elements * H n. nfzJgJEg SE``j nf&z JgJEg SE`JEf-`NT+@ - Ю +@`p`,`J@gȰ|gʰ|g`UJl+| -NqJL N^NuNV>B?.af\NqN^NuNVH>Nrn FAILURE; /* no good */ return SUCCESS; /* everything a-ok */ } /****************************/  return(rv); /* it worked */ } /****************************/ *******************************************************/ #include "stdio.h" WORD fputs(str,sp) /* CLEAR FUNCTION ******zalloc - memory allocator like malloc only zeros storage. * * BYTE *calloc(nelem,sizelem) * UWORD nelem, sizelem; * * Ret/************************************************************************** * * f p u t s F u n c t i o n * ---------------$.*@ fp`~0|gB`p.?< NT<-H@g-HH.?< NT.?<#NT-H@g0F.?< NT <n FAILURE; /* no good */ return SUCCESS; /* everything a-ok */ } /****************************/ return(rv); /* it worked */ } /****************************/ urns a pointer to a region of (zero filled) memory large * enough to hold 'nelem' items each of size 'sizelem'. * Returns NULLf./ / atP`d-EBJoX ,-@B ,gN,gF>"/</ 4/,/ N$|g3-3--pe = sizelem*nelem; #if I8086 if( size > 65535L ) return NULLPTR; #endif return zalloc((UWORD)size); } _IOREAD|_IOWRT); /* not marked rd/wrt */ ii++ ) /* */ if( ii >= MAXFILES ) /* if off end of table */ nbytes)) == NULLPTR) return(NULLPTR); blkfill( rp, NULL, nbytes ); return(rp); } BYTE * calloc(nelem,sizelem) /* CLEARmode = "r" for read-only, "w" for write, "a" for append * ****************************************************************** if not enough memory, or allocation too large * (on 8086). * * BYTE *zalloc(nbytes) * UWORD nbytes; * * Returns a pointe/*************************************************************************** * * f d o p e n F u n c t i o n * -------- `H n(g*  f$ n(gHH.?<NT n(gHH.?<NTp`l ` <*E. break; /* */ if( ii >= MAXFILES ) /* */ return(NULLFILE); /* fail */ if( *mode != 'r' && *mod FUNCTION ***********/ UWORD nelem, /* number of elements */ sizelem; /* size of element */ { REG LONG size; si***********/ #include "stdio.h" FILE * fdopen( fd, mode ) /* CLEAR FUNCTION ***********/ REG WORD fd; REG BYTE *mode; r to a region of zero filled memory nbytes long. * Returns NULL if not enough memory. * *************************************--------------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "fdopen" associates a file which wa?< NT.HH̼l0| .?<NTGJoJo fU `SS`Jo R "ҼNqJL8N^NuNVHe != 'R') /* not 'r'ead mode? */ { /* */ sp->_flag |= _IOWRT; /* set this flag */ if( *mode == 'a' ze = sizelem*nelem; #if I8086 if( size > 65535L ) return NULLPTR; #endif return zalloc((UWORD)size); }  { REG FILE *sp; REG WORD ii; /****************************/ if( fd<0 || lseek(fd,0L,1)==FAILURE ) /* is fd valid? ********************************/ #include "portab.h" #include "osif.h" BYTE * zalloc(nbytes) /* CLEAR FUNCTION ******s opened by a file descriptor * (using "open" or "creat") with a stream. * * Calling sequence: * stream = fdopen( fd, mode *n B:.>N$.(@ fp`JnB@`,g3 -3--p`,g>// aP`,g>// aP`|,|| /* 'a'ppend mode? */ *mode == 'A' ) /* */ lseek(fd,0L,2); /* its out there, seef EOF */ } /* e = sizelem*nelem; #if I8086 if( size > 65535L ) return NULLPTR; #endif return zalloc((UWORD)size); }  */ return(NULLFILE); /* no, oh well */ for( ii=0; /* look at _iob table */ (sp=(&_iob[ii]))->_flag&(*****/ UWORD nbytes; /* number of bytes */ { REG BYTE *rp; /* pointer to region */ BYTE *malloc(); if( (rp = malloc() * Where: * stream -> stream info (FILE *) (NULLPTR returned on fail) * fd = small int returned by open or creat * ************************/ else sp->_flag |= _IOREAD; /* 'r'ead mode */ /****************************/ sp->_cn------------- * Copyright 1982 by Digital Research Inc. All rights reserved. * * "ftell" returns the present value of the ree(`&M00-G7@&(;G#- \`-f>a*@ fB`(M*T`JL8N^NuNVH >.|?GG0>N(f*@f return((LONG)FAILURE); /* quit if bad lseek */ if( sp->_base == NULLPTR ) /* if file hasn't had i/o */ r*******/  REG BYTE *bp; /* Buffer ptr */ LONG nread; /* Temp var */ LONG lseek(); /* byte offset into buf */t = 0; /* init count */ sp->_fd = fd; /* and file des */ sp->_base = sp->_ptr = NULLPTR; /* and buffer poiad/write pointer * within the stream. This is a meaningless number for console * and list devices. * * Calling sequence: *B` R*@(M9G.\a 9-NqJL0N^NuNVH *n](y-ceeebf#-`J(T` 2-Ёf T0(meturn(filepos); /* return this position */ nread = sp->_ptr - sp->_base; /* calc for # read/written */ filepoTJo.?<NT+G0x.?NTJ@g>|o89-Bp d`BD-Hng0n.?< NT 2HЁ`@0Hހ0H0H /* */ if( isatty(fileno(sp)) ) /* are we talking to a tty? */ return(0L); /* quit now if so */ filepnters */ /****************************/ return(sp); /* return the stream ptr */ } /******************** offset = ftell(sp) * Where: * sp -> (FILE *) stream * offset = (LONG) where stream is reading from/writing to * ******* T*`* 2,Ёf 0-l(`(#-JL0N^NuNV .]-@ n0(=@> aV-@fB`.a@ .g~0. s += nread; /* correct for # read/wrtn */ if( sp->_flag & _IOREAD ) /* if reading from file */ if( fileposր0@H`v-Hng0n.?< NT NqJL0N^NuNVH|BG|l -f -0`RG`3-3--pNqJLos = FAILURE; /* default return value */ if( sp->_flag & (_IOREAD|_IOWRT) ) /* if file is open */ { /* *********/ ***********************************************************************/ #include "stdio.h" LONG ftell(sp) /* CLEAR FUN/*********************************************************************** * * f t e l l F u n c t i o n * -------------- > 0 ) /* and we've read from file*/ filepos -= nread + sp->_cnt; /* adjust file position */ /* to reflect reaN^NuNVH>.p2`F@H-B@NqJLN^NuNVH>.ZGB0>RGJ-f <- #-#- By-(y-*Tmb60X@m/ if((filepos=lseek(fileno(sp),0L,1)) /* get where next byte read */ == FAILURE ) /* from or written to */ *******/ CTION ***********/ REG FILE *sp; /* stream pointer */ { /* */ REG LONG filepos; /* file position */d ahead */ if( sp->_flag & _IOASCI ) /* ascii file? **************/ { /* count the newlines */ ifsole, and * translates the command line to lower case. Then it calls "__main()". * There are two versions of "__main()" (one ORD len; /* Command length */ { /****************************/ REG BYTE *s; /* Temp byte pointer */ r newlines */ filepos--; /* */ } /* */ } /* fini ascii ***************/ } /******" /* Include std definitions */ #include "osif.h" /* */ #include "ctype.h" /* */ EXTERN BYTE __tname[( sp->_flag & _IOWRT ) /* add in newline's cr's */ { /* */ for( bp=sp->_base; bp < sp->_ptr; bp++ ) /* compiled for wildcards * and the other compiled without) compiled from the source module * "XMAIN.C". * * Calling Sequence: /***************************************************************************** * * R U N T I M E S T A R T O F F R O U T /****************************/ _chinit(); /* Initialize channels */ open(__tname,READ); /* Open STDIN */ op**********************/ return(filepos); /* */ } /****************************/ ]; /* Name of terminal device */ EXTERN BYTE __fdecls(); /* force loading of _iob */ EXTERN BYTE ___atab(); /* force */ if( *bp == '\n' ) /* count newlines in stuff */ filepos++; /* written/read so far */ } else { * return = _main(command,length); * * Where: * command Is the address of the command line from CP/M * length Is the nuI N E * ----------------------------------------------- * Copyright 1982,83 by Digital Research Inc. All rights reserved. *en(__tname,WRITE); /* Open STDOUT */ open(__tname,WRITE); /* Open STDERR */ com[len] = NULL; /* Insure null *********************/ return(filepos); /* */ } /****************************/  loading of ___atab */ #define STDIN 0 /* file descriptors */ #define STDOUT 1 /* */ #define STDERR 2 / /* we're reading... */ if( filepos > 0 ) /* check to see we've read */ for(bp= &(sp->_ptr[sp->_cnt-1]);mber of characters in the line, * excluding the termination character (CR/LF). * * Modfications: * 11-Oct-83 whf conve * Routine "_main" is entered from the C header routine to start a C * program. It opens STDIN, STDOUT and STDERR to the conat line end */ for (s = com; *s; s++) /* Convert string to */ *s = tolower(*s); /* lower case */ __m*********************/ return(filepos); /* */ } /****************************/ * */ /* */ _main(com, len) /****************************/ BYTE *com; /* Command address */ W/* start at end of buffer */ bp >= sp->_ptr; bp-- ) /* back up to next read char*/ if( *bp == '\n' ) /* count off forted to DRC from CPM68K * *****************************************************************************/ #include "portab.hain(com,len); /* Do rest (replaceable) */ } /****************************/ in(com,len); /* Do rest (replaceable) */ } /****************************/ in(com,len); /* Do rest (replaceable) */ } /****************************/ B[b#5E?/ NN o AdpNu#5BNuNV0/"/ NB5d0< A-x"NB0<NBN^Nu o2/0/ 9//0.@>Wa>WaN^NuNVJnm n n.1?.W0N0T`. n m nn.1?.W7N0T`N\|g.//</NXNBy-BWB?9-N>\a JL N^NuNVH*|-BG|l.-N,:RG` y`-gn y`-HSoQBNu o0/JfBNuf SNuNVH nm noaB~ n h -fRy/RG n 2G.aN^NuNV.0KNNN^Nup "<0zNBBNBNVHN%4BW/<-NX>/<-NX>/<-NX-|- n2n fJ.-N,3/.-N,3/.-N,3/.-N,3/`.//<0NXNJL N^NuNVBW/. n ?N-^3/3/3-y-#-/B .l .-N,>>ahT/T` y`-f y /gBWaB`#//-y aXXB=|*nJgJgHHм2 @gR`JgBG M2GJgJ5pHHм2 @f45pHHм2 @g 5pH| `5pHN>\Jl.//<0.NXN n BhN^NuNVH>. y /fJB9/Jy/g .0EN>$a>/a`.0HN-B .l .-N,>>a T/T`Jy/fF y`-f y /gBWa`#//-y-JoBWaUT/`-x bBN+V`FC Runtime V01.11, Copyright(c) 1983, Digital Research XXXX-0000-654321 o#5"h&I"M4GRG`J5pg M2GBRG f0>NBWBg/ RN6\|g.R/<0>#ap>/aF>aBUy/Jy/f*9/HD>SWaD.1?< N0T3 /JLN^NuNV0.@>Wa>WaN^NuNV0.` y /gBWa`./NJLN^NuNVH*n>Bg/ N-@\3-l./</NXN#/>/<-?9-NaXX` N2n!MRn` N2n!|.?.NT>NJL N^NuNV.N*>>/.?<Nj\. N R D.Jg./N*dX. 93*` NqJL N^NuNVH*n<.H n0H.JngJl D. n P-"n R`μJg./`l`|C|5b@0@0 PN.N*>=@0.nl Jnm=n0.n=@J.fZ .0f, n -f"Sn. nH?N0T@g0G.?< NT|f32352p`>N%V>N'xB@NqJL N^NuNVBW?. /.a:\NqN^NuNVBW?. /.a"\NqN^?< // N x J.gp`pH`R.J.g < ` < #5.5Bg?< // N x J.gp`pH`H"mR`-gA+H +@ mR-gz>/-?Nj\<Bm `n-g>< g -мb" -:>/-*>>/. ?<Nj\>/<0?<Nj\>NN^NuNV. /./<1NPNqN^NuNVH*nBn n HR JgN*dX. 93*` NqJL N^NuNVN>NN^NuNVHBG|l0м1.NPRG`JLN^NuNVH*n0-|RRn0.SnJ@o..H?N0T`Rn0.SnJ@o. nH?N0TR`Rn0.SnJ@o..H?N0T`RnNuNV>?. /.a\NqN^NuNVHN',>JGlp`>N%V0*@5JnfU.-/.N*XJ@f U0`\`.-/.R.J.g < ` < #5.5Bg?<// N x J.gp`pH`JR.J.g < ` < #5.5Bg?<?Nj\<+mBm `( -:>/-?Nj\<;| +mFg mp` H|NqJL N^NuNVH>N%*@ fp`<%g.H?N0TRn`B. n H|-@R Df n R R.| <0fG n R =|<*f-M n=PT ng*.N-g .N(B@H+@+@Bm m>NNqJL N^NuNVH*n0-| |f. -<JFo >/-?Nj\>`l0.NqJL N^NuNVH /<5?.?./ /. nN*@5fB(n 5g%H| lp0`p7@`B NqJL0N^NuN*XJ@fU0`<>/.?N!\J@g>N'x3#2352p`U0NqJL N^NuNVH>N%*@ fp`d0.`4+n // N x J.gp`pH`-M n-PX`-M n0|@B.T`>// NPX=|`>/H0|g>N%V>N'xB@`&-g:-f2 - l>B?.N>\>/<-?.Nj\-gB>"/</ 4 R `8<0m2<9n,JnlBnH2. A|=@ n R `=|<.fBn n R <*f-M n=PT n R `.<0Gg mp`4-gJg-g;| `;| `Bm +mB@NqJL N^NuNVH. *n Sm mH"m|R``.H?NVH*n<.H n. nfzJgJEg SE``j nf&z JgJEg SE`JEf-` . ѭ`4>N+@ - Ю +@`p`,`J@gȰ|gʰ|g`UJl+| -NqJL N^NuNV>B?.af\NqN^NuNV/ NPX=|`>// NP.N*>2.^AAo>// NPX=|`4.H?N0TRn/-/ N&|g32352p`.?< NT>-H@g-HH.?< NT.?<NT<-Hm(<9n"H2. A|=@ n R `B.<lg<LfR. n R A-HH`0R.J.g < ` < #5.5?<NxTNqJL N^NuNVH. *n BF:-fp`&-fTJfN>N'+@+@fm`2m>N$J@gm@`;| H>N%*@ fp`~0|gB`p.?< NT<-H@g-HH.?< NT.?<#NT-H@g0F./ 4/./ N&|g U .`.+n߭ - o+m G4JoS` .NqJL8N^NuNVH*n(n ..-)l .NqJL8N^NuNVH*n(n ..-G --@ -g -g-gF>"/</ 4/-/ N&|2352p`tU -"- S¼nD>!/</ 4/./ N&|g32352p``>/ \J@g>N'x32352p`2U>B-H?N>\BWB-H?N>\0NqJL N^NuNVH*n B:.>N%(@ / aP`|,f./ / atP`d-EBJoX ,-@B ,gN,gF>"/</ 4/,/ N&|g3?< NT <0-gJ0o.-0Sg-gF>"/</ 4/-/ N&|g32352p`gA-H n(g.?<NTp`J n(g&L.?<NT n(Hf >N n(g Ag32352p`U>!/</ 4/./ N&|g32352p`~+n&M -4 м4a X+n&M -4 мd JoS`Jn$U@ .ѭ - o+m .`>"/</ 4/./ N&fp`,gB@`x,g3 2352p`X,g./ / NP`>,f./ / a6P`&-EJo.,g2352p`T ,", S¼n$>!/</ 4/./ N&)n ,-@&L4, мU>!/</ 4// N&|g32352p`V+G -+@I4Gd gR` " Ҽ4ѭ`B` -m Zn H| `H n(g*  f$ n(gHH.?<NT n(gHH.?<NTp`l `dJo SR`Jf - o+m .`.RB -@Jo >!/./ /./ N&H,ݮ ѭ   -|g32352p`fR -@Job -m .Юo U+|>"/./ /./ N&H".g,gF>"/</ 4/,/ N&|g32352p`T>!/</ 4// N&|gT .d"Jo  f < g< `SR` мe4>"/</ 4/./ N&|g .`$`T@Jf , o)l .0+@+m U -NqJL8N^NuNVBW?. /.a:\NqN^NuNVBW?. /.a"\NqN^NuNV>?. /.a\NqN^NuNVHN',>JGl <*E.?< NT.HH̼l0| .?<NTGJoJo fU `SS`Jo R "ҼNqJL o+m gU .`Jf .`-gD>"/</ 4/-/ N&|g32352p`hU>!/<32352p` . . .ѭ - o+m Jf .`-gB>"/</ 4/-/ N&|g3`)G ,-@&L4 мdDJo@<fT , o)l .`6`< fRR` SRR`` , o``JL8N^NuNVH*n(n ..-G --@ -gj -g-gF>"/</ 4/-/ N&|g3p`>N%V0*@5Jn fUJnfU.-/.N*XJ@f U0``.-/.N*XJ@fU0`f>/.?N!8N^NuNVH*n B:.>N%(@ fp`JnB@`,g3 2352p`,g>// aP`,g>/2352p`tU@ -+@ -"- S¼n&>!/</ 4/-/ N&`>/ 4a XG4JoS52pNqJLN^NuNVH>.p2`F@H2B@NqJLN^NuNVH>.ZGB0>RGJ2f <2#2#2By2(y2*T*@50.@BU+|BB B-I мd ` м0dB`JL0N^NuNVH>.|e3 2352B@`0R3Sy3. HNqN^NuNVH><y333#33>/93?93Nj\Ggp`B@NqJLN^NuNVH*n BmJnfB@,H@g,HH.?< NT.?.NT>,H@g0F.?< NT ng nf0`|nB@`pNqJL8N^NuNVH *nSn` .NqN^NuNVH >.HμgR*y5(G5.N|fp` NqJL0N^NuNVH *n(MJgR` NqJL0N^Nu` .NqJL8N^NuNVH*n>. 0SGJ@oB`JL N^NuNVH*n.. <.-GJo,  f0| .?NTHH.?NTS`оmb60X@me(`&M00-G7@&(;G#2 \`2f>a*@ fB`(M*T`JL8N^NuNVH >.|?GG0>N0*@5-f3 2352B@` NqJL N^NuNVH? *n.. (n,.:.B.?< NT=@-Hng-H`p=@>Bg/.N-@\:NqJL N^NuNVH*nJmnA+H>/-?N\;@Jmnp`Sm mH|RNqJL N^(n >.Jg.JGg*HHм2 @g H|`HRSG`JL0N^NuNVH *n(n >.Jg"H>/92NXJf JGgSG`NVH..,. Jf#3* <`Jc #3*B` // aP*@ :f6./ / aP|fp`)*@fB` R*@(M9G.\a 92NqJL0N^NuNVH *n](y2ceeebf#2`J(T` 2-ЁH.?< NTJo.?<NT+G0x.?NTJ@g>|o895Bp d`BD-Hng0n.?< NT 2HЁ`@0NuNVH*n.a>|fp`4<|F.a~>|fp`0|@g <@0NqJL N^NuNV>?. /.N\NqN^NuNVHB NqJL0N^NuNVH*n(n &nBGHHм2 @g H@|G`Jg*HHм2 @g H|`H|RJf *n(n JfJg&H>a,H>a"op`lp``B@NqJL0N^NuNVH. <am <zn< HNqJLN^NuJg .l> /R/ aP*@ *f>?<?/ RN\R>/ R/a.PJg .gp` .fN> // aTP*@ *f>f T0(m T*`* 2,Ёf 0-l(`(#2JL0N^NuNV .]-@ n0(=@> aV-@fB`.a@ .Hހ0H0Hր0@H`v-Hng0n.?< NT NqJL0N^NuNVH|BG|l 2f 20`RG`323>.0NqJLN^NuStack Overflow$C runtimeCON:LST: -op`B@NqJL8N^NuNVH>N%*@ fB@`-fB@`pNqJL N^NuNVHBG|l>aRG`JLN^NuNVH 0.NuNV y3n*>/ ?<Nj\|gp`b. H`ZJy3n4#33>/93?93Nj\|gp`&33 y3 ?<?/  N\>/  /aP nfH>?/ RNXJgp`,H@g,HH.?< NT.?<NTg~0. nd=n .d&-nJng n"nRRSn``< .B2.Ё-@0.H@B@H@ѮJngSS n"n2<>.,=:+-&/\|()[]*2!!!!"en_opena_openb_read__rdbinz__ttyin_writej__chrout!__wrtbint__cleadfile [>outputfile] C RTL -- Program not linked for floating point $Cannot open Cannot create < N/_noclear/_main_usagej_openfil_outword_readhdr*_longsee_hexby_hexwdCP/M-68K(tm), Version 1.2, Copyright (c) 1983, Digitalr!v___open!_isatty$__chinit%4___chini%V__chkc%__blkio&__chvec2_allocc',_freec N N N N N N N N N N N N : N N N N N N N N N N @ N_outhexnofloat_petoa_pftoa__main__err>_printf__doprt___prtin x__exit__break5__start___cpmrv5__base5_brk___BDO Research XXXX-0000-6543213'x_malloc'_free(_realloc)(_sbrk)_errno2__errcpm2___atab2_strlen*>_uldivr N N N N N N N N N N N N >  ___prtld ___prtsh _exit__cleanu_fcloseP_fflush_fputc0__flsbufx__iob1_c S903S_fill__index___pname-___tname-___lname-___xeof-_couthd-_ibuf-_ifilnam3*_uldiv*d__strcmp*_sw_+V_fout3_xputcha+f_myflush+_xfopen,L_xgetc,_xgetw lose_creat6__creat_creataN_creatbf_lseek>_tell__filesz_open__op0000FC unable to open %s read error on file: %s file format error: %s seek error on file %s S2S1Usage: sendc68 [-] comman/_datasta/_bssstar/_loctr/_pflg/_bcnt/_cksum/_syno/_ofn/_ofd,_xopen-@_dup-^_symptr5__fds5lo68 -r -o $1.68k s.o $1.o $2.o $3.o $4.o $5.o $6.o $7.o $8.o $9.o clib libe.a lo68 -r -unofloat -o $1.68k s.o $1.o $2.o $3.o $4.o $5.o $6.o $7.o $8.o $9.o clib