Browse Source

v2.30

* Minor bug fixes, cosmetic improvements and portability improvements
 * Added support for compiling on MVS (IBM mainframe)
tags/v2.30
Jon Foster 3 years ago
parent
commit
d79fbd4064
24 changed files with 545 additions and 9 deletions
  1. +11
    -0
      allbwb.bat
  2. +1
    -1
      bwb_dio.c
  3. +1
    -1
      bwb_fnc.c
  4. +2
    -1
      bwbasic.c
  5. +29
    -4
      bwbasic.h
  6. +9
    -0
      bwbasic1.jcl
  7. +35
    -0
      bwbasic2.jcl
  8. +4
    -0
      bwbasic3.bat
  9. +22
    -0
      bwbasic3.m4
  10. +32
    -0
      bwbasic4.jcl
  11. +64
    -0
      bwbasic5.jcl
  12. +33
    -0
      bwbasic6.jcl
  13. +23
    -0
      bwbasic7.jcl
  14. +14
    -0
      bwbmvs.txt
  15. +2
    -1
      bwx_iqc.c
  16. +1
    -0
      bwx_ncu.c
  17. +2
    -1
      bwx_tty.c
  18. +25
    -0
      compile.bat
  19. +1
    -0
      renum.c
  20. +3
    -0
      stdcomp.bat
  21. +9
    -0
      subjobs.bat
  22. +170
    -0
      unixio.c
  23. +41
    -0
      unixio.h
  24. +11
    -0
      zipall.bat

+ 11
- 0
allbwb.bat View File

@@ -0,0 +1,11 @@
rem this is the name of the patch file
set bwbname=bwb1

rem rm -fr bwbasic
rem md bwbasic
rem cd bwbasic
rem unzip ..\%bwbname%
rem chmod -R 666 *
call zipall
call bwbasic3
call subjobs

+ 1
- 1
bwb_dio.c View File

@@ -1009,7 +1009,7 @@ bwb_kill( l )
/* try to delete the specified file */ /* try to delete the specified file */


str_btoc( atbuf, &( e->sval ) ); str_btoc( atbuf, &( e->sval ) );
r = unlink( atbuf );
r = remove( atbuf );


/* detect error */ /* detect error */




+ 1
- 1
bwb_fnc.c View File

@@ -39,7 +39,7 @@
#include "bwbasic.h" #include "bwbasic.h"
#include "bwb_mes.h" #include "bwb_mes.h"


#if UNIX_CMDS
#if HAVE_SYSSTAT
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif




+ 2
- 1
bwbasic.c View File

@@ -51,7 +51,7 @@
char *bwb_ebuf; /* error buffer */ char *bwb_ebuf; /* error buffer */
static char *read_line; static char *read_line;
int bwb_trace = FALSE; int bwb_trace = FALSE;
FILE *errfdevice = stderr; /* output device for error messages */
FILE *errfdevice; /* output device for error messages */


#if HAVE_LONGJUMP #if HAVE_LONGJUMP
jmp_buf mark; jmp_buf mark;
@@ -133,6 +133,7 @@ bwb_init( argc, argv )
static char end_buf[] = "\0"; static char end_buf[] = "\0";
#endif #endif


errfdevice = stderr;
#if INTENSIVE_DEBUG #if INTENSIVE_DEBUG
prn_xprintf( stderr, "Memory Allocation Statistics:\n" ); prn_xprintf( stderr, "Memory Allocation Statistics:\n" );
prn_xprintf( stderr, "----------------------------\n" ); prn_xprintf( stderr, "----------------------------\n" );


+ 29
- 4
bwbasic.h View File

@@ -41,7 +41,7 @@


/* Version number */ /* Version number */


#define VERSION "2.20 patch level 2" /* Current version number */
#define VERSION "2.30" /* Current version number */


/*************************************************************** /***************************************************************


@@ -64,6 +64,27 @@
#define IMP_NCU FALSE /* Linux, ncurses */ #define IMP_NCU FALSE /* Linux, ncurses */
#define ALLOW_RENUM TRUE /* Added by JBV */ #define ALLOW_RENUM TRUE /* Added by JBV */


