home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * ParseCmdLn v1.1.2
- *******************************************************************************
- * INFO executes the parsing of a command line and sets the variables
- * accordingly
- * SYNOPSIS success = ParseCmdLn[StrPtr]
- * d0 a0
- * IN StrPtr ptr to command line string
- * OUT success 0=ERROR! else OK
- * MODIFIES FileName filled with the input filename
- * BaseName filled with the base name (if specified)
- * flags bit # F_QUIETMODE updated
- *******************************************************************************
-
- function ParseCmdLn[a0],a0:d0
-
- moveq.l #0,d0 ;retcode
-
- SkipSpaces[a0]
- when.s #"-q"=(a0).w ;if quiet mode
- bset.b #F_QUIETMODE,flags ;set appropriate flag
- addq.l #2,a0 ;skip "-q"
- SkipSpaces[a0]
- ewhen
-
- when.s GetFName[sav:a0,#InFile] ;if InFile specified (correctly)
- SkipSpaces[a0]
-
- move.l Valu[a0],ChnkSize ;get chunk length
- when.s d0 & {#$7fffffff╗=d0} ;d0 returned by Valu[]
- SkipSpaces[a0]
- when.s ~GetFName[a0,#OutBase] ;if OutBase not specified (correctly)
- clr.b OutBase ;void its path
- ewhen
- moveq.l #-1,d0 ;cmdline is good
- othw
- moveq.l #0,d0 ;error
- ewhen
-
- ewhen
-
- efunc
-
- *******************************************************************************
- * GetFName v1.1.1
- *******************************************************************************
- * INFO copies a filename, discarding the ""s or ''s (if present);
- * it stops at the first ENTER,BLANK or SPACE and NULL-terminates
- * the string copied
- * SYNOPSIS NewStrPtr = GetFName[StrPtr,DstBuf]
- * a0 a1 a2
- * IN StrPtr ptr to string (filename)
- * DstBuf adr of destination buffer
- * OUT NewStrPtr ptr after source filename (0 if ERROR!)
- * WARNING be careful there is *no* check!!!
- *******************************************************************************
-
- function GetFName[a1-a2],d0/a1-a2:a0
-
- move.b (a1),d0 ;get the 1st char
-
- when.s {#"'"=d0.b}|{#'"'=d0.b} ;if quoted...
- CpyQtd.s[a1,a2] ;returns in a0.l
-
- owhen {#0=d0.b}|{#10=d0.b}|{#' '=d0.b} ;else if BLANK or ENTER...
- suba.l a0,a0 ;error!
-
- othw
- addq.l #1,a1 ;skip char already picked
- repeat
- move.b d0,(a2)+ ;store char
- move.b (a1)+,d0 ;get new char
- until.s {#0=d0.b}|{#10=d0.b}|{#' '=d0.b}
- clr.b (a2) ;NULL-terminated
- movea.l a1,a0 ;update source ptr
- ewhen
-
- pop
-
- *******************************************************************************
- * CpyQtd v1.1.1
- *******************************************************************************
- * INFO copies a string enclosed between two quotes: it is considered
- * a "quote" the first char of the string;
- * the copy is NULL-terminated;
- * it fails at the first ENTER or BLANK
- * SYNOPSIS CpyQtd[StrPtr,DstBuf]
- * a1 a2
- * IN StrPtr ptr to string (filename)
- * DstBuf adr of destination buffer
- * MODIFIES a0.l ptr after string (0 if ERROR!)
- * WARNING be careful there is *no* check!!!
- * NOTE local proc of GetFName[]
- *******************************************************************************
- *
- procedure loc:CpyQtd[a1-a2],d0-d1/a1-a2
- move.b (a1)+,d0 ;get "quote"
- repeat
- move.b (a1)+,d1
-
- switch.s d1.b
- -> d0 ;successful copy
- clr.b (a1) ;NULL-termination
- moveq.l #0,d1 ;exit loop
- -> #0 ;unvalid char, exit loop
- suba.l a1,a1 ;error
- -> #10 ;unvalid char
- moveq.l #0,d1 ;exit loop
- suba.l a1,a1 ;error
- def
- move.b d1,(a2)+ ;copy char
- eswitch
-
- until.s ~d1.b
- movea.l a1,a0 ;new string ptr
-
- eproc
- *
- *******************************************************************************
-
- efunc
-
-
- *******************************************************************************
- * Settings v1.0.4
- *******************************************************************************
- * INFO reserves the memory and opens the files according to the values
- * retrived by ParseCmdLine[]
- * SYNOPSIS ErrCode = Settings[]
- * d0
- * OUT ErrCode 0=OK, else E_xxxxxx (see defs.i)
- * REQUIRES _DOSName address of "dos.library",0
- *******************************************************************************
-
- function Settings[],d1/a0-a1/a6:d0
-
- move.l ChnkSize,d0
- moveq.l #0,d1 ;best available mem
- movea.l 4.w,a6
- jsr (_LVOAllocMem,a6)
-
- when d0.l ;if enough mem 4 a whole
- move.l ChnkSize,WrkBufLen ;chunk, bufsize=chunksize
- othw ;else alloc biggest buf available
- move.l #MEMF_LARGEST,d1
- jsr (_LVOAvailMem,a6)
- move.l d0,WrkBufLen ;size of biggest buf
- moveq.l #0,d1 ;best available mem
- jsr (_LVOAllocMem,a6)
- ewhen
-
- when d0.l ;if buf successfully reserved
- move.l d0,WrkBufAdr ;keep buf adr
- move.l #InFile,d1
- move.l #MODE_OLDFILE,d2
- movea.l _DOSBase,a6
- jsr (_LVOOpen,a6)
-
- when d0.l
- move.l d0,InFileHnd ;store handle
-
- lea.l OutBase,a0
- when.s ~(a0).b ;if no OutBase specified
- lea.l InFile,a1 ;copy source filename
- repeat
- move.b (a1)+,d0
- move.b d0,(a0)+
- until ~d0.b
-
- othw
- while (a0)+.b ;find end of OutBase
- ewhile
- ewhen
-
- move.b #'.',(-1,a0) ;extension dot
- move.l a0,ExtnAdr ;store ptr to final BLANK
-
- move.l GetFileSize[InFileHnd],InFileSze
- divul.l ChnkSize,d1:d0 ;d0=max chunk #
- when.s ~d1.l
- subq.l #1,d0 ;max chunk #
- ewhen
- when.s #MAXCHNKSNMB╗d0 ;if reasonable # of chunks
- move.l d0,MaxChnk
- moveq.l #1,d1 ;min # of digits
- while.s #10½=d0.l
- addq.l #1,d1 ;1 more digit needed
- divu.l #10,d0
- ewhile
- move.l d1,DgtNmb
- moveq.l #0,d0 ;no error
- othw
- moveq.l #E_CHNKNB,d0 ;too many chunks
- ewhen
-
- othw
- moveq.l #E_SOUFLE,d0
- ewhen
-
- othw
- moveq.l #E_LOWMEM,d0 ;not enough mem
- ewhen
-
- efunc
-
- *******************************************************************************
- * GiveInfo v1.0.0
- *******************************************************************************
- * INFO prints some info about the current operations
- * SYNOPSIS GiveInfo[]
- * NOTE - Print[] and Stru[] always called without "sav:"
- * (regs already saved)
- * - uses TmpBuf
- *******************************************************************************
-
- procedure GiveInfo[],d0-d2/a0
- Print[#txt_InfoFName]
- Print[#InFile]
- Print[#txt_ENTER] ;show source name
-
- Print[#txt_InfoOFile]
- Stru[#0,ExtnAdr,DgtNmb] ;build 1st extension
- Print[#OutBase] ;show 1st chunk filename
-
- when.s MaxChnk.l ;if 2+ chunks
- Print[#txt_InfoArrow]
- Stru[MaxChnk,ExtnAdr,DgtNmb] ;build last extension
- Print[#OutBase] ;show last chunk filename
- ewhen
- Print[#txt_ENTER]
-
- Print[#txt_InfoCSize]
- Stru[ChnkSize,#TmpBuf,#10]
- Print[#TmpBuf] ;show chunk size
- Print[#txt_InfoBytes]
-
- Print[#txt_InfoBSize]
- Stru[WrkBufLen,#TmpBuf,#10]
- Print[#TmpBuf] ;show buffer size
- Print[#txt_InfoBytes]
- eproc
-