SOURCES: file-magic.mime-gen.awk (NEW) - magic.mime generator

qboosh qboosh at pld-linux.org
Sun Jul 20 00:54:44 CEST 2008


Author: qboosh                       Date: Sat Jul 19 22:54:44 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- magic.mime generator

---- Files affected:
SOURCES:
   file-magic.mime-gen.awk (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/file-magic.mime-gen.awk
diff -u /dev/null SOURCES/file-magic.mime-gen.awk:1.1
--- /dev/null	Sun Jul 20 00:54:45 2008
+++ SOURCES/file-magic.mime-gen.awk	Sun Jul 20 00:54:39 2008
@@ -0,0 +1,21 @@
+#!/bin/awk -f
+
+BEGIN {
+	FS = "\t+|  +"
+	level = 0
+}
+
+/^#/ { next }
+
+/^[^!]/ {
+	pref=$0
+	sub(/[^>].*/, "", pref)
+	level = length(pref)
+	str[level] = $1"\t"$2"\t"$3
+}
+
+/^!:mime/ {
+	for(i = 0; i < level; i++)
+		print str[i]
+	print str[level]"\t"$2
+}
================================================================


More information about the pld-cvs-commit mailing list