/* Make function names 8-character unique for systems like MVS */
#define var_findnval vf_nval
#define var_findsval vf_sval
#define fnc_timer f_timer
#define bwb_elseif b_elseif
#define bwb_caseif b_caseif
#define find_endif f_endif
#define find_endselect f_endselect
#define find_endsub f_endsub
#define fslt_findl fsf_l
#define fslt_findf fsf_f
#define bwb_loopuntil bl_until
#define bwb_exitfor bexfor
#define bwb_exitdo bexdo
#define bwb_endselect be_select
#define bwb_endsub be_endsub
#define fslt_addcallvar fa_callvar
#define fslt_addlocalvar fa_localvar
#define CALLOC calloc2
#define FREE free2

#if IMP_TTY #if IMP_TTY
#include "bwx_tty.h" #include "bwx_tty.h"
#endif #endif
@@ -89,7 +110,7 @@


***************************************************************/ ***************************************************************/


#ifdef MSDOS
#ifdef __STDC__
#define HAVE_RAISE TRUE #define HAVE_RAISE TRUE
#define HAVE_STRING TRUE #define HAVE_STRING TRUE
#define HAVE_STDLIB TRUE #define HAVE_STDLIB TRUE
@@ -128,13 +149,13 @@
#endif #endif


#ifdef __STDC__ #ifdef __STDC__
#define HAVE_SYSTYPES TRUE
#define HAVE_SYSTYPES FALSE
#else #else
#define HAVE_SYSTYPES TRUE /* Compiler has <sys/types.h> header */ #define HAVE_SYSTYPES TRUE /* Compiler has <sys/types.h> header */
#endif #endif


#ifdef __STDC__ #ifdef __STDC__
#define HAVE_SYSSTAT TRUE
#define HAVE_SYSSTAT FALSE
#else #else
#define HAVE_SYSSTAT TRUE /* Compiler has <sys/stat.h> header */ #define HAVE_SYSSTAT TRUE /* Compiler has <sys/stat.h> header */
#endif #endif
@@ -428,7 +449,11 @@
#define DEFVNAME_COLORS "BWB.COLORS" /* default variable name for COLORS */ #define DEFVNAME_COLORS "BWB.COLORS" /* default variable name for COLORS */
#define DEFVNAME_IMPL "BWB.IMPLEMENTATION$" /* default variable name for IMPLEMENTATION */ #define DEFVNAME_IMPL "BWB.IMPLEMENTATION$" /* default variable name for IMPLEMENTATION */
#define ERRFILE "err.out" /* Filename for redirected error messages */ #define ERRFILE "err.out" /* Filename for redirected error messages */
#if defined(__MVS__)
#define PROFILENAME "dd:profile"
#else
#define PROFILENAME "profile.bas" /* Filename for profile execution */ #define PROFILENAME "profile.bas" /* Filename for profile execution */
#endif
#define TASKS 4 /* number of tasks available */ #define TASKS 4 /* number of tasks available */
#define MAXARGSIZE 128 /* maximum size of argument */ #define MAXARGSIZE 128 /* maximum size of argument */
#define MAXREADLINESIZE 256 /* size of read_line buffer */ #define MAXREADLINESIZE 256 /* size of read_line buffer */


+ 9
- 0
bwbasic1.jcl View File

