Skip to content

Commit

Permalink
ACP
Browse files Browse the repository at this point in the history
1.Move some duplicated code into shared code file

Express
1. Make max_desclines configurable
2. Remove redundant code
3. Move some duplicated code into shared code file
4. Fix CONVERT_TO_MB to kick in at 10mb instead of 100mb
5. Improve directory scanning on FM operations
6. Tweak copyright string

JsonParser
1. Move some duplicated code into shared code file

jsonImport
1. New utility to create bbs structures from json file

icon2cfg
1. New tool to convert from icon files to cfg format and back again

makefile
added makefile to build all targets
  • Loading branch information
Darren Coles committed Dec 5, 2018
1 parent ab6e616 commit d2a6218
Show file tree
Hide file tree
Showing 8 changed files with 1,057 additions and 341 deletions.
30 changes: 2 additions & 28 deletions ACP.e
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
'icon'

MODULE '*axcommon',
'*jsonParser'
'*jsonParser',
'*miscfuncs'

/*
'Setup'
Expand Down Expand Up @@ -570,7 +571,6 @@ PROC tLock(str:PTR TO CHAR)
UnLock(lock)
RETURN 1
ENDIF

ENDPROC 0

PROC free_pdir()
Expand Down Expand Up @@ -681,32 +681,6 @@ PROC getFileName(path:PTR TO CHAR,buf:PTR TO CHAR)
FreeDosObject(DOS_FIB,dir_info)
ENDPROC returnval

PROC fileExists(filename)
DEF lh
IF lh:=Lock(filename,ACCESS_READ)
UnLock(lh)
RETURN TRUE
ENDIF
ENDPROC FALSE

PROC getFileSize(s: PTR TO CHAR)
DEF fBlock: fileinfoblock
DEF fLock
DEF fsize=8192

IF((fLock:=Lock(s,ACCESS_READ)))=NIL
RETURN 8192
ENDIF

IF((fBlock:=AllocDosObject(DOS_FIB,NIL)))=NIL
UnLock(fLock)
RETURN 8192
ENDIF
IF(Examine(fLock,fBlock)) THEN fsize:=fBlock.size
UnLock(fLock)
FreeDosObject(DOS_FIB,fBlock)
ENDPROC fsize

PROC findFirst(path: PTR TO CHAR,buf: PTR TO CHAR)
DEF returnval=0

Expand Down
150 changes: 150 additions & 0 deletions MiscFuncs.e
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/* Miscellaneous helper functions */

OPT MODULE

MODULE 'dos/dos','dos/dosextens'

EXPORT PROC getFileSize(s: PTR TO CHAR)
/* returns the file size of a given file or 8192 if an error occured */
DEF fBlock: fileinfoblock
DEF fLock
DEF fsize=8192

IF((fLock:=Lock(s,ACCESS_READ)))=NIL
RETURN 8192
ENDIF

IF((fBlock:=AllocDosObject(DOS_FIB,NIL)))=NIL
UnLock(fLock)
RETURN 8192
ENDIF
IF(Examine(fLock,fBlock)) THEN fsize:=fBlock.size
UnLock(fLock)
FreeDosObject(DOS_FIB,fBlock)
ENDPROC fsize

EXPORT PROC fileExists(filename, addInfo = FALSE)
/* checks to see if a file exists and returns TRUE OR FALSE */
DEF lh
DEF fn[255]:STRING

StrCopy(fn,filename)
IF addInfo THEN StrAdd(fn,'.info')
IF lh:=Lock(fn,ACCESS_READ)
UnLock(lh)
RETURN TRUE
ENDIF
ENDPROC FALSE

EXPORT PROC dirExists(path: PTR TO CHAR)
/* checks to see if a directory exists and is a directory and not a file and returns TRUE OR FALSE */
DEF pdir: PTR TO filelock
DEF dir_info: PTR TO fileinfoblock
DEF returnval=0

IF ((dir_info:=(AllocDosObject(DOS_FIB,NIL)))=NIL)
Delay(300)
RETURN 0
ENDIF

IF((pdir:=(Lock(path,ACCESS_READ)))=FALSE)
UnLock(pdir)
FreeDosObject(DOS_FIB,dir_info)
RETURN 0
ENDIF

IF(Examine(pdir,dir_info))=FALSE
UnLock(pdir)
FreeDosObject(DOS_FIB,dir_info)
RETURN 0
ENDIF

IF(dir_info.direntrytype > 0 )
returnval:=1
ENDIF
UnLock(pdir)
FreeDosObject(DOS_FIB,dir_info)
ENDPROC returnval

EXPORT PROC strCmpi(test1: PTR TO CHAR, test2: PTR TO CHAR, len)
/* case insensitive string compare */
DEF i,l1,l2

IF len=ALL
l1:=StrLen(test1)
l2:=StrLen(test2)
IF l1<>l2 THEN RETURN FALSE
len:=l1
ENDIF

FOR i:=0 TO len-1
IF charToLower(test1[i])<>charToLower(test2[i]) THEN RETURN FALSE
ENDFOR
ENDPROC TRUE

EXPORT PROC charToLower(c)
/* convert a given char to lowercase */
DEF str[1]:STRING
str[0]:=c
LowerStr(str)
ENDPROC str[0]

EXPORT PROC charToUpper(c)
/* convert a given char to uppercase */
DEF str[1]:STRING
str[0]:=c
UpperStr(str)
ENDPROC str[0]

EXPORT PROC findAssign(name: PTR TO CHAR)
/* checks to see if a specified assign exists, returns 0 if it exists otherwise it returns 20 */
DEF db: doslibrary
DEF rootnode: PTR TO rootnode
DEF dosinfo: PTR TO dosinfo
DEF devicelist: PTR TO devlist
DEF temp[256]:STRING
DEF temp2[256]:STRING
DEF i=0

StrCopy(temp,name)
WHILE temp[i]
IF(temp[i]=":")
SetStr(temp,i)
i:=-1
ENDIF
EXIT i=-1
i++
ENDWHILE

IF i<>-1 THEN RETURN 20

db:=dosbase
rootnode:=db.root
dosinfo:=Shl(rootnode.info,2)
devicelist:=Shl(dosinfo.devinfo,2)
Forbid()
WHILE(devicelist.next)
bStrC(devicelist.name,temp2)
IF(strCmpi(temp2,temp,ALL)/* && devicelist->dl_Type!=DLT_DEVICE*/)
Permit()
RETURN 0
ENDIF
devicelist:=Shl(devicelist.next,2)
ENDWHILE
Permit()
ENDPROC 20

PROC bStrC(bstr: PTR TO CHAR,outbuf: PTR TO CHAR)
/* take a BStr pointer and copy the characters to a new EString) */

DEF str: PTR TO CHAR
DEF loop,counter

counter:=0
str:=Shl(bstr,2)
SetStr(outbuf,str[0])
FOR loop:=1 TO str[0]
outbuf[counter]:=str[loop]
counter++
ENDFOR
ENDPROC
Loading

0 comments on commit d2a6218

Please sign in to comment.