diff options
Diffstat (limited to 'src/fs/fs_misc.c')
-rw-r--r-- | src/fs/fs_misc.c | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/src/fs/fs_misc.c b/src/fs/fs_misc.c index 918c637a0..79f082626 100644 --- a/src/fs/fs_misc.c +++ b/src/fs/fs_misc.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file fs/fs_misc.c | 21 | * @file fs/fs_misc.c |
22 | * @brief misc. functions related to file-sharing in general | 22 | * @brief misc. functions related to file-sharing in general |
@@ -35,74 +35,74 @@ | |||
35 | * @return NULL if meta data is useless for suggesting a filename | 35 | * @return NULL if meta data is useless for suggesting a filename |
36 | */ | 36 | */ |
37 | char * | 37 | char * |
38 | GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData | 38 | GNUNET_FS_meta_data_suggest_filename(const struct GNUNET_CONTAINER_MetaData |
39 | *md) | 39 | *md) |
40 | { | 40 | { |
41 | static const char *mimeMap[][2] = { | 41 | static const char *mimeMap[][2] = { |
42 | {"application/bz2", ".bz2"}, | 42 | { "application/bz2", ".bz2" }, |
43 | {"application/gnunet-directory", ".gnd"}, | 43 | { "application/gnunet-directory", ".gnd" }, |
44 | {"application/java", ".class"}, | 44 | { "application/java", ".class" }, |
45 | {"application/msword", ".doc"}, | 45 | { "application/msword", ".doc" }, |
46 | {"application/nar", ".nar"}, | 46 | { "application/nar", ".nar" }, |
47 | {"application/narinfo", ".narinfo"}, | 47 | { "application/narinfo", ".narinfo" }, |
48 | {"application/ogg", ".ogg"}, | 48 | { "application/ogg", ".ogg" }, |
49 | {"application/pdf", ".pdf"}, | 49 | { "application/pdf", ".pdf" }, |
50 | {"application/pgp-keys", ".key"}, | 50 | { "application/pgp-keys", ".key" }, |
51 | {"application/pgp-signature", ".pgp"}, | 51 | { "application/pgp-signature", ".pgp" }, |
52 | {"application/postscript", ".ps"}, | 52 | { "application/postscript", ".ps" }, |
53 | {"application/rar", ".rar"}, | 53 | { "application/rar", ".rar" }, |
54 | {"application/rtf", ".rtf"}, | 54 | { "application/rtf", ".rtf" }, |
55 | {"application/xml", ".xml"}, | 55 | { "application/xml", ".xml" }, |
56 | {"application/x-debian-package", ".deb"}, | 56 | { "application/x-debian-package", ".deb" }, |
57 | {"application/x-dvi", ".dvi"}, | 57 | { "application/x-dvi", ".dvi" }, |
58 | {"application/x-flac", ".flac"}, | 58 | { "application/x-flac", ".flac" }, |
59 | {"application/x-gzip", ".gz"}, | 59 | { "application/x-gzip", ".gz" }, |
60 | {"application/x-java-archive", ".jar"}, | 60 | { "application/x-java-archive", ".jar" }, |
61 | {"application/x-java-vm", ".class"}, | 61 | { "application/x-java-vm", ".class" }, |
62 | {"application/x-python-code", ".pyc"}, | 62 | { "application/x-python-code", ".pyc" }, |
63 | {"application/x-redhat-package-manager", ".rpm"}, | 63 | { "application/x-redhat-package-manager", ".rpm" }, |
64 | {"application/x-rpm", ".rpm"}, | 64 | { "application/x-rpm", ".rpm" }, |
65 | {"application/x-tar", ".tar"}, | 65 | { "application/x-tar", ".tar" }, |
66 | {"application/x-tex-pk", ".pk"}, | 66 | { "application/x-tex-pk", ".pk" }, |
67 | {"application/x-texinfo", ".texinfo"}, | 67 | { "application/x-texinfo", ".texinfo" }, |
68 | {"application/x-xcf", ".xcf"}, | 68 | { "application/x-xcf", ".xcf" }, |
69 | {"application/x-xfig", ".xfig"}, | 69 | { "application/x-xfig", ".xfig" }, |
70 | {"application/zip", ".zip"}, | 70 | { "application/zip", ".zip" }, |
71 | 71 | ||
72 | {"audio/midi", ".midi"}, | 72 | { "audio/midi", ".midi" }, |
73 | {"audio/mpeg", ".mp3"}, | 73 | { "audio/mpeg", ".mp3" }, |
74 | {"audio/real", ".rm"}, | 74 | { "audio/real", ".rm" }, |
75 | {"audio/x-wav", ".wav"}, | 75 | { "audio/x-wav", ".wav" }, |
76 | 76 | ||
77 | {"image/gif", ".gif"}, | 77 | { "image/gif", ".gif" }, |
78 | {"image/jpeg", ".jpg"}, | 78 | { "image/jpeg", ".jpg" }, |
79 | {"image/pcx", ".pcx"}, | 79 | { "image/pcx", ".pcx" }, |
80 | {"image/png", ".png"}, | 80 | { "image/png", ".png" }, |
81 | {"image/tiff", ".tiff"}, | 81 | { "image/tiff", ".tiff" }, |
82 | {"image/x-ms-bmp", ".bmp"}, | 82 | { "image/x-ms-bmp", ".bmp" }, |
83 | {"image/x-xpixmap", ".xpm"}, | 83 | { "image/x-xpixmap", ".xpm" }, |
84 | 84 | ||
85 | {"text/css", ".css"}, | 85 | { "text/css", ".css" }, |
86 | {"text/html", ".html"}, | 86 | { "text/html", ".html" }, |
87 | {"text/plain", ".txt"}, | 87 | { "text/plain", ".txt" }, |
88 | {"text/rtf", ".rtf"}, | 88 | { "text/rtf", ".rtf" }, |
89 | {"text/x-c++hdr", ".h++"}, | 89 | { "text/x-c++hdr", ".h++" }, |
90 | {"text/x-c++src", ".c++"}, | 90 | { "text/x-c++src", ".c++" }, |
91 | {"text/x-chdr", ".h"}, | 91 | { "text/x-chdr", ".h" }, |
92 | {"text/x-csrc", ".c"}, | 92 | { "text/x-csrc", ".c" }, |
93 | {"text/x-java", ".java"}, | 93 | { "text/x-java", ".java" }, |
94 | {"text/x-moc", ".moc"}, | 94 | { "text/x-moc", ".moc" }, |
95 | {"text/x-pascal", ".pas"}, | 95 | { "text/x-pascal", ".pas" }, |
96 | {"text/x-perl", ".pl"}, | 96 | { "text/x-perl", ".pl" }, |
97 | {"text/x-python", ".py"}, | 97 | { "text/x-python", ".py" }, |
98 | {"text/x-tex", ".tex"}, | 98 | { "text/x-tex", ".tex" }, |
99 | 99 | ||
100 | {"video/avi", ".avi"}, | 100 | { "video/avi", ".avi" }, |
101 | {"video/mpeg", ".mpeg"}, | 101 | { "video/mpeg", ".mpeg" }, |
102 | {"video/quicktime", ".qt"}, | 102 | { "video/quicktime", ".qt" }, |
103 | {"video/real", ".rm"}, | 103 | { "video/real", ".rm" }, |
104 | {"video/x-msvideo", ".avi"}, | 104 | { "video/x-msvideo", ".avi" }, |
105 | {NULL, NULL}, | 105 | { NULL, NULL }, |
106 | }; | 106 | }; |
107 | char *ret; | 107 | char *ret; |
108 | unsigned int i; | 108 | unsigned int i; |
@@ -111,52 +111,52 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData | |||
111 | const char *ext; | 111 | const char *ext; |
112 | 112 | ||
113 | ret = | 113 | ret = |
114 | GNUNET_CONTAINER_meta_data_get_by_type (md, | 114 | GNUNET_CONTAINER_meta_data_get_by_type(md, |
115 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); | 115 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); |
116 | if (ret != NULL) | 116 | if (ret != NULL) |
117 | return ret; | 117 | return ret; |
118 | ext = NULL; | 118 | ext = NULL; |
119 | mime = | 119 | mime = |
120 | GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE); | 120 | GNUNET_CONTAINER_meta_data_get_by_type(md, EXTRACTOR_METATYPE_MIMETYPE); |
121 | if (mime != NULL) | 121 | if (mime != NULL) |
122 | { | 122 | { |
123 | i = 0; | 123 | i = 0; |
124 | while ((mimeMap[i][0] != NULL) && (0 != strcmp (mime, mimeMap[i][0]))) | 124 | while ((mimeMap[i][0] != NULL) && (0 != strcmp(mime, mimeMap[i][0]))) |
125 | i++; | 125 | i++; |
126 | if (mimeMap[i][1] == NULL) | 126 | if (mimeMap[i][1] == NULL) |
127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 127 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
128 | _("Did not find mime type `%s' in extension list.\n"), mime); | 128 | _("Did not find mime type `%s' in extension list.\n"), mime); |
129 | else | 129 | else |
130 | ext = mimeMap[i][1]; | 130 | ext = mimeMap[i][1]; |
131 | GNUNET_free (mime); | 131 | GNUNET_free(mime); |
132 | } | 132 | } |
133 | base = | 133 | base = |
134 | GNUNET_CONTAINER_meta_data_get_first_by_types (md, | 134 | GNUNET_CONTAINER_meta_data_get_first_by_types(md, |
135 | EXTRACTOR_METATYPE_TITLE, | 135 | EXTRACTOR_METATYPE_TITLE, |
136 | EXTRACTOR_METATYPE_BOOK_TITLE, | 136 | EXTRACTOR_METATYPE_BOOK_TITLE, |
137 | EXTRACTOR_METATYPE_ORIGINAL_TITLE, | 137 | EXTRACTOR_METATYPE_ORIGINAL_TITLE, |
138 | EXTRACTOR_METATYPE_PACKAGE_NAME, | 138 | EXTRACTOR_METATYPE_PACKAGE_NAME, |
139 | EXTRACTOR_METATYPE_URL, | 139 | EXTRACTOR_METATYPE_URL, |
140 | EXTRACTOR_METATYPE_URI, | 140 | EXTRACTOR_METATYPE_URI, |
141 | EXTRACTOR_METATYPE_DESCRIPTION, | 141 | EXTRACTOR_METATYPE_DESCRIPTION, |
142 | EXTRACTOR_METATYPE_ISRC, | 142 | EXTRACTOR_METATYPE_ISRC, |
143 | EXTRACTOR_METATYPE_JOURNAL_NAME, | 143 | EXTRACTOR_METATYPE_JOURNAL_NAME, |
144 | EXTRACTOR_METATYPE_AUTHOR_NAME, | 144 | EXTRACTOR_METATYPE_AUTHOR_NAME, |
145 | EXTRACTOR_METATYPE_SUBJECT, | 145 | EXTRACTOR_METATYPE_SUBJECT, |
146 | EXTRACTOR_METATYPE_ALBUM, | 146 | EXTRACTOR_METATYPE_ALBUM, |
147 | EXTRACTOR_METATYPE_ARTIST, | 147 | EXTRACTOR_METATYPE_ARTIST, |
148 | EXTRACTOR_METATYPE_KEYWORDS, | 148 | EXTRACTOR_METATYPE_KEYWORDS, |
149 | EXTRACTOR_METATYPE_COMMENT, | 149 | EXTRACTOR_METATYPE_COMMENT, |
150 | EXTRACTOR_METATYPE_UNKNOWN, | 150 | EXTRACTOR_METATYPE_UNKNOWN, |
151 | -1); | 151 | -1); |
152 | if ((base == NULL) && (ext == NULL)) | 152 | if ((base == NULL) && (ext == NULL)) |
153 | return NULL; | 153 | return NULL; |
154 | if (base == NULL) | 154 | if (base == NULL) |
155 | return GNUNET_strdup (ext); | 155 | return GNUNET_strdup(ext); |
156 | if (ext == NULL) | 156 | if (ext == NULL) |
157 | return base; | 157 | return base; |
158 | GNUNET_asprintf (&ret, "%s%s", base, ext); | 158 | GNUNET_asprintf(&ret, "%s%s", base, ext); |
159 | GNUNET_free (base); | 159 | GNUNET_free(base); |
160 | return ret; | 160 | return ret; |
161 | } | 161 | } |
162 | 162 | ||