@@ -0,0 +1,9 @@
//BWBGEN JOB CLASS=C,REGION=0K
//IDCAMS EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE ALIAS (NAME(BWBASIC) RELATE(SYS1.UCAT.TSO)) -
CATALOG(SYS1.VMASTCAT/SECRET)
SET MAXCC=0
/*
//

+ 35
- 0
bwbasic2.jcl View File

@@ -0,0 +1,35 @@
//BWBGEN JOB CLASS=C,REGION=0K
//*
//CREATE PROC BWBPREF='BWBASIC'
//DELETE EXEC PGM=IEFBR14
//DD1 DD DSN=&BWBPREF..SOURCE,DISP=(MOD,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(0))
//DD2 DD DSN=&BWBPREF..INCLUDE,DISP=(MOD,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(0))
//DD3 DD DSN=&BWBPREF..NCALIB,DISP=(MOD,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(0))
//DD4 DD DSN=&BWBPREF..LINKLIB,DISP=(MOD,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(0))
//DD5 DD DSN=&BWBPREF..JCL,DISP=(MOD,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(0))
//*
//ALLOC EXEC PGM=IEFBR14
//DD1 DD DSN=&BWBPREF..SOURCE,DISP=(,CATLG),
// DCB=(RECFM=VB,LRECL=224,BLKSIZE=9024),
// SPACE=(CYL,(7,1,10)),UNIT=SYSDA
//DD2 DD DSN=&BWBPREF..INCLUDE,DISP=(,CATLG),
// DCB=(RECFM=VB,LRECL=224,BLKSIZE=9024),
// SPACE=(CYL,(1,1,10)),UNIT=SYSDA
//DD3 DD DSN=&BWBPREF..NCALIB,DISP=(,CATLG),
// DCB=(RECFM=U,LRECL=0,BLKSIZE=3200),
// SPACE=(CYL,(1,1,10)),UNIT=SYSDA
//DD4 DD DSN=&BWBPREF..LINKLIB,DISP=(,CATLG),
// DCB=(RECFM=U,LRECL=0,BLKSIZE=3200),
// SPACE=(CYL,(1,1,10)),UNIT=SYSDA
//DD5 DD DSN=&BWBPREF..JCL,DISP=(,CATLG),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=9040),
// SPACE=(CYL,(1,1,20)),UNIT=SYSDA
// PEND
//*
//S1 EXEC CREATE
//

+ 4
- 0
bwbasic3.bat View File

@@ -0,0 +1,4 @@
del allzips.txt
mvsendec encb all.zip allzips.txt
m4 bwbasic3.m4 >bwbasic3.jcl
del allzips.txt

+ 22
- 0
bwbasic3.m4 View File

@@ -0,0 +1,22 @@
//BWBGEN JOB CLASS=C,REGION=0K
//*
//TRANSFER PROC BWBPREF='BWBASIC',PDPPREF='PDPCLIB'
//DELETE EXEC PGM=IEFBR14
//DD1 DD DSN=&BWBPREF..ALLZIPS,DISP=(MOD,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(0))
//*
//MVSENDEC EXEC PGM=MVSENDEC,PARM='decb dd:input dd:output'
//STEPLIB DD DSN=&PDPPREF..LINKLIB,DISP=SHR
//INPUT DD DUMMY
//OUTPUT DD DSN=&BWBPREF..ALLZIPS,DISP=(,CATLG),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=3120),
// SPACE=(CYL,(20,10),RLSE),UNIT=SYSDA
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*,DCB=(RECFM=F,LRECL=132,BLKSIZE=132)
//SYSTERM DD SYSOUT=*,DCB=(RECFM=F,LRECL=132,BLKSIZE=132)
// PEND
//*
//S1 EXEC TRANSFER
//MVSENDEC.INPUT DD *
undivert(allzips.txt)/*
//

+ 32
- 0
bwbasic4.jcl View File

@@ -0,0 +1,32 @@
//BWBGEN JOB CLASS=C,REGION=0K
//*
//CREATE EXEC PGM=IEFBR14
//DD1 DD DSN=&&ZIPS,DISP=(,PASS),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=3120),
// SPACE=(CYL,(20,10,20)),UNIT=SYSDA
//*
//UNZIP1 PROC PDPPREF='PDPCLIB',BWBPREF='BWBASIC'
//MINI EXEC PGM=MVSUNZIP,PARM='dd:input dd:output binary'
//STEPLIB DD DSN=&PDPPREF..LINKLIB,DISP=SHR
//INPUT DD DSN=&BWBPREF..ALLZIPS,DISP=SHR
//OUTPUT DD DSN=&&ZIPS,DISP=(OLD,PASS)
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*,DCB=(RECFM=F,LRECL=132,BLKSIZE=132)
//SYSTERM DD SYSOUT=*,DCB=(RECFM=F,LRECL=132,BLKSIZE=132)
// PEND
//*
//UNZIP2 PROC IN=,OUT=,PDPPREF='PDPCLIB',BWBPREF='BWBASIC'
//MINI EXEC PGM=MVSUNZIP,PARM='dd:input dd:output'
//STEPLIB DD DSN=&PDPPREF..LINKLIB,DISP=SHR
//INPUT DD DSN=&&ZIPS(&IN),DISP=(OLD,PASS)
//OUTPUT DD DSN=&BWBPREF..&OUT,DISP=SHR
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*,DCB=(RECFM=F,LRECL=132,BLKSIZE=132)
//SYSTERM DD SYSOUT=*,DCB=(RECFM=F,LRECL=132,BLKSIZE=132)
// PEND
//*
//S1 EXEC UNZIP1
//S2 EXEC UNZIP2,IN='BWBSRC',OUT='SOURCE'
//S3 EXEC UNZIP2,IN='BWBINC',OUT='INCLUDE'
//S4 EXEC UNZIP2,IN='BWBJCL',OUT='JCL'
//

+ 64
- 0
bwbasic5.jcl View File

@@ -0,0 +1,64 @@
//BWBGEN JOB CLASS=C,REGION=0K
//*
//BWBCMP PROC BWBPREF='BWBASIC',MEMBER='',GCCPREF='GCC',
// PDPPREF='PDPCLIB',
// COS1='-w -S -ansi',
// COS2='-o dd:out -'
//*
//COMP EXEC PGM=GCC,
// PARM='&COS1 &COS2'
//STEPLIB DD DSN=&GCCPREF..LINKLIB,DISP=SHR
//SYSIN DD DSN=&BWBPREF..SOURCE(&MEMBER),DISP=SHR
//INCLUDE DD DSN=&BWBPREF..INCLUDE,DISP=SHR,DCB=BLKSIZE=32720
// DD DSN=&PDPPREF..INCLUDE,DISP=SHR
//SYSINCL DD DSN=&BWBPREF..INCLUDE,DISP=SHR,DCB=BLKSIZE=32720
// DD DSN=&PDPPREF..INCLUDE,DISP=SHR
//OUT DD DSN=&&TEMP1,DISP=(,PASS),UNIT=SYSDA,
// DCB=(LRECL=80,BLKSIZE=9040,RECFM=FB),
// SPACE=(CYL,(10,10))
//SYSPRINT DD SYSOUT=*,DCB=(LRECL=132,BLKSIZE=132)
//SYSTERM DD SYSOUT=*,DCB=(LRECL=132,BLKSIZE=132)
//*
//ASM EXEC PGM=ASMBLR,
// PARM='DECK,NOLIST',
// COND=(4,LT,COMP)
//SYSLIB DD DSN=SYS1.MACLIB,DISP=SHR
// DD DSN=&PDPPREF..MACLIB,DISP=SHR
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(2,1))
//SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(2,1))
//SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(2,1))
//SYSPRINT DD SYSOUT=*
//SYSLIN DD DUMMY
//SYSGO DD DUMMY
//SYSPUNCH DD DSN=&&OBJSET,UNIT=SYSDA,SPACE=(80,(240,200)),
// DISP=(,PASS)
//SYSIN DD DSN=&&TEMP1,DISP=(OLD,DELETE)
//*
//LKED EXEC PGM=IEWL,PARM='NCAL',
// COND=((4,LT,COMP),(4,LT,ASM))
//SYSLIN DD DSN=&&OBJSET,DISP=(OLD,DELETE)
//SYSLMOD DD DSN=&BWBPREF..NCALIB(&MEMBER),DISP=SHR
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(2,1))
//SYSPRINT DD SYSOUT=*
// PEND
//*
//BWBASIC EXEC BWBCMP,MEMBER=BWBASIC
//BWB@INT EXEC BWBCMP,MEMBER=BWB@INT
//BWB@TBL EXEC BWBCMP,MEMBER=BWB@TBL
//BWB@CMD EXEC BWBCMP,MEMBER=BWB@CMD
//BWB@PRN EXEC BWBCMP,MEMBER=BWB@PRN
//BWB@EXP EXEC BWBCMP,MEMBER=BWB@EXP
//BWB@VAR EXEC BWBCMP,MEMBER=BWB@VAR
//BWB@INP EXEC BWBCMP,MEMBER=BWB@INP
//BWB@FNC EXEC BWBCMP,MEMBER=BWB@FNC
//BWB@CND EXEC BWBCMP,MEMBER=BWB@CND
//BWB@OPS EXEC BWBCMP,MEMBER=BWB@OPS
//BWB@DIO EXEC BWBCMP,MEMBER=BWB@DIO
//BWB@STR EXEC BWBCMP,MEMBER=BWB@STR
//BWB@ELX EXEC BWBCMP,MEMBER=BWB@ELX
//BWB@MTH EXEC BWBCMP,MEMBER=BWB@MTH
//BWB@STC EXEC BWBCMP,MEMBER=BWB@STC
//BWX@TTY EXEC BWBCMP,MEMBER=BWX@TTY
//UNIXIO EXEC BWBCMP,MEMBER=UNIXIO
//*
//

+ 33
- 0
bwbasic6.jcl View File

@@ -0,0 +1,33 @@
//BWBGEN JOB CLASS=C,REGION=0K
//LINK PROC BWBPREF='BWBASIC',PDPPREF='PDPCLIB'
//LKED EXEC PGM=IEWL,PARM='MAP,LIST,SIZE=(999424,65536)'
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(30,10))
//SYSPRINT DD SYSOUT=*
//SYSLIB DD DSN=&PDPPREF..NCALIB,DISP=SHR,DCB=BLKSIZE=32760
// DD DSN=&BWBPREF..NCALIB,DISP=SHR
//SYSLMOD DD DSN=&BWBPREF..LINKLIB,DISP=SHR
// PEND
//DOLINK EXEC LINK
//LKED.SYSLIN DD *
INCLUDE SYSLIB(BWBASIC)
INCLUDE SYSLIB(BWB@INT)
INCLUDE SYSLIB(BWB@TBL)
INCLUDE SYSLIB(BWB@CMD)
INCLUDE SYSLIB(BWB@PRN)
INCLUDE SYSLIB(BWB@EXP)
INCLUDE SYSLIB(BWB@VAR)
INCLUDE SYSLIB(BWB@INP)
INCLUDE SYSLIB(BWB@FNC)
INCLUDE SYSLIB(BWB@CND)
INCLUDE SYSLIB(BWB@OPS)
INCLUDE SYSLIB(BWB@DIO)
INCLUDE SYSLIB(BWB@STR)
INCLUDE SYSLIB(BWB@ELX)
INCLUDE SYSLIB(BWB@MTH)
INCLUDE SYSLIB(BWB@STC)
INCLUDE SYSLIB(BWX@TTY)
INCLUDE SYSLIB(UNIXIO)
ENTRY @@CRT0
NAME BWBASIC(R)
/*
//

+ 23
- 0
bwbasic7.jcl View File

@@ -0,0 +1,23 @@
//BWBGEN JOB CLASS=C,REGION=0K
//*
//RUNBW PROC BWBPREF='BWBASIC'
//BWBASIC EXEC PGM=BWBASIC
//STEPLIB DD DSN=&BWBPREF..LINKLIB,DISP=SHR
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*,DCB=(RECFM=F,LRECL=132,BLKSIZE=132)
//SYSTERM DD SYSOUT=*,DCB=(RECFM=F,LRECL=132,BLKSIZE=132)
// PEND
//*
//CLEAN PROC BWBPREF='BWBASIC'
//DELETE EXEC PGM=IEFBR14
//DD1 DD DSN=&BWBPREF..ALLZIPS,DISP=(MOD,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(0))
// PEND
//*
//S1 EXEC RUNBW
//SYSIN DD *
print "hello, world"
quit
/*
//S2 EXEC CLEAN
//

+ 14
- 0
bwbmvs.txt View File

@@ -0,0 +1,14 @@
BWBASIC for MVS
---------------

To compile BWBASIC on MVS, run the following commands:

zipall
bwbasic3
subjobs

after taking a look at what they do and seeing if they
are appropriate to your environment.

Or just run "allbwb" which will do all of that.


+ 2
- 1
bwx_iqc.c View File

@@ -66,7 +66,7 @@ static int iqc_setpos( void );


***************************************************************/ ***************************************************************/


