1df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey#!/usr/bin/env python
2df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
3df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# Copyright (C) 2017 The Android Open Source Project
4df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey#
5df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# Licensed under the Apache License, Version 2.0 (the 'License');
6df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# you may not use this file except in compliance with the License.
7df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# You may obtain a copy of the License at
8df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey#
9df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey#      http://www.apache.org/licenses/LICENSE-2.0
10df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey#
11df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# Unless required by applicable law or agreed to in writing, software
12df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# distributed under the License is distributed on an 'AS IS' BASIS,
13df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# See the License for the specific language governing permissions and
15df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey# limitations under the License.
16df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
17b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkeyimport collections, sys
18df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
19df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff SharkeyTYPES = {
20df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    "AID_MEDIA_AUDIO": ["aac","aac","amr","awb","snd","flac","flac","mp3","mpga","mpega","mp2","m4a","aif","aiff","aifc","gsm","mka","m3u","wma","wax","ra","rm","ram","ra","pls","sd2","wav","ogg","oga"],
21df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    "AID_MEDIA_VIDEO": ["3gpp","3gp","3gpp2","3g2","avi","dl","dif","dv","fli","m4v","ts","mpeg","mpg","mpe","mp4","vob","qt","mov","mxu","webm","lsf","lsx","mkv","mng","asf","asx","wm","wmv","wmx","wvx","movie","wrf"],
22df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    "AID_MEDIA_IMAGE": ["bmp","gif","jpg","jpeg","jpe","pcx","png","svg","svgz","tiff","tif","wbmp","webp","dng","cr2","ras","art","jng","nef","nrw","orf","rw2","pef","psd","pnm","pbm","pgm","ppm","srw","arw","rgb","xbm","xpm","xwd"]
23df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey}
24df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
25b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkeyif "--rc" in sys.argv:
26b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey    print "on early-boot"
27b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey    print "    mkdir /config/sdcardfs/extensions/1055"
28b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey    print "    mkdir /config/sdcardfs/extensions/1056"
29b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey    print "    mkdir /config/sdcardfs/extensions/1057"
30b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey    for gid, exts in TYPES.iteritems():
31b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey        if gid is "AID_MEDIA_AUDIO": gid = "1055"
32b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey        if gid is "AID_MEDIA_VIDEO": gid = "1056"
33b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey        if gid is "AID_MEDIA_IMAGE": gid = "1057"
34b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey        for ext in exts:
35b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey            print "    mkdir /config/sdcardfs/extensions/%s/%s" % (gid, ext)
36b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey    exit()
37b22e7a742d4e0ba1510deda8f0726c02755a7961Jeff Sharkey
38df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkeyprint """/*
39df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * Copyright (C) 2017 The Android Open Source Project
40df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey *
41df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * Licensed under the Apache License, Version 2.0 (the "License");
42df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * you may not use this file except in compliance with the License.
43df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * You may obtain a copy of the License at
44df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey *
45df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey *      http://www.apache.org/licenses/LICENSE-2.0
46df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey *
47df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * Unless required by applicable law or agreed to in writing, software
48df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * distributed under the License is distributed on an "AS IS" BASIS,
49df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * See the License for the specific language governing permissions and
51df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * limitations under the License.
52df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey */
53df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
54df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey/******************************************************************
55df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey * THIS CODE WAS GENERATED BY matchgen.py, DO NOT MODIFY DIRECTLY *
56df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey ******************************************************************/
57df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
58df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey#include <private/android_filesystem_config.h>
59df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
60df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkeyint MatchExtension(const char* ext) {
61df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey"""
62df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
63df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkeytrie = collections.defaultdict(lambda: collections.defaultdict(lambda: collections.defaultdict(lambda: collections.defaultdict(lambda: collections.defaultdict(lambda: collections.defaultdict(lambda: ""))))))
64df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
65df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkeyfor t in TYPES:
66df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    for v in TYPES[t]:
67df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey        v = v.lower()
68df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey        target = trie
69df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey        for c in v:
70df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey            target = target[c]
71df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey        target["\0"] = t
72df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
73df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkeydef dump(target, index):
74df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    prefix = "    " * (index + 1)
75df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    print "%sswitch (ext[%d]) {" % (prefix, index)
76df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    for k in sorted(target.keys()):
77df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey        if k == "\0":
78df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey            print "%scase '\\0': return %s;" % (prefix, target[k])
79df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey        else:
80df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey            upper = k.upper()
81df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey            if k != upper:
82df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey                print "%scase '%s': case '%s':" % (prefix, k, upper)
83df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey            else:
84df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey                print "%scase '%s':" % (prefix, k)
85df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey            dump(target[k], index + 1)
86df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    print "%s}" % (prefix)
87df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
88df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkeydump(trie, 0)
89df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey
90df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkeyprint """
91df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey    return 0;
92df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey}
93df2d754b38796e0c49c70e0a67f7d383e3079ff2Jeff Sharkey"""
94