xref: /haiku/src/add-ons/kernel/generic/mime_table/mktable.sh (revision a583b8b54d676cf2502e239eb800b95f8f4c388b)
1*a583b8b5SFrançois Revol#!/bin/sh
2*a583b8b5SFrançois Revol
3*a583b8b5SFrançois Revolfunction dump_mime () {
4*a583b8b5SFrançois Revol	while [ ! -z "$1" ]; do
5*a583b8b5SFrançois Revol		case "$1" in
6*a583b8b5SFrançois Revol		-set)
7*a583b8b5SFrançois Revol			shift;
8*a583b8b5SFrançois Revol			mime="$1"
9*a583b8b5SFrançois Revol			;;
10*a583b8b5SFrançois Revol		-extension)
11*a583b8b5SFrançois Revol			shift
12*a583b8b5SFrançois Revol			extension="$1"
13*a583b8b5SFrançois Revol			echo "	{ \"$extension\", \"$mime\" },"
14*a583b8b5SFrançois Revol			;;
15*a583b8b5SFrançois Revol		esac
16*a583b8b5SFrançois Revol		shift
17*a583b8b5SFrançois Revol	done
18*a583b8b5SFrançois Revol}
19*a583b8b5SFrançois Revol
20*a583b8b5SFrançois Revol# header
21*a583b8b5SFrançois Revolecho "struct ext_mime mimes[] = {"
22*a583b8b5SFrançois Revol
23*a583b8b5SFrançois Revolsetmime -dump | grep extension | sed 's/^[^ ]*setmime /dump_mime /' | while read L; do
24*a583b8b5SFrançois Revol	eval $L
25*a583b8b5SFrançois Revoldone
26*a583b8b5SFrançois Revol
27*a583b8b5SFrançois Revol#footer
28*a583b8b5SFrançois Revolecho ""
29*a583b8b5SFrançois Revolecho "	{ 0, 0 }"
30*a583b8b5SFrançois Revolecho "};"
31*a583b8b5SFrançois Revol
32