void
int
main( int argc, char **argv ) main( int argc, char **argv )
{ {
#if MS_CMDS #if MS_CMDS
@@ -115,6 +115,7 @@ main( int argc, char **argv )
bwb_mainloop(); bwb_mainloop();
} }


return (0);
} }


/*************************************************************** /***************************************************************


+ 1
- 0
bwx_ncu.c View File

@@ -111,6 +111,7 @@ main( int argc, char **argv )
{ {
bwb_mainloop(); bwb_mainloop();
} }
return (0);
} }


/*************************************************************** /***************************************************************


+ 2
- 1
bwx_tty.c View File

@@ -66,7 +66,7 @@ extern jmp_buf mark;
***************************************************************/ ***************************************************************/


#if ANSI_C #if ANSI_C
void
int
main( int argc, char **argv ) main( int argc, char **argv )
#else #else
main( argc, argv ) main( argc, argv )
@@ -93,6 +93,7 @@ main( argc, argv )
bwx_terminate(); /* allow ^D (Unix) exit with grace */ bwx_terminate(); /* allow ^D (Unix) exit with grace */




return (0);
} }


/*************************************************************** /***************************************************************


+ 25
- 0
compile.bat View File

@@ -0,0 +1,25 @@
del bwbasic.exe
del *.o
del *.obj

call stdcomp bwbasic.c
call stdcomp bwb_int.c
call stdcomp bwb_tbl.c
call stdcomp bwb_cmd.c
call stdcomp bwb_prn.c
call stdcomp bwb_exp.c
call stdcomp bwb_var.c
call stdcomp bwb_inp.c
call stdcomp bwb_fnc.c
call stdcomp bwb_cnd.c
call stdcomp bwb_ops.c
call stdcomp bwb_dio.c
call stdcomp bwb_str.c
call stdcomp bwb_elx.c
call stdcomp bwb_mth.c
call stdcomp bwb_stc.c
call stdcomp bwx_tty.c
call stdcomp unixio.c

gcc -o bwbasic.exe *.o
rem bcc32 -ebwbasic.exe *.obj

+ 1
- 0
renum.c View File

@@ -467,6 +467,7 @@ main(argc, argv)
fclose(fdout); fclose(fdout);
sprintf(tempstr, "mv editfl %s\0", f9str); sprintf(tempstr, "mv editfl %s\0", f9str);
system(tempstr); system(tempstr);
return (0);
} }






+ 3
- 0
stdcomp.bat View File

@@ -0,0 +1,3 @@
rem gcc -w -c -ansi -I . %1 %2 %3 %4 %5 %6 %7 %8 %9
rem bcc32 -w- -A -c -I. %1 %2 %3 %4 %5 %6 %7 %8 %9
gccmvs -w -S -ansi -nostdinc -I ../pdos/pdpclib -I . %1 %2 %3 %4 %5 %6 %7 %8 %9

+ 9
- 0
subjobs.bat View File

@@ -0,0 +1,9 @@
del alljcl.jcl
type bwbasic1.jcl >>alljcl.jcl
type bwbasic2.jcl >>alljcl.jcl
type bwbasic3.jcl >>alljcl.jcl
type bwbasic4.jcl >>alljcl.jcl
type bwbasic5.jcl >>alljcl.jcl
type bwbasic6.jcl >>alljcl.jcl
type bwbasic7.jcl >>alljcl.jcl
call runmvs alljcl.jcl alljcl.txt

+ 170
- 0
unixio.c View File

@@ -0,0 +1,170 @@
/*********************************************************************/
/* */
/* This Program Written By Paul Edwards. */
/* Released to the public domain. */
/* */
/*********************************************************************/
/*********************************************************************/
/* */
/* unixio - Unix I/O functions written in terms of standard C */
/* functions. */
/* */
/*********************************************************************/

