home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34exe.zip
/
mutt
/
misc
/
pcshar.mut
< prev
next >
Wrap
Lisp/Scheme
|
1995-01-14
|
3KB
|
124 lines
;; C Durland Public Domain
(include me.mh)
;; Concat files that have been uuencoded and split.
;; Formats:
;; File names: <base-name><n> where n is in [1,2,3,...]
;; For example: foo.1, foo.2, etc.
;; Each part:
;; junk
;; BEGIN--cut here--cut here
;; the data
;; END--cut here--cut here
;; possibly more junk
;; Concats all the parts and uudecodes it.
(defun concat-pc-archive
{
(int part)
(string base-name)
(part 1)
(base-name (complete CC_FNAME
"Archive base name (each part is in form <base-name><n>): "))
(switch-to-buffer base-name)(clear-buffer)
;; Strip off the headers and trailers and concat all the archive
;; parts.
(insert-file (concat base-name part))
(while TRUE
{
(search-forward "END--cut here--")(beginning-of-line)
(+= part 1)
(if (not (insert-file (concat base-name part))) (break))
(set-mark)
(search-forward "BEGIN--cut here--")
(forward-line 1)(delete-region)
})
;; run the buffer though uudecode
(msg 'uudecoding "' base-name '"')
(beginning-of-buffer)(set-mark)(end-of-buffer)
(clear-bag CUT-BUFFER)(append-to-bag CUT-BUFFER APPEND-REGION)
(OS-filter "uudecode" CUT-BUFFER)
;; remove the uuencoded buffer
(clear-bag CUT-BUFFER)(free-buffer -1)(update)
(msg (- part 1) " parts to archive " '"' base-name '"')
})
;; BEGIN ---------------- foo: Part n of m ---------------
;; END ------------------ foo: Part n of m ---------------
(defun add-begin/end-lines-to-files
{
(int part parts)
(string base-name)
(base-name (complete CC_FNAME
"Archive base name (each part is in form <base-name><n>): "))
(parts (count-parts base-name))
(switch-to-buffer base-name)(clear-buffer)
(insert-file (concat base-name part))
(for (part 1) (<= part parts) (+= part 1)
{
(read-file (concat base-name part))
(insert-text
"BEGIN ---- " base-name part " -- Part " part " of " parts " ----^J")
(end-of-buffer)
(insert-text
"END ---- " base-name part " -- Part " part " of " parts " ----")
(save-buffer)
})
(msg parts " parts of " base-name " munged")
})
(defun
count-parts (string base-name) HIDDEN
{
(int parts)
(parts 0)
(while (file-exists (concat base-name (+= parts 1))) ())
(if (== 1 parts) { (msg "Bad name - no parts: " base-name)(halt) })
(- parts 1)
}
)
(defun
convert-splits-to-name
{
(int j)
(string base-name fname newname)
(base-name (complete CC_FNAME
"Base name (each part is in form <base-name>aa): "))
(newname (complete CC_FNAME
"New name (each part is in form <base-name>1): "))
(for (j 1)
(file-exists (fname
(concat base-name "a" ;; xaa
(extract-elements "xabcdefghijklmnopqrstuvwxyz" j 1))))
(+= j 1)
(shell-command (msg "mv " fname " " newname j))) ;; z1
(update)
(msg (- j 1) " parts renamed.")
}
)
(defun
chop-chop
{
(string name)
(int split-size)
(split-size (if (arg-flag) (arg-prefix) 820))
(name (complete CC_FNAME "Name of file to chop up: "))
(shell-command (msg "uuencode " name " " name " > " name ".uu"))
(shell-command (msg "split -" split-size " " name ".uu"))
(convert-splits-to-name "x" (concat name ".uu."))
(add-begin/end-lines-to-files (concat name ".uu."))
}
)