mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
base64: Turn into a regular Guile module.
* guix/base64.scm: Replace 'library' form with 'define-module'.
This commit is contained in:
parent
faa6bdf8ad
commit
4862a98be4
1 changed files with 189 additions and 188 deletions
|
@ -5,6 +5,7 @@
|
|||
;; February 12, 2014.
|
||||
;;
|
||||
;; Some optimizations made by Ludovic Courtès <ludo@gnu.org>, 2015.
|
||||
;; Turned into a Guile module (instead of R6RS).
|
||||
;;
|
||||
;; This program is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
|
@ -42,23 +43,20 @@
|
|||
;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
;; DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#!r6rs
|
||||
|
||||
;; RFC 4648 Base-N Encodings
|
||||
|
||||
(library (guix base64)
|
||||
(export base64-encode
|
||||
(define-module (guix base64)
|
||||
#:export (base64-encode
|
||||
base64-decode
|
||||
base64-alphabet
|
||||
base64url-alphabet
|
||||
get-delimited-base64
|
||||
put-delimited-base64)
|
||||
(import (rnrs)
|
||||
(only (srfi :13 strings)
|
||||
string-index
|
||||
#:use-module (rnrs)
|
||||
#:use-module ((srfi srfi-13)
|
||||
#:select (string-index
|
||||
string-prefix? string-suffix?
|
||||
string-concatenate string-trim-both)
|
||||
(only (guile) ash logior))
|
||||
string-concatenate string-trim-both)))
|
||||
|
||||
|
||||
(define-syntax define-alias
|
||||
|
@ -68,6 +66,7 @@ (define-syntax new (identifier-syntax old)))))
|
|||
|
||||
;; Force the use of Guile's own primitives to avoid the overhead of its 'fx'
|
||||
;; procedures.
|
||||
|
||||
(define-alias fxbit-field bitwise-bit-field)
|
||||
(define-alias fxarithmetic-shift ash)
|
||||
(define-alias fxarithmetic-shift-left ash)
|
||||
|
@ -143,6 +142,7 @@ (define base64-encode
|
|||
|
||||
;; Decodes a base64 string. The string must contain only pure
|
||||
;; unpadded base64 data.
|
||||
|
||||
(define base64-decode
|
||||
(case-lambda
|
||||
((str)
|
||||
|
@ -201,6 +201,7 @@ (define (get-line-comp f port)
|
|||
;; the given port. Returns two values: a string with the type and a
|
||||
;; bytevector containing the base64 decoded data. The second value
|
||||
;; is the eof object if there is an eof before the BEGIN delimiter.
|
||||
|
||||
(define (get-delimited-base64 port)
|
||||
(define (get-first-data-line port)
|
||||
;; Some MIME data has header fields in the same format as mail
|
||||
|
@ -249,4 +250,4 @@ (define put-delimited-base64
|
|||
line-length #f base64-alphabet port)
|
||||
(display (string-append "\n-----END " type "-----\n") port))
|
||||
((port type bv)
|
||||
(put-delimited-base64 port type bv 76)))))
|
||||
(put-delimited-base64 port type bv 76))))
|
||||
|
|
Loading…
Reference in a new issue