#include <stdio.h>

#ifdef fileno
#undef fileno
#endif

#include "unixio.h"

static FILE *files[FOPEN_MAX];
/*char *environ[] = { NULL };*/

int open(const char *fnm, int mode, ...)
{
int x;
char *modestr;

for (x = 3; x < FOPEN_MAX; x++)
{
if (files[x] == NULL)
{
break;
}
}
if (x == FOPEN_MAX)
{
return (-1);
}
if (mode == O_RDONLY)
{
modestr = "r";
}
else if (mode == O_WRONLY)
{
modestr = "w";
}
else if (mode == O_RDWR)
{
modestr = "r+";
}
files[x] = fopen(fnm, modestr);
if (files[x] == NULL)
{
return (-1);
}
return (x);
}

int read(int fno, void *buf, size_t bytes)
{
size_t rb;

if (fno < 3)
{
rb = fread(buf, 1, bytes, stdin);
}
else
{
rb = fread(buf, 1, bytes, files[fno]);
}
return ((int)rb);
}

int write(int fno, const void *buf, size_t bytes)
{
size_t wb;

if (fno == 1)
{
fwrite(buf, 1, bytes, stdout);
}
else if (fno == 2)
{
fwrite(buf, 1, bytes, stderr);
}
else if (fno > 2)
{
wb = fwrite(buf, 1, bytes, files[fno]);
}
return ((int)wb);
}

