summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-06 22:23:42 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-06 22:23:42 +0200
commite24c47988eb015184da876056911b58a24d2e616 (patch)
treebee17f3366b2645766f7af0fe8fba360c904823c
parent756ba064345609b739d6e5ef7d9a3bea74637e76 (diff)
indentation fixes
-rw-r--r--src/plugins/nsfe_extractor.c193
1 files changed, 101 insertions, 92 deletions
diff --git a/src/plugins/nsfe_extractor.c b/src/plugins/nsfe_extractor.c
index 2f6ab8b..36ba115 100644
--- a/src/plugins/nsfe_extractor.c
+++ b/src/plugins/nsfe_extractor.c
@@ -63,10 +63,10 @@ nsfeuint (const char *data)
int i;
for (i = 3; i > 0; i--)
- {
- value += (unsigned char) data[i];
- value *= 0x100;
- }
+ {
+ value += (unsigned char) data[i];
+ value *= 0x100;
+ }
value += (unsigned char) data[0];
return value;
}
@@ -82,14 +82,14 @@ nsfeuint (const char *data)
*/
static char *
nsfestring (const char *data,
- size_t size)
+ size_t size)
{
char *s;
size_t length;
length = 0;
while ( (length < size) &&
- (data[length] != '\0') )
+ (data[length] != '\0') )
length++;
if (NULL == (s = malloc (length + 1)))
return NULL;
@@ -105,7 +105,11 @@ nsfestring (const char *data,
* @param s metadata value as UTF8
* @param t metadata type to use
*/
-#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "nsfe", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return 1; } while (0)
+#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "nsfe", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) return 1; \
+} while (0)
/**
@@ -114,7 +118,12 @@ nsfestring (const char *data,
* @param s metadata value as UTF8, free at the end
* @param t metadata type to use
*/
-#define ADDF(s,t) do { if (0 != ec->proc (ec->cls, "nsfe", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) { free (s); return 1; } free (s); } while (0)
+#define ADDF(s,t) do { if (0 != ec->proc (ec->cls, "nsfe", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) { free (s); \
+ return 1; \
+ } free (s); } while (0)
/**
@@ -168,7 +177,7 @@ struct infochunk
*/
static int
info_extract (struct EXTRACTOR_ExtractContext *ec,
- uint32_t size)
+ uint32_t size)
{
void *data;
const struct infochunk *ichunk;
@@ -178,22 +187,22 @@ info_extract (struct EXTRACTOR_ExtractContext *ec,
return 0;
if ((ssize_t) size >
ec->read (ec->cls,
- &data,
- size))
+ &data,
+ size))
return 1;
ichunk = data;
if (0 != (ichunk->tvflags & DUAL_FLAG))
- {
- ADD ("PAL/NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- }
+ {
+ ADD ("PAL/NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
else
- {
- if (0 != (ichunk->tvflags & PAL_FLAG))
- ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- else
- ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- }
+ {
+ if (0 != (ichunk->tvflags & PAL_FLAG))
+ ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ else
+ ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
if (0 != (ichunk->chipflags & VRCVI_FLAG))
ADD ("VRCVI", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
@@ -209,19 +218,19 @@ info_extract (struct EXTRACTOR_ExtractContext *ec,
ADD ("Sunsoft FME-07", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
if (size < sizeof (struct infochunk))
- {
- ADD ("1", EXTRACTOR_METATYPE_SONG_COUNT);
- return 0;
- }
+ {
+ ADD ("1", EXTRACTOR_METATYPE_SONG_COUNT);
+ return 0;
+ }
snprintf (songs,
- sizeof (songs),
- "%d",
- ichunk->songs);
+ sizeof (songs),
+ "%d",
+ ichunk->songs);
ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT);
snprintf (songs,
- sizeof (songs),
- "%d",
- ichunk->firstsong);
+ sizeof (songs),
+ "%d",
+ ichunk->firstsong);
ADD (songs, EXTRACTOR_METATYPE_STARTING_SONG);
return 0;
}
@@ -236,7 +245,7 @@ info_extract (struct EXTRACTOR_ExtractContext *ec,
*/
static int
tlbl_extract (struct EXTRACTOR_ExtractContext *ec,
- uint32_t size)
+ uint32_t size)
{
char *title;
ssize_t left;
@@ -246,21 +255,21 @@ tlbl_extract (struct EXTRACTOR_ExtractContext *ec,
if ((ssize_t) size >
ec->read (ec->cls,
- &data,
- size))
+ &data,
+ size))
return 1;
cdata = data;
left = size;
while (left > 0)
- {
- title = nsfestring (&cdata[size - left], left);
- if (NULL == title)
- return 0;
- length = strlen (title) + 1;
- ADDF (title, EXTRACTOR_METATYPE_TITLE);
- left -= length;
- }
+ {
+ title = nsfestring (&cdata[size - left], left);
+ if (NULL == title)
+ return 0;
+ length = strlen (title) + 1;
+ ADDF (title, EXTRACTOR_METATYPE_TITLE);
+ left -= length;
+ }
return 0;
}
@@ -274,7 +283,7 @@ tlbl_extract (struct EXTRACTOR_ExtractContext *ec,
*/
static int
auth_extract (struct EXTRACTOR_ExtractContext *ec,
- uint32_t size)
+ uint32_t size)
{
char *album;
char *artist;
@@ -288,37 +297,37 @@ auth_extract (struct EXTRACTOR_ExtractContext *ec,
return 0;
if ((ssize_t) size >
ec->read (ec->cls,
- &data,
- size))
+ &data,
+ size))
return 1;
cdata = data;
album = nsfestring (&cdata[size - left], left);
if (NULL != album)
- {
- left -= (strlen (album) + 1);
- ADDF (album, EXTRACTOR_METATYPE_ALBUM);
- if (left < 1)
- return 0;
- }
+ {
+ left -= (strlen (album) + 1);
+ ADDF (album, EXTRACTOR_METATYPE_ALBUM);
+ if (left < 1)
+ return 0;
+ }
artist = nsfestring (&cdata[size - left], left);
if (NULL != artist)
- {
- left -= (strlen (artist) + 1);
- ADDF (artist, EXTRACTOR_METATYPE_ARTIST);
- if (left < 1)
- return 0;
- }
+ {
+ left -= (strlen (artist) + 1);
+ ADDF (artist, EXTRACTOR_METATYPE_ARTIST);
+ if (left < 1)
+ return 0;
+ }
copyright = nsfestring (&cdata[size - left], left);
if (NULL != copyright)
- {
- left -= (strlen (copyright) + 1);
- ADDF (copyright, EXTRACTOR_METATYPE_COPYRIGHT);
- if (left < 1)
- return 0;
- }
+ {
+ left -= (strlen (copyright) + 1);
+ ADDF (copyright, EXTRACTOR_METATYPE_COPYRIGHT);
+ if (left < 1)
+ return 0;
+ }
ripper = nsfestring (&cdata[size - left], left);
if (NULL != ripper)
ADDF (ripper, EXTRACTOR_METATYPE_RIPPER);
@@ -345,46 +354,46 @@ EXTRACTOR_nsfe_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ((ssize_t) sizeof (struct header) >
ec->read (ec->cls,
- &data,
- sizeof (struct header)))
+ &data,
+ sizeof (struct header)))
return;
head = data;
if (0 != memcmp (head->magicid, "NSFE", 4))
return;
if (0 != ec->proc (ec->cls,
- "nsfe",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-nsfe",
- strlen ("audio/x-nsfe") + 1))
+ "nsfe",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-nsfe",
+ strlen ("audio/x-nsfe") + 1))
return;
off = sizeof (struct header);
ret = 0;
while (0 == ret)
- {
- if (off != ec->seek (ec->cls,
- off,
- SEEK_SET))
- break;
- if (8 >
- ec->read (ec->cls,
- &data,
- 8))
- break;
- chunksize = nsfeuint (data);
- if (off + chunksize + 8LLU <= off)
- break; /* protect against looping */
- off += 8LLU + chunksize;
- if (0 == memcmp (data + 4, "INFO", 4))
- ret = info_extract (ec, chunksize);
- else if (0 == memcmp (data + 4, "auth", 4))
- ret = auth_extract (ec, chunksize);
- else if (0 == memcmp (data + 4, "tlbl", 4))
- ret = tlbl_extract (ec, chunksize);
- /* Ignored chunks: DATA, NEND, plst, time, fade, BANK */
- }
+ {
+ if (off != ec->seek (ec->cls,
+ off,
+ SEEK_SET))
+ break;
+ if (8 >
+ ec->read (ec->cls,
+ &data,
+ 8))
+ break;
+ chunksize = nsfeuint (data);
+ if (off + chunksize + 8LLU <= off)
+ break; /* protect against looping */
+ off += 8LLU + chunksize;
+ if (0 == memcmp (data + 4, "INFO", 4))
+ ret = info_extract (ec, chunksize);
+ else if (0 == memcmp (data + 4, "auth", 4))
+ ret = auth_extract (ec, chunksize);
+ else if (0 == memcmp (data + 4, "tlbl", 4))
+ ret = tlbl_extract (ec, chunksize);
+ /* Ignored chunks: DATA, NEND, plst, time, fade, BANK */
+ }
}
/* end of nsfe_extractor.c */