aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_misc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
commit502af2167f7c218366666ca4944bd7cc54b5b19a (patch)
treea91fec5cc9769d260640bd91c6633cb9cf395524 /src/fs/fs_misc.c
parent03af5a603b7cc53432249d5854cd412aa90dde0d (diff)
indentation
Diffstat (limited to 'src/fs/fs_misc.c')
-rw-r--r--src/fs/fs_misc.c99
1 files changed, 47 insertions, 52 deletions
diff --git a/src/fs/fs_misc.c b/src/fs/fs_misc.c
index 73dcd4e367..9fa86a5c46 100644
--- a/src/fs/fs_misc.c
+++ b/src/fs/fs_misc.c
@@ -35,7 +35,8 @@
* @return NULL if meta data is useless for suggesting a filename
*/
char *
-GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData *md)
+GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
+ *md)
{
static const char *mimeMap[][2] = {
{"application/bz2", ".bz2"},
@@ -65,12 +66,12 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData *md
{"application/x-xcf", ".xcf"},
{"application/x-xfig", ".xfig"},
{"application/zip", ".zip"},
-
+
{"audio/midi", ".midi"},
{"audio/mpeg", ".mp3"},
{"audio/real", ".rm"},
{"audio/x-wav", ".wav"},
-
+
{"image/gif", ".gif"},
{"image/jpeg", ".jpg"},
{"image/pcx", ".pcx"},
@@ -78,7 +79,7 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData *md
{"image/tiff", ".tiff"},
{"image/x-ms-bmp", ".bmp"},
{"image/x-xpixmap", ".xpm"},
-
+
{"text/css", ".css"},
{"text/html", ".html"},
{"text/plain", ".txt"},
@@ -93,7 +94,7 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData *md
{"text/x-perl", ".pl"},
{"text/x-python", ".py"},
{"text/x-tex", ".tex"},
-
+
{"video/avi", ".avi"},
{"video/mpeg", ".mpeg"},
{"video/quicktime", ".qt"},
@@ -108,56 +109,50 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData *md
const char *ext;
ret = GNUNET_CONTAINER_meta_data_get_by_type (md,
- EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
+ EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
if (ret != NULL)
- return ret;
+ return ret;
ext = NULL;
mime = GNUNET_CONTAINER_meta_data_get_by_type (md,
- EXTRACTOR_METATYPE_MIMETYPE);
+ EXTRACTOR_METATYPE_MIMETYPE);
if (mime != NULL)
- {
- i = 0;
- while ( (mimeMap[i][0] != NULL) &&
- (0 != strcmp (mime, mimeMap[i][0])))
- i++;
- if (mimeMap[i][1] == NULL)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG |
- GNUNET_ERROR_TYPE_BULK,
- _("Did not find mime type `%s' in extension list.\n"),
- mime);
- else
- ext = mimeMap[i][1];
- GNUNET_free (mime);
- }
+ {
+ i = 0;
+ while ((mimeMap[i][0] != NULL) && (0 != strcmp (mime, mimeMap[i][0])))
+ i++;
+ if (mimeMap[i][1] == NULL)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG |
+ GNUNET_ERROR_TYPE_BULK,
+ _("Did not find mime type `%s' in extension list.\n"), mime);
+ else
+ ext = mimeMap[i][1];
+ GNUNET_free (mime);
+ }
base = GNUNET_CONTAINER_meta_data_get_first_by_types (md,
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METATYPE_BOOK_TITLE,
- EXTRACTOR_METATYPE_ORIGINAL_TITLE,
- EXTRACTOR_METATYPE_PACKAGE_NAME,
- EXTRACTOR_METATYPE_URL,
- EXTRACTOR_METATYPE_URI,
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METATYPE_ISRC,
- EXTRACTOR_METATYPE_JOURNAL_NAME,
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METATYPE_ALBUM,
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METATYPE_UNKNOWN,
- -1);
- if ( (base == NULL) &&
- (ext == NULL) )
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METATYPE_BOOK_TITLE,
+ EXTRACTOR_METATYPE_ORIGINAL_TITLE,
+ EXTRACTOR_METATYPE_PACKAGE_NAME,
+ EXTRACTOR_METATYPE_URL,
+ EXTRACTOR_METATYPE_URI,
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METATYPE_ISRC,
+ EXTRACTOR_METATYPE_JOURNAL_NAME,
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METATYPE_ALBUM,
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METATYPE_UNKNOWN,
+ -1);
+ if ((base == NULL) && (ext == NULL))
return NULL;
if (base == NULL)
return GNUNET_strdup (ext);
if (ext == NULL)
return base;
- GNUNET_asprintf (&ret,
- "%s%s",
- base,
- ext);
+ GNUNET_asprintf (&ret, "%s%s", base, ext);
GNUNET_free (base);
return ret;
}
@@ -168,7 +163,7 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData *md
*/
unsigned int
GNUNET_FS_get_current_year ()
-{
+{
time_t tp;
struct tm *t;
@@ -195,18 +190,18 @@ GNUNET_FS_year_to_time (unsigned int year)
memset (&t, 0, sizeof (t));
if (year < 1900)
- {
- GNUNET_break (0);
- return GNUNET_TIME_absolute_get (); /* now */
- }
+ {
+ GNUNET_break (0);
+ return GNUNET_TIME_absolute_get (); /* now */
+ }
t.tm_year = year - 1900;
t.tm_mday = 1;
t.tm_mon = 1;
t.tm_wday = 1;
t.tm_yday = 1;
tp = mktime (&t);
- GNUNET_break (tp != (time_t) -1);
- ret.abs_value = tp * 1000LL; /* seconds to ms */
+ GNUNET_break (tp != (time_t) - 1);
+ ret.abs_value = tp * 1000LL; /* seconds to ms */
return ret;
}