int close(int fno)
{
if (fno >= 3)
{
fclose(files[fno]);
files[fno] = NULL;
}
return (0);
}

char *getcwd(char *buf, int len)
{
if (len != 0)
{
*buf = '\0';
}
return (buf);
}

void unlink(char *f)
{
remove(f);
return;
}

int stat(char *f, struct stat *buf)
{
memset(buf, '\0', sizeof *buf);
return (0);
}

int fileno(FILE *fp)
{
return (0);
}

int access(char *f, int n)
{
return (1);
}

int fstat(int fh, struct stat *buf)
{
memset(buf, '\0', sizeof *buf);
return (0);
}

int pwait(int a, int *b, int c)
{
return (0);
}

int putenv(char *x)
{
return (0);
}

char *mktemp(char *s)
{
return (tmpnam(s));
}

int chdir(char *path)
{
return (0);
}

int rmdir(char *path)
{
return (0);
}

int mkdir(char *path, int permissions)
{
return (0);
}

+ 41
- 0
unixio.h View File

@@ -0,0 +1,41 @@
/* written by Paul Edwards */
/* released to the public domain */

#ifndef UNIXIO_INCLUDED
#define UNIXIO_INCLUDED

#include <stddef.h>

#define S_IFBLK 0x3000
#define S_IFDIR 0x4000
#define S_IFREG 0x8000
#define S_IFMT 0xf000

#ifndef ENOENT
#define ENOENT 2002
#endif
#ifndef ENOTDIR
#define ENOTDIR 2045
#endif

#define O_RDONLY 1
#define O_WRONLY 2
#define O_RDWR 4
#define O_CREAT 0x100
#define O_TRUNC 0x200

struct stat {
long st_size;
long st_mode;
long st_ino;
long st_dev;
long st_mtime;
};

int open(const char *fnm, int mode, ...);
int read(int fno, void *buf, size_t bytes);
int write(int fno, const void *buf, size_t bytes);
int close(int fno);
char *mktemp(char *s);

#endif

+ 11
- 0
zipall.bat View File

@@ -0,0 +1,11 @@
del bwbinc.zip
del bwbsrc.zip
del bwbjcl.zip
del all.zip
del bwbasic3.jcl
del alljcl.jcl
del alljcl.txt
zip -0 -X -ll -j bwbsrc.zip *.c
zip -0 -X -ll -j bwbinc.zip *.h
zip -0 -X -ll -j bwbjcl.zip *.jcl README
zip -0 -X all *.zip

Loading…
Cancel
Save