summaryrefslogtreecommitdiffstats
path: root/util/bin
diff options
context:
space:
mode:
authortv <tv@also>2011-07-19 16:42:05 +0200
committertv <tv@also>2011-07-19 16:49:39 +0200
commit12568135bd4372de24225bc0acc3108870ea2961 (patch)
tree07b618ac64127467803da9945010a602d95fed3f /util/bin
parent9874481145501c095934d7136dfd0bb5de19b402 (diff)
util make-data-url: initial commit
NAME make-data-url - create a "data" URL scheme item SYNOPSIS make-data-url [file...] DESCRIPTION The make-data-url is a best efforts generator of "data" URL scheme compatible items as described by RFC 2397. Each file is read, analyzed, and printed as single-lined "data" URL to stdout. OPERANDS The following operands shall be supported: file A pathname of a file. The content of each file is printed as single-lined "data" URL to the standard output. The mime-type of the file's content gets guessed by the file utility. STDIN None INPUT FILES Input files can be any file type. ENVIRONMENT VARIABLES The following environment variables shall affect the execution of make-data-url: None. ASYNCHRONOUS EVENTS Default. STDOUT Each line shall contain a "data" URL item for the respective file operand. STDERR The standard error shall be used only for diagnostic messages. OUTPUT FILES None. EXTENDED DESCRIPTION None. EXIT STATUS The following exit values shall be returned: 0 The program has terminated. CONSEQUENCES OF ERRORS Default. The following sections are informative APPLICATION USAGE Default. EXAMPLES Test your backup scheme: sudo rm -fR /home RATIONALE None. FUTURE DIRECTIONS None. SEE ALSO RFC 2397, file BUGS None, this is enterprise-grade software and behaves exactly as specified. AUTHOR KREBS COPYTIGHT Copytight (c) 2011, KREBS. This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details. COPYRIGHT Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operatingg Systems Interface (POSIX), The Open Group Base Specification Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . Deal with it!
Diffstat (limited to 'util/bin')
-rwxr-xr-xutil/bin/make-data-uri7
-rwxr-xr-xutil/bin/make-data-url7
2 files changed, 14 insertions, 0 deletions
diff --git a/util/bin/make-data-uri b/util/bin/make-data-uri
new file mode 100755
index 00000000..a9d014e6
--- /dev/null
+++ b/util/bin/make-data-uri
@@ -0,0 +1,7 @@
+#! /bin/sh
+set -euf
+for path; do
+ type="`file -bi "$path"`"
+ data="`base64 -w 0 "$path"`"
+ echo "data:$type;base64,$data"
+done
diff --git a/util/bin/make-data-url b/util/bin/make-data-url
new file mode 100755
index 00000000..a9d014e6
--- /dev/null
+++ b/util/bin/make-data-url
@@ -0,0 +1,7 @@
+#! /bin/sh
+set -euf
+for path; do
+ type="`file -bi "$path"`"
+ data="`base64 -w 0 "$path"`"
+ echo "data:$type;base64,$data"
+done